Last updated: September 30, 1999
This document details how you can support iKnapsack in your applications. The code below makes
use of the FS_iKnapsack_API.h header file, contained in the iKnapsack SDK.
Here are a few examples of what you can do with the iKnapsack API. Items in red
denote constants and definitions defined with the FS_iKnapsack_API.h header file.
Opening URLs with iKnapsack
iKnapsack allows users to define a default web browser on their Palm organizer.
Using the iKnapsack launch code sysAppLaunchCmdGoToURL, you can
have a menu item entitled "Visit Web Site" that launches the default browser to your web site.
Use the OpenURL routine below to implement opening URLs in your application with iKnapsack.
static void OpenURL(CharPtr origUrl)
{
DmSearchStateType searchState;
UInt cardNo;
LocalID dbID;
Err err;
CharPtr url;
Int len;
DWord result = 0;
// Find the iKnapsack application
err = DmGetNextDatabaseByTypeCreator(true, &searchState, sysFileTApplication, iKnapsackFileCreator,
true, &cardNo, &dbID);
if(!err) {
// Copy the URL-string
len = StrLen(origUrl) + 1;
url = MemPtrNew(len);
MemMove(url, origUrl, len);
// Lock the pointer to the URL-string
MemPtrSetOwner(url, 0);
// Instruct iKnapsack to open the default web browser to the specified url
err = SysAppLaunch(cardNo, dbID, 0, sysAppLaunchCmdGoToURL, url, &result);
}
else {
// iKnapsack could not be found
}
}
Sending Email with iKnapsack
iKnapsack allows users to define a default email client on their Palm organizer.
Using the iKnapsack launch code iKnapsackAppLaunchCmdEmail, you can
have a menu item entitled "Send Feedback" that launches the default email client with a pre-defined
message. Use the SendMail routine below to implement sending email in your application with iKnapsack.
static void SendMail(CharPtr to, CharPtr subject, CharPtr body)
{
iKnapsackEmailPtr message;
DmSearchStateType searchState;
UInt cardNo;
LocalID dbID;
Err err;
DWord result = 0;
// Find the iKnapsack application
err = DmGetNextDatabaseByTypeCreator(true, &searchState, sysFileTApplication, iKnapsackFileCreator,
true, &cardNo, &dbID);
if(!err) {
message = MemPtrNew(sizeof(iKnapsackEmailType));
// Copy the message recipient
message->to = MemPtrNew(StrLen(to) + 1);
MemMove(message->to, to, StrLen(to) + 1);
// Copy the message subject
message->subject = MemPtrNew(StrLen(subject) + 1);
MemMove(message->subject, subject, StrLen(subject) + 1);
// Copy the message body
message->body = MemPtrNew(StrLen(body) + 1);
MemMove(message->body, body, StrLen(body) + 1);
// Lock the pointer to the URL-string
MemPtrSetOwner(message, 0);
// Instruct iKnapsack to send a new email message to the default email client
err = SysAppLaunch(cardNo, dbID, 0, iKnapsackAppLaunchCmdEmail, (Char *) message, &result);
}
else {
// iKnapsack could not be found
}
}
Copyright © 1995-2008, tow.com. All Rights Reserved. Terms of Use
Tomorrow begins today.