DjView : FAQ
Info  FAQ  Source  Home 
 
So, currently there is only one frequently asked question, but it is asked frequently:
 
I transferred a DjVu file to my PDA but how do I open it?
 
[The following also relates to the same problem opening Calculon package files]
 
A file can be opened from DjView by tapping on the "document" icon (this is the icon that looks like a piece of paper at the bottom left of the screen). This icon opens up a file selection panel at the bottom of the screen that should look like this (see right).
 
If your document does not appear in the file selection panel (and you're sure you copied it onto the PDA!) then this problem relates to you. Read on.
 

Basically the "problem" is with Qtopia, not DjView. Qtopia uses the concept of mime-types to identify document types (the same method as is used for email attachments and downloadable internet content). A mime-type is a short text description that describes the file type in a fairly commonsense way. E.g. JPEG files are of type "image/jpeg" text files are "text/plain". The downside of this method is that you need somewhere to store what mime-type each file on the system is. Qtopia does this in two ways:
 
1. The file is located in a directory hierachy which reflects the mime-type. E.g. a text file held in internal storage will be in /home/root/Documents/text/plain/ or if it is on a CF card /mnt/cf/Documents/text/plain/.
 
2. For each file thus located there is an additional file with the same name but with the extension ".desktop" in the same directory. This .desktop file is a short text file which contains some information about the file itself, including the mime-type. The .desktop file for a plain text file called "test" might look like this:
[Desktop Entry]
Categories =
File = /usr/mnt.rom/cf/Documents/text/plain/test.txt
Name = test
Type = text/plain
The upshot of all this is that when you transfer a file to the PDA, it has to go into the right place and the .desktop file ought to be created. If you just copy the file onto a CF card and then stick the card in the PDA Qtopia will not know anything about your file, and it will not appear in the file selector for the appropriate program (this applies to all Qtopia programs which use the mime-type file selection system). [Note: in some cases you can get away without the .desktop file, but generally, you can't].
 
If you use the Qtopia Desktop to sync files to the PDA then this sorts things out automatically. However, the PDA and Qtopia Desktop do not know about all possible mime-types (this is fair enough, mime-types are meant to be extensible after all). When you install DjView (or Calculon) the required mime-types are registered with the PDA. However, Qtopia Desktop remains blissfully unaware of them - it needs to be told about them explicitly (see below). Otherwise it just transfers "unknown" files as "application/octet-stream" which is no use to anyone.
 
So now you understand the problem. What's the solution? A few are listed below, hopefully something will be of use. This page will probably be added to quite soon with some utilities or scripts to make working with files and mime-types a bit easier, so remember to check back.
 
Qtopia Desktop
 
This is how to add a mime-type to Qtopia Desktop. It relates to the Windows version (but the Linux version is probably the same).
 
Use the Windows Explorer to find the directory in which Qtopia Desktop is installed. E.g. this might well be C:/Program Files/Sharp/Qtopia Desktop. Go into the "etc" directory and there you will find a file called "mime.types". Click the right mouse button on this file and select Open With. Use WordPad (not NotePad) to open the file. This file is a list of the mime-types Qtopia Desktop knows about. Telling it about a new mime-type is as simple as adding a new line with the right details. To get Qtopia Desktop to sync DjVu files properly add the following line (either at the end of the file or in the right place alphabetically - I don't think it matters):
image/djvu       djv djvu   ; DjVuFile
What this is saying is that when you sync a file from Windows with the extention ".djv" or ".djvu" it should go onto the PDA as mime-type image/djvu.
 
If it is Calculon packages you want to sync then add this:
application/x-calculon       cpk   ; CalculonFile
Save the file, and restart Qtopia Desktop. The immediate way to tell if its working is if you sync a file over it should appear on the PDA (under the Documents tab) with the correct icon (i.e. not just the generic Qtopia File icon).
 
Start the program from the command-line
 
Not much of a solution for a PDA, but it works for some people. Both DjView and Calculon can be started from the command-line with the file to open as an argument. In this case none of the mime-type stuff matters at all.
 
Generate the .desktop file by hand
 
The format of the .desktop files is pretty straightforward, use the example above as a template (remember that the file itself and the .desktop file must also be under the correct directory hierachy).
 
Use a script to generate the .desktop file
 
The following is a Python script written by Konrad Hinsen to generate the .desktop files for files transferred over by ftp, CF card or similar. It looks up the file extension in the PDAs mime-type list and (if the extension is found) generates the .desktop file. It therefore works for any mime-types that have been registered on the PDA. To get it to work you need to have Python installed on your PDA (it isn't by default). I personally haven't tested it, so obviously use at your own risk (but it looks good to me - thanks Konrad).
#!/usr/bin/python
import os, string, sys

template = """[Desktop Entry]
Categories = 
File = %s
Name = %s 
Type = %s
"""

if len(sys.argv) != 3:
    print "Usage: mime-install document_file document_name"
    sys.exit(0)

document = sys.argv[1]
name = sys.argv[2]
base, extension = os.path.splitext(document)
if not extension:
    print "No extension"
    sys.exit(0)
extension = extension[1:]

mime_types = file('/home/QtPalmtop/etc/mime.types')
found = 0
while 1:
    type = mime_types.readline()
    type = string.split(type)
    ext = type[1:]
    type = type[0]
    if extension in ext:
        found = 1
        break
if not found:
    print "No MIME type for extension ", extension
    sys.exit(0)

dest = os.path.join('/home/root/Documents', type)
desktop = os.path.join(dest, os.path.split(base)[-1]+'.desktop')
desktop = file(desktop, 'w')
desktop.write(template % (os.path.abspath(document), name, type))
desktop.close()
Download this script as a file: mime-install.