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 "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: Implementation of CApSelectorListboxModel. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "ApSelectorListBoxModel.h" |
|
22 #include "ApListItem.h" |
|
23 #include <ApSettingsHandlerCommons.h> |
|
24 |
|
25 #include <featmgr.h> |
|
26 |
|
27 #include "ApSettingsHandlerLogger.h" |
|
28 |
|
29 // CONSTANTS |
|
30 const TInt KGPRS_ICON_ID = 0; |
|
31 // No icon for CDMA (yet?) -> use GPRS icon. |
|
32 const TInt KCDMA_ICON_ID = KGPRS_ICON_ID; |
|
33 const TInt KCSD_ICON_ID = 1; |
|
34 const TInt KHSCSD_ICON_ID = 2; |
|
35 // const TInt KSMS_ICON_ID = 3; // DEPRECATED |
|
36 const TInt KWLAN_ICON_ID = 4; |
|
37 // fith icon element is the KEASY_WLAN_ICON_ID but it is not shown |
|
38 // in our UI, but is used by other modules using our |
|
39 // resources!!! const TInt KEASY_WLAN_ICON_ID = 5; |
|
40 |
|
41 const TInt KPROTECTED_ICON_ID = 6; |
|
42 // get real icons !!! now using GPRS... |
|
43 #ifdef __TEST_LAN_BEARER |
|
44 const TInt KLAN_ICON_ID = KGPRS_ICON_ID; |
|
45 #endif // __TEST_LAN_BEARER |
|
46 |
|
47 |
|
48 // ================= MEMBER FUNCTIONS ======================= |
|
49 |
|
50 // --------------------------------------------------------- |
|
51 // CApSelectorListboxModel::CApSelectorListboxModel |
|
52 // --------------------------------------------------------- |
|
53 // |
|
54 CApSelectorListboxModel::CApSelectorListboxModel( TGraphicType aGraphicType ) |
|
55 :CApListItemList(), |
|
56 iOffset( 0 ), |
|
57 iFeatureInitialised(EFalse), |
|
58 iProtectionSupported(EFalse) |
|
59 { |
|
60 APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::CApSelectorListboxModel<->") |
|
61 iGraphicType = aGraphicType; |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------- |
|
65 // CApSelectorListboxModel::~CApSelectorListboxModel |
|
66 // --------------------------------------------------------- |
|
67 // |
|
68 CApSelectorListboxModel::~CApSelectorListboxModel() |
|
69 { |
|
70 APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::~CApSelectorListboxModel<->") |
|
71 ResetAndDestroy(); // deletes all elements... |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------- |
|
75 // CApSelectorListboxModel::MdcaCount |
|
76 // --------------------------------------------------------- |
|
77 // |
|
78 TInt CApSelectorListboxModel::MdcaCount() const |
|
79 { |
|
80 APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::MdcaCount<->") |
|
81 |
|
82 return Count(); |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // CApSelectorListboxModel::MdcaPoint |
|
87 // --------------------------------------------------------- |
|
88 // |
|
89 TPtrC CApSelectorListboxModel::MdcaPoint( TInt aIndex ) const |
|
90 { |
|
91 APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::MdcaPoint") |
|
92 |
|
93 // We need to cast away the const-ness from the buffer. |
|
94 // It was definitely made for formatting! |
|
95 FormatListboxText( aIndex, |
|
96 ( MUTABLE_CAST( TBuf<KMaxApSelectorListboxName>&, iBuf ) ) ); |
|
97 |
|
98 APSETUILOGGER_LEAVEFN( EListbox,"SelListboxModel::MdcaPoint") |
|
99 return iBuf; |
|
100 } |
|
101 |
|
102 |
|
103 // --------------------------------------------------------- |
|
104 // CApSelectorListboxModel::Item4Uid |
|
105 // --------------------------------------------------------- |
|
106 // |
|
107 TInt CApSelectorListboxModel::Item4Uid( TUint32 aUid, TInt& aErr ) const |
|
108 { |
|
109 APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::Item4Uid") |
|
110 |
|
111 aErr = KErrNone; |
|
112 TInt retval( KErrNotFound ); |
|
113 for ( TInt i=0; i<Count(); i++ ) |
|
114 { |
|
115 if ( At( i )->Uid() == aUid ) |
|
116 { |
|
117 retval = i; |
|
118 break; |
|
119 } |
|
120 } |
|
121 if ( retval == KErrNotFound ) |
|
122 { |
|
123 aErr = KErrNotFound; |
|
124 } |
|
125 |
|
126 APSETUILOGGER_LEAVEFN( EListbox,"SelListboxModel::Item4Uid") |
|
127 return retval; |
|
128 } |
|
129 |
|
130 |
|
131 |
|
132 // --------------------------------------------------------- |
|
133 // CApSelectorListboxModel::SetOwnIconOffset |
|
134 // --------------------------------------------------------- |
|
135 // |
|
136 void CApSelectorListboxModel::SetOwnIconOffset( TInt aOffset ) |
|
137 { |
|
138 APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::SetOwnIconOffset<->") |
|
139 |
|
140 iOffset = aOffset; |
|
141 } |
|
142 |
|
143 |
|
144 // --------------------------------------------------------- |
|
145 // CApSelectorListboxModel::FormatListboxText |
|
146 // --------------------------------------------------------- |
|
147 // |
|
148 void CApSelectorListboxModel::FormatListboxText( TInt aIndex, |
|
149 TDes& aBuf ) const |
|
150 { |
|
151 APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::FormatListboxText") |
|
152 |
|
153 if ( !iFeatureInitialised ) |
|
154 { |
|
155 TRAPD(err, FeatureManager::InitializeLibL()); |
|
156 if (err == KErrNone) |
|
157 { |
|
158 CApSelectorListboxModel* tmp = CONST_CAST(CApSelectorListboxModel*, this); |
|
159 tmp->iProtectionSupported = FeatureManager::FeatureSupported( |
|
160 KFeatureIdSettingsProtection ); |
|
161 FeatureManager::UnInitializeLib(); |
|
162 tmp->iFeatureInitialised = ETrue; |
|
163 } |
|
164 } |
|
165 switch ( iGraphicType ) |
|
166 { |
|
167 case EGraphicBearer: |
|
168 { |
|
169 TInt iIconId; |
|
170 switch ( At( aIndex )->BearerType() ) |
|
171 { |
|
172 case EApBearerTypeCDMA: |
|
173 { |
|
174 iIconId = KCDMA_ICON_ID; |
|
175 break; |
|
176 } |
|
177 case EApBearerTypeGPRS: |
|
178 { |
|
179 iIconId = KGPRS_ICON_ID; |
|
180 break; |
|
181 } |
|
182 case EApBearerTypeCSD: |
|
183 { |
|
184 iIconId = KCSD_ICON_ID; |
|
185 break; |
|
186 } |
|
187 case EApBearerTypeHSCSD: |
|
188 { |
|
189 iIconId = KHSCSD_ICON_ID; |
|
190 break; |
|
191 } |
|
192 case EApBearerTypeWLAN: |
|
193 { |
|
194 iIconId = KWLAN_ICON_ID; |
|
195 break; |
|
196 } |
|
197 #ifdef __TEST_LAN_BEARER |
|
198 case EApBearerTypeLAN: |
|
199 { |
|
200 iIconId = KLAN_ICON_ID; |
|
201 break; |
|
202 } |
|
203 #endif // __TEST_LAN_BEARER |
|
204 case EApBearerTypeLANModem: |
|
205 { // LANMODEM get real icon ID |
|
206 iIconId = KWLAN_ICON_ID; |
|
207 break; |
|
208 } |
|
209 default: |
|
210 { |
|
211 // in release, shall not leave here, |
|
212 // it is checked when filled... |
|
213 __ASSERT_DEBUG( EFalse, Panic( EInvalidBearerType ) ); |
|
214 iIconId = KGPRS_ICON_ID; |
|
215 break; |
|
216 } |
|
217 } |
|
218 if ( iProtectionSupported ) |
|
219 { |
|
220 if ( At( aIndex )->IsReadOnly() ) |
|
221 { |
|
222 TInt iProtectedIconId = KPROTECTED_ICON_ID; |
|
223 aBuf.Format( |
|
224 KListItemFormatGraphicProtected, |
|
225 iOffset+iIconId, |
|
226 Min( At( aIndex )->Name().Length(), |
|
227 KMaxListItemNameLength ), |
|
228 &At( aIndex )->Name(), |
|
229 iOffset+iProtectedIconId |
|
230 ); |
|
231 } |
|
232 else |
|
233 { // protection supported, but not protected |
|
234 aBuf.Format( |
|
235 KListItemFormatGraphicBearer, |
|
236 iOffset+iIconId, |
|
237 Min( At( aIndex )->Name().Length(), |
|
238 KMaxListItemNameLength ), |
|
239 &At( aIndex )->Name() |
|
240 ); |
|
241 } |
|
242 } |
|
243 else |
|
244 { // protection not supported |
|
245 aBuf.Format( |
|
246 KListItemFormatGraphicBearer, |
|
247 iOffset+iIconId, |
|
248 Min( At( aIndex )->Name().Length(), |
|
249 KMaxListItemNameLength ), |
|
250 &At( aIndex )->Name() |
|
251 ); |
|
252 } |
|
253 break; |
|
254 } |
|
255 case EGraphicNone: |
|
256 { |
|
257 aBuf.Format( |
|
258 KListItemFormatGraphicNone, |
|
259 Min( At( aIndex )->Name().Length(), |
|
260 KMaxListItemNameLength ), |
|
261 &At( aIndex )->Name() |
|
262 ); |
|
263 break; |
|
264 } |
|
265 case EGraphicOnOff: |
|
266 { |
|
267 if ( iProtectionSupported ) |
|
268 { |
|
269 TInt ProtectedIconId( 0 ); |
|
270 if ( At( aIndex )->IsReadOnly() ) |
|
271 { |
|
272 ProtectedIconId = KPROTECTED_ICON_ID; |
|
273 aBuf.Format( |
|
274 KListItemFormatGraphicOnOffWithLock, |
|
275 1, |
|
276 Min( At( aIndex )->Name().Length(), |
|
277 KMaxListItemNameLength ), |
|
278 &At( aIndex )->Name(), |
|
279 iOffset + ProtectedIconId |
|
280 ); |
|
281 } |
|
282 else |
|
283 { |
|
284 aBuf.Format( |
|
285 KListItemFormatGraphicOnOff, |
|
286 1, |
|
287 Min( At( aIndex )->Name().Length(), |
|
288 KMaxListItemNameLength ), |
|
289 &At( aIndex )->Name() |
|
290 ); // magic Number, does not works with anything else |
|
291 } |
|
292 } |
|
293 else |
|
294 { |
|
295 aBuf.Format( |
|
296 KListItemFormatGraphicOnOff, |
|
297 1, |
|
298 Min( At( aIndex )->Name().Length(), |
|
299 KMaxListItemNameLength ), |
|
300 &At( aIndex )->Name() |
|
301 ); |
|
302 } |
|
303 break; |
|
304 } |
|
305 case EGraphicProtection: |
|
306 { |
|
307 if ( iProtectionSupported ) |
|
308 { |
|
309 TInt ProtectedIconId( 0 ); |
|
310 if ( At( aIndex )->IsReadOnly() ) |
|
311 { |
|
312 ProtectedIconId = 0; |
|
313 aBuf.Format( |
|
314 KListItemFormatGraphicWithLock, |
|
315 Min( At( aIndex )->Name().Length(), |
|
316 KMaxListItemNameLength ), |
|
317 &At( aIndex )->Name(), |
|
318 iOffset + ProtectedIconId |
|
319 ); |
|
320 } |
|
321 else |
|
322 { |
|
323 aBuf.Format( |
|
324 KListItemFormatGraphicNone, |
|
325 Min( At( aIndex )->Name().Length(), |
|
326 KMaxListItemNameLength ), |
|
327 &At( aIndex )->Name() |
|
328 ); |
|
329 } |
|
330 } |
|
331 else |
|
332 { |
|
333 aBuf.Format( |
|
334 KListItemFormatGraphicNone, |
|
335 Min( At( aIndex )->Name().Length(), |
|
336 KMaxListItemNameLength ), |
|
337 &At( aIndex )->Name() |
|
338 ); |
|
339 } |
|
340 break; |
|
341 } |
|
342 default: |
|
343 { |
|
344 __ASSERT_DEBUG( EFalse, Panic( EInvalidBitmapType ) ); |
|
345 break; |
|
346 } |
|
347 } |
|
348 |
|
349 APSETUILOGGER_LEAVEFN( EListbox,"SelListboxModel::FormatListboxText") |
|
350 } |
|
351 |
|
352 // End of File |
|