home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / happydays-src-1.37.tar.gz / happydays-src-1.37.tar / happydays-1.37 / datebook.h < prev    next >
C/C++ Source or Header  |  2000-04-01  |  6KB  |  199 lines

  1. /*
  2. HappyDays - A Birthdate displayer for the PalmPilot
  3. Copyright (C) 1999-2000 JaeMok Jeong
  4.  
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. */
  19.  
  20. #ifndef _DATEBOOK_H__
  21. #define _DATEBOOK_H__
  22.  
  23. #include <PalmOS.h>
  24.  
  25. typedef struct {
  26.     UInt16    renamedCategories;    // bitfield of categories with a different
  27.                                 // name
  28.     char     categoryLabels[dmRecNumCategories][dmCategoryLength];
  29.     UInt8    categoryUniqIDs[dmRecNumCategories];
  30.     UInt8    lastUniqID;    // Uniq IDs generated by the device are between
  31.     // 0 - 127.  Those from the PC are 128 - 255.
  32.     UInt8    reserved1;    // from the compiler word aligning things
  33.     UInt16    reserved2;
  34.     UInt8    startOfWeek;
  35. } ApptAppInfoType;
  36.  
  37.  
  38. typedef ApptAppInfoType * ApptAppInfoPtr;
  39.  
  40.  
  41. /************************************************************
  42.  *
  43.  * Appointment Database constants.
  44.  *
  45.  *************************************************************/
  46. #define apptMaxPerDay         100        // max appointments displayable on a day.
  47. #define apptNoTime            -1        // start time of an untimed appt.
  48. #define apptNoEndDate        -1        // end date of appts that repeat forever
  49. #define apptNoAlarm            -1
  50. #define apptMaxEndTime        0x1737    // 11:55 pm, hours in high byte, minutes in low byte
  51.  
  52. #define apptMaxDisplayableAlarms 10
  53.  
  54.  
  55. /************************************************************
  56.  *
  57.  * Appointment Database structures.
  58.  *
  59.  *************************************************************/
  60.  
  61. // The format of a packed appointment record is as follows:
  62. //
  63. //    ApptDateTimeType         when;
  64. //    ApptDBRecordFlags        flags;        // A flag set for each datum present
  65. //    AlarmInfoType            alarm;        // optional
  66. //    RepeatInfoType            repeat;        // optional
  67. //    ExceptionsListType    exceptions;        // optional
  68. //    char []                    note;        // null terminated, optional
  69. //    char []                    description;    // null terminated
  70. //
  71. // All optional data may or may not appear.
  72.  
  73.  
  74.  
  75. // Alarm advance - the period of time before the appointment that the
  76. // alarm should sound.
  77. //
  78. typedef enum alarmTypes {aauMinutes, aauHours, aauDays} AlarmUnitType;
  79.  
  80. typedef struct {
  81.     Int8                advance;        // Alarm advance (-1 = no alarm)
  82.     AlarmUnitType        advanceUnit;    // minutes, hours, days
  83. } AlarmInfoType;
  84.  
  85.  
  86. // The following enum is used to specify the frequency of
  87. // repeating appointments.
  88. //
  89. enum repeatTypes {
  90.     repeatNone,
  91.     repeatDaily,
  92.     repeatWeekly,
  93.     repeatMonthlyByDay,
  94.     repeatMonthlyByDate,
  95.     repeatYearly
  96. };
  97. typedef enum repeatTypes RepeatType;
  98.  
  99.  
  100. // This structure contains information about repeat appointments.  The
  101. // repeatOn member is only used by weelky and monthly-by-day repeating
  102. // appointments.  For weekly the byte is a bit field that contains the
  103. // days of the week the appointments occurs on (bit: 0-sun, 1-mon,
  104. // 2-tue, etc.).  For monthly-by-day the byte contains the day the
  105. // appointments occurs, (ex: the 3rd friday), the byte is of type
  106. // DayOfMonthType.
  107. //
  108. typedef struct {
  109.     RepeatType        repeatType;            // daily, weekly, monthlyByDay, etc.
  110.     DateType        repeatEndDate;        // minus one if forever
  111.     unsigned char    repeatFrequency;    // i.e. every 2 days if repeatType daily
  112.     unsigned char    repeatOn;            // monthlyByDay and repeatWeekly only
  113.     unsigned char  repeatStartOfWeek;   // repeatWeekly only
  114. } RepeatInfoType;
  115.  
  116. typedef RepeatInfoType * RepeatInfoPtr;
  117.  
  118.  
  119.  
  120. // This structure contains information about the date and time of an
  121. // appointment.
  122. //
  123. typedef struct {
  124.     TimeType            startTime;        // Time the appointment starts
  125.     TimeType            endTime;        // Time the appointment ends
  126.     DateType            date;            // date of appointment
  127. } ApptDateTimeType;
  128.  
  129.  
  130.  
  131. // This is the structure for a repeating appointment's exceptions list.  The
  132. // exceptions list is a variable length list of dates that the repeating appointment
  133. // should not appear on.  The list is in chronological order.
  134. //
  135. typedef struct {
  136.     UInt16        numExceptions;
  137.     DateType    exception;
  138. } ExceptionsListType;
  139.  
  140. typedef ExceptionsListType * ExceptionsListPtr;
  141.  
  142.  
  143.  
  144. // This structure describes what information is present in an
  145. // AppointmentPackedDBRecordType
  146. typedef struct {
  147. unsigned when            :1;        // set if when info changed (ApptChangeRecord)
  148. unsigned alarm            :1;        // set if record contains alarm info
  149. unsigned repeat        :1;            // set if record contains repeat info
  150. unsigned note            :1;        // set if record contains a note
  151. unsigned exceptions    :1;            // set if record contains exceptions list
  152. unsigned description    :1;
  153. } ApptDBRecordFlags;
  154.  
  155.  
  156. // ApptDBRecordType
  157. //
  158. // This is the record used by the application.  All pointers are either NULL
  159. // or point to data within the PackedDB record.  All strings are null
  160. // character terminated.
  161.  
  162. typedef struct {
  163.     ApptDateTimeType *    when;
  164.     AlarmInfoType *        alarm;
  165.     RepeatInfoType *        repeat;
  166.     ExceptionsListType *    exceptions;
  167.     Char *                    description;
  168.     Char *                    note;
  169. } ApptDBRecordType;
  170.  
  171. typedef ApptDBRecordType * ApptDBRecordPtr;
  172.  
  173.  
  174. // ApptGetAppointments returns an array of the following structures.
  175. typedef struct {
  176.     TimeType        startTime;
  177.     TimeType        endTime;
  178.     UInt16            recordNum;
  179. } ApptInfoType;
  180. typedef ApptInfoType * ApptInfoPtr;
  181.  
  182. /************************************************************
  183.  *
  184.  * Appointment database routines.
  185.  *
  186.  *************************************************************/
  187.  
  188.  
  189. extern Err ApptNewRecord (DmOpenRef dbP, ApptDBRecordPtr r, UInt16 *index);
  190. extern MemHandle ApptGetAppointments (DmOpenRef dbP, DateType date,
  191.                                       UInt16 *countP);
  192. extern Err ApptGetRecord (DmOpenRef dbP, UInt16 index, ApptDBRecordPtr r,
  193.                    MemHandle * handleP);
  194. extern Err ApptChangeRecord(DmOpenRef dbP, UInt16 *index, ApptDBRecordPtr r,
  195.                             ApptDBRecordFlags changedFields);
  196.  
  197.  
  198. #endif
  199.