home *** CD-ROM | disk | FTP | other *** search
/ Freelog 42 / Freelog042.iso / Palm / Millikey / evplugbase / SRC / PLUGBASE.H
C/C++ Source or Header  |  1998-12-05  |  8KB  |  247 lines

  1. /*******************************************************************
  2.  *
  3.  *    Copyright (c) 1998, EVSoft co., Ltd., All Rights Reserved
  4.  *
  5.  *------------------------------------------------------------------
  6.  * FileName:
  7.  *        PlugBase.h
  8.  *
  9.  * Description:
  10.  *        Include file used by PlugBase plugins for PalmOS
  11.  *
  12.  *      Email:  gzevsoft@public.guangzhou.gd.cn
  13.  *
  14.  *      This file may be freely distributed.
  15.  *
  16.  * History:
  17.  *       9/20/98  - Created by Winter Du
  18.  *
  19.  *******************************************************************/
  20.  
  21. #ifndef __PLUG_BASE_H__
  22. #define __PLUG_BASE_H__
  23.  
  24. #include <Common.h>                // PalmPilot common definitions
  25. #include <SystemMgr.rh>            // Needed to create PlugBase Version Number
  26. #include <FeatureMgr.h>            // Needed to get the PlugBase API Pointer
  27.  
  28. #define    SupportHackMaster
  29.  
  30. /********************************************************************
  31.  * Type and creator of PlugBase database
  32.  ********************************************************************/
  33. #define    ApplResType                'appl'    //same as sysFileTApplication
  34. #define    CodeResType                'code'
  35.  
  36. #define    PlugBasePluginType        'PLUG'    // PlugBase plugin PRC type
  37. #define    PlugBaseCreator           'evPB'    // PlugBase app's creator
  38. #define    PlugBaseBigIconID        1000    // PlugBase big icon ID
  39. #define    PlugBaseSmallIconID        1001    // PlugBase small icon ID
  40.  
  41. #ifdef    SupportHackMaster
  42. #define    HackPluginType            'HACK'
  43. #define    HackPluginInfoFormID    3000
  44. #define    HackPluginIconStrID        3000
  45. #define    HackPluginConfigFormID    2000
  46. #define    HackPluginConfigCodeID    2000
  47. #define    HackMainFormID            9000
  48. #define    HackPluginTrapIDBegin    1000
  49.  
  50. #define    FormResType                'tFRM'
  51. #define    TRAPResType                'TRAP'
  52. #endif
  53.  
  54.  
  55. /********************************************************************
  56.  * Feature Number of PlugBase
  57.  ********************************************************************/
  58. #define    PBFtrNum_APIPtr        100
  59.  
  60.  
  61. // PlugBase VERSION
  62. //
  63. // The PlugBase version scheme follows the system versioning scheme.
  64. // See sysMakeROMVersion and friends in SystemMgr.h.
  65. //
  66. // For reference:
  67. //
  68. // 0xMMmfsbbb, where MM is major version, m is minor version
  69. // f is bug fix, s is stage: 3-release,2-beta,1-alpha,0-development,
  70. // bbb is build number for non-releases
  71. // V1.12b3   would be: 0x01122003
  72. // V2.00a2   would be: 0x02001002
  73. // V1.01     would be: 0x01013000
  74.  
  75. // V1.0b1
  76. #define PlugBaseVersion        sysMakeROMVersion(1, 0, 0, sysROMStageBeta, 1)
  77.  
  78. #define PlugBaseAPIVersion    1
  79.  
  80. /********************************************************************
  81.  * Public Structures
  82.  ********************************************************************/
  83.  
  84. enum ScreenAreaChoices {
  85.     applButton,
  86.     menuButton,
  87.     calcButton,
  88.     findButton,
  89.     screenArea,
  90.     graffitiArea,
  91.     graffitiLetterUpArea,
  92.     graffitiLetterDownArea,
  93.     graffitiNumberUpArea,
  94.     graffitiNumberDownArea,
  95.     disableSoftPenStroke,
  96.  
  97.     NumToAreaChoices,
  98.     NumFromAreaChoices = (findButton+1),
  99.     NumAreaChoices = NumToAreaChoices
  100. };
  101. typedef enum ScreenAreaChoices ScreenAreaType;
  102.  
  103. typedef enum {areaFrom, areaTo} AreaMode;
  104.  
  105. typedef struct tagSoftPenStrokeType {
  106. ULong            type;        // Type of application which install the SoftPenStroke
  107. ULong            creator;    // Creator of application which install the SoftPenStroke
  108. UInt            id;            // An application can install several SoftPenStroke,
  109.                             // each SoftPenStroke identified by this ID,
  110.                             // maybe 0..MAX UInt
  111. ScreenAreaType  penFrom;    // From Area
  112. ScreenAreaType  penTo;        // To Area
  113. } SoftPenStrokeType, *SoftPenStrokePtr;
  114.  
  115.  
  116. typedef struct tagHookTrapType {
  117. ULong            type;            // Type of application
  118. ULong            creator;        // Creator of application
  119. UInt            trapNum;        // Trap Number
  120. VoidPtr            newTrapAddr;    // New Trap address
  121. VoidPtr            oldTrapAddr;    // Return SysTrap address before hooked
  122. } HookTrapType, *HookTrapPtr;
  123.  
  124.  
  125. /********************************************************************
  126.  * API Prototypes
  127.  ********************************************************************/
  128. #ifdef __cplusplus
  129. extern "C" {
  130. #endif
  131.  
  132. typedef DWord    (*PBGetVersionPtr)    (void);
  133. typedef DWord    (*PBGetAPIVersionPtr) (void);
  134.  
  135. typedef Err      (*PBPluginEnablePtr)  (ULong type, ULong creator, Boolean enableIt);
  136. typedef Boolean  (*PBPluginEnabledPtr) (ULong type, ULong creator);
  137.  
  138. typedef Err      (*PBHookSysTrapPtr)   (HookTrapPtr trapP);
  139. typedef Err      (*PBUnhookSysTrapPtr) (HookTrapPtr trapP);
  140. typedef Boolean  (*PBSysTrapHookedPtr) (HookTrapPtr trapP);
  141.  
  142. typedef Err      (*PBInstallSoftPenStrokePtr)   (SoftPenStrokePtr psP);
  143. typedef Err      (*PBUninstallSoftPenStrokePtr) (SoftPenStrokePtr psP);
  144. typedef Err      (*PBGetSoftPenStrokePtr)       (SoftPenStrokePtr psP);
  145. typedef Boolean  (*PBCheckSoftPenStrokePtr)     (SoftPenStrokePtr psP, SoftPenStrokePtr psOccupiedByP);
  146. typedef CharPtr* (*PBGetSoftPenStrokeChoicesPtr)     (UIntPtr numItemsP, AreaMode areaMode, Boolean longDesc);
  147. typedef void     (*PBSetSoftPenStrokeListChoicesPtr) (ListPtr list,      AreaMode areaMode, Boolean longDesc);
  148.  
  149. #ifdef __cplusplus
  150. }
  151. #endif
  152.  
  153.  
  154. typedef struct {
  155.     PBGetVersionPtr                        getVersion;
  156.     PBGetAPIVersionPtr                    getAPIVersion;
  157.  
  158.     PBPluginEnablePtr                    pluginEnable;
  159.     PBPluginEnabledPtr                    pluginEnabled;
  160.     
  161.     PBHookSysTrapPtr                    hookSysTrap;
  162.     PBUnhookSysTrapPtr                    unhookSysTrap;
  163.     PBSysTrapHookedPtr                    sysTrapHooked;
  164.  
  165.     PBInstallSoftPenStrokePtr            installSoftPenStroke;
  166.     PBUninstallSoftPenStrokePtr            uninstallSoftPenStroke;
  167.     PBGetSoftPenStrokePtr                getSoftPenStroke;
  168.     PBCheckSoftPenStrokePtr                checkSoftPenStroke;
  169.     PBGetSoftPenStrokeChoicesPtr        getSoftPenStrokeChoices;
  170.     PBSetSoftPenStrokeListChoicesPtr    setSoftPenStrokeListChoices;
  171. } PlugBaseAPIType, *PlugBaseAPIPtr;
  172.  
  173. /************************************************************
  174.  * PlugBase result codes
  175.  *************************************************************/
  176. #define pbErrorClass                (appErrorClass+0x2000)
  177. #define pbErrInvalidParam            (pbErrorClass | 1)
  178. #define pbErrNotEnoughSpace            (pbErrorClass | 2)
  179. #define pbErrNotFound                (pbErrorClass | 3)
  180. #define pbErrNotValidPlugin            (pbErrorClass | 4)
  181. #define pbErrSoftPenStrokeUsed        (pbErrorClass | 5)
  182.  
  183. //------------------------------------------------------------------------
  184. // PlugBase Launch Command
  185. //------------------------------------------------------------------------
  186. //
  187. typedef enum {
  188.     PBLaunchCmd_GetInformation = sysAppLaunchCmdCustomBase+'PB',
  189.     PBLaunchCmd_PluginAttach,
  190.     PBLaunchCmd_PluginDetach,
  191.     PBLaunchCmd_ActivePluginInfoPanel,
  192.     PBLaunchCmd_ActivePluginControlPanel,
  193.     PBLaunchCmd_SoftPenStroke
  194. } PlugBaseLaunchCmds;
  195.  
  196.  
  197. //------------------------------------------------------------------------
  198. // Parameter blocks for Launch Command
  199. //------------------------------------------------------------------------
  200.  
  201. typedef struct {
  202.     ULong            id;                // Launch command identifier for PlugBase,
  203.                                     // seted to PlugBaseCreator['evPB']
  204.                                     // by PlugBase before launch
  205.     ULong            pluginType;        // Type of plugin PRC
  206.     ULong            pluginCreator;    // Creator of plugin PRC
  207.     PlugBaseAPIPtr    apiP;            // PlugBase API pointer
  208.     Err                err;            // error code, plugin must set this value after process
  209.                                     // 0 no error
  210.     union param {
  211.         struct allParam {
  212.             Word data[8];
  213.         } allParam;
  214.  
  215.         // For PBLaunchCmd_GetInformation
  216.         struct {
  217.             Boolean        supportInfoPanel;
  218.             Boolean        supportConfigPanel;
  219.         } getInformation;
  220.  
  221.         // For PBLaunchCmd_SoftPenStroke
  222.         struct {
  223.             UInt        id;
  224.         } softPenStroke;
  225.  
  226.     } data;
  227.  
  228. } PBLaunchParameterType, *PBLaunchParameterPtr;
  229.  
  230.  
  231. /********************************************************************
  232.  * Public Macros
  233.  ********************************************************************/
  234.  
  235. // Get PlugBase API pointer
  236. #define    PBGetAPIPtr(ptr)                                            \
  237. {                                                                    \
  238.     DWord    ftrRet;                                                    \
  239.                                                                     \
  240.     ptr = 0;                                                        \
  241.     if (FtrGet (PlugBaseCreator, PBFtrNum_APIPtr, &ftrRet) == 0)    \
  242.         ptr = (PlugBaseAPIPtr) ftrRet;                                \
  243. }
  244.  
  245. #endif    // __PLUG_BASE_H__
  246.  
  247.