|
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 "CGrantPresenceForPresentityRequest.h" |
|
21 #include "impsconnectionmanagercontrolif.h" |
|
22 #include "impsdebugprint.h" |
|
23 #include "CImpsPluginAccessHandler.h" |
|
24 #include "CImpsPluginPureDataHandler.h" |
|
25 #include <protocolpresenceauthorizationdatahost.h> |
|
26 |
|
27 #include <presenceinfo.h> |
|
28 #include "CPEngXMLParser.h" |
|
29 #include "MPEngXMLParser.h" |
|
30 #include "CPEngXmlSerializer.h" |
|
31 #include "MPEngXmlSerializer.h" |
|
32 #include "CImpsPluginConnectionManager.h" |
|
33 #include "PEngXMLTags.h" |
|
34 |
|
35 #include <ximpobjectfactory.h> |
|
36 #include <protocolpresencedatahost.h> |
|
37 #include <presenceobjectfactory.h> |
|
38 #include <ximpobjectcollection.h> |
|
39 #include <protocolpresentitygroupsdatahost.h> |
|
40 #include <presentitygroupinfo.h> |
|
41 #include <presentitygroupmemberinfo.h> |
|
42 #include <ximpidentity.h> |
|
43 #include <presenceinfofilter.h> |
|
44 #include <ximpdatasubscriptionstate.h> |
|
45 |
|
46 #include <presencegrantrequestinfo.h> |
|
47 #include "PImpsAdapXMLTools.h" |
|
48 |
|
49 |
|
50 // ======== MEMBER FUNCTIONS ======== |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CGrantPresenceForPresentityRequest::CGrantPresenceForPresentityRequest |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CGrantPresenceForPresentityRequest::CGrantPresenceForPresentityRequest( |
|
57 MImpsPrtPluginConnectionManager& aConnMan, |
|
58 TXIMPRequestId aRequestId ) : |
|
59 CActive( EPriorityNormal ), |
|
60 iRequestId( aRequestId ), |
|
61 iConnMan( aConnMan ) |
|
62 { |
|
63 IMPS_DP( D_IMPS_LIT( "::CGrantPresenceForPresentityRequest Start" ) ); |
|
64 CActiveScheduler::Add( this ); |
|
65 IMPS_DP( D_IMPS_LIT( "::CGrantPresenceForPresentityRequest End" ) ); |
|
66 } |
|
67 |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CGrantPresenceForPresentityRequest::ConstructL |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 void CGrantPresenceForPresentityRequest::ConstructL() |
|
74 { |
|
75 IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::ConstructL Start-End" ) ); |
|
76 |
|
77 iParser = CreateXMLParserL(); |
|
78 |
|
79 } |
|
80 |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CGrantPresenceForPresentityRequest::NewL |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 CGrantPresenceForPresentityRequest* CGrantPresenceForPresentityRequest::NewL( |
|
87 MImpsPrtPluginConnectionManager& aConnMan, |
|
88 TXIMPRequestId aRequestId ) |
|
89 { |
|
90 IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::NewL Start" ) ); |
|
91 |
|
92 CGrantPresenceForPresentityRequest* self = new( ELeave ) |
|
93 CGrantPresenceForPresentityRequest( aConnMan, aRequestId ); |
|
94 CleanupStack::PushL( self ); |
|
95 self->ConstructL(); |
|
96 CleanupStack::Pop( self ); |
|
97 |
|
98 IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::NewL End" ) ); |
|
99 return self; |
|
100 } |
|
101 |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CGrantPresenceForPresentityRequest::NewLC |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 CGrantPresenceForPresentityRequest* CGrantPresenceForPresentityRequest::NewLC( |
|
108 MImpsPrtPluginConnectionManager& aConnMan, |
|
109 TXIMPRequestId aRequestId ) |
|
110 { |
|
111 IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::NewLC Start" ) ); |
|
112 |
|
113 CGrantPresenceForPresentityRequest* self = |
|
114 CGrantPresenceForPresentityRequest::NewL( aConnMan, aRequestId ); |
|
115 CleanupStack::PushL( self ); |
|
116 |
|
117 |
|
118 IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::NewLC End" ) ); |
|
119 return self; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CGrantPresenceForPresentityRequest::~CGrantPresenceForPresentityRequest |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 CGrantPresenceForPresentityRequest::~CGrantPresenceForPresentityRequest() |
|
127 { |
|
128 IMPS_DP( D_IMPS_LIT( "::~CGrantPresenceForPresentityRequest Start" ) ); |
|
129 delete iResponse; |
|
130 CActive::Cancel(); |
|
131 iConnMan.Remove( this ); |
|
132 delete iParser; |
|
133 delete iGroupName; |
|
134 |
|
135 IMPS_DP( D_IMPS_LIT( "::~CGrantPresenceForPresentityRequest End" ) ); |
|
136 } |
|
137 |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CGrantPresenceForPresentityRequest::DoCancel() |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CGrantPresenceForPresentityRequest::DoCancel() |
|
144 { |
|
145 IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::DoCancel Start" ) ); |
|
146 |
|
147 iConnMan.DataHandler().CancelSending( iSendId ); |
|
148 |
|
149 IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::DoCancel End" ) ); |
|
150 } |
|
151 |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CGrantPresenceForPresentityRequest::RunL() |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void CGrantPresenceForPresentityRequest::RunL() |
|
158 { |
|
159 IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::RunL Start" ) ); |
|
160 |
|
161 User::LeaveIfError( iStatus.Int() ); |
|
162 |
|
163 iResponse = iConnMan.DataHandler().ResponseL( iSendId ); |
|
164 |
|
165 TPtrC8 resultBlock( NULL, 0 ); |
|
166 TInt wvErrorCode = KErrNone; |
|
167 |
|
168 // Check if we got 200 |
|
169 if ( iParser->DecodeL( *iResponse, KResultXMLTag, ETrue ) ) |
|
170 { |
|
171 resultBlock.Set( iParser->ResultL() ); |
|
172 if ( iParser->DecodeL( resultBlock, KCodeXMLTag, EFalse ) ) |
|
173 { |
|
174 TPtrC8 cspStatusCodeBlock( iParser->ResultL() ); |
|
175 TInt cspStatusInt; |
|
176 TLex8 lexer( cspStatusCodeBlock ); |
|
177 lexer.SkipSpace(); |
|
178 TInt lexErr = lexer.Val( cspStatusInt ); |
|
179 if ( lexErr == KErrNone ) |
|
180 { |
|
181 wvErrorCode = cspStatusInt; |
|
182 } |
|
183 } |
|
184 } |
|
185 |
|
186 MXIMPObjectFactory& prfwObjFact = iConnMan.HandleToHost().ObjectFactory(); |
|
187 MPresenceObjectFactory& prObjFact = |
|
188 iConnMan.HandleToHost().ProtocolPresenceDataHost().PresenceObjectFactory(); |
|
189 MXIMPIdentity* grantIdentity = prfwObjFact.NewIdentityLC(); |
|
190 grantIdentity->SetIdentityL( *iGroupName ); |
|
191 |
|
192 MPresenceGrantRequestInfo* grantInfo = prObjFact.NewPresenceGrantRequestInfoLC(); |
|
193 grantInfo->SetRequestorIdL( grantIdentity ); |
|
194 // we do not set the display name |
|
195 |
|
196 // issue the request to prfw |
|
197 iConnMan.HandleToHost().ProtocolPresenceDataHost().AuthorizationDataHost().HandlePresenceGrantRequestReceivedL( |
|
198 grantInfo ); |
|
199 |
|
200 CleanupStack::Pop( 1 ); // blockIdentity |
|
201 CleanupStack::Pop( 1 ); // blockInfo |
|
202 |
|
203 // make the data available to the clients |
|
204 |
|
205 MXIMPDataSubscriptionState* dataSubscriptionState = prfwObjFact.NewDataSubscriptionStateLC(); |
|
206 dataSubscriptionState->SetDataStateL( MXIMPDataSubscriptionState::EDataAvailable ); |
|
207 dataSubscriptionState->SetSubscriptionStateL( MXIMPDataSubscriptionState::ESubscriptionActive ); |
|
208 |
|
209 // change the state |
|
210 iConnMan.HandleToHost().ProtocolPresenceDataHost().AuthorizationDataHost().SetPresenceGrantRequestDataSubscriptionStateL( |
|
211 dataSubscriptionState, NULL ); |
|
212 |
|
213 CleanupStack::Pop( 1 ); // dataSubscriptionState |
|
214 |
|
215 IMPS_DP( D_IMPS_LIT( "GrantPresenceForPresentityRequest Return Code %d" ), wvErrorCode ); |
|
216 if ( wvErrorCode == KWVRequestResponseResultCode ) |
|
217 { |
|
218 wvErrorCode = KErrNone; |
|
219 } |
|
220 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, wvErrorCode ); |
|
221 |
|
222 delete this; |
|
223 IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::RunL End" ) ); |
|
224 } |
|
225 |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // CGrantPresenceForPresentityRequest::RunError |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 TInt CGrantPresenceForPresentityRequest::RunError( TInt aError ) |
|
232 { |
|
233 IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::RunError Start %d" ), aError ); |
|
234 |
|
235 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, aError ); |
|
236 |
|
237 delete this; |
|
238 IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::RunError End" ) ); |
|
239 return KErrNone; |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // CGrantPresenceForPresentityRequest::GrantPresenceForPresentityL |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void CGrantPresenceForPresentityRequest::GrantPresenceForPresentityL( |
|
247 const MXIMPIdentity& aPresentityId, |
|
248 const MPresenceInfoFilter& aPif ) |
|
249 { |
|
250 IMPS_DP( D_IMPS_LIT( "::GrantPresenceForPresentityL Start" ) ); |
|
251 |
|
252 IMPS_DP( D_IMPS_LIT( "------------------------------------------------------------------" ) ); |
|
253 |
|
254 IMPS_DP( D_IMPS_LIT( "---------------------Data from framework to presadap1.2-----------" ) ); |
|
255 |
|
256 IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::GrantPresenceForPresentityL:PresentityId:%S " ), &aPresentityId.Identity() ); |
|
257 |
|
258 // IMPS_DP( D_IMPS_LIT( "CGrantPresenceForPresentityRequest::GrantPresenceForPresentityL:PresenceInfoFilter:%S "),&aPif); |
|
259 |
|
260 TPtr8 ptrbuffer( iConnMan.DataHandler().TransferBufferL() ); |
|
261 MPEngXMLSerializer* serializer = CreateXmlSerializerLC( ptrbuffer ); |
|
262 |
|
263 iGroupName = aPresentityId.Identity().AllocL(); |
|
264 |
|
265 NImpsAdapXMLTools::AppendTransactionContentTagXmlL( *serializer, iConnMan.GetVersion() ); |
|
266 |
|
267 serializer->StartTagL( KCreateAttributeList ); |
|
268 serializer->StartTagL( KPresenceSubList ); |
|
269 serializer->AttributeL( KXmlXmlns, KPresenceSubListAttributesNS_CSP12 ); |
|
270 |
|
271 // fetch attributes from the pif and send it over to the server |
|
272 TBool statusmessage = aPif.MatchPersonFilter( NPresenceInfo::NFieldType::KStatusMessage ); |
|
273 TBool availability = aPif.MatchPersonFilter( NPresenceInfo::NFieldType::KAvailability ); |
|
274 TBool allattributes = aPif.MatchPersonFilter( NPresenceInfo::NFieldType::KAcceptAll ); |
|
275 |
|
276 if ( !allattributes ) |
|
277 { |
|
278 if ( statusmessage ) |
|
279 { |
|
280 serializer->StartTagL( KStatusMood ).EndTagL( KStatusMood ); |
|
281 serializer->StartTagL( KOnlineStatusXMLTag ).EndTagL( KOnlineStatusXMLTag ); |
|
282 serializer->StartTagL( KStatusTextXMLTag ).EndTagL( KStatusTextXMLTag ); |
|
283 serializer->StartTagL( KStatusContentXMLTag ).EndTagL( KStatusContentXMLTag ); |
|
284 } |
|
285 if ( availability ) |
|
286 { |
|
287 serializer->StartTagL( KUserAvailabilityXMLTag ).EndTagL( KUserAvailabilityXMLTag ); |
|
288 } |
|
289 } |
|
290 |
|
291 serializer->EndTagL( KPresenceSubList ); |
|
292 if ( KErrNone == iGroupName->Left( KPEngAttrWVIdPrefixLength ).CompareF( KPengWVIDPrefix ) ) |
|
293 { |
|
294 serializer->StartTagL( KUserIDXMLTag |
|
295 ).WvAddressL( aPresentityId.Identity() |
|
296 ).EndTagL( KUserIDXMLTag ); |
|
297 } |
|
298 else |
|
299 { |
|
300 serializer->StartTagL( KUserIDXMLTag |
|
301 ).NarrowTextL( KWVXMLTag |
|
302 ).WvAddressL( aPresentityId.Identity() |
|
303 ).EndTagL( KUserIDXMLTag ); |
|
304 } |
|
305 serializer->StartTagL( KDefaultList ).NarrowTextL( KXMLValueTrue ).EndTagL( KDefaultList ); |
|
306 serializer->EndTagL( KCreateAttributeList ); |
|
307 serializer->EndTagL( KTransactionContent ); |
|
308 |
|
309 IMPS_DP( D_IMPS_LIT( "GrantPresenceForPresentityL" ) ); |
|
310 |
|
311 CleanupStack::PopAndDestroy(); //serializer |
|
312 |
|
313 iSendId = iConnMan.DataHandler().SendDataL( iStatus ); |
|
314 |
|
315 // signal the scheduler |
|
316 SetActive(); |
|
317 |
|
318 IMPS_DP( D_IMPS_LIT( "::GrantPresenceForPresentityL End" ) ); |
|
319 } |
|
320 |
|
321 // End of file |