|
1 /* |
|
2 * Copyright (c) 2006 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: Create Presentity Group Request to the Network Server. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ximpprotocolconnectionhost.h> |
|
20 #include "CSubscribePresentityGroupContentRequest.h" |
|
21 #include "impsconnectionmanagercontrolif.h" |
|
22 #include "impsdebugprint.h" |
|
23 #include "CImpsPluginAccessHandler.h" |
|
24 #include "CImpsPluginPureDataHandler.h" |
|
25 |
|
26 |
|
27 #include "CPEngXMLParser.h" |
|
28 #include "MPEngXMLParser.h" |
|
29 #include "CPEngXmlSerializer.h" |
|
30 #include "MPEngXmlSerializer.h" |
|
31 #include "CImpsPluginConnectionManager.h" |
|
32 #include "PEngXMLTags.h" |
|
33 |
|
34 #include <ximpobjectfactory.h> |
|
35 #include <protocolpresencedatahost.h> |
|
36 #include <presenceobjectfactory.h> |
|
37 #include <ximpobjectcollection.h> |
|
38 #include <protocolpresentitygroupsdatahost.h> |
|
39 #include <presentitygroupinfo.h> |
|
40 #include <presentitygroupmemberinfo.h> |
|
41 #include <ximpidentity.h> |
|
42 #include <ximpdatasubscriptionstate.h> |
|
43 #include "PImpsAdapXMLTools.h" |
|
44 |
|
45 // ======== MEMBER FUNCTIONS ======== |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CSubscribePresentityGroupContentRequest::CSubscribePresentityGroupContentRequest |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CSubscribePresentityGroupContentRequest::CSubscribePresentityGroupContentRequest( |
|
52 MImpsPrtPluginConnectionManager& aConnMan, |
|
53 TXIMPRequestId aRequestId ) : |
|
54 CActive( EPriorityNormal ), |
|
55 iRequestId( aRequestId ), |
|
56 iConnMan( aConnMan ) |
|
57 { |
|
58 IMPS_DP( D_IMPS_LIT( "::CSubscribePresentityGroupContentRequest Start" ) ); |
|
59 CActiveScheduler::Add( this ); |
|
60 IMPS_DP( D_IMPS_LIT( "::CSubscribePresentityGroupContentRequest End" ) ); |
|
61 } |
|
62 |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CSubscribePresentityGroupContentRequest::ConstructL |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CSubscribePresentityGroupContentRequest::ConstructL() |
|
69 { |
|
70 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::ConstructL Start-End" ) ); |
|
71 |
|
72 iParser = CreateXMLParserL(); |
|
73 |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CSubscribePresentityGroupContentRequest::NewL |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CSubscribePresentityGroupContentRequest* CSubscribePresentityGroupContentRequest::NewL( |
|
82 MImpsPrtPluginConnectionManager& aConnMan, |
|
83 TXIMPRequestId aRequestId ) |
|
84 { |
|
85 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::NewL Start" ) ); |
|
86 |
|
87 CSubscribePresentityGroupContentRequest* self = new( ELeave ) |
|
88 CSubscribePresentityGroupContentRequest( aConnMan, aRequestId ); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop( self ); |
|
92 |
|
93 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::NewL End" ) ); |
|
94 return self; |
|
95 } |
|
96 |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CSubscribePresentityGroupContentRequest::NewLC |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 CSubscribePresentityGroupContentRequest* CSubscribePresentityGroupContentRequest::NewLC( |
|
103 MImpsPrtPluginConnectionManager& aConnMan, |
|
104 TXIMPRequestId aRequestId ) |
|
105 { |
|
106 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::NewLC Start" ) ); |
|
107 |
|
108 CSubscribePresentityGroupContentRequest* self = |
|
109 CSubscribePresentityGroupContentRequest::NewL( aConnMan, aRequestId ); |
|
110 CleanupStack::PushL( self ); |
|
111 |
|
112 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::NewLC End" ) ); |
|
113 return self; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CSubscribePresentityGroupContentRequest::~CSubscribePresentityGroupContentRequest |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 CSubscribePresentityGroupContentRequest::~CSubscribePresentityGroupContentRequest() |
|
121 { |
|
122 IMPS_DP( D_IMPS_LIT( "::~CSubscribePresentityGroupContentRequest Start" ) ); |
|
123 delete iResponse; |
|
124 delete iParser; |
|
125 delete iGroupName; |
|
126 delete iContactName; |
|
127 delete iGroupDisplayName; |
|
128 delete iUserId; |
|
129 |
|
130 CActive::Cancel(); |
|
131 iConnMan.Remove( this ); |
|
132 IMPS_DP( D_IMPS_LIT( "::~CSubscribePresentityGroupContentRequest End" ) ); |
|
133 } |
|
134 |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // CSubscribePresentityGroupContentRequest::DoCancel() |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 void CSubscribePresentityGroupContentRequest::DoCancel() |
|
141 { |
|
142 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::DoCancel Start" ) ); |
|
143 |
|
144 iConnMan.DataHandler().CancelSending( iSendId ); |
|
145 |
|
146 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::DoCancel End" ) ); |
|
147 } |
|
148 |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // CSubscribePresentityGroupContentRequest::RunL() |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 void CSubscribePresentityGroupContentRequest::RunL() |
|
155 { |
|
156 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::RunL Start" ) ); |
|
157 |
|
158 User::LeaveIfError( iStatus.Int() ); |
|
159 |
|
160 iResponse = iConnMan.DataHandler().ResponseL( iSendId ); |
|
161 |
|
162 TPtrC8 resultBlock( NULL, 0 ); |
|
163 TInt wvErrorCode = KErrNone; |
|
164 |
|
165 // Check if we got 200 |
|
166 if ( iParser->DecodeL( *iResponse, KResultXMLTag, ETrue ) ) |
|
167 { |
|
168 resultBlock.Set( iParser->ResultL() ); |
|
169 if ( iParser->DecodeL( resultBlock, KCodeXMLTag, EFalse ) ) |
|
170 { |
|
171 TPtrC8 cspStatusCodeBlock( iParser->ResultL() ); |
|
172 TInt cspStatusInt; |
|
173 TLex8 lexer( cspStatusCodeBlock ); |
|
174 lexer.SkipSpace(); |
|
175 TInt lexErr = lexer.Val( cspStatusInt ); |
|
176 if ( lexErr == KErrNone ) |
|
177 { |
|
178 wvErrorCode = cspStatusInt; |
|
179 } |
|
180 } |
|
181 } |
|
182 |
|
183 // if we get 200 then fetch the details else complete the request |
|
184 |
|
185 if ( KWVRequestResponseResultCode == wvErrorCode ) |
|
186 { |
|
187 MXIMPObjectFactory& prfwObjFact = iConnMan.HandleToHost().ObjectFactory(); |
|
188 MPresenceObjectFactory& prObjFact = |
|
189 iConnMan.HandleToHost().ProtocolPresenceDataHost().PresenceObjectFactory(); |
|
190 MXIMPObjectCollection* listOfContacts = prfwObjFact.NewObjectCollectionLC(); |
|
191 |
|
192 MXIMPIdentity* contactIdentity; |
|
193 MPresentityGroupMemberInfo* groupMemberInfo; |
|
194 |
|
195 TBool nicknameflag = EFalse; |
|
196 TBool useridflag = EFalse; |
|
197 |
|
198 // NickName exists |
|
199 if ( iParser->DecodeL( *iResponse, KNickName, EFalse ) ) |
|
200 { |
|
201 IMPS_DP( D_IMPS_LIT( "NickName Exists in the result" ) ); |
|
202 nicknameflag = ETrue; |
|
203 } |
|
204 |
|
205 // UserID exists |
|
206 if ( iParser->DecodeL( *iResponse, KNickName, EFalse ) ) |
|
207 { |
|
208 IMPS_DP( D_IMPS_LIT( "UserID Exists in the result" ) ); |
|
209 useridflag = ETrue; |
|
210 } |
|
211 IMPS_DP( D_IMPS_LIT( "------------------------------------------------------------------" ) ); |
|
212 |
|
213 IMPS_DP( D_IMPS_LIT( "---------------------Data from presadap1.2 to PresenceFramework-----------" ) ); |
|
214 |
|
215 if ( nicknameflag && useridflag ) |
|
216 { |
|
217 |
|
218 // this is to be tested for boundary conditions of contacts. |
|
219 if ( iParser->DecodeL( *iResponse, KNickName, EFalse ) ) |
|
220 { |
|
221 |
|
222 TInt countResults( iParser->Count() ); |
|
223 IMPS_DP( D_IMPS_LIT( "UserID and NickName Both exists count %d" ), countResults ); |
|
224 for ( TInt i = 0 ; i < countResults; ++i ) |
|
225 { |
|
226 |
|
227 contactIdentity = prfwObjFact.NewIdentityLC(); |
|
228 iParser->DecodeL( *iResponse, KName, EFalse ); |
|
229 iContactName = iParser->ResultAsUnicodeTextL( i ); |
|
230 iContactName->Des().Fold(); |
|
231 |
|
232 |
|
233 iParser->DecodeL( *iResponse, KUserIDXMLTag, EFalse ); |
|
234 iUserId = iParser->ResultAsUnicodeTextL( i ); |
|
235 iUserId->Des().Fold(); |
|
236 |
|
237 contactIdentity->SetIdentityL( *iUserId ); |
|
238 |
|
239 groupMemberInfo = prObjFact.NewPresentityGroupMemberInfoLC(); |
|
240 |
|
241 groupMemberInfo->SetGroupMemberIdL( contactIdentity ); |
|
242 groupMemberInfo->SetGroupMemberDisplayNameL( *iContactName ); |
|
243 |
|
244 listOfContacts->AddObjectL( groupMemberInfo ); |
|
245 |
|
246 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::RunL:UserId:%S " ), iUserId ); |
|
247 |
|
248 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::RunL:ContactName:%S " ), iContactName ); |
|
249 |
|
250 delete iContactName; |
|
251 iContactName = NULL; |
|
252 |
|
253 delete iUserId; |
|
254 iUserId = NULL; |
|
255 |
|
256 CleanupStack::Pop( 2 ); // groupMemberInfo, contactIdentity |
|
257 } |
|
258 |
|
259 } |
|
260 } |
|
261 else |
|
262 { |
|
263 |
|
264 // this is to be tested for boundary conditions of contacts. |
|
265 if ( iParser->DecodeL( *iResponse, KUserIDXMLTag, EFalse ) ) |
|
266 { |
|
267 TInt countResults( iParser->Count() ); |
|
268 IMPS_DP( D_IMPS_LIT( "UserID and NickName either of them exists count %d" ), countResults ); |
|
269 for ( TInt i = 0 ; i < countResults; ++i ) |
|
270 { |
|
271 contactIdentity = prfwObjFact.NewIdentityLC(); |
|
272 |
|
273 iParser->DecodeL( *iResponse, KUserIDXMLTag, EFalse ); |
|
274 iUserId = iParser->ResultAsUnicodeTextL( i ); |
|
275 iUserId->Des().Fold(); |
|
276 |
|
277 contactIdentity->SetIdentityL( *iUserId ); |
|
278 groupMemberInfo = prObjFact.NewPresentityGroupMemberInfoLC(); |
|
279 groupMemberInfo->SetGroupMemberIdL( contactIdentity ); |
|
280 |
|
281 listOfContacts->AddObjectL( groupMemberInfo ); |
|
282 |
|
283 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::RunL:UserId:%S " ), iUserId ); |
|
284 |
|
285 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::RunL:ContactName:%S " ), &contactIdentity->Identity() ); |
|
286 |
|
287 delete iUserId; |
|
288 iUserId = NULL; |
|
289 |
|
290 CleanupStack::Pop( 2 ); // groupMemberInfo, contactIdentity |
|
291 } |
|
292 |
|
293 } |
|
294 } |
|
295 |
|
296 MXIMPIdentity* groupIdentity1 = prfwObjFact.NewIdentityLC(); |
|
297 groupIdentity1->SetIdentityL( *iGroupName ); |
|
298 iConnMan.HandleToHost().ProtocolPresenceDataHost().GroupsDataHost().HandlePresentityGroupContentL( |
|
299 groupIdentity1, listOfContacts ); |
|
300 |
|
301 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, KErrNone ); |
|
302 |
|
303 |
|
304 IMPS_DP( D_IMPS_LIT( " before clprop " ) ); |
|
305 if ( iParser->DecodeL( *iResponse, KContactListProperties, EFalse ) ) |
|
306 { |
|
307 MPEngXMLParser* Parser2 = CreateXMLParserLC(); |
|
308 if ( iParser->DecodeL( *iResponse, KProperty, ETrue ) ) // EFalse )) |
|
309 { |
|
310 TInt countResults( iParser->Count() ); |
|
311 |
|
312 for ( TInt i = 0 ; i < countResults; ++i ) |
|
313 { |
|
314 IMPS_DP( D_IMPS_LIT( " clprop index::%d %d" ), i, countResults ); |
|
315 if ( Parser2->DecodeL( iParser->ResultL( i ), KName, EFalse ) ) // *iResponse, KName, EFalse )) |
|
316 { |
|
317 IMPS_DP( D_IMPS_LIT( " name" ) ); |
|
318 if ( Parser2->ResultL().CompareF( KDispName ) == KErrNone ) |
|
319 { |
|
320 |
|
321 if ( Parser2->DecodeL( iParser->ResultL( i ), KValue, EFalse ) ) // *iResponse, KValue, EFalse )) |
|
322 { |
|
323 MXIMPIdentity* groupIdentity = prfwObjFact.NewIdentityLC(); |
|
324 iGroupDisplayName = Parser2->ResultAsUnicodeTextL(); |
|
325 iGroupDisplayName->Des().Fold(); |
|
326 IMPS_DP( D_IMPS_LIT( " CSubscribePresentityGroupContentRequest::RunL:displayname::%s" ), iGroupDisplayName ); |
|
327 MPresentityGroupInfo* groupInfo = prObjFact.NewPresentityGroupInfoLC(); |
|
328 groupIdentity->SetIdentityL( *iGroupName ); |
|
329 groupInfo->SetGroupIdL( groupIdentity ); |
|
330 groupInfo->SetGroupDisplayNameL( *iGroupDisplayName ); |
|
331 iConnMan.HandleToHost().ProtocolPresenceDataHost().GroupsDataHost().HandlePresentityGroupDisplayNameUpdatedL( groupInfo ); |
|
332 delete iGroupDisplayName; |
|
333 iGroupDisplayName = NULL; |
|
334 |
|
335 CleanupStack::Pop( 2 ); //groupInfo,groupIdentity |
|
336 } |
|
337 continue; |
|
338 } |
|
339 // parse default flag |
|
340 if ( Parser2->ResultL().CompareF( KDefault ) == KErrNone ) |
|
341 { |
|
342 IMPS_DP( D_IMPS_LIT( " default" ) ); |
|
343 // OK that is settings of the default list |
|
344 if ( Parser2->DecodeL( iParser->ResultL( i ), |
|
345 KValue, |
|
346 EFalse ) ) |
|
347 { |
|
348 //TBool defValue( aXMLparser2.ResultL().CompareF( |
|
349 // KXMLValueTrue ) == KErrNone ); |
|
350 |
|
351 } |
|
352 } |
|
353 } // |
|
354 } // for end |
|
355 |
|
356 IMPS_DP( D_IMPS_LIT( " out of for" ) ); |
|
357 } // if end |
|
358 CleanupStack::PopAndDestroy(); // Parser2 |
|
359 } |
|
360 |
|
361 CleanupStack::Pop( 2 ); //groupIdentity1,listOfContacts |
|
362 } |
|
363 else |
|
364 { |
|
365 IMPS_DP( D_IMPS_LIT( "HRC error code %d" ), wvErrorCode ); |
|
366 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, wvErrorCode ); |
|
367 } |
|
368 |
|
369 delete this; |
|
370 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::RunL End" ) ); |
|
371 } |
|
372 |
|
373 |
|
374 // --------------------------------------------------------------------------- |
|
375 // CSubscribePresentityGroupContentRequest::RunError |
|
376 // --------------------------------------------------------------------------- |
|
377 // |
|
378 TInt CSubscribePresentityGroupContentRequest::RunError( TInt aError ) |
|
379 { |
|
380 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::RunError Start" ) ); |
|
381 |
|
382 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, aError ); |
|
383 |
|
384 delete this; |
|
385 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::RunError End" ) ); |
|
386 return KErrNone; |
|
387 } |
|
388 |
|
389 // --------------------------------------------------------------------------- |
|
390 // CSubscribePresentityGroupContentRequest::SubscribePresentityGroupContentL |
|
391 // --------------------------------------------------------------------------- |
|
392 // |
|
393 void CSubscribePresentityGroupContentRequest::SubscribePresentityGroupContentL( |
|
394 const MXIMPIdentity& aIdentity ) |
|
395 { |
|
396 IMPS_DP( D_IMPS_LIT( "::SubscribePresentityGroupContentL Start" ) ); |
|
397 |
|
398 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::SubscribePresentityGroupContentL Start" ) ); |
|
399 |
|
400 IMPS_DP( D_IMPS_LIT( "------------------------------------------------------------------" ) ); |
|
401 |
|
402 IMPS_DP( D_IMPS_LIT( "---------------------Data from framework to presadap1.2-----------" ) ); |
|
403 |
|
404 IMPS_DP( D_IMPS_LIT( "CSubscribePresentityGroupContentRequest::SubscribePresentityGroupContentL:GroupId:%S " ), &aIdentity.Identity() ); |
|
405 |
|
406 TPtr8 ptrbuffer( iConnMan.DataHandler().TransferBufferL() ); |
|
407 MPEngXMLSerializer* serializer = CreateXmlSerializerLC( ptrbuffer ); |
|
408 |
|
409 iGroupName = aIdentity.Identity().AllocL(); |
|
410 |
|
411 NImpsAdapXMLTools::AppendTransactionContentTagXmlL( *serializer, iConnMan.GetVersion() ); |
|
412 serializer->StartTagL( KListMnageRequest ); |
|
413 |
|
414 if ( KErrNone == iGroupName->Left( KPEngAttrWVIdPrefixLength ).CompareF( KPengWVIDPrefix ) ) |
|
415 { |
|
416 serializer->StartTagL( KContactList |
|
417 ).WvAddressL( aIdentity.Identity() |
|
418 ).EndTagL( KContactList ); |
|
419 } |
|
420 |
|
421 else |
|
422 { |
|
423 serializer->StartTagL( KContactList |
|
424 ).NarrowTextL( KWVXMLTag |
|
425 ).WvAddressL( aIdentity.Identity() |
|
426 ).EndTagL( KContactList ); |
|
427 } |
|
428 |
|
429 serializer->StartTagL( KReceiveList ).NarrowTextL( KXMLValueTrue ).EndTagL( KReceiveList ); |
|
430 |
|
431 serializer->EndTagL( KListMnageRequest ); |
|
432 |
|
433 serializer->EndTagL( KTransactionContent ); |
|
434 |
|
435 |
|
436 IMPS_DP( D_IMPS_LIT( "SubscribePresentityGroupContentL" ) ); |
|
437 |
|
438 CleanupStack::PopAndDestroy(); //serializer |
|
439 |
|
440 iSendId = iConnMan.DataHandler().SendDataL( iStatus ); |
|
441 |
|
442 // signal the scheduler |
|
443 SetActive(); |
|
444 |
|
445 IMPS_DP( D_IMPS_LIT( "::SubscribePresentityGroupContentL End" ) ); |
|
446 } |
|
447 |
|
448 // End of file |