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 __MULTI_CALENDAR_H__
00025 #define __MULTI_CALENDAR_H__
00026
00027
00028 extern "C" {
00029 #include <libical/ical.h>
00030 }
00031 #include <string>
00032 #include <vector>
00033 #include "CCalendar.h"
00034
00035 class CComponent;
00036 class CCalendarDB;
00037 class CBdayEvent;
00038 #ifndef _QRESULT__
00039 #define _QRESULT__
00040 typedef struct _QueryResult QueryResult;
00041
00042 struct _QueryResult {
00043 public:
00044 char **pResult;
00045 int iRow;
00046 int iColumn;
00047 };
00048 #endif
00049
00059 class CMulticalendar {
00060
00061 public:
00066 bool getRequiredDates(time_t iCurrTime, int iFutureDateNum,
00067 int iBackDateNum, int &iStartDate, int &iEndDate,
00068 vector<string> &vIdList,int &pErrorCode);
00073 int getDateRange(time_t currTime, int iNum, bool iOperation,
00074 string &szTemp, int &pErrorCode);
00075
00076
00077 vector<CComponent*> getEventInList(vector<string> listId ,
00078 vector<int> &vCalId,int & pErrorCode);
00079
00088 CCalendar* getSynchronizedCalendar();
00098 CCalendar* getDefaultCalendar();
00110 bool getICSFileInfo(string szFileName,unsigned int& iEventCount,
00111 unsigned int& iTodoCount,unsigned int& iJournalCount ,
00112 int& pErrorCode );
00113
00114
00115
00116 bool getICSFileInfoProgressive(string szFileName,
00117 unsigned int &iEventCount,
00118 unsigned int &iTodoCount,
00119 unsigned int &iJournalCount,
00120 int &pErrorCode, bool *bFileReadingOver,
00121 unsigned int iRequestLimit);
00125 void cancelImportIcsFileData();
00131 string getSynchronizedCalendarName();
00132
00140 string getCTCapXML();
00141
00142
00143
00147 bool importIcsFileDataProgressive(string szFileName, int iCalId,
00148 string & eventId,int &iDuplicateCountTask,
00149 int &iDuplicateCountEvent,int &iDuplicateCountJournal,
00150 int &pErrorCode, bool *bFileReadingOver,
00151 unsigned int iRequestLimit);
00164 bool importIcsFileData(string szFileName, int iCalId,
00165 string & eventId,int &iDuplicateCountTask,
00166 int &iDuplicateCountEvent,int &iDuplicateCountJournal,int &pErrorCode);
00171 int totalComponentsRead(string szLine, bool &bError,
00172 int &iEventBegin, int &iJournalBegin, int &iToDoBegin,
00173 unsigned int &iEventCount, unsigned int &iTodoCount,
00174 unsigned int &iJournalCount);
00185 int exportCalendarEntries(int iCalendarId,string szFileName,int& pErrorCode);
00186
00198 bool deleteEventBeyond(int iCalId, time_t iUtc,int& pErrorCode);
00199
00200
00212 bool deleteTodosBeyond(int iCalId, time_t iUtc,int& pErrorCode);
00213
00222 CCalendar *getCalendarByName(string szName,int& pErrorCode);
00223
00224
00237 bool deleteJournalsBeyond(int iCalId, time_t iUtc,int& pErrorCode);
00238
00250 bool enableAutomaticDeletion(int iDayBefore,int iMax,int& iLimit,int& pErrorCode);
00251
00266 vector < time_t > getRecurrentTimes(string szRRule, icaltimetype iDtStart,
00267 time_t iViewEnd,icaltimezone *pTz,int& pErrorCode, int limit=-1);
00268
00285 bool getRecurrentTimes(string szRRule,
00286 icaltimetype iDtStart,
00287 int iEventDuration,
00288 time_t iViewBegin,
00289 time_t iViewEnd,
00290 icaltimezone *pTz,
00291 vector <time_t> &outTimes,
00292 int& pErrorCode,
00293 int limit=-1);
00305 bool checkRecurrentTimes(string szRRule, icaltimetype iDtStart,
00306 time_t iViewEnd,icaltimezone *pTz,int& pErrorCode);
00307
00322 bool checkRecurrentTimes(string szRRule,
00323 icaltimetype iDtStart,
00324 int iEventDuration,
00325 time_t iViewBegin,
00326 time_t iViewEnd,
00327 icaltimezone *pTz,
00328 int& pErrorCode);
00329
00346 vector < CComponent * >getComponents(int iCalId, int iType, int iStDate, int iEndDatei,int& pErrorCode);
00347
00348
00355 int getNoofCalendars();
00370 CCalendar* addCalendar(string szTitle, CalendarColour iColor, int iReadOnly,
00371 int iVisible,CalendarType iType,string szCalendarTune,
00372 string szCalendarVersion,int& pErrorCode);
00388 bool modifyCalendar(int iId ,string szTitle, CalendarColour iColor,
00389 int iReadOnly,int iVisible,CalendarType iType,string szCalendarTune,
00390 string szCalendarVersion,int& pErrorCode);
00391
00400 bool deleteCalendar(int iCalId,int& pErrorCode);
00401
00411 CCalendar *getCalendarById(int iCalId,int& pErrorCode);
00412
00434 vector < CComponent * > getComponentsAllCalendars( int iStDate, int iEndDate,
00435 int iLimit,int iOffset,vector<int > &vCalid , int &pErrorCode,int iQueryType=0);
00447 vector < CComponent * > getAllEventsTodos(int iCalid, int iStDate,
00448 int iEndDate, int iLimit , int iOffset,int& pErrorCode);
00449
00459 bool deleteEventAndTodoBeyond(int iCalId, time_t iUtc,
00460 int iType,int &pErrorCode);
00472 bool addEvent(CEvent * pEvent, int iCalendarId,int& pErrorCode);
00473
00482 bool modifyEvent(CEvent * pEvent, int iCalendarId,int& pErrorCode);
00483
00492 bool deleteEvent(int iCalId, string sCompId,int& pErrorCode);
00493
00494
00505 bool addTodo(CTodo * pTodo, int iCalendarId,int& pErrorCode);
00506
00515 bool modifyTodo(CTodo * pTodo, int iCalendarId,int& pErrorCode);
00516
00525 bool deleteTodo(int iCalId, string sCompId,int& pErrorCode);
00526
00527
00536 bool addJournal(CJournal * pJournal, int iCalendarId,int& pErrorCode);
00537
00546 bool modifyJournal(CJournal * pJournal, int iCalendarId,int& pErrorCode);
00547
00556 bool deleteJournal(int iCalId, string sCompId,int& pErrorCode);
00557
00563 static CMulticalendar *MCInstance();
00564
00572 int getEventCount(int iCalId,int& pErrorCode);
00573
00581 int getTodoCount(int iCalId,int& pErrorCode);
00582
00590 int getNoteCount(int iCalId,int& pErrorCode);
00591
00601 vector < CCalendar * > getListCalFromMc();
00602
00610 void releaseListCalendars(vector<CCalendar*> Calendars);
00611
00620 bool modifyCalendar(CCalendar* pCal,int& pErrorCode);
00621
00631 int addCalendar(CCalendar* pCal,int& pErrorCode);
00640 int getNumOfUndoneTasks(int* iCalId,int& pErrorCode);
00647 int getNumOfAllDayEventsForToday(int& pErrorCode);
00657 vector <CComponent*> getTodaysAllDay(int &pErrorCode);
00658
00662 ~CMulticalendar();
00663
00673 bool addBirthDay(CBdayEvent * pBday,int& pErrorCode);
00674
00682 bool addBirthdays(vector<CBdayEvent*>& pBdays, int &pErrorCode);
00683
00691 bool modifyBirthDay(CBdayEvent * pBday,int& pErrorCode);
00692
00700 bool deleteBirthDay(string szEUid,int& pErrorCode);
00701
00709 bool deleteBirthdays(vector<string> &szEUidList,int& pErrorCode);
00710
00719 CCalendar *getCalendarByType(int iCalTypei,int& pErrorCode);
00720
00740 vector < CComponent * > getComponents(int iCalId, int iType, int iStDate,
00741 int iEndDate,int iLimit,int iOffset,int& pErrorCode);
00742
00743
00752 int setAutocommitOff ();
00753
00754
00763 bool commitAllChanges ();
00764
00772 bool rollbackAllChanges ();
00773
00787 bool setNextAlarm (int iCalendarId, string sComponentId,int iType,int& pErrorCode);
00788
00795 void setApplicationName (string ApplicationName);
00802 string getApplicationName ();
00809 bool checkCalendarNameExists(string szName);
00819 CComponent* getLatestComponent(int iType,time_t &startdate,int &ioffset,int& pErrorCode );
00826 string getDefaultCalendarName();
00838 CComponent* getPrevNextComponent(string szId , time_t iDateStart,
00839 bool isPrev,int& iCalid,time_t &instance_time,int& perrorcode);
00845 void MCdestroy();
00852 vector<CComponent*> popEventDetails (QueryResult* pQr);
00853
00859 int getCalendarIdForComponent(string iI,int &pErrorCode);
00860
00869 CCalendar* getBirthdayCalendar();
00876 bool deleteBirthdaysForCalendar(int iCalid,int & pErrorCode);
00884 int getBdayEventCount(int iCalId,int& pErrorCode);
00885
00890 static time_t getSystemTimeShift();
00895 static string getSystemTimeZone();
00903 void clearCalendar(int iCalId,int &pErrorCode );
00912 void clearCalendarContents(int iCalId,int &pErrorCode );
00917 icaltimezone* getSystemTimeZoneAsIcalTimeZone();
00920 void printCurrentTime();
00924
00934 vector <string> addComponents(vector<CComponent*> &compList,
00935 int iCalId,
00936 vector<string> & duplicateId,
00937 int &ErroCode);
00938
00947 void deleteComponents(vector<string> &idList,
00948 int iCalId,
00949 int &ErrorCode);
00950
00959 void modifyComponents(vector<CComponent*> &compList,
00960 int iCalId,
00961 int &ErrorCode);
00968 int getVisibleCalendarCount(int &pErrorCode);
00969
00970
00971
00972
00973 void findRecursiveImpendingEventId(time_t OriginalDateStart,
00974 time_t timebasedDateStart,
00975 bool isPrev,
00976 string &szEventId,
00977 time_t &instance_time,
00978 int &pErrorCode);
00979
00980 string getEventIdFromMap(map<time_t,string > &timeEventIdMap,
00981 time_t &timebasedDateStart,
00982 time_t &OriginalDateStart ,
00983 bool isPrev,
00984 time_t &instance_time);
00993 void enableDisableCalendarLogs(int value );
00994
00995 void deleteItemsByIdList(vector<string> &listId, int& pErrorCode);
00996
01001 bool moveFileFromSkel(string oldpath, string newpath);
01005 static bool checkFileExists(string szPath);
01010 int getComponentCount(int &pErrorCode);
01015 CEvent *localBdayEventFromRemoteId(string szExId,int &pErrorCode);
01016
01027 bool getInstances(string sId, time_t timeFrom, time_t timeTo, vector <time_t> &result, time_t tzshift=0);
01028
01029
01039 int getInstanceNumber(string sId, time_t timeFrom, time_t timeTo, time_t tzshift=0);
01040
01047 bool dropInstances(string sId);
01048
01058 bool addInstance(string sId, time_t instTime, time_t duration, time_t tzshift=0);
01059
01069 bool addInstances(string sId, vector <time_t> instances, time_t duration, time_t tzshift=0);
01070
01089 vector <CComponent*> getComponentsWithLimitedData (
01090 int iStDate,int iEndDate,int iLimit,
01091 int iOffset, vector <int> &vCalid,int &pErrorCode);
01095 bool checkExistenceOfFutureRepeatingEvent(time_t OriginalDateStart,
01096 string sId,
01097 int& pErrorCode);
01098
01129 bool checkForNextPrev(time_t instanceTime,string Id ,bool isPrev, int &pErrorCode);
01130
01131
01138 CalendarColour getUnusedCalendarColor(void);
01139
01143 static void reloadSystemTimezone();
01144
01148 void getImpendingAlarm (string szRrule,time_t & triggerTime,
01149 time_t dateStart, int alarmFlag, icaltimezone* pTz);
01150
01151
01152 private:
01153
01154
01158 CMulticalendar();
01159
01160
01171 vector<string> giveRecursiveExpiredEvents(int iCalId,int iType,int iDayBefore,int iMax,int &iLimit,int &pErrorCode);
01184 time_t getInstanceBeyond(string szRRule, icaltimetype iDtStart, time_t iViewEnd, icaltimezone* pTz, int& pErrorCode);
01195 vector < string > giveExpiredEntries(int iCalId, int iType, int iConfiguredTime,int& pErrorCode);
01196
01206 int getCount(int iCalId, int iType,int& pErrorCode);
01207
01218 string generateRrule(int iRepeatType, time_t iUntil,int& pErrorCode);
01219
01220
01226 CMulticalendar(CMulticalendar & ref);
01227
01232 CMulticalendar & operator=(CMulticalendar & calendardb);
01233
01243 void setCalendarName(CCalendar* pCalendar, string szCalendarName) const;
01244
01245
01246
01247 int iMaxId;
01248
01249
01250 string AppName;
01251 static CMulticalendar *pMc;
01252 static std::string szSystemTimezone;
01253
01254
01255 int regenerateInstances();
01256
01264 int deleteNonRecurrentComponents(int iDayBefore, int iMax, int &pErrorCode);
01265
01266
01273 bool deleteAllComponents(int iCalId, int &pErrorCode);
01274
01279 void cleanupIcsString(std::string &ics_line);
01280 };
01281
01282 #endif