|
1 /* |
|
2 * Copyright (c) 2002-2009 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_SCPPPROFILEHANDLER_H |
|
20 #define C_SCPPPROFILEHANDLER_H |
|
21 |
|
22 #include <sipprofileregistryobserver.h> |
|
23 #include <sipconnectionobserver.h> |
|
24 #include <sipobserver.h> |
|
25 #include <sipprofilealrobserver.h> |
|
26 |
|
27 #include "scpsipconnectionobserver.h" |
|
28 #include "scpalrobserver.h" |
|
29 #include "scpdefs.h" |
|
30 #include "scpsipconnection.h" |
|
31 #include "scpalrobserver.h" |
|
32 |
|
33 class CSIP; |
|
34 class CSIPProfileRegistry; |
|
35 class CSIPManagedProfileRegistry; |
|
36 class CSIPManagedProfile; |
|
37 class CSipProfileAlrController; |
|
38 class CScpSipConnection; |
|
39 class MIpVmbxObserver; |
|
40 class CIpVmbxInterface; |
|
41 |
|
42 /** |
|
43 * Register/unregister protocol profiles. |
|
44 * |
|
45 * @lib sipconnectionprovider.dll |
|
46 * @since Series 60 3.2 |
|
47 */ |
|
48 class CScpProfileHandler : public CBase, |
|
49 public MSIPProfileRegistryObserver, |
|
50 public MSIPObserver, |
|
51 public MSipProfileAlrObserver, |
|
52 public MScpSipConnectionObserver |
|
53 { |
|
54 public: |
|
55 |
|
56 /** |
|
57 * Enumeration for ALR events. |
|
58 */ |
|
59 enum TAlrEvent |
|
60 { |
|
61 EScpAlrAllowMigration, |
|
62 EScpAlrDisallowMigration, |
|
63 EScpAlrRefresh |
|
64 }; |
|
65 |
|
66 public: // Constructors and destructor |
|
67 |
|
68 /** |
|
69 * Two-phased constructor. |
|
70 */ |
|
71 static CScpProfileHandler* NewL(); |
|
72 |
|
73 /** |
|
74 * Destructor. |
|
75 */ |
|
76 virtual ~CScpProfileHandler(); |
|
77 |
|
78 public: |
|
79 |
|
80 /** |
|
81 * Adds Sip profile observer. |
|
82 * @param aObserver SIP profile observer. |
|
83 */ |
|
84 void AddObserverL( MScpSipConnectionObserver& aObserver ); |
|
85 |
|
86 /** |
|
87 * Remove observer from the array. |
|
88 * @param aObserver SIP profile observer. |
|
89 * @return KErrNone If succeed. |
|
90 */ |
|
91 TInt RemoveObserver( MScpSipConnectionObserver& aObserver ); |
|
92 |
|
93 /** |
|
94 * Get current state of scp connection having given sip profile id |
|
95 * @param aProfileId SIP profile id. |
|
96 * @param aState Current state. |
|
97 * @return KErrNone if succeed. |
|
98 */ |
|
99 TInt GetCurrentState( TUint32 aProfileId, |
|
100 CScpSipConnection::TConnectionState& aState, |
|
101 TInt& aError ) const; |
|
102 |
|
103 /** |
|
104 * Register profile to SIP. |
|
105 * @param aProfileId SIP Profile id to register. |
|
106 * @return Symbian error codes. |
|
107 */ |
|
108 void RegisterProfileL( TUint32 aProfileId ); |
|
109 |
|
110 /** |
|
111 * UnRegister profile to SIP. |
|
112 * @param aProfileId SIP Profile id to unregister. |
|
113 * @return Symbian error codes. |
|
114 */ |
|
115 TInt UnregisterProfile( TUint32 aProfileId ); |
|
116 |
|
117 /** |
|
118 * Cancels any ongoing registration |
|
119 * @param aProfileId SIP Profile id to unregister. |
|
120 * @return Symbian error codes. |
|
121 */ |
|
122 TInt CancelRegistration( TUint32 aProfileId ); |
|
123 |
|
124 /** |
|
125 * Return existence info of profile id. |
|
126 * @param aProfileId Protocol profile id. |
|
127 * @return ETrue if profile exist. |
|
128 */ |
|
129 TBool ProfileExists( TUint32 aProfileId ) const; |
|
130 |
|
131 /** |
|
132 * Uses SIP ALR controller for ALR events. |
|
133 * @param aProfileId Profile id. |
|
134 * @param aEvent New ALR event. |
|
135 * @param aIapId IAP id. |
|
136 */ |
|
137 void DoAlrEventL( TUint32 aProfileId, |
|
138 TAlrEvent aEvent, |
|
139 TUint32 aIapId = NULL ); |
|
140 |
|
141 /** |
|
142 * Checks if sip connection for give profile id exists |
|
143 * @param aProfileId Profile id. |
|
144 * @return ETrue if exists |
|
145 */ |
|
146 TBool SipConnectionExists( TUint32 aProfileId ) const; |
|
147 |
|
148 /** |
|
149 * Gets a asip connection for given profile id |
|
150 * @param aProfileId Profile id. |
|
151 * @return Sip connection. Ownership is not transferred. |
|
152 */ |
|
153 CScpSipConnection* GetSipConnection( TUint32 aProfileId ) const; |
|
154 |
|
155 /** |
|
156 * Creates a sip connection for given profile id |
|
157 * @param aProfileId Profile id. |
|
158 * @return Sip connection. Ownership is transferred. |
|
159 */ |
|
160 CScpSipConnection* CreateSipConnectionL( TUint32 aProfileId ) const; |
|
161 |
|
162 /** |
|
163 * Sets a sip profile reserved state |
|
164 * @param aProfileId Sip profile id |
|
165 * @param aReserved Reserved |
|
166 */ |
|
167 void SetSipProfileReserved( TUint32 aProfileId, TBool aReserved ); |
|
168 |
|
169 /** |
|
170 * Return VMBX service provider interface |
|
171 * @param aObserver VMBX service provider observer |
|
172 * @return Interface |
|
173 */ |
|
174 CIpVmbxInterface& VmbxInterfaceL( MIpVmbxObserver& aObserver ); |
|
175 |
|
176 /** |
|
177 * Delete VMBX service provider interface, there is no other way to remove |
|
178 * MIpVmbxObserver. Observer has to remove when deleting vmbx subservice. |
|
179 */ |
|
180 void DeleteVmbxInterface(); |
|
181 |
|
182 /** |
|
183 * Checks if a sip profile requires update |
|
184 * @param aProfileId SIP profile ID |
|
185 * @param aTerminalType indicates is terminal type defined |
|
186 * @param aWlanMac indicates is wlan mac defined |
|
187 * @param aStringLength length of free string |
|
188 */ |
|
189 void UpdateSipProfileL( TUint32 aProfileId, TBool aTerminalType, |
|
190 TBool aWlanMac, TInt astringLength ); |
|
191 |
|
192 /** |
|
193 * Set username and/or passowrd. |
|
194 * @param aProfileId Profile id to use. |
|
195 * @param aUsername to set |
|
196 * @param aSetUsername If true, set username. |
|
197 * @param aPassword Password to set. |
|
198 * @param aSetPassword If true, set password. |
|
199 * @@return none |
|
200 * @leave KErrArgument if passed values are incorrect, or other |
|
201 * symbian error code. |
|
202 */ |
|
203 void SetUsernameAndPasswordL( TUint32 aProfileId, |
|
204 const TDesC8& aUsername, |
|
205 TBool aSetUsername, |
|
206 const TDesC8& aPassword, |
|
207 TBool aSetPassword ); |
|
208 |
|
209 #ifdef _DEBUG |
|
210 void GetDebugInfo( TDes& aInfo ) const; |
|
211 #endif |
|
212 |
|
213 |
|
214 private: // Functions from base classes |
|
215 |
|
216 /** |
|
217 * From MSIPObserver |
|
218 * A SIP request has been received from the network. |
|
219 * @pre aTransaction != 0 |
|
220 * @param aIapId The IapId from which the SIP request was received. |
|
221 * @param aTransaction contains local address, remote address of a SIP |
|
222 * message, as well as optional SIP message method, headers and |
|
223 * body. The ownership is transferred. |
|
224 */ |
|
225 void IncomingRequest( TUint32 aIapId, CSIPServerTransaction* aTransaction ); |
|
226 |
|
227 /** |
|
228 * From MSIPObserver |
|
229 * The received SIP request time-outed and it is invalid i.e. cannot be used |
|
230 * anymore. |
|
231 * This will be called if the user fails to create a SIP connection |
|
232 * and does not send an appropriate SIP response. |
|
233 * @param aTransaction The time-outed transaction. |
|
234 */ |
|
235 void TimedOut( CSIPServerTransaction& aTransaction ); |
|
236 |
|
237 |
|
238 /** |
|
239 * From MSIPProfileRegistryObserver |
|
240 * An event related to SIP Profile has accorred |
|
241 * @param aProfileId a profile Id |
|
242 * @param aEvent an occurred event |
|
243 */ |
|
244 void ProfileRegistryEventOccurred( TUint32 aProfileId, |
|
245 MSIPProfileRegistryObserver::TEvent aEvent ); |
|
246 |
|
247 /** |
|
248 * From MSIPProfileRegistryObserver |
|
249 * An asynchronous error has occurred related to SIP profile |
|
250 * Event is send to those observers, who have the |
|
251 * corresponding profile instantiated. |
|
252 * @param aProfileId the id of failed profile |
|
253 * @param aError an occurred error |
|
254 */ |
|
255 void ProfileRegistryErrorOccurred( TUint32 aProfileId, |
|
256 TInt aError ); |
|
257 |
|
258 /** |
|
259 * ALR related event occurred. See MSipProfileAlrObserver. |
|
260 * @param aEvent the event that occurred |
|
261 * @param aProfileId identifies the SIP profile related to the event |
|
262 * @param aSnapId the SNAP related to the event |
|
263 * @param aIapId the IAP related to the event |
|
264 */ |
|
265 void AlrEvent( MSipProfileAlrObserver::TEvent aEvent, |
|
266 TUint32 aProfileId, |
|
267 TUint32 aSnapId, |
|
268 TUint32 aIapId ); |
|
269 |
|
270 /** |
|
271 * ALR related error occurred. See MSipProfileAlrObserver. |
|
272 * @param aError the error that occurred |
|
273 * @param aProfileId identifies the SIP profile related to the error |
|
274 * @param aSnapId the SNAP related to the event |
|
275 * @param aIapId the IAP related to the error |
|
276 */ |
|
277 void AlrError( TInt aError, |
|
278 TUint32 aProfileId, |
|
279 TUint32 aSnapId, |
|
280 TUint32 aIapId ); |
|
281 |
|
282 /** |
|
283 * Sip profile state changed |
|
284 * @param aProfileId Profile id. |
|
285 * @param aSipEvent A new event of profile. |
|
286 */ |
|
287 void HandleSipConnectionEvent( TUint32 aProfileId, |
|
288 TScpConnectionEvent aSipEvent ); |
|
289 |
|
290 private: |
|
291 |
|
292 /** |
|
293 * C++ default constructor. |
|
294 */ |
|
295 CScpProfileHandler(); |
|
296 |
|
297 /** |
|
298 * By default Symbian 2nd phase constructor is private. |
|
299 */ |
|
300 void ConstructL(); |
|
301 |
|
302 /** |
|
303 * Removes a sip connection from iSipConnections |
|
304 * @param aProfilId Sip profile id |
|
305 * @return Symbian error codes |
|
306 */ |
|
307 TInt RemoveSipConnection( TUint32 aProfileId ); |
|
308 |
|
309 /** |
|
310 * Checks if sip profile is reserved by some service |
|
311 * @param aProfileId Sip profile id |
|
312 * @return ETrue if reserved |
|
313 */ |
|
314 TBool IsSipProfileReserved( TUint32 aProfileId ) const; |
|
315 |
|
316 private: |
|
317 |
|
318 /** |
|
319 * SIP instance. Own. |
|
320 */ |
|
321 CSIP* iSip; |
|
322 |
|
323 /** |
|
324 * SIP profile registry. Own. |
|
325 */ |
|
326 CSIPProfileRegistry* iProfileRegistry; |
|
327 |
|
328 /** |
|
329 * SIP managed profile registry. Own. |
|
330 */ |
|
331 CSIPManagedProfileRegistry* iManagedProfileRegistry; |
|
332 |
|
333 /** |
|
334 * SIP ALR controller. Own. |
|
335 */ |
|
336 CSipProfileAlrController* iAlrController; |
|
337 |
|
338 /** |
|
339 * Sip connections. |
|
340 */ |
|
341 RPointerArray< CScpSipConnection > iSipConnections; |
|
342 |
|
343 /** |
|
344 * SIP profile observers. |
|
345 */ |
|
346 RPointerArray< MScpSipConnectionObserver > iObservers; |
|
347 |
|
348 /** |
|
349 * VMBx service provider interface. Created once, when needed. |
|
350 */ |
|
351 CIpVmbxInterface* iVmbxInterface; |
|
352 |
|
353 // This need to be cleaned to separate macro/header |
|
354 #ifdef _DEBUG |
|
355 friend class T_CScpServiceManager; |
|
356 friend class T_CScpProfileHandler; |
|
357 friend class T_CScpSipHelper; |
|
358 friend class T_CScpVmbxHandler; |
|
359 friend class T_CScpVoipHandler; |
|
360 friend class T_CScpPresenceHandler; |
|
361 friend class T_CScpSettingHandler; |
|
362 friend class T_CScpImHandler; |
|
363 #endif |
|
364 }; |
|
365 |
|
366 #endif // CSCPPPROFILEHANDLER_H |
|
367 |
|
368 // End of File |