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 session 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 "locsuplsessionlbmodel.h" |
|
29 #include "locsuplsettingsuiengine.h" |
|
30 #include "locsupldebug.h" |
|
31 |
|
32 // Constants |
|
33 |
|
34 const TInt KMaxConversionBufferLength = 0x200; |
|
35 const TInt KSessionEntryGranularity = 10; |
|
36 |
|
37 |
|
38 // ========================= MEMBER FUNCTIONS ================================ |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CLocSUPLSessionLBModel::CLocSUPLSessionLBModel |
|
42 // Default Constructor |
|
43 // |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CLocSUPLSessionLBModel::CLocSUPLSessionLBModel( |
|
47 CLocSUPLSettingsUiEngine& aEngine ) |
|
48 : iEngine( aEngine ), |
|
49 iSessionIdList( KSessionEntryGranularity ), |
|
50 iSessionTypeList( KSessionEntryGranularity ) |
|
51 { |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CLocSUPLSessionLBModel::~CLocSUPLSessionLBModel |
|
56 // Destructor |
|
57 // |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CLocSUPLSessionLBModel::~CLocSUPLSessionLBModel() |
|
61 { |
|
62 DEBUG( + CLocSUPLSessionLBModel::~CLocSUPLSessionLBModel ); |
|
63 |
|
64 iSessionNameList.ResetAndDestroy(); |
|
65 iSessionNameList.Close(); |
|
66 iSessionIdList.Close(); |
|
67 iSessionTypeList.Close(); |
|
68 |
|
69 delete iUnnamedSuplActiveSessions; |
|
70 iUnnamedSuplActiveSessions = NULL; |
|
71 |
|
72 // Delete the Buffers |
|
73 delete iBuffer; |
|
74 iBuffer = NULL; |
|
75 DEBUG( - CLocSUPLSessionLBModel::~CLocSUPLSessionLBModel ); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CLocSUPLSessionLBModel* CLocSUPLSessionLBModel::NewL |
|
80 // Two-phased constructor |
|
81 // |
|
82 // @param aEngine Reference the SUPL Settings Engine |
|
83 // @return CLocSUPLSessionLBModel* Reference to the object created |
|
84 // |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 CLocSUPLSessionLBModel* CLocSUPLSessionLBModel::NewL( |
|
88 CLocSUPLSettingsUiEngine& aEngine ) |
|
89 { |
|
90 DEBUG( + CLocSUPLSessionLBModel::NewL ); |
|
91 CLocSUPLSessionLBModel* self = CLocSUPLSessionLBModel::NewLC( aEngine ); |
|
92 CleanupStack::Pop( self ); |
|
93 DEBUG( - CLocSUPLSessionLBModel::NewL ); |
|
94 return self; |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CLocSUPLSessionLBModel* CLocSUPLSessionLBModel::NewLC |
|
99 // Two-phased constructor |
|
100 // |
|
101 // @param aEngine Reference the SUPL Settings Engine |
|
102 // @return CLocSUPLSessionLBModel* Reference to the object created |
|
103 // |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 CLocSUPLSessionLBModel* CLocSUPLSessionLBModel::NewLC( |
|
107 CLocSUPLSettingsUiEngine& aEngine ) |
|
108 { |
|
109 CLocSUPLSessionLBModel* self = |
|
110 new ( ELeave ) CLocSUPLSessionLBModel( aEngine ); |
|
111 CleanupStack::PushL( self ); |
|
112 self->ConstructL(); |
|
113 return self; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // void CLocSUPLSessionLBModel::ConstructL |
|
118 // Second Phase of the two phase constructor. |
|
119 // |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 void CLocSUPLSessionLBModel::ConstructL() |
|
123 { |
|
124 DEBUG( + CLocSUPLSessionLBModel::ConstructL ); |
|
125 // Allocate the Conversion Buffer |
|
126 iBuffer = HBufC16::NewL( KMaxConversionBufferLength ); |
|
127 |
|
128 iUnnamedSuplActiveSessions = StringLoader::LoadL( R_LOC_SUPL_UNKNOWN_SERVICE ); |
|
129 |
|
130 UpdateSessionIdsL(); |
|
131 DEBUG( - CLocSUPLSessionLBModel::ConstructL ); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // TInt CLocSUPLSessionLBModel::MdcaCount() const |
|
136 // Inherited from MDesCArray. Returns the total number of items in the |
|
137 // Settings description array |
|
138 // |
|
139 // @return TInt The total number of elements in the Settings Description array |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 TInt CLocSUPLSessionLBModel::MdcaCount() const |
|
143 { |
|
144 DEBUG1( CLocSUPLSessionLBModel::MdcaCount= %d, iSessionIdList.Count() ); |
|
145 return iSessionIdList.Count(); |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // TPtrC16 CLocSUPLSessionLBModel::MdcaPoint() const |
|
150 // Inherited from MDesCArray. Returns the list box entry corresponding to the |
|
151 // index value |
|
152 // |
|
153 // @param aIndex The index whose list box entry needs to be retrieved |
|
154 // @return TPtr16 The list box description |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 TPtrC16 CLocSUPLSessionLBModel::MdcaPoint( TInt aIndex ) const |
|
158 { |
|
159 DEBUG1( + CLocSUPLSessionLBModel::MdcaPoint =%d, aIndex ); |
|
160 |
|
161 // Zero the internal buffer |
|
162 TPtr16 ptr( iBuffer->Des() ); |
|
163 ptr.Zero(); |
|
164 |
|
165 AppendSuplSessionDetail( ptr, aIndex ); |
|
166 |
|
167 DEBUG( - CLocSUPLSessionLBModel::MdcaPoint ); |
|
168 return iBuffer->Des(); |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // CLocSUPLSessionLBModel::AppendSuplSessionDetail() |
|
173 // Packs the session name and type to the buffer passed. |
|
174 // |
|
175 // @param aPtr Buffer to which session name and type will be appended. |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CLocSUPLSessionLBModel::AppendSuplSessionDetail( TDes& aPtr, TInt aIndex ) const |
|
179 { |
|
180 DEBUG( + CLocSUPLSessionLBModel::AppendSuplSessionDetail ); |
|
181 |
|
182 _LIT(KItemString, "%d\t%S\t\t" ); |
|
183 |
|
184 RBuf sessionName; |
|
185 if( iSessionNameList[aIndex]->Length() ) |
|
186 { |
|
187 TRAP_IGNORE( sessionName.CreateL( *iSessionNameList[ aIndex ] ) ); |
|
188 } |
|
189 else |
|
190 { |
|
191 TRAP_IGNORE( sessionName.CreateL( *iUnnamedSuplActiveSessions ) ); |
|
192 } |
|
193 |
|
194 if( iSessionTypeList[ aIndex ] ) |
|
195 { |
|
196 // Format the string |
|
197 aPtr.Format( KItemString, 1, &sessionName ); |
|
198 } |
|
199 else |
|
200 { |
|
201 // Format the string |
|
202 aPtr.Format( KItemString, 2, &sessionName ); |
|
203 } |
|
204 sessionName.Close(); |
|
205 |
|
206 DEBUG( - CLocSUPLSessionLBModel::AppendSuplSessionDetail ); |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // CLocSUPLSessionLBModel::UpdateSessionIdsL() |
|
211 // Packs the server ids to id array |
|
212 // |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 void CLocSUPLSessionLBModel::UpdateSessionIdsL() |
|
216 { |
|
217 DEBUG( + CLocSUPLSessionLBModel::UpdateSessionIdsL ); |
|
218 |
|
219 iSessionIdList.Reset(); |
|
220 iSessionNameList.ResetAndDestroy(); |
|
221 iSessionTypeList.Reset(); |
|
222 |
|
223 RPointerArray< CTriggerParams > sessionList; |
|
224 |
|
225 // Get all session entries |
|
226 iEngine.GetTriggerParamsL( sessionList ); |
|
227 |
|
228 for( TInt i = 0; i < sessionList.Count() ; i++ ) |
|
229 { |
|
230 TInt64 sessionId; |
|
231 TUint64 outstandingTrigger; |
|
232 TUint64 interval; |
|
233 HBufC* sessionName = HBufC::NewL( KMaxTriggerSessionNameLen ); |
|
234 CleanupStack::PushL( sessionName ); |
|
235 TBool notificationPresent; |
|
236 TBool triggerNotificationStatus; |
|
237 CTriggerParams::TTriggerType triggerType; |
|
238 CTriggerParams::TRequestType requestType; |
|
239 |
|
240 |
|
241 TInt errParams = sessionList[i]->Get( |
|
242 sessionId, |
|
243 sessionName->Des(), |
|
244 notificationPresent, |
|
245 triggerNotificationStatus, |
|
246 triggerType, |
|
247 requestType, |
|
248 outstandingTrigger, |
|
249 interval); |
|
250 |
|
251 if ( errParams != KErrNone ) |
|
252 { |
|
253 // Error has occured |
|
254 } |
|
255 |
|
256 iSessionIdList.Append( sessionId ); |
|
257 iSessionNameList.Append( sessionName->AllocL() ); |
|
258 switch( triggerType ) |
|
259 { |
|
260 case CTriggerParams::EPeriodic: |
|
261 iSessionTypeList.Append( ESUPLSessionTIType ); |
|
262 break; |
|
263 case CTriggerParams::EAreaEvent: |
|
264 iSessionTypeList.Append( ESUPLSessionNIType ); |
|
265 break; |
|
266 case CTriggerParams::EUnknown: |
|
267 default: |
|
268 iSessionTypeList.Append( ESUPLSessionTIType ); |
|
269 break; |
|
270 } |
|
271 |
|
272 CleanupStack::PopAndDestroy( sessionName ); |
|
273 } |
|
274 sessionList.ResetAndDestroy(); |
|
275 sessionList.Close(); |
|
276 |
|
277 DEBUG( - CLocSUPLSessionLBModel::UpdateSessionIdsL ); |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // CLocSUPLSessionLBModel::SlpIds() |
|
282 // returns server id array |
|
283 // |
|
284 // --------------------------------------------------------------------------- |
|
285 // |
|
286 RArray<TInt64>& CLocSUPLSessionLBModel::SessionIds() |
|
287 { |
|
288 DEBUG( CLocSUPLSessionLBModel::SessionIds ); |
|
289 return iSessionIdList; |
|
290 } |
|
291 |
|
292 // --------------------------------------------------------------------------- |
|
293 // CLocSUPLSessionLBModel::CurrentSessionName() |
|
294 // Get the currently focused session name |
|
295 // |
|
296 // --------------------------------------------------------------------------- |
|
297 // |
|
298 TPtrC CLocSUPLSessionLBModel::SessionName(TInt aIndex) |
|
299 { |
|
300 if( iSessionNameList[aIndex]->Length() ) |
|
301 { |
|
302 return iSessionNameList[aIndex]->Des(); |
|
303 } |
|
304 else |
|
305 { |
|
306 return *iUnnamedSuplActiveSessions; |
|
307 } |
|
308 } |
|
309 |
|
310 // End of file |
|