|
1 /* |
|
2 * Copyright (c) 2002-2004 Nokia Corporation 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 Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implements the definition of CICalParser. It deals with parsing the ICAL received onto the device. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // Class include. |
|
21 #include "ICalParser.h" // CICalParser |
|
22 |
|
23 //debug |
|
24 #include "calendarengines_debug.h" |
|
25 |
|
26 // User includes. |
|
27 #include "ICal.h" // CICal |
|
28 #include "ICalContentLineReader.h" // CICalContentLineReader |
|
29 #include "ICalKeyWords.h" // Literals |
|
30 #include "ICalUtil.h" // NICalUtil |
|
31 |
|
32 using namespace NICalUtil; |
|
33 |
|
34 /** |
|
35 Allocates and constructs a new CICalParser. |
|
36 @return A new CICalParser. |
|
37 @publishedPartner |
|
38 */ |
|
39 EXPORT_C CICalParser* CICalParser::NewL() |
|
40 { |
|
41 TRACE_ENTRY_POINT; |
|
42 |
|
43 CICalParser* self = CICalParser::NewLC(); |
|
44 CleanupStack::Pop(self); |
|
45 |
|
46 TRACE_EXIT_POINT; |
|
47 return self; |
|
48 } |
|
49 |
|
50 /** |
|
51 Allocates and constructs a new CICalParser. |
|
52 The pointer to the new object is left on the Cleanup Stack. |
|
53 @return A new CICalParser. |
|
54 @publishedPartner |
|
55 */ |
|
56 EXPORT_C CICalParser* CICalParser::NewLC() |
|
57 { |
|
58 TRACE_ENTRY_POINT; |
|
59 |
|
60 CICalParser* self = new (ELeave) CICalParser; |
|
61 CleanupStack::PushL(self); |
|
62 self->ConstructL(); |
|
63 |
|
64 TRACE_EXIT_POINT; |
|
65 return self; |
|
66 } |
|
67 |
|
68 /** |
|
69 Destructor |
|
70 @internalTechnology |
|
71 */ |
|
72 CICalParser::~CICalParser() |
|
73 { |
|
74 TRACE_ENTRY_POINT; |
|
75 |
|
76 iCals.ResetAndDestroy(); |
|
77 TRACE_EXIT_POINT; |
|
78 } |
|
79 |
|
80 /** |
|
81 Creates a CICalContentLinerReader from aReadStream and parses iCalendar |
|
82 information. |
|
83 @param aReadStream The stream to read from. |
|
84 @publishedPartner |
|
85 */ |
|
86 EXPORT_C void CICalParser::InternalizeL(RReadStream& aReadStream) |
|
87 { |
|
88 TRACE_ENTRY_POINT; |
|
89 |
|
90 CICalContentLineReader* reader = CICalContentLineReader::NewLC(aReadStream); |
|
91 |
|
92 TPtrC line; |
|
93 TPtrC name; |
|
94 TPtrC parameters; |
|
95 TPtrC values; |
|
96 |
|
97 TInt error = KErrNone; |
|
98 |
|
99 while ((error = reader->GetNextContentLine(line)) == KErrNone) |
|
100 { |
|
101 if (ExtractSectionsL(line, name, parameters, values) == KErrNone) |
|
102 { |
|
103 if ((name.CompareF(KICalBegin) == 0) && (values.CompareF(KICalVCalendar) == 0)) |
|
104 { |
|
105 // This is the start of a new iCalendar |
|
106 CICal* cal = CICal::NewLC(); |
|
107 cal->InternalizeL(*reader); |
|
108 User::LeaveIfError(iCals.Append(cal)); |
|
109 CleanupStack::Pop(cal); |
|
110 } |
|
111 |
|
112 // Else not a VCALENDAR - ignore it. |
|
113 } |
|
114 |
|
115 // Else no property value given on the line. |
|
116 } |
|
117 |
|
118 if ((error != KErrEof) && (error != KErrNone)) |
|
119 { |
|
120 User::Leave(error); |
|
121 } |
|
122 |
|
123 CleanupStack::PopAndDestroy(reader); |
|
124 TRACE_EXIT_POINT; |
|
125 } |
|
126 |
|
127 /** |
|
128 Get the number of CICal objects owned by this CICalParser. |
|
129 @return The number of CICal objects. |
|
130 @publishedPartner |
|
131 */ |
|
132 EXPORT_C TInt CICalParser::CalCount() const |
|
133 { |
|
134 TRACE_ENTRY_POINT; |
|
135 TRACE_EXIT_POINT; |
|
136 return iCals.Count(); |
|
137 } |
|
138 |
|
139 /** |
|
140 Returns the iCalendar at the given index. |
|
141 @param aIndex The iCalendar required. |
|
142 @return A modifiable reference to the required iCalendar. |
|
143 @publishedPartner |
|
144 */ |
|
145 EXPORT_C CICal& CICalParser::Cal(TInt aIndex) |
|
146 { |
|
147 TRACE_ENTRY_POINT; |
|
148 TRACE_EXIT_POINT; |
|
149 return *iCals[aIndex]; |
|
150 } |
|
151 |
|
152 /** |
|
153 Default constructor. |
|
154 @internalTechnology |
|
155 */ |
|
156 CICalParser::CICalParser() |
|
157 { |
|
158 TRACE_ENTRY_POINT; |
|
159 TRACE_EXIT_POINT; |
|
160 } |
|
161 |
|
162 /** |
|
163 Second phase construction. |
|
164 @internalTechnology |
|
165 */ |
|
166 void CICalParser::ConstructL() |
|
167 { |
|
168 TRACE_ENTRY_POINT; |
|
169 TRACE_EXIT_POINT; |
|
170 } |
|
171 |
|
172 // End of File |