1 /* |
|
2 * Copyright (c) 2002-2007 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 public: // From CScpServiceHandlerBase |
|
81 |
|
82 /** |
|
83 * Enables service. |
|
84 */ |
|
85 void EnableSubServiceL(); |
|
86 |
|
87 /** |
|
88 * Disables service. |
|
89 * @return Symbian error code |
|
90 */ |
|
91 TInt DisableSubService(); |
|
92 |
|
93 /** |
|
94 * Returns type of sub service (VoIP, Vmbx, Presence). |
|
95 * @return Type of the sub service. |
|
96 */ |
|
97 TCCHSubserviceType SubServiceType() const; |
|
98 |
|
99 /** |
|
100 * Handles sip connection event |
|
101 * @param aProfileId Sip profile id |
|
102 * @param aSipEvent Connection event |
|
103 */ |
|
104 void HandleSipConnectionEvent( const TUint32 aProfileId, |
|
105 TScpConnectionEvent aSipEvent ); |
|
106 |
|
107 public: // From MScpSubServiceObserver |
|
108 /** |
|
109 * Handle SubService state change. |
|
110 * This function is for observing VoIP subservice. |
|
111 * If VoIP subservice connection is not OK, |
|
112 * set presence state to offline. |
|
113 * @param aState subservice connection state |
|
114 * @param aError is the error of the service |
|
115 */ |
|
116 void HandleSubServiceChange( TCCHSubserviceState aState, TInt aError ); |
|
117 |
|
118 |
|
119 public: // From MXIMPContextObserver |
|
120 |
|
121 /** |
|
122 * Handles presence context events. |
|
123 * @param aContext |
|
124 * @param aEvent Event |
|
125 */ |
|
126 void HandlePresenceContextEvent( const MXIMPContext& aContext, |
|
127 const MXIMPBase& aEvent ); |
|
128 |
|
129 private: |
|
130 |
|
131 /** |
|
132 * C++ default constructor. |
|
133 * @param aSubService The presence subservice |
|
134 */ |
|
135 CScpPresenceHandler( CScpSubService& aSubService ); |
|
136 |
|
137 /** |
|
138 * Symbian second phase constructor. |
|
139 */ |
|
140 void ConstructL(); |
|
141 |
|
142 /** |
|
143 * Update XDM settings access point. |
|
144 * XDM ap should be same as sip profile. |
|
145 */ |
|
146 void UpdateXdmSettingsL(); |
|
147 |
|
148 /** |
|
149 * Binds SCP's presence context. |
|
150 */ |
|
151 void ServerBindL(); |
|
152 |
|
153 /** |
|
154 * Unbinds SCP's presence context. |
|
155 */ |
|
156 void ServerUnBindL(); |
|
157 |
|
158 /** |
|
159 * Stops publishing according to parameter and unbinds the presence |
|
160 * context. Leaves, if there are ongoing requests and publish offline |
|
161 * is not called. |
|
162 * @param aDoStopPublish if ETrue, users own presence status is |
|
163 * removed from presence server before unbinding the context |
|
164 */ |
|
165 void HandleDeregistrationL( TBool aDoStopPublish ); |
|
166 |
|
167 /** |
|
168 * Publishes presence according to given parameter. |
|
169 * @param aPublishOnline If ETrue, publish Online, if EFalse, |
|
170 * publish Offline |
|
171 */ |
|
172 void PublishPresenceL( TBool aPublishOnline ); |
|
173 |
|
174 /** |
|
175 * Creates presence info item |
|
176 * @param aState presence state |
|
177 * @return The created presence info pointer |
|
178 */ |
|
179 MPresenceInfo* CreateInfoLC( TBool aState ); |
|
180 |
|
181 /** |
|
182 * Changes service state to deregistered. If user requested |
|
183 * disabling the service, also profile deregistration is done. |
|
184 */ |
|
185 void DeregisterNow(); |
|
186 |
|
187 /** |
|
188 * Get property id. |
|
189 * @param aProperty, presence service property name |
|
190 * @param aValue, the id as a result of the query |
|
191 */ |
|
192 void GetPresencePropertyIdL( TServicePropertyName aProperty, TInt& aValue ) const; |
|
193 |
|
194 /** |
|
195 * Force service disable |
|
196 * @param aSelf This object |
|
197 * @return 1 |
|
198 */ |
|
199 static TInt ForcePresenceServiceDisable( TAny* aSelf ); |
|
200 |
|
201 /** |
|
202 * Find VoIP subservice pointer |
|
203 * @return VoIP subservice pointer |
|
204 */ |
|
205 CScpSubService* GetVoipSubService(); |
|
206 |
|
207 /** |
|
208 * Handles the XIMP context state events. |
|
209 * @param aEvent The XIMP event to handle |
|
210 */ |
|
211 void HandleContextStateEvent( const MXIMPBase& aEvent ); |
|
212 |
|
213 /** |
|
214 * Handles the XIMP request complete events |
|
215 * @param aEvent The XIMP event to handle |
|
216 */ |
|
217 void HandleRequestCompleteEvent( const MXIMPBase& aEvent ); |
|
218 |
|
219 /** |
|
220 * Handles the Bind complete event |
|
221 */ |
|
222 void HandleBindCompleteEvent(); |
|
223 |
|
224 /** |
|
225 * Subscribe presentity group |
|
226 */ |
|
227 void SubscribePresentityGroupL(); |
|
228 |
|
229 /** |
|
230 * Unsubscribe presentity group |
|
231 */ |
|
232 void UnsubscribePresentityGroupL(); |
|
233 |
|
234 /** |
|
235 * Gets stored presence values if available |
|
236 * @param aAvailabilityEnum Holds stored availability value |
|
237 * @param aCustomMessage Holds stored custom message |
|
238 */ |
|
239 void GetStoredPresenceValuesL( TInt& aAvailabilityEnum, RBuf& aCustomMessage ); |
|
240 |
|
241 private: // data |
|
242 |
|
243 MXIMPClient* iPresClient; |
|
244 MXIMPContext* iPresenceCtx; |
|
245 MPresenceFeatures* iFeature; |
|
246 |
|
247 /** |
|
248 * Id for presence settings |
|
249 */ |
|
250 TInt iPresenceSettingsId; |
|
251 |
|
252 /** |
|
253 * Tells the state of presence handler |
|
254 */ |
|
255 TScpPresenceState iPresenceState; |
|
256 |
|
257 /** |
|
258 * Array for storing requests |
|
259 */ |
|
260 RArray< TScpReqId > iReqIdArray; |
|
261 |
|
262 /** |
|
263 * Indicates do we have to make rebind |
|
264 */ |
|
265 TBool iRebind; |
|
266 |
|
267 /** |
|
268 * Holds the last ximp error |
|
269 */ |
|
270 TInt iLastXimpError; |
|
271 |
|
272 /** |
|
273 * Flag for indicating if service disabling should be done |
|
274 * after all Ximp requests are completed. |
|
275 */ |
|
276 TBool iDisableAfterXimpRequestsCompleted; |
|
277 |
|
278 #ifdef _DEBUG |
|
279 friend class T_CScpPresenceHandler; |
|
280 #endif |
|
281 |
|
282 }; |
|
283 |
|
284 #endif // C_CSCPPRESENCEHANDLER_H |
|
285 |
|
286 // End of File |
|