|
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 "CSubscribeOwnPresenceNotificationRequest.h" |
|
21 #include "impsconnectionmanagercontrolif.h" |
|
22 #include "impsdebugprint.h" |
|
23 #include "CImpsPluginAccessHandler.h" |
|
24 #include "CImpsPluginPureDataHandler.h" |
|
25 #include "impsplugintags.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 <protocolpresencepublishingdatahost.h> |
|
41 |
|
42 |
|
43 #include <personpresenceinfo.h> |
|
44 #include <servicepresenceinfo.h> |
|
45 #include <devicepresenceinfo.h> |
|
46 #include <presenceinfo.h> |
|
47 |
|
48 |
|
49 |
|
50 // ======== MEMBER FUNCTIONS ======== |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CSubscribeOwnPresenceNotificationRequest::CSubscribeOwnPresenceNotificationRequest |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CSubscribeOwnPresenceNotificationRequest::CSubscribeOwnPresenceNotificationRequest( |
|
57 MImpsPrtPluginConnectionManager& aConnMan, |
|
58 TXIMPRequestId aRequestId ) : |
|
59 CActive( EPriorityNormal ), |
|
60 iRequestId( aRequestId ), |
|
61 iConnMan( aConnMan ) |
|
62 { |
|
63 IMPS_DP( D_IMPS_LIT( "::CSubscribeOwnPresenceNotificationRequest Start" ) ); |
|
64 CActiveScheduler::Add( this ); |
|
65 |
|
66 IMPS_DP( D_IMPS_LIT( "::CSubscribeOwnPresenceNotificationRequest End" ) ); |
|
67 } |
|
68 |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CSubscribeOwnPresenceNotificationRequest::ConstructL |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 void CSubscribeOwnPresenceNotificationRequest::ConstructL() |
|
75 { |
|
76 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::ConstructL Start-End" ) ); |
|
77 |
|
78 iParser = CreateXMLParserL(); |
|
79 |
|
80 } |
|
81 |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CSubscribeOwnPresenceNotificationRequest::NewL |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 CSubscribeOwnPresenceNotificationRequest* CSubscribeOwnPresenceNotificationRequest::NewL( |
|
88 MImpsPrtPluginConnectionManager& aConnMan, |
|
89 TXIMPRequestId aRequestId ) |
|
90 { |
|
91 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::NewL Start" ) ); |
|
92 |
|
93 CSubscribeOwnPresenceNotificationRequest* self = new( ELeave ) |
|
94 CSubscribeOwnPresenceNotificationRequest( aConnMan, aRequestId ); |
|
95 CleanupStack::PushL( self ); |
|
96 self->ConstructL(); |
|
97 CleanupStack::Pop( self ); |
|
98 |
|
99 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::NewL End" ) ); |
|
100 return self; |
|
101 } |
|
102 |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CSubscribeOwnPresenceNotificationRequest::NewLC |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 CSubscribeOwnPresenceNotificationRequest* CSubscribeOwnPresenceNotificationRequest::NewLC( |
|
109 MImpsPrtPluginConnectionManager& aConnMan, |
|
110 TXIMPRequestId aRequestId ) |
|
111 { |
|
112 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::NewLC Start" ) ); |
|
113 |
|
114 CSubscribeOwnPresenceNotificationRequest* self = |
|
115 CSubscribeOwnPresenceNotificationRequest::NewL( aConnMan, aRequestId ); |
|
116 CleanupStack::PushL( self ); |
|
117 |
|
118 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::NewLC End" ) ); |
|
119 return self; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CSubscribeOwnPresenceNotificationRequest::~CSubscribeOwnPresenceNotificationRequest |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 CSubscribeOwnPresenceNotificationRequest::~CSubscribeOwnPresenceNotificationRequest() |
|
127 { |
|
128 IMPS_DP( D_IMPS_LIT( "::~CSubscribeOwnPresenceNotificationRequest Start" ) ); |
|
129 |
|
130 delete iResponse; |
|
131 delete iListId; |
|
132 Cancel(); |
|
133 delete iParser; |
|
134 |
|
135 IMPS_DP( D_IMPS_LIT( "::~CSubscribeOwnPresenceNotificationRequest End" ) ); |
|
136 } |
|
137 |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CSubscribeOwnPresenceNotificationRequest::DoCancel() |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CSubscribeOwnPresenceNotificationRequest::DoCancel() |
|
144 { |
|
145 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::DoCancel Start" ) ); |
|
146 |
|
147 iConnMan.DataHandler().CancelListening(); |
|
148 |
|
149 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::DoCancel End" ) ); |
|
150 } |
|
151 |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CSubscribeOwnPresenceNotificationRequest::RunL() |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void CSubscribeOwnPresenceNotificationRequest::RunL() |
|
158 { |
|
159 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::RunL Start" ) ); |
|
160 |
|
161 User::LeaveIfError( iStatus.Int() ); |
|
162 |
|
163 // get the incoming response from the server with transaction id equals zero |
|
164 iResponse = iConnMan.DataHandler().ResponseL( 0 ); |
|
165 |
|
166 // Check if we got Notification Request |
|
167 if ( iParser->DecodeL( *iResponse, KPresenceNotificationRequest, ETrue ) ) |
|
168 { |
|
169 IMPS_DP( D_IMPS_LIT( " Got Notification Request From Server" ) ); |
|
170 } |
|
171 |
|
172 if ( iParser->DecodeL( *iResponse, KPresenceXMLTag, EFalse ) ) |
|
173 { |
|
174 |
|
175 TInt countResults( iParser->Count() ); |
|
176 IMPS_DP( D_IMPS_LIT( " Got Presence Tag %d" ), countResults ); |
|
177 } |
|
178 // is user tag present in the result? |
|
179 if ( iParser->DecodeL( *iResponse, KUserTag, EFalse ) ) |
|
180 { |
|
181 IMPS_DP( D_IMPS_LIT( " Got UserID Tag " ) ); |
|
182 } |
|
183 |
|
184 // is PresenceSubList tag present in the result? |
|
185 if ( iParser->DecodeL( *iResponse, KPresenceSubList, EFalse ) ) |
|
186 { |
|
187 IMPS_DP( D_IMPS_LIT( " Got PresenceSubList Tag " ) ); |
|
188 } |
|
189 |
|
190 // is PresenceSubList tag present in the result? |
|
191 if ( iParser->DecodeL( *iResponse, KOnlineStatusXMLTag, EFalse ) ) |
|
192 { |
|
193 IMPS_DP( D_IMPS_LIT( " Got KOnlineStatusXMLTag Tag " ) ); |
|
194 } |
|
195 |
|
196 |
|
197 // is PresenceSubList tag present in the result? |
|
198 if ( iParser->DecodeL( *iResponse, KRegistrationXMLTag, EFalse ) ) |
|
199 { |
|
200 IMPS_DP( D_IMPS_LIT( " Got KOnlineStatusXMLTag Tag " ) ); |
|
201 } |
|
202 |
|
203 |
|
204 // is KClientInfoXMLTag tag present in the result? |
|
205 if ( iParser->DecodeL( *iResponse, KClientInfoXMLTag, EFalse ) ) |
|
206 { |
|
207 IMPS_DP( D_IMPS_LIT( " Got KClientInfoXMLTag Tag " ) ); |
|
208 } |
|
209 |
|
210 // is KClientInfoXMLTag tag present in the result? |
|
211 if ( iParser->DecodeL( *iResponse, KTimeZoneXMLTag, EFalse ) ) |
|
212 { |
|
213 IMPS_DP( D_IMPS_LIT( " Got KClientInfoXMLTag Tag " ) ); |
|
214 } |
|
215 |
|
216 // is KClientInfoXMLTag tag present in the result? |
|
217 if ( iParser->DecodeL( *iResponse, KGeoLocationXMLTag, EFalse ) ) |
|
218 { |
|
219 IMPS_DP( D_IMPS_LIT( " Got KClientInfoXMLTag Tag " ) ); |
|
220 } |
|
221 |
|
222 // is KClientInfoXMLTag tag present in the result? |
|
223 if ( iParser->DecodeL( *iResponse, KClientInfoXMLTag, EFalse ) ) |
|
224 { |
|
225 IMPS_DP( D_IMPS_LIT( " Got KClientInfoXMLTag Tag " ) ); |
|
226 } |
|
227 |
|
228 // is KClientInfoXMLTag tag present in the result? |
|
229 if ( iParser->DecodeL( *iResponse, KClientInfoXMLTag, EFalse ) ) |
|
230 { |
|
231 IMPS_DP( D_IMPS_LIT( " Got KClientInfoXMLTag Tag " ) ); |
|
232 } |
|
233 |
|
234 // is KClientInfoXMLTag tag present in the result? |
|
235 if ( iParser->DecodeL( *iResponse, KClientInfoXMLTag, EFalse ) ) |
|
236 { |
|
237 IMPS_DP( D_IMPS_LIT( " Got KClientInfoXMLTag Tag " ) ); |
|
238 } |
|
239 |
|
240 // is KClientInfoXMLTag tag present in the result? |
|
241 if ( iParser->DecodeL( *iResponse, KClientInfoXMLTag, EFalse ) ) |
|
242 { |
|
243 IMPS_DP( D_IMPS_LIT( " Got KClientInfoXMLTag Tag " ) ); |
|
244 } |
|
245 |
|
246 // is KClientInfoXMLTag tag present in the result? |
|
247 if ( iParser->DecodeL( *iResponse, KClientInfoXMLTag, EFalse ) ) |
|
248 { |
|
249 IMPS_DP( D_IMPS_LIT( " Got KClientInfoXMLTag Tag " ) ); |
|
250 } |
|
251 |
|
252 // is KClientInfoXMLTag tag present in the result? |
|
253 if ( iParser->DecodeL( *iResponse, KClientInfoXMLTag, EFalse ) ) |
|
254 { |
|
255 IMPS_DP( D_IMPS_LIT( " Got KClientInfoXMLTag Tag " ) ); |
|
256 } |
|
257 |
|
258 iConnMan.DataHandler().ListenIncomingData( iStatus ); |
|
259 |
|
260 //delete this; |
|
261 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::RunL End" ) ); |
|
262 } |
|
263 |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // CSubscribeOwnPresenceNotificationRequest::RunError |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 TInt CSubscribeOwnPresenceNotificationRequest::RunError( TInt aError ) |
|
270 { |
|
271 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::RunError Start" ) ); |
|
272 |
|
273 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, aError ); |
|
274 |
|
275 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::RunError End" ) ); |
|
276 return KErrNone; |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // CSubscribeOwnPresenceNotificationRequest::MakeSubscribeOwnPresenceNotificationActiveL |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 void CSubscribeOwnPresenceNotificationRequest::MakeSubscribeOwnPresenceNotificationActiveL() |
|
284 { |
|
285 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::MakeSubscribeOwnPresenceNotificationActiveL Start" ) ); |
|
286 |
|
287 // Ready to receive notification from the server |
|
288 |
|
289 // signal the scheduler |
|
290 TInt count( iConnMan.DataHandler().ListenIncomingData( iStatus ) ); |
|
291 SetActive(); |
|
292 |
|
293 for ( TInt x( 0 ) ; x < count ; ++x ) |
|
294 { |
|
295 HandleIncomingDataL(); |
|
296 } |
|
297 |
|
298 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::MakeSubscribeOwnPresenceNotificationActiveL End" ) ); |
|
299 } |
|
300 |
|
301 // --------------------------------------------------------------------------- |
|
302 // CSubscribeOwnPresenceNotificationRequest::HandleIncomingDataL |
|
303 // --------------------------------------------------------------------------- |
|
304 // |
|
305 void CSubscribeOwnPresenceNotificationRequest::HandleIncomingDataL() |
|
306 { |
|
307 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::HandleIncomingDataL Start" ) ); |
|
308 |
|
309 // first get new data from the pure data handler |
|
310 HBufC8* newData; |
|
311 newData = iConnMan.DataHandler().ResponseL( 0 ); // zero is incoming Data |
|
312 if ( !newData ) |
|
313 { |
|
314 MakeSubscribeOwnPresenceNotificationActiveL(); |
|
315 return; |
|
316 } |
|
317 CleanupStack::PushL( newData ); |
|
318 // do some processing here |
|
319 RunL(); |
|
320 CleanupStack::PopAndDestroy(); // newData |
|
321 |
|
322 IMPS_DP( D_IMPS_LIT( "CSubscribeOwnPresenceNotificationRequest::HandleIncomingDataL End" ) ); |
|
323 } |
|
324 |
|
325 // End of file |