|
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 protected: // From base classes |
|
96 |
|
97 /** |
|
98 * From CActive |
|
99 * @since Series 60 3.2 |
|
100 */ |
|
101 void RunL(); |
|
102 |
|
103 /** |
|
104 * From CActive |
|
105 * @since Series 60 3.2 |
|
106 */ |
|
107 TInt RunError( TInt aError ); |
|
108 |
|
109 /** |
|
110 * From CActive |
|
111 * @since Series 60 3.2 |
|
112 */ |
|
113 void DoCancel(); |
|
114 |
|
115 private: |
|
116 |
|
117 /** |
|
118 * C++ default constructor. |
|
119 */ |
|
120 CCCHCommDbWatcher( MCCHCommDbWatcherObserver& aObserver ); |
|
121 |
|
122 /** |
|
123 * By default Symbian 2nd phase constructor is private. |
|
124 */ |
|
125 void ConstructL(); |
|
126 |
|
127 /* |
|
128 * Request notifications of cenrep changes |
|
129 * @return KErrNone if succesful |
|
130 */ |
|
131 TInt RequestNotifications(); |
|
132 |
|
133 /** |
|
134 * Check changes in IAPs / SNAP configurations |
|
135 * @param aChanged will be ETrue if there has been changes to |
|
136 * either total WLAN AP count or SNAP/IAP configuration |
|
137 * @param aSNAPId will contain ID of the changed SNAP that |
|
138 * contains now more WLAN Iaps |
|
139 */ |
|
140 void CheckIapsL( TBool& aChanged, TInt& aSNAPId ); |
|
141 |
|
142 /** |
|
143 * Count number of Iaps in an array of TDestinationData. |
|
144 * Helper function to detect new iap additions |
|
145 * @param aArray Array to count from |
|
146 * @return total number of IAPs from the given destinations array |
|
147 * @since S60 3.2 |
|
148 */ |
|
149 TInt CountIapsFromArray( RArray<TDestinationData>& aArray ) const; |
|
150 |
|
151 /** |
|
152 * Updates internal iDestinations store after a SNAP configuration change. |
|
153 * Determines also the SNAP where WLAN iap(s) were added. |
|
154 * @param aDestinations current Snap configuration attained from cmmanager |
|
155 * @param aChanged will be ETrue if there is a new WLAN iap |
|
156 * @param aSNAPId holds the SNAP id of the added WLAN iap |
|
157 * @since S60 3.2 |
|
158 */ |
|
159 void UpdateDestinationStore( RArray<TDestinationData>& aDestinations, |
|
160 TBool& aChanged, |
|
161 TInt& aSNAPId); |
|
162 |
|
163 /** |
|
164 * Updates IAPs / SNAPs configurations and notifies our client if |
|
165 * there is some changes. |
|
166 * @return TInt general symbian error code. |
|
167 */ |
|
168 TInt UpdateIapTable(); |
|
169 |
|
170 /** |
|
171 * Open connection to cmmanager |
|
172 * @return RCmManager reference to cmmanager |
|
173 */ |
|
174 RCmManager& CmManagerL(); |
|
175 |
|
176 /** |
|
177 * Initializes destinations. |
|
178 */ |
|
179 void InitializeDestination(); |
|
180 |
|
181 private: // data |
|
182 |
|
183 ///not own: observer to notify when there are changes in WLAN IAP/SNAPs |
|
184 MCCHCommDbWatcherObserver& iObserver; |
|
185 |
|
186 ///own: Commsdb access to get notifications about changes |
|
187 CCommsDatabase* iCommDb; |
|
188 |
|
189 // Central repository to get notifications of commsdat changes |
|
190 CRepository* iRepository; |
|
191 |
|
192 // Table id for iap table |
|
193 TUint32 iTableId; |
|
194 |
|
195 ///own: array holding information about iap count per destination |
|
196 // index 0 will contain count of iaps not bound to any |
|
197 // destination |
|
198 RArray<TDestinationData> iDestinations; |
|
199 |
|
200 //own, connectionmethodmanager |
|
201 RCmManager iCmm; |
|
202 |
|
203 // indicates is cmmanager open |
|
204 TBool iCmmOpen; |
|
205 |
|
206 // Holds the last cmmanager error |
|
207 TInt iLastError; |
|
208 |
|
209 // Error counter for cenrep notification request errors |
|
210 TInt iErrorCounter; |
|
211 |
|
212 // Indicates do we have to use force when asking snap's iap |
|
213 TBool iUseForce; |
|
214 }; |
|
215 |
|
216 #endif // C_CCHCOMMDBWATCHER_H |
|
217 |
|
218 // End of file |