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