~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.1.0/pjsip-apps/src/symbian_ua_gui/src/symbian_ua_guiSettingItemList.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: symbian_ua_guiSettingItemList.cpp 3550 2011-05-05 05:33:27Z nanang $ */
 
2
/* 
 
3
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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 
 
18
 */
 
19
 
 
20
// [[[ begin generated region: do not modify [Generated System Includes]
 
21
#include <avkon.hrh>
 
22
#include <avkon.rsg>
 
23
#include <eikmenup.h>
 
24
#include <aknappui.h>
 
25
#include <eikcmobs.h>
 
26
#include <barsread.h>
 
27
#include <stringloader.h>
 
28
#include <gdi.h>
 
29
#include <eikedwin.h>
 
30
#include <eikenv.h>
 
31
#include <eikseced.h>
 
32
#include <aknpopupfieldtext.h>
 
33
#include <eikappui.h>
 
34
#include <aknviewappui.h>
 
35
#include <akntextsettingpage.h> 
 
36
#include <symbian_ua_gui.rsg>
 
37
// ]]] end generated region [Generated System Includes]
 
38
 
 
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]
 
46
 
 
47
 
 
48
#include <s32stor.h>
 
49
#include <s32file.h>
 
50
 
 
51
 
 
52
// [[[ begin generated region: do not modify [Generated Constants]
 
53
// ]]] end generated region [Generated Constants]
 
54
 
 
55
 
 
56
_LIT(KtxDicFileName                     ,"settings.ini" );
 
57
 
 
58
const TInt KRegistrar           = 2;
 
59
const TInt KUsername            = 3;
 
60
const TInt KPassword            = 4;
 
61
const TInt KStunServer          = 5;
 
62
const TInt KSrtp                        = 6;
 
63
const TInt KIce                         = 7;
 
64
 
 
65
/**
 
66
 * Construct the CSymbian_ua_guiSettingItemList instance
 
67
 * @param aCommandObserver command observer
 
68
 */ 
 
69
CSymbian_ua_guiSettingItemList::CSymbian_ua_guiSettingItemList( 
 
70
                TSymbian_ua_guiSettingItemListSettings& aSettings, 
 
71
                MEikCommandObserver* aCommandObserver )
 
72
        : iSettings( aSettings ), iCommandObserver( aCommandObserver )
 
73
        {
 
74
        // [[[ begin generated region: do not modify [Generated Contents]
 
75
        // ]]] end generated region [Generated Contents]
 
76
        
 
77
        }
 
78
/** 
 
79
 * Destroy any instance variables
 
80
 */
 
81
CSymbian_ua_guiSettingItemList::~CSymbian_ua_guiSettingItemList()
 
82
        {
 
83
        // [[[ begin generated region: do not modify [Generated Contents]
 
84
        // ]]] end generated region [Generated Contents]
 
85
        
 
86
        }
 
87
 
 
88
/**
 
89
 * Handle system notification that the container's size has changed.
 
90
 */
 
91
void CSymbian_ua_guiSettingItemList::SizeChanged()
 
92
        {
 
93
        if ( ListBox() ) 
 
94
                {
 
95
                ListBox()->SetRect( Rect() );
 
96
                }
 
97
        }
 
98
 
 
99
/**
 
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.
 
105
 */
 
106
CAknSettingItem* CSymbian_ua_guiSettingItemList::CreateSettingItemL( TInt aId )
 
107
        {
 
108
        switch ( aId )
 
109
                {
 
110
        // [[[ begin generated region: do not modify [Initializers]
 
111
                case ESymbian_ua_guiSettingItemListViewEd_registrar:
 
112
                        {                       
 
113
                        CAknTextSettingItem* item = new ( ELeave ) 
 
114
                                CAknTextSettingItem( 
 
115
                                        aId,
 
116
                                        iSettings.Ed_registrar() );
 
117
                        item->SetSettingPageFlags(CAknTextSettingPage::EZeroLengthAllowed);
 
118
                        return item;
 
119
                        }
 
120
                case ESymbian_ua_guiSettingItemListViewEd_user:
 
121
                        {                       
 
122
                        CAknTextSettingItem* item = new ( ELeave ) 
 
123
                                CAknTextSettingItem( 
 
124
                                        aId,
 
125
                                        iSettings.Ed_user() );
 
126
                        item->SetSettingPageFlags(CAknTextSettingPage::EZeroLengthAllowed);
 
127
                        return item;
 
128
                        }
 
129
                case ESymbian_ua_guiSettingItemListViewEd_password:
 
130
                        {                       
 
131
                        CAknPasswordSettingItem* item = new ( ELeave ) 
 
132
                                CAknPasswordSettingItem( 
 
133
                                        aId,
 
134
                                        CAknPasswordSettingItem::EAlpha,
 
135
                                        iSettings.Ed_password() );
 
136
                        item->SetSettingPageFlags(CAknTextSettingPage::EZeroLengthAllowed);
 
137
                        return item;
 
138
                        }
 
139
                case ESymbian_ua_guiSettingItemListViewB_srtp:
 
140
                        {                       
 
141
                        CAknBinaryPopupSettingItem* item = new ( ELeave ) 
 
142
                                CAknBinaryPopupSettingItem( 
 
143
                                        aId,
 
144
                                        iSettings.B_srtp() );
 
145
                        item->SetHidden( ETrue ); 
 
146
                        return item;
 
147
                        }
 
148
                case ESymbian_ua_guiSettingItemListViewB_ice:
 
149
                        {                       
 
150
                        CAknBinaryPopupSettingItem* item = new ( ELeave ) 
 
151
                                CAknBinaryPopupSettingItem( 
 
152
                                        aId,
 
153
                                        iSettings.B_ice() );
 
154
                        item->SetHidden( ETrue ); 
 
155
                        return item;
 
156
                        }
 
157
                case ESymbian_ua_guiSettingItemListViewEd_stun_server:
 
158
                        {                       
 
159
                        CAknTextSettingItem* item = new ( ELeave ) 
 
160
                                CAknTextSettingItem( 
 
161
                                        aId,
 
162
                                        iSettings.Ed_stun_server() );
 
163
                        item->SetHidden( ETrue ); 
 
164
                        return item;
 
165
                        }
 
166
        // ]]] end generated region [Initializers]
 
167
        
 
168
                }
 
169
                
 
170
        return NULL;
 
171
        }
 
172
        
 
173
/**
 
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
 
180
 */
 
181
void CSymbian_ua_guiSettingItemList::EditItemL ( TInt aIndex, TBool aCalledFromMenu )
 
182
        {
 
183
        CAknSettingItem* item = ( *SettingItemArray() )[aIndex];
 
184
        switch ( item->Identifier() )
 
185
                {
 
186
        // [[[ begin generated region: do not modify [Editing Started Invoker]
 
187
        // ]]] end generated region [Editing Started Invoker]
 
188
        
 
189
                }
 
190
        
 
191
        CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
 
192
        
 
193
        TBool storeValue = ETrue;
 
194
        switch ( item->Identifier() )
 
195
                {
 
196
        // [[[ begin generated region: do not modify [Editing Stopped Invoker]
 
197
        // ]]] end generated region [Editing Stopped Invoker]
 
198
        
 
199
                }
 
200
                
 
201
        if ( storeValue )
 
202
                {
 
203
                item->StoreL();
 
204
                SaveSettingValuesL();
 
205
                }       
 
206
        }
 
207
/**
 
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).
 
211
 */
 
212
void CSymbian_ua_guiSettingItemList::ChangeSelectedItemL()
 
213
        {
 
214
        if ( ListBox()->CurrentItemIndex() >= 0 )
 
215
                {
 
216
                EditItemL( ListBox()->CurrentItemIndex(), ETrue );
 
217
                }
 
218
        }
 
219
 
 
220
/**
 
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.
 
224
 *      <p>
 
225
 *      Note: this call alone does not update the UI.  
 
226
 *      LoadSettingsL() must be called afterwards.
 
227
 */
 
228
void CSymbian_ua_guiSettingItemList::LoadSettingValuesL()
 
229
        {
 
230
        // load values into iSettings
 
231
 
 
232
        TFileName path;
 
233
        TFileName pathWithoutDrive;
 
234
        CEikonEnv::Static()->FsSession().PrivatePath( pathWithoutDrive );
 
235
 
 
236
        // Extract drive letter into appDrive:
 
237
#ifdef __WINS__
 
238
        path.Copy( _L("c:") );
 
239
#else
 
240
        RProcess process;
 
241
        path.Copy( process.FileName().Left(2) );
 
242
#endif
 
243
 
 
244
        path.Append( pathWithoutDrive );
 
245
        path.Append( KtxDicFileName );
 
246
        
 
247
        TFindFile AufFolder(CCoeEnv::Static()->FsSession());
 
248
        if(KErrNone == AufFolder.FindByDir(path, KNullDesC))
 
249
        {
 
250
                CDictionaryFileStore* MyDStore = CDictionaryFileStore::OpenLC(CCoeEnv::Static()->FsSession(),AufFolder.File(), TUid::Uid(1));
 
251
                TUid FileUid;
 
252
                
 
253
                FileUid.iUid = KRegistrar;
 
254
                if(MyDStore->IsPresentL(FileUid))
 
255
                {
 
256
                        RDictionaryReadStream in;
 
257
                        in.OpenLC(*MyDStore,FileUid);
 
258
                        in >> iSettings.Ed_registrar();
 
259
                        CleanupStack::PopAndDestroy(1);// in
 
260
                }
 
261
                        
 
262
                FileUid.iUid = KUsername;
 
263
                if(MyDStore->IsPresentL(FileUid))
 
264
                {
 
265
                        RDictionaryReadStream in;
 
266
                        in.OpenLC(*MyDStore,FileUid);
 
267
                        in >> iSettings.Ed_user();
 
268
                        CleanupStack::PopAndDestroy(1);// in
 
269
                }
 
270
 
 
271
                FileUid.iUid = KPassword;
 
272
                if(MyDStore->IsPresentL(FileUid))
 
273
                {
 
274
                        RDictionaryReadStream in;
 
275
                        in.OpenLC(*MyDStore,FileUid);
 
276
                        in >> iSettings.Ed_password();
 
277
                        CleanupStack::PopAndDestroy(1);// in
 
278
                }
 
279
 
 
280
                FileUid.iUid = KStunServer;
 
281
                if(MyDStore->IsPresentL(FileUid))
 
282
                {
 
283
                        RDictionaryReadStream in;
 
284
                        in.OpenLC(*MyDStore,FileUid);
 
285
                        in >> iSettings.Ed_stun_server();
 
286
                        CleanupStack::PopAndDestroy(1);// in
 
287
                }
 
288
 
 
289
                FileUid.iUid = KSrtp;
 
290
                if(MyDStore->IsPresentL(FileUid))
 
291
                {
 
292
                        RDictionaryReadStream in;
 
293
                        in.OpenLC(*MyDStore,FileUid);
 
294
                        iSettings.SetB_srtp((TBool)in.ReadInt32L());
 
295
                        CleanupStack::PopAndDestroy(1);// in
 
296
                }
 
297
                
 
298
                FileUid.iUid = KIce;
 
299
                if(MyDStore->IsPresentL(FileUid))
 
300
                {
 
301
                        RDictionaryReadStream in;
 
302
                        in.OpenLC(*MyDStore,FileUid);
 
303
                        iSettings.SetB_ice((TBool)in.ReadInt32L());
 
304
                        CleanupStack::PopAndDestroy(1);// in
 
305
                }
 
306
 
 
307
                CleanupStack::PopAndDestroy(1);// Store         
 
308
        }
 
309
 
 
310
        }
 
311
        
 
312
/**
 
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.
 
316
 */
 
317
void CSymbian_ua_guiSettingItemList::SaveSettingValuesL()
 
318
        {
 
319
        // store values from iSettings
 
320
 
 
321
        TFileName path;
 
322
        TFileName pathWithoutDrive;
 
323
        CEikonEnv::Static()->FsSession().PrivatePath( pathWithoutDrive );
 
324
 
 
325
        // Extract drive letter into appDrive:
 
326
#ifdef __WINS__
 
327
        path.Copy( _L("c:") );
 
328
#else
 
329
        RProcess process;
 
330
        path.Copy( process.FileName().Left(2) );
 
331
        
 
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);    
 
336
#endif
 
337
 
 
338
        path.Append( pathWithoutDrive );
 
339
        path.Append( KtxDicFileName );
 
340
        
 
341
        TFindFile AufFolder(CCoeEnv::Static()->FsSession());
 
342
        if(KErrNone == AufFolder.FindByDir(path, KNullDesC))
 
343
        {
 
344
                User::LeaveIfError(CCoeEnv::Static()->FsSession().Delete(AufFolder.File()));
 
345
        }
 
346
 
 
347
        CDictionaryFileStore* MyDStore = CDictionaryFileStore::OpenLC(CCoeEnv::Static()->FsSession(),path, TUid::Uid(1));
 
348
 
 
349
        TUid FileUid = {0x0};
 
350
                
 
351
        FileUid.iUid = KRegistrar;
 
352
        RDictionaryWriteStream out1;
 
353
        out1.AssignLC(*MyDStore,FileUid);
 
354
        out1 << iSettings.Ed_registrar();
 
355
        out1.CommitL();         
 
356
        CleanupStack::PopAndDestroy(1);// out2  
 
357
        
 
358
        FileUid.iUid = KUsername;
 
359
        RDictionaryWriteStream out2;
 
360
        out2.AssignLC(*MyDStore,FileUid);
 
361
        out2 << iSettings.Ed_user();
 
362
        out2.CommitL();         
 
363
        CleanupStack::PopAndDestroy(1);// out2  
 
364
        
 
365
        FileUid.iUid = KPassword;
 
366
        RDictionaryWriteStream out3;
 
367
        out3.AssignLC(*MyDStore,FileUid);
 
368
        out3 << iSettings.Ed_password();
 
369
        out3.CommitL();         
 
370
        CleanupStack::PopAndDestroy(1);// out2  
 
371
        
 
372
        FileUid.iUid = KStunServer;
 
373
        RDictionaryWriteStream out4;
 
374
        out4.AssignLC(*MyDStore,FileUid);
 
375
        out4 << iSettings.Ed_stun_server();
 
376
        out4.CommitL();         
 
377
        CleanupStack::PopAndDestroy(1);// out2  
 
378
        
 
379
        FileUid.iUid = KSrtp;
 
380
        RDictionaryWriteStream out5;
 
381
        out5.AssignLC(*MyDStore,FileUid);
 
382
        out5.WriteInt32L(iSettings.B_srtp());
 
383
        out5.CommitL();         
 
384
        CleanupStack::PopAndDestroy(1);// out1
 
385
        
 
386
        FileUid.iUid = KIce;
 
387
        RDictionaryWriteStream out6;
 
388
        out6.AssignLC(*MyDStore,FileUid);
 
389
        out6.WriteInt32L(iSettings.B_ice());
 
390
        out6.CommitL();         
 
391
        CleanupStack::PopAndDestroy(1);// out1
 
392
         
 
393
        MyDStore->CommitL();
 
394
        CleanupStack::PopAndDestroy(1);// Store
 
395
 
 
396
        }
 
397
 
 
398
 
 
399
/** 
 
400
 * Handle global resource changes, such as scalable UI or skin events (override)
 
401
 */
 
402
void CSymbian_ua_guiSettingItemList::HandleResourceChange( TInt aType )
 
403
        {
 
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]
 
408
        
 
409
        }
 
410
                                
 
411
/** 
 
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
 
416
 */
 
417
TKeyResponse CSymbian_ua_guiSettingItemList::OfferKeyEventL( 
 
418
                const TKeyEvent& aKeyEvent, 
 
419
                TEventCode aType )
 
420
        {
 
421
        // [[[ begin generated region: do not modify [Generated Contents]
 
422
        // ]]] end generated region [Generated Contents]
 
423
        
 
424
        if ( aKeyEvent.iCode == EKeyLeftArrow 
 
425
                || aKeyEvent.iCode == EKeyRightArrow )
 
426
                {
 
427
                // allow the tab control to get the arrow keys
 
428
                return EKeyWasNotConsumed;
 
429
                }
 
430
        
 
431
        return CAknSettingItemList::OfferKeyEventL( aKeyEvent, aType );
 
432
        }
 
433