|
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: IMPS Protocol implementation for Presence Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ximpprotocolconnectionhost.h> |
|
20 #include "CUnsubscribePresentityPresenceRequest.h" |
|
21 #include "impsconnectionmanagercontrolif.h" |
|
22 #include "impsdebugprint.h" |
|
23 #include "CImpsPluginAccessHandler.h" |
|
24 #include "CImpsPluginPureDataHandler.h" |
|
25 |
|
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 "PImpsAdapXMLTools.h" |
|
41 |
|
42 |
|
43 |
|
44 // ======== MEMBER FUNCTIONS ======== |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CUnsubscribePresentityPresenceRequest::CUnsubscribePresentityPresenceRequest |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CUnsubscribePresentityPresenceRequest::CUnsubscribePresentityPresenceRequest( |
|
51 MImpsPrtPluginConnectionManager& aConnMan, |
|
52 TXIMPRequestId aRequestId ) : |
|
53 CActive( EPriorityNormal ), |
|
54 iRequestId( aRequestId ), |
|
55 iConnMan( aConnMan ) |
|
56 { |
|
57 IMPS_DP( D_IMPS_LIT( "::CUnsubscribePresentityPresenceRequest Start" ) ); |
|
58 |
|
59 CActiveScheduler::Add( this ); |
|
60 |
|
61 IMPS_DP( D_IMPS_LIT( "::CUnsubscribePresentityPresenceRequest End" ) ); |
|
62 } |
|
63 |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CUnsubscribePresentityPresenceRequest::ConstructL |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CUnsubscribePresentityPresenceRequest::ConstructL() |
|
70 { |
|
71 IMPS_DP( D_IMPS_LIT( "CUnsubscribePresentityPresenceRequest::ConstructL Start-End" ) ); |
|
72 |
|
73 iParser = CreateXMLParserL(); |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CUnsubscribePresentityPresenceRequest::NewL |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CUnsubscribePresentityPresenceRequest* CUnsubscribePresentityPresenceRequest::NewL( |
|
82 MImpsPrtPluginConnectionManager& aConnMan, |
|
83 TXIMPRequestId aRequestId ) |
|
84 { |
|
85 IMPS_DP( D_IMPS_LIT( "CUnsubscribePresentityPresenceRequest::NewL Start" ) ); |
|
86 |
|
87 CUnsubscribePresentityPresenceRequest* self = new( ELeave ) |
|
88 CUnsubscribePresentityPresenceRequest( aConnMan, aRequestId ); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop( self ); |
|
92 |
|
93 IMPS_DP( D_IMPS_LIT( "CUnsubscribePresentityPresenceRequest::NewL End" ) ); |
|
94 return self; |
|
95 } |
|
96 |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CUnsubscribePresentityPresenceRequest::NewLC |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 CUnsubscribePresentityPresenceRequest* CUnsubscribePresentityPresenceRequest::NewLC( |
|
103 MImpsPrtPluginConnectionManager& aConnMan, |
|
104 TXIMPRequestId aRequestId ) |
|
105 { |
|
106 IMPS_DP( D_IMPS_LIT( "CUnsubscribePresentityPresenceRequest::NewLC Start" ) ); |
|
107 |
|
108 CUnsubscribePresentityPresenceRequest* self = new( ELeave ) |
|
109 CUnsubscribePresentityPresenceRequest( aConnMan, aRequestId ); |
|
110 CleanupStack::PushL( self ); |
|
111 self->ConstructL(); |
|
112 |
|
113 IMPS_DP( D_IMPS_LIT( "CUnsubscribePresentityPresenceRequest::NewLC End" ) ); |
|
114 return self; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CUnsubscribePresentityPresenceRequest::~CUnsubscribePresentityPresenceRequest |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 CUnsubscribePresentityPresenceRequest::~CUnsubscribePresentityPresenceRequest() |
|
122 { |
|
123 IMPS_DP( D_IMPS_LIT( "::~CUnsubscribePresentityPresenceRequest Start" ) ); |
|
124 |
|
125 delete iResponse; |
|
126 CActive::Cancel(); |
|
127 iConnMan.Remove( this ); |
|
128 delete iParser; |
|
129 |
|
130 IMPS_DP( D_IMPS_LIT( "::~CUnsubscribePresentityPresenceRequest End" ) ); |
|
131 } |
|
132 |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CUnsubscribePresentityPresenceRequest::DoCancel() |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void CUnsubscribePresentityPresenceRequest::DoCancel() |
|
139 { |
|
140 IMPS_DP( D_IMPS_LIT( "CUnsubscribePresentityPresenceRequest::DoCancel Start" ) ); |
|
141 |
|
142 iConnMan.DataHandler().CancelSending( iSendId ); |
|
143 |
|
144 IMPS_DP( D_IMPS_LIT( "CUnsubscribePresentityPresenceRequest::DoCancel End" ) ); |
|
145 } |
|
146 |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // CUnsubscribePresentityPresenceRequest::RunL() |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 void CUnsubscribePresentityPresenceRequest::RunL() |
|
153 { |
|
154 IMPS_DP( D_IMPS_LIT( "CUnsubscribePresentityPresenceRequest::RunL Start" ) ); |
|
155 |
|
156 User::LeaveIfError( iStatus.Int() ); |
|
157 |
|
158 iResponse = iConnMan.DataHandler().ResponseL( iSendId ); |
|
159 |
|
160 TPtrC8 resultBlock( NULL, 0 ); |
|
161 TInt wvErrorCode = KErrNone; |
|
162 |
|
163 // Check if we got 200 |
|
164 if ( iParser->DecodeL( *iResponse, KResultXMLTag, ETrue ) ) |
|
165 { |
|
166 resultBlock.Set( iParser->ResultL() ); |
|
167 if ( iParser->DecodeL( resultBlock, KCodeXMLTag, EFalse ) ) |
|
168 { |
|
169 TPtrC8 cspStatusCodeBlock( iParser->ResultL() ); |
|
170 TInt cspStatusInt; |
|
171 TLex8 lexer( cspStatusCodeBlock ); |
|
172 lexer.SkipSpace(); |
|
173 TInt lexErr = lexer.Val( cspStatusInt ); |
|
174 if ( lexErr == KErrNone ) |
|
175 { |
|
176 wvErrorCode = cspStatusInt; |
|
177 } |
|
178 } |
|
179 } |
|
180 |
|
181 IMPS_DP( D_IMPS_LIT( " UnsubscribePresentityPresenceL wvErrorCode::%d" ), wvErrorCode ); |
|
182 |
|
183 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, wvErrorCode ); |
|
184 delete this; |
|
185 IMPS_DP( D_IMPS_LIT( "CUnsubscribePresentityPresenceRequest::RunL End" ) ); |
|
186 } |
|
187 |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CUnsubscribePresentityPresenceRequest::RunError |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 TInt CUnsubscribePresentityPresenceRequest::RunError( TInt aError ) |
|
194 { |
|
195 IMPS_DP( D_IMPS_LIT( "CUnsubscribePresentityPresenceRequest::RunError Start" ) ); |
|
196 |
|
197 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, aError ); |
|
198 |
|
199 delete this; |
|
200 IMPS_DP( D_IMPS_LIT( "CUnsubscribePresentityPresenceRequest::RunError End" ) ); |
|
201 return KErrNone; |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // CUnsubscribePresentityPresenceRequest::UnsubscribePresentityPresenceL |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 void CUnsubscribePresentityPresenceRequest::UnsubscribePresentityPresenceL( |
|
209 const MXIMPIdentity& aIdentity ) |
|
210 { |
|
211 IMPS_DP( D_IMPS_LIT( "::UnsubscribePresentityPresenceL Start" ) ); |
|
212 |
|
213 TPtr8 ptrbuffer( iConnMan.DataHandler().TransferBufferL() ); |
|
214 MPEngXMLSerializer* serializer = CreateXmlSerializerLC( ptrbuffer ); |
|
215 |
|
216 |
|
217 IMPS_DP( D_IMPS_LIT( "UnsubscribePresentityPresenceL Manufacture XML " ) ); |
|
218 |
|
219 //serializer->StartTagL(KTransactionContent); |
|
220 //serializer->AttributeL( KXmlXmlns, KTransactionContentNS_CSP12 ); |
|
221 NImpsAdapXMLTools::AppendTransactionContentTagXmlL( *serializer, iConnMan.GetVersion() ); |
|
222 |
|
223 serializer->StartTagL( KUnsubscribePresence ); |
|
224 |
|
225 // userId or contactlist Id or both are allowed |
|
226 serializer->StartTagL( KUserIDXMLTag |
|
227 ).NarrowTextL( KWVXMLTag |
|
228 ).WvAddressL( aIdentity.Identity() |
|
229 ).EndTagL( KUserIDXMLTag ); |
|
230 |
|
231 serializer->EndTagL( KUnsubscribePresence ); |
|
232 serializer->EndTagL( KTransactionContent ); |
|
233 |
|
234 CleanupStack::PopAndDestroy(); //serializer |
|
235 |
|
236 |
|
237 iSendId = iConnMan.DataHandler().SendDataL( iStatus ); |
|
238 |
|
239 IMPS_DP( D_IMPS_LIT( " SendData Request id %d " ), iSendId ); |
|
240 // signal the scheduler |
|
241 SetActive(); |
|
242 |
|
243 IMPS_DP( D_IMPS_LIT( "::UnsubscribePresentityPresenceL End" ) ); |
|
244 } |
|
245 |
|
246 // End of file |