|
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: Delete Presentity Group Request to the Network Server. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ximpprotocolconnectionhost.h> |
|
20 #include "CDeletePresentityGroupRequest.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 |
|
46 // ======== MEMBER FUNCTIONS ======== |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CDeletePresentityGroupRequest::CDeletePresentityGroupRequest |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CDeletePresentityGroupRequest::CDeletePresentityGroupRequest( |
|
53 MImpsPrtPluginConnectionManager& aConnMan, |
|
54 TXIMPRequestId aRequestId ) : |
|
55 CActive( EPriorityNormal ), |
|
56 iRequestId( aRequestId ), |
|
57 iConnMan( aConnMan ) |
|
58 { |
|
59 IMPS_DP( D_IMPS_LIT( "::CDeletePresentityGroupRequest Start" ) ); |
|
60 CActiveScheduler::Add( this ); |
|
61 IMPS_DP( D_IMPS_LIT( "::CDeletePresentityGroupRequest End" ) ); |
|
62 } |
|
63 |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CDeletePresentityGroupRequest::ConstructL |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CDeletePresentityGroupRequest::ConstructL() |
|
70 { |
|
71 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::ConstructL Start" ) ); |
|
72 |
|
73 iParser = CreateXMLParserL(); |
|
74 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::ConstructL End" ) ); |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CDeletePresentityGroupRequest::NewL |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 CDeletePresentityGroupRequest* CDeletePresentityGroupRequest::NewL( |
|
83 MImpsPrtPluginConnectionManager& aConnMan, |
|
84 TXIMPRequestId aRequestId ) |
|
85 { |
|
86 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::NewL Start" ) ); |
|
87 |
|
88 CDeletePresentityGroupRequest* self = |
|
89 new( ELeave ) CDeletePresentityGroupRequest( aConnMan, aRequestId ); |
|
90 CleanupStack::PushL( self ); |
|
91 self->ConstructL(); |
|
92 CleanupStack::Pop( self ); |
|
93 |
|
94 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::NewL End" ) ); |
|
95 return self; |
|
96 } |
|
97 |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CDeletePresentityGroupRequest::NewLC |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 CDeletePresentityGroupRequest* CDeletePresentityGroupRequest::NewLC( |
|
104 MImpsPrtPluginConnectionManager& aConnMan, |
|
105 TXIMPRequestId aRequestId ) |
|
106 { |
|
107 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::NewLC Start" ) ); |
|
108 |
|
109 CDeletePresentityGroupRequest* self = |
|
110 CDeletePresentityGroupRequest::NewL( aConnMan, aRequestId ); |
|
111 CleanupStack::PushL( self ); |
|
112 |
|
113 |
|
114 |
|
115 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::NewLC End" ) ); |
|
116 return self; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CDeletePresentityGroupRequest::~CDeletePresentityGroupRequest |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 CDeletePresentityGroupRequest::~CDeletePresentityGroupRequest() |
|
124 { |
|
125 IMPS_DP( D_IMPS_LIT( "::~CDeletePresentityGroupRequest Start" ) ); |
|
126 CActive::Cancel(); |
|
127 iConnMan.Remove( this ); |
|
128 delete iGroupName; |
|
129 delete iParser; |
|
130 IMPS_DP( D_IMPS_LIT( "::~CDeletePresentityGroupRequest End" ) ); |
|
131 } |
|
132 |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CDeletePresentityGroupRequest::DoCancel() |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void CDeletePresentityGroupRequest::DoCancel() |
|
139 { |
|
140 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::DoCancel Start" ) ); |
|
141 |
|
142 iConnMan.DataHandler().CancelSending( iSendId ); |
|
143 |
|
144 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::DoCancel End" ) ); |
|
145 } |
|
146 |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // CDeletePresentityGroupRequest::RunL() |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 void CDeletePresentityGroupRequest::RunL() |
|
153 { |
|
154 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::RunL Start" ) ); |
|
155 |
|
156 User::LeaveIfError( iStatus.Int() ); |
|
157 |
|
158 HBufC8* response = iConnMan.DataHandler().ResponseL( iSendId ); |
|
159 CleanupStack::PushL( response ); |
|
160 |
|
161 TPtrC8 resultBlock( NULL, 0 ); |
|
162 TInt wvErrorCode = KErrNone; |
|
163 |
|
164 //Look for mandatory parts |
|
165 if ( iParser->DecodeL( *response, 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 CleanupStack::PopAndDestroy( response ); |
|
183 |
|
184 IMPS_DP( D_IMPS_LIT( "DeletePresentityGroupRequest %d" ), wvErrorCode ); |
|
185 |
|
186 // issue request to prfw datacache for updated info |
|
187 if ( KWVRequestResponseResultCode == wvErrorCode ) |
|
188 { |
|
189 MXIMPObjectFactory& prfwObjFact = iConnMan.HandleToHost().ObjectFactory(); |
|
190 MXIMPIdentity* groupName = prfwObjFact.NewIdentityLC(); |
|
191 groupName->SetIdentityL( *iGroupName ); |
|
192 |
|
193 iConnMan.HandleToHost().ProtocolPresenceDataHost().GroupsDataHost().HandlePresentityGroupDeletedL( groupName ); |
|
194 |
|
195 IMPS_DP( D_IMPS_LIT( "------------------------------------------------------------------" ) ); |
|
196 |
|
197 IMPS_DP( D_IMPS_LIT( "---------------------Data from presadap1.2 to PresenceFramework-----------" ) ); |
|
198 |
|
199 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::RunL:GroupId:%S " ), iGroupName ); |
|
200 |
|
201 IMPS_DP( D_IMPS_LIT( "------------------------------------------------------------------" ) ); |
|
202 |
|
203 CleanupStack::Pop( 1 ); // groupName |
|
204 } |
|
205 |
|
206 // tell prfw that request is complete |
|
207 if ( wvErrorCode == KWVRequestResponseResultCode ) |
|
208 { |
|
209 wvErrorCode = KErrNone; |
|
210 } |
|
211 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, wvErrorCode ); |
|
212 |
|
213 delete this; |
|
214 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::RunL End" ) ); |
|
215 } |
|
216 |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CDeletePresentityGroupRequest::RunError |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 TInt CDeletePresentityGroupRequest::RunError( TInt aError ) |
|
223 { |
|
224 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::RunError %d" ), aError ); |
|
225 |
|
226 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, aError ); |
|
227 |
|
228 delete this; |
|
229 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::RunError End" ) ); |
|
230 return KErrNone; |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // CDeletePresentityGroupRequest::DeletePresentityGroupRequestL |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 void CDeletePresentityGroupRequest::DeletePresentityGroupRequestL( |
|
238 const MXIMPIdentity& aIdentity ) |
|
239 { |
|
240 IMPS_DP( D_IMPS_LIT( "::DeletePresentityGroupRequestL Start" ) ); |
|
241 |
|
242 IMPSPRTPLUGIN_UNUSED_PARAM( aIdentity ); |
|
243 |
|
244 IMPS_DP( D_IMPS_LIT( "------------------------------------------------------------------" ) ); |
|
245 |
|
246 IMPS_DP( D_IMPS_LIT( "---------------------Data from framework to presadap1.2-----------" ) ); |
|
247 |
|
248 IMPS_DP( D_IMPS_LIT( "CDeletePresentityGroupRequest::DeletePresentityGroupRequestL:aIdentity:%S " ), & aIdentity.Identity() ); |
|
249 |
|
250 TPtr8 ptrbuffer( iConnMan.DataHandler().TransferBufferL() ); |
|
251 MPEngXMLSerializer* serializer = CreateXmlSerializerLC( ptrbuffer ); |
|
252 |
|
253 iGroupName = aIdentity.Identity().AllocL(); |
|
254 |
|
255 IMPS_DP( D_IMPS_LIT( "DeletePresentityGroupRequestL Manufacture XML " ) ); |
|
256 |
|
257 NImpsAdapXMLTools::AppendTransactionContentTagXmlL( *serializer, iConnMan.GetVersion() ); |
|
258 |
|
259 serializer->StartTagL( KDeleteList ); |
|
260 |
|
261 // <ContactList> |
|
262 // Contact list name value |
|
263 // </ContactList> |
|
264 if ( KErrNone == iGroupName->Left( KPEngAttrWVIdPrefixLength ).CompareF( KPengWVIDPrefix ) ) |
|
265 { |
|
266 serializer->StartTagL( KContactList |
|
267 ).WvAddressL( aIdentity.Identity() |
|
268 ).EndTagL( KContactList ); |
|
269 } |
|
270 else |
|
271 { |
|
272 serializer->StartTagL( KContactList |
|
273 ).NarrowTextL( KWVXMLTag |
|
274 ).WvAddressL( aIdentity.Identity() |
|
275 ).EndTagL( KContactList ); |
|
276 } |
|
277 |
|
278 // </DeleteList-Request> |
|
279 serializer->EndTagL( KDeleteList ); |
|
280 serializer->EndTagL( KTransactionContent ); |
|
281 |
|
282 CleanupStack::PopAndDestroy(); //serializer |
|
283 |
|
284 IMPS_DP( D_IMPS_LIT( "DeletePresentityGroupRequestL SendData to the DataHandler" ) ); |
|
285 iSendId = iConnMan.DataHandler().SendDataL( iStatus ); |
|
286 |
|
287 |
|
288 IMPS_DP( D_IMPS_LIT( "DeletePresentityGroupRequestL Before SetActive" ) ); |
|
289 // signal the scheduler |
|
290 SetActive(); |
|
291 |
|
292 IMPS_DP( D_IMPS_LIT( "::DeletePresentityGroupRequestL End" ) ); |
|
293 } |
|
294 |
|
295 // End of file |