bluetoothengine/btserviceutil/export/btdevrepository.h
changeset 19 43824b19ee35
child 31 a0ea99b6fa53
equal deleted inserted replaced
17:f05641c183ff 19:43824b19ee35
       
     1 /*
       
     2 * Copyright (c) 2010 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:  The repository of remote devices from BT registry
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef BTDEVICEREPOSITORY_H
       
    19 #define BTDEVICEREPOSITORY_H
       
    20 
       
    21 #include <btdevice.h>
       
    22 #include <btmanclient.h>
       
    23 #include <btservices/btdevextension.h>
       
    24 
       
    25 class CBtDevRepositoryImpl;
       
    26 
       
    27 /**
       
    28  * APIs from this class offer functionalities that are common in mw and app 
       
    29  * components of Bluetooth packages. They do not serve as domain APIs.
       
    30  * 
       
    31  * Using these from external components is risky, due to possible source
       
    32  * and binary breaks in future.
       
    33  * 
       
    34  */
       
    35 
       
    36 /**
       
    37  *  Class MBtDevRepositoryObserver
       
    38  *
       
    39  *  Callback class to notify changes in BT registry.
       
    40  */
       
    41 class MBtDevRepositoryObserver
       
    42     {
       
    43 public:
       
    44 
       
    45     /**
       
    46      * Callback to notify that the repository has finished initialization.
       
    47      * Initialization completion means the repository has retieved all
       
    48      * Bluetooth devices from BT registry, and it is subscribing to
       
    49      * registry update events.
       
    50      * 
       
    51      */
       
    52     virtual void RepositoryInitialiazed() = 0;    
       
    53     
       
    54     /**
       
    55      * Callback to notify that a device has been deleted from BT registry.
       
    56      * 
       
    57      *
       
    58      * @param aAddr the bd_addr of the deleted device
       
    59      */
       
    60     virtual void BtDeviceDeleted( const TBTDevAddr& aAddr ) = 0;
       
    61     
       
    62     /**
       
    63      * Callback to notify that the device has been added to BT registry.
       
    64      *
       
    65      * @param aDevice the device that has been added to registry
       
    66      */
       
    67     virtual void BtDeviceAdded( const CBtDevExtension& aDevice ) = 0;
       
    68     
       
    69     /**
       
    70      * Callback to notify that the property of a device in BT registry has been
       
    71      * changed.
       
    72      *
       
    73      * @param aDevice the device that possesses the latest properties.
       
    74      * @param aSimilarity the similarity of the properties comparing to the ones
       
    75      *        prior to this change.
       
    76      *        Refer CBTDevice::TBTDeviceNameSelector and 
       
    77      *        TBTNamelessDevice::TBTDeviceSet for the meanings of the bits 
       
    78      *        in this parameter.
       
    79      */
       
    80     virtual void BtDeviceChangedInRegistry( 
       
    81             const CBtDevExtension& aDevice, TUint aSimilarity ) = 0;    
       
    82     };
       
    83 
       
    84 /**
       
    85  *  Class CBtDevRepository
       
    86  *
       
    87  *  This class provides the full access to remote devices in BT registry, 
       
    88  *  and informs client when the properties of remote devices are changed.
       
    89  *
       
    90  */
       
    91 NONSHARABLE_CLASS( CBtDevRepository ) : public CBase
       
    92     {
       
    93 public:
       
    94 
       
    95     /**
       
    96      * Two-phase constructor
       
    97      */
       
    98     IMPORT_C static CBtDevRepository* NewL();
       
    99 
       
   100     /**
       
   101      * Destructor
       
   102      */
       
   103     IMPORT_C virtual ~CBtDevRepository();
       
   104 
       
   105     /**
       
   106      * Add an observer to this reposity for receivng repository update
       
   107      * events.
       
   108      * @param aObserver the observer to be added.
       
   109      */
       
   110     IMPORT_C void AddObserverL( MBtDevRepositoryObserver* aObserver );
       
   111 
       
   112     /**
       
   113      * Remove an observer from this repository.
       
   114      * @param aObserver the observer to be removed.
       
   115      */
       
   116     IMPORT_C void RemoveObserver( MBtDevRepositoryObserver* aObserver );
       
   117     
       
   118     /**
       
   119      * Tells if this repository has finished the initialization.
       
   120      * Initialization completion means the repository has retieved all
       
   121      * Bluetooth devices from BT registry, and it is subscribing to
       
   122      * registry update events.
       
   123      */
       
   124     IMPORT_C TBool IsInitialized() const;
       
   125     
       
   126     /**
       
   127      * Get all devices in this repository.
       
   128      * @return the device list
       
   129      */
       
   130     IMPORT_C const RDevExtensionArray& AllDevices() const;
       
   131 
       
   132     /**
       
   133      * Get a specific device by the given address.
       
   134      * @param aAddr the address of the device to be retrieved
       
   135      * @return the device pointer, NULL if the device is unavailable.
       
   136      */
       
   137     IMPORT_C const CBtDevExtension* Device( const TBTDevAddr& aAddr ) const;
       
   138 
       
   139 private:
       
   140     
       
   141     /**
       
   142      * C++ default constructor
       
   143      */
       
   144     CBtDevRepository();
       
   145     
       
   146     /**
       
   147      * Symbian 2nd-phase constructor
       
   148      */
       
   149     void ConstructL();
       
   150     
       
   151 private:
       
   152     
       
   153     CBtDevRepositoryImpl* iImpl; 
       
   154     };
       
   155 
       
   156 #endif /*BTDEVICEREPOSITORY_H*/