|
1 /* |
|
2 * Copyright (c) 2005 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: SIP Settings view controller |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <uikon.hrh> |
|
21 #include <aknradiobuttonsettingpage.h> |
|
22 #include <aknnotewrappers.h> |
|
23 #include <StringLoader.h> |
|
24 #include <hlplch.h> |
|
25 #include <featmgr.h> |
|
26 #include <bautils.h> |
|
27 #include <gsfwviewuids.h> //for KGSConPluginUid |
|
28 #include <gssipsettingspluginrsc.rsg> //GUI Resource |
|
29 #include <gssipsettingsplugin.mbg> |
|
30 #include "sipsettingsplugin.h" |
|
31 #include "sipsettingsmodel.h" |
|
32 #include "sipsettingscontainer.h" |
|
33 #include "gssipmodel.h" |
|
34 #include "sipsettlistsipprofsetview.h" |
|
35 #include "sipsettlistsipprxsetview.h" |
|
36 #include "sipsettlistsipregsetview.h" |
|
37 #include "gssipsettingsplugin.hrh" |
|
38 #include "viewid.h" |
|
39 #include "gsprivatepluginproviderids.h" |
|
40 #include "gssippluginlogger.h" |
|
41 |
|
42 #include "gssipsettingspluginrsc.rsg" |
|
43 |
|
44 #include <aknappui.h> |
|
45 // LOCAL CONSTANTS AND MACROS |
|
46 // Middle Softkey control ID. |
|
47 const TInt KGSMSKControlID = 3; |
|
48 |
|
49 // ============================ MEMBER FUNCTIONS =============================== |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CSIPSettingsPlugin::CSIPSettingsPlugin |
|
53 // C++ default constructor can NOT contain any code, that |
|
54 // might leave. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CSIPSettingsPlugin::CSIPSettingsPlugin() |
|
58 : iResourceLoader( *iCoeEnv ), iMskCommandFlag(ETrue) |
|
59 { |
|
60 __GSLOGSTRING( "[GSSIPSettingsPlugin] CSIPSettingsPlugin::CSIPSettingsPlugin()" ) |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CSIPSettingsPlugin::~CSIPSettingsPlugin() |
|
65 // Destructor |
|
66 // |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CSIPSettingsPlugin::~CSIPSettingsPlugin() |
|
70 { |
|
71 __GSLOGSTRING( "[GSSIPSettingsPlugin] CSIPSettingsPlugin::~CSIPSettingsPlugin()" ) |
|
72 |
|
73 if ( iContainer ) |
|
74 { |
|
75 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
76 delete iContainer; |
|
77 iContainer=NULL; |
|
78 } |
|
79 iResourceLoader.Close(); |
|
80 |
|
81 delete iModel; |
|
82 delete iHandler; |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // When this method is called, view checks based on highlight focus, if the MSK |
|
87 // label is correct. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CSIPSettingsPlugin::CheckMiddleSoftkeyLabelL() |
|
91 { |
|
92 __GSLOGSTRING("CSIPSettingsPlugin::CheckMiddleSoftkeyLabelL " ) |
|
93 const TInt currentFeatureId = iContainer->CurrentFeatureId(); |
|
94 // First remove any previous commands. |
|
95 RemoveCommandFromMSK( iMskCommandFlag ); |
|
96 if ( currentFeatureId >= 0 ) |
|
97 { |
|
98 //Set middle softkey as Change. |
|
99 SetMiddleSoftKeyLabelL( R_PROFILES_MSK_EDIT, |
|
100 EGSMSKCmdAppChange ); |
|
101 // This way we set which command is set for MSK |
|
102 iMskCommandFlag = ETrue; |
|
103 } |
|
104 else |
|
105 { |
|
106 } |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // Remove unnecessary commands from Middle softkey. |
|
111 // @flag = ETrue means presently MSK value is "Change" so we remove that |
|
112 // @flag = EFalse means presently no MSK value is currently on |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CSIPSettingsPlugin::RemoveCommandFromMSK(const TBool flag ) |
|
116 { |
|
117 __GSLOGSTRING("CSIPSettingsPlugin::RemoveCommandFromMSK " ) |
|
118 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
119 if ( cbaGroup ) |
|
120 { |
|
121 if ( flag ) |
|
122 { |
|
123 cbaGroup->RemoveCommandFromStack( |
|
124 KGSMSKControlID, EGSMSKCmdAppChange ); |
|
125 } |
|
126 else |
|
127 { |
|
128 } |
|
129 } |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // Sets middle softkey label. |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void CSIPSettingsPlugin::SetMiddleSoftKeyLabelL( |
|
137 const TInt aResourceId, const TInt aCommandId ) |
|
138 { |
|
139 __GSLOGSTRING("CSIPSettingsPlugin::SetMiddleSoftKeyLabelL" ) |
|
140 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
141 if ( cbaGroup ) |
|
142 { |
|
143 HBufC* middleSKText = StringLoader::LoadLC( aResourceId ); |
|
144 TPtr mskPtr = middleSKText->Des(); |
|
145 cbaGroup->AddCommandToStackL( |
|
146 KGSMSKControlID, |
|
147 aCommandId, |
|
148 mskPtr ); |
|
149 CleanupStack::PopAndDestroy( middleSKText ); |
|
150 } |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CSIPSettingsPlugin::ConstructL(const TRect& aRect) |
|
155 // Symbian OS two-phased constructor |
|
156 // (other items were commented in a header). |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void CSIPSettingsPlugin::ConstructL() |
|
160 { |
|
161 __GSLOGSTRING( "[GSSIPSettingsPlugin] CSIPSettingsPlugin::ConstructL()" ) |
|
162 __GSLOGSTRING( "[GSSIPSettingsPlugin] Loading resource from : z:GSSIPSettingsPluginRsc.rsc" ) |
|
163 |
|
164 |
|
165 // Find the resource file |
|
166 TParse parse; |
|
167 parse.Set( KSIPSettingsResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL ); |
|
168 TFileName fileName( parse.FullName() ); |
|
169 |
|
170 // Get language of resource file |
|
171 BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName ); |
|
172 |
|
173 // Open resource file |
|
174 iResourceLoader.OpenL( fileName ); |
|
175 |
|
176 iHandler = CGSSIPModel::NewL(); |
|
177 iHandler->CreateEngineL( this ); |
|
178 iModel = CSIPSettingsModel::NewL( iHandler ); |
|
179 |
|
180 // Construct views |
|
181 CAknView* view; |
|
182 |
|
183 view = CSIPSettListSIPProfSetView::NewLC( iHandler ); |
|
184 AppUi()->AddViewL( view ); // transfer ownership to CAknViewAppUi |
|
185 CleanupStack::Pop( view ); |
|
186 __GSLOGSTRING( "[GSSIPSettingsPlugin] CSIPSettingsPlugin::ConstructL: View created" ) |
|
187 |
|
188 view = CSIPSettListSIPPrxSetView::NewLC( iHandler ); |
|
189 AppUi()->AddViewL( view ); // transfer ownership to CAknViewAppUi |
|
190 CleanupStack::Pop( view ); |
|
191 __GSLOGSTRING( |
|
192 "[GSSIPSettingsPlugin] CSIPSettingsPlugin::ConstructL: SIP prx srv View created" ) |
|
193 |
|
194 view = CSIPSettListSIPRegSetView::NewLC( iHandler ); |
|
195 AppUi()->AddViewL( view ); // transfer ownership to CAknViewAppUi |
|
196 CleanupStack::Pop( view ); |
|
197 __GSLOGSTRING( |
|
198 "[GSSIPSettingsPlugin] CSIPSettingsPlugin::ConstructL: SIP reg srv View created" ) |
|
199 |
|
200 iListBoxEventPenDown = EFalse; |
|
201 BaseConstructL( R_GS_SIP_PROFILE_LIST_VIEW ); |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CSIPSettingsPlugin::NewL |
|
206 // Static constructor |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 CSIPSettingsPlugin* CSIPSettingsPlugin::NewL( TAny* /*aInitParams*/ ) |
|
210 { |
|
211 __GSLOGSTRING( "[GSSIPSettingsPlugin] CSIPSettingsPlugin::NewL()" ) |
|
212 |
|
213 CSIPSettingsPlugin* self = |
|
214 new ( ELeave ) CSIPSettingsPlugin( ); |
|
215 |
|
216 CleanupStack::PushL( self ); |
|
217 self->ConstructL(); |
|
218 CleanupStack::Pop(self); |
|
219 return self; |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CSIPSettingsPlugin::Id |
|
224 // |
|
225 // Returns the UID of the view |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 TUid CSIPSettingsPlugin::Id() const |
|
229 { |
|
230 return KGSSIPSettingsPluginUID; |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CSIPSettingsPlugin::HandleClientRectChange |
|
235 // |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 void CSIPSettingsPlugin::HandleClientRectChange() |
|
239 { |
|
240 __GSLOGSTRING("[GSSIPSettingsPlugin] CSIPSettingsPlugin::HandleClientRectChange()" ) |
|
241 if ( iContainer && iContainer->iListBox ) |
|
242 { |
|
243 iContainer->SetRect( ClientRect() ); |
|
244 } |
|
245 } |
|
246 |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CSIPSettListSIPProfListView::DoActivateL() |
|
250 // Activates the view, creates View and Model |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 void CSIPSettingsPlugin::DoActivateL( |
|
254 const TVwsViewId& aPrevViewId, |
|
255 TUid /*aCustomMessageId*/, |
|
256 const TDesC8& /*aCustomMessage*/ ) |
|
257 { |
|
258 __GSLOGSTRING( "[GSSIPSettingsPlugin] CSIPSettingsPlugin::DoActivateL()" ) |
|
259 __GSLOGSTRING1( "[GSSIPSettingsPlugin] Previous vied id: %d" , aPrevViewId.iViewUid.iUid ) |
|
260 iPrevViewId = aPrevViewId; |
|
261 |
|
262 if ( iContainer ) |
|
263 { |
|
264 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
265 delete iContainer; |
|
266 iContainer=NULL; |
|
267 } |
|
268 |
|
269 iContainer = new (ELeave) CSIPSettingsContainer( this ); |
|
270 __ASSERT_DEBUG( |
|
271 iContainer, |
|
272 User::Panic(_L( "CSIPSettingsPlugin::iContainer == NULL" ), 0 ) ); |
|
273 iContainer->SetMopParent( this ); |
|
274 |
|
275 TRAPD( error, iContainer->ConstructL( ClientRect(), iActiveIndex, iModel ) ); |
|
276 |
|
277 if ( error && iContainer ) |
|
278 { |
|
279 delete iContainer; |
|
280 iContainer = NULL; |
|
281 User::Leave( error ); |
|
282 } |
|
283 |
|
284 iContainer->SetMiddleSoftkeyObserver( this ); |
|
285 AppUi()->AddToViewStackL( *this, iContainer ); |
|
286 // This way we set which command is set for MSK |
|
287 iMskCommandFlag = ETrue; |
|
288 CheckMiddleSoftkeyLabelL(); |
|
289 |
|
290 __GSLOGSTRING("[GSSIPSettingsPlugin] CSIPSettingsPlugin::DoActivateL done" ) |
|
291 } |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // CSIPSettingsPlugin::DoDeactivate() |
|
295 // Deactivates the view |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void CSIPSettingsPlugin::DoDeactivate() |
|
299 { |
|
300 __GSLOGSTRING( "[GSSIPSettingsPlugin] CSIPSettingsPlugin::DoDeactivate()" ) |
|
301 if ( iContainer ) |
|
302 { |
|
303 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
304 delete iContainer; |
|
305 iContainer = NULL; |
|
306 } |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CSIPSettingsPlugin::HandleCommandL |
|
311 // Handles the user interaction |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 void CSIPSettingsPlugin::HandleCommandL( TInt aCommand ) |
|
315 { |
|
316 __GSLOGSTRING1("CSIPSettingsPlugin::HandleCommandL aCommand: %d", aCommand) |
|
317 TBool exitNow( ETrue ); |
|
318 TVwsViewId id; |
|
319 AppUi()->GetActiveViewId( id ); // Current view id. |
|
320 |
|
321 switch ( aCommand ) |
|
322 { |
|
323 // "Add new..Use existing profile" menu item |
|
324 case EGSCmdAppNewExist: |
|
325 CreateFromExisitingProfileL(); |
|
326 break; |
|
327 |
|
328 // "Add new..Use default profile" menu item |
|
329 case EGSCmdAppNewDefault: |
|
330 CreateNewProfileL( KUnknownProfileIndex ); |
|
331 break; |
|
332 |
|
333 // "Edit" menu item / Select pressed |
|
334 case EGSMSKCmdAppChange: |
|
335 case EGSCmdAppEdit: |
|
336 EditProfileL(); |
|
337 break; |
|
338 |
|
339 // "Delete" menu item / 'c' pressed |
|
340 case EGSCmdAppDelete: |
|
341 DeleteProfileL(); |
|
342 break; |
|
343 |
|
344 // "Default profile" menu item |
|
345 case EGSCmdAppDefault: |
|
346 ChangeDefaultProfileL(); |
|
347 break; |
|
348 |
|
349 // Updates the list as registration status has changed |
|
350 // or a new list item is added |
|
351 case EGSCmdUpdateList: |
|
352 if ( iContainer ) |
|
353 { |
|
354 iContainer->ListItemModifiedL( iHandler->AddedProfileIndex() ); |
|
355 CheckMiddleSoftkeyLabelL(); |
|
356 } |
|
357 break; |
|
358 |
|
359 // Called when a profile is deleted |
|
360 case EGSCmdProfileDeleted: |
|
361 if ( iContainer ) |
|
362 { |
|
363 iContainer->ListItemDeletedL(); |
|
364 CheckMiddleSoftkeyLabelL(); |
|
365 } |
|
366 break; |
|
367 |
|
368 // Activate 'Connection' or 'Administrative Settings' view |
|
369 case EAknSoftkeyBack: |
|
370 iActiveIndex = 0; |
|
371 #if defined (RD_CONTROL_PANEL) |
|
372 AppUi()->ActivateLocalViewL( KGSAdminPluginUid ); |
|
373 #else |
|
374 AppUi()->ActivateLocalViewL( KGSConPluginUid ); |
|
375 #endif // RD_CONTROL_PANEL |
|
376 break; |
|
377 |
|
378 case EAknCmdHelp: |
|
379 { |
|
380 if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
381 { |
|
382 HlpLauncher::LaunchHelpApplicationL( |
|
383 iEikonEnv->WsSession(), AppUi()->AppHelpContextL() ); |
|
384 } |
|
385 break; |
|
386 } |
|
387 |
|
388 case EAknCmdExit: |
|
389 iActiveIndex = 0; |
|
390 iHandler->QuitAfterSave(); |
|
391 if ( ( id.iViewUid == KSettListSIPProfileSettingView || |
|
392 id.iViewUid == KSettListSIPProxyServerView || |
|
393 id.iViewUid == KSettListSIPRegistrarServerView ) && |
|
394 iHandler->SaveProfileL() ) |
|
395 { |
|
396 exitNow = EFalse; |
|
397 } |
|
398 |
|
399 // Exit? |
|
400 if ( exitNow ) |
|
401 { |
|
402 AppUi()->HandleCommandL( aCommand ); |
|
403 } |
|
404 break; |
|
405 |
|
406 |
|
407 case EGSCmdAppShutterExit: |
|
408 default: |
|
409 AppUi()->HandleCommandL( aCommand ); |
|
410 break; |
|
411 } |
|
412 } |
|
413 |
|
414 // ========================= From CGSPluginInterface ================== |
|
415 |
|
416 // ----------------------------------------------------------------------------- |
|
417 // CSIPSettingsPlugin::GetCaptionL |
|
418 // |
|
419 // Method for getting caption of this plugin. This should be the |
|
420 // localized name of the settings view to be shown in parent view. |
|
421 // ----------------------------------------------------------------------------- |
|
422 // |
|
423 void CSIPSettingsPlugin::GetCaptionL( TDes& aCaption ) const |
|
424 { |
|
425 __GSLOGSTRING("CSIPSettingsPlugin::GetCaptionL " ) |
|
426 HBufC* result = StringLoader::LoadL( R_GS_SIPSETTINGS_PLUGIN_CAPTION ); |
|
427 aCaption.Copy( *result ); |
|
428 delete result; |
|
429 } |
|
430 |
|
431 // ----------------------------------------------------------------------------- |
|
432 // CSIPSettingsPlugin::PluginProviderCategory |
|
433 // Method for reading the ID of the plugin provider category. |
|
434 // ----------------------------------------------------------------------------- |
|
435 // |
|
436 TInt CSIPSettingsPlugin::PluginProviderCategory() const |
|
437 { |
|
438 return KGSPluginProviderInternal; |
|
439 } |
|
440 |
|
441 // --------------------------------------------------------------------------- |
|
442 // CSIPSettingsPlugin::CreateIconL |
|
443 // |
|
444 // Return the icon, if has one. |
|
445 // --------------------------------------------------------------------------- |
|
446 // |
|
447 CGulIcon* CSIPSettingsPlugin::CreateIconL( const TUid aIconType ) |
|
448 { |
|
449 __GSLOGSTRING( "[CSIPSettingsPlugin] CreateIconL()|->" ) |
|
450 //EMbm<Mbm_file_name><Bitmap_name> |
|
451 CGulIcon* icon; |
|
452 |
|
453 if( aIconType == KGSIconTypeLbxItem ) |
|
454 { |
|
455 icon = AknsUtils::CreateGulIconL( |
|
456 AknsUtils::SkinInstance(), |
|
457 KAknsIIDQgnPropSetConnSip, |
|
458 KGSDefaultSIPIconFileName, |
|
459 EMbmGssipsettingspluginQgn_prop_set_conn_sip, |
|
460 EMbmGssipsettingspluginQgn_prop_set_conn_sip_mask ); |
|
461 } |
|
462 else |
|
463 { |
|
464 icon = CGSPluginInterface::CreateIconL( aIconType ); |
|
465 } |
|
466 |
|
467 __GSLOGSTRING( "[CSIPSettingsPlugin] CreateIconL()-|" ) |
|
468 return icon; |
|
469 } |
|
470 |
|
471 // ========================= MEikMenuObserver ================================= |
|
472 |
|
473 // ----------------------------------------------------------------------------- |
|
474 // CSIPSettingsPlugin::HandleListBoxEventL |
|
475 // Handles the list box events |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 void CSIPSettingsPlugin::HandleListBoxEventL( |
|
479 CEikListBox* /*aListBox*/, |
|
480 TListBoxEvent aEventType ) |
|
481 { |
|
482 __GSLOGSTRING("CSIPSettingsPlugin::HandleListBoxEventL " ) |
|
483 __GSLOGSTRING1("CSIPSettingsPlugin::HandleListBoxEventL aEventType: %d", aEventType) |
|
484 |
|
485 if( EEventPenDownOnItem == aEventType ) |
|
486 { |
|
487 iContainer->LongTapDetector()->PointerEventL( iContainer->PointerEvent() ); |
|
488 return; |
|
489 } |
|
490 if( EEventItemSingleClicked == aEventType || |
|
491 EEventEnterKeyPressed == aEventType ) |
|
492 { |
|
493 if ( !iContainer->LongPressStatus() ) |
|
494 { |
|
495 EditProfileL(); |
|
496 } |
|
497 } |
|
498 iContainer ->SetLongPress( EFalse ); |
|
499 } |
|
500 |
|
501 // ----------------------------------------------------------------------------- |
|
502 // CSIPSettingsPlugin::ChangeDefaultProfileL |
|
503 // Shows the pop-up list for changing the default profile |
|
504 // ----------------------------------------------------------------------------- |
|
505 // |
|
506 void CSIPSettingsPlugin::ChangeDefaultProfileL() |
|
507 { |
|
508 __GSLOGSTRING("CSIPSettingsPlugin::ChangeDefaultProfileL Start " ) |
|
509 TInt selectedIndex = iModel->DefaultProfileIndex(); |
|
510 TInt oldProfileIndex = selectedIndex; |
|
511 |
|
512 // Get the array of the profile names, ownership changes |
|
513 CDesCArray* array = iModel->ListOfProfileNamesL(); |
|
514 CleanupStack::PushL( array ); |
|
515 |
|
516 // Create and display the pop-up list |
|
517 CAknRadioButtonSettingPage* defaultPopUp = |
|
518 new ( ELeave ) CAknRadioButtonSettingPage( |
|
519 R_SIP_PROFILE_LIST_VIEW_DEFAULT_SETTING_PAGE, |
|
520 selectedIndex, |
|
521 array ); |
|
522 if ( defaultPopUp->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) ) |
|
523 { |
|
524 if ( selectedIndex != oldProfileIndex ) |
|
525 { |
|
526 // User has changed the default profile, set new setting |
|
527 // to persistent storage |
|
528 iModel->SetDefaultProfileL( selectedIndex ); |
|
529 } |
|
530 } |
|
531 |
|
532 CleanupStack::PopAndDestroy( array ); // array |
|
533 __GSLOGSTRING("CSIPSettingsPlugin::ChangeDefaultProfileL End" ) |
|
534 } |
|
535 |
|
536 // ----------------------------------------------------------------------------- |
|
537 // CSIPSettingsPlugin::CreateFromExistingProfileL |
|
538 // Shows pop-up list for user to choose the cloned profile |
|
539 // ----------------------------------------------------------------------------- |
|
540 // |
|
541 void CSIPSettingsPlugin::CreateFromExisitingProfileL() |
|
542 { |
|
543 __GSLOGSTRING("CSIPSettingsPlugin::CreateFromExisitingProfileL Start " ) |
|
544 // Creates list box for the pop-up list |
|
545 CEikFormattedCellListBox* listBox = new ( ELeave ) |
|
546 CAknSinglePopupMenuStyleListBox; |
|
547 CleanupStack::PushL( listBox ); |
|
548 |
|
549 // Create pop-up list |
|
550 CAknPopupList* popupList = CreatePopupListL( listBox ); |
|
551 |
|
552 // Show the pop-up list |
|
553 TBool profileSelected = popupList->ExecuteLD(); |
|
554 TInt index = listBox->CurrentItemIndex(); |
|
555 |
|
556 CleanupStack::PopAndDestroy( listBox ); |
|
557 |
|
558 if ( profileSelected ) |
|
559 { |
|
560 CreateNewProfileL( index ); |
|
561 } |
|
562 __GSLOGSTRING("CSIPSettingsPlugin::CreateFromExisitingProfileL End" ) |
|
563 } |
|
564 |
|
565 // ----------------------------------------------------------------------------- |
|
566 // CSIPSettingsPlugin::CreatePopupListL |
|
567 // Creates pop-up list for choosing the cloned profile |
|
568 // ----------------------------------------------------------------------------- |
|
569 // |
|
570 CAknPopupList* CSIPSettingsPlugin::CreatePopupListL( |
|
571 CEikFormattedCellListBox* aListBox ) |
|
572 { |
|
573 __GSLOGSTRING("CSIPSettingsPlugin::CreatePopupListL" ) |
|
574 // Create and initialize the popup list |
|
575 CAknPopupList* popupList = CAknPopupList::NewL( |
|
576 aListBox, R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, |
|
577 AknPopupLayouts::EPopupSNotePopupWindow ); |
|
578 CleanupStack::PushL( popupList ); |
|
579 |
|
580 // Set the title of the pop-up list |
|
581 HBufC* titleBuf = StringLoader::LoadLC( |
|
582 R_PROFILE_LIST_VIEW_NEW_PROFILE_LIST_TITLE ); |
|
583 popupList->SetTitleL( *titleBuf ); |
|
584 CleanupStack::PopAndDestroy( titleBuf ); |
|
585 |
|
586 // Initialize list box |
|
587 aListBox->ConstructL( popupList, |
|
588 EAknListBoxSelectionList ); |
|
589 aListBox->CreateScrollBarFrameL( ETrue ); |
|
590 aListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
591 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
592 aListBox->Model()->SetItemTextArray( iModel->ListOfProfileNamesL() ); |
|
593 |
|
594 CleanupStack::Pop( popupList ); |
|
595 |
|
596 return popupList; |
|
597 } |
|
598 |
|
599 // ----------------------------------------------------------------------------- |
|
600 // CSIPSettingsPlugin::CreateNewProfileL |
|
601 // Creates a new profile and changes the view to another |
|
602 // ----------------------------------------------------------------------------- |
|
603 // |
|
604 void CSIPSettingsPlugin::CreateNewProfileL( |
|
605 TInt aIndex ) |
|
606 { |
|
607 __GSLOGSTRING("CSIPSettingsPlugin::CreateNewProfileL" ) |
|
608 iActiveIndex = iContainer->CurrentIndex(); |
|
609 iModel->CreateNewProfileL( aIndex ); |
|
610 AppUi()->ActivateLocalViewL( KSettListSIPProfileSettingView ); |
|
611 } |
|
612 |
|
613 // ----------------------------------------------------------------------------- |
|
614 // CSIPSettListSIPProfListView::DeleteProfileL |
|
615 // Confirms from the user and then deletes the profile |
|
616 // ----------------------------------------------------------------------------- |
|
617 // |
|
618 void CSIPSettingsPlugin::DeleteProfileL() |
|
619 { |
|
620 __GSLOGSTRING("CSIPSettingsPlugin::DeleteProfileL Start" ) |
|
621 TUint count = iModel->NumOfProfiles(); |
|
622 if ( count == 0 ) |
|
623 { |
|
624 // No profiles to be deleted, so return |
|
625 return; |
|
626 } |
|
627 |
|
628 TBool isUse( EFalse ); |
|
629 TBool isDefault( EFalse ); |
|
630 TBool isLocked( EFalse ); |
|
631 iModel->CheckProfileForDeleteL( iContainer->CurrentIndex(), isUse, |
|
632 isDefault, isLocked ); |
|
633 |
|
634 // Don't allow delete profile which is in use. |
|
635 if ( isUse ) |
|
636 { |
|
637 HBufC* txtErr = StringLoader::LoadLC( |
|
638 R_QTN_SIP_ERROR_UNABLE_TO_DELETE ); |
|
639 CAknErrorNote* note = new ( ELeave ) CAknErrorNote( ETrue ); |
|
640 note->ExecuteLD( txtErr->Des() ); |
|
641 CleanupStack::PopAndDestroy( txtErr ); |
|
642 } |
|
643 // Don't allow delete default profile until it's last one. |
|
644 else if ( isDefault && count > 1 ) |
|
645 { |
|
646 HBufC* txtErr = StringLoader::LoadLC( |
|
647 R_QTN_SIP_ERROR_UNABLE_TO_DELETE_DEFAULT ); |
|
648 CAknErrorNote* note = new ( ELeave ) CAknErrorNote( ETrue ); |
|
649 note->ExecuteLD( txtErr->Des() ); |
|
650 CleanupStack::PopAndDestroy( txtErr ); |
|
651 } |
|
652 // Don't allow to delete profile which is locked |
|
653 else if ( isLocked ) |
|
654 { |
|
655 HBufC* txtErr = StringLoader::LoadLC( |
|
656 R_QTN_SIP_ERROR_UNABLE_TO_DEL_LOCKED ); |
|
657 CAknErrorNote* note = new ( ELeave ) CAknErrorNote( ETrue ); |
|
658 note->ExecuteLD( txtErr->Des() ); |
|
659 CleanupStack::PopAndDestroy( txtErr ); |
|
660 } |
|
661 else |
|
662 { |
|
663 // Load and initialize the dialog text |
|
664 HBufC* txtBuf = iModel->ProfileNameLC( iContainer->CurrentIndex() ); |
|
665 HBufC* dlgTxt = StringLoader::LoadLC( |
|
666 R_QTN_CONF_PROFILE_DELETE_LABEL, *txtBuf ); |
|
667 |
|
668 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
669 CleanupStack::PushL( dlg ); |
|
670 dlg->SetPromptL( *dlgTxt ); |
|
671 CleanupStack::Pop( dlg ); |
|
672 |
|
673 if ( dlg->ExecuteLD( R_SIP_DELETE_CONFIRMATION_DLG ) ) |
|
674 { |
|
675 iModel->DeleteProfileL( iContainer->CurrentIndex() ); |
|
676 if ( iActiveIndex && iActiveIndex == iContainer->CurrentIndex()) |
|
677 { |
|
678 iActiveIndex--; |
|
679 } |
|
680 } |
|
681 |
|
682 CleanupStack::PopAndDestroy( dlgTxt ); |
|
683 CleanupStack::PopAndDestroy( txtBuf ); |
|
684 } |
|
685 __GSLOGSTRING("CSIPSettingsPlugin::DeleteProfileL End" ) |
|
686 } |
|
687 |
|
688 // ----------------------------------------------------------------------------- |
|
689 // CSIPSettingsPlugin::EditProfileL |
|
690 // Edits existing profile |
|
691 // ----------------------------------------------------------------------------- |
|
692 // |
|
693 void CSIPSettingsPlugin::EditProfileL() |
|
694 { |
|
695 __GSLOGSTRING("CSIPSettingsPlugin::EditProfileL" ) |
|
696 if ( iContainer->CurrentIndex() < 0 ) |
|
697 { |
|
698 return; |
|
699 } |
|
700 |
|
701 TBool moveNxtView = iModel->EditProfileL( iContainer->CurrentIndex() ); |
|
702 |
|
703 if ( moveNxtView ) |
|
704 { |
|
705 iActiveIndex = iContainer->CurrentIndex(); |
|
706 AppUi()->ActivateLocalViewL( KSettListSIPProfileSettingView ); |
|
707 } |
|
708 } |
|
709 |
|
710 // ----------------------------------------------------------------------------- |
|
711 // CSIPSettListSIPProfListView::DynInitMenuPaneL |
|
712 // Initializes the menu dynamically before it is shown to the user |
|
713 // ----------------------------------------------------------------------------- |
|
714 // |
|
715 void CSIPSettingsPlugin::DynInitMenuPaneL( |
|
716 TInt aResourceId, |
|
717 CEikMenuPane* aMenuPane ) |
|
718 { |
|
719 __GSLOGSTRING("CSIPSettingsPlugin::DynInitMenuPaneL" ) |
|
720 // Delete Help item if feature is not supported |
|
721 if( aResourceId == R_GS_SIP_PROFILE_LIST_VIEW_MENU ) |
|
722 { |
|
723 if ( iContainer->IfPointerEvent() ) |
|
724 { |
|
725 aMenuPane->SetItemDimmed( EGSCmdAppEdit, ETrue ); |
|
726 aMenuPane->SetItemDimmed( EGSCmdAppDelete, ETrue ); |
|
727 aMenuPane->SetItemDimmed( EGSCmdAppDefault, ETrue ); |
|
728 } |
|
729 if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
730 { |
|
731 aMenuPane->DeleteMenuItem( EAknCmdHelp ); |
|
732 } |
|
733 } |
|
734 |
|
735 if ( aResourceId == R_GS_SIP_PROFILE_LIST_VIEW_MENU && |
|
736 iModel->NumOfProfiles() == 0 ) |
|
737 { |
|
738 // No profiles exist, time to dim some menu items |
|
739 aMenuPane->SetItemDimmed( EGSCmdAppEdit, ETrue ); |
|
740 aMenuPane->SetItemDimmed( EGSCmdAppDelete, ETrue ); |
|
741 aMenuPane->SetItemDimmed( EGSCmdAppDefault, ETrue ); |
|
742 } |
|
743 else if ( aResourceId == R_GS_SIP_PROFILE_LIST_ADD_NEW_MENU && |
|
744 iModel->NumOfProfiles() == 0 ) |
|
745 { |
|
746 // No profiles exist, time to dim some menu items |
|
747 aMenuPane->SetItemDimmed( EGSCmdAppNewExist, ETrue ); |
|
748 } |
|
749 else |
|
750 { |
|
751 // Do nothing |
|
752 } |
|
753 } |
|
754 |
|
755 // End of File |