|
1 /* |
|
2 * Copyright (c) 2002-2010 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CSCPPRESENCEHANDLER_H |
|
20 #define C_CSCPPRESENCEHANDLER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <ximpbase.h> |
|
24 #include <ximpcontextobserver.h> |
|
25 #include <ximpcontextstate.h> |
|
26 #include <spdefinitions.h> |
|
27 |
|
28 #include "scpservicehandlerbase.h" |
|
29 #include "scpsubserviceobserver.h" |
|
30 |
|
31 class CScpSubService; |
|
32 class CScpSubService; |
|
33 class CScpServiceStorage; |
|
34 class MPresenceInfo; |
|
35 class MXIMPContext; |
|
36 class MXIMPClient; |
|
37 class MPresenceFeatures; |
|
38 class TScpReqId; |
|
39 |
|
40 /** |
|
41 * Presence sub service handler. |
|
42 * |
|
43 * @lib sipconnectionprovider.dll |
|
44 */ |
|
45 class CScpPresenceHandler : public CScpServiceHandlerBase, |
|
46 public MXIMPContextObserver, |
|
47 public MScpSubServiceObserver |
|
48 |
|
49 { |
|
50 |
|
51 public: |
|
52 /** |
|
53 * Enumeration for presence states |
|
54 */ |
|
55 enum TScpPresenceState |
|
56 { |
|
57 EBinding = 0, |
|
58 EBindComplete, /* Bind complete, publish not yet requested */ |
|
59 EPublishing, |
|
60 ESubscribing, |
|
61 EPresenceOnline, /* Bind, publish and subscribe complete -> presence online */ |
|
62 EPresenceOffline, /* Bind complete, presence offline */ |
|
63 EUnBinding, |
|
64 ENoBind |
|
65 }; |
|
66 |
|
67 public: |
|
68 |
|
69 /** |
|
70 * Two-phased constructor |
|
71 * @param aSubService The presence subservice |
|
72 */ |
|
73 static CScpPresenceHandler* NewL( CScpSubService& aSubService ); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 */ |
|
78 virtual ~CScpPresenceHandler(); |
|
79 |
|
80 /** |
|
81 * Update XDM settings access point. |
|
82 * XDM AP should be the same as SIP profile. |
|
83 */ |
|
84 void UpdateXdmSettingsL(); |
|
85 |
|
86 public: // From CScpServiceHandlerBase |
|
87 |
|
88 /** |
|
89 * Enables service. |
|
90 */ |
|
91 void EnableSubServiceL(); |
|
92 |
|
93 /** |
|
94 * Disables service. |
|
95 * @return Symbian error code |
|
96 */ |
|
97 TInt DisableSubService(); |
|
98 |
|
99 /** |
|
100 * Returns type of sub service (VoIP, Vmbx, Presence). |
|
101 * @return Type of the sub service. |
|
102 */ |
|
103 TCCHSubserviceType SubServiceType() const; |
|
104 |
|
105 /** |
|
106 * Handles sip connection event |
|
107 * @param aProfileId Sip profile id |
|
108 * @param aSipEvent Connection event |
|
109 */ |
|
110 void HandleSipConnectionEvent( const TUint32 aProfileId, |
|
111 TScpConnectionEvent aSipEvent ); |
|
112 |
|
113 /** |
|
114 * Query is starting to ALR allowed. |
|
115 * Client can start ALR later if needed to do something first |
|
116 * |
|
117 * @return ETrue if allowed. |
|
118 */ |
|
119 TBool IsSipProfileAllowedToStartAlr(); |
|
120 |
|
121 public: // From MScpSubServiceObserver |
|
122 /** |
|
123 * Handle SubService state change. |
|
124 * This function is for observing VoIP subservice. |
|
125 * If VoIP subservice connection is not OK, |
|
126 * set presence state to offline. |
|
127 * @param aState subservice connection state |
|
128 * @param aError is the error of the service |
|
129 */ |
|
130 void HandleSubServiceChange( TCCHSubserviceState aState, TInt aError ); |
|
131 |
|
132 |
|
133 public: // From MXIMPContextObserver |
|
134 |
|
135 /** |
|
136 * Handles presence context events. |
|
137 * @param aContext |
|
138 * @param aEvent Event |
|
139 */ |
|
140 void HandlePresenceContextEvent( const MXIMPContext& aContext, |
|
141 const MXIMPBase& aEvent ); |
|
142 |
|
143 private: |
|
144 |
|
145 /** |
|
146 * C++ default constructor. |
|
147 * @param aSubService The presence subservice |
|
148 */ |
|
149 CScpPresenceHandler( CScpSubService& aSubService ); |
|
150 |
|
151 /** |
|
152 * Symbian second phase constructor. |
|
153 */ |
|
154 void ConstructL(); |
|
155 |
|
156 /** |
|
157 * Binds SCP's presence context. |
|
158 */ |
|
159 void ServerBindL(); |
|
160 |
|
161 /** |
|
162 * Unbinds SCP's presence context. |
|
163 */ |
|
164 void ServerUnBindL(); |
|
165 |
|
166 /** |
|
167 * Stops publishing according to parameter and unbinds the presence |
|
168 * context. Leaves, if there are ongoing requests and publish offline |
|
169 * is not called. |
|
170 * @param aDoStopPublish if ETrue, users own presence status is |
|
171 * removed from presence server before unbinding the context |
|
172 */ |
|
173 void HandleDeregistrationL( TBool aDoStopPublish ); |
|
174 |
|
175 /** |
|
176 * Publishes presence according to given parameter. |
|
177 * @param aPublishOnline If ETrue, publish Online, if EFalse, |
|
178 * publish Offline |
|
179 */ |
|
180 void PublishPresenceL( TBool aPublishOnline ); |
|
181 |
|
182 /** |
|
183 * Creates presence info item |
|
184 * @param aState presence state |
|
185 * @return The created presence info pointer |
|
186 */ |
|
187 MPresenceInfo* CreateInfoLC( TBool aState ); |
|
188 |
|
189 /** |
|
190 * Changes service state to deregistered. If user requested |
|
191 * disabling the service, also profile deregistration is done. |
|
192 */ |
|
193 void DeregisterNow(); |
|
194 |
|
195 /** |
|
196 * Get property id. |
|
197 * @param aProperty, presence service property name |
|
198 * @param aValue, the id as a result of the query |
|
199 */ |
|
200 void GetPresencePropertyIdL( TServicePropertyName aProperty, TInt& aValue ) const; |
|
201 |
|
202 /** |
|
203 * Force service disable |
|
204 * @param aSelf This object |
|
205 * @return 1 |
|
206 */ |
|
207 static TInt ForcePresenceServiceDisable( TAny* aSelf ); |
|
208 |
|
209 /** |
|
210 * Find VoIP subservice pointer |
|
211 * @return VoIP subservice pointer |
|
212 */ |
|
213 CScpSubService* GetVoipSubService(); |
|
214 |
|
215 /** |
|
216 * Handles the XIMP context state events. |
|
217 * @param aEvent The XIMP event to handle |
|
218 */ |
|
219 void HandleContextStateEvent( const MXIMPBase& aEvent ); |
|
220 |
|
221 /** |
|
222 * Handles the XIMP request complete events |
|
223 * @param aEvent The XIMP event to handle |
|
224 */ |
|
225 void HandleRequestCompleteEvent( const MXIMPBase& aEvent ); |
|
226 |
|
227 /** |
|
228 * Handles the Bind complete event |
|
229 */ |
|
230 void HandleBindCompleteEvent(); |
|
231 |
|
232 /** |
|
233 * Subscribe presentity group |
|
234 */ |
|
235 void SubscribePresentityGroupL(); |
|
236 |
|
237 /** |
|
238 * Unsubscribe presentity group |
|
239 */ |
|
240 void UnsubscribePresentityGroupL(); |
|
241 |
|
242 /** |
|
243 * Gets stored presence values if available |
|
244 * @param aAvailabilityEnum Holds stored availability value |
|
245 * @param aCustomMessage Holds stored custom message |
|
246 */ |
|
247 void GetStoredPresenceValuesL( TInt& aAvailabilityEnum, RBuf& aCustomMessage ); |
|
248 |
|
249 private: // data |
|
250 |
|
251 MXIMPClient* iPresClient; |
|
252 MXIMPContext* iPresenceCtx; |
|
253 MPresenceFeatures* iFeature; |
|
254 |
|
255 /** |
|
256 * Id for presence settings |
|
257 */ |
|
258 TInt iPresenceSettingsId; |
|
259 |
|
260 /** |
|
261 * Tells the state of presence handler |
|
262 */ |
|
263 TScpPresenceState iPresenceState; |
|
264 |
|
265 /** |
|
266 * Array for storing requests |
|
267 */ |
|
268 RArray< TScpReqId > iReqIdArray; |
|
269 |
|
270 /** |
|
271 * Indicates do we have to make rebind |
|
272 */ |
|
273 TBool iRebind; |
|
274 |
|
275 /** |
|
276 * Holds the last ximp error |
|
277 */ |
|
278 TInt iLastXimpError; |
|
279 |
|
280 /** |
|
281 * Flag for indicating if service disabling should be done |
|
282 * after all Ximp requests are completed. |
|
283 */ |
|
284 TBool iDisableAfterXimpRequestsCompleted; |
|
285 |
|
286 /** |
|
287 * Flag for indicating if network is lost and roaming is |
|
288 * concluded to be ongoing |
|
289 */ |
|
290 TBool iNetworkLostRoamingOngoing; |
|
291 |
|
292 #ifdef _DEBUG |
|
293 friend class T_CScpPresenceHandler; |
|
294 #endif |
|
295 |
|
296 }; |
|
297 |
|
298 #endif // C_CSCPPRESENCEHANDLER_H |
|
299 |
|
300 // End of File |