00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __CCALENDAR_H__
00025 #define __CCALENDAR_H__
00026 #include <map>
00027 #include <sqlite3.h>
00028 #include <string>
00029 #include <vector>
00030 using namespace std;
00031 using std::vector;
00032 using std::string;
00033
00034
00035 class CEvent;
00036 class CTodo;
00037 class CJournal;
00038 class CBdayEvent;
00039 class CProperties;
00040 class CCache;
00041 class CProperties;
00042 class CComponentDetails;
00043 class CRecurrence;
00044 class CAlarm;
00045 class CComponent;
00046 class CParameters;
00047 class CAttendee;
00048 class COrganizer;
00049 class CBdayEvent;
00050
00051
00052 const int SEC_IN_DAY = 86400;
00053 const int ATTACHMENTS = 2;
00054 const int RECURSIVE = 4;
00055 const int ATTENDEES = 6;
00056 const int ORGANIZER = 8;
00057
00058 enum ACTION {
00059 E_ADD = 0,
00060 E_MODIFY,
00061 E_DELETE
00062 };
00063
00064 enum CalendarColour {
00065 COLOUR_DARKBLUE = 0,
00066 COLOUR_DARKGREEN,
00067 COLOUR_DARKRED,
00068 COLOUR_ORANGE,
00069 COLOUR_VIOLET,
00070 COLOUR_YELLOW,
00071 COLOUR_WHITE,
00072 COLOUR_BLUE,
00073 COLOUR_RED,
00074 COLOUR_GREEN,
00075
00076 COLOUR_NEXT_FREE
00077 };
00078
00079 enum SyncProfileType{
00080 SYNC_METHOD_NONE=0,
00081 SYNC_METHOD_TWOWAY ,
00082 SYNC_METHOD_SEND,
00083 SYNC_METHOD_RECEIVE,
00084 SYNC_METHOD_WEB
00085 };
00086
00087 typedef enum {
00088 LOCAL_CALENDAR = 0,
00089 BIRTHDAY_CALENDAR,
00090 SYNC_CALENDAR,
00091 DEFAULT_PRIVATE,
00092 DEFAULT_SYNC
00093 } CalendarType;
00094
00095
00103 string intToString(int i);
00104
00105
00114 class CCalendar {
00115
00116 public:
00117
00118
00119
00120
00121 string getCacheEntry(time_t startDate, int &pErrorCode);
00122
00126 bool addCacheEntry(string sId, time_t startDate, int &pErrorCode);
00127
00128
00132 bool deleteCacheEntry(time_t startDate, int &pErrorCode);
00133
00137 int getCacheTableCount(time_t inputDate, int &pErrorCode);
00145 bool addCacheEntries(CComponent* pEntry, int &pErrorCode);
00146
00147
00148
00149
00150
00151 bool updateCacheEntry(string szId, time_t startDate, int &pErrorCode);
00152
00153
00154
00155
00156 bool appendToIds(string Id, string& szIds);
00157
00161 string removeFromIds(string Id, string szIdStrings);
00162
00167 bool deleteCacheEntries(string szId, int eEntry, int &pErrorCode);
00168
00172 bool modifyCacheEntry(CComponent* oldEntry, int &pErrorCode);
00176 void checkIfMultiDayEvent(CComponent* pEntry, vector <time_t> &vStartdates);
00177
00181 CCalendar(CCalendar & ref);
00182
00183
00187 const CCalendar & operator=(const CCalendar & right);
00188
00202 CCalendar(int iCalId, string szName, CalendarColour iColour, bool fIsReadOnly,
00203 bool fIsVisible, CalendarType iCalType ,string szCalendarTune);
00204
00218 CCalendar(string szName, CalendarColour iColour, bool fIsReadOnly,
00219 bool fIsVisible, CalendarType iCalType,string szCalendarTune,string szCalendarVersion);
00220
00236 vector < CComponent * > getAllEventsTodos( int iStDate, int iEndDate,
00237 int iLimit , int& iOffset,int& pErrorCode);
00238
00246 CCalendar();
00247
00261 bool setCalendarColor(CalendarColour iCalendarColor);
00262
00274 CalendarColour getCalendarColor();
00275
00283 bool setCalendarName(string szName);
00284
00291 string getCalendarName();
00292
00300 bool setCalendarId(int iId);
00301
00308 int getCalendarId();
00309
00310
00320 bool setCalendarType(CalendarType iCalType);
00327 void setProfileType(SyncProfileType iProfile);
00334 SyncProfileType getProfileType();
00335
00345 CalendarType getCalendarType();
00346
00353 bool setCalendarReadOnly(bool fIsReadOnly);
00354
00361 bool IsReadOnly();
00362
00369 bool setCalendarShown(bool fIsVisible);
00370
00377 bool IsShown();
00378
00389 bool modifyEvent(CEvent * pEvent,int &pErrorCode);
00390
00391
00400 bool modifyBirthDay(CBdayEvent *pBday,int& pErrorCode);
00401
00412 bool modifyJournal(CJournal * pJournal,int& pErrorCode);
00413
00424 bool modifyTodo(CTodo * pTodo,int& pErrorCode);
00425
00436 bool addEvent(CEvent * pEvent,int& pErrorCode);
00437
00438
00448 bool addBirthDay(CBdayEvent * pBday,int& pErrorCode);
00449
00460 bool addTodo(CTodo * ptrTodo,int& pErrorCode);
00461
00472 bool addJournal(CJournal * ptrJournal,int& pErrorCode);
00473
00483 bool deleteEvent(string sEventID,int& pErrorCode);
00484
00485
00493 bool deleteBirthDay(int iUid,int& pErrorCode);
00494
00504 bool deleteTodo(string sTodoID,int& pErrorCode);
00505
00514 bool deleteJournal(string sJournalID,int& pErrorCode);
00515
00523 void deleteComponent(string sId,int& pErrorCode);
00524
00533 vector < long > getCookie(string ietjId,int& pErrorCode);
00534
00541 string getCalendarVersion();
00542
00549 void setCalendarVersion(string szCalendarVersion);
00555 bool registerAlarmForVisibleCalendar( int& perrorCode);
00556
00565 ~CCalendar();
00575 vector<string> getIdList(int iCompType,int& pErrorCode);
00576
00588 CEvent *getEvent(string sComponentID,int& pErrorCode);
00589
00590
00602 CTodo *getTodo(string szComponentID,int& pErrorCode);
00603
00604
00616 CJournal *getJournal(string sComponentID,int& pErrorCode);
00626 bool checkDuplicateEntry(CComponent* pEntry,int iType , int& pErrorCode);
00627
00628
00637 vector < CEvent * >getDetailedEventList(int& pErrorCode);
00638
00639
00649 vector < CTodo * >getTodoListDetailed(int& pErrorCode);
00650
00651
00660 vector < CJournal * >getJournalListDetailed(int& pErrorCode);
00661
00662
00672 bool deleteBirthDay(string szUID,int& pErrorCode);
00673
00693 vector < CComponent * > getComponents(int iCalendarID,
00694 int iStartDate, int iEndDate,int& pErrorCode);
00695
00696
00726 vector < CComponent * > getComponents(int iCalendarID, int iStartDate,
00727 int iEndDate, int iLimit , int iOffset,int& pErrorCode);
00728
00729
00741 int updateTrash (int iCalendarID, string iComponentID, int iComponentType,
00742 time_t iDeletedTime, int& pErrorCode);
00743
00744
00754 vector < CEvent * > getAllAddedEvents(int iDate,int& pErrorCode);
00755
00765 vector < CTodo * > getAllAddedTodos(int iDate,int& pErrorCode);
00766
00776 vector < CJournal * > getAllAddedJournals(int iDate,int& pErrorCode);
00777
00788 vector < CComponent * >getAllAddItems(int iDate,int& pErrorCode);
00789
00800 vector < CEvent * > getAllModifiedEvents(int iDate,int& pErrorCode);
00801
00813 vector < CTodo * > getAllModifiedTodos(int iDate,int& pErrorCode);
00814
00825 vector < CJournal * > getAllModifiedJournals(int iDate,int& pErrorCode);
00826
00837 vector < CComponent * >getAllModifiedItems(int iDate,int& pErrorCode);
00838
00850 vector < string >getAllDeletedItems(int iDate,int iType,int& pErrorCode);
00851
00859 int exportCalendarEntries(string szFilename,int& pErrorCode);
00860
00870 bool setNextAlarm (string sComponentId,int iType,int& pErrorCode);
00871
00878 void setCalendarTune(string szCalendarTune);
00885 string getCalendarTune();
00886
00887
00898 bool addParameters(map< string, vector < CParameters* > > hashMap,string sId,ACTION iAction,int& pErrorCode,bool clearHashMap = true);
00899
00910 bool addXProperties(vector < CProperties* > vXProp,string sId,ACTION iAction,int& pErrorCode);
00921 string getExternalToLocalId(string sId,bool fetchLocal, int & pErrorCode);
00922
00931 bool addMapTableInfo(string sLocalId,string sExternalId,int & pErrorCode);
00940 vector<string> getAllDeletedEvents (int iLastSyncDate,int& pErrorCode);
00949 vector<string> getAllDeletedJournals(int iLastSyncDate,int& pErrorCode);
00950
00959 vector<string> getAllDeletedTodos(int iLastSyncDate,int& pErrorCode);
00968 bool destroyExistingValidAlarms(int& pErrorCode );
00977 bool checkEntryExist(string szTable, string iId,int& pErrorCode);
00978
00986 CComponent* getEntry(string sCompId , int iType, int &pErrorCode);
00987
00996 vector <CEvent *> getDetailedBdayList(int &pErrorCode);
00997
01006 CEvent* getBirthDayEvent(string sCompId, int &pErrorCode);
01007
01015 void deleteComponents(vector<string> idList,int &ErrorCode);
01024 void modifyComponents(vector<CComponent*> &compList,int &ErrorCode);
01042 vector<string> addComponents(vector<CComponent*> &compList,vector <string> &duplicateIds,int &ErrorCode);
01049 vector <CEvent*> getEvents(int & pErrorCode);
01056 vector <CTodo*> getTodos(int & pErrorCode );
01063 vector <CJournal*> getJournals(int & pErrorCode );
01064
01068 string toString();
01069
01070
01071 private:
01072
01073
01074
01075 vector<CCache*> getDeletedCacheTableInfo(string sCompId,int& pErrorCode);
01076
01077 bool updateAttendeesForComponent(CComponentDetails *pCompDetails,
01078 int &pErrorCode);
01079 bool deleteAttendeesForComponent(CComponentDetails *pCompDetails,
01080 int &pErrorCode);
01081 bool updateOrganizerForComponent(CComponentDetails *pCompDetails,
01082 int &pErrorCode);
01083 bool deleteOrganizerForComponent(CComponentDetails *pCompDetails,
01084 int &pErrorCode);
01085 bool updateXPropertiesForComponent(CComponentDetails *pEntry,
01086 int &pErrorCode);
01087 bool deleteXPropertiesForComponent (CComponentDetails *pEntry,
01088 int &pErrorCode);
01089 bool updateParametersForComponent(CComponentDetails *pEntry,
01090 int &pErrorCode);
01091 bool deleteParametersForComponent (CComponentDetails *pEntry,
01092 int &pErrorCode);
01093
01094 bool deregisterAlarm (CComponentDetails *pCompDetails,
01095 int &pErrorCode);
01096
01103 bool checkFieldinTable(string szTable,string szField,string szValue);
01104
01115 vector <CComponent *> getRecursiveEventsInRange( int iStartDate,
01116 int iEndDate, vector < CComponent * >vListEntry,int& pErrorCode);
01117
01118
01129 vector < string > getChangeIds(int iComponentType, int iChangeType,
01130 int iDate,int& pErrorCode);
01131
01141 bool entrySetModifiedTime(CComponent * pEntry,int& pErrorCode);
01142
01143
01152 template < class comp > bool addCompDetails(sqlite3_stmt * pStmt, comp * cDet
01153 ,int& pErrorCode);
01154
01155
01163 bool addEventCompDetails(CEvent * pEvent,int& pErrorCode);
01164
01172 bool addTodoCompDetails(CTodo * ptrTodo,int& pErrorCode);
01173
01181 bool addJournalCompDetails(CJournal * ptrJournal,int& pErrorCode);
01182
01192 bool manageCookie(const ACTION iAction, CComponent * pcomp,int& pErrorCode);
01202 bool addAlarm(CAlarm * ptrAlarm, ACTION iAction, string sId,int& pErrorCode);
01203
01213 bool addRecurrence(CRecurrence * ptrRecur,
01214 string sId,int& pErrorCode);
01215 bool modifyRecurrence(CRecurrence * ptrRecur,
01216 string sId,int& pErrorCode);
01217
01218
01219
01220
01221
01222
01223
01224
01238 bool addAttendeeDetails(vector < CAttendee * >vAttendeeList, string sId,
01239 int iType,ACTION iAction,int& pErrorCode);
01240
01253 bool addOrganizer(COrganizer * ptrOrganizer, string sId,
01254 int iType,ACTION iAction,int& pErrorCode);
01255
01266 template < class ent > int addComponent(ent * pEvent, ACTION iAction,int& pErrorCode);
01267
01268
01269 string szName;
01271 CalendarColour iColor;
01273 bool fReadOnly;
01275 bool fIsVisible;
01277 int iCalId;
01279 CalendarType iCalType;
01281 string szCalendarTune;
01282
01283 string szCalendarVersion ;
01284
01285 SyncProfileType iProfileType ;
01286
01287 };
01288
01289 #endif