| 1 |
/* |
| 2 |
* BluezQt - Asynchronous Bluez wrapper library |
| 3 |
* |
| 4 |
* SPDX-FileCopyrightText: 2014 David Rosca <[email protected]> |
| 5 |
* |
| 6 |
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "profileadaptor.h" |
| 10 |
#include "device.h" |
| 11 |
#include "manager.h" |
| 12 |
#include "profile.h" |
| 13 |
|
| 14 |
#include <QDBusMessage> |
| 15 |
#include <QDBusObjectPath> |
| 16 |
#include <QDBusUnixFileDescriptor> |
| 17 |
|
| 18 |
namespace BluezQt |
| 19 |
{ |
| 20 |
ProfileAdaptor::ProfileAdaptor(Profile *parent, Manager *manager) |
| 21 |
: QDBusAbstractAdaptor(parent) |
| 22 |
, m_profile(parent) |
| 23 |
, m_manager(manager) |
| 24 |
{ |
| 25 |
} |
| 26 |
|
| 27 |
void ProfileAdaptor::NewConnection(const QDBusObjectPath &device, const QDBusUnixFileDescriptor &fd, const QVariantMap &properties, const QDBusMessage &msg) |
| 28 |
{ |
| 29 |
msg.setDelayedReply(true); |
| 30 |
Request<> req(OrgBluezProfile, msg); |
| 31 |
|
| 32 |
DevicePtr dev = m_manager->deviceForUbi(device.path()); |
| 33 |
if (!dev) { |
| 34 |
req.cancel(); |
| 35 |
return; |
| 36 |
} |
| 37 |
|
| 38 |
m_profile->newConnection(dev, fd, properties, req); |
| 39 |
} |
| 40 |
|
| 41 |
void ProfileAdaptor::RequestDisconnection(const QDBusObjectPath &device, const QDBusMessage &msg) |
| 42 |
{ |
| 43 |
msg.setDelayedReply(true); |
| 44 |
Request<> req(OrgBluezProfile, msg); |
| 45 |
|
| 46 |
DevicePtr dev = m_manager->deviceForUbi(device.path()); |
| 47 |
if (!dev) { |
| 48 |
req.cancel(); |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
m_profile->requestDisconnection(dev, req); |
| 53 |
} |
| 54 |
|
| 55 |
void ProfileAdaptor::Release() |
| 56 |
{ |
| 57 |
m_profile->release(); |
| 58 |
} |
| 59 |
|
| 60 |
} // namespace BluezQt |
| 61 |
|
| 62 |
#include "moc_profileadaptor.cpp" |