version bump
[profile/ivi/bluetooth-qt.git] / bluetoothbaseagent.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 "bluetoothbaseagent.h"
13
14 #include "agentadaptor.h"
15 #include "bluemanager.h"
16 #include "blueadapter.h"
17 #include <QTimer>
18
19 BluetoothBaseAgent::BluetoothBaseAgent(QString path, QObject *parent):QObject(parent),requestAccepted(false),m_path(path)
20 {
21         new AgentAdaptor(this);
22         QDBusConnection::systemBus().registerObject(path,this);
23 }
24
25 void BluetoothBaseAgent::registerAgent()
26 {
27     OrgBluezManagerInterface manager(
28                     "org.bluez",
29                     "/", QDBusConnection::systemBus());
30
31     QDBusObjectPath adapterpath = manager.DefaultAdapter();
32
33     OrgBluezAdapterInterface adapter(
34                     "org.bluez",
35                     adapterpath.path(),
36                     QDBusConnection::systemBus());
37
38     adapter.RegisterAgent(QDBusObjectPath(m_path),"");
39     qDebug()<<"last error: "<<adapter.lastError().message();
40 }
41
42 void BluetoothBaseAgent::authorize(OrgBluezDeviceInterface &device, QString uuid)
43 {
44         Q_UNUSED(uuid);
45         Q_UNUSED(device);
46         qDebug("authorize");
47 }
48
49 void BluetoothBaseAgent::confirmModeChange(QString mode)
50 {
51         qDebug()<<"mode changed "<<mode;
52 }
53
54 void BluetoothBaseAgent::displayPasskey(OrgBluezDeviceInterface &device, uint key, uint entered)
55 {
56         qDebug()<<"display key "<<device.path()<<" "<<key;
57
58         ///create and return back an empty reply:
59         QDBusMessage reply = message().createReply();
60         connection().send(reply);
61 }
62
63 void BluetoothBaseAgent::release()
64 {
65         qDebug("release called");
66 }
67
68 void BluetoothBaseAgent::requestConfirmation(OrgBluezDeviceInterface &device, uint key)
69 {
70         QVariantMap props = device.GetProperties();
71
72         QString alias = props["Alias"].toString();
73
74         qDebug()<<"Pairing with "<< alias << " with key: "+QString::number(key);
75 }
76
77 uint BluetoothBaseAgent::requestPasskey(OrgBluezDeviceInterface &device)
78 {
79         Q_UNUSED(device);
80         qDebug("requestKey");
81         return 0;
82 }
83
84 QString BluetoothBaseAgent::requestPidCode(OrgBluezDeviceInterface &device)
85 {
86         Q_UNUSED(device);
87         return "";
88 }
89