cmmanager/cmmgr/Framework/Src/cmconnselectrbpage.cpp
changeset 0 5a93021fdf25
child 3 f7816ffc66ed
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     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:  Implementation of plugin base class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <cmmanager.rsg>
       
    20 #include <StringLoader.h>
       
    21 
       
    22 #include "cmconnselectrbpage.h"
       
    23 #include "cmmanager.hrh"
       
    24 #include "cmconnsettingsuiimpl.h"
       
    25 #include "cmlogger.h"
       
    26 
       
    27 using namespace CMManager;
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // CCMConnSelectRBPage::CCMConnSelectRBPage
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CCMConnSelectRBPage::CCMConnSelectRBPage( TInt aDialogResourceId, 
       
    34                                     TInt& aCurrentSelectionIndex, 
       
    35                                     const MDesCArray* aItemArray, 
       
    36                                     CCmManagerImpl& aCmManagerImpl, 
       
    37                                     TCmDCSettingSelectionMode& aSelectionMode,
       
    38                                     RArray<TUint32>& aDestinations,
       
    39                                     TBool areDestinations,
       
    40                                     TBool aOpenDestination,
       
    41                                     TCoeContextName& aContext )
       
    42     : CAknRadioButtonSettingPage( aDialogResourceId, 
       
    43                                   aCurrentSelectionIndex, 
       
    44                                   aItemArray )
       
    45 	, iDialogResourceId (aDialogResourceId)
       
    46     , iCmManagerImpl( aCmManagerImpl )
       
    47     , iSelectionMode( aSelectionMode )
       
    48     , iDestinations( aDestinations )
       
    49     , iAreDestinations( areDestinations )
       
    50     , iOpenDestination( aOpenDestination )
       
    51     , iHelpContext ( aContext )
       
    52     {
       
    53     CLOG_CREATE;
       
    54     iPrevItem = iDestinations[aCurrentSelectionIndex];
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CCMConnSelectRBPage::~CCMConnSelectRBPage
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CCMConnSelectRBPage::~CCMConnSelectRBPage()
       
    62     {
       
    63     CLOG_CLOSE;    
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // CCMConnSelectRBPage::OkToExitL
       
    68 // Good to know : EAknSoftkeyCancel is never called, because
       
    69 // EEikDialogFlagNotifyEsc flag is not set in the resource.
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 TBool CCMConnSelectRBPage::OkToExitL( TInt aButtonId )
       
    73     {
       
    74     LOGGER_ENTERFN("CCMConnSelectRBPage::OkToExitL");
       
    75 
       
    76     // Convert the button presses into commands for the appui & current
       
    77     // view to handle
       
    78     TBool retval( EFalse );
       
    79     if ( aButtonId ==  EAknSoftkeyOk )
       
    80         {
       
    81         ProcessCommandL( ECmManagerUiCmdDestSelect );
       
    82         retval = ETrue;        
       
    83         }
       
    84     else 
       
    85         {
       
    86         if ( aButtonId == EAknSoftkeyOptions )
       
    87             {
       
    88             //*iSelected = iListbox->CurrentItemUid();
       
    89             //retval = ETrue;
       
    90             DisplayMenuL();
       
    91             retval = EFalse;  
       
    92             }
       
    93         else
       
    94             {
       
    95            	retval = ETrue;
       
    96             }
       
    97         }
       
    98 
       
    99     return retval;
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CCMConnSelectRBPage::ProcessCommandL
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 void CCMConnSelectRBPage::ProcessCommandL( TInt aCommandId )
       
   107     {
       
   108     LOGGER_ENTERFN("CCMConnSelectRBPage::ProcessCommandL");
       
   109     
       
   110     if ( MenuShowing() )
       
   111         {
       
   112         HideMenu();
       
   113         }
       
   114 
       
   115     switch ( aCommandId )
       
   116         {
       
   117         case EAknSoftkeyOptions:
       
   118             {
       
   119             DisplayMenuL();
       
   120             break;
       
   121             }
       
   122 
       
   123         case EAknSoftkeyCancel:
       
   124             {
       
   125             AttemptExitL(EFalse);   
       
   126             break;
       
   127             }
       
   128 
       
   129         case EAknSoftkeyOk:                   
       
   130         case EAknSoftkeySelect:                   
       
   131         case ECmManagerUiCmdDestSelect:
       
   132             {
       
   133             TUint selectedItem = 
       
   134                     iDestinations[ ListBoxControl()->CurrentItemIndex() ];
       
   135             if ( selectedItem == KDestItemAlwaysAsk )
       
   136                 {
       
   137                 iSelectionMode = EDCAlwaysAsk;
       
   138                 }
       
   139             else if ( selectedItem == KDestItemAskOnce )
       
   140                 {
       
   141                 iSelectionMode = EDCAskOnce;
       
   142                 }
       
   143             else if ( selectedItem == KDestItemDefaultConnection )
       
   144                 {
       
   145                 iSelectionMode = EDCDefaultConnection;
       
   146                 }
       
   147             else if ( selectedItem == KDestItemUncategorized )
       
   148                 {
       
   149                 iSelectionMode = EDCConnectionMethod;
       
   150                 }
       
   151             else 
       
   152                 {
       
   153                 if (iAreDestinations)
       
   154                     {
       
   155                     iSelectionMode = EDCDestination;
       
   156                     }
       
   157                 else
       
   158                     {
       
   159                     iSelectionMode = EDCConnectionMethod;                        
       
   160                     }    
       
   161                 }
       
   162             //iId is to be defined in the caller class   
       
   163             SelectCurrentItemL();         
       
   164             AttemptExitL(ETrue);
       
   165             break;
       
   166             }
       
   167 
       
   168         case ECmManagerUiCmdCMSelect:
       
   169             {
       
   170             iSelectionMode = EDCConnectionMethod;
       
   171             SelectCurrentItemL();         
       
   172             AttemptExitL( ETrue );                   
       
   173             break;
       
   174             }
       
   175         case EAknCmdHelp:
       
   176             {
       
   177             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   178                                     iEikonEnv->EikAppUi()->AppHelpContextL() );
       
   179             }
       
   180             break;
       
   181         default:
       
   182             {
       
   183             break;
       
   184             }
       
   185         }
       
   186     }    
       
   187 
       
   188 // ---------------------------------------------------------------------------
       
   189 // CCMConnSelectRBPage::DynInitMenuPaneL
       
   190 // ---------------------------------------------------------------------------
       
   191 //
       
   192 void CCMConnSelectRBPage::DynInitMenuPaneL( TInt aResourceId,
       
   193                                          CEikMenuPane* aMenuPane )
       
   194     {
       
   195     LOGGER_ENTERFN("CCMConnSelectRBPage::DynInitMenuPaneL");
       
   196 
       
   197     CAknSettingPage::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   198     if ( aResourceId == R_SELECT_NETW_CONN_MENU )
       
   199         {
       
   200     	if (!iCmManagerImpl.IsHelpOn())
       
   201             {
       
   202             aMenuPane->DeleteMenuItem( EAknCmdHelp );		    
       
   203             }
       
   204         TUint32 currentItem = 
       
   205                     iDestinations[ ListBoxControl()->CurrentItemIndex() ];
       
   206         
       
   207         // Always Ask ( always the first item )
       
   208         if ( (currentItem == KDestItemAlwaysAsk) || 
       
   209              (currentItem == KDestItemAskOnce) || 
       
   210              (currentItem == KDestItemDefaultConnection) ||
       
   211               !iOpenDestination )
       
   212             {
       
   213             aMenuPane->SetItemDimmed( ECmManagerUiCmdCMSelect, ETrue );
       
   214             }        
       
   215         else if ( ( currentItem != KDestItemAlwaysAsk ) && 
       
   216                   ( currentItem != KDestItemAskOnce ) && 
       
   217                   ( currentItem != KDestItemDefaultConnection ) &&
       
   218                   ( currentItem != KDestItemUncategorized ))
       
   219             {
       
   220             CCmDestinationImpl* destImpl = iCmManagerImpl.DestinationL( currentItem );
       
   221             
       
   222             if ( !destImpl->ConnectionMethodCount() )
       
   223                 {
       
   224                 aMenuPane->SetItemDimmed( ECmManagerUiCmdCMSelect, ETrue );                
       
   225                 }
       
   226                 
       
   227             delete destImpl;
       
   228             }
       
   229         else
       
   230             {
       
   231             RArray<TUint32> uncatArray( KCmArraySmallGranularity );
       
   232             CleanupClosePushL( uncatArray );
       
   233             iCmManagerImpl.ConnectionMethodL( uncatArray );
       
   234             
       
   235             // Uncategorised - cannot be selected
       
   236             if ( currentItem == KDestItemUncategorized )
       
   237                 {
       
   238                 aMenuPane->SetItemDimmed( ECmManagerUiCmdDestSelect, ETrue );
       
   239                 }
       
   240             CleanupStack::PopAndDestroy( &uncatArray );
       
   241             }
       
   242         }
       
   243     }
       
   244 
       
   245 
       
   246 // ---------------------------------------------------------------------------
       
   247 // CCMConnSelectRBPage::OfferKeyEventL
       
   248 // ---------------------------------------------------------------------------
       
   249 //
       
   250 TKeyResponse CCMConnSelectRBPage::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   251                                                TEventCode aType )    
       
   252     {
       
   253     LOGGER_ENTERFN("CCMConnSelectRBPage::OfferKeyEventL");
       
   254     
       
   255     TKeyResponse retVal ( EKeyWasNotConsumed );
       
   256     // save for the future use
       
   257     iPrevItem = iDestinations[ListBoxControl()->CurrentItemIndex()];
       
   258     
       
   259     switch ( aKeyEvent.iScanCode )
       
   260         {
       
   261         case EStdKeyDownArrow:
       
   262         case EStdKeyUpArrow:
       
   263             {
       
   264             if ( iOpenDestination ) //only if we are on 'destination level' and we are able to
       
   265                 //open destinations
       
   266                 {            
       
   267                 // If focus is on the 'uncategorised' destination, 
       
   268                 // change the soft key to 'Open'
       
   269                 if ( iDestinations[ ListBoxControl()->CurrentItemIndex() ] == 
       
   270                                                         KDestItemUncategorized )
       
   271                     {
       
   272                     HBufC* text = StringLoader::LoadLC( R_QTN_MSK_OPEN );
       
   273                     Cba()->SetCommandL( EAknSoftkeySelect, *text );
       
   274                     Cba()->DrawNow();
       
   275                     CleanupStack::PopAndDestroy( text );                
       
   276                     }
       
   277                 else
       
   278                     {
       
   279                     HBufC* text = StringLoader::LoadLC( R_QTN_MSK_SELECT );
       
   280                     Cba()->SetCommandL( EAknSoftkeySelect, *text );
       
   281                     Cba()->DrawNow();
       
   282                     CleanupStack::PopAndDestroy( text );
       
   283                     }
       
   284                 }
       
   285             break;
       
   286             }
       
   287         default:
       
   288             {
       
   289             break;
       
   290             }
       
   291         }
       
   292     retVal = CAknRadioButtonSettingPage::OfferKeyEventL( aKeyEvent, aType );
       
   293     
       
   294     return retVal;
       
   295     }
       
   296 
       
   297 // --------------------------------------------------------------------------
       
   298 // CCMConnSelectRBPage::GetHelpContext
       
   299 // --------------------------------------------------------------------------
       
   300 //
       
   301 void CCMConnSelectRBPage::GetHelpContext( TCoeHelpContext& aContext ) const
       
   302     {
       
   303     LOGGER_ENTERFN("CCMConnSelectRBPage::GetHelpContext");
       
   304         
       
   305     aContext.iMajor = KHelpUidPlugin;
       
   306     aContext.iContext = iHelpContext; 
       
   307     }
       
   308 
       
   309 // ---------------------------------------------------------------------------
       
   310 // CCMConnSelectRBPage::HandleListBoxEventL
       
   311 // ---------------------------------------------------------------------------
       
   312 //
       
   313 void CCMConnSelectRBPage::HandleListBoxEventL(CEikListBox* aListBox, 
       
   314 		MEikListBoxObserver::TListBoxEvent aEventType)
       
   315 	{
       
   316     LOGGER_ENTERFN("CCMConnSelectRBPage::HandleListBoxEventL");
       
   317         
       
   318     if ( AknLayoutUtils::PenEnabled() )
       
   319         {
       
   320 
       
   321 		if (iDialogResourceId == R_RADIO_BUTTON_SETTING_PAGE_OK_CANCEL)
       
   322 			{
       
   323 			// Call base class implementation and return if no options menu
       
   324 			CAknRadioButtonSettingPage::HandleListBoxEventL(aListBox, aEventType);
       
   325 		
       
   326 	    	switch ( aEventType )
       
   327     	    	{
       
   328         		case EEventEnterKeyPressed:
       
   329         		case EEventItemDoubleClicked:
       
   330 				case EEventItemClicked:        	
       
   331             		{
       
   332             		ProcessCommandL(ECmManagerUiCmdDestSelect);
       
   333             		break;
       
   334             		}
       
   335 
       
   336         		default:
       
   337 	            	{
       
   338     	        	break;
       
   339             		}
       
   340         		}
       
   341 			return;
       
   342 			}
       
   343 		
       
   344         switch ( aEventType )
       
   345             {
       
   346             // All these actions are activating the listbox item
       
   347             case MEikListBoxObserver::EEventEnterKeyPressed:
       
   348             case MEikListBoxObserver::EEventItemActioned:
       
   349                 CAknRadioButtonSettingPage::HandleListBoxEventL(aListBox, aEventType);
       
   350                 break;
       
   351 
       
   352             case MEikListBoxObserver::EEventItemClicked:
       
   353             case MEikListBoxObserver::EEventItemSingleClicked:
       
   354                 if (iPrevItem == iDestinations[ListBoxControl()->CurrentItemIndex()])
       
   355                     {
       
   356                     ProcessCommandL(ECmManagerUiCmdDestSelect);
       
   357                     }
       
   358                 else
       
   359                     {
       
   360                     // save for the later use
       
   361                     iPrevItem = iDestinations[ListBoxControl()->CurrentItemIndex()];
       
   362 					    
       
   363 		            if ( iOpenDestination ) //only if we are on 'destination level' and we are able to
       
   364         		        //open destinations
       
   365                 		{            
       
   366                 		// If focus is on the 'uncategorised' destination, 
       
   367                 		// change the soft key to 'Open'
       
   368                 		if ( iDestinations[ ListBoxControl()->CurrentItemIndex() ] == 
       
   369 		                                                        KDestItemUncategorized )
       
   370         		            {
       
   371                 		    HBufC* text = StringLoader::LoadLC( R_QTN_MSK_OPEN );
       
   372                     		Cba()->SetCommandL( EAknSoftkeySelect, *text );
       
   373                     		Cba()->DrawNow();
       
   374                     		CleanupStack::PopAndDestroy( text );                
       
   375                     		}
       
   376                 		else
       
   377                     		{
       
   378                     		HBufC* text = StringLoader::LoadLC( R_QTN_MSK_SELECT );
       
   379                     		Cba()->SetCommandL( EAknSoftkeySelect, *text );
       
   380                     		Cba()->DrawNow();
       
   381                     		CleanupStack::PopAndDestroy( text );
       
   382                     		}
       
   383                 		}
       
   384 		            CAknRadioButtonSettingPage::HandleListBoxEventL(aListBox, aEventType);
       
   385                 	}
       
   386                 break;
       
   387                 
       
   388             case MEikListBoxObserver::EEventItemDoubleClicked:
       
   389                 ProcessCommandL(ECmManagerUiCmdDestSelect);
       
   390                 break;
       
   391 
       
   392             default:
       
   393                 CAknRadioButtonSettingPage::HandleListBoxEventL(aListBox, aEventType);            
       
   394                 break;
       
   395             }
       
   396         }
       
   397     else
       
   398         {
       
   399         CAknRadioButtonSettingPage::HandleListBoxEventL(aListBox, aEventType);
       
   400 		}		
       
   401 	}
       
   402 
       
   403