Data Structures | |
struct | QofDateBook |
Files | |
file | qof-datebook.c |
QOF datebook definitions for pilot-link. | |
file | qof-datebook.h |
QOF datebook definitions for pilot-link. | |
Defines | |
#define | _GNU_SOURCE |
#define | ENUM_REPEAT_LIST(_) |
see QOF or alioth for information on this macro. | |
#define | ENUM_ALARM_UNIT(_) _(advMinutes,) _(advHours,) _(advDays,) |
Units to measure the digit entered in alarm_advance. | |
#define | ENUM_MONTH_DAYQ(_) |
#define | DATEBOOK_REPEATER "transient_repeat" |
Is this a transient repeat object? | |
#define | DATEBOOK_KVP_PATH "datebook/exceptions" |
#define | DATEBOOK_EVENT "untimed_event" |
#define | DATEBOOK_BEGIN "start_time" |
#define | DATEBOOK_END "end_time" |
#define | DATEBOOK_ALARM "use_alarm" |
#define | DATEBOOK_ADVANCE "alarm_advance" |
#define | DATEBOOK_ADV_UNIT "advance_unit" |
#define | DATEBOOK_REPEAT_TYPE "repeat_type" |
#define | DATEBOOK_REPEAT_FOREVER "repeat_forever" |
Does the repeat have an end? | |
#define | DATEBOOK_REPEAT_END "repeat_end" |
#define | DATEBOOK_REPEAT_FREQUENCY "repeat_frequency" |
#define | DATEBOOK_REPEAT_DAY "repeat_day" |
#define | DATEBOOK_REPEAT_WEEK_START "repeat_week_start" |
#define | DATEBOOK_EXCEPTIONS "exception_count" |
#define | DATEBOOK_EXCEPTION "exception_list" |
#define | DATEBOOK_NOTE "note" |
#define | DATEBOOK_CATEGORY "category" |
Functions | |
const gchar * | repeatTypesasString (enum repeatTypes n) |
void | repeatTypesfromString (const gchar *str, enum repeatTypes *type) |
const gchar * | alarmTypesasString (enum alarmTypes n) |
void | alarmTypesfromString (const gchar *str, enum alarmTypes *type) |
const gchar * | DayOfMonthTypeasString (enum DayOfMonthType n) |
void | DayOfMonthTypefromString (const gchar *str, enum DayOfMonthType *type) |
static QofDateBook * | datebook_create (QofBook *book) |
Create a datebook object in QOF. | |
Appointment_t * | datebook_get_pilot (QofInstance *inst) |
static gboolean | datebook_getEvent (QofDateBook *d) |
static QofTime * | datebook_getBegin (QofDateBook *d) |
static QofTime * | datebook_getEnd (QofDateBook *d) |
static gboolean | datebook_getAlarm (QofDateBook *d) |
static gint | datebook_getAdvance (QofDateBook *d) |
static const gchar * | datebook_getAdvanceUnit (QofDateBook *d) |
Uses ENUM_ALARM_UNIT to convert to a string. | |
static const gchar * | datebook_getRepeatType (QofDateBook *d) |
static gboolean | datebook_getRepeatForever (QofDateBook *d) |
static QofTime * | datebook_getRepeatEnd (QofDateBook *d) |
static gint | datebook_getRepeatFrequency (QofDateBook *d) |
How often to repeat. | |
static const gchar * | datebook_getRepeatDay (QofDateBook *d) |
static gchar * | datebook_getRepeatWeekStart (QofDateBook *d) |
static gint | datebook_getExceptions (QofDateBook *d) |
static gchar * | datebook_getDescription (QofDateBook *d) |
static gchar * | datebook_getNote (QofDateBook *d) |
static gchar * | datebook_getCategory (QofDateBook *d) |
static double | datebook_getDuration (QofDateBook *d) |
static gboolean | datebook_check_repeater (QofDateBook *d) |
static void | datebook_set_repeater (QofDateBook *d, gboolean e) |
static void | datebook_setEvent (QofDateBook *d, gboolean e) |
static void | datebook_setBegin (QofDateBook *d, QofTime *qt) |
static void | datebook_setEnd (QofDateBook *d, QofTime *qt) |
static void | datebook_setAlarm (QofDateBook *d, gboolean e) |
static void | datebook_setAdvance (QofDateBook *d, gint e) |
static void | datebook_setAdvanceUnit (QofDateBook *d, const gchar *e) |
static void | datebook_setRepeatType (QofDateBook *d, const gchar *type_label) |
Uses ENUM_REPEAT_LIST to convert to an enum value. | |
static void | datebook_setRepeatForever (QofDateBook *d, gboolean e) |
static void | datebook_setRepeatEnd (QofDateBook *d, QofTime *qt) |
static void | datebook_setRepeatFrequency (QofDateBook *d, gint e) |
static void | datebook_setRepeatDay (QofDateBook *d, const gchar *e) |
static void | datebook_setRepeatWeekStart (QofDateBook *d, gchar *e) |
Set the day to start the week from the locale name. | |
static void | datebook_setExceptions (QofDateBook *d, gint e) |
static void | datebook_setDescription (QofDateBook *d, gchar *h) |
static void | datebook_setNote (QofDateBook *d, gchar *h) |
static void | datebook_setCategory (QofDateBook *d, gchar *n) |
void | datebook_repeater_clone (QofEntity *ent, QofTime *qt_end, QofTime *qt_increment) |
static const gchar * | datebookPrintable (gpointer instance) |
gboolean | DateBookRegister (void) |
Variables | |
static QofLogModule | log_module = "pilotqof-objects" |
static QofDateFormat | df = 0 |
Get the locale name of the day to start the week. | |
static QofObject | datebook_object_def |
QOF object declaration | |
#define | DATEBOOK_VERSION datebook_v1 |
#define | PILOT_LINK_QOF_DATEBOOK "pilot_datebook" |
#define | QOF_DATEBOOK_DESC "Pilot-link QOF datebook" |
#define | DATEBOOK_DESCRIPTION "description" |
#define | DATEBOOK_DURATION "duration_hours" |
The pilot-link QOF objects therefore expect UTC time from QOF and pass localtime to the pilot-link code.
#define DATEBOOK_REPEAT_FOREVER "repeat_forever" |
Does the repeat have an end?
If set, any value in repeat-end is ignored.
Definition at line 76 of file qof-datebook.h.
Referenced by DateBookRegister().
#define DATEBOOK_REPEATER "transient_repeat" |
Is this a transient repeat object?
To make it easier to query repeat appointments, transient events are created for each incidence of a repeat. This parameter allows such transient events to be ignored in certain queries.
Definition at line 62 of file qof-datebook.h.
Referenced by DateBookRegister().
#define ENUM_MONTH_DAYQ | ( | _ | ) |
Value:
_(dom1stSun,) _(dom1stMon,) _(dom1stTue,) _(dom1stWen,) _(dom1stThu,) \ _(dom1stFri,) _(dom1stSat,) _(dom2ndSun,) _(dom2ndMon,) _(dom2ndTue,) \ _(dom2ndWen,) _(dom2ndThu,) _(dom2ndFri,) _(dom2ndSat,) _(dom3rdSun,) \ _(dom3rdMon,) _(dom3rdTue,) _(dom3rdWen,) _(dom3rdThu,) _(dom3rdFri,) \ _(dom3rdSat,) _(dom4thSun,) _(dom4thMon,) _(dom4thTue,) _(dom4thWen,) \ _(dom4thThu,) _(dom4thFri,) _(dom4thSat,) \ _(domLastSun,) _(domLastMon,) _(domLastTue,) _(domLastWen,) \ _(domLastThu,) _(domLastFri,) _(domLastSat,)
Definition at line 93 of file qof-datebook.c.
#define ENUM_REPEAT_LIST | ( | _ | ) |
Value:
_(repeatNone,) \ _(repeatDaily,) \ _(repeatWeekly,) \ _(repeatMonthlyByDay,) \ _(repeatMonthlyByDate,) \ _(repeatYearly,)
To document enums generated using the macro, look at the doxygen.cfg file in this package, under "PREPROCESSOR".
Note the use of the NON_TYPEDEF versions of the macro here. enum values cannot be defined twice so if the original definition in libpisock is NOT a typedef, use the NON_TYPEDEF version of the macro.
http://qof.sourceforge.net/doxy/group__Utilities.html
http://alioth.debian.org/snippet/detail.php?type=snippet&id=13
Definition at line 75 of file qof-datebook.c.
static QofDateBook* datebook_create | ( | QofBook * | book | ) | [static] |
Create a datebook object in QOF.
Sets a default time for start and end as the current time. Creates a KVP frame ready for any exceptions which is an array of struct tm. The length of array = datebook_getExceptions()
let QofTime remain NULL
Definition at line 117 of file qof-datebook.c.
References QofDateBook::repeater.
00118 { 00119 Appointment_t *qd; 00120 QofDateBook *obj; 00121 QofCollection *coll; 00122 GList *all; 00123 00124 obj = g_new0 (QofDateBook, 1); 00125 qof_instance_init (&obj->inst, PILOT_LINK_QOF_DATEBOOK, book); 00126 coll = qof_book_get_collection (book, PILOT_LINK_QOF_DATEBOOK); 00127 all = qof_collection_get_data (coll); 00128 all = g_list_prepend (all, obj); 00129 qof_collection_set_data (coll, all); 00130 qd = &obj->wrap; 00131 obj->repeater = FALSE; 00133 qd->exception = NULL; 00134 return obj; 00135 }
static const gchar* datebook_getAdvanceUnit | ( | QofDateBook * | d | ) | [static] |
Uses ENUM_ALARM_UNIT to convert to a string.
The enumerator values are converted to text for XML.
Definition at line 204 of file qof-datebook.c.
Referenced by DateBookRegister().
00205 { 00206 Appointment_t *qd; 00207 gchar *unit; 00208 00209 g_return_val_if_fail (d != NULL, NULL); 00210 qd = &d->wrap; 00211 if (datebook_getAlarm (d) == FALSE) 00212 return NULL; 00213 unit = g_strdup (alarmTypesasString (qd->advanceUnits)); 00214 return unit; 00215 }
static gint datebook_getRepeatFrequency | ( | QofDateBook * | d | ) | [static] |
How often to repeat.
Actual frequency depends on the value of repeatType. 1 == every time that repeat type comes around. 2 == every other repeat.
Definition at line 258 of file qof-datebook.c.
Referenced by DateBookRegister().
00259 { 00260 Appointment_t *qd; 00261 00262 g_return_val_if_fail (d != NULL, -1); 00263 qd = &d->wrap; 00264 return qd->repeatFrequency; 00265 }
static void datebook_setRepeatType | ( | QofDateBook * | d, | |
const gchar * | type_label | |||
) | [static] |
Uses ENUM_REPEAT_LIST to convert to an enum value.
The XML string is converted back to an enumerator value.
Definition at line 505 of file qof-datebook.c.
Referenced by DateBookRegister().
00506 { 00507 Appointment_t *qd; 00508 enum repeatTypes type; 00509 00510 g_return_if_fail (d != NULL); 00511 qd = &d->wrap; 00512 repeatTypesfromString (type_label, &type); 00513 qd->repeatType = type; 00514 }
static void datebook_setRepeatWeekStart | ( | QofDateBook * | d, | |
gchar * | e | |||
) | [static] |
Set the day to start the week from the locale name.
If the value is not recognised, QOF sets a default of zero - which would start the week on Sunday.
However, this value is not synced to the Palm - it is XML only.
Definition at line 575 of file qof-datebook.c.
Referenced by DateBookRegister().
00576 { 00577 gchar day[MAX_DATE_LENGTH]; 00578 Appointment_t *qd; 00579 time_t local; 00580 struct tm *local_tm; 00581 gint i, diff; 00582 gboolean found; 00583 00584 g_return_if_fail (d != NULL); 00585 qd = &d->wrap; 00586 diff = 0; 00587 found = FALSE; 00588 local = time (NULL); 00589 local_tm = localtime (&local); 00590 if (local_tm->tm_wday <= 7) 00591 diff = 1; 00592 else 00593 diff = -1; 00594 for (i = 0; i < 7; i++) 00595 { 00596 strftime (day, MAX_DATE_LENGTH, "%A", local_tm); 00597 if (0 == safe_strcmp (e, day)) 00598 { 00599 found = TRUE; 00600 break; 00601 } 00602 local_tm->tm_mday += diff; 00603 } 00604 if (!found) 00605 i = 0; 00606 qd->repeatWeekstart = i; 00607 }
gboolean DateBookRegister | ( | void | ) |
Register the datebook with QOF
Definition at line 700 of file qof-datebook.c.
References datebook_getAdvanceUnit(), datebook_getRepeatFrequency(), DATEBOOK_REPEAT_FOREVER, DATEBOOK_REPEATER, datebook_setRepeatType(), and datebook_setRepeatWeekStart().
Referenced by pilot_qof_init().
00701 { 00702 static QofParam params[] = { 00703 {DATEBOOK_EVENT, QOF_TYPE_BOOLEAN, 00704 (QofAccessFunc) datebook_getEvent, 00705 (QofSetterFunc) datebook_setEvent}, 00706 {DATEBOOK_BEGIN, QOF_TYPE_TIME, (QofAccessFunc) datebook_getBegin, 00707 (QofSetterFunc) datebook_setBegin}, 00708 {DATEBOOK_END, QOF_TYPE_TIME, (QofAccessFunc) datebook_getEnd, 00709 (QofSetterFunc) datebook_setEnd}, 00710 {DATEBOOK_ALARM, QOF_TYPE_BOOLEAN, 00711 (QofAccessFunc) datebook_getAlarm, 00712 (QofSetterFunc) datebook_setAlarm}, 00713 {DATEBOOK_ADVANCE, QOF_TYPE_INT32, 00714 (QofAccessFunc) datebook_getAdvance, 00715 (QofSetterFunc) datebook_setAdvance}, 00716 {DATEBOOK_ADV_UNIT, QOF_TYPE_STRING, 00717 (QofAccessFunc) datebook_getAdvanceUnit, 00718 (QofSetterFunc) datebook_setAdvanceUnit}, 00719 {DATEBOOK_REPEAT_TYPE, QOF_TYPE_STRING, 00720 (QofAccessFunc) datebook_getRepeatType, 00721 (QofSetterFunc) datebook_setRepeatType}, 00722 {DATEBOOK_REPEAT_FOREVER, QOF_TYPE_BOOLEAN, 00723 (QofAccessFunc) datebook_getRepeatForever, 00724 (QofSetterFunc) datebook_setRepeatForever}, 00725 {DATEBOOK_REPEAT_END, QOF_TYPE_TIME, 00726 (QofAccessFunc) datebook_getRepeatEnd, 00727 (QofSetterFunc) datebook_setRepeatEnd}, 00728 {DATEBOOK_REPEAT_FREQUENCY, QOF_TYPE_INT32, 00729 (QofAccessFunc) datebook_getRepeatFrequency, 00730 (QofSetterFunc) datebook_setRepeatFrequency}, 00731 {DATEBOOK_REPEAT_DAY, QOF_TYPE_STRING, 00732 (QofAccessFunc) datebook_getRepeatDay, 00733 (QofSetterFunc) datebook_setRepeatDay}, 00734 {DATEBOOK_REPEAT_WEEK_START, QOF_TYPE_STRING, 00735 (QofAccessFunc) datebook_getRepeatWeekStart, 00736 (QofSetterFunc) datebook_setRepeatWeekStart}, 00737 {DATEBOOK_EXCEPTIONS, QOF_TYPE_INT32, 00738 (QofAccessFunc) datebook_getExceptions, 00739 (QofSetterFunc) datebook_setExceptions}, 00740 {DATEBOOK_DESCRIPTION, QOF_TYPE_STRING, 00741 (QofAccessFunc) datebook_getDescription, 00742 (QofSetterFunc) datebook_setDescription}, 00743 {DATEBOOK_CATEGORY, QOF_TYPE_STRING, 00744 (QofAccessFunc) datebook_getCategory, 00745 (QofSetterFunc) datebook_setCategory}, 00746 {DATEBOOK_REPEATER, QOF_TYPE_BOOLEAN, 00747 (QofAccessFunc) datebook_check_repeater, 00748 (QofSetterFunc) datebook_set_repeater}, 00749 {DATEBOOK_NOTE, QOF_TYPE_STRING, (QofAccessFunc) datebook_getNote, 00750 (QofSetterFunc) datebook_setNote}, 00751 {DATEBOOK_DURATION, QOF_TYPE_DOUBLE, 00752 (QofAccessFunc) datebook_getDuration, NULL}, 00753 {DATEBOOK_EXCEPTION, QOF_TYPE_KVP, 00754 (QofAccessFunc) qof_instance_get_slots, NULL}, 00755 {QOF_PARAM_BOOK, QOF_ID_BOOK, 00756 (QofAccessFunc) qof_instance_get_book, NULL}, 00757 {QOF_PARAM_GUID, QOF_TYPE_GUID, 00758 (QofAccessFunc) qof_instance_get_guid, NULL}, 00759 {NULL}, 00760 }; 00761 00762 qof_class_register (PILOT_LINK_QOF_DATEBOOK, NULL, params); 00763 00764 return qof_object_register (&datebook_object_def); 00765 }
QofObject datebook_object_def [static] |
Initial value:
{ interface_version: 4 , e_type: "pilot_datebook" , type_label: "Pilot-link QOF datebook" , create:(gpointer) datebook_create, book_begin:NULL, book_end:NULL, is_dirty:qof_collection_is_dirty, mark_clean:qof_collection_mark_clean, foreach:qof_collection_foreach, printable:datebookPrintable, version_cmp:(gint (*)(gpointer, gpointer)) qof_instance_version_cmp, }
Definition at line 685 of file qof-datebook.c.
QofDateFormat df = 0 [static] |
Get the locale name of the day to start the week.
Calculate the current day of the week, compare with the integer set in the preferences and deduce the full weekday name according to the current locale.
repeatWeekstart contains 0=sunday, 1=monday etc. QofDate->qd_wday also starts at 0=sunday. Say it's Tues 26th and weekstart is sunday qd_wday = 2, qd_mday = 26, repeatWeekstart = 0; if (qdate->qd_mday < qdate->qd_wday) qdate->qd_mday += 7; qdate->qd_mday -= qdate->qd_wday + repeatWeekstart; qd_mday = 26 - 2 + 0 = 24. Sunday 24th. in case it's near the start of the month, go to the next week. If it's Thursday 1st and weekstart is Monday: qd_wday = 4, qd_mday = 1. qd_mday = qd_mday + 7 = 8. (Thurs 8th) qd_mday = 8 - 4 + 1 = 5. (Mon 5th.)
Definition at line 317 of file qof-datebook.c.