|
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 "CCreatePresentityGroupRequest.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 <presenceobjectfactory.h> |
|
36 #include <protocolpresencedatahost.h> |
|
37 #include <ximpobjectcollection.h> |
|
38 #include <protocolpresentitygroupsdatahost.h> |
|
39 #include <presentitygroupinfo.h> |
|
40 #include <presentitygroupmemberinfo.h> |
|
41 #include <ximpidentity.h> |
|
42 #include "PImpsAdapXMLTools.h" |
|
43 |
|
44 |
|
45 // ======== MEMBER FUNCTIONS ======== |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CCreatePresentityGroupRequest::CCreatePresentityGroupRequest |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CCreatePresentityGroupRequest::CCreatePresentityGroupRequest( |
|
52 MImpsPrtPluginConnectionManager& aConnMan, |
|
53 TXIMPRequestId aRequestId ) : |
|
54 CActive( EPriorityNormal ), |
|
55 iRequestId( aRequestId ), |
|
56 iConnMan( aConnMan ) |
|
57 { |
|
58 IMPS_DP( D_IMPS_LIT( "::CCreatePresentityGroupRequest Start" ) ); |
|
59 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest request id is %d %d" ), iRequestId, aRequestId ); |
|
60 CActiveScheduler::Add( this ); |
|
61 IMPS_DP( D_IMPS_LIT( "::CCreatePresentityGroupRequest End" ) ); |
|
62 } |
|
63 |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CCreatePresentityGroupRequest::ConstructL |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CCreatePresentityGroupRequest::ConstructL() |
|
70 { |
|
71 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::ConstructL Start" ) ); |
|
72 |
|
73 iParser = CreateXMLParserL(); |
|
74 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::ConstructL End" ) ); |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CCreatePresentityGroupRequest::NewL |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 CCreatePresentityGroupRequest* CCreatePresentityGroupRequest::NewL( |
|
83 MImpsPrtPluginConnectionManager& aConnMan, |
|
84 TXIMPRequestId aRequestId ) |
|
85 { |
|
86 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::NewL Start" ) ); |
|
87 |
|
88 CCreatePresentityGroupRequest* self = |
|
89 new( ELeave ) CCreatePresentityGroupRequest( aConnMan, aRequestId ); |
|
90 CleanupStack::PushL( self ); |
|
91 self->ConstructL(); |
|
92 CleanupStack::Pop( self ); |
|
93 |
|
94 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::NewL End" ) ); |
|
95 return self; |
|
96 } |
|
97 |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CCreatePresentityGroupRequest::NewLC |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 CCreatePresentityGroupRequest* CCreatePresentityGroupRequest::NewLC( |
|
104 MImpsPrtPluginConnectionManager& aConnMan, |
|
105 TXIMPRequestId aRequestId ) |
|
106 { |
|
107 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::NewLC Start" ) ); |
|
108 |
|
109 CCreatePresentityGroupRequest* self = |
|
110 CCreatePresentityGroupRequest::NewL( aConnMan, aRequestId ); |
|
111 CleanupStack::PushL( self ); |
|
112 |
|
113 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::NewLC End" ) ); |
|
114 return self; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CCreatePresentityGroupRequest::~CCreatePresentityGroupRequest |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 CCreatePresentityGroupRequest::~CCreatePresentityGroupRequest() |
|
122 { |
|
123 IMPS_DP( D_IMPS_LIT( "::~CCreatePresentityGroupRequest Start" ) ); |
|
124 delete iResponse; |
|
125 delete iGroupDisplayName; |
|
126 delete iParser; |
|
127 delete iGroupId; |
|
128 CActive::Cancel(); |
|
129 iConnMan.Remove( this ); |
|
130 |
|
131 IMPS_DP( D_IMPS_LIT( "::~CCreatePresentityGroupRequest End" ) ); |
|
132 } |
|
133 |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // CCreatePresentityGroupRequest::DoCancel() |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void CCreatePresentityGroupRequest::DoCancel() |
|
140 { |
|
141 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::DoCancel Start" ) ); |
|
142 |
|
143 iConnMan.DataHandler().CancelSending( iSendId ); |
|
144 |
|
145 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::DoCancel End" ) ); |
|
146 } |
|
147 |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // CCreatePresentityGroupRequest::RunL() |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 void CCreatePresentityGroupRequest::RunL() |
|
154 { |
|
155 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::RunL Start" ) ); |
|
156 |
|
157 User::LeaveIfError( iStatus.Int() ); |
|
158 |
|
159 iResponse = iConnMan.DataHandler().ResponseL( iSendId ); |
|
160 |
|
161 TPtrC8 resultBlock( NULL, 0 ); |
|
162 TInt wvErrorCode = KErrNone; |
|
163 |
|
164 //Look for mandatory parts |
|
165 if ( iParser->DecodeL( *iResponse, KResultXMLTag, ETrue ) ) |
|
166 { |
|
167 resultBlock.Set( iParser->ResultL() ); |
|
168 if ( iParser->DecodeL( resultBlock, KCodeXMLTag, EFalse ) ) |
|
169 { |
|
170 TPtrC8 cspStatusCodeBlock( iParser->ResultL() ); |
|
171 TInt cspStatusInt; |
|
172 TLex8 lexer( cspStatusCodeBlock ); |
|
173 lexer.SkipSpace(); |
|
174 TInt lexErr = lexer.Val( cspStatusInt ); |
|
175 if ( lexErr == KErrNone ) |
|
176 { |
|
177 wvErrorCode = cspStatusInt; |
|
178 } |
|
179 } |
|
180 } |
|
181 |
|
182 IMPS_DP( D_IMPS_LIT( "CreatePresentityGroupRequest Return Code %d" ), wvErrorCode ); |
|
183 |
|
184 |
|
185 // issue request to prfw datacache for updated info |
|
186 // so that client can get the updateded event |
|
187 |
|
188 if ( KWVRequestResponseResultCode == wvErrorCode ) |
|
189 { |
|
190 MXIMPObjectFactory& prfwObjFact = iConnMan.HandleToHost().ObjectFactory(); |
|
191 MPresenceObjectFactory& objFact = iConnMan.HandleToHost().ProtocolPresenceDataHost().PresenceObjectFactory(); |
|
192 MXIMPIdentity* groupIdentity = prfwObjFact.NewIdentityLC(); |
|
193 groupIdentity->SetIdentityL( *iGroupId ); |
|
194 |
|
195 MPresentityGroupInfo* groupInfo = objFact.NewPresentityGroupInfoLC(); |
|
196 groupInfo->SetGroupIdL( groupIdentity ); |
|
197 groupInfo->SetGroupDisplayNameL( *iGroupDisplayName ); |
|
198 |
|
199 iConnMan.HandleToHost().ProtocolPresenceDataHost().GroupsDataHost().HandlePresentityGroupCreatedL( groupInfo ); |
|
200 |
|
201 IMPS_DP( D_IMPS_LIT( "------------------------------------------------------------------" ) ); |
|
202 |
|
203 IMPS_DP( D_IMPS_LIT( "---------------------Data from presadap1.2 to PresenceFramework-----------" ) ); |
|
204 |
|
205 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::RunL():GroupId:%S " ), iGroupId ); |
|
206 |
|
207 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::RunL():GroupDisplayName:%S " ), iGroupDisplayName ); |
|
208 |
|
209 IMPS_DP( D_IMPS_LIT( "------------------------------------------------------------------" ) ); |
|
210 |
|
211 CleanupStack::Pop( 2 ); // groupInfo,groupName |
|
212 } |
|
213 if ( wvErrorCode == KWVRequestResponseResultCode ) |
|
214 { |
|
215 wvErrorCode = KErrNone; |
|
216 } |
|
217 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, wvErrorCode ); |
|
218 delete this; |
|
219 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::RunL End" ) ); |
|
220 } |
|
221 |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // CCreatePresentityGroupRequest::RunError |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 TInt CCreatePresentityGroupRequest::RunError( TInt aError ) |
|
228 { |
|
229 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::RunError %d " ), aError ); |
|
230 |
|
231 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, aError ); |
|
232 |
|
233 delete this; |
|
234 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::RunError End" ) ); |
|
235 return KErrNone; |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------------------------- |
|
239 // CCreatePresentityGroupRequest::CreatePresentityGroupRequestL |
|
240 // --------------------------------------------------------------------------- |
|
241 // |
|
242 void CCreatePresentityGroupRequest::CreatePresentityGroupRequestL( |
|
243 const MXIMPIdentity& aIdentity, |
|
244 const TDesC16& aDisplayName ) |
|
245 { |
|
246 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::CreatePresentityGroupRequestL Start" ) ); |
|
247 |
|
248 IMPS_DP( D_IMPS_LIT( "------------------------------------------------------------------" ) ); |
|
249 |
|
250 IMPS_DP( D_IMPS_LIT( "---------------------Data from framework to presadap1.2-----------" ) ); |
|
251 |
|
252 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::CreatePresentityGroupRequestL:aIdentity:%S " ), & aIdentity.Identity() ); |
|
253 |
|
254 IMPS_DP( D_IMPS_LIT( "CCreatePresentityGroupRequest::CreatePresentityGroupRequestL:aDisplayName:%S " ), &aDisplayName ); |
|
255 |
|
256 |
|
257 TPtr8 ptrbuffer( iConnMan.DataHandler().TransferBufferL() ); |
|
258 MPEngXMLSerializer* serializer = CreateXmlSerializerLC( ptrbuffer ); |
|
259 |
|
260 iGroupDisplayName = aDisplayName.AllocL(); |
|
261 |
|
262 iGroupId = aIdentity.Identity().AllocL(); |
|
263 NImpsAdapXMLTools::AppendTransactionContentTagXmlL( *serializer, |
|
264 iConnMan.GetVersion() ); |
|
265 |
|
266 |
|
267 // <CreateList-Request> |
|
268 serializer->StartTagL( KCreateList ); |
|
269 if ( KErrNone == iGroupId->Left( KPEngAttrWVIdPrefixLength ).CompareF( KPengWVIDPrefix ) ) |
|
270 { |
|
271 serializer->StartTagL( KContactList ). |
|
272 WvAddressL( aIdentity.Identity() ). |
|
273 //NarrowTextL( KServerAddressTag ). |
|
274 EndTagL( KContactList ); |
|
275 } |
|
276 |
|
277 |
|
278 else |
|
279 { |
|
280 serializer->StartTagL( KContactList ). |
|
281 NarrowTextL( KWVXMLTag ). |
|
282 //NarrowTextL(KHash). |
|
283 WvAddressL( aIdentity.Identity() ). |
|
284 //NarrowTextL( KServerAddressTag ). |
|
285 EndTagL( KContactList ); |
|
286 } |
|
287 // <ContactListProperties> |
|
288 // <Property> |
|
289 serializer->StartTagL( KContactListProperties ). |
|
290 StartTagL( KProperty ); |
|
291 |
|
292 // <Name> |
|
293 // DisplayName |
|
294 // </Name> |
|
295 serializer->StartTagL( KName ). |
|
296 NarrowTextL( KDispName ). |
|
297 EndTagL( KName ); |
|
298 |
|
299 // <Value> |
|
300 // display name value |
|
301 // </Value> |
|
302 serializer->StartTagL( KValue ). |
|
303 UnicodeTextL( aDisplayName ). |
|
304 EndTagL( KValue ); |
|
305 |
|
306 serializer->EndTagL( KProperty ); |
|
307 serializer->StartTagL( KProperty ); |
|
308 // <Name> |
|
309 // Default |
|
310 // </Name> |
|
311 serializer->StartTagL( KName ). |
|
312 NarrowTextL( KDefault ). |
|
313 EndTagL( KName ); |
|
314 |
|
315 // <Value> |
|
316 // display name value |
|
317 // </Value> |
|
318 serializer->StartTagL( KValue ). |
|
319 NarrowTextL( KXMLValueFalse ). |
|
320 EndTagL( KValue ); |
|
321 |
|
322 // </Property> |
|
323 serializer->EndTagL( KProperty ); |
|
324 serializer->EndTagL( KContactListProperties ); |
|
325 |
|
326 |
|
327 // </CreateList-Request> |
|
328 serializer->EndTagL( KCreateList ); |
|
329 serializer->EndTagL( KTransactionContent ); |
|
330 |
|
331 IMPS_DP( D_IMPS_LIT( "CreatePresentityGroupRequest" ) ); |
|
332 |
|
333 CleanupStack::PopAndDestroy(); //serializer |
|
334 |
|
335 iSendId = iConnMan.DataHandler().SendDataL( iStatus ); |
|
336 |
|
337 // complete the request to prfw |
|
338 // iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, KErrNone ); |
|
339 |
|
340 // signal the scheduler |
|
341 SetActive(); |
|
342 |
|
343 IMPS_DP( D_IMPS_LIT( "::CreatePresentityGroupRequestL End" ) ); |
|
344 } |
|
345 |
|
346 // End of file |