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 __ICALCONVERTER_H__
00025 #define __ICALCONVERTER_H__
00026 using namespace std;
00027 extern "C" {
00028 #include <libical/ical.h>
00029 #include <libical/icalcomponent.h>
00030 #include <libical/icalenums.h>
00031 #include "stdlib.h"
00032 #include "stdio.h"
00033 }
00034 #include "Common.h"
00035 #include "CParameters.h"
00036 typedef enum {
00037 ICAL_TYPE = 0,
00038 VCAL_TYPE,
00039 UNKNOWN_TYPE
00040 }FileType;
00045 class ICalConverter {
00046
00047 public:
00058 string localToIcalVcal(CComponent *pEntry,FileType iType,int &pErrorCode);
00059
00065 void setSyncing(bool sync);
00069 void findEffectiveDSToffset(string szLine,string &szDaylight);
00080 CComponent *toLocal(string strIcalComp,FileType iType,int &pErrorCode);
00084 ICalConverter();
00088 ~ICalConverter();
00089
00096 string appendControlM(string szContents);
00097
00103 string toString();
00114 vector < CComponent* > icalVcalToLocal(string strIcalComp,FileType iType,int &pErrorCode);
00122 string strip(string szContents);
00135 bool checkCount(string szContents,string szBegin,string szEnd,unsigned int& iCount);
00144 string validateContents(string szContents);
00152 int getIntFromIcaltimetype(struct icaltimetype ical_time);
00158 char* decodeParameterTextFields(string encodedString,
00159 icalparameter_encoding encodingType);
00160
00161
00162
00163
00164 char* getCurrentTimeZone();
00168 void fillvCalTimeZone(string &szContents);
00169 string exportTimeZone(time_t dtstart,string szZone,FileType iType);
00170 string calculateMonthdayFromRule(time_t dtstart,struct icaltimetype &dtstartStd,string ruleStd,string szZone);
00171 private:
00178 void findZoneStartTime(string &szRepeatPattern, int correction);
00186 void findLocationFromOffset(string szDaylight);
00191 void limitDateRange(struct icaltimetype &s_time,bool isExport);
00192
00196 void replaceWithEncodedString(string &szIcalComp,
00197 CComponentDetails *pEntry);
00201 void convertAttach(string &szAttach);
00205 void getImpendingAlarm (string szRrule,time_t & triggerTime, time_t dateStart, int alarmFlag);
00212 float stringToFloat(string szValue);
00221 string addAlarmDateToString(string strIcalComp, string strVCalAlarmDate,
00222 entryType iType);
00231 string addRuleToString(string strIcalComp, vector < string > rrules,
00232 int flag);
00242 string getIcalAlarm(CAlarm * cAlarm,string sZone,bool isAllday = false);
00249 void deleteWhiteSpaces(string &szSpaceString );
00260 vector<CRecurrenceRule*> getRecurrence(string strIcalComp, icalcomponent* pComp, icalproperty_kind kind,FileType iFType);
00261
00272 CRecurrenceRule* getRecurrenceRule(string strIcalComp, int index, string strRuleType,FileType iFType);
00273
00284 vector<string> getRecurrenceDates(string strIcalComp, icalcomponent *pComp,
00285 CEvent* pEvent, icalproperty_kind kind,int type=ICAL_TYPE);
00286
00287
00288
00299 template<class T> CAlarm* getAlarm(string strIcalComp, icalcomponent *pComp,
00300 T* pEntry);
00301
00302
00309 struct tm initTime(icaltimetype time_ical);
00310
00319 string get_line(string strIcal, int start_loc);
00320
00328 string get_line_in_ical(string strInVcal, string strType, int index);
00329
00337 string getTranspFromIcal(icalproperty_transp iTransp);
00338
00345 COrganizer* getOrganizerFromIcal(icalproperty *pProp);
00346
00354 CAttendee* getAttendeeFromIcal(icalproperty *pProp,FileType iType);
00355
00363 int getParticipationRoleFromIcal(icalparameter_role icalRole);
00364
00372 int getParticipationStatusFromIcal(icalparameter_partstat icalPartStat);
00373
00381 bool getRSVPFromIcal(icalparameter_rsvp icalRSVP);
00382
00390 int getCUTypeFromIcal(icalparameter_cutype icalCUType);
00391
00399 string getClasFromIcal(icalproperty_class iClass);
00400
00407 icalproperty* getIcalOrganizer(COrganizer* pOrg);
00408
00415 string getContactFromIcal(icalproperty* pProp);
00416
00424 icalparameter_rsvp getIcalRSVP(bool fRSVP);
00425
00433 icalparameter_partstat getIcalPartStatus(ParticipantStatus iPartStat);
00434
00442 icalparameter_role getIcalPartRole(ParticipantRole iRole);
00443
00451 icalparameter_cutype getIcalCalendarUserType(CalendarUserType iCUType);
00452
00459 icalproperty* getIcalAttendee_ical(CAttendee* pAtten);
00460
00461 icalproperty* getIcalAttendee_vcal(CAttendee* pAtten);
00462
00469 CProperties* getXProperty(icalproperty *pProp);
00470
00477 CParameters* getParameters(icalparameter *pParam);
00478
00485 vector <CParameters*> getRelationshipParamFromICal(icalparameter* pParam);
00486
00493 int getStatusFromIcal(icalproperty_status icalStatus);
00494
00501 CParameters* getLanguageFromIcal(icalparameter* pParam);
00502
00509 CParameters* getAlterFromIcal(icalparameter* pParam);
00510
00517 vector < CParameters* > getLangAlterParam(icalproperty* pProp);
00518
00526 int getIcalStatus(statusParam iStatus);
00534 icalparameter_reltype getIcalRelType(RelationshipType iRel);
00541 CParameters* getFMTypeFromIcal(icalparameter* pParam);
00547 icalparameter* getTZIDParam();
00548
00549 string getTimeInHHMM(int offset);
00550
00551
00552 time_t getTimeDiff(time_t diffTime );
00553 void exportEventProperties (icalcomponent *pEntComp, CEvent *pEvent, FileType iType);
00554 void exportTodoProperties (icalcomponent *pEntComp, CTodo *pTodo, FileType iType);
00555 void exportJournalProperties (icalcomponent *pEntComp, CJournal *pJournal, FileType iType);
00556
00557 template<class T> void exportCreatedTimeFromLocal(icalcomponent *pEntComp,
00558 T *pComp, FileType iType);
00559 template<class T> void exportDueFromLocal(icalcomponent *pEntcomp, T *pComp);
00560 template<class T> void exportDateStampFromLocal(icalcomponent *pEntcomp, T *pComp);
00561 template<class T> void exportSummaryFromLocal(icalcomponent *pEntcomp, T *pComp);
00562 template<class T> void exportLocationFromLocal(icalcomponent *pEntcomp, T *pComp);
00563 template<class T> void exportDescriptionFromLocal(icalcomponent *pEntcomp, T *pComp);
00564 template<class T> void exportUidFromLocal(icalcomponent *pEntcomp, T *pComp);
00565 template<class T> void exportDateStartFromLocal(icalcomponent *pEntcomp, T *pComp,FileType iType);
00566 template<class T> void exportAttendeesFromLocal(icalcomponent *pEntcomp, T *pComp, FileType iType);
00567 template<class T> void exportAttachmentsFromLocal(icalcomponent *pEntcomp, T *pComp);
00568 template<class T> void exportPriorityFromLocal(icalcomponent *pEntcomp, T *pComp);
00569 template<class T> void exportSequenceFromLocal(icalcomponent *pEntcomp, T *pComp);
00570 template<class T> void exportCommentsFromLocal(icalcomponent *pEntcomp, T *pComp);
00571 template<class T> void exportUrlFromLocal(icalcomponent *pEntcomp, T *pComp);
00572 template<class T> void exportCategoriesFromLocal(icalcomponent *pEntcomp, T *pComp);
00573 template<class T> void exportGeoFromLocal(icalcomponent *pEntcomp, T *pComp);
00574 template<class T> void exportClassFromLocal(icalcomponent *pEntcomp, T *pComp);
00575 template<class T> void exportRelatedFromLocal(icalcomponent *pEntcomp, T *pComp);
00576 template<class T> void exportOrganizerFromLocal(icalcomponent *pEntcomp, T *pComp);
00577 template<class T> void exportXPropFromLocal(icalcomponent *pEntcomp, T *pComp);
00578 template<class T> void exportResourcesFromLocal(icalcomponent *pEntcomp, T *pComp);
00579 template<class T> void exportContactsFromLocal(icalcomponent *pEntcomp, T *pComp);
00580 template<class T> string exportAlarmFromLocal(T *pComp, FileType iType);
00581 void exportEventDateEndFromLocal(icalcomponent *pEntcomp, CEvent *pEvent,FileType iType);
00582 void exportEventTranspFromLocal(icalcomponent *pEntcomp, CEvent *pEvent, FileType iType);
00583 void exportTodoPercentCompleteFromLocal(icalcomponent *pEntcomp, CTodo *pTodo);
00584 void exportTodoCompletedFromLocal(icalcomponent *pEntcomp, CTodo *pTodo);
00585
00586 void exportEntryStatusFromLocal(icalcomponent *pEntcomp, CComponent *pEntry,
00587 FileType iType);
00588 void exportEntryLastModifiedFromLocal(icalcomponent *pEntcomp, CComponent *pEntry);
00589 template<class T> struct icaltimetype importCreatedTime(icalcomponent *pComp,
00590 T *tComp, FileType iType, string strIcalComp);
00591 template<class T> void importDateStamp(icalcomponent *pComp, T *tComp, struct icaltimetype c_time);
00592 template<class T> void importOrganizer(icalcomponent *pComp, T *tComp);
00593 template<class T> void importAttendees(icalcomponent *pComp, T *tComp, FileType iType);
00594 template<class T> void importSequence(icalcomponent *pComp, T *tComp);
00595 template<class T> void importPriority(icalcomponent *pComp, T *tComp);
00596 template<class T> void importUrl(icalcomponent *pComp, T *tComp);
00597 template<class T> void importGeo(icalcomponent *pComp, T *tComp);
00598 template<class T> void importClass(icalcomponent *pComp, T *tComp);
00599 template<class T> vector <CParameters *> importResources(icalcomponent *pComp, T *tComp);
00600 template<class T> vector <CParameters *> importCategories(icalcomponent *pComp, T *tComp);
00601 template<class T> vector <CParameters *> importContacts(icalcomponent *pComp, T *tComp);
00602 template<class T> vector <CParameters *> importRelated(icalcomponent *pComp, T *tComp);
00603 template<class T> vector <CParameters *> importLocation(icalcomponent *pComp, T *tComp);
00604 template<class T> vector <CParameters *> importDescription(icalcomponent *pComp, T *tComp);
00605 template<class T> vector <CParameters *> importSummary(icalcomponent *pComp, T *tComp);
00606 template<class T> vector <CParameters *> importComments(icalcomponent *pComp, T *tComp);
00607 template<class T> void importDateStart(icalcomponent *pComp, T *pComp);
00608 bool importEventDateStartAndDateEnd(icalcomponent *pComp, CEvent *pEvent,FileType iType,int& pErrorCode);
00609 bool importEventDateEnd(icalcomponent *pComp, CEvent *pEvent,FileType iType);
00610 void importEventXProp(icalcomponent *pComp, CEvent *pEvent);
00611 void importEventTransp(icalcomponent *pComp, CEvent *pEvent, FileType iType, string strIcalComp);
00612 void importEventAttachements(icalcomponent *pComp, CEvent *pEvent);
00613 void importEventAlarm(icalcomponent *pComp, CEvent *pEvent, icalcomponent *pAComp,
00614 string strIcalComp, FileType iType);
00615 void importEventRecurrence(icalcomponent *pComp, CEvent *pEvent, string strIcalComp, FileType iType, int &pErrorCode);
00616
00617 void importTodoDue(icalcomponent *pComp, CTodo *pTodo);
00618 void importTodoPercentCompleted(icalcomponent *pComp, CTodo *pTodo);
00619 void importTodoCompleted(icalcomponent *pComp, CTodo *pTodo);
00620 void importTodoAlarm(icalcomponent *pComp, CTodo *pTodo, icalcomponent *pAComp,
00621 string strIcalComp, FileType iType);
00622 void importJournalAttach(icalcomponent *pComp, CJournal *pJournal);
00623
00624 void importComponentStatus(icalcomponent *pComp, CComponent *pComponent, FileType iType, string strIcalComp);
00625 void importComponentLastModified(icalcomponent *pComp, CComponent *pComponent);
00626
00627 void parseTimeZone(string &szZone);
00628 private:
00629 bool bSyncing;
00630 };
00631 #endif