1
/* $Id: symbian_ua_guiSettingItemList.cpp 3550 2011-05-05 05:33:27Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
// [[[ begin generated region: do not modify [Generated System Includes]
27
#include <stringloader.h>
32
#include <aknpopupfieldtext.h>
34
#include <aknviewappui.h>
35
#include <akntextsettingpage.h>
36
#include <symbian_ua_gui.rsg>
37
// ]]] end generated region [Generated System Includes]
39
// [[[ begin generated region: do not modify [Generated User Includes]
40
#include "symbian_ua_guiSettingItemList.h"
41
#include "Symbian_ua_guiSettingItemListSettings.h"
42
#include "symbian_ua_guiSettingItemList.hrh"
43
#include "symbian_ua_gui.hrh"
44
#include "symbian_ua_guiSettingItemListView.h"
45
// ]]] end generated region [Generated User Includes]
52
// [[[ begin generated region: do not modify [Generated Constants]
53
// ]]] end generated region [Generated Constants]
56
_LIT(KtxDicFileName ,"settings.ini" );
58
const TInt KRegistrar = 2;
59
const TInt KUsername = 3;
60
const TInt KPassword = 4;
61
const TInt KStunServer = 5;
66
* Construct the CSymbian_ua_guiSettingItemList instance
67
* @param aCommandObserver command observer
69
CSymbian_ua_guiSettingItemList::CSymbian_ua_guiSettingItemList(
70
TSymbian_ua_guiSettingItemListSettings& aSettings,
71
MEikCommandObserver* aCommandObserver )
72
: iSettings( aSettings ), iCommandObserver( aCommandObserver )
74
// [[[ begin generated region: do not modify [Generated Contents]
75
// ]]] end generated region [Generated Contents]
79
* Destroy any instance variables
81
CSymbian_ua_guiSettingItemList::~CSymbian_ua_guiSettingItemList()
83
// [[[ begin generated region: do not modify [Generated Contents]
84
// ]]] end generated region [Generated Contents]
89
* Handle system notification that the container's size has changed.
91
void CSymbian_ua_guiSettingItemList::SizeChanged()
95
ListBox()->SetRect( Rect() );
100
* Create one setting item at a time, identified by id.
101
* CAknSettingItemList calls this method and takes ownership
102
* of the returned value. The CAknSettingItem object owns
103
* a reference to the underlying data, which EditItemL() uses
104
* to edit and store the value.
106
CAknSettingItem* CSymbian_ua_guiSettingItemList::CreateSettingItemL( TInt aId )
110
// [[[ begin generated region: do not modify [Initializers]
111
case ESymbian_ua_guiSettingItemListViewEd_registrar:
113
CAknTextSettingItem* item = new ( ELeave )
116
iSettings.Ed_registrar() );
117
item->SetSettingPageFlags(CAknTextSettingPage::EZeroLengthAllowed);
120
case ESymbian_ua_guiSettingItemListViewEd_user:
122
CAknTextSettingItem* item = new ( ELeave )
125
iSettings.Ed_user() );
126
item->SetSettingPageFlags(CAknTextSettingPage::EZeroLengthAllowed);
129
case ESymbian_ua_guiSettingItemListViewEd_password:
131
CAknPasswordSettingItem* item = new ( ELeave )
132
CAknPasswordSettingItem(
134
CAknPasswordSettingItem::EAlpha,
135
iSettings.Ed_password() );
136
item->SetSettingPageFlags(CAknTextSettingPage::EZeroLengthAllowed);
139
case ESymbian_ua_guiSettingItemListViewB_srtp:
141
CAknBinaryPopupSettingItem* item = new ( ELeave )
142
CAknBinaryPopupSettingItem(
144
iSettings.B_srtp() );
145
item->SetHidden( ETrue );
148
case ESymbian_ua_guiSettingItemListViewB_ice:
150
CAknBinaryPopupSettingItem* item = new ( ELeave )
151
CAknBinaryPopupSettingItem(
154
item->SetHidden( ETrue );
157
case ESymbian_ua_guiSettingItemListViewEd_stun_server:
159
CAknTextSettingItem* item = new ( ELeave )
162
iSettings.Ed_stun_server() );
163
item->SetHidden( ETrue );
166
// ]]] end generated region [Initializers]
174
* Edit the setting item identified by the given id and store
175
* the changes into the store.
176
* @param aIndex the index of the setting item in SettingItemArray()
177
* @param aCalledFromMenu true: a menu item invoked editing, thus
178
* always show the edit page and interactively edit the item;
179
* false: change the item in place if possible, else show the edit page
181
void CSymbian_ua_guiSettingItemList::EditItemL ( TInt aIndex, TBool aCalledFromMenu )
183
CAknSettingItem* item = ( *SettingItemArray() )[aIndex];
184
switch ( item->Identifier() )
186
// [[[ begin generated region: do not modify [Editing Started Invoker]
187
// ]]] end generated region [Editing Started Invoker]
191
CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
193
TBool storeValue = ETrue;
194
switch ( item->Identifier() )
196
// [[[ begin generated region: do not modify [Editing Stopped Invoker]
197
// ]]] end generated region [Editing Stopped Invoker]
204
SaveSettingValuesL();
208
* Handle the "Change" option on the Options menu. This is an
209
* alternative to the Selection key that forces the settings page
210
* to come up rather than changing the value in place (if possible).
212
void CSymbian_ua_guiSettingItemList::ChangeSelectedItemL()
214
if ( ListBox()->CurrentItemIndex() >= 0 )
216
EditItemL( ListBox()->CurrentItemIndex(), ETrue );
221
* Load the initial contents of the setting items. By default,
222
* the setting items are populated with the default values from
223
* the design. You can override those values here.
225
* Note: this call alone does not update the UI.
226
* LoadSettingsL() must be called afterwards.
228
void CSymbian_ua_guiSettingItemList::LoadSettingValuesL()
230
// load values into iSettings
233
TFileName pathWithoutDrive;
234
CEikonEnv::Static()->FsSession().PrivatePath( pathWithoutDrive );
236
// Extract drive letter into appDrive:
238
path.Copy( _L("c:") );
241
path.Copy( process.FileName().Left(2) );
244
path.Append( pathWithoutDrive );
245
path.Append( KtxDicFileName );
247
TFindFile AufFolder(CCoeEnv::Static()->FsSession());
248
if(KErrNone == AufFolder.FindByDir(path, KNullDesC))
250
CDictionaryFileStore* MyDStore = CDictionaryFileStore::OpenLC(CCoeEnv::Static()->FsSession(),AufFolder.File(), TUid::Uid(1));
253
FileUid.iUid = KRegistrar;
254
if(MyDStore->IsPresentL(FileUid))
256
RDictionaryReadStream in;
257
in.OpenLC(*MyDStore,FileUid);
258
in >> iSettings.Ed_registrar();
259
CleanupStack::PopAndDestroy(1);// in
262
FileUid.iUid = KUsername;
263
if(MyDStore->IsPresentL(FileUid))
265
RDictionaryReadStream in;
266
in.OpenLC(*MyDStore,FileUid);
267
in >> iSettings.Ed_user();
268
CleanupStack::PopAndDestroy(1);// in
271
FileUid.iUid = KPassword;
272
if(MyDStore->IsPresentL(FileUid))
274
RDictionaryReadStream in;
275
in.OpenLC(*MyDStore,FileUid);
276
in >> iSettings.Ed_password();
277
CleanupStack::PopAndDestroy(1);// in
280
FileUid.iUid = KStunServer;
281
if(MyDStore->IsPresentL(FileUid))
283
RDictionaryReadStream in;
284
in.OpenLC(*MyDStore,FileUid);
285
in >> iSettings.Ed_stun_server();
286
CleanupStack::PopAndDestroy(1);// in
289
FileUid.iUid = KSrtp;
290
if(MyDStore->IsPresentL(FileUid))
292
RDictionaryReadStream in;
293
in.OpenLC(*MyDStore,FileUid);
294
iSettings.SetB_srtp((TBool)in.ReadInt32L());
295
CleanupStack::PopAndDestroy(1);// in
299
if(MyDStore->IsPresentL(FileUid))
301
RDictionaryReadStream in;
302
in.OpenLC(*MyDStore,FileUid);
303
iSettings.SetB_ice((TBool)in.ReadInt32L());
304
CleanupStack::PopAndDestroy(1);// in
307
CleanupStack::PopAndDestroy(1);// Store
313
* Save the contents of the setting items. Note, this is called
314
* whenever an item is changed and stored to the model, so it
315
* may be called multiple times or not at all.
317
void CSymbian_ua_guiSettingItemList::SaveSettingValuesL()
319
// store values from iSettings
322
TFileName pathWithoutDrive;
323
CEikonEnv::Static()->FsSession().PrivatePath( pathWithoutDrive );
325
// Extract drive letter into appDrive:
327
path.Copy( _L("c:") );
330
path.Copy( process.FileName().Left(2) );
332
if(path.Compare(_L("c")) || path.Compare(_L("C")))
333
CEikonEnv::Static()->FsSession().CreatePrivatePath(EDriveC);
334
else if(path.Compare(_L("e")) || path.Compare(_L("E")))
335
CEikonEnv::Static()->FsSession().CreatePrivatePath(EDriveE);
338
path.Append( pathWithoutDrive );
339
path.Append( KtxDicFileName );
341
TFindFile AufFolder(CCoeEnv::Static()->FsSession());
342
if(KErrNone == AufFolder.FindByDir(path, KNullDesC))
344
User::LeaveIfError(CCoeEnv::Static()->FsSession().Delete(AufFolder.File()));
347
CDictionaryFileStore* MyDStore = CDictionaryFileStore::OpenLC(CCoeEnv::Static()->FsSession(),path, TUid::Uid(1));
349
TUid FileUid = {0x0};
351
FileUid.iUid = KRegistrar;
352
RDictionaryWriteStream out1;
353
out1.AssignLC(*MyDStore,FileUid);
354
out1 << iSettings.Ed_registrar();
356
CleanupStack::PopAndDestroy(1);// out2
358
FileUid.iUid = KUsername;
359
RDictionaryWriteStream out2;
360
out2.AssignLC(*MyDStore,FileUid);
361
out2 << iSettings.Ed_user();
363
CleanupStack::PopAndDestroy(1);// out2
365
FileUid.iUid = KPassword;
366
RDictionaryWriteStream out3;
367
out3.AssignLC(*MyDStore,FileUid);
368
out3 << iSettings.Ed_password();
370
CleanupStack::PopAndDestroy(1);// out2
372
FileUid.iUid = KStunServer;
373
RDictionaryWriteStream out4;
374
out4.AssignLC(*MyDStore,FileUid);
375
out4 << iSettings.Ed_stun_server();
377
CleanupStack::PopAndDestroy(1);// out2
379
FileUid.iUid = KSrtp;
380
RDictionaryWriteStream out5;
381
out5.AssignLC(*MyDStore,FileUid);
382
out5.WriteInt32L(iSettings.B_srtp());
384
CleanupStack::PopAndDestroy(1);// out1
387
RDictionaryWriteStream out6;
388
out6.AssignLC(*MyDStore,FileUid);
389
out6.WriteInt32L(iSettings.B_ice());
391
CleanupStack::PopAndDestroy(1);// out1
394
CleanupStack::PopAndDestroy(1);// Store
400
* Handle global resource changes, such as scalable UI or skin events (override)
402
void CSymbian_ua_guiSettingItemList::HandleResourceChange( TInt aType )
404
CAknSettingItemList::HandleResourceChange( aType );
405
SetRect( iAvkonViewAppUi->View( TUid::Uid( ESymbian_ua_guiSettingItemListViewId ) )->ClientRect() );
406
// [[[ begin generated region: do not modify [Generated Contents]
407
// ]]] end generated region [Generated Contents]
412
* Handle key event (override)
413
* @param aKeyEvent key event
414
* @param aType event code
415
* @return EKeyWasConsumed if the event was handled, else EKeyWasNotConsumed
417
TKeyResponse CSymbian_ua_guiSettingItemList::OfferKeyEventL(
418
const TKeyEvent& aKeyEvent,
421
// [[[ begin generated region: do not modify [Generated Contents]
422
// ]]] end generated region [Generated Contents]
424
if ( aKeyEvent.iCode == EKeyLeftArrow
425
|| aKeyEvent.iCode == EKeyRightArrow )
427
// allow the tab control to get the arrow keys
428
return EKeyWasNotConsumed;
431
return CAknSettingItemList::OfferKeyEventL( aKeyEvent, aType );