1 /* |
|
2 * Copyright (c) 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: CCCHCommDbWatcher declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CCHCOMMDBWATCHER_H |
|
20 #define C_CCHCOMMDBWATCHER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <commdb.h> |
|
26 #include <cmmanager.h> |
|
27 #include <commsdattypesv1_1.h> |
|
28 |
|
29 // CONSTANTS |
|
30 // Stop requesting new notifications after this many consecutive errors |
|
31 const TInt KCchConnCenRepErrorThreshold = 80; |
|
32 |
|
33 // MACROS |
|
34 // None |
|
35 |
|
36 // DATA TYPES |
|
37 class TDestinationData |
|
38 { |
|
39 public: |
|
40 inline TDestinationData(): iDestId(0), iIapCount(0), iWlanIaps(0){} |
|
41 inline TDestinationData(TInt aDestId, TInt aIapCount): |
|
42 iDestId(aDestId), iIapCount(aIapCount), iWlanIaps(0){} |
|
43 TInt iDestId; //CMM Destination ID |
|
44 TInt iIapCount; //Number of IAPs under this destination |
|
45 TInt iWlanIaps; //Number of WLAN IAPs under this destination |
|
46 }; |
|
47 |
|
48 // FUNCTION PROTOTYPES |
|
49 // None |
|
50 |
|
51 // FORWARD DECLARATIONS |
|
52 class MCCHCommDbWatcherObserver; |
|
53 class CRepository; |
|
54 |
|
55 // CLASS DECLARATION |
|
56 |
|
57 /** |
|
58 * CCCHCommDbWatcher declaration |
|
59 * Handles CommsDb changes and notifies CCHServiceHandler at IAP count changes |
|
60 * @lib cchserver.exe |
|
61 * @since S60 3.2 |
|
62 */ |
|
63 NONSHARABLE_CLASS( CCCHCommDbWatcher ) : public CActive |
|
64 { |
|
65 |
|
66 public: // Constructors and destructor |
|
67 |
|
68 static CCCHCommDbWatcher* NewL( MCCHCommDbWatcherObserver& aObserver ); |
|
69 |
|
70 static CCCHCommDbWatcher* NewLC( MCCHCommDbWatcherObserver& aObserver ); |
|
71 |
|
72 ~CCCHCommDbWatcher(); |
|
73 |
|
74 public: // new functions |
|
75 |
|
76 /** |
|
77 * Returns number of IAPs that have WLAN bearer type |
|
78 * @param aSNAPId ID of SNAP to check. Use value KErrNotFound |
|
79 * to get number of WLAN IAPS without SNAP binding |
|
80 * @param aWLANIapsOnly if ETrue, returns WLAN iap count in given SNAP |
|
81 * @param aUpdateDestinations if ETrue, update destination before checking |
|
82 * @return number of IAPs in given SNAP. KErrNotFound if no IAPS |
|
83 * @since Series 60 3.2 |
|
84 */ |
|
85 TInt GetIapCountFromSnap( TInt aSNAPId, TBool aWLANIapsOnly, TBool aUpdateDestinations = EFalse ); |
|
86 |
|
87 /** |
|
88 * Checks is IAP's bearer type WLAN AP. |
|
89 * @param aIapId of IAP to check. |
|
90 * @return ETrue if given IAP id is WLAN AP, otherwise EFalse. |
|
91 * @since Series 60 3.2 |
|
92 */ |
|
93 TBool IsWlanApL( TInt aIapId ); |
|
94 |
|
95 /** |
|
96 * Checks is IAP's bearer type VPN AP. |
|
97 * @param aIapId of IAP to check. |
|
98 * @return ETrue if given IAP id is VPN AP, otherwise EFalse. |
|
99 */ |
|
100 TBool IsVpnApL( TInt aIapId ); |
|
101 |
|
102 /** |
|
103 * IAP's bearer getter. |
|
104 * @param aIapId. |
|
105 * @return TUint32 bearer type. |
|
106 */ |
|
107 TUint32 GetBearerL( TInt aIapId ); |
|
108 |
|
109 /** |
|
110 * Removes IAPs which are not linked to VPN AP. |
|
111 * @param aIapIds all connected iaps, afterward only linked IAPs. |
|
112 * @param aIAPId VPN IAP to check. |
|
113 */ |
|
114 void RemoveOtherThanVpnIapsL( RArray<TUint>& aIaps, TUint aIAPId ); |
|
115 |
|
116 |
|
117 protected: // From base classes |
|
118 |
|
119 /** |
|
120 * From CActive |
|
121 * @since Series 60 3.2 |
|
122 */ |
|
123 void RunL(); |
|
124 |
|
125 /** |
|
126 * From CActive |
|
127 * @since Series 60 3.2 |
|
128 */ |
|
129 TInt RunError( TInt aError ); |
|
130 |
|
131 /** |
|
132 * From CActive |
|
133 * @since Series 60 3.2 |
|
134 */ |
|
135 void DoCancel(); |
|
136 |
|
137 private: |
|
138 |
|
139 /** |
|
140 * C++ default constructor. |
|
141 */ |
|
142 CCCHCommDbWatcher( MCCHCommDbWatcherObserver& aObserver ); |
|
143 |
|
144 /** |
|
145 * By default Symbian 2nd phase constructor is private. |
|
146 */ |
|
147 void ConstructL(); |
|
148 |
|
149 /* |
|
150 * Request notifications of cenrep changes |
|
151 * @return KErrNone if succesful |
|
152 */ |
|
153 TInt RequestNotifications(); |
|
154 |
|
155 /** |
|
156 * Check changes in IAPs / SNAP configurations |
|
157 * @param aChanged will be ETrue if there has been changes to |
|
158 * either total WLAN AP count or SNAP/IAP configuration |
|
159 * @param aSNAPId will contain ID of the changed SNAP that |
|
160 * contains now more WLAN Iaps |
|
161 */ |
|
162 void CheckIapsL( TBool& aChanged, TInt& aSNAPId ); |
|
163 |
|
164 /** |
|
165 * Count number of Iaps in an array of TDestinationData. |
|
166 * Helper function to detect new iap additions |
|
167 * @param aArray Array to count from |
|
168 * @return total number of IAPs from the given destinations array |
|
169 * @since S60 3.2 |
|
170 */ |
|
171 TInt CountIapsFromArray( RArray<TDestinationData>& aArray ) const; |
|
172 |
|
173 /** |
|
174 * Updates internal iDestinations store after a SNAP configuration change. |
|
175 * Determines also the SNAP where WLAN iap(s) were added. |
|
176 * @param aDestinations current Snap configuration attained from cmmanager |
|
177 * @param aChanged will be ETrue if there is a new WLAN iap |
|
178 * @param aSNAPId holds the SNAP id of the added WLAN iap |
|
179 * @since S60 3.2 |
|
180 */ |
|
181 void UpdateDestinationStore( RArray<TDestinationData>& aDestinations, |
|
182 TBool& aChanged, |
|
183 TInt& aSNAPId); |
|
184 |
|
185 /** |
|
186 * Updates IAPs / SNAPs configurations and notifies our client if |
|
187 * there is some changes. |
|
188 * @return TInt general symbian error code. |
|
189 */ |
|
190 TInt UpdateIapTable(); |
|
191 |
|
192 /** |
|
193 * Open connection to cmmanager |
|
194 * @return RCmManager reference to cmmanager |
|
195 */ |
|
196 RCmManager& CmManagerL(); |
|
197 |
|
198 /** |
|
199 * Initializes destinations. |
|
200 */ |
|
201 void InitializeDestination(); |
|
202 |
|
203 private: // data |
|
204 |
|
205 ///not own: observer to notify when there are changes in WLAN IAP/SNAPs |
|
206 MCCHCommDbWatcherObserver& iObserver; |
|
207 |
|
208 ///own: Commsdb access to get notifications about changes |
|
209 CCommsDatabase* iCommDb; |
|
210 |
|
211 // Central repository to get notifications of commsdat changes |
|
212 CRepository* iRepository; |
|
213 |
|
214 // Table id for iap table |
|
215 TUint32 iTableId; |
|
216 |
|
217 ///own: array holding information about iap count per destination |
|
218 // index 0 will contain count of iaps not bound to any |
|
219 // destination |
|
220 RArray<TDestinationData> iDestinations; |
|
221 |
|
222 //own, connectionmethodmanager |
|
223 RCmManager iCmm; |
|
224 |
|
225 // indicates is cmmanager open |
|
226 TBool iCmmOpen; |
|
227 |
|
228 // Holds the last cmmanager error |
|
229 TInt iLastError; |
|
230 |
|
231 // Error counter for cenrep notification request errors |
|
232 TInt iErrorCounter; |
|
233 |
|
234 // Indicates do we have to use force when asking snap's iap |
|
235 TBool iUseForce; |
|
236 }; |
|
237 |
|
238 #endif // C_CCHCOMMDBWATCHER_H |
|
239 |
|
240 // End of file |
|