bluetoothengine/btnotif/inc/btnotifier.h
branchRCL_3
changeset 56 9386f31cc85b
child 61 269724087bed
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
       
     1 /*
       
     2 * Copyright (c) 2002 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 Bluetooth notifiers base class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef BTNOTIFIERBASE_H
       
    20 #define BTNOTIFIERBASE_H
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include "btnotif.h"
       
    25 #include "btnotifuiutil.h"
       
    26 #include <eikenv.h>
       
    27 #include <btdevice.h>
       
    28 #include <btengdevman.h>
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 // Literals for resource and bitmap files ( drive, directory, filename(s) )
       
    33 
       
    34 const TUid KBTInquiryChannel            = {0x00000601}; // Channel for inquiry notifier
       
    35 const TUid KBTAuthorisationChannel      = {0x00000602}; // Channel for PIN query notifier
       
    36 const TUid KBTAuthenticationChannel     = {0x00000603}; // Channel for authorisation notifier
       
    37 const TUid KBTBBEventChannel            = {0x00000604}; // Channel for baseband event notifier
       
    38 const TUid KBTObexPINChannel            = {0x00000605}; // Channel for OBEX PIN notifier
       
    39 const TUid KBTPowerModeChannel          = {0x00000606}; // Channel for power mode notifier
       
    40 const TUid KBTAudioAccessoryChannel     = {0x00000607}; // Channel for audio accessory notifier
       
    41 const TUid KBTLowMemoryChannel          = {0x00000608}; // Channel for low memory notifier
       
    42 const TUid KBTPairedDeviceSettingChannel  = {0x00000610};
       
    43 
       
    44 // FORWARD DECLARATIONS
       
    45 class CBTEngSettings;
       
    46 
       
    47 enum TBTRegistryQueryState
       
    48 {
       
    49 	ENoQuery=0,
       
    50 	EQueryPaired=1,
       
    51 	EQueryUsed=2,
       
    52 	ESetDeviceAuthorizeState,
       
    53 	ESetDeviceBlocked,
       
    54 	ESetDeviceUnblocked,
       
    55 };
       
    56 
       
    57 // CLASS DECLARATION
       
    58 /**
       
    59 * This class is the base class for all notifiers.
       
    60 */
       
    61 NONSHARABLE_CLASS(CBTNotifierBase): public CBase, public MEikSrvNotifierBase2, MBTEngDevManObserver
       
    62     {
       
    63     public: // Constructors and destructor
       
    64 
       
    65         /**
       
    66         * Destructor.
       
    67         */
       
    68         virtual ~CBTNotifierBase();
       
    69 
       
    70         /**
       
    71         * A utility function for checking whether autolock is on.
       
    72         * @param None.
       
    73         * @return A boolean according to autolock state.
       
    74         */
       
    75         TBool AutoLockOnL();
       
    76 
       
    77     protected: // Constructors and destructor
       
    78 
       
    79         /**
       
    80         * C++ default constructor.
       
    81         */
       
    82         CBTNotifierBase();
       
    83 
       
    84     protected: // New functions
       
    85 
       
    86         /**
       
    87         * Symbian 2nd phase constructor.
       
    88         */
       
    89         virtual void ConstructL();
       
    90 
       
    91         /**
       
    92         * Used in asynchronous notifier launch to store received parameters
       
    93         * into members variables and make needed initializations.
       
    94         * @param aBuffer A buffer containing received parameters
       
    95         * @param aReturnVal The return value to be passed back.
       
    96         * @param aMessage Should be completed when the notifier is deactivated.
       
    97         * @return None.
       
    98         */
       
    99         virtual void GetParamsL(const TDesC8& aBuffer,
       
   100                                 TInt aReplySlot,
       
   101                                 const RMessagePtr2& aMessage)=0;
       
   102 
       
   103         /**
       
   104         * A utility function for setting the power status of Bluetooth.
       
   105         * If the power is not on the user will be presented a query.
       
   106         * @return ETrue if BT is turned on successfully; EFalse otherwise
       
   107         */
       
   108         TBool CheckAndSetPowerOnL();
       
   109 
       
   110 		/**
       
   111 		* A function for setting BT name
       
   112 		* @return ETrue if BT name is set successfully; EFalse otherwise
       
   113 		*/
       
   114 		TBool AskLocalBTNameQueryL();
       
   115 
       
   116         /**
       
   117 		* Check if there is any existing connection to audio profiles from
       
   118 		* the same device
       
   119 		* @return ETrue if the device is connected.
       
   120 		*/
       
   121 		TBool IsExistingConnectionToAudioL(const TBTDevAddr& aDevAddr);
       
   122 
       
   123 		/**
       
   124 		* Complete Client/Server message and Nulled the reply slot.
       
   125 		* @param aErr  Error code for client notification.
       
   126 		* @return None
       
   127 		*/
       
   128 		void CompleteMessage(TInt aErr);
       
   129 
       
   130        /**
       
   131         * Complete Client/Server message and Nulled the reply slot.
       
   132         * @param aErr  Error code for client notification.
       
   133         * @return None
       
   134         */
       
   135         void CompleteMessage(TInt aValueToReplySlot, TInt aErr);
       
   136 
       
   137        /**
       
   138         * Complete Client/Server message and Nulled the reply slot.
       
   139         * @param aErr  Error code for client notification.
       
   140         * @return None
       
   141         */
       
   142         void CompleteMessage(const TDesC8& aDesToReplySlot, TInt aErr);
       
   143 
       
   144 		/**
       
   145 		* Checks from central repository whether the Bluetooth friendly name
       
   146         * has been modified .
       
   147 		* @return ETure if the name has been modified.
       
   148 		*/
       
   149 		TBool IsLocalNameModifiedL();
       
   150 
       
   151 		/**
       
   152 		 * Get the device information from BT Registry by the given address.
       
   153 		 */
       
   154 		void GetDeviceFromRegL(const TBTDevAddr& aAddr);
       
   155 
       
   156 		/**
       
   157 		 * virtual function to be ovewritten by sub-classes.
       
   158 		 * Will be called when Getting Device by BTEng DevMan is completed.
       
   159 		 * @param aDev the device from registry if it is not null. indicates either a failure
       
   160 		 *             or the device is not available in registry.
       
   161 		 */
       
   162 		virtual void HandleGetDeviceCompletedL(const CBTDevice* aDev);
       
   163 
       
   164         /**
       
   165          * Asks the user if s/he want's to block the device in question
       
   166          * Does not block the device. That is left to the caller.
       
   167          * NOTE: Cannot be called while iAuthQueryDlg is active.
       
   168          */
       
   169         void QueryBlockDeviceL();
       
   170 
       
   171         /**
       
   172          * Set BTDevice's security setting to blocked and modify device
       
   173          * @param None
       
   174          * @return None
       
   175          */
       
   176         void DoBlockDevice();
       
   177 
       
   178         /**
       
   179          * Set BTDevice's security setting to un/authorized and modify device
       
   180          * @param aTrust Set authorized if ETrue; otherwise, unauthorized.
       
   181          * @return None
       
   182          */
       
   183         void ChangeAuthorizeState( TBool aTrust);
       
   184 
       
   185         /**
       
   186          * Checks if the user is queried too often, and handle the result.
       
   187          * @return None
       
   188          */
       
   189         void CheckAndHandleQueryIntervalL();
       
   190 
       
   191     private:
       
   192 
       
   193         void DoHandleGetDevicesCompleteL(TInt aErr, CBTDeviceArray* aDeviceArray );
       
   194 
       
   195     protected: // Functions from base classes
       
   196 
       
   197         /**
       
   198         * From MEikSrvNotifierBase2 Called when a notifier is first loaded
       
   199         * to allow any initial construction that is required.
       
   200         * @param None.
       
   201         * @return A structure containing priority and channel info.
       
   202         */
       
   203         virtual TNotifierInfo RegisterL()=0;
       
   204 
       
   205         /**
       
   206         * From MEikSrvNotifierBase2 The notifier has been deactivated
       
   207         * so resources can be freed and outstanding messages completed.
       
   208         * @param None.
       
   209         * @return None.
       
   210         */
       
   211         virtual void Cancel();
       
   212 
       
   213 #ifdef __SERIES60_HELP
       
   214 		/** This is used to create TCallBack to help.
       
   215 		 * @param TCoeHelpContext. Must be instance TCoeHelpContext, or NULL.
       
   216 		 * If null this will open help about blocked devices.,
       
   217 		 * @return KErrNone
       
   218 		 */
       
   219 		static TInt LaunchHelp(TAny *TCoeHelpContext=NULL);
       
   220 #endif
       
   221 
       
   222     private: // Functions from base classes
       
   223 
       
   224         /**
       
   225         * From MEikSrvNotifierBase2 Called when all resources allocated
       
   226         * by notifiers should be freed.
       
   227         * @param None.
       
   228         * @return None.
       
   229         */
       
   230         virtual void Release();
       
   231 
       
   232         /**
       
   233         * From MEikSrvNotifierBase2 Return the priority a notifier takes
       
   234         * and the channels it acts on.
       
   235         * @param None.
       
   236         * @return A structure containing priority and channel info.
       
   237         */
       
   238         virtual TNotifierInfo Info() const;
       
   239 
       
   240         /**
       
   241         * From MEikSrvNotifierBase2 Synchronic notifier launch.
       
   242         * @param aBuffer Received parameter data.
       
   243         * @return A pointer to return value.
       
   244         */
       
   245         virtual TPtrC8 StartL(const TDesC8& aBuffer);
       
   246 
       
   247         /**
       
   248         * From MEikSrvNotifierBase2 Asynchronic notifier launch.
       
   249         * @param aBuffer A buffer containing received parameters
       
   250         * @param aReturnVal The return value to be passed back.
       
   251         * @param aMessage Should be completed when the notifier is deactivated.
       
   252         * @return A pointer to return value.
       
   253         */
       
   254         virtual void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage);
       
   255 
       
   256         /**
       
   257         * From MEikSrvNotifierBase2 Updates a currently active notifier.
       
   258         * @param aBuffer The updated data.
       
   259         * @return A pointer to return value.
       
   260         */
       
   261         virtual TPtrC8 UpdateL(const TDesC8& aBuffer);
       
   262 
       
   263         /**
       
   264          * From MBTEngDevManObserver
       
   265          * Indicates to the caller that adding, deleting or modifying a device
       
   266          * has completed.
       
   267          */
       
   268         virtual void HandleDevManComplete(TInt aErr);
       
   269 
       
   270         /**
       
   271          * From MBTEngDevManObserver
       
   272          * Call back function when GetDevices() request is completed.
       
   273          * @param aErr Status information, if there is an error.
       
   274          * @param aDeviceArray Array of devices that match the given criteria
       
   275          *                     (the array provided by the calller).
       
   276          */
       
   277         void HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* aDeviceArray );
       
   278 
       
   279         /**
       
   280          * Checks the timestamp since last query.
       
   281          * @return true if too often
       
   282          */
       
   283         TBool CheckQueryInterval();
       
   284 
       
   285     protected: // Data
       
   286 
       
   287         RMessagePtr2                iMessage;               // Received message
       
   288         TInt                        iReplySlot;             // Reply slot
       
   289         TNotifierInfo               iInfo;                  // Notifier parameters structure
       
   290         TBTRegistryQueryState       iBTRegistryQueryState;
       
   291         CBTDeviceArray*             iDeviceArray;  // for getting device from registry
       
   292         CBTDevice*                  iDevice;                // Current Bluetooth device
       
   293         TBTDevAddr                  iBTAddr; // Gotten from PckBuffer, constant no matter how iDevice changes.
       
   294         CBTNotifUIUtil*             iNotifUiUtil;           // Utility to show UI notes & queries
       
   295         CBTEngSettings*             iBTEngSettings;
       
   296         TBool                       iIsCoverUI;
       
   297 
       
   298     private:
       
   299         CBTEngDevMan*               iDevMan;  // for BT registry manipulation
       
   300 
       
   301 
       
   302 
       
   303     };
       
   304 
       
   305 #endif
       
   306 
       
   307 // End of File