presencesettingsui/src/psuisipxdmsettingitem.cpp
branchRCL_3
changeset 18 fbd2e7cec7ef
parent 0 c8caa15ef882
equal deleted inserted replaced
17:2669f8761a99 18:fbd2e7cec7ef
       
     1 /*
       
     2 * Copyright (c) 2006 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:    Setting item for SIP / XDM settings
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <psuigspluginrsc.rsg>
       
    23 #include <aknradiobuttonsettingpage.h>
       
    24 #include <akntextsettingpage.h>
       
    25 #include "psuigspluginmodel.h"
       
    26 #include "psuisipxdmsettingitem.h"
       
    27 
       
    28 // ========================= MEMBER FUNCTIONS ================================
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // CPSUISipXdmSettingItem::CPSUISipXdmSettingItem()
       
    32 // Default constructor.
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 CPSUISipXdmSettingItem::CPSUISipXdmSettingItem( 
       
    36     TInt aIdentifier, TInt& aId, CPSUIGSPluginModel* aPSModel ): 
       
    37         CAknSettingItem( aIdentifier ),
       
    38         iExtChosenSettingID ( aId ),
       
    39         iPSModel ( aPSModel )
       
    40     {
       
    41     }        
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // CPSUISipXdmSettingItem::~CPSUISipXdmSettingItem()
       
    45 // Destructor
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CPSUISipXdmSettingItem::~CPSUISipXdmSettingItem()
       
    49     {
       
    50     // iPSModel deleted elsewhere
       
    51     delete iPSUIInternalText;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // CPSUISipXdmSettingItem::LoadL()
       
    56 // See header for details. 
       
    57 // ---------------------------------------------------------------------------
       
    58 //    
       
    59 void CPSUISipXdmSettingItem::LoadL()
       
    60     {
       
    61     delete iPSUIInternalText;
       
    62     iPSUIInternalText = 0;
       
    63     
       
    64     TInt id = Identifier();
       
    65     if ( id == EPSUISIPProfileId )
       
    66         {// SIP
       
    67         iPSUIInternalText = iPSModel->SipProfileNameL( iExtChosenSettingID );
       
    68         }
       
    69     else if ( id ==  EPSUIXDMSettingsId )
       
    70         {// XDM
       
    71         iPSUIInternalText = iPSModel->XdmCollectionNameL( iExtChosenSettingID );
       
    72         }
       
    73     else
       
    74         {
       
    75         __ASSERT_DEBUG( 0,User::Panic( KPSUIGSPluginPanicCategory, KErrNotFound ));
       
    76         }        
       
    77 
       
    78     iIntChosenSettingID = iExtChosenSettingID;
       
    79     }    
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // CPSUISipXdmSettingItem::StoreL()
       
    83 // See header for details. 
       
    84 // ---------------------------------------------------------------------------
       
    85 // 
       
    86 void CPSUISipXdmSettingItem::StoreL()
       
    87     {
       
    88     iExtChosenSettingID = iIntChosenSettingID;
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // CPSUISipXdmSettingItem::SettingTextL()
       
    93 // See header for details. 
       
    94 // ---------------------------------------------------------------------------
       
    95 // 
       
    96 const TDesC& CPSUISipXdmSettingItem::SettingTextL()
       
    97     {
       
    98     if ( iPSUIInternalText->Length() > 0 )
       
    99         return *iPSUIInternalText;
       
   100     else
       
   101         return EmptyItemText();
       
   102     }    
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CPSUISipXdmSettingItem::EditItemL()
       
   106 // See header for details. 
       
   107 // ---------------------------------------------------------------------------
       
   108 //     
       
   109 void CPSUISipXdmSettingItem::EditItemL( TBool /*aCalledFromMenu*/ )
       
   110     {
       
   111     TInt id = Identifier();
       
   112     if ( id == EPSUISIPProfileId )
       
   113         {// SIP
       
   114         EditSipItemL();
       
   115         }
       
   116     else if ( id ==  EPSUIXDMSettingsId )
       
   117         {// XDM
       
   118         EditXdmItemL();
       
   119         }
       
   120     else
       
   121         {
       
   122         __ASSERT_DEBUG( 0,User::Panic( KPSUIGSPluginPanicCategory, KErrNotFound ));
       
   123         }
       
   124     }    
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // CPSUISipXdmSettingItem::EditSipItemL()
       
   128 // See header for details.
       
   129 // ---------------------------------------------------------------------------
       
   130 //  
       
   131 void CPSUISipXdmSettingItem::EditSipItemL()
       
   132     {
       
   133     CDesCArray* array = iPSModel->SipProfilesLC();
       
   134     TInt index = iPSModel->SipProfileIndex( iIntChosenSettingID );
       
   135     LaunchSettingDlgL( index, array );
       
   136     CleanupStack::PopAndDestroy( array );  // array
       
   137     
       
   138     if ( index != KErrNotFound )
       
   139         {// update only if index available
       
   140         iIntChosenSettingID = iPSModel->SipProfileId( index );
       
   141 
       
   142         delete iPSUIInternalText;
       
   143         iPSUIInternalText = 0;
       
   144         iPSUIInternalText = iPSModel->SipProfileNameL( iIntChosenSettingID );
       
   145         
       
   146         UpdateListBoxTextL();
       
   147         }
       
   148     }
       
   149 
       
   150 // ---------------------------------------------------------------------------
       
   151 // CPSUISipXdmSettingItem::EditXdmItemL()
       
   152 // See header for details.
       
   153 // ---------------------------------------------------------------------------
       
   154 //  
       
   155 void CPSUISipXdmSettingItem::EditXdmItemL()
       
   156     {
       
   157     CDesCArray* array = iPSModel->XdmCollectionNamesL();// array not owned
       
   158     TInt index = iPSModel->XdmSettingIndex( iIntChosenSettingID );
       
   159     LaunchSettingDlgL( index, array );
       
   160 
       
   161     if ( index != KErrNotFound )
       
   162         {// update only if index available
       
   163         iIntChosenSettingID = iPSModel->XdmSettingId( index );
       
   164 
       
   165         delete iPSUIInternalText;
       
   166         iPSUIInternalText = 0;
       
   167         iPSUIInternalText = iPSModel->XdmCollectionNameL( iIntChosenSettingID );
       
   168         
       
   169         UpdateListBoxTextL();
       
   170         }
       
   171     } 
       
   172 
       
   173 // ---------------------------------------------------------------------------
       
   174 // CPSUISipXdmSettingItem::LaunchSettingDlgL()
       
   175 // See header for details.
       
   176 // ---------------------------------------------------------------------------
       
   177 //
       
   178 void CPSUISipXdmSettingItem::LaunchSettingDlgL( TInt& aIndex, CDesCArray* aArray )
       
   179     {
       
   180     CAknRadioButtonSettingPage* dlg = new (ELeave ) CAknRadioButtonSettingPage(
       
   181         R_RADIOBUTTON_SETTING_PAGE, 
       
   182         aIndex, 
       
   183         aArray );
       
   184     CleanupStack::PushL( dlg );
       
   185     dlg->SetSettingTextL( SettingName() );
       
   186     SetSettingPage( dlg );
       
   187     SettingPage()->SetSettingPageObserver( this );
       
   188     CleanupStack::Pop( dlg );  // dlg
       
   189     SettingPage()->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted );
       
   190     SetSettingPage( 0 ); // dlg deleted
       
   191     }
       
   192 
       
   193 // End of File