1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #if !defined(__VCAL_H__)
19 #if !defined(__VERSIT_H__)
23 #if !defined(__VRECUR_H__)
28 /** This constant is for internal use only.
31 _LIT(KVersitTokenVCalVersionNo, "1.0");
37 class CParserVCal : public CVersitParser
38 /** A vCalendar parser.
40 Adds support for parsing vToDos and vEvents, and associated alarms
41 (see CParserPropertyValueAlarm) to the functionality of CVersitParser.
43 Adds a constructor and overrides CVersitParser::InternalizeL() for streams,
44 ExternalizeL() for streams, RecognizeToken(), RecognizeEntityName() and MakeEntityL().
46 The vCalendar data is read from or written to a stream or file, using the
47 InternalizeL() and ExternalizeL() functions. Most users of this class will
48 only need to use these functions.
50 Note: if you are sequentially creating and destroying multiple
51 parsers, a major performance improvement may be achieved by using thread local
52 storage to store an instance of CVersitUnicodeUtils which persists and can be
53 used by all of the parsers.
55 See CVersitTlsData for more information.
62 IMPORT_C static CParserVCal* NewL();
63 public: // from CVersitParser
64 IMPORT_C void InternalizeL(RReadStream& aStream);
65 IMPORT_C void ExternalizeL(RWriteStream& aStream);
66 protected: // from CVersitParser
67 IMPORT_C CVersitParser* MakeEntityL(TInt aEntityUid,HBufC* aEntityName);
68 public: // from CVersitParser
69 IMPORT_C TUid RecognizeToken(const TDesC8& aToken) const;
70 IMPORT_C TInt RecognizeEntityName() const;
73 private: // from CVersitParser
74 IMPORT_C virtual void Reserved1();
75 IMPORT_C virtual void Reserved2();
81 class CVersitAlarm : public CBase
82 /** An alarm for a vEvent or a vTodo.
84 Specifies the date/time for the alarm, the amount of time the alarm will be
85 snoozed (optional), the number of times that the alarm will repeat, the binary
86 data of the sound to be played when the alarm runs (optional), and some text
87 to associate with the alarm (optional).
89 An object of this class is owned by the CParserPropertyValueAlarm class.
91 This class supports the following types of alarm:
95 - Display Alarm (displays message on the screen)
97 - Procedure Alarm (calls a procedure)
99 - Mail Alarm (sends an email).
106 IMPORT_C static CVersitAlarm* NewL(TVersitDateTime* aRunTime, TTime* aSnoozeTime, TInt aRepeatCount, const TDesC& aAudioContent, const TDesC& aNote);
107 IMPORT_C ~CVersitAlarm();
109 CVersitAlarm(TInt aRepeatCount);
110 void ConstructL(const TDesC& aAudioContent, const TDesC& aNote, TVersitDateTime* aRunTime, TTime* aSnoozeTime);
112 /** The date/time for the alarm. */
113 TVersitDateTime* iRunTime;
114 /** The amount of time the alarm will be snoozed (optional). */
116 /** The number of times that the alarm will repeat. */
118 /** The binary data describing the sound to play for an AALARM (optional), or
119 the string which specifies the address to send the e-mail to, for an MALARM. */
120 HBufC* iAudioContent;
121 /** The mesage to display on the screen for a DALARM (optional), or
122 the body of the e-mail to be sent for an MALARM, or the name of the procedure
123 to call for a PALARM. */
124 HBufC* iNote;//Empty except for MAlarm
127 class CVersitExtendedAlarm : public CBase
128 /** An extended alarm for a vEvent or a vTodo.
130 Specifies the date/time for the alarm, the amount of time the alarm will be
131 snoozed (optional), the number of times that the alarm will repeat, and the
132 action for the alarm.
133 An object of this class is owned by the CParserPropertyValueAlarm class.
135 This class supports the following types of alarm:
144 /** Extended Alarm's disposition types.
151 /** Inline disposition
153 EDispositionInline = 1,
154 /** Unknown disposition
156 EDispositionUnknown = 15
159 IMPORT_C static CVersitExtendedAlarm* NewL(const TDesC8& aContent,const TDesC8& aContentMimeType, CVersitExtendedAlarm::TDisposition aDisposition);
160 IMPORT_C ~CVersitExtendedAlarm();
162 CVersitExtendedAlarm();
163 void ConstructL(const TDesC8& aContent, const TDesC8& aContentMimeType, CVersitExtendedAlarm::TDisposition aContentDisposition);
165 /** The data describing the action for the alarm.*/
167 /** The MIME type of the data describing the action for the alarm.*/
169 /** The disposition of the data for the alarm action (i.e whether it is inline or an URI).*/
170 CVersitExtendedAlarm::TDisposition iDisposition;
176 class CParserVCalEntity : public CRecurrenceParser
177 /** A parser for vCalendar sub-entities.
179 A vCalendar sub-entity is a vEvent or vToDo contained in a vCalendar. vEvents
180 and vToDos are derived from CRecurrenceParser, which provides recurrence functionality.
182 vEvents and vTodos may have alarm properties (see CParserPropertyValueAlarm).
189 IMPORT_C static CParserVCalEntity* NewL();
190 IMPORT_C ~CParserVCalEntity();
191 public: // from CVersitParser
192 IMPORT_C void ExternalizeL(RWriteStream& aStream);
193 protected: // from CVersitParser
194 IMPORT_C CParserPropertyValue* MakePropertyValueL(const TUid& aPropertyUid,HBufC16*& aValue);
195 IMPORT_C CVersitAlarm* MakePropertyValueAlarmL(TPtr16 aAlarmValue);
196 IMPORT_C CVersitExtendedAlarm* MakePropertyValueExtendedAlarmL(TPtr16 aAlarmValue);
197 IMPORT_C CVersitExtendedAlarm* MakePropertyValueExtendedAlarmL(CBufSeg& aAlarmValue);
198 IMPORT_C CVersitExtendedAlarm::TDisposition DecodeDisposition(const TDesC8& aContentDispositionToken) const;
199 IMPORT_C TUid RecognizeToken(const TDesC8& aToken) const;
202 private: // from CVersitParser
203 IMPORT_C virtual void Reserved1();
204 IMPORT_C virtual void Reserved2();
209 // CParserPropertyValueAlarm
211 class CParserPropertyValueAlarm : public CParserTimePropertyValue
212 /** An alarm property value parser for a vCalendar entity.
214 An alarm can be associated with a vEvent or a vTodo. The value for the alarm
215 is stored as a CVersitAlarm.
217 Note: The UID for an alarm property value is KVCalPropertyAlarmUid.
224 IMPORT_C CParserPropertyValueAlarm(CVersitAlarm* aValue);
225 IMPORT_C CParserPropertyValueAlarm();
226 IMPORT_C ~CParserPropertyValueAlarm();
227 inline CVersitAlarm* Value() const;
228 public: // from CParserTimePropertyValue
229 IMPORT_C void ConvertAllDateTimesToUTCL(const TTimeIntervalSeconds& aIncrement,const CVersitDaylight* aDaylight);
230 IMPORT_C void ConvertAllUTCDateTimesToMachineLocalL(const TTimeIntervalSeconds& aIncrement);
231 public: // from CParserPropertyValue
232 IMPORT_C void ExternalizeL(RWriteStream& aStream,const Versit::TEncodingAndCharset& aEncodingCharset,TInt aLengthOutput);
233 IMPORT_C TBool IsAsciiCharacterSetSufficient();
235 CVersitAlarm* iValue;
240 // CParserPropertyValueExtendedAlarm
242 class CParserPropertyValueExtendedAlarm : public CParserTimePropertyValue
243 /** An extended alarm property value parser for a vCalendar entity.
245 An alarm action can be attached with a vEvent or a vTodo. The value for the alarm
246 action is stored as a CVersitExtendedAlarm object.
248 Note: The UID for an extended alarm property value is KVCalPropertyExtendedAlarmUid.
255 IMPORT_C CParserPropertyValueExtendedAlarm(CVersitExtendedAlarm* aValue);
256 IMPORT_C ~CParserPropertyValueExtendedAlarm();
257 inline CVersitExtendedAlarm* Value() const;
258 public: // from CParserTimePropertyValue
259 IMPORT_C void ConvertAllDateTimesToUTCL(const TTimeIntervalSeconds& aIncrement,const CVersitDaylight* aDaylight);
260 IMPORT_C void ConvertAllUTCDateTimesToMachineLocalL(const TTimeIntervalSeconds& aIncrement);
261 public: // from CParserPropertyValue
262 IMPORT_C void ExternalizeL(RWriteStream& aStream, const Versit::TEncodingAndCharset& aEncodingCharset, TInt aLengthOutput);
263 IMPORT_C TBool IsAsciiCharacterSetSufficient();
265 void ExternalizeUrlL(RWriteStream& aStream, const Versit::TEncodingAndCharset& aEncodingCharset, TInt aLengthOutput);
266 void ExternalizeInlineL(RWriteStream& aStream, const Versit::TEncodingAndCharset& aEncodingCharset, TInt aLengthOutput);
269 CVersitExtendedAlarm* iValue;