initial Bluetooth Device Model addition
[profile/ivi/bluetooth-qt.git] / agentadaptor.cpp
1 /*  -*- Mode: C++ -*-
2  *
3  * meego handset bluetooth
4  * Copyright © 2010, Intel Corporation.
5  *
6  * This program is licensed under the terms and conditions of the
7  * Apache License, version 2.0.  The full text of the Apache License is at
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  */
11
12 #include "agentadaptor.h"
13
14 AgentAdaptor::AgentAdaptor(BluetoothBaseAgent *parent) :
15     QDBusAbstractAdaptor(parent), agent(parent)
16 {
17
18 }
19
20 AgentAdaptor::~AgentAdaptor()
21 {
22
23 }
24
25 void AgentAdaptor::Authorize(const QDBusObjectPath &deviceObject, const QString &uuid)
26 {
27         if (!agent)
28         {
29                 return;
30         }
31
32         OrgBluezDeviceInterface device("org.bluez",                                                 deviceObject.path(),                                            QDBusConnection::systemBus());
33
34         agent->authorize(device, uuid);
35 }
36
37 void AgentAdaptor::Cancel()
38 {
39         if(!agent)
40         {
41                 return;
42         }
43
44         agent->cancel();
45 }
46
47 void AgentAdaptor::ConfirmModeChange(const QString &mode)
48 {
49         if(!agent)
50         {
51                 return;
52         }
53
54         agent->confirmModeChange(mode);
55 }
56
57 void AgentAdaptor::DisplayPasskey(const QDBusObjectPath &deviceObject, uint passkey)
58 {
59         if(!agent)
60         {
61                 return;
62         }
63
64         OrgBluezDeviceInterface device("org.bluez", deviceObject.path(), QDBusConnection::systemBus());
65
66         agent->displayPasskey(device, passkey);
67 }
68
69 void AgentAdaptor::Release()
70 {
71         if(!agent)
72         {
73                 return;
74         }
75
76         agent->release();
77 }
78
79 void AgentAdaptor::RequestConfirmation(const QDBusObjectPath &deviceObject, uint passkey)
80 {
81         if(!agent)
82         {
83                 return;
84         }
85
86         OrgBluezDeviceInterface device("org.bluez", deviceObject.path(), QDBusConnection::systemBus());
87
88         agent->requestConfirmation(device, passkey);
89 }
90
91 uint AgentAdaptor::RequestPasskey(const QDBusObjectPath &deviceObject)
92 {
93         if(!agent)
94         {
95                 return 0;
96         }
97
98         OrgBluezDeviceInterface device("org.bluez", deviceObject.path(), QDBusConnection::systemBus());
99
100         return agent->requestPasskey(device);
101 }
102
103 QString AgentAdaptor::RequestPinCode(const QDBusObjectPath &deviceObject)
104 {
105         if(!agent)
106         {
107                 return QString();
108         }
109
110         OrgBluezDeviceInterface device("org.bluez", deviceObject.path(), QDBusConnection::systemBus());
111
112         return agent->requestPidCode(device);
113 }