>So I guess that I should only allow db's to be tap-launched if the
>dmHdrAttrLaunchableData flag is set. But should I open them with
>sysAppLaunchCmdOpenNamedDB or sysAppLaunchCmdOpenDB? Should any open-saavy
>app support BOTH of these launch codes?
There's no such thing as sysAppLaunchCmdOpenNamedDB no matter what
DataMgr.h says :-) So just the sysAppLaunchCmdOpenDB is the one to use.
Here's a code snippet that shows the way to launch a launchable-data
database. (Warning: I haven't compiled this, but it was based on code that
runs correctly...)
What the owning app should do will be straightforward; look for the OpenDB
launch cmd, cast the pointer to SysApLaunchCmdOpenDBType, use the data, and
remember to not free the cmdPBP block since the system will do it for you
once the owning app quits.
-David Fedor
Palm Developer Support
// define some things in case we're using old headers...
#ifndef SysAppLaunchCmdOpenDBType
typedef struct {
Word cardNo;
LocalID dbID;
} SysAppLaunchCmdOpenDBType;
#define sysAppLaunchCmdOpenDB 52
#endif
Err LaunchTheDocument(Word documentCardNo, LocalID documentDbID, ULong documentCreator)
{
void *cmdPBP;
// Create the param block
cmdPBP = MemPtrNew(sizeof(SysAppLaunchCmdOpenDBType));
if (!cmdPBP) {
err = memErrNotEnoughSpace;
goto Exit;
}
// Fill it in
MemPtrSetOwner (cmdPBP, 0);
cmdPBP->cardNo = documentCardNo;
cmdPBP->dbID = documentDbID;
// Find the owner app for this document
err = DmGetNextDatabaseByTypeCreator (true, &searchState,
sysFileTApplication, documentCreator,
true, &cardNo, &dbID);
ErrNonFatalDisplayIf(err, "owner app not found");
if (err) goto Exit;
// Switch to it
SysUIAppSwitch (cardNo, dbID, sysAppLaunchCmdOpenDB, (Ptr)cmdPBP);
Exit:
return err;
}