bluetoothengine/btui/btuimodel/btdevicedata.h
changeset 41 0b2439c3e397
parent 40 997690c3397a
child 46 5ab02bc213db
child 52 4545c04e61e1
equal deleted inserted replaced
40:997690c3397a 41:0b2439c3e397
     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: 
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef BTDEVICEDATA_H
       
    19 #define BTDEVICEDATA_H
       
    20 
       
    21 #include "btuimodeltypes.h"
       
    22 #include <btdevicemodel.h>
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <btservices/btdevrepository.h>
       
    26 #include <btservices/devdiscoveryobserver.h>
       
    27 
       
    28 
       
    29 class CAdvanceDevDiscoverer;
       
    30 
       
    31 /*!
       
    32     \class BtDeviceData
       
    33     \brief class for providing remote device data.
       
    34 
       
    35     BtDeviceData class is responsible for providing the latest information
       
    36     regarding the properties of remote devices.
       
    37 
       
    38     \\sa bluetoothuimodel
       
    39  */
       
    40 class BtDeviceData : public QObject,
       
    41                      public MBtDevRepositoryObserver,
       
    42                      public MDevDiscoveryObserver
       
    43 {
       
    44     Q_OBJECT
       
    45 
       
    46 public:
       
    47     explicit BtDeviceData( BtDeviceModel& model, QObject *parent = 0 );
       
    48     
       
    49     virtual ~BtDeviceData();
       
    50     
       
    51     bool isValid( int row, int col ) const;
       
    52     
       
    53     int rowCount() const;
       
    54     
       
    55     int columnCount() const;
       
    56         
       
    57     void data(QVariant& val, int row, int col, int role ) const;
       
    58     
       
    59     BtuiModelDataItem itemData( int row, int col ) const;
       
    60     
       
    61     bool searchDevice();
       
    62     
       
    63     void cancelSearchDevice();
       
    64     
       
    65     void removeTransientDevices();
       
    66     
       
    67 private:
       
    68     // From MBtDeviceRepositoryObserver
       
    69     
       
    70     void RepositoryInitialized();
       
    71     
       
    72     void DeletedFromRegistry( const TBTDevAddr& addr );
       
    73     
       
    74     void AddedToRegistry( const CBtDevExtension& dev );
       
    75     
       
    76     void ChangedInRegistry( const CBtDevExtension& dev, TUint similarity  ); 
       
    77 
       
    78     void ServiceConnectionChanged(
       
    79             const CBtDevExtension& dev, TBool connected );
       
    80     
       
    81     // from MDevDiscoveryObserver
       
    82     void HandleNextDiscoveryResultL( 
       
    83             const TInquirySockAddr& inqAddr, const TDesC& name );
       
    84 
       
    85     void HandleDiscoveryCompleted( TInt error );
       
    86     
       
    87 public slots:
       
    88     //void activeRequestCompleted( int status, int id );
       
    89 
       
    90 private:
       
    91 
       
    92     void initializeDataStore();
       
    93 
       
    94     void updateDeviceProperty(BtuiModelDataItem& qtdev,
       
    95             const CBtDevExtension& dev, TUint similarity );
       
    96     
       
    97     int indexOf( const TBTDevAddr& addr ) const;
       
    98     
       
    99     void updateRssi(BtuiModelDataItem& qtdev, int rssi );
       
   100     
       
   101     void setMajorProperty( BtuiModelDataItem& qtdev, int prop, bool addto);
       
   102     
       
   103     bool isDeviceInRange( const BtuiModelDataItem& qtdev );
       
   104     
       
   105     bool isDeviceInRegistry( const BtuiModelDataItem& qtdev );
       
   106     
       
   107 private:
       
   108 
       
   109     BtuiModelDataSource mData;
       
   110     
       
   111     BtDeviceModel& mModel;
       
   112     
       
   113     CBtDevRepository* mDeviceRepo;
       
   114     
       
   115     CAdvanceDevDiscoverer* mDiscover;
       
   116     
       
   117     bool isSearchingDevice;
       
   118     
       
   119     Q_DISABLE_COPY(BtDeviceData)
       
   120 
       
   121 };
       
   122 
       
   123 #endif // BTLOCALSETTING_H