bluetoothengine/btui/src/BTUIAppUi.cpp
branchRCL_3
changeset 56 9386f31cc85b
parent 0 f63038272f30
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
       
     1 /*
       
     2 * Copyright (c) 2002-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:   This class the care of opening and closing the views.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "BTUIDocument.h"
       
    21 #include <aknview.h>
       
    22 #include "BTUIAppUi.h"
       
    23 #include <avkon.hrh>
       
    24 #include <aknappui.h>
       
    25 #include "BtuiPluginInterface.h"
       
    26 #include "btui.h"
       
    27 #include "BTUIMainView.h"
       
    28 #include "debug.h"
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 
       
    32 // ----------------------------------------------------------
       
    33 // CBTUIAppUi::ConstructL
       
    34 //
       
    35 // Symbian 2nd phase constructor can leave. 
       
    36 // Contains status pane, navi pane, tab group and view 
       
    37 // creations and setting the main view active.
       
    38 // ----------------------------------------------------------
       
    39 //
       
    40 void CBTUIAppUi::ConstructL()
       
    41     {
       
    42     TRACE_FUNC_ENTRY
       
    43 
       
    44     BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible);
       
    45 
       
    46     // Show tabs for main views from resources
       
    47     CEikStatusPane* sp = StatusPane();
       
    48 
       
    49     // Fetch pointer to the default navi pane control
       
    50     iNaviPane = (CAknNavigationControlContainer*)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
       
    51 
       
    52     // Tabgroup has been read from resource and it were pushed to the navi pane.
       
    53     // Get pointer to the navigation decorator and set this to be a MAknTabObserver    
       
    54     iDecoratedTabGroup = iNaviPane->ResourceDecorator();
       
    55 
       
    56     if (iDecoratedTabGroup)
       
    57         {
       
    58         iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
       
    59         iTabGroup->SetObserver( this );
       
    60         }    
       
    61         
       
    62     // -----------------------------------------------------------------------    
       
    63     // Construct Views by calling ECOM interface CBtuiPluginInterface's 
       
    64     // factory function NewL(), which in turn will call instantiation funtion
       
    65     // of the concrate class that implement this interface.
       
    66     // -----------------------------------------------------------------------
       
    67         
       
    68 	// 1.Construct Mainview 
       
    69 	// 
       
    70     CBtuiPluginInterface* mainView = CBtuiPluginInterface::NewL(KBtuiPluginUidMainView,(MBtuiPluginViewActivationObserver*) this );
       
    71    		
       
    72     CleanupStack::PushL( mainView );
       
    73     AddViewL( mainView ); // Transfer ownership to CAknViewAppUi
       
    74     CleanupStack::Pop(mainView );    
       
    75 
       
    76 	// 2.Construct OtherDeviceView
       
    77 	//
       
    78     CBtuiPluginInterface* otherDeviceView = CBtuiPluginInterface::NewL(
       
    79     	KBtuiPluginUidPairedDevicesView, (MBtuiPluginViewActivationObserver*) this );	
       
    80 
       
    81     CleanupStack::PushL( otherDeviceView );
       
    82     AddViewL( otherDeviceView ); // Transfer ownership to CAknViewAppUi
       
    83     CleanupStack::Pop(otherDeviceView );
       
    84 
       
    85 	// 3.Construct BlockDeviceView
       
    86 	//
       
    87     CBtuiPluginInterface* blockDeviceView = CBtuiPluginInterface::NewL(
       
    88     	KBtuiPluginUidBlockedDevicesView , (MBtuiPluginViewActivationObserver*) this );	
       
    89 
       
    90     CleanupStack::PushL( blockDeviceView );
       
    91     AddViewL( blockDeviceView ); // Transfer ownership to CAknViewAppUi
       
    92     CleanupStack::Pop(blockDeviceView );
       
    93 
       
    94     //ActivateLocalViewL( mainView->Id() ); 
       
    95     TRACE_FUNC_EXIT
       
    96     }
       
    97 
       
    98 // ----------------------------------------------------
       
    99 // CBTUIAppUi::~CBTUIAppUi
       
   100 // ----------------------------------------------------
       
   101 //
       
   102 CBTUIAppUi::~CBTUIAppUi() 
       
   103     {
       
   104     TRACE_FUNC_ENTRY
       
   105     if(iNaviPane != NULL && iDecoratedTabGroup != NULL)
       
   106     	{
       
   107     
       
   108   		delete iDecoratedTabGroup; // Tabgroup was read from resource.
       
   109   		iDecoratedTabGroup=NULL;
       
   110     	}
       
   111   	
       
   112 	REComSession::FinalClose();
       
   113   	
       
   114     TRACE_FUNC_EXIT
       
   115     }
       
   116 
       
   117 
       
   118 // ------------------------------------------------------------------------------
       
   119 // CBTUIAppUi::DynInitMenuPaneL
       
   120 //
       
   121 // This function is called by the UIKON framework just before it displays
       
   122 // a menu pane. Its default implementation is empty, and by overriding it,
       
   123 // the application can set the state of menu items dynamically according
       
   124 // to the state of application data.
       
   125 // ------------------------------------------------------------------------------
       
   126 //
       
   127 void CBTUIAppUi::DynInitMenuPaneL( TInt /* aResourceId */, CEikMenuPane* /* aMenuPane */ )
       
   128     {
       
   129     }
       
   130 
       
   131 // ----------------------------------------------------
       
   132 // CBTUIAppUi::HandleKeyEventL
       
   133 // ----------------------------------------------------
       
   134 //
       
   135 
       
   136 TKeyResponse CBTUIAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   137     {
       
   138     TRACE_FUNC
       
   139 
       
   140     iTabGroup = (CAknTabGroup*)iDecoratedTabGroup->DecoratedControl();
       
   141     
       
   142 	//  Event will not be handled, if:
       
   143 	//  1.It is not a key event.  
       
   144 	//  2.No tab group be created yet.
       
   145 	//  3.Device's BT name hasn't been initialized by user yet.   
       
   146 	//
       
   147     if (aType != EEventKey || !iTabGroup ) 
       
   148         {
       
   149         return EKeyWasNotConsumed;
       
   150         }
       
   151 
       
   152     return 	iTabGroup->OfferKeyEventL(aKeyEvent, aType);
       
   153     }
       
   154 
       
   155 // ----------------------------------------------------
       
   156 //  CBTUIAppUi::HandleCommandL
       
   157 //
       
   158 // Handle user commands. All commands are handled via
       
   159 // this routine.
       
   160 // ----------------------------------------------------
       
   161 //
       
   162 void CBTUIAppUi::HandleCommandL(TInt aCommand)
       
   163     {
       
   164     TRACE_INFO((_L("command = %d"), aCommand ))
       
   165 
       
   166     switch ( aCommand )
       
   167         {
       
   168         case EAknCmdExit:
       
   169         case EEikCmdExit:
       
   170             {
       
   171             Exit();
       
   172             break;
       
   173             }
       
   174         default:
       
   175             {
       
   176             break;
       
   177             }
       
   178         }
       
   179     }
       
   180 // ----------------------------------------------------
       
   181 // CBTUIAppUi::PluginViewActivated
       
   182 // ----------------------------------------------------
       
   183 //   
       
   184 void CBTUIAppUi::PluginViewActivated(TPluginViewId aViewId)
       
   185 
       
   186     {
       
   187     TRACE_INFO((_L("view id = %d"), aViewId ))        
       
   188     if(iTabGroup->ActiveTabId()!=aViewId)
       
   189         {            
       
   190             iTabGroup->SetActiveTabById(aViewId);
       
   191         }
       
   192     }
       
   193 
       
   194 // ----------------------------------------------------
       
   195 // CBTUIAppUi::TabChangedL
       
   196 // ----------------------------------------------------
       
   197 //
       
   198 void CBTUIAppUi::TabChangedL(TInt aIndex)
       
   199     {
       
   200     TRACE_FUNC
       
   201     switch (aIndex)
       
   202     	{
       
   203     	case 0:
       
   204 		    ActivateLocalViewL(KBtuiPluginUidMainView);
       
   205 			break;
       
   206     	case 1:
       
   207 		    ActivateLocalViewL(KBtuiPluginUidPairedDevicesView);    	
       
   208 			break;    	
       
   209     	case 2:
       
   210 		    ActivateLocalViewL(KBtuiPluginUidBlockedDevicesView);    	
       
   211 			break;    	
       
   212     	}
       
   213     }
       
   214