XDMSettingsUI/src/XDMPluginSettinglist.cpp
changeset 0 c8caa15ef882
child 7 895b8e06c769
child 12 e6a66db4e9d0
equal deleted inserted replaced
-1:000000000000 0:c8caa15ef882
       
     1 /*
       
     2 * Copyright (c) 2005-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:    XDM GS plugin, Setting List class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "XDMExternalInterface.h"
       
    23 
       
    24 #include <barsread.h>
       
    25 #include <ApSettingsHandlerUI.h>
       
    26 #include <ApUtils.h>
       
    27 #include <commdb.h>
       
    28 #include <avkon.loc>
       
    29 #include <StringLoader.h>
       
    30 #include <akntitle.h>
       
    31 #include <eikspane.h>
       
    32 
       
    33 #include "XDMPlugin.hrh"
       
    34 #include "XDMPluginSettinglist.h"
       
    35 #include "SettingsData.h"
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CXDMPluginSettinglist::NewL(CSettingsData &aData)
       
    39 // -----------------------------------------------------------------------------
       
    40 // 
       
    41 CXDMPluginSettinglist *CXDMPluginSettinglist::NewL(CSettingsData &aData)
       
    42     {
       
    43     CXDMPluginSettinglist* self = CXDMPluginSettinglist::NewLC(aData);
       
    44     CleanupStack::Pop(self);
       
    45     return self;
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CXDMPluginSettinglist::NewLC(CSettingsData &aData)
       
    50 // -----------------------------------------------------------------------------
       
    51 // 
       
    52 CXDMPluginSettinglist *CXDMPluginSettinglist::NewLC(CSettingsData &aData)
       
    53     {
       
    54     CXDMPluginSettinglist* self = new (ELeave) CXDMPluginSettinglist(aData);
       
    55     CleanupStack::PushL(self);
       
    56     return self;
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CXDMPluginSettinglist::CXDMPluginSettinglist(CSettingsData &aData)
       
    61 // -----------------------------------------------------------------------------
       
    62 // 
       
    63 CXDMPluginSettinglist::CXDMPluginSettinglist(CSettingsData &aData) : 
       
    64     CAknSettingItemList(),
       
    65     iSettingsData(aData)  
       
    66     {
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CXDMPluginSettinglist::~CXDMPluginSettinglist()
       
    71 // -----------------------------------------------------------------------------
       
    72 // 
       
    73 CXDMPluginSettinglist::~CXDMPluginSettinglist()
       
    74   {
       
    75   // no specific destruction code required - no owned data
       
    76   }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CXDMPluginSettinglist::SizeChanged()
       
    80 // -----------------------------------------------------------------------------
       
    81 // 
       
    82 void CXDMPluginSettinglist::SizeChanged()
       
    83     {
       
    84     // if size changes, make sure component takes whole available space
       
    85     if (ListBox()) 
       
    86         {
       
    87         ListBox()->SetRect(Rect());
       
    88         }
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CXDMPluginSettinglist::EditCurrentItemL()
       
    93 // -----------------------------------------------------------------------------
       
    94 // 
       
    95 void CXDMPluginSettinglist::EditCurrentItemL()
       
    96     {
       
    97     // invoke EditItemL on the current item
       
    98     TInt index = ListBox()->CurrentItemIndex();
       
    99 
       
   100     //Cause SIP setting is hidden
       
   101     if(index >= 3) //ESipURLIndex == 3
       
   102       index++;
       
   103     
       
   104     // if access point need to be edit
       
   105     if (index == EAccessPointIndex)
       
   106         {
       
   107         EditAccessPointL();
       
   108         SaveSettingL(index);
       
   109         }
       
   110     else 
       
   111         EditItemL(index,ETrue); // invoked from menu
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CXDMPluginSettinglist::EditItemL (TInt aIndex, TBool aCalledFromMenu)
       
   116 // -----------------------------------------------------------------------------
       
   117 // 
       
   118 void CXDMPluginSettinglist::EditItemL (TInt aIndex, TBool aCalledFromMenu)
       
   119     {
       
   120     if (aIndex == EAccessPointIndex)
       
   121       {
       
   122       EditAccessPointL();
       
   123       }
       
   124     else
       
   125         {
       
   126          CAknSettingItemList::EditItemL(aIndex, aCalledFromMenu);
       
   127         }
       
   128     (*SettingItemArray())[aIndex]->StoreL();
       
   129     SaveSettingL(aIndex);
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CXDMPluginSettinglist::SaveSettingL(TInt aIndex)
       
   134 // -----------------------------------------------------------------------------
       
   135 // 
       
   136 void CXDMPluginSettinglist::SaveSettingL(TInt aIndex)
       
   137     {
       
   138     
       
   139     switch (aIndex)
       
   140         {
       
   141         case ESettingNameIndex:
       
   142             SetTitlePaneTextL(iSettingsData.iSettingNameDisp);         
       
   143             break;
       
   144  
       
   145          case EAccessPointIndex:
       
   146             if (iSettingsData.iAccessPoint > -1) // if Valid AP number
       
   147                 {
       
   148                 (iSettingsData.iAccessPointDes).Num(iSettingsData.iAccessPoint);
       
   149                 GetAccessPointNameL(iSettingsData.iAccessPoint, 
       
   150                                                     iSettingsData.iAccessPointName);
       
   151                 }
       
   152             LoadSettingsL();
       
   153             break;
       
   154  
       
   155         case EServerAddressIndex:
       
   156             break;
       
   157         
       
   158         
       
   159         case ESipURLIndex:
       
   160             break;
       
   161         case EUserIDIndex:
       
   162             break;
       
   163             
       
   164         case EPasswordIndex:
       
   165             break;
       
   166             
       
   167         default:
       
   168             break;
       
   169         }
       
   170     }
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // CXDMPluginSettinglist::CreateSettingItemL (TInt aIdentifier) 
       
   174 // -----------------------------------------------------------------------------
       
   175 // 
       
   176 CAknSettingItem * CXDMPluginSettinglist::CreateSettingItemL (TInt aIdentifier) 
       
   177     {
       
   178     // method is used to create specific setting item as required at run-time.
       
   179     // aIdentifier is used to determine what kind of setting item should be 
       
   180     // created
       
   181 
       
   182     CAknSettingItem* settingItem = NULL;
       
   183 
       
   184     switch (aIdentifier)
       
   185         {
       
   186         case ESettingItemSettingName:
       
   187             
       
   188             settingItem = new (ELeave) CAknTextSettingItem ( aIdentifier,
       
   189                                                    iSettingsData.iSettingNameDisp);
       
   190             break;
       
   191 
       
   192         case ESettingItemAccessPoint:
       
   193             GetAccessPointNameL(iSettingsData.iAccessPoint, iSettingsData.iAccessPointName);
       
   194             settingItem = new (ELeave) CAknTextSettingItem (
       
   195                           aIdentifier, iSettingsData.iAccessPointName);
       
   196             break;
       
   197 
       
   198         case ESettingItemServerAddress:
       
   199             settingItem = new (ELeave) CAknTextSettingItem (
       
   200                           aIdentifier, 
       
   201                           iSettingsData.iServerAddress);
       
   202             break;
       
   203 
       
   204 
       
   205         
       
   206         case ESettingItemSipURL:
       
   207             settingItem = new (ELeave) CAknTextSettingItem (
       
   208                           aIdentifier, 
       
   209                           iSettingsData.iSipURL);
       
   210                 settingItem->SetHidden(ETrue);
       
   211             break;
       
   212         
       
   213 
       
   214         case ESettingItemUserID:
       
   215             settingItem = new (ELeave) CAknTextSettingItem (
       
   216                           aIdentifier, 
       
   217                           iSettingsData.iUserID);
       
   218             break;
       
   219         case ESettingItemPassword:
       
   220             settingItem = new (ELeave) CAknPasswordSettingItem (
       
   221                           aIdentifier, 
       
   222                           CAknPasswordSettingItem::EAlpha,
       
   223                           iSettingsData.iPassword);
       
   224             break;
       
   225         default:
       
   226             break;
       
   227         }
       
   228     return settingItem;
       
   229     }
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // CXDMPluginSettinglist::EditAccessPoint()
       
   233 // -----------------------------------------------------------------------------
       
   234 // 
       
   235 void CXDMPluginSettinglist::EditAccessPointL()
       
   236     {
       
   237     // After dialog server for access point selection (RGenConAgentDialogServer)
       
   238     // has deprecated wins emulator mode needs a different technique to show
       
   239     // emulator-lan access point.
       
   240     
       
   241     CCommsDatabase* commsDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
       
   242     CleanupStack::PushL(commsDb);
       
   243     CApUtils* aPUtils = CApUtils::NewLC( *commsDb );
       
   244 
       
   245     CApSettingsHandler *apUi = CApSettingsHandler::NewLC(
       
   246                                                         ETrue, 
       
   247                                                         EApSettingsSelListIsPopUp,
       
   248                                                         EApSettingsSelMenuSelectNormal,
       
   249                                                         KEApIspTypeAll,
       
   250                                                         EApBearerTypeAllBearers,
       
   251                                                         KEApSortNameAscending,
       
   252                                                         EIPv4 | EIPv6
       
   253                                                         );
       
   254     TUint32 id;
       
   255     
       
   256     TRAP_IGNORE(id = aPUtils->WapIdFromIapIdL(iSettingsData.iAccessPoint));
       
   257     
       
   258     //err can also be in case this is new set, iSettingsData.iAccessPoint = -1
       
   259     //so ignoring the error
       
   260     
       
   261     if ( apUi->RunSettingsL( id, id ) == KApUiEventSelected)
       
   262         {
       
   263     iSettingsData.iAccessPoint = aPUtils->IapIdFromWapIdL(id);
       
   264         }
       
   265     CleanupStack::PopAndDestroy(3, commsDb); //commsDb, aPUtils, apUi
       
   266     }
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // CXDMPluginSettinglist::GetAccessPointNameL(TInt32 aAP, TDes& aAccessPoint)
       
   270 // -----------------------------------------------------------------------------
       
   271 // 
       
   272 void CXDMPluginSettinglist::GetAccessPointNameL(TInt32 aAP, TDes& aAccessPoint)
       
   273     {
       
   274 #if defined __WINS__ && defined _DEBUG // handled differently in wins+debug
       
   275     if (aAP != KErrNotFound) // if access point is defined take a general name
       
   276         StringLoader::Load ( aAccessPoint, R_STR_XDM_AP_NAME_FOR_DEBUG_ONLY);    
       
   277 #else
       
   278     CCommsDatabase* commsDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
       
   279     CleanupStack::PushL(commsDb);
       
   280     CApUtils* aPUtils = CApUtils::NewLC( *commsDb );
       
   281     TInt err(KErrNone);
       
   282     // to remove id bug
       
   283     TRAP(err, aAP = aPUtils->WapIdFromIapIdL(aAP)); 
       
   284     TRAP(err, aPUtils->NameL(aAP, aAccessPoint));
       
   285     // dont do anything if name not found or if some error occur
       
   286     CleanupStack::PopAndDestroy(2); // commsDb, aPUtils
       
   287 #endif 
       
   288     }
       
   289 
       
   290 // -----------------------------------------------------------------------------
       
   291 // CXDMPluginSettinglist::SetTitlePaneTextL( const TDesC& aTitleText ) const
       
   292 // -----------------------------------------------------------------------------
       
   293 // 
       
   294 void CXDMPluginSettinglist::SetTitlePaneTextL( const TDesC& aTitleText ) const
       
   295     {
       
   296     CAknTitlePane* title = static_cast< CAknTitlePane* >
       
   297         ( CEikonEnv::Static()->AppUiFactory()->StatusPane()->ControlL(
       
   298                                         TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   299     if ( !title )
       
   300         {
       
   301         User::Leave( KErrNotSupported );
       
   302         }
       
   303 
       
   304     title->SetTextL( aTitleText );
       
   305     }
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // CXDMPluginSettinglist::ResetItemIndex()
       
   309 // -----------------------------------------------------------------------------
       
   310 // 
       
   311 void CXDMPluginSettinglist::ResetItemIndex()
       
   312     {
       
   313     ListBox()->SetCurrentItemIndexAndDraw(NULL);
       
   314     }
       
   315 
       
   316 // End of File