3 * meego handset bluetooth
4 * Copyright © 2010, Intel Corporation.
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
12 #include "asyncagent.h"
14 AsyncAgent::AsyncAgent(QString path, QObject *parent) :
15 BluetoothBaseAgent(path,parent), m_connection(QDBusConnection::systemBus())
20 void AsyncAgent::requestConfirmation(OrgBluezDeviceInterface &device, uint key)
22 qDebug("requestConfirmation");
23 setDelayedReply(true);
24 pendingMessage = message();
25 m_connection = connection();
27 QVariantMap props = device.GetProperties();
29 QString alias = props["Alias"].toString();
31 deviceToPair = new BluetoothDevice(QDBusObjectPath(device.path()),this);
33 QMetaObject::invokeMethod(parent(),"requestConfirmation",
34 Qt::QueuedConnection, Q_ARG(QString, alias), Q_ARG(uint,key));
39 uint AsyncAgent::requestPasskey(OrgBluezDeviceInterface &device)
42 setDelayedReply(true);
43 pendingMessage = message();
44 m_connection = connection();
46 QVariantMap props = device.GetProperties();
48 QString alias = props["Alias"].toString();
50 deviceToPair = new BluetoothDevice(QDBusObjectPath(device.path()),this);
52 QMetaObject::invokeMethod(parent(), "requestPasskey", Qt::QueuedConnection, Q_ARG(QString, alias));
57 QString AsyncAgent::requestPidCode(OrgBluezDeviceInterface &device)
59 qDebug("requestPidCode");
60 setDelayedReply(true);
61 pendingMessage = message();
62 m_connection = connection();
64 QVariantMap props = device.GetProperties();
66 QString alias = props["Alias"].toString();
68 deviceToPair = new BluetoothDevice(QDBusObjectPath(device.path()),this);
70 QMetaObject::invokeMethod(parent(), "requestPidCode", Qt::QueuedConnection, Q_ARG(QString, alias));
75 void AsyncAgent::release()
78 if (!QMetaObject::invokeMethod(parent(), "release", Qt::QueuedConnection))
79 qDebug("sending relay signal failed!!!");
83 void AsyncAgent::replyRequestConfirmation(bool confirmed)
88 QDBusMessage reply = pendingMessage.createErrorReply("org.bluez.Error.Rejected", "The request was rejected");
89 m_connection.send(reply);
94 QDBusMessage reply = pendingMessage.createReply();
95 m_connection.send(reply);
99 void AsyncAgent::replyPasskey(uint passkey)
101 QDBusMessage reply = pendingMessage.createReply(passkey);
102 m_connection.send(reply);
105 void AsyncAgent::replyRequestPidCode(QString pidCode)
107 QDBusMessage reply = pendingMessage.createReply(pidCode);
108 m_connection.send(reply);