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