Applications and Geodes: 2.1 Creating Icons: The Token Database

Up: GEOS SDK TechDocs | Up | Prev: 2 Creating Icons | Next: 2.2 Managing the Token Database File
TokenOpenLocalTokenDB(), TokenCloseLocalTokenDB()

The token database is stored in its own file. Each entry represents a single icon or series of icons that can be used with any number of files. The token database file is managed by the UI and the kernel; you should have no reason to access its internals directly, and most applications will never need to use any of the token routines except to install their document icons.

Some systems may have shared token database files; this is controlled by the INI file key sharedTokenDatabase in the paths category. Most often a shared database file exists on a network drive and may be supplemented with a local token database. By default, if a shared database file exists, it will be opened read-only in addition to the read/write local file. You can open and close only the local database file, however, with the routines TokenOpenLocalTokenDB() and TokenCloseLocalTokenDB() .

Every GEOS file has a token. The token is an index into the token database. When GeoManager scans a directory, it grabs the token from each file and searches through the token database file for it. If a match is found, GeoManager selects the proper icon and displays it; if no match is found or if the file's token is invalid, GeoManager will launch the application in engine mode and request that it install its token in the database.

For non-GEOS files, GeoManager uses the three extension characters of the file's name as a pseudo-index. For each extension (e.g. .COM, .EXE, .DOC, .BAT, etc.), GeoManager uses a single icon. Which icon is used can be set in the GEOS.INI file if a user wishes, but GeoManager will normally select the default DOS icon (of which there are two: one for executables and one for non-executables).

The index into the token database consists of two parts and is of type GeodeToken . This structure contains four text characters as well as the manufacturer ID number of the geode's manufacturer. The structure's definition is shown below:

typedef struct {
    TokenChars				GT_chars;
    ManufacturerID				GT_manufID;
} GeodeToken;
typedef char TokenChars[TOKEN_CHARS_LENGTH];

This structure is created and filled automatically in the geode's .geo file header by the Glue linker, which takes the values from the geode's geode parameters ( .gp ) file. The two fields used from the .gp file are tokenchars for the four characters and tokenid for the manufacturer ID.

A GeodeToken structure in the token database file can also be filled in when GeoManager scans a directory. If the header of a particular application's .geo file does not have a recognized token, GeoManager will launch the application in "engine" mode, loading its GenApplication object. It will request that the application object then install its icon into the token database file ( GenApplicationClass knows how to do this).

The token database file contains one entry for each token that has been installed. Each time a new token and icon is encountered, a new entry is added by the UI. This happens automatically when GeoManager scans a directory.


Up: GEOS SDK TechDocs | Up | Prev: 2 Creating Icons | Next: 2.2 Managing the Token Database File