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 |
{
|
|
233 |
TSettingItem setting = { KErrNotFound, EApplication , EFalse };
|
|
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 );
|
|
246 |
|
|
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 |
{
|
|
405 |
TPtrC view = aMenuItem.GetAttributeL( KMenuAttrView, exists );
|
|
406 |
if( exists && view.Length() > 0 )
|
|
407 |
{
|
|
408 |
HBufC8* view8( NULL );
|
|
409 |
view8 = AiUtility::CopyToBufferL( view8, view );
|
|
410 |
CleanupStack::PushL( view8 );
|
|
411 |
properties[i]->SetValueL( *view8 );
|
|
412 |
CleanupStack::PopAndDestroy( view8 );
|
|
413 |
}
|
|
414 |
else
|
|
415 |
{
|
|
416 |
properties[ i ]->SetValueL( KNullDesC8 );
|
|
417 |
}
|
|
418 |
}
|
|
419 |
else if ( properties[ i ]->Name() == KProperNameParam )
|
|
420 |
{
|
|
421 |
TPtrC param = aMenuItem.GetAttributeL( KMenuAttrParam, exists );
|
|
422 |
TBool isFolder = EFalse;
|
|
423 |
TPtrC type = aMenuItem.Type();
|
|
424 |
|
|
425 |
// is the item folder or suite?
|
|
426 |
|
|
427 |
if ( type == KMenuTypeFolder )
|
|
428 |
{
|
|
429 |
isFolder = ETrue;
|
|
430 |
}
|
|
431 |
|
|
432 |
if ( (exists && param.Length() > 0) || (isFolder) )
|
|
433 |
{
|
|
434 |
// the folder id is stored
|
|
435 |
// in param attribute in HSPS
|
|
436 |
if ( isFolder )
|
|
437 |
{
|
|
438 |
TBuf<8> number;
|
|
439 |
number.Num( aMenuItem.Id() );
|
|
440 |
param.Set( number );
|
|
441 |
}
|
|
442 |
|
|
443 |
HBufC8* param8( NULL );
|
|
444 |
param8 = AiUtility::CopyToBufferL( param8, param );
|
|
445 |
CleanupStack::PushL( param8 );
|
|
446 |
properties[ i ]->SetValueL( *param8 );
|
|
447 |
CleanupStack::PopAndDestroy( param8 );
|
|
448 |
}
|
|
449 |
else
|
|
450 |
{
|
|
451 |
properties[ i ]->SetValueL( KNullDesC8 );
|
|
452 |
}
|
|
453 |
}
|
|
454 |
else if ( properties[ i ]->Name() == KProperNameLocked )
|
|
455 |
{
|
|
456 |
TPtrC locked = aMenuItem.GetAttributeL( KMenuAttrLocked, exists );
|
|
457 |
if ( exists && locked.Length() > 0 )
|
|
458 |
{
|
|
459 |
HBufC8* locked8( NULL );
|
|
460 |
locked8 = AiUtility::CopyToBufferL( locked8, locked );
|
|
461 |
CleanupStack::PushL( locked8 );
|
|
462 |
properties[ i ]->SetValueL( *locked8 );
|
|
463 |
CleanupStack::PopAndDestroy( locked8 );
|
|
464 |
}
|
|
465 |
else
|
|
466 |
{
|
|
467 |
properties[i]->SetValueL( KNullDesC8 );
|
|
468 |
}
|
|
469 |
}
|
|
470 |
}
|
|
471 |
}
|
|
472 |
|
|
473 |
// ETrue tells that modified settings are stored also to plugin reference
|
|
474 |
User::LeaveIfError( iPluginSettings->SetSettingsL( *iPluginId, settingItems, ETrue ) );
|
|
475 |
CleanupStack::PopAndDestroy(); // settingItems
|
|
476 |
}
|
|
477 |
|
|
478 |
// ---------------------------------------------------------------------------
|
|
479 |
// Updates settings container.
|
|
480 |
// ---------------------------------------------------------------------------
|
|
481 |
//
|
|
482 |
void CMCSPluginSettingsModel::SetPluginIdL( const TDesC8& aPluginId )
|
|
483 |
{
|
|
484 |
delete iPluginId;
|
|
485 |
iPluginId = NULL;
|
|
486 |
iPluginId = aPluginId.AllocL();
|
|
487 |
}
|
|
488 |
|
|
489 |
// ---------------------------------------------------------------------------
|
|
490 |
// From MDesCArray
|
|
491 |
// Returns the number of descriptor elements in a descriptor array.
|
|
492 |
// ---------------------------------------------------------------------------
|
|
493 |
//
|
|
494 |
TInt CMCSPluginSettingsModel::MdcaCount() const
|
|
495 |
{
|
|
496 |
return iSettings.Count();
|
|
497 |
}
|
|
498 |
|
|
499 |
// ---------------------------------------------------------------------------
|
|
500 |
// From MDesCArray
|
|
501 |
// Indexes into a descriptor array.
|
|
502 |
// ---------------------------------------------------------------------------
|
|
503 |
//
|
|
504 |
TPtrC CMCSPluginSettingsModel::MdcaPoint( TInt aIndex ) const
|
|
505 |
{
|
|
506 |
if (aIndex < 0 || aIndex >= iSettings.Count())
|
|
507 |
{
|
|
508 |
TPtrC ret(KNullDesC);
|
|
509 |
return ret;
|
|
510 |
}
|
|
511 |
|
|
512 |
TPtrC line( KNullDesC );
|
|
513 |
if ( iSettings[aIndex].type == EApplication )
|
|
514 |
{
|
|
515 |
// first, we need to check if the item is missing
|
|
516 |
// (application uninstalled or mmc card removed)
|
|
517 |
// If it is, we return "Undefined" application name instead
|
|
518 |
if ( iSettings[ aIndex ].id == KErrNotFound )
|
|
519 |
{
|
|
520 |
const TDesC& caption = iAppList->UndefinedText();
|
|
521 |
TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) )
|
|
522 |
}
|
|
523 |
else
|
|
524 |
{
|
|
525 |
const TDesC& caption = iAppList->MdcaPoint( iSettings[ aIndex ].id );
|
|
526 |
TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) )
|
|
527 |
}
|
|
528 |
}
|
|
529 |
else
|
|
530 |
{
|
|
531 |
const TDesC& caption = iBkmList->MdcaPoint( iSettings[aIndex].id );
|
|
532 |
TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) )
|
|
533 |
}
|
|
534 |
|
|
535 |
return line;
|
|
536 |
}
|
|
537 |
|
|
538 |
// ---------------------------------------------------------------------------
|
|
539 |
// Returns a setting ID for the given index.
|
|
540 |
// ---------------------------------------------------------------------------
|
|
541 |
//
|
|
542 |
TInt CMCSPluginSettingsModel::ItemId( TInt aIndex ) const
|
|
543 |
{
|
|
544 |
if ( aIndex >= 0 && aIndex < iSettings.Count() )
|
|
545 |
{
|
|
546 |
return iSettings[ aIndex ].id;
|
|
547 |
}
|
|
548 |
|
|
549 |
return KErrNotFound;
|
|
550 |
}
|
|
551 |
|
|
552 |
// ---------------------------------------------------------------------------
|
|
553 |
// Returns a pointer to setting item for the given index
|
|
554 |
// ---------------------------------------------------------------------------
|
|
555 |
//
|
|
556 |
const TSettingItem CMCSPluginSettingsModel::Item( TInt aIndex ) const
|
|
557 |
{
|
|
558 |
TSettingItem setting = { KErrNotFound, EApplication, EFalse };
|
|
559 |
|
|
560 |
if ( aIndex >= 0 && aIndex < iSettings.Count() )
|
|
561 |
{
|
|
562 |
setting = iSettings[ aIndex ];
|
|
563 |
}
|
|
564 |
|
|
565 |
return setting;
|
|
566 |
}
|
|
567 |
|
|
568 |
// ---------------------------------------------------------------------------
|
|
569 |
// Replaces shortcut item at given index by a new one.
|
|
570 |
// ---------------------------------------------------------------------------
|
|
571 |
//
|
|
572 |
TBool CMCSPluginSettingsModel::ReplaceItemL( const TInt& aSettingIndex,
|
|
573 |
TInt aId,
|
|
574 |
TSettingType aType )
|
|
575 |
{
|
|
576 |
TBool replaced( EFalse );
|
|
577 |
if (aSettingIndex >= 0 && aSettingIndex < iSettings.Count())
|
|
578 |
{
|
|
579 |
CMenuItem* item( NULL );
|
|
580 |
if ( aType == EApplication )
|
|
581 |
{
|
|
582 |
item = iAppList->ItemL( aId );
|
|
583 |
}
|
|
584 |
else
|
|
585 |
{
|
|
586 |
item = iBkmList->ItemL( aId );
|
|
587 |
}
|
|
588 |
|
|
589 |
if ( item )
|
|
590 |
{
|
|
591 |
SaveSettingsL( aSettingIndex, *item );
|
|
592 |
iSettings[ aSettingIndex ].id = aId;
|
|
593 |
iSettings[ aSettingIndex ].type = aType;
|
|
594 |
replaced = ETrue;
|
|
595 |
}
|
|
596 |
}
|
|
597 |
return replaced;
|
|
598 |
}
|
|
599 |
|
|
600 |
// ---------------------------------------------------------------------------
|
|
601 |
// Sets a container
|
|
602 |
// ---------------------------------------------------------------------------
|
|
603 |
//
|
|
604 |
void CMCSPluginSettingsModel::SetContainer(CMCSPluginSettingsContainer* aContainer)
|
|
605 |
{
|
|
606 |
iContainer = aContainer;
|
|
607 |
}
|
|
608 |
|
|
609 |
// ---------------------------------------------------------------------------
|
|
610 |
// Returns application list
|
|
611 |
// ---------------------------------------------------------------------------
|
|
612 |
//
|
|
613 |
CMCSPluginSettingsAppList* CMCSPluginSettingsModel::AppList()
|
|
614 |
{
|
|
615 |
return iAppList;
|
|
616 |
}
|
|
617 |
|
|
618 |
// ---------------------------------------------------------------------------
|
|
619 |
// Returns bookmarklist
|
|
620 |
// ---------------------------------------------------------------------------
|
|
621 |
//
|
|
622 |
CMCSPluginSettingsBkmList* CMCSPluginSettingsModel::BkmList()
|
|
623 |
{
|
|
624 |
return iBkmList;
|
|
625 |
}
|
|
626 |
|
|
627 |
// ---------------------------------------------------------------------------
|
|
628 |
// Updates application list
|
|
629 |
// ---------------------------------------------------------------------------
|
|
630 |
//
|
|
631 |
void CMCSPluginSettingsModel::UpdateAppListL( TBool aUpdateSettings )
|
|
632 |
{
|
|
633 |
if( !iAppList )
|
|
634 |
{
|
|
635 |
iAppList = CMCSPluginSettingsAppList::NewL();
|
|
636 |
}
|
|
637 |
iAppList->StartL();
|
|
638 |
if ( aUpdateSettings )
|
|
639 |
{
|
|
640 |
UpdateSettingsL();
|
|
641 |
}
|
|
642 |
}
|
|
643 |
|
|
644 |
// ---------------------------------------------------------------------------
|
|
645 |
// Updates bookmark list
|
|
646 |
// ---------------------------------------------------------------------------
|
|
647 |
//
|
|
648 |
void CMCSPluginSettingsModel::UpdateBkmListL( TBool aUpdateSettings )
|
|
649 |
{
|
|
650 |
delete iBkmList;
|
|
651 |
iBkmList = NULL;
|
|
652 |
iBkmList = CMCSPluginSettingsBkmList::NewL();
|
|
653 |
if ( aUpdateSettings )
|
|
654 |
{
|
|
655 |
UpdateSettingsL();
|
|
656 |
}
|
|
657 |
}
|
|
658 |
|
|
659 |
// End of File.
|