bluetoothengine/btui/Ecom/inc/BTUIMainView.h
branchRCL_3
changeset 56 9386f31cc85b
parent 0 f63038272f30
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Declares the settings view for BTUI application.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef BTUIMAINVIEW_H
       
    20 #define BTUIMAINVIEW_H
       
    21 
       
    22 #include "BtuiPluginInterface.h"
       
    23 #include "BTUIViewsCommonUtils.h"
       
    24 #include "btui.hrh"
       
    25 
       
    26 #include <aknview.h>        	// AVKON components
       
    27 #include <btengconnman.h>       // for disconnect type and connection observer
       
    28 #include <btengdomaincrkeys.h>
       
    29 #include <btengprivatecrkeys.h>
       
    30 #include <btengconstants.h>
       
    31 #include <btengdevman.h>
       
    32 #include <btengsettings.h>
       
    33 #include <bt_sock.h>
       
    34 #include <gsplugininterface.h>
       
    35 #include <gstabbedview.h>
       
    36 #include <eikclb.h>
       
    37 #include <ConeResLoader.h>
       
    38 
       
    39 class CBTUIMainContainer;
       
    40 class CBTDevModel;
       
    41 class TBTUIViewsCommonUtils;
       
    42 class CGSTabHelper;
       
    43 class CBTUIKeyWatcher;
       
    44 class CAknViewAppUi;
       
    45 class MGSTabbedView;
       
    46 
       
    47 /**
       
    48 * Main view of the application.
       
    49 *
       
    50 * This view handles option activation, 
       
    51 * deactivation, commands and dynamic options menus.
       
    52 *
       
    53 *@lib BTUIPlugin.dll
       
    54 *@since S60 v3.0
       
    55 */
       
    56 class CBTUIMainView : public CBtuiPluginInterface,
       
    57                       public MBTEngSettingsObserver,
       
    58                       public TBTUIViewsCommonUtils,
       
    59                       public MGSTabbedView 
       
    60     {
       
    61     public: // Constructors and destructor
       
    62 
       
    63 
       
    64 		/**
       
    65         * ECOM implementation instantiation function of 
       
    66         * interface "CBtuiPluginInterface", to be used by BTUI Application.
       
    67         */	            
       
    68         static CBTUIMainView* NewL(MBtuiPluginViewActivationObserver* aObserver= NULL);
       
    69 		/**
       
    70         * ECOM implementation instantiation function of 
       
    71         * interface "CGSPluginInterface", to be used by GS application.
       
    72         */
       
    73         static CBTUIMainView* NewGsPluginL();
       
    74 
       
    75 		/**
       
    76         * Destructor.
       
    77         */
       
    78         virtual ~CBTUIMainView();
       
    79 
       
    80         /**
       
    81         * From MGSTabbedView:
       
    82         * Creates new icon for tab. Ownership is transferred to client.
       
    83         * @since 3.1
       
    84         */       
       
    85         CGulIcon* CreateTabIconL();
       
    86 
       
    87         /**
       
    88         * From MBTEngSettingsObserver - Called when powerstate is changed
       
    89         * @param TBTPowerStateValue power state
       
    90         * @return None
       
    91         */       
       
    92 		void PowerStateChanged( TBTPowerStateValue aState );
       
    93 		
       
    94         /**
       
    95         * From MBTEngSettingsObserver - Called when visibility is changed
       
    96         * @param TBTPowerStateValue state of visibility mode
       
    97         * @return None
       
    98         */    		
       
    99 		void VisibilityModeChanged( TBTVisibilityMode aState );       
       
   100                 
       
   101     protected:
       
   102     
       
   103         /**
       
   104         * C++ default constructor.
       
   105         */
       
   106         CBTUIMainView (MBtuiPluginViewActivationObserver* aObserver= NULL);
       
   107 
       
   108 		/**
       
   109         * Symbian 2nd phase constructor.
       
   110         */
       
   111         void ConstructL();
       
   112     
       
   113 
       
   114     public: // Functions from base classes
       
   115 
       
   116         /**
       
   117         * From CAknView Returns view id.
       
   118         * @param None.
       
   119         * @return View id.
       
   120         */
       
   121         TUid Id() const;
       
   122 		
       
   123 		/**
       
   124         * Calls possibly leaving HandleCommandL function
       
   125         * @param aCommand A command id.        
       
   126         * @return None.
       
   127         */
       
   128         void HandleCommand(TInt aCommand); 		
       
   129         
       
   130 		/**
       
   131         * From CAknView Handles user commands.
       
   132         * @param aCommand A command id.        
       
   133         * @return None.
       
   134         */
       
   135         void HandleCommandL(TInt aCommand);
       
   136         
       
   137         /**
       
   138 		* Used by BTUIAppUI to Redraw BT name
       
   139 		* field.
       
   140 		* @param aListItem The changed setting item.
       
   141 		* @return None.
       
   142 		*/
       
   143 		void SettingChangedL( TBTMainListItemIndexes aListItem );
       
   144 
       
   145 	private: // Functions from base classes
       
   146 
       
   147         /**
       
   148         * From CAknView Activates view.
       
   149         * @param aPrevViewId Id of previous view.
       
   150         * @param aCustomMessageId Custom message id.
       
   151         * @param aCustomMessage Custom message.
       
   152         * @return None.
       
   153         */
       
   154         void DoActivateL( const TVwsViewId& aPrevViewId,
       
   155                                 TUid aCustomMessageId,
       
   156                           const TDesC8& aCustomMessage );		
       
   157 
       
   158         /**
       
   159         * From CAknView Deactivates view.        
       
   160         * @param None.
       
   161         * @return None.
       
   162         */
       
   163         void DoDeactivate();
       
   164 
       
   165         /**
       
   166         * From CAknView Dynamically initialises options menu.
       
   167         * @param aResourceId Id identifying the menu pane to initialise.
       
   168         * @param aMenuPane The in-memory representation of the menu pane.
       
   169         * @return None.
       
   170         */
       
   171         void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
       
   172         
       
   173         /**
       
   174         * From MProgressDialogCallback Get's called when a dialog is dismissed.        
       
   175         * @param aButtonId Id of the pressed button.
       
   176         * @return None.
       
   177         */
       
   178         void DialogDismissedL( TInt aButtonId );
       
   179 
       
   180     public: // New functions
       
   181 		
       
   182         /**
       
   183         * Set the power status of Bluetooth.
       
   184         *
       
   185         * @param aValue The new power status.
       
   186         * @return Symbian OS error code.
       
   187         */
       
   188         TInt SetPowerStatusL( TBool aValue );
       
   189 
       
   190         /**
       
   191         * Set the visibility mode of Bluetooth.
       
   192         *
       
   193         * @param aMode The new visibility mode.
       
   194         * @return None.
       
   195         */
       
   196         void SetVisibilityStatusL( TBTVisibilityMode aMode );
       
   197         
       
   198 
       
   199         /**
       
   200         * Returns the local name of BT Device.
       
   201         *
       
   202         * @param None.
       
   203         * @return The local name.
       
   204         */
       
   205         TDesC* GetBTLocalName();
       
   206           
       
   207         /**
       
   208         * Returns a reference to class CBTEngSettings.
       
   209         *
       
   210         * @param None.
       
   211         * @return A reference to class CBTEngSettings.
       
   212         */        
       
   213         CBTEngSettings* GetBtSettingsReference();     		   
       
   214         
       
   215         /**
       
   216         * Set the SIM Access Profile status .
       
   217         *
       
   218         * @param aValue The new SAP status.
       
   219         */
       
   220         void SetSapStatusL( TBTSapMode aValue );
       
   221         
       
   222         /**
       
   223         * Update its parent's view
       
   224         * @param None.
       
   225         * @return None.
       
   226         */        
       
   227         void UpdateParentView();
       
   228         
       
   229     private:
       
   230         /** takes care of middle softkey press.
       
   231          */
       
   232 		void HandleMiddleSoftkey();
       
   233 
       
   234          /**
       
   235         * Asks new power mode from user via selection buttons.
       
   236         *
       
   237         * @param None.
       
   238         * @return None.
       
   239         */
       
   240         void AskPowerModeDlgL();
       
   241 
       
   242         /**
       
   243         * Asks new visibility mode from user via selection buttons.
       
   244         *
       
   245         * @param None.
       
   246         * @return None.
       
   247         */
       
   248         void AskVisibilityDlgL();
       
   249 
       
   250         /**
       
   251         * Asks new local BT Device name from user.
       
   252         *
       
   253         * @param None.
       
   254         * @return None.
       
   255         */
       
   256         void AskNewBtNameDlgL();
       
   257        
       
   258         /**
       
   259         * A callback for launching local BT Device name query.
       
   260         *
       
   261         * @param aAppUi A reference to self.
       
   262         * @return Symbian OS error code.
       
   263         */
       
   264         static TInt LaunchBTLocalNameQueryL(TAny* aAppUi);
       
   265 
       
   266         /**
       
   267         * Asks local BT Device name from user at startup.
       
   268         *
       
   269         * @param None.
       
   270         * @return Symbian OS error code.
       
   271         */
       
   272         TInt AskBTLocalNameQueryL();
       
   273 
       
   274         /**
       
   275         * Initiates BT local name query after Symbian OS has entered idle state.
       
   276         *
       
   277         * @param None.
       
   278         * @return None.
       
   279         */
       
   280         void InitiateBTLocalNameQueryL();
       
   281 		
       
   282         /**
       
   283         * blaa blaa
       
   284         *
       
   285         * @param aNum  count of connectionsions.
       
   286         * @return None.
       
   287         */			
       
   288 		TInt GetConnectionNumber(TInt& aNum);
       
   289         
       
   290 		/**
       
   291         * Asks new SAP mode from user via selection buttons.
       
   292         *
       
   293         * @param None.
       
   294         * @return None.
       
   295         */
       
   296         void AskSapModeDlgL();
       
   297              
       
   298         /**
       
   299         * Connected sap name
       
   300         *
       
   301         * @param aName
       
   302         * @return TInt.
       
   303         */  	
       
   304 		TInt GetConnectedSapNameL( TDes& aName );
       
   305 		
       
   306 		/**
       
   307         * Get settings' values including power state, discovery mode and connection state
       
   308         * Then set member varient iBtState.
       
   309         */  	
       
   310 		void RefreshSettingsStatusL();
       
   311 		
       
   312 		/**
       
   313 		* Internal leave function used by GetValue().
       
   314 		*/
       
   315 		void GetValueL( const TGSPluginValueKeys aKey, TDes& aValue );
       
   316 
       
   317 		/**
       
   318 		* Checks from central repository whether the Bluetooth friendly name 
       
   319         * has been modified .
       
   320 		* @param aStatus
       
   321 		* @return error code
       
   322 		*/
       
   323 		
       
   324 		TInt IsLocalNameModifiedL( TBool& aStatus );
       
   325 		
       
   326 	public: // Enumerations
       
   327 	
       
   328 	    enum TBTStateSummary
       
   329 			{
       
   330 			EBTOff = 0,
       
   331 			EBTOnShown,
       
   332 			EBTOnHidden,
       
   333 			EBTConnectedShown,
       
   334 			EBTConnectedHidden
       
   335 			};
       
   336 											
       
   337 	private: // from CGSBaseView
       
   338 	
       
   339         /**
       
   340         * Handles OK key press.
       
   341         * @since 3.1
       
   342         */
       
   343         void HandleListBoxSelectionL();
       
   344         
       
   345         /**
       
   346         * Creates new container.
       
   347         * @since 3.1
       
   348         */
       
   349         void NewContainerL();
       
   350  
       
   351  
       
   352 	public: //Functions from CGSPluginInterface
       
   353 	
       
   354         /**
       
   355         * Method for checking plugin's Uid. Uid identifies this GS plugin. Use
       
   356         * same Uid as the ECOM plugin implementation Uid.
       
   357         *
       
   358         * @return PluginUid
       
   359         */
       
   360         TUid PluginUid() const;
       
   361 
       
   362         /**
       
   363         * Method for getting caption of this plugin. This should be the 
       
   364         * localized name of the settings view to be shown in parent view.
       
   365         *
       
   366         * @param aCaption pointer to Caption variable
       
   367         */
       
   368         void GetCaptionL( TDes& aCaption ) const;
       
   369 
       
   370 
       
   371         /**
       
   372         * Creates a new icon of desired type. 
       
   373         * @param aIconType UID Icon type UID of the icon to be created.
       
   374         * @return Pointer of the icon. NOTE: Ownership of this icon is
       
   375         *         transferred to the caller.
       
   376         */
       
   377         CGulIcon* CreateIconL( const TUid aIconType );
       
   378         
       
   379         /**
       
   380         * Function for getting plugin's value for a certain key.
       
   381         * Override to provide own functionality.
       
   382         *
       
   383         * @param aKey Key for the value to be retrieved.
       
   384         * @parem aValue Value for the given gey in TDes format.
       
   385         */
       
   386         void GetValue( const TGSPluginValueKeys aKey, TDes& aValue );
       
   387              
       
   388         /**
       
   389         * Returns sap status
       
   390         *
       
   391         * @param None
       
   392         * @return TInt.
       
   393         */        
       
   394 		TInt GetSapStatusL();          
       
   395  
       
   396  		TVwsViewId GetParentView();
       
   397  
       
   398          /**
       
   399         * From MGSTabbedView
       
   400         * @return Reference to owned tabbed views which should be included in 
       
   401         *         the sub-view's tab group.
       
   402         * @since 3.1
       
   403         */
       
   404         CArrayPtrFlat<MGSTabbedView>* TabbedViews();
       
   405     		       	
       
   406     private: // Data
       
   407         CBTUIMainContainer*             iContainer;      	    // Main container           
       
   408         CBTEngSettings*					iBtEngSettings;         // Settings class        
       
   409         CIdle*                          iIdle;              	// Idle time class (for doing operation delayed)
       
   410         TBTDeviceName                   iTempNameBuffer;    	// Temporary storage for BT name        
       
   411         CEikonEnv*                  	iEikEnv;                // Local eikonenv		
       
   412         TInt                        	iResourceFileFlag;      // Flag for eikon env.
       
   413 		TBool							iConstructAsGsPlugin;	// Flag that indicate who constrct this obj
       
   414 		TBool							iCoverDisplayEnabled;	// Flag that indicate cover UI feature							                			
       
   415 
       
   416         CGSTabHelper* 					iTabHelper;
       
   417 	    TBool							iParentViewNotSetYet;
       
   418         CArrayPtrFlat<MGSTabbedView>* 	iViewArray; 
       
   419         TVwsViewId 						iParentView; 
       
   420         TBTStateSummary					iBtState;
       
   421         CBTUIKeyWatcher*				iKeyWatcher;
       
   422         MBtuiPluginViewActivationObserver* iActivationObserver; // view activation observer
       
   423     };
       
   424     
       
   425 #endif
       
   426 
       
   427