|
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 "CWithdrawPresenceGrantFromPresentityRequest.h" |
|
21 #include "impsconnectionmanagercontrolif.h" |
|
22 #include "impsdebugprint.h" |
|
23 #include "CImpsPluginAccessHandler.h" |
|
24 #include "CImpsPluginPureDataHandler.h" |
|
25 #include <protocolpresenceauthorizationdatahost.h> |
|
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 #include <ximpprotocolconnectionhost.h> |
|
34 #include <ximpobjectfactory.h> |
|
35 #include <protocolpresencedatahost.h> |
|
36 #include <ximpobjectcollection.h> |
|
37 #include <protocolpresentitygroupsdatahost.h> |
|
38 #include <presentitygroupinfo.h> |
|
39 #include <presentitygroupmemberinfo.h> |
|
40 #include <ximpidentity.h> |
|
41 #include <ximpdatasubscriptionstate.h> |
|
42 #include "PImpsAdapXMLTools.h" |
|
43 |
|
44 |
|
45 // ======== MEMBER FUNCTIONS ======== |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CWithdrawPresenceGrantFromPresentityRequest::CWithdrawPresenceGrantFromPresentityRequest |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CWithdrawPresenceGrantFromPresentityRequest::CWithdrawPresenceGrantFromPresentityRequest( |
|
52 MImpsPrtPluginConnectionManager& aConnMan, |
|
53 TXIMPRequestId aRequestId ) : |
|
54 CActive( EPriorityNormal ), |
|
55 iRequestId( aRequestId ), |
|
56 iConnMan( aConnMan ) |
|
57 { |
|
58 IMPS_DP( D_IMPS_LIT( "Constructor::CWithdrawPresenceGrantFromPresentityRequest Start" ) ); |
|
59 CActiveScheduler::Add( this ); |
|
60 IMPS_DP( D_IMPS_LIT( "Constructor::CWithdrawPresenceGrantFromPresentityRequest End" ) ); |
|
61 } |
|
62 |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CWithdrawPresenceGrantFromPresentityRequest::ConstructL |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CWithdrawPresenceGrantFromPresentityRequest::ConstructL() |
|
69 { |
|
70 IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromPresentityRequest::ConstructL Start-End" ) ); |
|
71 |
|
72 iParser = CreateXMLParserL(); |
|
73 |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CWithdrawPresenceGrantFromPresentityRequest::NewL |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CWithdrawPresenceGrantFromPresentityRequest* CWithdrawPresenceGrantFromPresentityRequest::NewL( |
|
82 MImpsPrtPluginConnectionManager& aConnMan, |
|
83 TXIMPRequestId aRequestId ) |
|
84 { |
|
85 IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromPresentityRequest::NewL Start" ) ); |
|
86 |
|
87 CWithdrawPresenceGrantFromPresentityRequest* self = new( ELeave ) |
|
88 CWithdrawPresenceGrantFromPresentityRequest( aConnMan, aRequestId ); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop( self ); |
|
92 |
|
93 IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromPresentityRequest::NewL End" ) ); |
|
94 return self; |
|
95 } |
|
96 |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CWithdrawPresenceGrantFromPresentityRequest::NewLC |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 CWithdrawPresenceGrantFromPresentityRequest* CWithdrawPresenceGrantFromPresentityRequest::NewLC( |
|
103 MImpsPrtPluginConnectionManager& aConnMan, |
|
104 TXIMPRequestId aRequestId ) |
|
105 { |
|
106 IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromPresentityRequest::NewLC Start" ) ); |
|
107 |
|
108 CWithdrawPresenceGrantFromPresentityRequest* self = |
|
109 CWithdrawPresenceGrantFromPresentityRequest::NewL( aConnMan, aRequestId ); |
|
110 CleanupStack::PushL( self ); |
|
111 |
|
112 IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromPresentityRequest::NewLC End" ) ); |
|
113 return self; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CWithdrawPresenceGrantFromPresentityRequest::~CWithdrawPresenceGrantFromPresentityRequest |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 CWithdrawPresenceGrantFromPresentityRequest::~CWithdrawPresenceGrantFromPresentityRequest() |
|
121 { |
|
122 IMPS_DP( D_IMPS_LIT( "::~CWithdrawPresenceGrantFromPresentityRequest Start" ) ); |
|
123 delete iResponse; |
|
124 CActive::Cancel(); |
|
125 iConnMan.Remove( this ); |
|
126 delete iParser; |
|
127 delete iGroupName; |
|
128 delete iContactName; |
|
129 delete iUserId; |
|
130 IMPS_DP( D_IMPS_LIT( "::~CWithdrawPresenceGrantFromPresentityRequest End" ) ); |
|
131 } |
|
132 |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CWithdrawPresenceGrantFromPresentityRequest::DoCancel() |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void CWithdrawPresenceGrantFromPresentityRequest::DoCancel() |
|
139 { |
|
140 IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromPresentityRequest::DoCancel Start" ) ); |
|
141 |
|
142 iConnMan.DataHandler().CancelSending( iSendId ); |
|
143 |
|
144 IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromPresentityRequest::DoCancel End" ) ); |
|
145 } |
|
146 |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // CWithdrawPresenceGrantFromPresentityRequest::RunL() |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 void CWithdrawPresenceGrantFromPresentityRequest::RunL() |
|
153 { |
|
154 IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromPresentityRequest::RunL Start" ) ); |
|
155 |
|
156 User::LeaveIfError( iStatus.Int() ); |
|
157 |
|
158 iResponse = iConnMan.DataHandler().ResponseL( iSendId ); |
|
159 |
|
160 TPtrC8 resultBlock( NULL, 0 ); |
|
161 TInt wvErrorCode = KErrNone; |
|
162 |
|
163 // Check if we got 200 |
|
164 if ( iParser->DecodeL( *iResponse, KResultXMLTag, ETrue ) ) |
|
165 { |
|
166 resultBlock.Set( iParser->ResultL() ); |
|
167 if ( iParser->DecodeL( resultBlock, KCodeXMLTag, EFalse ) ) |
|
168 { |
|
169 TPtrC8 cspStatusCodeBlock( iParser->ResultL() ); |
|
170 TInt cspStatusInt; |
|
171 TLex8 lexer( cspStatusCodeBlock ); |
|
172 lexer.SkipSpace(); |
|
173 TInt lexErr = lexer.Val( cspStatusInt ); |
|
174 if ( lexErr == KErrNone ) |
|
175 { |
|
176 wvErrorCode = cspStatusInt; |
|
177 } |
|
178 } |
|
179 } |
|
180 |
|
181 MXIMPObjectFactory& prfwObjFact = iConnMan.HandleToHost().ObjectFactory(); |
|
182 MXIMPIdentity* withdrawGrantIdentity = prfwObjFact.NewIdentityLC(); |
|
183 withdrawGrantIdentity->SetIdentityL( *iGroupName ); |
|
184 |
|
185 iConnMan.HandleToHost().ProtocolPresenceDataHost().AuthorizationDataHost().HandlePresenceGrantRequestObsoletedL( |
|
186 withdrawGrantIdentity ); |
|
187 |
|
188 CleanupStack::Pop( 1 ); // withdrawGrantIdentity |
|
189 |
|
190 MXIMPDataSubscriptionState* dataSubscriptionState = prfwObjFact.NewDataSubscriptionStateLC(); |
|
191 dataSubscriptionState->SetDataStateL( MXIMPDataSubscriptionState::EDataAvailable ); |
|
192 dataSubscriptionState->SetSubscriptionStateL( MXIMPDataSubscriptionState::ESubscriptionActive ); |
|
193 |
|
194 // change the state |
|
195 iConnMan.HandleToHost().ProtocolPresenceDataHost().AuthorizationDataHost().SetPresenceGrantRequestDataSubscriptionStateL( |
|
196 dataSubscriptionState, NULL ); |
|
197 |
|
198 CleanupStack::Pop( 1 ); // dataSubscriptionState |
|
199 |
|
200 IMPS_DP( D_IMPS_LIT( "WithdrawPresenceGrantFromPresentityL Return Code %d" ), wvErrorCode ); |
|
201 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, wvErrorCode ); |
|
202 |
|
203 delete this; |
|
204 IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromPresentityRequest::RunL End" ) ); |
|
205 } |
|
206 |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // CWithdrawPresenceGrantFromPresentityRequest::RunError |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 TInt CWithdrawPresenceGrantFromPresentityRequest::RunError( TInt aError ) |
|
213 { |
|
214 IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromPresentityRequest::RunError Start" ) ); |
|
215 |
|
216 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, aError ); |
|
217 |
|
218 delete this; |
|
219 IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromPresentityRequest::RunError End" ) ); |
|
220 return KErrNone; |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // CWithdrawPresenceGrantFromPresentityRequest::WithdrawPresenceGrantFromPresentityL |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 void CWithdrawPresenceGrantFromPresentityRequest::WithdrawPresenceGrantFromPresentityL( |
|
228 const MXIMPIdentity& aIdentity ) |
|
229 { |
|
230 IMPS_DP( D_IMPS_LIT( "::WithdrawPresenceGrantFromPresentityL Start" ) ); |
|
231 |
|
232 IMPS_DP( D_IMPS_LIT( "------------------------------------------------------------------" ) ); |
|
233 |
|
234 IMPS_DP( D_IMPS_LIT( "---------------------Data from framework to presadap1.2-----------" ) ); |
|
235 |
|
236 IMPS_DP( D_IMPS_LIT( "CWithdrawPresenceGrantFromPresentityRequest::WithdrawPresenceGrantFromPresentityL:PresentityId:%S " ), &aIdentity.Identity() ); |
|
237 |
|
238 TPtr8 ptrbuffer( iConnMan.DataHandler().TransferBufferL() ); |
|
239 MPEngXMLSerializer* serializer = CreateXmlSerializerLC( ptrbuffer ); |
|
240 |
|
241 |
|
242 // when we withdraw append to withdraw array |
|
243 iGroupName = aIdentity.Identity().AllocL(); |
|
244 |
|
245 NImpsAdapXMLTools::AppendTransactionContentTagXmlL( *serializer, iConnMan.GetVersion() ); |
|
246 |
|
247 serializer->StartTagL( KCreateAttributeList ); |
|
248 serializer->StartTagL( KPresenceSubList ); |
|
249 serializer->AttributeL( KXmlXmlns, KPresenceSubListAttributesNS_CSP12 ); |
|
250 |
|
251 serializer->EndTagL( KPresenceSubList ); |
|
252 if ( KErrNone == iGroupName->Left( KPEngAttrWVIdPrefixLength ).CompareF( KPengWVIDPrefix ) ) |
|
253 { |
|
254 serializer->StartTagL( KUserIDXMLTag |
|
255 ).WvAddressL( aIdentity.Identity() |
|
256 ).EndTagL( KUserIDXMLTag ); |
|
257 } |
|
258 |
|
259 |
|
260 else |
|
261 { |
|
262 serializer->StartTagL( KUserIDXMLTag |
|
263 ).NarrowTextL( KWVXMLTag |
|
264 ).WvAddressL( aIdentity.Identity() |
|
265 ).EndTagL( KUserIDXMLTag ); |
|
266 } |
|
267 |
|
268 serializer->StartTagL( KDefaultList ).NarrowTextL( KXMLValueFalse ).EndTagL( KDefaultList ); |
|
269 serializer->EndTagL( KCreateAttributeList ); |
|
270 |
|
271 serializer->EndTagL( KTransactionContent ); |
|
272 |
|
273 |
|
274 IMPS_DP( D_IMPS_LIT( "WithdrawPresenceGrantFromPresentityL" ) ); |
|
275 |
|
276 CleanupStack::PopAndDestroy(); //serializer |
|
277 |
|
278 iSendId = iConnMan.DataHandler().SendDataL( iStatus ); |
|
279 |
|
280 // signal the scheduler |
|
281 SetActive(); |
|
282 |
|
283 IMPS_DP( D_IMPS_LIT( "::WithdrawPresenceGrantFromPresentityL End" ) ); |
|
284 } |
|
285 |
|
286 // End of file |