blueZync

Synchronize Bluetooth phone with Thunderbird

Develpers' detailed documentation for the mozilla-sync plugin for OpenSync. A part of blueZync.

calendar-event.cpp File Reference


Detailed Description

Functions for mozilla calendar.

#include <glib.h>
#include <libxml/encoding.h>
#include <libxml/xmlwriter.h>
#include <libxml/xpath.h>
#include "mozilla-headers.h"
#include <nsEmbedString.h>
#include <nsServiceManagerUtils.h>
#include <xpcom/nsIUUIDGenerator.h>
#include <storage/mozIStorageStatement.h>
#include <calbase/calIICSService.h>
#include <calbase/calIDateTime.h>
#include "mozilla-sync-utils.h"
#include "mozilla-calendar.h"
#include "calendar-event.h"

Include dependency graph for calendar-event.cpp:


Classes

struct  _TMozVcardPair

Defines

#define CAL_ADD_TIME_PROPERTY(IDX, ATTR)
 Small helper for SetTimeInTimezone in either 0.7 or 0.8.
#define CAL_MODIFY_TIME_PROPERTY(IDX, ATTR)
 Small helper to get TimeZone in either 0.7 or 0.8.
#define MAX_MOZVCARD_ARRAY   20

Typedefs

typedef struct _TMozVcardPair TMozVcardPair

Functions

gboolean EventAdd (mozIStorageConnection *pConn, const char *szCalId, const char *szICS, char **pSzNewKey, char **pSzNewHash, char **pSzError, void(*pLogFunction)(int level, bool sensitive, const char *szFile, int iLine, const char *szFunc, const char *szFormat,...))
 Add an event to mozilla calendar.
gboolean EventICS (mozIStorageConnection *pConn, const char *szCalId, const char *szKey, char **pSzICS, char **pSzError, void(*pLogFunction)(int level, bool sensitive, const char *szFile, int iLine, const char *szFunc, const char *szFormat,...))
 Get vcalendar representation of mozilla calendar event.
gboolean EventModify (mozIStorageConnection *pConn, const char *szCalId, const char *szKey, const char *szICS, char **pSzNewHash, char **pSzError, void(*pLogFunction)(int level, bool sensitive, const char *szFile, int iLine, const char *szFunc, const char *szFormat,...))
 Modify an event in a mozilla calendar.
GList * PGListEventCapabilities ()
 Get list of field names representing Sunbird Event capabilities.

Variables

const char * apSzCapabilities []
static TMozVcardPair BaseMozVcardArray [MAX_MOZVCARD_ARRAY]
nsCOMPtr< calIICSService > globalIcsService
 Global holding Mozilla ICS service.
nsCOMPtr< nsIUUIDGenerator > globalUuidgen = nsnull
 Global holding Mozilla UUID generator.

Define Documentation

#define CAL_ADD_TIME_PROPERTY ( IDX,
ATTR   ) 

Small helper for SetTimeInTimezone in either 0.7 or 0.8.

Small helper for GetInTimezone in either 0.7 or 0.8 Small helper for AddTimezoneReference in either 0.7 or 0.8 Get statement parameter IDX and call icsEvent method ATTR with it The way this is done is a bit convoluted: First we create a calIDateTime and set the UTC time in it (Mozilla stores times at UTC in the SQL database, no matter what timezone is specified) Then we "get" this into a new calIDateTime with the timezone we want And finally we call ATTR with the new calIDateTime

Referenced by EventICS().

#define CAL_MODIFY_TIME_PROPERTY ( IDX,
ATTR   ) 

Small helper to get TimeZone in either 0.7 or 0.8.

Call icsEvent method ATTR and bind parameter IDX in statement with it

Todo:
GetXXXXTime may fail if the timezone is invalid But OpenSync seems to strip off the vtimezone part of vcalendar, so leave resolution of this for later...

Referenced by EventModify().

#define MAX_MOZVCARD_ARRAY   20

Maximal number of matching mozilla SQL field name and VCARD field name

Referenced by EventICS(), and EventModify().


Typedef Documentation

typedef struct _TMozVcardPair TMozVcardPair


Function Documentation

gboolean EventAdd ( mozIStorageConnection *  pConn,
const char *  szCalId,
const char *  szICS,
char **  pSzNewKey,
char **  pSzNewHash,
char **  pSzError,
void(*)(int level, bool sensitive, const char *szFile, int iLine, const char *szFunc, const char *szFormat,...)  pLogFunction 
)

Add an event to mozilla calendar.

Parameters:
pConn (IN) Open connection to mozilla storage
szCalId (IN) Identifier of mozilla calendar
szICS (IN) String in vcalendar format
pSzNewKey (OUT) The generated uuid of the event
pSzNewHash (OUT) The hash value (modified time) of the event
pSzError (OUT) Pointer to string, into which we shall write an error message if we return false
pLogFunction (OUT)Function used to log information text
Returns:
TRUE on success; FALSE on error

References EventModify(), GFREE, globalUuidgen, LOG, MOZ_ERROR_CHECK_FALSE, and SQL_ERROR_CHECK_FALSE.

Referenced by MozillaCalendar::AddEvent().

Here is the call graph for this function:

gboolean EventICS ( mozIStorageConnection *  pConn,
const char *  szCalId,
const char *  szKey,
char **  pSzICS,
char **  pSzError,
void(*)(int level, bool sensitive, const char *szFile, int iLine, const char *szFunc, const char *szFormat,...)  pLogFunction 
)

Get vcalendar representation of mozilla calendar event.

Todo:
szCalId is not really needed, as szKey is unique over calendars
Parameters:
pConn (IN) Open connection to mozilla storage
szCalId (IN) Identifier of mozilla calendar
szKey (IN) The uuid of the event to change
pSzICS (OUT) Produced string in VCALENDAR format
pSzError (OUT) Pointer to string, into which we shall write an error message if we return false
pLogFunction (OUT)Function used to log information text
Returns:
TRUE on success; FALSE on error

References CAL_ADD_TIME_PROPERTY, GFREE, globalIcsService, LOG, MAX_MOZVCARD_ARRAY, MOZ_ERROR_CHECK_FALSE, SQL_ERROR_CHECK_FALSE, and _TMozVcardPair::szMozilla.

Referenced by MozillaCalendar::CurrentICS().

gboolean EventModify ( mozIStorageConnection *  pConn,
const char *  szCalId,
const char *  szKey,
const char *  szICS,
char **  pSzNewHash,
char **  pSzError,
void(*)(int level, bool sensitive, const char *szFile, int iLine, const char *szFunc, const char *szFormat,...)  pLogFunction 
)

Modify an event in a mozilla calendar.

Parameters:
pConn (IN) Open connection to mozilla storage
szCalId (IN) Identifier of mozilla calendar
szKey (IN) The uuid of the event to change
szICS (IN) String in vcalendar format
pSzNewHash (OUT) The hash value (modified time) of the event
pSzError (OUT) Pointer to string, into which we shall write an error message if we return false
pLogFunction (OUT)Function used to log information text
Returns:
TRUE on success; FALSE on error

References CAL_MODIFY_TIME_PROPERTY, GFREE, globalIcsService, LOG, LOG_SENSITIVE, MAX_MOZVCARD_ARRAY, MOZ_ERROR_CHECK_FALSE, SQL_ERROR_CHECK_FALSE, SQL_ERROR_CHECK_NOROWSOK_FALSE, _TMozVcardPair::szMozilla, and _TMozVcardPair::szVcard.

Referenced by EventAdd(), and MozillaCalendar::ModifyEvent().

GList* PGListEventCapabilities (  ) 

Get list of field names representing Sunbird Event capabilities.

References apSzCapabilities.

Referenced by mozilla_sync_initialize().


Variable Documentation

const char* apSzCapabilities[]

Referenced by PGListEventCapabilities().

TMozVcardPair BaseMozVcardArray[MAX_MOZVCARD_ARRAY] [static]

Initial value:

 {
        { "title", "SUMMARY", "Summary" },
        { "priority", "PRIORITY", "Priority" },
        { "privacy", "CLASS", "Class" },
        { "ical_status", "STATUS", "Status" },
        NULL
}
Matching mozilla SQL field name and VCARD field name

nsCOMPtr<calIICSService> globalIcsService

Global holding Mozilla ICS service.

Referenced by EventICS(), and EventModify().

nsCOMPtr<nsIUUIDGenerator> globalUuidgen = nsnull

Global holding Mozilla UUID generator.

Referenced by EventAdd().