|
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 "CCancelPresenceBlockFromPresentityRequest.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 |
|
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 <ximpdatasubscriptionstate.h> |
|
41 #include "PImpsAdapXMLTools.h" |
|
42 |
|
43 |
|
44 // ======== MEMBER FUNCTIONS ======== |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CCancelPresenceBlockFromPresentityRequest::CCancelPresenceBlockFromPresentityRequest |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CCancelPresenceBlockFromPresentityRequest::CCancelPresenceBlockFromPresentityRequest( |
|
51 MImpsPrtPluginConnectionManager& aConnMan, |
|
52 TXIMPRequestId aRequestId ) : |
|
53 CActive( EPriorityNormal ), |
|
54 iRequestId( aRequestId ), |
|
55 iConnMan( aConnMan ) |
|
56 { |
|
57 IMPS_DP( D_IMPS_LIT( "::CCancelPresenceBlockFromPresentityRequest Start" ) ); |
|
58 CActiveScheduler::Add( this ); |
|
59 IMPS_DP( D_IMPS_LIT( "::CCancelPresenceBlockFromPresentityRequest End" ) ); |
|
60 } |
|
61 |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CCancelPresenceBlockFromPresentityRequest::ConstructL |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CCancelPresenceBlockFromPresentityRequest::ConstructL() |
|
68 { |
|
69 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest::ConstructL Start-End" ) ); |
|
70 |
|
71 iParser = CreateXMLParserL(); |
|
72 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest::ConstructL End" ) ); |
|
73 } |
|
74 |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CCancelPresenceBlockFromPresentityRequest::NewL |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 CCancelPresenceBlockFromPresentityRequest* CCancelPresenceBlockFromPresentityRequest::NewL( |
|
81 MImpsPrtPluginConnectionManager& aConnMan, |
|
82 TXIMPRequestId aRequestId ) |
|
83 { |
|
84 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest::NewL Start" ) ); |
|
85 |
|
86 CCancelPresenceBlockFromPresentityRequest* self = new( ELeave ) |
|
87 CCancelPresenceBlockFromPresentityRequest( aConnMan, aRequestId ); |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL(); |
|
90 CleanupStack::Pop( self ); |
|
91 |
|
92 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest::NewL End" ) ); |
|
93 return self; |
|
94 } |
|
95 |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CCancelPresenceBlockFromPresentityRequest::NewLC |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 CCancelPresenceBlockFromPresentityRequest* CCancelPresenceBlockFromPresentityRequest::NewLC( |
|
102 MImpsPrtPluginConnectionManager& aConnMan, |
|
103 TXIMPRequestId aRequestId ) |
|
104 { |
|
105 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest::NewLC Start" ) ); |
|
106 |
|
107 CCancelPresenceBlockFromPresentityRequest* self = CCancelPresenceBlockFromPresentityRequest::NewL( aConnMan, aRequestId ); |
|
108 CleanupStack::PushL( self ); |
|
109 |
|
110 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest::NewLC End" ) ); |
|
111 return self; |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // CCancelPresenceBlockFromPresentityRequest::~CCancelPresenceBlockFromPresentityRequest |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 CCancelPresenceBlockFromPresentityRequest::~CCancelPresenceBlockFromPresentityRequest() |
|
119 { |
|
120 IMPS_DP( D_IMPS_LIT( "::~CCancelPresenceBlockFromPresentityRequest Start" ) ); |
|
121 delete iResponse; |
|
122 CActive::Cancel(); |
|
123 iConnMan.Remove( this ); |
|
124 delete iParser; |
|
125 delete iGroupName; |
|
126 |
|
127 IMPS_DP( D_IMPS_LIT( "::~CCancelPresenceBlockFromPresentityRequest End" ) ); |
|
128 } |
|
129 |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CCancelPresenceBlockFromPresentityRequest::DoCancel() |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CCancelPresenceBlockFromPresentityRequest::DoCancel() |
|
136 { |
|
137 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest::DoCancel Start" ) ); |
|
138 |
|
139 iConnMan.DataHandler().CancelSending( iSendId ); |
|
140 |
|
141 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest::DoCancel End" ) ); |
|
142 } |
|
143 |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // CCancelPresenceBlockFromPresentityRequest::RunL() |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 void CCancelPresenceBlockFromPresentityRequest::RunL() |
|
150 { |
|
151 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest::RunL Start" ) ); |
|
152 |
|
153 User::LeaveIfError( iStatus.Int() ); |
|
154 |
|
155 iResponse = iConnMan.DataHandler().ResponseL( iSendId ); |
|
156 |
|
157 TPtrC8 resultBlock( NULL, 0 ); |
|
158 TInt wvErrorCode = KErrNone; |
|
159 |
|
160 // Check if we got 200 |
|
161 if ( iParser->DecodeL( *iResponse, KResultXMLTag, ETrue ) ) |
|
162 { |
|
163 resultBlock.Set( iParser->ResultL() ); |
|
164 if ( iParser->DecodeL( resultBlock, KCodeXMLTag, EFalse ) ) |
|
165 { |
|
166 TPtrC8 cspStatusCodeBlock( iParser->ResultL() ); |
|
167 TInt cspStatusInt; |
|
168 TLex8 lexer( cspStatusCodeBlock ); |
|
169 lexer.SkipSpace(); |
|
170 TInt lexErr = lexer.Val( cspStatusInt ); |
|
171 if ( lexErr == KErrNone ) |
|
172 { |
|
173 wvErrorCode = cspStatusInt; |
|
174 } |
|
175 } |
|
176 } |
|
177 // update data cache |
|
178 if ( wvErrorCode == KWVRequestResponseResultCode ) |
|
179 { |
|
180 wvErrorCode = KErrNone; |
|
181 } |
|
182 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest Return Code %d" ), wvErrorCode ); |
|
183 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, wvErrorCode ); |
|
184 |
|
185 delete this; |
|
186 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest::RunL End" ) ); |
|
187 } |
|
188 |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CCancelPresenceBlockFromPresentityRequest::RunError |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 TInt CCancelPresenceBlockFromPresentityRequest::RunError( TInt aError ) |
|
195 { |
|
196 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest::RunError Start" ) ); |
|
197 |
|
198 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, aError ); |
|
199 |
|
200 delete this; |
|
201 IMPS_DP( D_IMPS_LIT( "CCancelPresenceBlockFromPresentityRequest::RunError End" ) ); |
|
202 return KErrNone; |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CCancelPresenceBlockFromPresentityRequest::CancelPresenceBlockFromPresentityL |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 void CCancelPresenceBlockFromPresentityRequest::CancelPresenceBlockFromPresentityL( |
|
210 const MXIMPIdentity& aPresentityId ) |
|
211 { |
|
212 IMPS_DP( D_IMPS_LIT( "::CancelPresenceBlockFromPresentityL 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( "CCancelPresenceBlockFromPresentityRequest::CancelPresenceBlockFromPresentityL:PresentityId:%S " ), &aPresentityId.Identity() ); |
|
219 |
|
220 TPtr8 ptrbuffer( iConnMan.DataHandler().TransferBufferL() ); |
|
221 MPEngXMLSerializer* serializer = CreateXmlSerializerLC( ptrbuffer ); |
|
222 |
|
223 iGroupName = aPresentityId.Identity().AllocL(); |
|
224 |
|
225 NImpsAdapXMLTools::AppendTransactionContentTagXmlL( *serializer, iConnMan.GetVersion() ); |
|
226 |
|
227 serializer->StartTagL( KCreateAttributeList ); |
|
228 |
|
229 serializer->StartTagL( KPresenceSubList ); |
|
230 serializer->AttributeL( KXmlXmlns, KPresenceSubListAttributesNS_CSP12 ); |
|
231 serializer->StartTagL( KUserAvailabilityXMLTag ).EndTagL( KUserAvailabilityXMLTag ); |
|
232 serializer->StartTagL( KStatusMood ).EndTagL( KStatusMood ); |
|
233 serializer->StartTagL( KOnlineStatusXMLTag ).EndTagL( KOnlineStatusXMLTag ); |
|
234 serializer->StartTagL( KStatusTextXMLTag ).EndTagL( KStatusTextXMLTag ); |
|
235 serializer->StartTagL( KStatusContentXMLTag ).EndTagL( KStatusContentXMLTag ); |
|
236 serializer->EndTagL( KPresenceSubList ); |
|
237 |
|
238 // UserID does not have wv: tag |
|
239 serializer->StartTagL( KUserIDXMLTag |
|
240 //).NarrowTextL(KWVXMLTag |
|
241 ).WvAddressL( aPresentityId.Identity() |
|
242 ).EndTagL( KUserIDXMLTag ); |
|
243 |
|
244 serializer->StartTagL( KDefaultList ).NarrowTextL( KXMLValueFalse ).EndTagL( KDefaultList ); |
|
245 serializer->EndTagL( KCreateAttributeList ); |
|
246 serializer->EndTagL( KTransactionContent ); |
|
247 |
|
248 IMPS_DP( D_IMPS_LIT( "CancelPresenceBlockFromPresentityL Before SendData" ) ); |
|
249 |
|
250 CleanupStack::PopAndDestroy(); //serializer |
|
251 |
|
252 iSendId = iConnMan.DataHandler().SendDataL( iStatus ); |
|
253 |
|
254 // signal the scheduler |
|
255 SetActive(); |
|
256 |
|
257 IMPS_DP( D_IMPS_LIT( "::CancelPresenceBlockFromPresentityL End" ) ); |
|
258 } |
|
259 |
|
260 // End of file |