author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:53:46 +0300 | |
branch | RCL_3 |
changeset 130 | 67f2ed48ad91 |
parent 118 | 8baec10861af |
permissions | -rw-r--r-- |
114 | 1 |
/* |
2 |
* Copyright (c) 2009 - 2010 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: MCS settings plug-in model. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <eikenv.h> |
|
19 |
#include <itemmap.h> |
|
20 |
#include <mhomescreensettingsif.h> |
|
21 |
#include <aistrcnv.h> |
|
22 |
#include <StringLoader.h> |
|
23 |
#include <uri16.h> |
|
24 |
#include <mcspluginsettingsres.rsg> |
|
25 |
#include <mcsmenuitem.h> |
|
26 |
||
27 |
#include "mcspluginsettingsmodel.h" |
|
28 |
#include "mcspluginsettingsapplist.h" |
|
29 |
#include "mcspluginsettingsbkmlist.h" |
|
30 |
#include "mcspluginsettingscontainer.h" |
|
31 |
||
32 |
||
33 |
/** |
|
34 |
* Line format for the settings list box |
|
35 |
*/ |
|
36 |
_LIT(KSettingListboxLineFormat, " \t%S\t\t%S"); |
|
37 |
_LIT( KMenuAttrParam, "param"); |
|
38 |
_LIT( KMenuAttrLocked, "locked"); |
|
39 |
_LIT8( KTrue, "true" ); |
|
40 |
_LIT8( KAppUid, "271012080" ); |
|
41 |
_LIT8( KProperNameType, "type" ); |
|
42 |
_LIT8( KProperNameParam, "param" ); |
|
43 |
_LIT8( KProperNameUid, "uid" ); |
|
44 |
_LIT8( KProperNameView, "view" ); |
|
45 |
_LIT8( KProperNameLocked, "locked" ); |
|
46 |
_LIT8( KProperValueFolder, "folder" ); |
|
47 |
_LIT8( KProperValueSuite, "suite" ); |
|
48 |
_LIT8( KProperValueBookmark, "bookmark" ); |
|
49 |
_LIT8( KProperValueAppl, "application" ); |
|
50 |
_LIT8( KProperValueMailbox, "mailbox" ); |
|
51 |
_LIT( KMenuTypeMailbox, "menu:mailbox" ); |
|
52 |
||
53 |
using namespace HSPluginSettingsIf; |
|
54 |
||
55 |
// ======== LOCAL FUNCTIONS ======== |
|
56 |
||
57 |
// ---------------------------------------------------------------------------- |
|
58 |
// CleanupResetAndDestroy() |
|
59 |
// ---------------------------------------------------------------------------- |
|
60 |
// |
|
61 |
template<class T> |
|
62 |
static void CleanupResetAndDestroy( TAny* aObj ) |
|
63 |
{ |
|
64 |
if( aObj ) |
|
65 |
{ |
|
66 |
static_cast<T*>( aObj )->ResetAndDestroy(); |
|
67 |
} |
|
68 |
} |
|
69 |
||
70 |
// ---------------------------------------------------------------------------- |
|
71 |
// CleanupResetAndDestroyPushL |
|
72 |
// ---------------------------------------------------------------------------- |
|
73 |
// |
|
74 |
template<class T> |
|
75 |
static void CleanupResetAndDestroyPushL(T& aArray) |
|
76 |
{ |
|
77 |
CleanupStack::PushL( TCleanupItem( &CleanupResetAndDestroy<T>, &aArray ) ); |
|
78 |
} |
|
79 |
||
80 |
// ======== MEMBER FUNCTIONS ======== |
|
81 |
||
82 |
// ----------------------------------------------------------------------------- |
|
83 |
// Creates a formatted listbox line. |
|
84 |
// ----------------------------------------------------------------------------- |
|
85 |
// |
|
86 |
TPtrC CMCSPluginSettingsModel::ListBoxLineL( const TDesC& aCaption, TInt aIndex ) const |
|
87 |
{ |
|
88 |
HBufC* title = StringLoader::LoadLC( |
|
89 |
R_AI_MCS_SETTINGS_TXT_LINKN, aIndex + 1, iEnv ); |
|
90 |
||
91 |
TPtrC caption; |
|
92 |
caption.Set(aCaption); |
|
93 |
||
94 |
TUriParser parser; |
|
95 |
TInt err = parser.Parse(aCaption); |
|
96 |
if (err == KErrNone) |
|
97 |
{ |
|
98 |
// Remove scheme from the url. |
|
99 |
const TDesC& host = parser.Extract(EUriHost); |
|
100 |
if (host.Length()) |
|
101 |
{ |
|
102 |
caption.Set(host); |
|
103 |
} |
|
104 |
} |
|
105 |
||
106 |
// Format (" \t%S\t\t%S") without %S characters. |
|
107 |
TInt formatLength = KSettingListboxLineFormat().Length(); |
|
108 |
||
109 |
HBufC* listBoxLine = |
|
110 |
HBufC::NewLC( title->Length() + |
|
111 |
caption.Length() + |
|
112 |
formatLength ); |
|
113 |
||
114 |
TPtr ptr = listBoxLine->Des(); |
|
115 |
ptr.Format(KSettingListboxLineFormat, title, &caption); |
|
116 |
||
117 |
delete iListBoxLine; |
|
118 |
iListBoxLine = NULL; |
|
119 |
iListBoxLine = listBoxLine; |
|
120 |
CleanupStack::Pop(listBoxLine); |
|
121 |
CleanupStack::PopAndDestroy(title); |
|
122 |
return *iListBoxLine; |
|
123 |
} |
|
124 |
||
125 |
// ======== MEMBER FUNCTIONS ======== |
|
126 |
||
127 |
// --------------------------------------------------------------------------- |
|
128 |
// Two phased constructor |
|
129 |
// --------------------------------------------------------------------------- |
|
130 |
// |
|
131 |
CMCSPluginSettingsModel* CMCSPluginSettingsModel::NewL( CMCSPluginSettings& aPlugin, |
|
132 |
CCoeEnv* aEnv) |
|
133 |
{ |
|
134 |
CMCSPluginSettingsModel* self = new (ELeave) CMCSPluginSettingsModel(aPlugin, aEnv); |
|
135 |
||
136 |
CleanupStack::PushL(self); |
|
137 |
self->ConstructL(); |
|
138 |
CleanupStack::Pop(self); |
|
139 |
||
140 |
return self; |
|
141 |
} |
|
142 |
||
143 |
// --------------------------------------------------------------------------- |
|
144 |
// First phase construction |
|
145 |
// --------------------------------------------------------------------------- |
|
146 |
// |
|
147 |
CMCSPluginSettingsModel::CMCSPluginSettingsModel( CMCSPluginSettings& aPlugin, |
|
148 |
CCoeEnv* aEnv ) |
|
149 |
: iPlugin( aPlugin ), |
|
150 |
iEnv( aEnv ) |
|
151 |
{ |
|
152 |
} |
|
153 |
||
154 |
// --------------------------------------------------------------------------- |
|
155 |
// Destructor |
|
156 |
// --------------------------------------------------------------------------- |
|
157 |
// |
|
158 |
CMCSPluginSettingsModel::~CMCSPluginSettingsModel() |
|
159 |
{ |
|
160 |
delete iAppList; |
|
161 |
delete iBkmList; |
|
162 |
iSettings.Reset(); |
|
163 |
delete iPluginId; |
|
164 |
delete iListBoxLine; |
|
165 |
||
166 |
CHomescreenSettings::UnInitialize(); |
|
167 |
iPluginSettings = NULL; |
|
168 |
} |
|
169 |
||
170 |
// --------------------------------------------------------------------------- |
|
171 |
// Second phase construction |
|
172 |
// --------------------------------------------------------------------------- |
|
173 |
// |
|
174 |
void CMCSPluginSettingsModel::ConstructL() |
|
175 |
{ |
|
176 |
CHomescreenSettings::InitializeL( KAppUid ); |
|
177 |
||
178 |
iPluginSettings = CHomescreenSettings::Instance(); |
|
179 |
if( iPluginSettings == NULL ) |
|
180 |
{ |
|
181 |
User::Leave( KErrUnknown ); |
|
182 |
} |
|
183 |
} |
|
184 |
||
185 |
// --------------------------------------------------------------------------- |
|
186 |
// Gets the latest settings from HSPS and updates |
|
187 |
// --------------------------------------------------------------------------- |
|
188 |
// |
|
189 |
void CMCSPluginSettingsModel::UpdateSettingsL() |
|
190 |
{ |
|
191 |
iSettings.Reset(); |
|
192 |
if( !iPluginId ) |
|
193 |
{ |
|
194 |
return; |
|
195 |
} |
|
196 |
||
197 |
if (iContainer) |
|
198 |
{ |
|
199 |
iContainer->CloseChangeDialog(); |
|
200 |
} |
|
201 |
||
202 |
RPointerArray<CItemMap> settingItems; |
|
203 |
CleanupResetAndDestroyPushL( settingItems ); |
|
204 |
||
205 |
User::LeaveIfError( |
|
206 |
iPluginSettings->GetSettingsL( *iPluginId, settingItems ) ); |
|
207 |
||
208 |
for ( TInt i = 0; i < settingItems.Count(); i++ ) |
|
209 |
{ |
|
210 |
CItemMap* itemMap = settingItems[i]; |
|
211 |
// get properties |
|
212 |
RPointerArray<HSPluginSettingsIf::CPropertyMap>& properties |
|
213 |
= itemMap->Properties(); |
|
214 |
TSettingItem item = ItemL( properties ); |
|
215 |
iSettings.AppendL( item ); |
|
216 |
} |
|
217 |
||
218 |
CleanupStack::PopAndDestroy(); // settingItems |
|
219 |
||
220 |
if (iContainer) |
|
221 |
{ |
|
222 |
iContainer->ResetCurrentListL(0); |
|
223 |
} |
|
224 |
} |
|
225 |
||
226 |
// --------------------------------------------------------------------------- |
|
227 |
// Tries to find menuitem which matches given HSPS entry |
|
228 |
// --------------------------------------------------------------------------- |
|
229 |
// |
|
230 |
TSettingItem CMCSPluginSettingsModel::ItemL( |
|
231 |
RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties ) |
|
232 |
{ |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
118
diff
changeset
|
233 |
TSettingItem setting = { KErrNotFound, EApplication , EFalse }; |
114 | 234 |
|
235 |
TSettingType type = SettingTypeL( aProperties ); |
|
236 |
if ( type == EApplication || type == EMailbox ) |
|
237 |
{ |
|
238 |
setting = iAppList->FindItemL( aProperties ); |
|
239 |
} |
|
240 |
else if ( type == EBookmark ) |
|
241 |
{ |
|
242 |
setting = iBkmList->FindItemL( aProperties ); |
|
243 |
} |
|
244 |
||
245 |
setting.locked = SettingLockedL( aProperties ); |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
118
diff
changeset
|
246 |
|
114 | 247 |
return setting; |
248 |
} |
|
249 |
||
250 |
// --------------------------------------------------------------------------- |
|
251 |
// Gets Type (application or bookmark) of given HSPS entry |
|
252 |
// --------------------------------------------------------------------------- |
|
253 |
// |
|
254 |
TSettingType CMCSPluginSettingsModel::SettingTypeL( |
|
255 |
RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties ) |
|
256 |
{ |
|
257 |
TSettingType type( EApplication ); |
|
258 |
||
259 |
for( TInt i = 0; i < aProperties.Count(); i++ ) |
|
260 |
{ |
|
261 |
TPtrC8 name = aProperties[i]->Name(); |
|
262 |
if( name == KProperNameType ) |
|
263 |
{ |
|
264 |
TPtrC8 value = aProperties[i]->Value(); |
|
265 |
if( value == KProperValueBookmark ) |
|
266 |
{ |
|
267 |
type = EBookmark; |
|
268 |
} |
|
269 |
else |
|
270 |
{ |
|
271 |
type = EApplication; |
|
272 |
} |
|
273 |
} |
|
274 |
} |
|
275 |
||
276 |
return type; |
|
277 |
} |
|
278 |
||
279 |
// --------------------------------------------------------------------------- |
|
280 |
// Gets locking status of given HSPS entry |
|
281 |
// --------------------------------------------------------------------------- |
|
282 |
// |
|
283 |
TBool CMCSPluginSettingsModel::SettingLockedL( |
|
284 |
RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties ) |
|
285 |
{ |
|
286 |
||
287 |
for( TInt i = 0; i <aProperties.Count(); i++ ) |
|
288 |
{ |
|
289 |
TPtrC8 name = aProperties[i]->Name(); |
|
290 |
if( name == KProperNameLocked ) |
|
291 |
{ |
|
292 |
TPtrC8 value = aProperties[i]->Value(); |
|
293 |
if( value == KTrue ) |
|
294 |
{ |
|
295 |
return ETrue; |
|
296 |
} |
|
297 |
} |
|
298 |
} |
|
299 |
||
300 |
return EFalse; |
|
301 |
} |
|
302 |
||
303 |
// --------------------------------------------------------------------------- |
|
304 |
// Saves menuitem to HSPS to the given shortcut index |
|
305 |
// --------------------------------------------------------------------------- |
|
306 |
// |
|
307 |
void CMCSPluginSettingsModel::SaveSettingsL( const TInt& aIndex, |
|
308 |
CMenuItem& aMenuItem ) |
|
309 |
{ |
|
310 |
if( !iPluginId ) |
|
311 |
{ |
|
312 |
return; |
|
313 |
} |
|
314 |
||
315 |
RPointerArray<CItemMap> settingItems; |
|
316 |
CleanupResetAndDestroyPushL( settingItems ); |
|
317 |
User::LeaveIfError( iPluginSettings->GetSettingsL( *iPluginId, settingItems ) ); |
|
318 |
||
319 |
if ( aIndex >= 0 && aIndex < settingItems.Count() ) |
|
320 |
{ |
|
321 |
TBool exists( EFalse ); |
|
322 |
CItemMap* itemMap = settingItems[ aIndex ]; |
|
323 |
||
324 |
// get properties |
|
325 |
RPointerArray<HSPluginSettingsIf::CPropertyMap>& properties |
|
326 |
= itemMap->Properties(); |
|
327 |
||
328 |
const TInt KGranularity = 6; |
|
329 |
CDesC8Array* propertiesList = new ( ELeave ) CDesC8ArrayFlat( KGranularity ); |
|
330 |
CleanupStack::PushL( propertiesList ); |
|
331 |
propertiesList->AppendL( KProperNameType ); |
|
332 |
propertiesList->AppendL( KProperNameParam ); |
|
333 |
propertiesList->AppendL( KProperNameUid ); |
|
334 |
propertiesList->AppendL( KProperNameView ); |
|
335 |
// skip KProperNameLocked property, attribute may be missing. results into |
|
336 |
// leave with -1 when saving settings |
|
337 |
||
338 |
// add missing properties |
|
339 |
for ( TInt i=0; i<propertiesList->Count(); i++ ) |
|
340 |
{ |
|
341 |
TBool found( EFalse ); |
|
342 |
const TPtrC8 namePtr = propertiesList->MdcaPoint( i ); |
|
343 |
for ( TInt j=0; j<properties.Count() && !found; j++ ) |
|
344 |
{ |
|
345 |
found = ( (namePtr == properties[ j ]->Name() ) ? ETrue : EFalse ); |
|
346 |
} |
|
347 |
if ( !found ) |
|
348 |
{ |
|
349 |
CPropertyMap* property = CPropertyMap::NewLC(); |
|
350 |
property->SetNameL( namePtr ); |
|
351 |
property->SetValueL( KNullDesC8 ); |
|
352 |
itemMap->AddPropertyMapL( property ); |
|
353 |
CleanupStack::Pop( property ); |
|
354 |
||
355 |
// get updated list |
|
356 |
properties = itemMap->Properties(); |
|
357 |
} |
|
358 |
} |
|
359 |
CleanupStack::PopAndDestroy( propertiesList ); |
|
360 |
||
361 |
for ( TInt i = 0; i < properties.Count(); i++ ) |
|
362 |
{ |
|
363 |
if ( properties[ i ]->Name() == KProperNameType ) |
|
364 |
{ |
|
365 |
TPtrC type = aMenuItem.Type(); |
|
366 |
if ( type == KMenuTypeUrl ) |
|
367 |
{ |
|
368 |
properties[ i ]->SetValueL( KProperValueBookmark ); |
|
369 |
} |
|
370 |
else if ( type == KMenuTypeFolder ) |
|
371 |
{ |
|
372 |
properties[ i ]->SetValueL( KProperValueFolder ); |
|
373 |
} |
|
374 |
else if ( type == KMenuTypeSuite ) |
|
375 |
{ |
|
376 |
properties[ i ]->SetValueL( KProperValueSuite ); |
|
377 |
} |
|
378 |
else if( type == KMenuTypeMailbox ) |
|
379 |
{ |
|
380 |
properties[ i ]->SetValueL( KProperValueMailbox ); |
|
381 |
} |
|
382 |
else |
|
383 |
{ |
|
384 |
properties[ i ]->SetValueL( KProperValueAppl ); |
|
385 |
} |
|
386 |
} |
|
387 |
else if ( properties[ i ]->Name() == KProperNameUid ) |
|
388 |
{ |
|
389 |
TPtrC uid = aMenuItem.GetAttributeL( KMenuAttrUid, exists ); |
|
390 |
if ( exists && uid.Length() > 0 ) |
|
391 |
{ |
|
392 |
HBufC8* uid8( NULL ); |
|
393 |
uid8 = AiUtility::CopyToBufferL( uid8, uid ); |
|
394 |
CleanupStack::PushL( uid8 ); |
|
395 |
properties[ i ]->SetValueL( *uid8 ); |
|
396 |
CleanupStack::PopAndDestroy( uid8 ); |
|
397 |
} |
|
398 |
else |
|
399 |
{ |
|
400 |
properties[ i ]->SetValueL( KNullDesC8 ); |
|
401 |
} |
|
402 |
} |
|
403 |
else if ( properties[ i ]->Name() == KProperNameView ) |
|
404 |
{ |
|
118
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
405 |
TPtrC type = aMenuItem.Type(); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
406 |
TPtrC attr; |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
407 |
if ( type == KMenuTypeUrl ) |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
408 |
{ |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
409 |
// In case of bookmark type item, bookmark URL is stored to view property |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
410 |
attr.Set( KMenuAttrUrl ); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
411 |
} |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
412 |
else |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
413 |
{ |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
414 |
attr.Set( KMenuAttrView ); |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
415 |
} |
8baec10861af
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
416 |
TPtrC view = aMenuItem.GetAttributeL( attr, exists ); |
114 | 417 |
if( exists && view.Length() > 0 ) |
418 |
{ |
|
419 |
HBufC8* view8( NULL ); |
|
420 |
view8 = AiUtility::CopyToBufferL( view8, view ); |
|
421 |
CleanupStack::PushL( view8 ); |
|
422 |
properties[i]->SetValueL( *view8 ); |
|
423 |
CleanupStack::PopAndDestroy( view8 ); |
|
424 |
} |
|
425 |
else |
|
426 |
{ |
|
427 |
properties[ i ]->SetValueL( KNullDesC8 ); |
|
428 |
} |
|
429 |
} |
|
430 |
else if ( properties[ i ]->Name() == KProperNameParam ) |
|
431 |
{ |
|
432 |
TPtrC param = aMenuItem.GetAttributeL( KMenuAttrParam, exists ); |
|
433 |
TBool isFolder = EFalse; |
|
434 |
TPtrC type = aMenuItem.Type(); |
|
435 |
||
436 |
// is the item folder or suite? |
|
437 |
||
438 |
if ( type == KMenuTypeFolder ) |
|
439 |
{ |
|
440 |
isFolder = ETrue; |
|
441 |
} |
|
442 |
||
443 |
if ( (exists && param.Length() > 0) || (isFolder) ) |
|
444 |
{ |
|
445 |
// the folder id is stored |
|
446 |
// in param attribute in HSPS |
|
447 |
if ( isFolder ) |
|
448 |
{ |
|
449 |
TBuf<8> number; |
|
450 |
number.Num( aMenuItem.Id() ); |
|
451 |
param.Set( number ); |
|
452 |
} |
|
453 |
||
454 |
HBufC8* param8( NULL ); |
|
455 |
param8 = AiUtility::CopyToBufferL( param8, param ); |
|
456 |
CleanupStack::PushL( param8 ); |
|
457 |
properties[ i ]->SetValueL( *param8 ); |
|
458 |
CleanupStack::PopAndDestroy( param8 ); |
|
459 |
} |
|
460 |
else |
|
461 |
{ |
|
462 |
properties[ i ]->SetValueL( KNullDesC8 ); |
|
463 |
} |
|
464 |
} |
|
465 |
else if ( properties[ i ]->Name() == KProperNameLocked ) |
|
466 |
{ |
|
467 |
TPtrC locked = aMenuItem.GetAttributeL( KMenuAttrLocked, exists ); |
|
468 |
if ( exists && locked.Length() > 0 ) |
|
469 |
{ |
|
470 |
HBufC8* locked8( NULL ); |
|
471 |
locked8 = AiUtility::CopyToBufferL( locked8, locked ); |
|
472 |
CleanupStack::PushL( locked8 ); |
|
473 |
properties[ i ]->SetValueL( *locked8 ); |
|
474 |
CleanupStack::PopAndDestroy( locked8 ); |
|
475 |
} |
|
476 |
else |
|
477 |
{ |
|
478 |
properties[i]->SetValueL( KNullDesC8 ); |
|
479 |
} |
|
480 |
} |
|
481 |
} |
|
482 |
} |
|
483 |
||
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
118
diff
changeset
|
484 |
// ETrue tells that modified settings are stored also to plugin reference |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
118
diff
changeset
|
485 |
User::LeaveIfError( iPluginSettings->SetSettingsL( *iPluginId, settingItems, ETrue ) ); |
114 | 486 |
CleanupStack::PopAndDestroy(); // settingItems |
487 |
} |
|
488 |
||
489 |
// --------------------------------------------------------------------------- |
|
490 |
// Updates settings container. |
|
491 |
// --------------------------------------------------------------------------- |
|
492 |
// |
|
493 |
void CMCSPluginSettingsModel::SetPluginIdL( const TDesC8& aPluginId ) |
|
494 |
{ |
|
495 |
delete iPluginId; |
|
496 |
iPluginId = NULL; |
|
497 |
iPluginId = aPluginId.AllocL(); |
|
498 |
} |
|
499 |
||
500 |
// --------------------------------------------------------------------------- |
|
501 |
// From MDesCArray |
|
502 |
// Returns the number of descriptor elements in a descriptor array. |
|
503 |
// --------------------------------------------------------------------------- |
|
504 |
// |
|
505 |
TInt CMCSPluginSettingsModel::MdcaCount() const |
|
506 |
{ |
|
507 |
return iSettings.Count(); |
|
508 |
} |
|
509 |
||
510 |
// --------------------------------------------------------------------------- |
|
511 |
// From MDesCArray |
|
512 |
// Indexes into a descriptor array. |
|
513 |
// --------------------------------------------------------------------------- |
|
514 |
// |
|
515 |
TPtrC CMCSPluginSettingsModel::MdcaPoint( TInt aIndex ) const |
|
516 |
{ |
|
517 |
if (aIndex < 0 || aIndex >= iSettings.Count()) |
|
518 |
{ |
|
519 |
TPtrC ret(KNullDesC); |
|
520 |
return ret; |
|
521 |
} |
|
522 |
||
523 |
TPtrC line( KNullDesC ); |
|
524 |
if ( iSettings[aIndex].type == EApplication ) |
|
525 |
{ |
|
526 |
// first, we need to check if the item is missing |
|
527 |
// (application uninstalled or mmc card removed) |
|
528 |
// If it is, we return "Undefined" application name instead |
|
529 |
if ( iSettings[ aIndex ].id == KErrNotFound ) |
|
530 |
{ |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
118
diff
changeset
|
531 |
const TDesC& caption = iAppList->UndefinedText(); |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
118
diff
changeset
|
532 |
TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) ) |
114 | 533 |
} |
534 |
else |
|
535 |
{ |
|
536 |
const TDesC& caption = iAppList->MdcaPoint( iSettings[ aIndex ].id ); |
|
537 |
TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) ) |
|
538 |
} |
|
539 |
} |
|
540 |
else |
|
541 |
{ |
|
542 |
const TDesC& caption = iBkmList->MdcaPoint( iSettings[aIndex].id ); |
|
543 |
TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) ) |
|
544 |
} |
|
545 |
||
546 |
return line; |
|
547 |
} |
|
548 |
||
549 |
// --------------------------------------------------------------------------- |
|
550 |
// Returns a setting ID for the given index. |
|
551 |
// --------------------------------------------------------------------------- |
|
552 |
// |
|
553 |
TInt CMCSPluginSettingsModel::ItemId( TInt aIndex ) const |
|
554 |
{ |
|
555 |
if ( aIndex >= 0 && aIndex < iSettings.Count() ) |
|
556 |
{ |
|
557 |
return iSettings[ aIndex ].id; |
|
558 |
} |
|
559 |
||
560 |
return KErrNotFound; |
|
561 |
} |
|
562 |
||
563 |
// --------------------------------------------------------------------------- |
|
564 |
// Returns a pointer to setting item for the given index |
|
565 |
// --------------------------------------------------------------------------- |
|
566 |
// |
|
567 |
const TSettingItem CMCSPluginSettingsModel::Item( TInt aIndex ) const |
|
568 |
{ |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
118
diff
changeset
|
569 |
TSettingItem setting = { KErrNotFound, EApplication, EFalse }; |
114 | 570 |
|
571 |
if ( aIndex >= 0 && aIndex < iSettings.Count() ) |
|
572 |
{ |
|
573 |
setting = iSettings[ aIndex ]; |
|
574 |
} |
|
575 |
||
576 |
return setting; |
|
577 |
} |
|
578 |
||
579 |
// --------------------------------------------------------------------------- |
|
580 |
// Replaces shortcut item at given index by a new one. |
|
581 |
// --------------------------------------------------------------------------- |
|
582 |
// |
|
583 |
TBool CMCSPluginSettingsModel::ReplaceItemL( const TInt& aSettingIndex, |
|
584 |
TInt aId, |
|
585 |
TSettingType aType ) |
|
586 |
{ |
|
587 |
TBool replaced( EFalse ); |
|
588 |
if (aSettingIndex >= 0 && aSettingIndex < iSettings.Count()) |
|
589 |
{ |
|
590 |
CMenuItem* item( NULL ); |
|
591 |
if ( aType == EApplication ) |
|
592 |
{ |
|
593 |
item = iAppList->ItemL( aId ); |
|
594 |
} |
|
595 |
else |
|
596 |
{ |
|
597 |
item = iBkmList->ItemL( aId ); |
|
598 |
} |
|
599 |
||
600 |
if ( item ) |
|
601 |
{ |
|
602 |
SaveSettingsL( aSettingIndex, *item ); |
|
603 |
iSettings[ aSettingIndex ].id = aId; |
|
604 |
iSettings[ aSettingIndex ].type = aType; |
|
605 |
replaced = ETrue; |
|
606 |
} |
|
607 |
} |
|
608 |
return replaced; |
|
609 |
} |
|
610 |
||
611 |
// --------------------------------------------------------------------------- |
|
612 |
// Sets a container |
|
613 |
// --------------------------------------------------------------------------- |
|
614 |
// |
|
615 |
void CMCSPluginSettingsModel::SetContainer(CMCSPluginSettingsContainer* aContainer) |
|
616 |
{ |
|
617 |
iContainer = aContainer; |
|
618 |
} |
|
619 |
||
620 |
// --------------------------------------------------------------------------- |
|
621 |
// Returns application list |
|
622 |
// --------------------------------------------------------------------------- |
|
623 |
// |
|
624 |
CMCSPluginSettingsAppList* CMCSPluginSettingsModel::AppList() |
|
625 |
{ |
|
626 |
return iAppList; |
|
627 |
} |
|
628 |
||
629 |
// --------------------------------------------------------------------------- |
|
630 |
// Returns bookmarklist |
|
631 |
// --------------------------------------------------------------------------- |
|
632 |
// |
|
633 |
CMCSPluginSettingsBkmList* CMCSPluginSettingsModel::BkmList() |
|
634 |
{ |
|
635 |
return iBkmList; |
|
636 |
} |
|
637 |
||
638 |
// --------------------------------------------------------------------------- |
|
639 |
// Updates application list |
|
640 |
// --------------------------------------------------------------------------- |
|
641 |
// |
|
642 |
void CMCSPluginSettingsModel::UpdateAppListL( TBool aUpdateSettings ) |
|
643 |
{ |
|
644 |
if( !iAppList ) |
|
645 |
{ |
|
646 |
iAppList = CMCSPluginSettingsAppList::NewL(); |
|
647 |
} |
|
648 |
iAppList->StartL(); |
|
649 |
if ( aUpdateSettings ) |
|
650 |
{ |
|
651 |
UpdateSettingsL(); |
|
652 |
} |
|
653 |
} |
|
654 |
||
655 |
// --------------------------------------------------------------------------- |
|
656 |
// Updates bookmark list |
|
657 |
// --------------------------------------------------------------------------- |
|
658 |
// |
|
659 |
void CMCSPluginSettingsModel::UpdateBkmListL( TBool aUpdateSettings ) |
|
660 |
{ |
|
661 |
delete iBkmList; |
|
662 |
iBkmList = NULL; |
|
663 |
iBkmList = CMCSPluginSettingsBkmList::NewL(); |
|
664 |
if ( aUpdateSettings ) |
|
665 |
{ |
|
666 |
UpdateSettingsL(); |
|
667 |
} |
|
668 |
} |
|
669 |
||
670 |
// End of File. |