|
1 /* |
|
2 * Copyright (c) 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: WV Comm Cap implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CPEngWVAttributeConstructBase.h" |
|
20 #include "CPEngWVAttributeModelBase.h" |
|
21 #include "CPEngWVCommCapConstruct.h" |
|
22 |
|
23 #include "MPEngXMLSerializer.h" |
|
24 #include "MPEngXMLParser.h" |
|
25 |
|
26 #include <MPEngPresenceAttrModel2.h> |
|
27 #include <E32Base.h> |
|
28 #include <S32Strm.h> |
|
29 |
|
30 |
|
31 |
|
32 // DATA TYPES |
|
33 /** |
|
34 * CommCap CSP name table. |
|
35 * |
|
36 * @since 3.0 |
|
37 */ |
|
38 const TWVCspAttributeNameEntry KCommCapCspNameTable[] = |
|
39 { |
|
40 { |
|
41 EWVCspV11, |
|
42 LIT_AS_DESC8_PTR( KCommCapXMLTag ), |
|
43 LIT_AS_DESC8_PTR( KPresenceSubListAttributesNS ) |
|
44 }, |
|
45 { |
|
46 EWVCspV12, |
|
47 LIT_AS_DESC8_PTR( KCommCapXMLTag ), |
|
48 LIT_AS_DESC8_PTR( KPresenceSubListAttributesNS_CSP12 ) |
|
49 } |
|
50 }; |
|
51 |
|
52 |
|
53 const TInt KCommCapCspNameTableCount = sizeof( KCommCapCspNameTable ) / sizeof( TWVCspAttributeNameEntry ); |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 // =============== CPEngWVCommCapConstruct MEMBER FUNCTIONS =============== |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CPEngWVCommCapConstruct::CPEngWVCommCapConstruct |
|
62 // C++ constructor can NOT contain any code, that |
|
63 // might leave. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CPEngWVCommCapConstruct::CPEngWVCommCapConstruct( TPEngWVCspVersion aCurrentCspVer ) |
|
67 : CPEngWVAttributeConstructBase( aCurrentCspVer, |
|
68 KCommCapCspNameTable, |
|
69 KCommCapCspNameTableCount ) |
|
70 { |
|
71 } |
|
72 |
|
73 |
|
74 // Destructor |
|
75 CPEngWVCommCapConstruct::~CPEngWVCommCapConstruct() |
|
76 { |
|
77 } |
|
78 |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CPEngWVCommCapConstruct::NewAttributeInstanceLC() |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 MPEngPresenceAttrModelTypeImp* CPEngWVCommCapConstruct::NewAttributeInstanceLC( |
|
85 TBool aUserOwnAttribute ) const |
|
86 { |
|
87 CPEngWVCommCapModel* model = new ( ELeave ) CPEngWVCommCapModel( |
|
88 aUserOwnAttribute ); |
|
89 CleanupStack::PushL( model ); |
|
90 model->ResetDataL(); |
|
91 return model; |
|
92 } |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 // ================= CPEngWVCommCapModel MEMBER FUNCTIONS ================= |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CPEngWVCommCapConstruct::CPEngWVCommCapConstruct::CPEngWVCommCapModel |
|
101 // C++ constructor can NOT contain any code, that |
|
102 // might leave. |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 CPEngWVCommCapConstruct::CPEngWVCommCapModel::CPEngWVCommCapModel( |
|
106 TBool aUserOwnAttribute ) |
|
107 : CPEngWVAttributeModelBase( aUserOwnAttribute ) |
|
108 { |
|
109 } |
|
110 |
|
111 |
|
112 // Destructor |
|
113 CPEngWVCommCapConstruct::CPEngWVCommCapModel::~CPEngWVCommCapModel() |
|
114 { |
|
115 } |
|
116 |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CPEngWVCommCapConstruct::CPEngWVCommCapModel::SetDataL() |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 TBool CPEngWVCommCapConstruct::CPEngWVCommCapModel::SetDataL( TInt* aIntData, |
|
123 const TDesC8* /*a8Data*/, |
|
124 const TDesC16* /*a16Data*/, |
|
125 TInt aField, |
|
126 TInt aGroup ) |
|
127 { |
|
128 TBool handled = EFalse; |
|
129 |
|
130 if ( aIntData && ( aField == EPEngCommCapStatus ) ) |
|
131 { |
|
132 switch ( aGroup ) //from TPEngCommunicationCapabilitiesFieldGroups |
|
133 { |
|
134 case EPEngCommCapIMClient: |
|
135 { |
|
136 DoSetCapabilityStatusL( iIMCapability, *aIntData ); |
|
137 handled = ETrue; |
|
138 break; |
|
139 } |
|
140 } |
|
141 } |
|
142 |
|
143 return handled; |
|
144 } |
|
145 |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CPEngWVCommCapConstruct::CPEngWVCommCapModel::GetData() |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 TBool CPEngWVCommCapConstruct::CPEngWVCommCapModel::GetData( TInt* aIntData, |
|
152 TPtrC8* /*a8Data*/, |
|
153 TPtrC16* /*a16Data*/, |
|
154 TInt aField, |
|
155 TInt aGroup ) const |
|
156 { |
|
157 TBool handled = EFalse; |
|
158 |
|
159 if ( aIntData && ( aField == EPEngCommCapStatus ) ) |
|
160 { |
|
161 switch ( aGroup ) //from TPEngCommunicationCapabilitiesFieldGroups |
|
162 { |
|
163 case EPEngCommCapIMClient: |
|
164 { |
|
165 *aIntData = iIMCapability; |
|
166 handled = ETrue; |
|
167 break; |
|
168 } |
|
169 } |
|
170 } |
|
171 |
|
172 return handled; |
|
173 } |
|
174 |
|
175 |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CPEngWVCommCapConstruct::CPEngWVCommCapModel::EncodeDataToXmlL() |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void CPEngWVCommCapConstruct::CPEngWVCommCapModel::EncodeDataToXmlL( |
|
182 MPEngXMLSerializer& aSerializer ) const |
|
183 { |
|
184 aSerializer.StartTagL( KCommCXMLTag ); |
|
185 { |
|
186 aSerializer.StartTagL( KCommCapXMLTagCap ).RawValueL( KCommCapIMXMLTag ).EndTagL( KCommCapXMLTagCap ); |
|
187 |
|
188 aSerializer.StartTagL( KCommCapStatusXMLTag ); |
|
189 { |
|
190 switch ( iIMCapability ) |
|
191 { |
|
192 case EPEngCommCapStatusOpen: |
|
193 { |
|
194 aSerializer.RawValueL( KCommCapStatusOpen ); |
|
195 break; |
|
196 } |
|
197 case EPEngCommCapStatusClosed: |
|
198 default: |
|
199 { |
|
200 aSerializer.RawValueL( KCommCapStatusClosed ); |
|
201 break; |
|
202 } |
|
203 } |
|
204 } |
|
205 aSerializer.EndTagL( KCommCapStatusXMLTag ); |
|
206 |
|
207 aSerializer.StartTagL( KCommCapNoteXMLTag ).EndTagL( KCommCapNoteXMLTag ); |
|
208 } |
|
209 aSerializer.EndTagL( KCommCXMLTag ); |
|
210 } |
|
211 |
|
212 |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 // CPEngWVCommCapConstruct::CPEngWVCommCapModel::DecodeDataFromXmlL() |
|
216 // ----------------------------------------------------------------------------- |
|
217 // |
|
218 void CPEngWVCommCapConstruct::CPEngWVCommCapModel::DecodeDataFromXmlL( |
|
219 MPEngXMLParser& aParser, |
|
220 const TDesC8& aValueBlock ) |
|
221 { |
|
222 RArray<TPtrC8> commCaps; |
|
223 CleanupClosePushL( commCaps ); |
|
224 |
|
225 // parse the commcap attribute values |
|
226 if ( aParser.DecodeL( aValueBlock, KCommCXMLTag, ETrue ) ) |
|
227 { |
|
228 TInt count( aParser.Count() ); |
|
229 for ( TInt resCount( 0 ); resCount < count; resCount++ ) |
|
230 { |
|
231 User::LeaveIfError( commCaps.Append( aParser.ResultL( resCount ) ) ); |
|
232 } |
|
233 |
|
234 count = commCaps.Count(); |
|
235 for ( TInt i( 0 ); i < count; i++ ) |
|
236 { |
|
237 if ( aParser.DecodeL( commCaps[i], KCommCapXMLTagCap, EFalse ) ) |
|
238 { |
|
239 if ( aParser.ResultL().CompareF( KCommCapIMXMLTag ) == 0 ) |
|
240 { |
|
241 if ( aParser.DecodeL( commCaps[i], KCommCapStatusXMLTag, EFalse ) ) |
|
242 { |
|
243 if ( aParser.ResultL().CompareF( KCommCapStatusOpen ) == 0 ) |
|
244 { |
|
245 iIMCapability = EPEngCommCapStatusOpen; |
|
246 } |
|
247 else |
|
248 { |
|
249 iIMCapability = EPEngCommCapStatusClosed; |
|
250 } |
|
251 } |
|
252 } |
|
253 } |
|
254 } |
|
255 } |
|
256 |
|
257 CleanupStack::PopAndDestroy(); //commCaps |
|
258 } |
|
259 |
|
260 |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // CPEngWVCommCapConstruct::CPEngWVCommCapModel::ResetDataL() |
|
264 // ----------------------------------------------------------------------------- |
|
265 // |
|
266 void CPEngWVCommCapConstruct::CPEngWVCommCapModel::ResetDataL() |
|
267 { |
|
268 iIMCapability = EPEngCommCapStatusClosed; |
|
269 } |
|
270 |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CPEngWVCommCapConstruct::CPEngWVCommCapModel::DataExternalizeSize() |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 TInt CPEngWVCommCapConstruct::CPEngWVCommCapModel::DataExternalizeSize() const |
|
277 { |
|
278 return 1; //iIMCapability is stored to 8 bit |
|
279 } |
|
280 |
|
281 |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // CPEngWVCommCapConstruct::CPEngWVCommCapModel::ExternalizeDataL() |
|
285 // ----------------------------------------------------------------------------- |
|
286 // |
|
287 void CPEngWVCommCapConstruct::CPEngWVCommCapModel::ExternalizeDataL( |
|
288 RWriteStream& aStream ) const |
|
289 { |
|
290 aStream.WriteInt8L( iIMCapability ); |
|
291 } |
|
292 |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // CPEngWVCommCapConstruct::CPEngWVCommCapModel::InternalizeDataL() |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void CPEngWVCommCapConstruct::CPEngWVCommCapModel::InternalizeDataL( |
|
299 RReadStream& aStream ) |
|
300 { |
|
301 iIMCapability = static_cast<TPEngWVCommunicationCapabilityValues> ( aStream.ReadInt8L() ); |
|
302 } |
|
303 |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CPEngWVCommCapConstruct::CPEngWVCommCapModel::DoSetCapabilityStatusL() |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 void CPEngWVCommCapConstruct::CPEngWVCommCapModel::DoSetCapabilityStatusL( |
|
310 TPEngWVCommunicationCapabilityValues& aCapabilityHolder, |
|
311 TInt aNewStatus ) |
|
312 { |
|
313 //validate the data |
|
314 switch ( aNewStatus ) |
|
315 { |
|
316 //from TPEngCommunicationCapabilityStatus |
|
317 case EPEngCommCapStatusOpen: |
|
318 case EPEngCommCapStatusClosed: |
|
319 { |
|
320 aCapabilityHolder = static_cast<TPEngWVCommunicationCapabilityValues> ( aNewStatus ); |
|
321 break; |
|
322 } |
|
323 default: |
|
324 { |
|
325 __AssertAttrEnumValueOutOfBoundsL(); |
|
326 break; |
|
327 } |
|
328 } |
|
329 } |
|
330 |
|
331 |
|
332 |
|
333 // End of File |
|
334 |
|
335 |