20
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2007 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:
|
|
15 |
* Phonebook 2 names list control.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "CPbk2SettingsListControl.h"
|
|
22 |
#include "CPbk2NameOrderSettingItem.h"
|
|
23 |
#include "CPbk2MemorySelectionSettingItem.h"
|
|
24 |
#include "CPbk2PredictiveSearchSettingItem.h"
|
|
25 |
#include "CPbk2DefaultSavingStorageSettingItem.h"
|
|
26 |
#include "Pbk2UIControls.hrh"
|
|
27 |
#include "CPbk2SettingsListState.h"
|
|
28 |
#include "Phonebook2PrivateCRKeys.h"
|
|
29 |
|
|
30 |
// From Phonebook 2
|
|
31 |
#include <Pbk2UIControls.rsg>
|
|
32 |
#include <CPbk2UIExtensionManager.h>
|
|
33 |
#include <MPbk2UIExtensionFactory.h>
|
|
34 |
#include <MPbk2SettingsControlExtension.h>
|
|
35 |
#include <CPbk2SortOrderManager.h>
|
|
36 |
|
|
37 |
#include <StringLoader.h>
|
|
38 |
#include <centralrepository.h>
|
|
39 |
#include <featmgr.h>
|
|
40 |
#include <AknFepInternalCRKeys.h>
|
|
41 |
#include <akncheckboxsettingpage.h>
|
|
42 |
#include <sysutil.h>
|
|
43 |
|
|
44 |
//Pbk2Debug
|
|
45 |
#include "Pbk2Debug.h"
|
|
46 |
|
|
47 |
|
|
48 |
// ================= MEMBER FUNCTIONS =======================
|
|
49 |
// -----------------------------------------------------------------------------
|
|
50 |
// CPbk2SettingsListControl::CPbk2SettingsListControl
|
|
51 |
// -----------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
CPbk2SettingsListControl::CPbk2SettingsListControl(
|
|
54 |
CPbk2SortOrderManager& aSortOrderManager,
|
|
55 |
MPbk2SettingsControlExtension& aControlExtension ) :
|
|
56 |
iSortOrderManager( aSortOrderManager ),
|
|
57 |
iControlExtension( aControlExtension )
|
|
58 |
{
|
|
59 |
}
|
|
60 |
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
// CPbk2SettingsListControl::~CPbk2SettingsListControl
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
//
|
|
65 |
CPbk2SettingsListControl::~CPbk2SettingsListControl()
|
|
66 |
{
|
|
67 |
delete iSettingListState;
|
|
68 |
}
|
|
69 |
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
// CPbk2SettingsListControl::NewL
|
|
72 |
// -----------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
EXPORT_C CPbk2SettingsListControl* CPbk2SettingsListControl::NewL(
|
|
75 |
const CCoeControl* aContainer,
|
|
76 |
CPbk2SortOrderManager& aSortOrderManager,
|
|
77 |
MPbk2SettingsControlExtension& aControlExtension )
|
|
78 |
{
|
|
79 |
CPbk2SettingsListControl* self = new (ELeave) CPbk2SettingsListControl(
|
|
80 |
aSortOrderManager, aControlExtension );
|
|
81 |
CleanupStack::PushL( self );
|
|
82 |
self->ConstructL( aContainer );
|
|
83 |
CleanupStack::Pop( self );
|
|
84 |
return self;
|
|
85 |
}
|
|
86 |
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
// CPbk2SettingsListControl::CommitSettingsL
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
EXPORT_C void CPbk2SettingsListControl::CommitSettingsL()
|
|
92 |
{
|
|
93 |
StoreSettingsL();
|
|
94 |
}
|
|
95 |
|
|
96 |
// -----------------------------------------------------------------------------
|
|
97 |
// CPbk2SettingsListControl::StoreSettings
|
|
98 |
// -----------------------------------------------------------------------------
|
|
99 |
//
|
|
100 |
void CPbk2SettingsListControl::StoreSettings()
|
|
101 |
{
|
|
102 |
TRAPD( err, StoreSettingsL() );
|
|
103 |
if ( err != KErrNone )
|
|
104 |
{
|
|
105 |
iEikonEnv->HandleError( err );
|
|
106 |
}
|
|
107 |
}
|
|
108 |
|
|
109 |
// -----------------------------------------------------------------------------
|
|
110 |
// CPbk2SettingsListControl::SizeChanged
|
|
111 |
// -----------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
void CPbk2SettingsListControl::SizeChanged()
|
|
114 |
{
|
|
115 |
CAknSettingItemList::SizeChanged();
|
|
116 |
|
|
117 |
CEikListBox* listBox = ListBox();
|
|
118 |
if( listBox )
|
|
119 |
{
|
|
120 |
listBox->SetRect( Rect() ); // Set container's rect to listbox
|
|
121 |
}
|
|
122 |
}
|
|
123 |
|
|
124 |
// -----------------------------------------------------------------------------
|
|
125 |
// CPbk2SettingsListControl::EditItemL
|
|
126 |
// -----------------------------------------------------------------------------
|
|
127 |
//
|
|
128 |
void CPbk2SettingsListControl::EditItemL( TInt aIndex, TBool aCalledFromMenu )
|
|
129 |
{
|
|
130 |
switch ( aIndex )
|
|
131 |
{
|
|
132 |
case EPbk2SettingMemorySelection:
|
|
133 |
{
|
|
134 |
LaunchMemorySelectionSettingPageL();
|
|
135 |
this->StoreSettings();
|
|
136 |
break;
|
|
137 |
}
|
|
138 |
case EPbk2SettingPredictiveSearch:
|
|
139 |
{
|
|
140 |
// aCalledFromMenu = EFalse to make it in place, not show the popup
|
|
141 |
CAknSettingItemList::EditItemL( aIndex, EFalse );
|
|
142 |
this->StoreSettings();
|
|
143 |
|
|
144 |
break;
|
|
145 |
}
|
|
146 |
case EPbk2SettingDefaultSavingStorage: //Fall through
|
|
147 |
case EPbk2SettingNameOrder: //Fall through
|
|
148 |
default:
|
|
149 |
{
|
|
150 |
CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
|
|
151 |
this->StoreSettings();
|
|
152 |
break;
|
|
153 |
}
|
|
154 |
}
|
|
155 |
}
|
|
156 |
|
|
157 |
void CPbk2SettingsListControl::HandleResourceChange( TInt aType )
|
|
158 |
{
|
|
159 |
ListBox()->HandleResourceChange( aType );
|
|
160 |
CAknSettingItemList::HandleResourceChange( aType );
|
|
161 |
}
|
|
162 |
|
|
163 |
|
|
164 |
// -----------------------------------------------------------------------------
|
|
165 |
// CPbk2SettingsListControl::HandleListBoxEventL
|
|
166 |
// -----------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
void CPbk2SettingsListControl::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
|
|
169 |
{
|
|
170 |
if( AknLayoutUtils::PenEnabled() )
|
|
171 |
{
|
|
172 |
switch( aEventType )
|
|
173 |
{
|
|
174 |
case EEventItemSingleClicked: //fall through
|
|
175 |
case EEventEnterKeyPressed:
|
|
176 |
{
|
|
177 |
EditItemL( ListBox()->CurrentItemIndex(), ETrue );
|
|
178 |
break;
|
|
179 |
}
|
|
180 |
default :
|
|
181 |
//ignore rest events
|
|
182 |
break;
|
|
183 |
}
|
|
184 |
}
|
|
185 |
}
|
|
186 |
|
|
187 |
// -----------------------------------------------------------------------------
|
|
188 |
// CPbk2SettingsListControl::ConstructL
|
|
189 |
// -----------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
inline void CPbk2SettingsListControl::ConstructL(
|
|
192 |
const CCoeControl* aContainer )
|
|
193 |
{
|
|
194 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
|
|
195 |
("CPbk2SettingsListControl::ConstructL(0x%x)"),
|
|
196 |
aContainer);
|
|
197 |
|
|
198 |
if ( !aContainer )
|
|
199 |
{
|
|
200 |
User::Leave( KErrGeneral );
|
|
201 |
}
|
|
202 |
|
|
203 |
// First set container
|
|
204 |
SetContainerWindowL( *aContainer );
|
|
205 |
|
|
206 |
iSettingListState = CPbk2SettingsListState::NewL();
|
|
207 |
|
|
208 |
// Check language specific variation for name ordering item
|
|
209 |
if ( ShowNameOrderingSettingL() )
|
|
210 |
{
|
|
211 |
ConstructFromResourceL( R_PHONEBOOK2_SETTINGS_LIST );
|
|
212 |
}
|
|
213 |
else
|
|
214 |
{
|
|
215 |
ConstructFromResourceL( R_PHONEBOOK2_SETTINGS_LIST_NO_NAME_ORDERING );
|
|
216 |
}
|
|
217 |
|
|
218 |
iControlExtension.ModifySettingItemListL( *this );
|
|
219 |
// call this to make extension modifications visible
|
|
220 |
HandleChangeInItemArrayOrVisibilityL();
|
|
221 |
|
|
222 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
|
|
223 |
("CPbk2SettingsListControl::ConstructL end"));
|
|
224 |
}
|
|
225 |
|
|
226 |
// -----------------------------------------------------------------------------
|
|
227 |
// CPbk2SettingsListControl::CreateSettingItemL
|
|
228 |
// -----------------------------------------------------------------------------
|
|
229 |
//
|
|
230 |
CAknSettingItem* CPbk2SettingsListControl::CreateSettingItemL( TInt aSettingId )
|
|
231 |
{
|
|
232 |
CAknSettingItem* settingItem =
|
|
233 |
iControlExtension.CreateSettingItemL( aSettingId );
|
|
234 |
|
|
235 |
if ( !settingItem )
|
|
236 |
{
|
|
237 |
switch ( aSettingId )
|
|
238 |
{
|
|
239 |
case EPbk2SettingMemorySelection:
|
|
240 |
{
|
|
241 |
iSelectionSettingItem =
|
|
242 |
new(ELeave) CPbk2MemorySelectionSettingItem(
|
|
243 |
aSettingId,
|
|
244 |
iSettingListState->SupportedStores(),
|
|
245 |
iSettingListState->SelectionItemList() );
|
|
246 |
settingItem = iSelectionSettingItem;
|
|
247 |
break;
|
|
248 |
}
|
|
249 |
case EPbk2SettingDefaultSavingStorage:
|
|
250 |
{
|
|
251 |
iDefaultSavingStorage = 0;
|
|
252 |
iDefaultSavingStorageItem =
|
|
253 |
new(ELeave) CPbk2DefaultSavingStorageSettingItem(
|
|
254 |
aSettingId, iDefaultSavingStorage,
|
|
255 |
iSettingListState->SupportedStores(),
|
|
256 |
iSettingListState->SelectionItemList() );
|
|
257 |
settingItem = iDefaultSavingStorageItem;
|
|
258 |
break;
|
|
259 |
}
|
|
260 |
case EPbk2SettingNameOrder:
|
|
261 |
{
|
|
262 |
CPbk2SortOrderManager::TPbk2NameDisplayOrder order =
|
|
263 |
iSortOrderManager.NameDisplayOrder();
|
|
264 |
iDefaultNameDisplayOrder = TInt( order );
|
|
265 |
settingItem = new (ELeave) CPbk2NameOrderSettingItem(
|
|
266 |
iSortOrderManager, aSettingId, iDefaultNameDisplayOrder );
|
|
267 |
break;
|
|
268 |
}
|
|
269 |
case EPbk2SettingPredictiveSearch:
|
|
270 |
{
|
|
271 |
if(FeatureManager::FeatureSupported(KFeatureIdFfContactsPredictiveSearch))
|
|
272 |
{
|
|
273 |
TBool physicalKeyboardExist = PhysicalKeyboardExistL();
|
|
274 |
if ( physicalKeyboardExist )
|
|
275 |
{
|
|
276 |
PredictiveSearchEnableInfoFromCenrepL();
|
|
277 |
iPredictiveSearchItem = new ( ELeave ) CPbk2PredictiveSearchSettingItem( aSettingId, iPredictiveSearchSettingsValue );
|
|
278 |
settingItem = iPredictiveSearchItem;
|
|
279 |
}
|
|
280 |
else // if no physical keyboard, make this settings invisible,
|
|
281 |
// and reset cenrep for predictive search
|
|
282 |
{
|
|
283 |
DisablePredictiveSearchInCenrepL();
|
|
284 |
}
|
|
285 |
}
|
|
286 |
break;
|
|
287 |
}
|
|
288 |
default:
|
|
289 |
{
|
|
290 |
// Do nothing
|
|
291 |
break;
|
|
292 |
}
|
|
293 |
}
|
|
294 |
}
|
|
295 |
|
|
296 |
return settingItem;
|
|
297 |
}
|
|
298 |
|
|
299 |
// -----------------------------------------------------------------------------
|
|
300 |
// CPbk2SettingsListControl::LaunchMemorySelectionSettingPageL
|
|
301 |
// -----------------------------------------------------------------------------
|
|
302 |
//
|
|
303 |
void CPbk2SettingsListControl::LaunchMemorySelectionSettingPageL()
|
|
304 |
{
|
|
305 |
//Store selection setting item list
|
|
306 |
iSettingListState->StoreItemStateL();
|
|
307 |
|
|
308 |
TBool result( EFalse );
|
|
309 |
do
|
|
310 |
{
|
|
311 |
//Edit selection setting item
|
|
312 |
//result is ETrue if OK pressed
|
|
313 |
result = iSelectionSettingItem->EditItemL();
|
|
314 |
|
|
315 |
TBool driveSpaceFull( EFalse );
|
|
316 |
driveSpaceFull = SysUtil::FFSSpaceBelowCriticalLevelL( &CCoeEnv::Static()->FsSession() );
|
|
317 |
if ( driveSpaceFull )
|
|
318 |
{
|
|
319 |
//If the disk is full, a write operation cannot complete. So restore
|
|
320 |
//the previous state.
|
|
321 |
iEikonEnv->HandleError(KErrDiskFull);
|
|
322 |
CSelectionItemList& oldItem( iSettingListState->ItemListState() );
|
|
323 |
CSelectionItemList& item( iSettingListState->SelectionItemList() );
|
|
324 |
TInt count = item.Count();
|
|
325 |
for ( TInt i(0); i < count; ++i )
|
|
326 |
{
|
|
327 |
TBool select = oldItem.At(i)->SelectionStatus();
|
|
328 |
item.At(i)->SetSelectionStatus( select );
|
|
329 |
}
|
|
330 |
iSelectionSettingItem->RestoreStateL();
|
|
331 |
result = EFalse;
|
|
332 |
}
|
|
333 |
|
|
334 |
if ( result )
|
|
335 |
{
|
|
336 |
//Is selection setting list changed by user
|
|
337 |
//result is ETrue if it is changed
|
|
338 |
result = iSettingListState->IsChanged();
|
|
339 |
if ( result )
|
|
340 |
{
|
|
341 |
//Update default saving storage
|
|
342 |
//result is ETrue if success
|
|
343 |
result = !iDefaultSavingStorageItem->UpdateL();
|
|
344 |
DrawDeferred();
|
|
345 |
}
|
|
346 |
}
|
|
347 |
else
|
|
348 |
{
|
|
349 |
//restore selection setting item list
|
|
350 |
iSettingListState->RestoreItemStateL();
|
|
351 |
iDefaultSavingStorageItem->RestoreStateL();
|
|
352 |
}
|
|
353 |
}while( result );
|
|
354 |
}
|
|
355 |
|
|
356 |
// -----------------------------------------------------------------------------
|
|
357 |
// CPbk2SettingsListControl::ShowNameOrderingSettingL
|
|
358 |
// -----------------------------------------------------------------------------
|
|
359 |
//
|
|
360 |
TBool CPbk2SettingsListControl::ShowNameOrderingSettingL()
|
|
361 |
{
|
|
362 |
// Language specific variation for name ordering setting item
|
|
363 |
_LIT( KVisible, "1");
|
|
364 |
HBufC* nameOrderVisibilityBuf =
|
|
365 |
StringLoader::LoadLC( R_QTN_PHOB_NAME_ORDERING_SETTINGS_VISIBILITY );
|
|
366 |
TBool result = ( nameOrderVisibilityBuf->Compare( KVisible ) == 0 );
|
|
367 |
CleanupStack::PopAndDestroy( nameOrderVisibilityBuf );
|
|
368 |
return result;
|
|
369 |
}
|
|
370 |
|
|
371 |
// -----------------------------------------------------------------------------
|
|
372 |
// CPbk2SettingsListControl::PredictiveSearchEnableInfoFromCenrepL
|
|
373 |
// -----------------------------------------------------------------------------
|
|
374 |
//
|
|
375 |
void CPbk2SettingsListControl::PredictiveSearchEnableInfoFromCenrepL()
|
|
376 |
{
|
|
377 |
CRepository* repository = CRepository::NewLC(TUid::Uid(KCRUidPhonebook));
|
|
378 |
|
|
379 |
TBool predictiveSearch = EFalse;
|
|
380 |
TInt ret = KErrNone;
|
|
381 |
|
|
382 |
ret = repository->Get( KPhonebookPredictiveSearchEnablerFlags, predictiveSearch );
|
|
383 |
|
|
384 |
if ( ret == KErrNotFound )
|
|
385 |
{
|
|
386 |
predictiveSearch = EFalse;
|
|
387 |
repository->Create(KPhonebookPredictiveSearchEnablerFlags, predictiveSearch );
|
|
388 |
}
|
|
389 |
|
|
390 |
if ( predictiveSearch )
|
|
391 |
{
|
|
392 |
iPredictiveSearchSettingsValue = ETrue;
|
|
393 |
}
|
|
394 |
else
|
|
395 |
{
|
|
396 |
iPredictiveSearchSettingsValue = EFalse;
|
|
397 |
}
|
|
398 |
|
|
399 |
CleanupStack::PopAndDestroy( repository );
|
|
400 |
}
|
|
401 |
|
|
402 |
// -----------------------------------------------------------------------------
|
|
403 |
// CPbk2SettingsListControl::PhysicalKeyboardExistL
|
|
404 |
// -----------------------------------------------------------------------------
|
|
405 |
//
|
|
406 |
TBool CPbk2SettingsListControl::PhysicalKeyboardExistL()
|
|
407 |
{
|
|
408 |
TBool ret = ETrue;
|
|
409 |
|
|
410 |
TInt physicalKeyboard = 0;
|
|
411 |
CRepository* aknFepRepository = CRepository::NewL( KCRUidAknFep );
|
|
412 |
TInt err = aknFepRepository->Get( KAknFepPhysicalKeyboards, physicalKeyboard );
|
|
413 |
delete aknFepRepository;
|
|
414 |
|
|
415 |
if ( err == KErrNone )
|
|
416 |
{
|
|
417 |
ret = ( physicalKeyboard != 0 ) ? ETrue : EFalse;
|
|
418 |
}
|
|
419 |
return ret;
|
|
420 |
}
|
|
421 |
|
|
422 |
// -----------------------------------------------------------------------------
|
|
423 |
// CPbk2SettingsListControl::DisablePredictiveSearchInCenrepL
|
|
424 |
// -----------------------------------------------------------------------------
|
|
425 |
//
|
|
426 |
void CPbk2SettingsListControl::DisablePredictiveSearchInCenrepL()
|
|
427 |
{
|
|
428 |
TBool predictiveSearch = EFalse;
|
|
429 |
CRepository* rep = CRepository::NewL(TUid::Uid(KCRUidPhonebook));
|
|
430 |
|
|
431 |
TInt err( rep->Set( KPhonebookPredictiveSearchEnablerFlags, predictiveSearch ) );
|
|
432 |
|
|
433 |
if ( err )
|
|
434 |
{
|
|
435 |
rep->Create( KPhonebookPredictiveSearchEnablerFlags, predictiveSearch );
|
|
436 |
}
|
|
437 |
|
|
438 |
delete rep;
|
|
439 |
}
|
|
440 |
// End of File
|