While I'm not completely sure I understand your question, one thing
that your code didn't seem to indicate is whether there's a .prc or
.pdb extension on the "filename". Without that, or any MIME
information, the receiving device has no idea what kind of data it
has been sent (e.g. text file, PRC, bitmap, vcard...) and will
presumably give an error message.
If your app isn't on the other device, and you want the database to
just be dropped in memory, then you shouldn't specify your creator
ID. Just fill in the "name" field with "whatever.prc" and give a
nice description in the description field since that's what the user
will see in the progress dialog. That's all that is strictly
necessary, assuming you've done a MemSet to set everything else to
zero. When the data gets there, the exchange manager will see the
".prc" extension and save the incoming data as a database.
Here's some code that I know works for an app to send itself. You're
not beaming your app, so the logic inside SendMe to get a
user-friendly name won't apply to you, but I'm including it for the
archive's sake :-)
static Err WriteDBData(const void* dataP, UInt32* sizeP, void* userDataP)
{
Err err;
// Try to send as many bytes as were requested by the caller
*sizeP = ExgSend((ExgSocketPtr)userDataP, (void*)dataP, *sizeP, &err);
return err;
}
static Err SendDatabase (UInt16 cardNo, LocalID dbID, char *nameP,
char *descriptionP)
{
ExgSocketType exgSocket;
Err err;
// Create exgSocket structure
MemSet(&exgSocket, sizeof(exgSocket), 0);
exgSocket.description = descriptionP;
exgSocket.name = nameP;
// Start an exchange put operation
err = ExgPut(&exgSocket);
if (!err)
{
// This function converts a palm database into its external (public)
// format. The first parameter is a callback that will be
passed parts of
// the database to send or write.
err = ExgDBWrite(WriteDBData, &exgSocket, NULL, dbID, cardNo);
// Disconnect Exg and pass error
err = ExgDisconnect(&exgSocket, err);
}
return err;
}
static void SendMe(void)
{
Err err;
LocalID dbID;
UInt16 cardNo;
char dbname[40];
char prcname[40];
char *nicename;
MemHandle tainH;
// get the user-friendly name of the app from the 'tain' string,
or else use the db name as a last resort
tainH = DmGetResource(ainRsc, appVersionID);
if (!tainH)
tainH = DmGetResource(ainRsc, appVersionAlternateID);
if (tainH)
nicename = (char *) MemHandleLock(tainH);
else
nicename = (char *) dbname;
if (0==SysCurAppDatabase(&cardNo, &dbID)) {
DmDatabaseInfo(cardNo, dbID, dbname, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
StrCopy(prcname, dbname);
StrCat(prcname, ".prc");
err = SendDatabase(0, dbID, prcname, nicename);
}
if (tainH)
MemHandleUnlock(tainH);
}
-David Fedor
PalmSource, Inc.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/