File indexing completed on 2024-12-01 12:29:51

0001 /*
0002  * BluezQt - Asynchronous Bluez wrapper library
0003  *
0004  * SPDX-FileCopyrightText: 2014 David Rosca <nowrep@gmail.com>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #include "profileadaptor.h"
0010 #include "device.h"
0011 #include "manager.h"
0012 #include "profile.h"
0013 
0014 #include <QDBusMessage>
0015 #include <QDBusObjectPath>
0016 #include <QDBusUnixFileDescriptor>
0017 
0018 namespace BluezQt
0019 {
0020 ProfileAdaptor::ProfileAdaptor(Profile *parent, Manager *manager)
0021     : QDBusAbstractAdaptor(parent)
0022     , m_profile(parent)
0023     , m_manager(manager)
0024 {
0025 }
0026 
0027 void ProfileAdaptor::NewConnection(const QDBusObjectPath &device, const QDBusUnixFileDescriptor &fd, const QVariantMap &properties, const QDBusMessage &msg)
0028 {
0029     msg.setDelayedReply(true);
0030     Request<> req(OrgBluezProfile, msg);
0031 
0032     DevicePtr dev = m_manager->deviceForUbi(device.path());
0033     if (!dev) {
0034         req.cancel();
0035         return;
0036     }
0037 
0038     m_profile->newConnection(dev, fd, properties, req);
0039 }
0040 
0041 void ProfileAdaptor::RequestDisconnection(const QDBusObjectPath &device, const QDBusMessage &msg)
0042 {
0043     msg.setDelayedReply(true);
0044     Request<> req(OrgBluezProfile, msg);
0045 
0046     DevicePtr dev = m_manager->deviceForUbi(device.path());
0047     if (!dev) {
0048         req.cancel();
0049         return;
0050     }
0051 
0052     m_profile->requestDisconnection(dev, req);
0053 }
0054 
0055 void ProfileAdaptor::Release()
0056 {
0057     m_profile->release();
0058 }
0059 
0060 } // namespace BluezQt
0061 
0062 #include "moc_profileadaptor.cpp"