calendarengines/caldav/inc/caldavutils.h
branchRCL_3
changeset 31 97232defd20e
equal deleted inserted replaced
30:bd7edf625bdd 31:97232defd20e
       
     1 /*
       
     2 * Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributor:
       
    10 * Maximilian Odendahl
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: 	various utility classes and functions
       
    15 *				used in Caldav client and server code
       
    16 */
       
    17 
       
    18 #ifndef CALDAVUTILS_H
       
    19 #define CALDAVUTILS_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 
       
    25 // CLASS DECLARATION
       
    26 class RHTTPTransaction;
       
    27 
       
    28 _LIT(KCalDavServerName,"!CalDavServer");
       
    29 _LIT(KCalDavServerFilename,"!CalDavServer.exe");
       
    30 _LIT8(KUserAgent, "Symbian 1.0");
       
    31 
       
    32 const TUint KCalDavServerMajorVersionNumber = 1;
       
    33 const TUint KCalDavServerMinorVersionNumber = 0;
       
    34 const TUint KCalDavServerBuildVersionNumber = 0;
       
    35 
       
    36 enum TCalDavServReq
       
    37 	{
       
    38 	ECalDavCreate = 1,
       
    39 	ECalDavClose,
       
    40 	ECalDavUnsupportedRequest,
       
    41 	ECalDavEnable,
       
    42 	ECalDavDisable,
       
    43 	ECalDavMkCalendar,
       
    44 	ECalDavDeleteCalendar,
       
    45 	ECalDavSyncAll,
       
    46 	ECalDavSync,
       
    47 	ECalDavUrl,
       
    48 	ECalDavSetUrl,
       
    49 	ECalDavUsername,
       
    50 	ECalDavSetUsername,
       
    51 	ECalDavPassword,
       
    52 	ECalDavSetPassword,
       
    53 	ECalDavSyncInterval,
       
    54 	ECalDavSetSyncInterval,
       
    55 	ECalDavPastDays,
       
    56 	ECalDavSetPastDays,
       
    57 	ECalDavImmediateSync,
       
    58 	ECalDavSetImmediateSync,
       
    59 	ECalDavKeepServer,
       
    60 	ECalDavSetKeepServer,
       
    61 	ECalDavEnabled
       
    62 	};
       
    63 
       
    64 enum TCalDavServLeave
       
    65 	{
       
    66 	ENonNumericString = 99
       
    67 	};
       
    68 
       
    69 // reasons for server panic
       
    70 enum TCalDavServPanic
       
    71 	{
       
    72 	EBadRequest = 1,
       
    73 	EBadDescriptor,
       
    74 	EMainSchedulerError,
       
    75 	ESvrCreateServer,
       
    76 	ESvrStartServer,
       
    77 	ECreateTrapCleanup,
       
    78 	ENotImplementedYet,
       
    79 	};
       
    80 
       
    81 struct TCalDAVOptions
       
    82 	{
       
    83 	// ALLOW header
       
    84 	TBool DELETE;
       
    85 	TBool GET;
       
    86 	TBool HEAD;
       
    87 	TBool MKCALENDAR;
       
    88 	TBool MKCOL;
       
    89 	TBool OPTIONS;
       
    90 	TBool PROPFIND;
       
    91 	TBool PROPPATCH;
       
    92 	TBool PUT;
       
    93 	TBool REPORT;
       
    94 	TBool COPY;
       
    95 	TBool POST;
       
    96 	TBool MOVE;
       
    97 	TBool ACL;
       
    98 	TBool LOCK;
       
    99 	TBool UNLOCK;
       
   100 	TBool MULTIGET;
       
   101 	TBool QUERY;
       
   102 
       
   103 	TBool VEVENT;
       
   104 	TBool VTODO;
       
   105 	TBool VFREEBUSY;
       
   106 	TBool VJOURNAL;
       
   107 
       
   108 	//DAV header
       
   109 	TBool ONE;
       
   110 	TBool TWO;
       
   111 	TBool THREE;
       
   112 	TBool access_control;
       
   113 	TBool calendar_access;
       
   114 	TBool calendar_schedule;
       
   115 	TBool calendar_auto_schedule;
       
   116 	TBool extended_mkcol;
       
   117 	TBool sync_collection;
       
   118 	TBool sync_ctag;
       
   119 	};
       
   120 _LIT8(colon,",");
       
   121 _LIT8(DAV,"DAV");
       
   122 _LIT8(ALLOW,"Allow");
       
   123 _LIT8(DELETE,"DELETE");
       
   124 _LIT8(GET,"GET");
       
   125 _LIT8(HEAD,"HEAD");
       
   126 _LIT8(MKCALENDAR,"MKCALENDAR");
       
   127 _LIT8(MKCOL,"MKCOL");
       
   128 _LIT8(OPTIONS,"OPTIONS");
       
   129 _LIT8(PROPFIND,"PROPFIND");
       
   130 _LIT8(PROPPATCH,"PROPPATCH");
       
   131 _LIT8(PUT,"PUT");
       
   132 _LIT8(REPORT,"REPORT");
       
   133 _LIT8(COPY,"COPY");
       
   134 _LIT8(POST,"POST");
       
   135 _LIT8(MOVE,"MOVE");
       
   136 _LIT8(ACL,"ACL");
       
   137 _LIT8(LOCK,"LOCK");
       
   138 _LIT8(UNLOCK,"UNLOCK");
       
   139 _LIT8(MULTIGET,"MULTIGET");
       
   140 //DAV header
       
   141 _LIT8(ZERO,"0");
       
   142 _LIT8(ONE,"1");
       
   143 _LIT8(TWO,"2");
       
   144 _LIT8(THREE,"3");
       
   145 _LIT8(access_control,"access-control");
       
   146 _LIT8(calendar_access,"calendar-access");
       
   147 _LIT8(calendar_schedule,"calendar-schedule");
       
   148 _LIT8(calendar_auto_schedule,"calendar-auto-schedule");
       
   149 _LIT8(sync_collection,"sync-collection");
       
   150 _LIT8(extended_mkcol,"extended-mkcol");
       
   151 _LIT8(KVEVENT,"VEVENT");
       
   152 _LIT8(KVTODO,"VTODO");
       
   153 _LIT8(KVJOURNAL,"VJOURNAL");
       
   154 _LIT8(KVFREBUSY,"VFREEBUSY");
       
   155 _LIT8(KDav,"DAV:");
       
   156 _LIT8(KMultistatus,"multistatus");
       
   157 _LIT8(LProp,"prop");
       
   158 _LIT8(KHref,"href");
       
   159 _LIT8(KResponse,"response");
       
   160 _LIT8(KStatus,"status");
       
   161 _LIT8(KOwner,"owner");
       
   162 _LIT8(KEtag,"getetag");
       
   163 _LIT8(KResourcetype,"resourcetype");
       
   164 _LIT8(KCalDav,"urn:ietf:params:xml:ns:caldav");
       
   165 _LIT8(KGetctag,"getctag");
       
   166 _LIT8(KSynctoken,"sync-token");
       
   167 _LIT8(KCalendarData,"calendar-data");
       
   168 _LIT8(KCalendar,"calendar");
       
   169 _LIT8(KCalendarHomeSet,"calendar-home-set");
       
   170 _LIT8(KOutbox,"schedule-outbox-URL");
       
   171 _LIT8(KInbox,"schedule-inbox-URL");
       
   172 _LIT8(KCalendarMultiget,"calendar-multiget");
       
   173 _LIT8(KCalendarQuery,"calendar-query");
       
   174 _LIT8(KDisplayname,"displayname");
       
   175 _LIT8(KSupportedCalendarComponentSet,"supported-calendar-component-set");
       
   176 _LIT8(KCalendar_Color,"calendar-color");
       
   177 
       
   178 // groupdav
       
   179 _LIT8(KVTodoCollection,"vtodo-collection");
       
   180 _LIT8(KVEventCollection,"vevent-collection");
       
   181 _LIT8(KIcs, ".ics");
       
   182 _LIT8(KUID,"UID:");
       
   183 _LIT8(KSlash,"/");
       
   184 _LIT8(KName,"name");
       
   185 _LIT8(KHrefstart,"<D:href xmlns:D=\"DAV:\">");
       
   186 _LIT8(KHrefend,"</D:href>");
       
   187 _LIT8(KMultistart,"<?xml version=\"1.0\" encoding=\"utf-8\" ?><C:calendar-multiget xmlns:C=\"urn:ietf:params:xml:ns:caldav\"><D:prop xmlns:D=\"DAV:\"><D:getetag/><C:calendar-data/></D:prop>");
       
   188 _LIT8(KMultiend,"</C:calendar-multiget>");
       
   189 _LIT8(KSync,"<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:sync-collection xmlns:D=\"DAV:\"><D:sync-token>%S</D:sync-token><D:prop><D:getetag/></D:prop></D:sync-collection>");
       
   190 _LIT8(KCtag,"<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propfind xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\"><D:prop><T:getctag xmlns:T=\"http://calendarserver.org/ns/\"/></D:prop></D:propfind>");
       
   191 _LIT8(KSupportedSet,"<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propfind xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\"><D:prop><C:supported-calendar-component-set/><D:supported-report-set/><D:displayname/><A:calendar-color xmlns:A=\"http://apple.com/ns/ical/\"/></D:prop></D:propfind>");
       
   192 _LIT8(KCalendarurl,"<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propfind xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\"><D:prop><D:owner/><D:resourcetype/></D:prop></D:propfind>");
       
   193 _LIT8(KPrincipalurl,"<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propfind xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\"><D:prop><C:calendar-home-set/><C:schedule-inbox-URL/><C:schedule-outbox-URL/></D:prop></D:propfind>");
       
   194 _LIT8(KPropList,"<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propfind xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\"><D:prop><D:getetag/></D:prop></D:propfind>");
       
   195 _LIT8(KTimeStartEVENT,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><calendar-query xmlns:D=\"DAV:\" xmlns=\"urn:ietf:params:xml:ns:caldav\"><D:prop><D:getetag/></D:prop><filter><comp-filter name=\"VCALENDAR\"><comp-filter name=\"VEVENT\"><time-range start=");
       
   196 _LIT8(KTimeStartTODO,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><calendar-query xmlns:D=\"DAV:\" xmlns=\"urn:ietf:params:xml:ns:caldav\"><D:prop><D:getetag/></D:prop><filter><comp-filter name=\"VCALENDAR\"><comp-filter name=\"VTODO\"><time-range start=");
       
   197 _LIT8(KTimeEnd," end=\"20200101T000000Z\"/></comp-filter></comp-filter></filter></calendar-query>");
       
   198 _LIT8(KTimeTest,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><calendar-query xmlns:D=\"DAV:\" xmlns=\"urn:ietf:params:xml:ns:caldav\"><D:prop><D:getetag/></D:prop><filter><comp-filter name=\"VCALENDAR\"><comp-filter name=\"VEVENT\"><time-range start=\"20090509T220000Z\" end=\"20090509T220000Z\"/></comp-filter></comp-filter></filter></calendar-query>");
       
   199 
       
   200 _LIT8(KColorDisplayStart,"<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propertyupdate xmlns:D=\"DAV:\"><D:set><D:prop><A:calendar-color xmlns:A=\"http://apple.com/ns/ical/\">");
       
   201 _LIT8(KColorDisplayMiddle,"</A:calendar-color><D:displayname>");
       
   202 _LIT8(KColorDisplayEnd,"</D:displayname></D:prop></D:set></D:propertyupdate>");
       
   203 
       
   204 // strings for CCalCalendarInfo Properties
       
   205 _LIT8(KCaldavEnabled,"caldavenabled");
       
   206 _LIT8(KCaldavFirstInit,"caldavfirstinit");
       
   207 _LIT8(KCaldavCtag,"caldavctag");
       
   208 _LIT8(KCaldavSynctoken,"caldavsynctoken");
       
   209 _LIT8(KCaldavManualSync,"caldavmanualsync");
       
   210 _LIT8(KCaldavTime,"caldavtime");
       
   211 _LIT8(KCaldavUser,"caldavuser");
       
   212 _LIT8(KCaldavPassword,"caldavpassword");
       
   213 _LIT8(KCaldavUrl,"caldavurl");
       
   214 _LIT8(KCaldavKeepServer,"caldavkeepserver");
       
   215 _LIT8(KCaldavImmediateSync,"caldavimmediatesync");
       
   216 _LIT8(KCaldavPastDays,"caldavpastdays");
       
   217 _LIT8(KCaldavSyncInterval,"caldavsyncinterval");
       
   218 
       
   219 class CalDavUtils : public CBase
       
   220 	{
       
   221 public:
       
   222 
       
   223 	~CalDavUtils();
       
   224 
       
   225 	static CalDavUtils* NewL();
       
   226 	static CalDavUtils* NewLC();
       
   227 
       
   228 	static void ScanDAVHeaderL(RHTTPTransaction &aTransaction,
       
   229 			TCalDAVOptions &aOptions);
       
   230 	static void ScanAllowHeaderL(RHTTPTransaction &aTransaction,
       
   231 			TCalDAVOptions &aOptions);
       
   232 	static void FixExportIssues(TDes8 &aDes);
       
   233 	static void FixImportIssues(TDes8 &aDes);
       
   234 	static void GetFileName(const TDesC8 &aIcs, TDes8 &aUrl);
       
   235 
       
   236 	static HBufC8* EnsureSlashL(HBufC8* aIn);
       
   237 	static HBufC8* CalDavUtils::EnsureSlashL(const TDesC8 &aIn);
       
   238 
       
   239 private:
       
   240 
       
   241 	CalDavUtils();
       
   242 	void ConstructL();
       
   243 
       
   244 	static void FindAndRemoveMethod(TDes8 &aDes);
       
   245 	static void FixBYMONTHDAY(TDes8 &aDes);
       
   246 	static void FixSameTime(TDes8 &aDes);
       
   247 	static void FixLineFeed(TDes8 &aDes);
       
   248 
       
   249 	};
       
   250 
       
   251 #endif // CALDAVUTILS_H