a49ef4e53e0b3a908156084aa8b86240469a9df4
[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)
20 {
21         new AgentAdaptor(this);
22         QDBusConnection::systemBus().registerObject(path,this);
23
24         OrgBluezManagerInterface manager(
25                         "org.bluez",
26                         "/", QDBusConnection::systemBus());
27
28         QDBusObjectPath adapterpath = manager.DefaultAdapter();
29
30         OrgBluezAdapterInterface adapter(
31                         "org.bluez",
32                         adapterpath.path(),
33                         QDBusConnection::systemBus());
34
35         adapter.RegisterAgent(QDBusObjectPath("/pairing/agent"),"");
36
37         qDebug()<<"last error: "<<adapter.lastError().message();
38
39 }
40
41 void BluetoothBaseAgent::authorize(OrgBluezDeviceInterface &device, QString uuid)
42 {
43         Q_UNUSED(uuid);
44         Q_UNUSED(device);
45         qDebug("authorize");
46 }
47
48 void BluetoothBaseAgent::confirmModeChange(QString mode)
49 {
50         qDebug()<<"mode changed "<<mode;
51 }
52
53 void BluetoothBaseAgent::displayPasskey(OrgBluezDeviceInterface &device, uint key)
54 {
55         qDebug()<<"display key "<<device.path()<<" "<<key;
56 }
57
58 void BluetoothBaseAgent::release()
59 {
60         qDebug("release called");
61 }
62
63 void BluetoothBaseAgent::requestConfirmation(OrgBluezDeviceInterface &device, uint key)
64 {
65         QVariantMap props = device.GetProperties();
66
67         QString alias = props["Alias"].toString();
68
69         qDebug()<<"Pairing with "<< alias << " with key: "+QString::number(key);
70 }
71
72 uint BluetoothBaseAgent::requestPasskey(OrgBluezDeviceInterface &device)
73 {
74         Q_UNUSED(device);
75         qDebug("requestKey");
76         return 0;
77 }
78
79 QString BluetoothBaseAgent::requestPidCode(OrgBluezDeviceInterface &device)
80 {
81         Q_UNUSED(device);
82         return "";
83 }
84