|
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 "CUpdatePresenceGrantPifForEveryoneRequest.h" |
|
21 #include "impsconnectionmanagercontrolif.h" |
|
22 #include "impsdebugprint.h" |
|
23 #include "CImpsPluginAccessHandler.h" |
|
24 #include "CImpsPluginPureDataHandler.h" |
|
25 #include <presenceinfo.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 <ximpobjectcollection.h> |
|
36 #include <protocolpresentitygroupsdatahost.h> |
|
37 #include <presentitygroupinfo.h> |
|
38 #include <presentitygroupmemberinfo.h> |
|
39 #include <ximpidentity.h> |
|
40 #include <presenceinfofilter.h> |
|
41 |
|
42 #include "PImpsAdapXMLTools.h" |
|
43 |
|
44 |
|
45 // ======== MEMBER FUNCTIONS ======== |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CUpdatePresenceGrantPifForEveryoneRequest::CUpdatePresenceGrantPifForEveryoneRequest |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CUpdatePresenceGrantPifForEveryoneRequest::CUpdatePresenceGrantPifForEveryoneRequest( |
|
52 MImpsPrtPluginConnectionManager& aConnMan, |
|
53 TXIMPRequestId aRequestId ) : |
|
54 CActive( EPriorityNormal ), |
|
55 iRequestId( aRequestId ), |
|
56 iConnMan( aConnMan ) |
|
57 { |
|
58 IMPS_DP( D_IMPS_LIT( "::CUpdatePresenceGrantPifForEveryoneRequest Start" ) ); |
|
59 CActiveScheduler::Add( this ); |
|
60 IMPS_DP( D_IMPS_LIT( "::CUpdatePresenceGrantPifForEveryoneRequest End" ) ); |
|
61 } |
|
62 |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CUpdatePresenceGrantPifForEveryoneRequest::ConstructL |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CUpdatePresenceGrantPifForEveryoneRequest::ConstructL() |
|
69 { |
|
70 IMPS_DP( D_IMPS_LIT( "CUpdatePresenceGrantPifForEveryoneRequest::ConstructL Start-End" ) ); |
|
71 |
|
72 iParser = CreateXMLParserL(); |
|
73 |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CUpdatePresenceGrantPifForEveryoneRequest::NewL |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CUpdatePresenceGrantPifForEveryoneRequest* CUpdatePresenceGrantPifForEveryoneRequest::NewL( |
|
82 MImpsPrtPluginConnectionManager& aConnMan, |
|
83 TXIMPRequestId aRequestId ) |
|
84 { |
|
85 IMPS_DP( D_IMPS_LIT( "CUpdatePresenceGrantPifForEveryoneRequest::NewL Start" ) ); |
|
86 |
|
87 CUpdatePresenceGrantPifForEveryoneRequest* self = new( ELeave ) |
|
88 CUpdatePresenceGrantPifForEveryoneRequest( aConnMan, aRequestId ); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop( self ); |
|
92 |
|
93 IMPS_DP( D_IMPS_LIT( "CUpdatePresenceGrantPifForEveryoneRequest::NewL End" ) ); |
|
94 return self; |
|
95 } |
|
96 |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CUpdatePresenceGrantPifForEveryoneRequest::NewLC |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 CUpdatePresenceGrantPifForEveryoneRequest* CUpdatePresenceGrantPifForEveryoneRequest::NewLC( |
|
103 MImpsPrtPluginConnectionManager& aConnMan, |
|
104 TXIMPRequestId aRequestId ) |
|
105 { |
|
106 IMPS_DP( D_IMPS_LIT( "CUpdatePresenceGrantPifForEveryoneRequest::NewLC Start" ) ); |
|
107 |
|
108 CUpdatePresenceGrantPifForEveryoneRequest* self = |
|
109 CUpdatePresenceGrantPifForEveryoneRequest::NewL( aConnMan, aRequestId ); |
|
110 CleanupStack::PushL( self ); |
|
111 |
|
112 IMPS_DP( D_IMPS_LIT( "CUpdatePresenceGrantPifForEveryoneRequest::NewLC End" ) ); |
|
113 return self; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CUpdatePresenceGrantPifForEveryoneRequest::~CUpdatePresenceGrantPifForEveryoneRequest |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 CUpdatePresenceGrantPifForEveryoneRequest::~CUpdatePresenceGrantPifForEveryoneRequest() |
|
121 { |
|
122 IMPS_DP( D_IMPS_LIT( "::~CUpdatePresenceGrantPifForEveryoneRequest Start-End" ) ); |
|
123 delete iResponse; |
|
124 CActive::Cancel(); |
|
125 iConnMan.Remove( this ); |
|
126 delete iParser; |
|
127 delete iGroupName; |
|
128 delete iContactName; |
|
129 delete iUserId; |
|
130 } |
|
131 |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CUpdatePresenceGrantPifForEveryoneRequest::DoCancel() |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 void CUpdatePresenceGrantPifForEveryoneRequest::DoCancel() |
|
138 { |
|
139 IMPS_DP( D_IMPS_LIT( "CUpdatePresenceGrantPifForEveryoneRequest::DoCancel Start" ) ); |
|
140 |
|
141 iConnMan.DataHandler().CancelSending( iSendId ); |
|
142 |
|
143 IMPS_DP( D_IMPS_LIT( "CUpdatePresenceGrantPifForEveryoneRequest::DoCancel End" ) ); |
|
144 } |
|
145 |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // CUpdatePresenceGrantPifForEveryoneRequest::RunL() |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CUpdatePresenceGrantPifForEveryoneRequest::RunL() |
|
152 { |
|
153 IMPS_DP( D_IMPS_LIT( "CUpdatePresenceGrantPifForEveryoneRequest::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 // completet the group content request |
|
181 IMPS_DP( D_IMPS_LIT( "CUpdatePresenceGrantPifForEveryoneRequest Return Code %d" ), |
|
182 wvErrorCode ); |
|
183 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, wvErrorCode ); |
|
184 |
|
185 delete this; |
|
186 IMPS_DP( D_IMPS_LIT( "CUpdatePresenceGrantPifForEveryoneRequest::RunL End" ) ); |
|
187 } |
|
188 |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CUpdatePresenceGrantPifForEveryoneRequest::RunError |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 TInt CUpdatePresenceGrantPifForEveryoneRequest::RunError( TInt aError ) |
|
195 { |
|
196 IMPS_DP( D_IMPS_LIT( "CUpdatePresenceGrantPifForEveryoneRequest::RunError Start" ) ); |
|
197 |
|
198 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, aError ); |
|
199 |
|
200 delete this; |
|
201 IMPS_DP( D_IMPS_LIT( "CUpdatePresenceGrantPifForEveryoneRequest::RunError End" ) ); |
|
202 return KErrNone; |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CUpdatePresenceGrantPifForEveryoneRequest::UpdatePresenceGrantPifForEveryoneL |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 void CUpdatePresenceGrantPifForEveryoneRequest::UpdatePresenceGrantPifForEveryoneL( |
|
210 const MPresenceInfoFilter& aPif ) |
|
211 { |
|
212 IMPS_DP( D_IMPS_LIT( "::UpdatePresenceGrantPifForEveryoneL 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( "CUpdatePresenceGrantPifForEveryoneRequest::UpdatePresenceGrantPifForEveryoneL:PresenceInfoFilter:%S " ), &aPif ); |
|
219 |
|
220 TPtr8 ptrbuffer( iConnMan.DataHandler().TransferBufferL() ); |
|
221 MPEngXMLSerializer* serializer = CreateXmlSerializerLC( ptrbuffer ); |
|
222 |
|
223 NImpsAdapXMLTools::AppendTransactionContentTagXmlL( *serializer, iConnMan.GetVersion() ); |
|
224 |
|
225 serializer->StartTagL( KCreateAttributeList ); |
|
226 serializer->StartTagL( KPresenceSubList ); |
|
227 serializer->AttributeL( KXmlXmlns, KPresenceSubListAttributesNS_CSP12 ); |
|
228 |
|
229 // fetch attributes from the pif and send it over to the server |
|
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 // empty list so that all attributes |
|
249 serializer->EndTagL( KPresenceSubList ); |
|
250 |
|
251 serializer->StartTagL( KDefaultList ).NarrowTextL( KXMLValueTrue ).EndTagL( KDefaultList ); |
|
252 serializer->EndTagL( KCreateAttributeList ); |
|
253 serializer->EndTagL( KTransactionContent ); |
|
254 |
|
255 |
|
256 |
|
257 IMPS_DP( D_IMPS_LIT( "UpdatePresenceGrantPifForEveryoneL" ) ); |
|
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( "::UpdatePresenceGrantPifForEveryoneL End" ) ); |
|
267 } |
|
268 |
|
269 // End of file |