|
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: Class implementing the definiton of CICal. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // Class include. |
|
21 #include "ICal.h" // CICal |
|
22 |
|
23 //debug |
|
24 #include "calendarengines_debug.h" |
|
25 |
|
26 // System includes. |
|
27 #include <s32strm.h> // RWriteStream |
|
28 |
|
29 // User includes. |
|
30 #include "ICalBase.h" // TICalComponentType |
|
31 #include "ICalKeyWords.h" // Literals |
|
32 #include "ICalContentLineWriter.h" // CICalContentLineWriter |
|
33 |
|
34 /** |
|
35 Static factory construction |
|
36 @return A new CICal |
|
37 @publishedPartner |
|
38 */ |
|
39 EXPORT_C CICal* CICal::NewL() |
|
40 { |
|
41 TRACE_ENTRY_POINT; |
|
42 |
|
43 CICal* self = CICal::NewLC(); |
|
44 CleanupStack::Pop(self); |
|
45 |
|
46 TRACE_EXIT_POINT; |
|
47 return self; |
|
48 } |
|
49 |
|
50 /** |
|
51 Static factory construction |
|
52 @return A new CICal |
|
53 @publishedPartner |
|
54 */ |
|
55 EXPORT_C CICal* CICal::NewLC() |
|
56 { |
|
57 TRACE_ENTRY_POINT; |
|
58 |
|
59 CICal* self = new (ELeave) CICal; |
|
60 CleanupStack::PushL(self); |
|
61 self->ConstructL(); |
|
62 |
|
63 TRACE_EXIT_POINT; |
|
64 return self; |
|
65 } |
|
66 |
|
67 EXPORT_C void CICal::SetMethodL(TICalMethod aMethod) |
|
68 { |
|
69 TRACE_ENTRY_POINT; |
|
70 |
|
71 iMethod = aMethod; |
|
72 |
|
73 TRACE_EXIT_POINT; |
|
74 } |
|
75 |
|
76 /** |
|
77 Destructor |
|
78 @internalTechnology |
|
79 */ |
|
80 CICal::~CICal() |
|
81 { |
|
82 TRACE_ENTRY_POINT; |
|
83 TRACE_EXIT_POINT; |
|
84 } |
|
85 |
|
86 |
|
87 |
|
88 /** |
|
89 Creates a CICalContentLineWriter from aWriteStream and calls |
|
90 CICalbase::Externalize with it. |
|
91 @param aWriteStream The stream to externalize to. |
|
92 @publishedPartner |
|
93 */ |
|
94 EXPORT_C void CICal::ExternalizeL(RWriteStream& aWriteStream) |
|
95 { |
|
96 TRACE_ENTRY_POINT; |
|
97 |
|
98 CICalContentLineWriter* writer = CICalContentLineWriter::NewLC(aWriteStream); |
|
99 CICalBase::ExternalizeL(*writer); |
|
100 CleanupStack::PopAndDestroy(writer); |
|
101 |
|
102 TRACE_EXIT_POINT; |
|
103 } |
|
104 |
|
105 /** |
|
106 Constructor |
|
107 @internalTechnology |
|
108 */ |
|
109 CICal::CICal() |
|
110 { |
|
111 TRACE_ENTRY_POINT; |
|
112 |
|
113 iComponentType = EICalCalendar; |
|
114 |
|
115 TRACE_EXIT_POINT; |
|
116 } |
|
117 |
|
118 /** |
|
119 Internal construction |
|
120 @internalTechnology |
|
121 */ |
|
122 void CICal::ConstructL() |
|
123 { |
|
124 TRACE_ENTRY_POINT; |
|
125 TRACE_EXIT_POINT; |
|
126 } |
|
127 |
|
128 /** |
|
129 Checks that the iCalendar specification allows this calendar component to |
|
130 contain the property aName |
|
131 @param aName the name of the property to validate |
|
132 @return ETrue if the property is valid for this component, otherwise EFalse |
|
133 @internalTechnology |
|
134 */ |
|
135 TBool CICal::ValidatePropertyImpl(const TDesC& aName) const |
|
136 { |
|
137 TRACE_ENTRY_POINT; |
|
138 |
|
139 if ((aName.CompareF(KICalProdId) == 0) || (aName.CompareF(KICalVersion) == 0) || |
|
140 (aName.CompareF(KICalCalscale) == 0) || (aName.CompareF(KICalMethod) == 0)) |
|
141 { |
|
142 // 1 PRODID |
|
143 // 1 VERSION |
|
144 // 0..1 CALSCALE |
|
145 // 0..1 METHOD |
|
146 TRACE_EXIT_POINT; |
|
147 return (FindProperty(aName) == NULL); |
|
148 } |
|
149 |
|
150 if ((aName.Length() >= 2) && (aName.Left(2).CompareF(KICalXProperty) == 0)) |
|
151 { |
|
152 // 0..* X-[anything] |
|
153 TRACE_EXIT_POINT; |
|
154 return ETrue; |
|
155 } |
|
156 |
|
157 TRACE_EXIT_POINT; |
|
158 // If we got this far we didn't match any of the possible property names |
|
159 return EFalse; |
|
160 } |
|
161 |
|
162 /** |
|
163 Checks that the iCalendar specification allows this calendar component to |
|
164 contain a nested component of type aType. |
|
165 @param aType the type of component to validate. |
|
166 @return ETrue if the component is a valid child for this component, otherwise |
|
167 EFalse. |
|
168 @internalTechnology |
|
169 */ |
|
170 TBool CICal::ValidateComponent(TICalComponentType aType) const |
|
171 { |
|
172 TRACE_ENTRY_POINT; |
|
173 TRACE_EXIT_POINT; |
|
174 // VCALENDAR can have all components nested except another VCALENDAR or a VALARM, STANDARD or DAYLIGHT. |
|
175 // However, we also return false for invalid components. |
|
176 return ((aType != EICalCalendar) && |
|
177 (aType != EICalAlarm) && |
|
178 (aType != EICalStandard) && |
|
179 (aType != EICalDaylight) && |
|
180 (aType != EICalInvalid)); |
|
181 } |
|
182 |
|
183 // End of File |