|
1 /* |
|
2 * Copyright (c) 2008 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: List box for the SUPL server UI |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System Includes |
|
20 #include <e32keys.h> |
|
21 #include <locsuplsettingsui.rsg> |
|
22 #include <StringLoader.h> |
|
23 #include <epos_csuplsettings.h> |
|
24 #include <epos_csuplsettingparams.h> |
|
25 #include <epos_csuplsettingsconstants.h> |
|
26 |
|
27 // User Include |
|
28 #include "locsuplserverlbmodel.h" |
|
29 #include "locsuplsettingsuiengine.h" |
|
30 #include "locsupldebug.h" |
|
31 |
|
32 // Constants |
|
33 |
|
34 const TInt KMaxConversionBufferLength = 0x200; |
|
35 const TInt KServerEntryGranularity = 10; |
|
36 |
|
37 |
|
38 // ========================= MEMBER FUNCTIONS ================================ |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CLocSUPLServerLBModel::CLocSUPLServerLBModel |
|
42 // Default Constructor |
|
43 // |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CLocSUPLServerLBModel::CLocSUPLServerLBModel( |
|
47 CLocSUPLSettingsUiEngine& aEngine ) |
|
48 : iEngine( aEngine ), |
|
49 iSlpIdList( KServerEntryGranularity ) |
|
50 { |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CLocSUPLServerLBModel::~CLocSUPLServerLBModel |
|
55 // Destructor |
|
56 // |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CLocSUPLServerLBModel::~CLocSUPLServerLBModel() |
|
60 { |
|
61 DEBUG( + CLocSUPLServerLBModel::~CLocSUPLServerLBModel ); |
|
62 |
|
63 iEnableFlagList.Close(); |
|
64 iSlpAddressList.ResetAndDestroy(); |
|
65 iSlpAddressList.Close(); |
|
66 iSlpIdList.Close(); |
|
67 |
|
68 // Delete the Buffers |
|
69 delete iBuffer; |
|
70 iBuffer = NULL; |
|
71 DEBUG( - CLocSUPLServerLBModel::~CLocSUPLServerLBModel ); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CLocSUPLServerLBModel* CLocSUPLServerLBModel::NewL |
|
76 // Two-phased constructor |
|
77 // |
|
78 // @param aEngine Reference the SUPL Settings Engine |
|
79 // @return CLocSUPLServerLBModel* Reference to the object created |
|
80 // |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 CLocSUPLServerLBModel* CLocSUPLServerLBModel::NewL( |
|
84 CLocSUPLSettingsUiEngine& aEngine ) |
|
85 { |
|
86 DEBUG( + CLocSUPLServerLBModel::NewL ); |
|
87 CLocSUPLServerLBModel* self = CLocSUPLServerLBModel::NewLC( aEngine ); |
|
88 CleanupStack::Pop( self ); |
|
89 DEBUG( - CLocSUPLServerLBModel::NewL ); |
|
90 return self; |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CLocSUPLServerLBModel* CLocSUPLServerLBModel::NewLC |
|
95 // Two-phased constructor |
|
96 // |
|
97 // @param aEngine Reference the SUPL Settings Engine |
|
98 // @return CLocSUPLServerLBModel* Reference to the object created |
|
99 // |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 CLocSUPLServerLBModel* CLocSUPLServerLBModel::NewLC( |
|
103 CLocSUPLSettingsUiEngine& aEngine ) |
|
104 { |
|
105 CLocSUPLServerLBModel* self = |
|
106 new ( ELeave ) CLocSUPLServerLBModel( aEngine ); |
|
107 CleanupStack::PushL( self ); |
|
108 self->ConstructL(); |
|
109 return self; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // void CLocSUPLServerLBModel::ConstructL |
|
114 // Second Phase of the two phase constructor. |
|
115 // |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CLocSUPLServerLBModel::ConstructL() |
|
119 { |
|
120 DEBUG( + CLocSUPLServerLBModel::ConstructL ); |
|
121 // Allocate the Conversion Buffer |
|
122 iBuffer = HBufC16::NewL( KMaxConversionBufferLength ); |
|
123 |
|
124 UpdateSlpIdsL(); |
|
125 DEBUG( - CLocSUPLServerLBModel::ConstructL ); |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // TInt CLocSUPLServerLBModel::MdcaCount() const |
|
130 // Inherited from MDesCArray. Returns the total number of items in the |
|
131 // Settings description array |
|
132 // |
|
133 // @return TInt The total number of elements in the Settings Description array |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 TInt CLocSUPLServerLBModel::MdcaCount() const |
|
137 { |
|
138 DEBUG1( CLocSUPLServerLBModel::MdcaCount= %d, iSlpIdList.Count() ); |
|
139 return iSlpIdList.Count(); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // TPtrC16 CLocSUPLServerLBModel::MdcaPoint() const |
|
144 // Inherited from MDesCArray. Returns the list box entry corresponding to the |
|
145 // index value |
|
146 // |
|
147 // @param aIndex The index whose list box entry needs to be retrieved |
|
148 // @return TPtr16 The list box description |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 TPtrC16 CLocSUPLServerLBModel::MdcaPoint( TInt aIndex ) const |
|
152 { |
|
153 DEBUG1( + CLocSUPLServerLBModel::MdcaPoint =%d, aIndex ); |
|
154 |
|
155 // Zero the internal buffer |
|
156 TPtr16 ptr( iBuffer->Des() ); |
|
157 ptr.Zero(); |
|
158 |
|
159 AppendSuplServerDetail( ptr, aIndex ); |
|
160 |
|
161 DEBUG( - CLocSUPLServerLBModel::MdcaPoint ); |
|
162 return iBuffer->Des(); |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // CLocSUPLServerLBModel::AppendSuplServerDetail() |
|
167 // Packs the server address to the end of the buffer passed. |
|
168 // |
|
169 // @param aPtr Buffer to which the server address needs to be appended. |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 void CLocSUPLServerLBModel::AppendSuplServerDetail( TDes& aPtr, TInt aIndex ) const |
|
173 { |
|
174 DEBUG( + CLocSUPLServerLBModel::AppendSuplServerDetail ); |
|
175 |
|
176 // CAknSingleNumberStyleListBox "2\tTextLabel\t0\t1" |
|
177 |
|
178 _LIT(KItemString, "%d\t%S\t\t" ); |
|
179 _LIT(KItemString2, "%d\t%S\t%d\t" ); |
|
180 |
|
181 RBuf hslpAddr; |
|
182 TRAP_IGNORE( hslpAddr.CreateL( *iSlpAddressList[ aIndex ] ) ); |
|
183 |
|
184 if( iEnableFlagList[ aIndex ] ) |
|
185 { |
|
186 // Format the string |
|
187 aPtr.Format( KItemString, aIndex+1, &hslpAddr ); |
|
188 } |
|
189 else |
|
190 { |
|
191 // Format the string |
|
192 aPtr.Format( KItemString2, aIndex+1, &hslpAddr, ETrue ); |
|
193 } |
|
194 hslpAddr.Close(); |
|
195 |
|
196 DEBUG( - CLocSUPLServerLBModel::AppendSuplServerDetail ); |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // CLocSUPLServerLBModel::UpdateSlpIdsL() |
|
201 // Packs the server ids to id array |
|
202 // |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 void CLocSUPLServerLBModel::UpdateSlpIdsL() |
|
206 { |
|
207 DEBUG( + CLocSUPLServerLBModel::CollectSlpIdsL ); |
|
208 |
|
209 iSlpIdList.Reset(); |
|
210 iSlpAddressList.ResetAndDestroy(); |
|
211 iEnableFlagList.Reset(); |
|
212 |
|
213 if( iEngine.SlpCount() > 0 ) |
|
214 { |
|
215 RPointerArray< CServerParams > serverList; |
|
216 |
|
217 // Get all server entries |
|
218 iEngine.GetAllSlpL( serverList ); |
|
219 |
|
220 for( TInt i = 0; i < serverList.Count() ; i++ ) |
|
221 { |
|
222 TInt64 slpId; |
|
223 HBufC* hslpAddr = HBufC::NewL( KMaxHSLPAddrLen ); |
|
224 HBufC* iapName = HBufC::NewL( KMaxIAPLen ); |
|
225 TBool enabledFlag, simChangeFlag, usageInHomeNwFlag, editFlag; |
|
226 |
|
227 TInt errParams = serverList[i]->Get( |
|
228 slpId, |
|
229 hslpAddr->Des(), |
|
230 iapName->Des(), |
|
231 enabledFlag, |
|
232 simChangeFlag, |
|
233 usageInHomeNwFlag, |
|
234 editFlag |
|
235 ); |
|
236 if ( errParams != KErrNone ) |
|
237 { |
|
238 // Error has occured |
|
239 } |
|
240 |
|
241 iSlpIdList.Append( slpId ); |
|
242 iSlpAddressList.Append( hslpAddr->AllocL() ); |
|
243 iEnableFlagList.Append( enabledFlag ); |
|
244 |
|
245 delete hslpAddr; |
|
246 delete iapName; |
|
247 } |
|
248 serverList.ResetAndDestroy(); |
|
249 serverList.Close(); |
|
250 } |
|
251 DEBUG( - CLocSUPLServerLBModel::CollectSlpIdsL ); |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // CLocSUPLServerLBModel::SlpIds() |
|
256 // returns server id array |
|
257 // |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 RArray<TInt64>& CLocSUPLServerLBModel::SlpIds() |
|
261 { |
|
262 DEBUG( CLocSUPLServerLBModel::SlpIds ); |
|
263 return iSlpIdList; |
|
264 } |
|
265 |
|
266 // End of file |