Common Desktop Environment: Programmer's Overview

Data Typing

You can define data types when you perform basic integration for your application. This section focuses on a different aspect of data typing: extracting information from the actions and data-types database.

Data typing provides an extension to the attributes of files and data beyond what is provided by traditional UNIX file systems. These extensions include typing and attribute management. Use the data-typing API if your application receives data from external sources and must act on it. For example, your application might want to display an icon or execute an action that has a system-wide definition.

Data typing consist of two parts:

The data-typing system determines a type for a file or byte vector based on a set of criteria. These criteria include its name, permissions, symbolic link value, and contents. The attributes associated with a type describe its user-visible interfaces, including a description, the icon to represent it graphically, and the actions that apply to it. Attributes also exist that name the interchange formats to which the data conforms.

The Common Desktop Environment File Manager and Common Desktop Environment Mail attachment window use data typing to determine the icon and actions associated with a file. For example, for a C file filename.c, File Manager uses the .c extension to determine the file's data type, C_SOURCE. It then uses C_SOURCE to determine the icon file name for the icon that it can use for filename.c.

Database Loading

This section discusses the loading API for the actions and data-types database. The syntax for this and any Common Desktop Environment databases a developer defines is discussed in man pages in the /usr/dt/man/man4 directory.

The external database loading API consists of two functions:

DtDbLoad() reads in the actions and data-types database. It determines the set of directories that are searched for database files, and it loads into the database the .dt files that are found. Your application must call DtDbLoad() before calling any of the routines that query the actions and data-types database.

Use DtDbReLoadNotify() to request notification of actions and data-types database reload events. It registers an application's interest in database reload messages.

Your application should reload the database whenever it changes, so that the end user will notice updates without having to restart the application.

Database Queries

To look up an attribute for a data object, you must first determine the type of the object and then ask for the appropriate attribute value for that type. The database query functions enable you to perform operations such as retrieve type data and attributes, free memory, and load and unload the database. These functions are documented in the Solaris Common Desktop Environment: Programmer's Guide and also in man pages in the man3 directory.

Library and Header Files

The Desktop Services library, libDtSvc, provides access to many desktop APIs, including that for data typing. Include the Dt/Dt.h and Dt/Dts.h header files to access the data-typing API.


Note -

If your application uses any of the data-typing APIs, or loads the actions and data-types database, it must first initialize the libDtSvc library by calling either DtInitialize() or DtAppInitialize(). Refer to the DtInitialize(3) or DtAppInitialize(3) man page for more information.


Demo Programs

You can find the data typing demos in /usr/dt/examples/dtdts. Read the README file for detailed information on the demos.

Related Documentation

For more information on data typing, see the relevant man pages and the Solaris Common Desktop Environment: Programmer's Guide.