|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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: Declaration of class CBrowserCommsModel. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef BROWSER_COMMS_MODEL_H |
|
21 #define BROWSER_COMMS_MODEL_H |
|
22 |
|
23 // INCLUDES |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <ActiveApDb.h> |
|
27 #include "CommsModel.h" |
|
28 |
|
29 // FORWARD DECLARATION |
|
30 |
|
31 // class CApListItem; |
|
32 class CApListItemList; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * Comms model for the Browser. |
|
38 * Provides CommsDb / AP database handling. Because querying AP-s is slow, but |
|
39 * there should not be many of them, this class keeps a cached copy of AP-s. |
|
40 * AP db is observed, and the cached list of AP-s is kept up to date. |
|
41 * However, if database changes but we cannot get new data (database locked |
|
42 * etc., the cached list is kept (until we can get the new data successfully)). |
|
43 * |
|
44 * @lib Browser.app |
|
45 * @since Series 60 1.2 |
|
46 */ |
|
47 class CBrowserCommsModel: |
|
48 public CBase, public MCommsModel, public MActiveApDbObserver |
|
49 { |
|
50 public: // construction |
|
51 |
|
52 /** |
|
53 * Two-phased constructor. Leaves on failure. |
|
54 * @return The constructed model |
|
55 */ |
|
56 static CBrowserCommsModel* NewL(); |
|
57 |
|
58 /** |
|
59 * Destructor. |
|
60 */ |
|
61 virtual ~CBrowserCommsModel(); |
|
62 |
|
63 protected: // construction |
|
64 |
|
65 /** |
|
66 * Constructor. |
|
67 */ |
|
68 CBrowserCommsModel(); |
|
69 |
|
70 /** |
|
71 * Second phase constructor. Leaves on failure. |
|
72 */ |
|
73 void ConstructL(); |
|
74 |
|
75 public: // from MCommsModel |
|
76 |
|
77 /** |
|
78 * Get Access Point Engine object. |
|
79 * @since Series 60 1.2 |
|
80 * @return Access Point Engine object |
|
81 */ |
|
82 CActiveApDb& ApDb() const; |
|
83 |
|
84 /** |
|
85 * Get CommsDb object. |
|
86 * @since Series 60 1.2 |
|
87 * @return CommsDb object |
|
88 */ |
|
89 CCommsDatabase& CommsDb() const; |
|
90 |
|
91 /** |
|
92 * Get a copy of access points in a list. |
|
93 * The caller is responsible for destroying the returned list. |
|
94 * @since Series 60 1.2 |
|
95 * @return List of access points. |
|
96 */ |
|
97 CApListItemList* CopyAccessPointsL(); |
|
98 |
|
99 /** |
|
100 * Get pointer to model's cached access points. |
|
101 * The owner of the list is the model. List contents may be updated |
|
102 * if database update occurs. |
|
103 * @since Series 60 1.2 |
|
104 * @return List of access points. |
|
105 */ |
|
106 const CApListItemList* AccessPointsL(); |
|
107 |
|
108 /** |
|
109 * Refresh the cached access points. |
|
110 */ |
|
111 void RefreshAccessPointsL(); |
|
112 |
|
113 /** |
|
114 * Add an observer. Duplicates allowed. |
|
115 * @since Series 60 1.2 |
|
116 * @param aObserver The observer to add. |
|
117 */ |
|
118 void AddObserverL( MCommsModelObserver& aObserver ); |
|
119 |
|
120 /** |
|
121 * Remove an observer. Does nothing if not added / already removed. |
|
122 * @since Series 60 1.2 |
|
123 * @param aObserver The observer to remove. |
|
124 */ |
|
125 void RemoveObserver( MCommsModelObserver& aObserver ); |
|
126 |
|
127 public: // from MActiveApDbObserver |
|
128 |
|
129 /** |
|
130 * Handle database event (refresh cached AP list on change). |
|
131 * @since Series 60 1.2 |
|
132 * @param aEvent Database-related event. |
|
133 */ |
|
134 void HandleApDbEventL( MActiveApDbObserver::TEvent aEvent ); |
|
135 |
|
136 private: // new methods |
|
137 |
|
138 /** |
|
139 * Get all access points (implementation detail). If database is |
|
140 * inaccessible, old data remains and update becomes pending. |
|
141 * @since Series 60 1.2 |
|
142 */ |
|
143 void GetAccessPointsL(); |
|
144 |
|
145 /** |
|
146 * Get all access points (implementation detail). |
|
147 * @since Series 60 1.2 |
|
148 * @param aList Append access points to this list |
|
149 */ |
|
150 void DoGetAccessPointsL( CApListItemList& aList ) const; |
|
151 |
|
152 /** |
|
153 * Successfully got new AP data. Notify observers. |
|
154 * @since Series 60 1.2 |
|
155 */ |
|
156 void NotifyObserversL(); |
|
157 |
|
158 private: // data |
|
159 |
|
160 /** |
|
161 * Access Point database. |
|
162 */ |
|
163 CActiveApDb* iDb; |
|
164 |
|
165 /** |
|
166 * Cached AP list. Since querying the AP Engine is expensive (slow), |
|
167 * we maintain a cached list of AP-s for quick access. Hopefully |
|
168 * there are not too many of them. |
|
169 */ |
|
170 CApListItemList* iCachedApList; |
|
171 |
|
172 /** |
|
173 * Array of observer pointers. Array owned, contents not. |
|
174 */ |
|
175 CArrayPtrFlat<MCommsModelObserver>* iObservers; |
|
176 |
|
177 /** |
|
178 * ETrue if database has changed, but could not get new data yet. |
|
179 */ |
|
180 TBool iUpdatePending; |
|
181 |
|
182 |
|
183 /** |
|
184 *Etrue if referesh needs to be done on next access to cached data |
|
185 *Added as a result of performance tuning |
|
186 */ |
|
187 TBool iDelayedRefresh; |
|
188 }; |
|
189 |
|
190 #endif |
|
191 |
|
192 // End of file |