home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / linkmaster-src-1.0.4.tar.gz / linkmaster-src-1.0.4.tar / linkmaster-1.0.4 / proxy / db / Datebook.h < prev    next >
C/C++ Source or Header  |  2000-09-05  |  13KB  |  387 lines

  1. /***********************************************************************
  2.  *
  3.  Copyright ⌐ 1995 - 1998, 3Com Corporation or its subsidiaries ("3Com").  
  4.  All rights reserved.
  5.    
  6.  This software may be copied and used solely for developing products for 
  7.  the Palm Computing platform and for archival and backup purposes.  Except 
  8.  for the foregoing, no part of this software may be reproduced or transmitted 
  9.  in any form or by any means or used to make any derivative work (such as 
  10.  translation, transformation or adaptation) without express written consent 
  11.  from 3Com.
  12.  
  13.  3Com reserves the right to revise this software and to make changes in content 
  14.  from time to time without obligation on the part of 3Com to provide notification 
  15.  of such revision or changes.  
  16.  3COM MAKES NO REPRESENTATIONS OR WARRANTIES THAT THE SOFTWARE IS FREE OF ERRORS 
  17.  OR THAT THE SOFTWARE IS SUITABLE FOR YOUR USE.  THE SOFTWARE IS PROVIDED ON AN 
  18.  "AS IS" BASIS.  3COM MAKES NO WARRANTIES, TERMS OR CONDITIONS, EXPRESS OR IMPLIED, 
  19.  EITHER IN FACT OR BY OPERATION OF LAW, STATUTORY OR OTHERWISE, INCLUDING WARRANTIES, 
  20.  TERMS, OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND 
  21.  SATISFACTORY QUALITY.
  22.  
  23.  TO THE FULL EXTENT ALLOWED BY LAW, 3COM ALSO EXCLUDES FOR ITSELF AND ITS SUPPLIERS 
  24.  ANY LIABILITY, WHETHER BASED IN CONTRACT OR TORT (INCLUDING NEGLIGENCE), FOR 
  25.  DIRECT, INCIDENTAL, CONSEQUENTIAL, INDIRECT, SPECIAL, OR PUNITIVE DAMAGES OF 
  26.  ANY KIND, OR FOR LOSS OF REVENUE OR PROFITS, LOSS OF BUSINESS, LOSS OF INFORMATION 
  27.  OR DATA, OR OTHER FINANCIAL LOSS ARISING OUT OF OR IN CONNECTION WITH THIS SOFTWARE, 
  28.  EVEN IF 3COM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  29.  
  30.  3Com, HotSync, Palm Computing, and Graffiti are registered trademarks, and 
  31.  Palm III and Palm OS are trademarks of 3Com Corporation or its subsidiaries.
  32.  
  33.  IF THIS SOFTWARE IS PROVIDED ON A COMPACT DISK, THE OTHER SOFTWARE AND 
  34.  DOCUMENTATION ON THE COMPACT DISK ARE SUBJECT TO THE LICENSE AGREEMENT 
  35.  ACCOMPANYING THE COMPACT DISK.
  36.  
  37.  *****************************************************************************
  38.  *
  39.  * PROJECT:  Touchdown
  40.  * FILE:     Datebook.h
  41.  * AUTHOR:     Art Lamb: August 10, 1995
  42.  *
  43.  * DECLARER: Datebook
  44.  *
  45.  * DESCRIPTION:
  46.  *      This file defines the Datebook's Main modual's functions anf globals.
  47.  *
  48.  * REVISION HISTORY:
  49.  *            Name        Date        Description
  50.  *            ----        ----        -----------
  51.  *            frigino    9/9/97    Moved DatebookPreferenceType into here
  52.  *
  53.  ***********************************************************************/
  54.  
  55. #include <ImcUtils.h>
  56. #include <ExgMgr.h>
  57. #include <CharAttr.h>
  58.  
  59. #include "DateDB.h"
  60. #include "DateAlarm.h"
  61. #include "DateDisplay.h"
  62. #include "DatePref.h"
  63. #include "DateWeek.h"
  64. #include "DateMonth.h"
  65. #include "DateTransfer.h"
  66. #include "DatebookRsc.h"
  67.  
  68.  
  69. /***********************************************************************
  70.  *
  71.  *    Constants
  72.  *
  73.  ***********************************************************************/
  74. #define noRecordSelected                -1
  75. #define maxDescSize                        256
  76.  
  77. // Length of verious  
  78. #define maxFrequenceFieldLen            3
  79. #define defaultRepeatDecsLen            32
  80. #define maxAdvanceFieldLen                3
  81.  
  82.  
  83. #define datebookDBType                    'DATA'
  84.  
  85. // Feature numbers used by the datebook
  86. #define alarmsFeatureNum                0        // List of pending alarms
  87.  
  88. #define datebookVersionNum                3
  89. #define datebookPrefsVersionNum        3
  90. #define datebookPrefID                    0x00
  91. #define datebookDBName                    "DatebookDB"
  92.  
  93. // Column in the to do table on the day view.
  94. #define timeBarColumn                    0
  95. #define timeColumn                        1
  96. #define descColumn                        2
  97.  
  98. #define spaceAfterTimeBarColumn        0
  99. #define spaceAfterTimeColumn            2
  100.  
  101. #define newEventSize                      16
  102. #define maxNoteTitleLen                    40
  103.  
  104. // Update codes, used to determine how the to do day view should 
  105. // be redrawn.
  106. #define updateRedrawAll                    0x00
  107. #define updateItemDelete                0x01
  108. #define updateItemHide                    0x02
  109. #define updateDateChanged                0x04
  110. #define updateTimeChanged                0x08
  111. #define updateException                    0x10
  112. #define updateRepeatChanged            0x20
  113. #define updateDisplayOptsChanged        0x40
  114. #define updateAlarmChanged                0x80
  115. #define updateFontChanged                0x100
  116.  
  117. // Fonts used by application
  118. #define apptTimeFont                     stdFont
  119. #define apptEmptyDescFont                stdFont
  120. #define noteTitleFont                    boldFont
  121.  
  122.  
  123. // Token strings in repeating event description template.
  124. #define frequenceToken                    "^f"
  125. #define dayOrdinalToken                    "^x"
  126. #define weekOrdinalToken                "^w"
  127. #define monthNameToken                    "^m"
  128. #define dayNameToken                        "^d"
  129.  
  130. // Default setting for the Details Dialog.
  131. #define defaultAlarmAdvance            5
  132. #define defaultAdvanceUnit                aauMinutes
  133.  
  134. // Default setting for the Repeating Events Dialog.
  135. #define defaultRepeatFrequency        1
  136. #define defaultRepeatEndDate            -1
  137.  
  138. // Repeat dialog "end on" popup list items.
  139. #define repeatNoEndDateItem            0
  140. #define repeatChooseDateItem            1
  141.  
  142. // End Date popup list chooses
  143. #define noEndDateItem                    0
  144. #define selectEndDateItem                1
  145.  
  146. #define emptySlot                            -1
  147.  
  148. // Field numbers used the id where search string was found
  149. #define descSeacrchFieldNum            0
  150. #define noteSeacrchFieldNum            1
  151.  
  152. // Preference Dialog.
  153. #define dayRangeTimeWidth                50
  154. #define dayRangeTimeHeight                13
  155.  
  156. // Latest time
  157. #define maxHours                            23
  158. #define maxMinutes                        55
  159.  
  160. // Time bars
  161. #define maxTimeBarColumns                5
  162. #define timeBarWidth                        2
  163.  
  164. // The duration to display the current time when the title of the 
  165. // Day View is pressed. 
  166. #define timeDisplayTicks             150        // 2 1/2 seconds
  167.  
  168.  
  169. // Default databook app preference values
  170. #define defaultDayStartHour                    (8)
  171. #define defaultDayEndHour                        (18)
  172. #define defaultAlarmPresetAdvance            (apptNoAlarm)
  173. #define defaultAlarmPresetUnit                (aauMinutes)
  174. #define defaultNoteFont                            (stdFont)
  175. #define defaultSaveBackup                        (true)
  176. #define defaultShowTimeBars                    (true)
  177. #define defaultCompressDayView                (true)
  178. #define defaultShowTimedAppts                    (true)
  179. #define defaultShowUntimedAppts                (false)
  180. #define defaultShowDailyRepeatingAppts        (false)
  181. #define defaultAlarmSoundRepeatCount        (3)
  182. #define defaultAlarmSoundRepeatInterval    (300)
  183. #define defaultAlarmSoundUniqueRecID        (0)
  184. #define defaultApptDescFont                    (stdFont)
  185.  
  186.  
  187. // Rom Incompatible Alert
  188. #define RomIncompatibleAlert            1001
  189.  
  190.  
  191. /***********************************************************************
  192.  *
  193.  *    Far calls
  194.  *
  195.  ***********************************************************************/
  196. typedef struct {
  197.     void         (*apptGetAppointments)     (DmOpenRef dbP, DateType date, Word days,VoidHand apptLists [], UInt counts []);
  198.     Err        (*apptGetRecord)            (DmOpenRef dbP, UInt index, ApptDBRecordPtr r, VoidHand * handleP); 
  199.     Boolean    (*apptFindFirst)            (DmOpenRef dbP, DateType date, UIntPtr indexP);
  200.     Boolean    (*apptNextRepeat)            (ApptDBRecordPtr apptRec, DatePtr dateP);
  201.     Err         (*apptNewRecord)            (DmOpenRef dbP, ApptDBRecordPtr r, UInt *index);
  202.      Err         (*moveEvent)                (WordPtr recordNumP, TimeType startTime, TimeType endTime, DateType date, Boolean splitEvent, BooleanPtr moved);
  203.      Boolean    (*preferencesHandleEvent)    (EventPtr event);
  204.      void        (*alarmReset)                    (Boolean newerOnly);
  205.      void        (*rescheduleAlarms)            (DmOpenRef dbP);
  206.      void        (*displayAlarm)                (void);
  207. } FarCallsType;
  208.  
  209.  
  210. extern FarCallsType    FarCalls;
  211.  
  212. #define ApptGetAppointmentsFar            (*FarCalls.apptGetAppointments)
  213. #define ApptGetRecordFar                    (*FarCalls.apptGetRecord)
  214. #define ApptFindFirstFar                    (*FarCalls.apptFindFirst)
  215. #define ApptNextRepeatFar                    (*FarCalls.apptNextRepeat)
  216. #define ApptNewRecordFar                    (*FarCalls.apptNewRecord)
  217. #define MoveEventFar                            (*FarCalls.moveEvent)
  218. #define PreferencesHandleEventFar        (*FarCalls.preferencesHandleEvent)
  219. #define AlarmResetFar                        (*FarCalls.alarmReset)
  220. #define RescheduleAlarmsFar                (*FarCalls.rescheduleAlarms)
  221. #define DisplayAlarmFar                        (*FarCalls.displayAlarm)
  222.  
  223. /***********************************************************************
  224.  *
  225.  *    Datebook prefs structure
  226.  *
  227.  ***********************************************************************/
  228.  
  229. // This is the structure of the data that's saved to the state file.
  230. typedef struct {
  231.     Word                    dayStartHour;
  232.     Word                    dayEndHour;
  233.     AlarmInfoType        alarmPreset;
  234.     FontID                v20NoteFont;        // Changed for 2.0 compatibility (BGT)
  235.     Boolean                saveBackup;
  236.     Boolean                showTimeBars;
  237.     Boolean                compressDayView;
  238.     Boolean                showTimedAppts;
  239.     Boolean                showUntimedAppts;
  240.     Boolean                showDailyRepeatingAppts;
  241.     
  242.     // Version 3 preferences
  243.     UInt                     alarmSoundRepeatCount;
  244.     UInt                     alarmSoundRepeatInterval;
  245.     ULong                    alarmSoundUniqueRecID;
  246.     FontID                apptDescFont;
  247.     FontID                noteFont;        // Changed for 2.0 compatibility (BGT)
  248. } DatebookPreferenceType;
  249.  
  250.  
  251. /***********************************************************************
  252.  *
  253.  *    Global variables
  254.  *
  255.  ***********************************************************************/
  256. extern DmOpenRef                ApptDB;                        // datebook database
  257.  
  258. extern    DateType                Date;                            // date currently displayed
  259. extern    Word                    StartDayOfWeek;
  260. extern    Word                    DayStartHour;                // start of the day 8:00am
  261. extern    Word                    DayEndHour;                    // end of the day 6:00pm
  262.  
  263. extern    TimeFormatType        TimeFormat;
  264. extern    DateFormatType        LongDateFormat;            // system preference
  265. extern     DateFormatType        ShortDateFormat;
  266. extern     Word                    CurrentRecord;                // record being edited
  267. extern    Boolean                ItemSelected;                // true if a day view item is selected
  268. extern    Word                    DayEditPosition;            // position of the insertion point in the desc field
  269.  
  270.  
  271. #if 0        // moved to DatePref.c    vmk 12/9/97
  272.     // The following global variable are only valid while editng the datebook's
  273.     // preferences.
  274.     extern    Word                    PrefDayStartHour;
  275.     extern    Word                    PrefDayEndHour;
  276. #endif
  277.  
  278. // The following global variable are saved to a state file.
  279. extern     Word                    DayStartHour;                // start of the day 8:00am
  280. extern     Word                    DayEndHour;                    // end of the day 6:00pm
  281. extern      FontID                NoteFont;                    // font used in note view
  282. extern      AlarmInfoType        AlarmPreset;                // default alarm settings.
  283. extern    Boolean                SaveBackup;                    // default setting "Backuo tp PC" checkbox
  284. extern    Boolean                ShowTimeBars;                // show time bars in the day view
  285. extern    Boolean                CompressDayView;            // remove empty time slot to prevent scrolling
  286. extern    Boolean                ShowTimedAppts;            // show timed appointments in month view
  287. extern    Boolean                ShowUntimedAppts;            // show untimed appointments in month view
  288. extern    Boolean                ShowDailyRepeatingAppts;// show daily repeating appointments in month view
  289.  
  290. extern    Boolean                EventInWeekView;            // true if pen of key event has occured
  291.                                                                     // in the Week View
  292. extern    FontID                ApptDescFont;                // font for drawing event description
  293.  
  294.  
  295. // The following global variable is used to control the displaying of the
  296. // current time in the title of a view.
  297. extern    Boolean                TimeDisplayed;                // True if time in been displayed
  298. extern    ULong                    TimeDisplayTick;            // Tick count when we stop showing time
  299.  
  300.  
  301. // The following globals are for the repeat rates of the alarms.
  302. extern    UInt                    AlarmSoundRepeatCount;    // number of times to repeat alarm sound 
  303. extern    UInt                    AlarmSoundRepeatInterval;// interval between repeat sounds, in seconds
  304.  
  305. extern    ULong                    AlarmSoundUniqueRecID;    // Unique record ID of desired alarm sound
  306.  
  307.  
  308. /***********************************************************************
  309.  *
  310.  *    Functions
  311.  *
  312.  ***********************************************************************/
  313. #ifdef __cplusplus
  314. extern "C" {
  315. #endif
  316.  
  317.  
  318. extern void ShowInfo (void);
  319.  
  320. extern  Err MoveEvent (WordPtr recordNumP, TimeType startTime, TimeType endTime,
  321.          DateType date, Boolean splitEvent, BooleanPtr moved);
  322.  
  323. extern SWord DatebookLoadPrefs (DatebookPreferenceType* prefsP);
  324.  
  325. extern void DatebookSavePrefs (void);
  326.  
  327.  
  328. #ifdef __cplusplus 
  329. }
  330. #endif
  331.  
  332. /***********************************************************************
  333.  *
  334.  *   ParamBlock definition for plug-in routines
  335.  *
  336.  ***********************************************************************/
  337.  
  338. typedef enum
  339.     {
  340.     DateSendRecordCall,
  341.     DateReceiveDataCall
  342.     } MultiSegmentCalls;
  343.     
  344. typedef struct 
  345.     {
  346.     DmOpenRef dbP;
  347.     Int recordNum;
  348.     } DateSendRecordParams;
  349.  
  350. typedef struct 
  351.     {
  352.     DmOpenRef dbP;
  353.     ExgSocketPtr exgSocketP;
  354.     } DateReceiveDataParams;
  355.  
  356. typedef union
  357.     {
  358.     DateSendRecordParams dsr;
  359.     DateReceiveDataParams drd;
  360.     } ParamsType;
  361.  
  362. typedef struct 
  363.     {
  364.     MultiSegmentCalls call;
  365.     ParamsType params;
  366.     } myPlugInParamBlockType;
  367.  
  368. typedef myPlugInParamBlockType* myPlugInParamBlockPtr;
  369.  
  370. /***********************************************************************
  371.  *
  372.  *   Function prototype for plug-in routines
  373.  *
  374.  ***********************************************************************/
  375. typedef DWord PlugInMainF (myPlugInParamBlockPtr plugInParamsP);
  376.  
  377.  
  378. /***********************************************************************
  379.  *
  380.  *   Entry Points
  381.  *
  382.  ***********************************************************************/
  383. #if EMULATION_LEVEL == EMULATION_NONE
  384.     extern DWord __Startup__( myPlugInParamBlockPtr plugInParamsP );
  385. #endif
  386. extern DWord PlugIn1Main( myPlugInParamBlockPtr plugInParamsP );
  387.