This document details how to write an iKnapsack Plug-in. The process of developing a plug-in is broken down into four steps:
The first step in learning how to write iKnapsack Plug-ins is to download the Starter iKnapsack Plug-in project. This is a project compiled in CodeWarrior for Palm Computing Platform, Release 5.
The project contains the following files:
An iKnapsack Plug-in is a PalmOS Code Resource instead of the more common PalmOS Application.
The 68K Target Pane in the Starter Plug-in Settings Dialog Box of CodeWarrior
The primary advantage to this is that your plug-in does not appear in the Launcher and is generally smaller than a typical Palm OS application.
A Creator ID is a four-character code that uniquely identifies your product to the Palm OS. Each plug-in has a unique Creator ID which is used by web sites and Palm applications to instruct the iKnapsack application as to which iKnapsack Plug-in to use. For instance, the Creator ID's for the plug-ins that come with iKnapsack include:
When creating your own plug-ins, you must assign them a Creator ID and register that ID with Palm Computing at: http://oasis.palm.com/devzone/creatorid/. You can search for existing Creator ID's on that site as well.
In the "Starter Plug-in.c" file, there is a function called PlugInMain. This is the main routine for your iKnapsack Plug-in and is called whenever there is a request to process data with your plug-in.
Err PluginMain(PluginParamBlockPtr PluginParamsP)
ParametersPlugInMain receives one parameter, a pointer to a
typedef struct {
CharPtr url;
VoidPtr other;
Int mode;
DWord d1;
DWord d2;
} PluginParamBlockType;
Each parameter in the url other mode d1 and d2 |
Return TypePlugInMain should return 0 if there was no error or non-zero if there was an error. If you handled an error in your plug-in and alerted the user, you should return 0. Otherwise, iKnapsack will display the alert on the right to the user.
|
Here is a the PlugInMain routine from our Starter iKnapsack Plug-in project.
/*********************************************************************** * * FUNCTION: PluginMain * * DESCRIPTION: Your function that handles a Plug-in call from * iKnapsack. * * PARAMETERS: The parameters of PluginParamsP: * * url - the url-string containing data * other - developer-specific information * mode - 0 = Run * 1 = Config * anything else = Developer Specific * * RETURNED: 0 - Success or Error Handled by Plugin * non-zero - iKnapsack will report the error to the user * * ***********************************************************************/ Err PluginMain(PluginParamBlockPtr PluginParamsP) { Err err = 0; switch(PluginParamsP->mode) { case kPluginModeRun: // Mode = 0 // Your code to handle the plug-in request // Data is stored in PluginParamsP->url break; case kPluginModeConfig: // Mode = 1 // Your code to handle the plug-in config request // If you Plugin does not have a configuration panel, // alert the user. FrmAlert(NoConfigAlert); break; default: break; } return err; }
![]() View your information dialog by selecting your plug-in and tapping Info. The form which appears has the ID 5000 and is created in Constructor for Palm OS. ![]() Display parameter and usage information in the Help string for your information dialog |
Every iKnapsack Plug-in must have an information screen which is displayed when the user selects Info on your iKnapsack in the Plug-ins form. This form has an ID of 5000 and is invoked by FrmDoDialog so it must contain a button that will exit the dialog.
It is a good idea to associate a Help String with your Information Dialog. You can place parameter and usage information in this resource.
The next to last step in creating your iKnapsack Plug-in is the funnest, and the most difficult: Processing the data! It's easy to get data to your Plug-in, but converting it into something your code can deal with can be a hassle. Fortunately, we have many of the pieces coded for you.
Use the routines in the FS_Web.c and FS_Web.h source files to assist you in parsing parameters, converting between the Palm OS and Internet Date and Time formats and more.
More information on parsing data is forthcoming.
Your Plug-in is finished! Now, build the project and install it onto your device or the Palm OS Emulator. Note that you won't be able to debug your project since it is a Code Resource. You may want to build your project as an application and then later convert it into a Plug-in.
Copyright © 1995-2008, tow.com. All Rights Reserved. Terms of Use
Tomorrow begins today.