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