Ramel Levin wrote:
>I want to beam an application from my app to the built in launcher app.
Can
>you show me an example of how to build the ExgSocket?
Sure. This needs to be added to a FAQ.
You need the ExgDBWrite function. This allows you to send any database
directly to the launcher on another device without requiring your app to be
there. In this example the app actually beams itself. This is the correct
way to beam a file that you see on the desktop as a .prc or .pdb file.
--- Gavin
/***********************************************************************
*
* FUNCTION: WriteDBData
*
* DESCRIPTION: Callback for ExgDBWrite to send data with exchange manager
*
* PARAMETERS: dataP : buffer containing data to send
* sizeP : number of bytes to send
* userDataP: app defined buffer for context
( (holds exgSocket when using ExgManager)
*
* RETURNED: error if non-zero
*
***********************************************************************/
static Err WriteDBData(const void* dataP, ULong* 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;
}
/***********************************************************************
*
* FUNCTION: SendDatabase
*
* DESCRIPTION: Sends data in the input field using the Exg API
*
* PARAMETERS: cardNo: card number of db to send (usually 0)
* dbID: databaseId of database to send
* nameP: public filename for this database
* This is the name as it appears on a PC file
listing
* It should end with a .prc or .pdb extension
* description: Optional text description of db to show to
user
* who receives the database.
*
* RETURNED: error code or zero for no error.
*
***************************************************************************
/
static Err SendDatabase (Word cardNo, LocalID dbID, CharPtr nameP, CharPtr
descriptionP)
{
ExgSocketType exgSocket;
Err err;
// Create exgSocket structure
MemSet(&exgSocket, sizeof(exgSocket), 0);
exgSocket.description = descriptionP;
exgSocket.name = nameP;
// Start and 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;
}
/***********************************************************************
*
* FUNCTION: SendMe
*
* DESCRIPTION: Sends this application
*
* PARAMETERS: none
*
* RETURNED: error code or zero for no error.
*
***************************************************************************
/
static Err SendMe(void)
{
Err err;
// Find our app using its internal name
LocalID dbID = DmFindDatabase(0, "Beamer");
if (dbID) // send it giving external name and description
err = SendDatabase(0, dbID, "Beamer.prc", "Beamer application");
else
err = DmGetLastErr();
return err;
}