pilot-qof  0.2.3
Data Structures | Files | Defines | Functions | Variables
Datebooks and Appointments
Query Object Framework

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 QofDateBookdatebook_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"

Detailed Description

A note on TIME:

The pilot-link QOF objects therefore expect UTC time from QOF and pass localtime to the pilot-link code.


Define Documentation

#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.

#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.

#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,)

Possible settings for repeats on certain days of each month. dom == day of month in each case.

Definition at line 93 of file qof-datebook.c.

#define ENUM_REPEAT_LIST (   _)
Value:
_(repeatNone,) \
    _(repeatDaily,) \
    _(repeatWeekly,) \
    _(repeatMonthlyByDay,) \
    _(repeatMonthlyByDate,) \
    _(repeatYearly,)

see QOF or alioth for information on this macro.

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.


Function Documentation

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 111 of file qof-datebook.c.

{
    Appointment_t *qd;
    QofDateBook *obj;
    QofCollection *coll;
    GList *all;

    obj = g_new0 (QofDateBook, 1);
    qof_instance_init (&obj->inst, PILOT_LINK_QOF_DATEBOOK, book);
    coll = qof_book_get_collection (book, PILOT_LINK_QOF_DATEBOOK);
    all = qof_collection_get_data (coll);
    all = g_list_prepend (all, obj);
    qof_collection_set_data (coll, all);
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 198 of file qof-datebook.c.

{
    Appointment_t *qd;
    gchar *unit;

    g_return_val_if_fail (d != NULL, NULL);
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 252 of file qof-datebook.c.

{
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 499 of file qof-datebook.c.

{
    Appointment_t *qd;
    enum repeatTypes type;
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 569 of file qof-datebook.c.

{
    gchar day[MAX_DATE_LENGTH];
    Appointment_t *qd;
    time_t local;
    struct tm *local_tm;
    gint i, diff;
    gboolean found;

    g_return_if_fail (d != NULL);
    qd = &d->wrap;
    diff = 0;
    found = FALSE;
    local = time (NULL);
    local_tm = localtime (&local);
    if (local_tm->tm_wday <= 7)
        diff = 1;
    else
        diff = -1;
    for (i = 0; i < 7; i++)
    {
        strftime (day, MAX_DATE_LENGTH, "%A", local_tm);
        if (0 == safe_strcmp (e, day))
        {
            found = TRUE;
            break;
        }
gboolean DateBookRegister ( void  )

Register the datebook with QOF

Definition at line 694 of file qof-datebook.c.

Referenced by pilot_qof_init().

         :qof_collection_foreach,
  printable:datebookPrintable,
  version_cmp:(gint (*)(gpointer, gpointer)) qof_instance_version_cmp,
};

gboolean
DateBookRegister (void)
{
    static QofParam params[] = {
        {DATEBOOK_EVENT, QOF_TYPE_BOOLEAN,
                (QofAccessFunc) datebook_getEvent,
            (QofSetterFunc) datebook_setEvent},
        {DATEBOOK_BEGIN, QOF_TYPE_TIME, (QofAccessFunc) datebook_getBegin,
            (QofSetterFunc) datebook_setBegin},
        {DATEBOOK_END, QOF_TYPE_TIME, (QofAccessFunc) datebook_getEnd,
            (QofSetterFunc) datebook_setEnd},
        {DATEBOOK_ALARM, QOF_TYPE_BOOLEAN,
                (QofAccessFunc) datebook_getAlarm,
            (QofSetterFunc) datebook_setAlarm},
        {DATEBOOK_ADVANCE, QOF_TYPE_INT32,
                (QofAccessFunc) datebook_getAdvance,
            (QofSetterFunc) datebook_setAdvance},
        {DATEBOOK_ADV_UNIT, QOF_TYPE_STRING,
                (QofAccessFunc) datebook_getAdvanceUnit,
            (QofSetterFunc) datebook_setAdvanceUnit},
        {DATEBOOK_REPEAT_TYPE, QOF_TYPE_STRING,
                (QofAccessFunc) datebook_getRepeatType,
            (QofSetterFunc) datebook_setRepeatType},
        {DATEBOOK_REPEAT_FOREVER, QOF_TYPE_BOOLEAN,
                (QofAccessFunc) datebook_getRepeatForever,
            (QofSetterFunc) datebook_setRepeatForever},
        {DATEBOOK_REPEAT_END, QOF_TYPE_TIME,
                (QofAccessFunc) datebook_getRepeatEnd,
            (QofSetterFunc) datebook_setRepeatEnd},
        {DATEBOOK_REPEAT_FREQUENCY, QOF_TYPE_INT32,
                (QofAccessFunc) datebook_getRepeatFrequency,
            (QofSetterFunc) datebook_setRepeatFrequency},
        {DATEBOOK_REPEAT_DAY, QOF_TYPE_STRING,
                (QofAccessFunc) datebook_getRepeatDay,
            (QofSetterFunc) datebook_setRepeatDay},
        {DATEBOOK_REPEAT_WEEK_START, QOF_TYPE_STRING,
                (QofAccessFunc) datebook_getRepeatWeekStart,
            (QofSetterFunc) datebook_setRepeatWeekStart},
        {DATEBOOK_EXCEPTIONS, QOF_TYPE_INT32,
                (QofAccessFunc) datebook_getExceptions,
            (QofSetterFunc) datebook_setExceptions},
        {DATEBOOK_DESCRIPTION, QOF_TYPE_STRING,
                (QofAccessFunc) datebook_getDescription,
            (QofSetterFunc) datebook_setDescription},
        {DATEBOOK_CATEGORY, QOF_TYPE_STRING,
                (QofAccessFunc) datebook_getCategory,
            (QofSetterFunc) datebook_setCategory},
        {DATEBOOK_REPEATER, QOF_TYPE_BOOLEAN,
                (QofAccessFunc) datebook_check_repeater,
            (QofSetterFunc) datebook_set_repeater},
        {DATEBOOK_NOTE, QOF_TYPE_STRING, (QofAccessFunc) datebook_getNote,
            (QofSetterFunc) datebook_setNote},
        {DATEBOOK_DURATION, QOF_TYPE_DOUBLE,
                (QofAccessFunc) datebook_getDuration, NULL},
        {DATEBOOK_EXCEPTION, QOF_TYPE_KVP,
                (QofAccessFunc) qof_instance_get_slots, NULL},
        {QOF_PARAM_BOOK, QOF_ID_BOOK,
                (QofAccessFunc) qof_instance_get_book, NULL},
        {QOF_PARAM_GUID, QOF_TYPE_GUID,
                (QofAccessFunc) qof_instance_get_guid, NULL},
        {NULL},

Variable Documentation

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 679 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.

Note:
Current. QOF deals with the timezone issues but if you take your Palm to another country, be prepared for this value to be translated!

This value is not used to set the preference in the Palm, so it does not need to be translated back. Setting the value in Datebooks and Appointments only affects any exported XML.

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 311 of file qof-datebook.c.