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);
00456 int getComponentsAllCalendars( int iStDate, int iEndDate,
00457 int iLimit,int iOffset, vector<CComponent*> &vComponents, int iQueryType=0);
00458
00475 int getComponentsAllCalendarsBySummary(std::string sSummary, int iLimit, int iOffset,
00476 vector<CComponent*> &vComponents);
00477
00489 vector < CComponent * > getAllEventsTodos(int iCalid, int iStDate,
00490 int iEndDate, int iLimit , int iOffset,int& pErrorCode);
00491
00501 bool deleteEventAndTodoBeyond(int iCalId, time_t iUtc,
00502 int iType,int &pErrorCode);
00514 bool addEvent(CEvent * pEvent, int iCalendarId,int& pErrorCode);
00515
00524 bool modifyEvent(CEvent * pEvent, int iCalendarId,int& pErrorCode);
00525
00534 bool deleteEvent(int iCalId, string sCompId,int& pErrorCode);
00535
00536
00547 bool addTodo(CTodo * pTodo, int iCalendarId,int& pErrorCode);
00548
00557 bool modifyTodo(CTodo * pTodo, int iCalendarId,int& pErrorCode);
00558
00567 bool deleteTodo(int iCalId, string sCompId,int& pErrorCode);
00568
00569
00578 bool addJournal(CJournal * pJournal, int iCalendarId,int& pErrorCode);
00579
00588 bool modifyJournal(CJournal * pJournal, int iCalendarId,int& pErrorCode);
00589
00598 bool deleteJournal(int iCalId, string sCompId,int& pErrorCode);
00599
00605 static CMulticalendar *MCInstance();
00606
00614 int getEventCount(int iCalId,int& pErrorCode);
00615
00623 int getTodoCount(int iCalId,int& pErrorCode);
00624
00632 int getNoteCount(int iCalId,int& pErrorCode);
00633
00643 vector < CCalendar * > getListCalFromMc();
00644
00652 void releaseListCalendars(vector<CCalendar*> Calendars);
00653
00662 bool modifyCalendar(CCalendar* pCal,int& pErrorCode);
00663
00673 int addCalendar(CCalendar* pCal,int& pErrorCode);
00682 int getNumOfUndoneTasks(int* iCalId,int& pErrorCode);
00689 int getNumOfAllDayEventsForToday(int& pErrorCode);
00699 vector <CComponent*> getTodaysAllDay(int &pErrorCode);
00700
00704 ~CMulticalendar();
00705
00715 bool addBirthDay(CBdayEvent * pBday,int& pErrorCode);
00716
00724 bool addBirthdays(vector<CBdayEvent*>& pBdays, int &pErrorCode);
00725
00733 bool modifyBirthDay(CBdayEvent * pBday,int& pErrorCode);
00734
00742 bool deleteBirthDay(string szEUid,int& pErrorCode);
00743
00751 bool deleteBirthdays(vector<string> &szEUidList,int& pErrorCode);
00752
00761 CCalendar *getCalendarByType(int iCalTypei,int& pErrorCode);
00762
00782 vector < CComponent * > getComponents(int iCalId, int iType, int iStDate,
00783 int iEndDate,int iLimit,int iOffset,int& pErrorCode);
00784
00785
00794 int setAutocommitOff ();
00795
00796
00805 bool commitAllChanges ();
00806
00814 bool rollbackAllChanges ();
00815
00829 bool setNextAlarm (int iCalendarId, string sComponentId,int iType,int& pErrorCode);
00830
00837 void setApplicationName (string ApplicationName);
00844 string getApplicationName ();
00851 bool checkCalendarNameExists(string szName);
00861 CComponent* getLatestComponent(int iType,time_t &startdate,int &ioffset,int& pErrorCode );
00868 string getDefaultCalendarName();
00880 CComponent* getPrevNextComponent(string szId , time_t iDateStart,
00881 bool isPrev,int& iCalid,time_t &instance_time,int& perrorcode);
00887 void MCdestroy();
00894 vector<CComponent*> popEventDetails (QueryResult* pQr);
00895
00901 int getCalendarIdForComponent(string iI,int &pErrorCode);
00902
00911 CCalendar* getBirthdayCalendar();
00918 bool deleteBirthdaysForCalendar(int iCalid,int & pErrorCode);
00926 int getBdayEventCount(int iCalId,int& pErrorCode);
00927
00932 static time_t getSystemTimeShift();
00937 static string getSystemTimeZone();
00945 void clearCalendar(int iCalId,int &pErrorCode );
00954 void clearCalendarContents(int iCalId,int &pErrorCode );
00959 icaltimezone* getSystemTimeZoneAsIcalTimeZone();
00962 void printCurrentTime();
00966
00976 vector <string> addComponents(vector<CComponent*> &compList,
00977 int iCalId,
00978 vector<string> & duplicateId,
00979 int &ErroCode);
00980
00989 void deleteComponents(vector<string> &idList,
00990 int iCalId,
00991 int &ErrorCode);
00992
01001 void modifyComponents(vector<CComponent*> &compList,
01002 int iCalId,
01003 int &ErrorCode);
01010 int getVisibleCalendarCount(int &pErrorCode);
01011
01012
01013
01014
01015 void findRecursiveImpendingEventId(time_t OriginalDateStart,
01016 time_t timebasedDateStart,
01017 bool isPrev,
01018 string &szEventId,
01019 time_t &instance_time,
01020 int &pErrorCode);
01021
01022 string getEventIdFromMap(map<time_t,string > &timeEventIdMap,
01023 time_t &timebasedDateStart,
01024 time_t &OriginalDateStart ,
01025 bool isPrev,
01026 time_t &instance_time);
01035 void enableDisableCalendarLogs(int value );
01036
01037 void deleteItemsByIdList(vector<string> &listId, int& pErrorCode);
01038
01043 bool moveFileFromSkel(string oldpath, string newpath);
01047 static bool checkFileExists(string szPath);
01052 int getComponentCount(int &pErrorCode);
01057 CEvent *localBdayEventFromRemoteId(string szExId,int &pErrorCode);
01058
01069 bool getInstances(string sId, time_t timeFrom, time_t timeTo, vector <time_t> &result, time_t tzshift=0);
01070
01071
01081 int getInstanceNumber(string sId, time_t timeFrom, time_t timeTo, time_t tzshift=0);
01082
01089 bool dropInstances(string sId);
01090
01100 bool addInstance(string sId, time_t instTime, time_t duration, time_t tzshift=0);
01101
01111 bool addInstances(string sId, vector <time_t> instances, time_t duration, time_t tzshift=0);
01112
01131 vector <CComponent*> getComponentsWithLimitedData (
01132 int iStDate,int iEndDate,int iLimit,
01133 int iOffset, vector <int> &vCalid,int &pErrorCode);
01137 bool checkExistenceOfFutureRepeatingEvent(time_t OriginalDateStart,
01138 string sId,
01139 int& pErrorCode);
01140
01171 bool checkForNextPrev(time_t instanceTime,string Id ,bool isPrev, int &pErrorCode);
01172
01173
01180 CalendarColour getUnusedCalendarColor(void);
01181
01185 static void reloadSystemTimezone();
01186
01190 void getImpendingAlarm (string szRrule,time_t & triggerTime,
01191 time_t dateStart, int alarmFlag, icaltimezone* pTz);
01192
01193
01194 private:
01195
01196
01200 CMulticalendar();
01201
01202
01213 vector<string> giveRecursiveExpiredEvents(int iCalId,int iType,int iDayBefore,int iMax,int &iLimit,int &pErrorCode);
01226 time_t getInstanceBeyond(string szRRule, icaltimetype iDtStart, time_t iViewEnd, icaltimezone* pTz, int& pErrorCode);
01237 vector < string > giveExpiredEntries(int iCalId, int iType, int iConfiguredTime,int& pErrorCode);
01238
01248 int getCount(int iCalId, int iType,int& pErrorCode);
01249
01260 string generateRrule(int iRepeatType, time_t iUntil,int& pErrorCode);
01261
01262
01268 CMulticalendar(CMulticalendar & ref);
01269
01274 CMulticalendar & operator=(CMulticalendar & calendardb);
01275
01285 void setCalendarName(CCalendar* pCalendar, string szCalendarName) const;
01286
01287
01288
01289 int iMaxId;
01290
01291
01292 string AppName;
01293 static CMulticalendar *pMc;
01294 static std::string szSystemTimezone;
01295
01296
01297 int regenerateInstances();
01298
01306 int deleteNonRecurrentComponents(int iDayBefore, int iMax, int &pErrorCode);
01307
01308
01315 bool deleteAllComponents(int iCalId, int &pErrorCode);
01316
01321 void cleanupIcsString(std::string &ics_line);
01322
01326 void restoreAlarms();
01327
01337 int comparePrevNextComponent(CComponent *c1, CComponent *c2, time_t t1 = -1, time_t t2 = -1);
01338 };
01339
01340 #endif