datasourcemodules/bluetoothgpspositioningmodule/btgpspsy/inc/Utils/BTGPSDeviceManager.h
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef BTGPSDEVICEMANAGER_H
       
    21 #define BTGPSDEVICEMANAGER_H
       
    22 
       
    23 //  INCLUDES
       
    24 
       
    25 #include <e32base.h> 
       
    26 #include "BTGPSDeviceListener.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CBTDevice;
       
    30 class TBTSockAddr;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35 *  Manager class for connected BT device. This class contains connected
       
    36 *  BT device address, pairing information, device connection status and
       
    37 *  device type. It also inform listeners if device connection status or
       
    38 *  device type is changed.
       
    39 *  
       
    40 */
       
    41 class CBTGPSDeviceManager: public CBase
       
    42     {
       
    43     public: 
       
    44 
       
    45         /**
       
    46         * Two-phase construction.
       
    47         */
       
    48         static CBTGPSDeviceManager * NewL();
       
    49 
       
    50         /**
       
    51         * Destructor
       
    52         */
       
    53         virtual ~CBTGPSDeviceManager();
       
    54 
       
    55 		/**
       
    56 		* Get BT Device
       
    57 		* @return Reference to CBTDevice object
       
    58 		*/
       
    59 		CBTDevice& BtDevice();
       
    60 		
       
    61 		/**
       
    62 		* Get BT socket address
       
    63         * @param aAddr On return contains connected BT socket
       
    64         *        address
       
    65 		*/
       
    66 		void BtSockAddr(TBTSockAddr& aAddr) const;
       
    67 		
       
    68 		/**
       
    69 		* Set BT socket info and device type. This function will also
       
    70 		* do reset.
       
    71         * @param aAddr BT device  socket address.
       
    72         * @param aType BT device type
       
    73 		*/
       
    74 		void SetDeviceInfo(
       
    75 		    const TBTSockAddr& aAddr,
       
    76 		    const TBTDeviceType& aType);
       
    77 		
       
    78 		/**
       
    79 		* Set port number
       
    80         * @param aPort Port number
       
    81 		*/
       
    82 		void SetPort(TInt aPort);
       
    83 		
       
    84 		/**
       
    85 		* Get port number
       
    86         * @return Port number. Zero by default.
       
    87 		*/
       
    88 		TInt Port() const;
       
    89 
       
    90 		/**
       
    91 		* Get paired status
       
    92         * @return ETrue if the device is paried, EFalse otherwise.
       
    93 		*/
       
    94 		TBool IsPaired() const;
       
    95 
       
    96 		/**
       
    97 		* Set device paired status
       
    98         * @param aPaired Device pairing status
       
    99 		*/
       
   100 		void SetPaired(TBool aPaired = ETrue);
       
   101 		
       
   102         /**
       
   103         * Get BT Device Type
       
   104         * @return Device type
       
   105         */
       
   106         TBTDeviceType DeviceType() const;
       
   107         
       
   108         /**
       
   109         * Check if GPS is connected
       
   110         * @return ETrue if the connected device is a GPS device
       
   111         */
       
   112         TBool IsGpsConnected() const;
       
   113 
       
   114         /**
       
   115         * Set BT Device Type
       
   116         * @param aType BT device type
       
   117         */
       
   118         void SetBTDeviceType(TBTDeviceType aType);
       
   119         
       
   120         /**
       
   121         * Get BT Device connect status
       
   122         * @return BT device connection status.
       
   123         */
       
   124         TBTDeviceConnectStatus DeviceConnectStatus() const;
       
   125         
       
   126         /**
       
   127         * Set device connection status
       
   128         * @param aStatus BT device connection status.
       
   129         * @param aErr Last operation error code if connection
       
   130         *        status is EBTDeviceConnectError.
       
   131         */
       
   132         void SetBTDeviceConnectStatus(
       
   133             TBTDeviceConnectStatus aStatus,
       
   134             TInt aErr = KErrNone);
       
   135 
       
   136         /**
       
   137         * Add device status change listener
       
   138         * @param aListener Reference to listener.
       
   139         */
       
   140         void AddListenerL(MBTGPSDeviceListener& aListener);
       
   141 
       
   142         /**
       
   143         * Remove listener
       
   144         * @param aListener Reference to listener.
       
   145         */
       
   146         void RemoveListener(MBTGPSDeviceListener& aListener);
       
   147 
       
   148     private:
       
   149 
       
   150         /**
       
   151         * Second phase of the construction
       
   152         */
       
   153         void ConstructL();
       
   154 
       
   155         /**
       
   156         * Private constructor
       
   157         */
       
   158         CBTGPSDeviceManager();
       
   159         
       
   160         /**
       
   161         * Issue status change event to listeners
       
   162         */
       
   163         void StatusChanged();
       
   164         
       
   165     private:
       
   166         //Status
       
   167         CBTDevice* iBtDevice;
       
   168 
       
   169         //Port
       
   170         TInt iPort;
       
   171         
       
   172         //Paired
       
   173         TBool iPaired;
       
   174 
       
   175         //BT Device Type
       
   176         TBTDeviceType iType;
       
   177         
       
   178         //BT Device connection status
       
   179         TBTDeviceConnectStatus iConnectStatus;
       
   180         
       
   181         //Last operation error code
       
   182         TInt iError;
       
   183         
       
   184         //Listner array
       
   185         RArray<MBTGPSDeviceListener*> iListenerArray;
       
   186 
       
   187     };
       
   188 #endif
       
   189 // End of File
       
   190