- fixed base agent ignoring pass in object path
[profile/ivi/bluetooth-qt.git] / nearbydevicesmodel.h
1 #ifndef NEARBYDEVICESMODEL_H
2 #define NEARBYDEVICESMODEL_H
3
4 #include <QObject>
5 #include <QAbstractListModel>
6 #include <QDBusObjectPath>
7
8 #include "bluemanager.h"
9 #include "blueadapter.h"
10 #include "asyncagent.h"
11
12 namespace NearbyDevicesModelRoles
13 {
14         enum
15         {
16                 name = Qt::UserRole + 1,
17                 address
18         };
19 }
20
21 class NearbyDevicesModel : public QAbstractListModel
22 {
23         Q_OBJECT
24
25 public:
26         NearbyDevicesModel(QObject *parent = 0);
27
28 public slots:
29
30         int columnCount(const QModelIndex &) const { return 1;}
31         int rowCount(const QModelIndex &parent = QModelIndex()) const;
32         QVariant data(const QModelIndex &index, int role) const;
33
34         QString hwAddress(int index) { return devicepathlist[index]; }
35         QString alias(int index){ return deviceAliasMap[devicepathlist[index]]; }
36         void pair(QString hwaddy);
37         void discover(bool start);
38         void removeAll(bool);
39
40         void replyRequestConfirmation(bool confirmed);
41         void replyPasskey(uint passkey);
42         void replyRequestPidCode(QString pidCode);
43
44         void setAdapterProperty(QString name, QVariant value);
45
46 private slots:
47         void adapterAdded(QDBusObjectPath);
48         void adapterRemoved(QDBusObjectPath);
49         void deviceCreated(QString hwaddy, QVariantMap properties);
50         void deviceRemoved(QString hwaddy);
51
52         void adapterPropertiesChangedSlot(QString n,QDBusVariant v);
53
54 signals:
55         void requestConfirmation(QString device, uint code);
56         void requestPasskey(QString device);
57         void requestPidCode(QString device);
58         void release();
59
60         void nearbyDeviceFound(int index);
61         void nearbyDeviceRemoved(int index);
62
63         void adapterPropertiesChanged(QString name, QVariant value);
64
65 private:
66         QList<QString> devicepathlist;
67         QMap<QString,QString> deviceAliasMap;
68         OrgBluezManagerInterface *manager;
69         OrgBluezAdapterInterface *adapter;
70         AsyncAgent* agent;
71 };
72
73 #endif // NEARBYDEVICESMODEL_H