|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : sipapnconfigurationhandler.h |
|
15 // Part of : SIP Profile Server |
|
16 // implementation |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 #ifndef __CSIPAPNCONFIGURATIONHANDLER_H__ |
|
21 #define __CSIPAPNCONFIGURATIONHANDLER_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <etelpckt.h> |
|
25 #include <es_enum.h> |
|
26 #include <es_enum_partner.h> |
|
27 #include "sipapnmanager.h" |
|
28 |
|
29 // CONSTANTS |
|
30 const TInt KSecondaryApnMaxRetryCount = 100; |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CCommsDatabase; |
|
34 namespace CommsDat |
|
35 { |
|
36 class CCDRecordBase; |
|
37 } |
|
38 |
|
39 // CLASS DEFINITION sipapnconfigurationhandler.h |
|
40 /** |
|
41 * |
|
42 */ |
|
43 class CSIPApnConfigurationHandler : public CActive |
|
44 { |
|
45 public: // Constructors and destructor |
|
46 |
|
47 enum TSipApnMonitoringState |
|
48 { |
|
49 EMonitoringIdle, |
|
50 EMonitoringConnection, |
|
51 EMonitoringDatabase |
|
52 }; |
|
53 |
|
54 /** |
|
55 * Static constructor. |
|
56 * |
|
57 * @return An initialized instance of this class. |
|
58 */ |
|
59 static CSIPApnConfigurationHandler* NewL( MSIPApnChangeObserver& aObserver, |
|
60 TUint32 aIapId); |
|
61 |
|
62 /** |
|
63 * Static constructor. |
|
64 * |
|
65 * @return An initialized instance of this class. |
|
66 */ |
|
67 static CSIPApnConfigurationHandler* NewLC( MSIPApnChangeObserver& aObserver, |
|
68 TUint32 aIapId); |
|
69 |
|
70 /// Destructor |
|
71 ~CSIPApnConfigurationHandler(); |
|
72 |
|
73 public: |
|
74 |
|
75 /** |
|
76 * Change APN of specified IAP. If async change is allowed, change |
|
77 * may be done later if it was not possible at the moment. Once apn |
|
78 * is changed, observer is notified about change. |
|
79 */ |
|
80 void SetApnL( const TDesC8& aApn, |
|
81 TBool aUseSecureAuthentication, |
|
82 TBool aAllowAsync ); |
|
83 |
|
84 TBool IsPrimaryApnUsed(); |
|
85 |
|
86 TBool HasPendingTasks() const; |
|
87 |
|
88 TUint32 HandlerIapId() const; |
|
89 |
|
90 TBool IsFailed() const; |
|
91 |
|
92 void SetFailed(TBool aIsFailed, TBool aIsFatalFailure ); |
|
93 |
|
94 void UpdateApnL( TBool aIsPrimaryApn, const TDesC8& aApn ); |
|
95 |
|
96 protected: // From CActive |
|
97 |
|
98 void DoCancel(); |
|
99 void RunL(); |
|
100 TInt RunError( TInt aError ); |
|
101 |
|
102 private: |
|
103 |
|
104 TBool IsInUseL( TConnectionInfo& aConnectionInfo ); |
|
105 |
|
106 void StartMonitoringConnectionL( TConnectionInfo& aConnectionInfo ); |
|
107 |
|
108 void WatchConnectionStatusChange(); |
|
109 |
|
110 void WatchDatabaseStatusChangeL( TUint32 aIapId ); |
|
111 |
|
112 TBool ApnChangeNeededL( const TDesC8& aApn ); |
|
113 |
|
114 TBool ChangeApnIfNotInUseL( TBool aAllowAsync = ETrue ); |
|
115 |
|
116 TBool IssueApnChangeL( TUint32 aIapId, |
|
117 const TDesC8& aApn, |
|
118 TBool aUseSecureAuthentication, |
|
119 TBool aAllowAsync = ETrue ); |
|
120 |
|
121 void ChangeApnL( const TDesC8& aApn, |
|
122 TBool aUseSecureAuthentication ); |
|
123 |
|
124 TBool ClearProtectedRecord( CommsDat::CCDRecordBase& aRecord ); |
|
125 |
|
126 void SetMonitoringState( TSipApnMonitoringState aMonitoringState ); |
|
127 |
|
128 TSipApnMonitoringState MonitoringState() const; |
|
129 |
|
130 void ConnectionMonitoringCompletedL( TInt aError ); |
|
131 |
|
132 void DatabaseMonitoringCompletedL( TInt aError ); |
|
133 |
|
134 void SendApnChangedNotificationL( const TDesC8& aApn, TInt aError = KErrNone ); |
|
135 |
|
136 TDesC8& PrimaryApn(); |
|
137 |
|
138 TDesC8& SecondaryApn(); |
|
139 |
|
140 /** |
|
141 * Reads the APN of specified IAP. |
|
142 * @param aIapId IAP id |
|
143 * @return APN or NULL if not found. Ownership is transferred. |
|
144 */ |
|
145 HBufC8* ReadCurrentApnL(); |
|
146 |
|
147 |
|
148 private: // Constructors |
|
149 |
|
150 /// Constructor |
|
151 CSIPApnConfigurationHandler( MSIPApnChangeObserver& aObserver, |
|
152 TUint32 aIapId); |
|
153 |
|
154 /// 2nd phase constructor |
|
155 void ConstructL(); |
|
156 |
|
157 private: // Data |
|
158 |
|
159 MSIPApnChangeObserver& iObserver; |
|
160 |
|
161 TSipApnMonitoringState iMonitoringState; |
|
162 |
|
163 RSocketServ iSocketSrv; |
|
164 |
|
165 RConnection iConnection; |
|
166 |
|
167 TPckgBuf<TConnectionInfo> iConnectionInfo; |
|
168 |
|
169 TNifProgressBuf iProgress; |
|
170 |
|
171 HBufC8* iApnProposal; |
|
172 |
|
173 TUint32 iIapId; |
|
174 |
|
175 CCommsDatabase* iCommsDatabase; |
|
176 |
|
177 TInt iMonitoringRetryCount; |
|
178 |
|
179 HBufC8* iCurrentApn; |
|
180 |
|
181 TBool iApnUseSecureAuthProposal; |
|
182 |
|
183 TBool iIsFailed; |
|
184 |
|
185 TBool iIsFatalFailure; |
|
186 |
|
187 HBufC8* iPrimaryApn; |
|
188 HBufC8* iSecondaryApn; |
|
189 |
|
190 #ifdef CPPUNIT_TEST |
|
191 friend class CSIPApnManagerTest; |
|
192 friend class CSIPApnManager; |
|
193 #endif |
|
194 |
|
195 }; |
|
196 |
|
197 #endif // __CSIPAPNCONFIGURATIONHANDLER_H__ |
|
198 |