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 / DateDB.h < prev    next >
C/C++ Source or Header  |  2000-09-05  |  8KB  |  259 lines

  1. /*******************************************************************
  2.  Copyright ⌐ 1995 - 1998, 3Com Corporation or its subsidiaries ("3Com").  
  3.  All rights reserved.
  4.    
  5.  This software may be copied and used solely for developing products for 
  6.  the Palm Computing platform and for archival and backup purposes.  Except 
  7.  for the foregoing, no part of this software may be reproduced or transmitted 
  8.  in any form or by any means or used to make any derivative work (such as 
  9.  translation, transformation or adaptation) without express written consent 
  10.  from 3Com.
  11.  
  12.  3Com reserves the right to revise this software and to make changes in content 
  13.  from time to time without obligation on the part of 3Com to provide notification 
  14.  of such revision or changes.  
  15.  3COM MAKES NO REPRESENTATIONS OR WARRANTIES THAT THE SOFTWARE IS FREE OF ERRORS 
  16.  OR THAT THE SOFTWARE IS SUITABLE FOR YOUR USE.  THE SOFTWARE IS PROVIDED ON AN 
  17.  "AS IS" BASIS.  3COM MAKES NO WARRANTIES, TERMS OR CONDITIONS, EXPRESS OR IMPLIED, 
  18.  EITHER IN FACT OR BY OPERATION OF LAW, STATUTORY OR OTHERWISE, INCLUDING WARRANTIES, 
  19.  TERMS, OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND 
  20.  SATISFACTORY QUALITY.
  21.  
  22.  TO THE FULL EXTENT ALLOWED BY LAW, 3COM ALSO EXCLUDES FOR ITSELF AND ITS SUPPLIERS 
  23.  ANY LIABILITY, WHETHER BASED IN CONTRACT OR TORT (INCLUDING NEGLIGENCE), FOR 
  24.  DIRECT, INCIDENTAL, CONSEQUENTIAL, INDIRECT, SPECIAL, OR PUNITIVE DAMAGES OF 
  25.  ANY KIND, OR FOR LOSS OF REVENUE OR PROFITS, LOSS OF BUSINESS, LOSS OF INFORMATION 
  26.  OR DATA, OR OTHER FINANCIAL LOSS ARISING OUT OF OR IN CONNECTION WITH THIS SOFTWARE, 
  27.  EVEN IF 3COM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  28.  
  29.  3Com, HotSync, Palm Computing, and Graffiti are registered trademarks, and 
  30.  Palm III and Palm OS are trademarks of 3Com Corporation or its subsidiaries.
  31.  
  32.  IF THIS SOFTWARE IS PROVIDED ON A COMPACT DISK, THE OTHER SOFTWARE AND 
  33.  DOCUMENTATION ON THE COMPACT DISK ARE SUBJECT TO THE LICENSE AGREEMENT 
  34.  ACCOMPANYING THE COMPACT DISK.
  35.  
  36.  *****************************************************************************
  37.  * FileName:
  38.  *        ApptMgr.h
  39.  *
  40.  * Description:
  41.  *        Header for the Appointment Manager
  42.  *
  43.  * History:
  44.  *       1/25/95  rsf - Created
  45.  *
  46.  *******************************************************************/
  47.  
  48. #ifndef __TDAPPTMGR_H__
  49. #define __TDAPPTMGR_H__
  50.  
  51.  
  52. typedef struct {
  53.    UInt    renamedCategories;    // bitfield of categories with a different name
  54.     char     categoryLabels[dmRecNumCategories][dmCategoryLength];
  55.     Byte    categoryUniqIDs[dmRecNumCategories];
  56.     Byte    lastUniqID;    // Uniq IDs generated by the device are between
  57.                             // 0 - 127.  Those from the PC are 128 - 255.
  58.     Byte    reserved1;    // from the compiler word aligning things
  59.     Word    reserved2;
  60.     Byte    startOfWeek;
  61. } ApptAppInfoType;
  62.  
  63.  
  64. typedef ApptAppInfoType * ApptAppInfoPtr;
  65.  
  66.  
  67. /************************************************************
  68.  *
  69.  * Appointment Database constants.
  70.  *
  71.  *************************************************************/
  72. #define apptMaxPerDay         100        // max appointments displayable on a day.
  73. #define apptNoTime            -1            // start time of an untimed appt.
  74. #define apptNoEndDate        -1            // end date of appts that repeat forever
  75. #define apptNoAlarm            -1
  76. #define apptMaxEndTime        0x1737    // 11:55 pm, hours in high byte, minutes in low byte
  77.  
  78. #define apptMaxDisplayableAlarms 10
  79.  
  80.  
  81. /************************************************************
  82.  *
  83.  * Appointment Database structures.
  84.  *
  85.  *************************************************************/
  86.  
  87. // The format of a packed appointment record is as follows:
  88. //
  89. //    ApptDateTimeType         when;
  90. //    ApptDBRecordFlags        flags;            // A flag set for each datum present
  91. //    AlarmInfoType            alarm;            // optional
  92. //    RepeatInfoType            repeat;            // optional
  93. //    ExceptionsListType    exceptions;        // optional
  94. //    char []                    note;                // null terminated, optional
  95. //    char []                    description;    // null terminated
  96. //
  97. // All optional data may or may not appear.
  98.  
  99.  
  100.  
  101. // Alarm advance - the period of time before the appointment that the 
  102. // alarm should sound.
  103. //
  104. typedef enum alarmTypes {aauMinutes, aauHours, aauDays} AlarmUnitType;
  105.  
  106. typedef struct {
  107.     SByte                    advance;            // Alarm advance (-1 = no alarm)
  108.     AlarmUnitType        advanceUnit;    // minutes, hours, days
  109. } AlarmInfoType;
  110.  
  111.  
  112. // The following enum is used to specify the frequency of
  113. // repeating appointments.
  114. //
  115. enum repeatTypes {
  116.     repeatNone, 
  117.     repeatDaily, 
  118.     repeatWeekly, 
  119.     repeatMonthlyByDay, 
  120.     repeatMonthlyByDate,
  121.     repeatYearly
  122. };
  123. typedef enum repeatTypes RepeatType;
  124.  
  125.  
  126. // This structure contains information about repeat appointments.  The 
  127. // repeatOn member is only used by weelky and monthly-by-day repeating
  128. // appointments.  For weekly the byte is a bit field that contains the 
  129. // days of the week the appointments occurs on (bit: 0-sun, 1-mon, 
  130. // 2-tue, etc.).  For monthly-by-day the byte contains the day the 
  131. // appointments occurs, (ex: the 3rd friday), the byte is of type 
  132. // DayOfMonthType.
  133. //
  134. typedef struct {
  135.     RepeatType        repeatType;            // daily, weekly, monthlyByDay, etc.
  136.     DateType            repeatEndDate;        // minus one if forever
  137.     unsigned char    repeatFrequency;    // i.e. every 2 days if repeatType daily
  138.     unsigned char    repeatOn;            // monthlyByDay and repeatWeekly only    
  139.     unsigned char  repeatStartOfWeek;// repeatWeekly only
  140. } RepeatInfoType;
  141.  
  142. typedef RepeatInfoType * RepeatInfoPtr;
  143.  
  144.  
  145.  
  146. // This structure contains information about the date and time of an 
  147. // appointment.
  148. //
  149. typedef struct {
  150.     TimeType            startTime;            // Time the appointment starts
  151.     TimeType            endTime;                // Time the appointment ends
  152.     DateType            date;                    // date of appointment
  153. } ApptDateTimeType;
  154.  
  155.  
  156.  
  157. // This is the structure for a repeating appointment's exceptions list.  The
  158. // exceptions list is a variable length list of dates that the repeating appointment
  159. // should not appear on.  The list is in chronological order.
  160. //
  161. typedef struct {
  162.     UInt        numExceptions;
  163.     DateType    exception;
  164. } ExceptionsListType;
  165.  
  166. typedef ExceptionsListType * ExceptionsListPtr;
  167.  
  168.  
  169.  
  170. // This structure describes what information is present in an
  171. // AppointmentPackedDBRecordType
  172. typedef struct {
  173.     unsigned when            :1;            // set if when info changed (ApptChangeRecord)
  174.     unsigned alarm            :1;            // set if record contains alarm info
  175.     unsigned repeat        :1;            // set if record contains repeat info
  176.     unsigned note            :1;            // set if record contains a note
  177.     unsigned exceptions    :1;            // set if record contains exceptions list
  178.     unsigned description    :1;            
  179. } ApptDBRecordFlags;
  180.  
  181.  
  182. // ApptDBRecordType
  183. //
  184. // This is the record used by the application.  All pointers are either NULL 
  185. // or point to data within the PackedDB record.  All strings are null 
  186. // character terminated.
  187.  
  188. typedef struct {
  189.     ApptDateTimeType *    when;
  190.     AlarmInfoType *        alarm;
  191.     RepeatInfoType *        repeat;
  192.     ExceptionsListType *    exceptions;
  193.     CharPtr                    description;
  194.     CharPtr                    note;
  195. } ApptDBRecordType;
  196.  
  197. typedef ApptDBRecordType * ApptDBRecordPtr;
  198.  
  199.  
  200. // ApptGetAppointments returns an array of the following structures.
  201. typedef struct {
  202.     TimeType        startTime;
  203.     TimeType        endTime;
  204.     UInt            recordNum;
  205.     } ApptInfoType;
  206. typedef ApptInfoType * ApptInfoPtr;
  207.  
  208.  
  209.  
  210. /************************************************************
  211.  *
  212.  * Appointment database routines.
  213.  *
  214.  *************************************************************/
  215.  
  216. #ifdef __cplusplus
  217. extern "C" {
  218. #endif
  219.  
  220.  
  221. Err         ApptAppInfoInit (DmOpenRef dbP);
  222.  
  223. Err         ApptGetRecord (DmOpenRef dbP, UInt index, ApptDBRecordPtr r,
  224.                 VoidHand * handleP);
  225.  
  226. Err         ApptNewRecord (DmOpenRef dbP, ApptDBRecordPtr r, UInt *index);
  227.  
  228. Err         ApptChangeRecord (DmOpenRef dbP, UInt *index, ApptDBRecordPtr r, 
  229.                 ApptDBRecordFlags changedFields);
  230.  
  231. Err         ApptAddException (DmOpenRef dbP, UInt *index, DateType date);
  232.  
  233. Boolean     ApptFindFirst (DmOpenRef dbP, DateType date, UIntPtr indexP);
  234.  
  235. Boolean    ApptRepeatsOnDate  (ApptDBRecordPtr apptRec, DateType date);
  236.  
  237. Boolean    ApptNextRepeat (ApptDBRecordPtr apptRec, DatePtr dateP);
  238.  
  239. ULong        ApptGetAlarmTime (ApptDBRecordPtr apptRec, ULong currentTime);
  240.  
  241. VoidHand ApptGetAlarmsList (DmOpenRef dbP, ULong alarmTime, UIntPtr countP, 
  242.                 BooleanPtr quite);
  243.  
  244. void        ApptGetNextAlarm (DmOpenRef dbP);
  245.  
  246. ULong        ApptGetTimeOfNextAlarm (DmOpenRef dbP, ULong timeInSeconds);
  247.  
  248. void        ApptSort (DmOpenRef dbP);
  249.  
  250. void         ApptGetAppointments (DmOpenRef dbP, DateType date, Word days,
  251.                 VoidHand apptLists [], UInt counts []);
  252.  
  253.  
  254. #ifdef __cplusplus
  255. }
  256. #endif
  257.  
  258. #endif
  259.