BluezQt

obexagentadaptor.cpp
1/*
2 * BluezQt - Asynchronous Bluez wrapper library
3 *
4 * SPDX-FileCopyrightText: 2014-2015 David Rosca <nowrep@gmail.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "obexagentadaptor.h"
10#include "dbusproperties.h"
11#include "obexagent.h"
12#include "obexmanager.h"
13#include "obextransfer.h"
14#include "obextransfer_p.h"
15#include "utils.h"
16
17#include <QDBusObjectPath>
18
19namespace BluezQt
20{
21typedef org::freedesktop::DBus::Properties DBusProperties;
22
23ObexAgentAdaptor::ObexAgentAdaptor(ObexAgent *parent, ObexManager *manager)
24 : QDBusAbstractAdaptor(parent)
25 , m_agent(parent)
26 , m_manager(manager)
27{
28}
29
30QString ObexAgentAdaptor::AuthorizePush(const QDBusObjectPath &transfer, const QDBusMessage &msg)
31{
32 msg.setDelayedReply(true);
33 m_transferRequest = Request<QString>(OrgBluezObexAgent, msg);
34 m_transferPath = transfer.path();
35
36 DBusProperties dbusProperties(Strings::orgBluezObex(), m_transferPath, DBusConnection::orgBluezObex(), this);
37
38 const QDBusPendingReply<QVariantMap> &call = dbusProperties.GetAll(Strings::orgBluezObexTransfer1());
39 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
40 connect(watcher, &QDBusPendingCallWatcher::finished, this, &ObexAgentAdaptor::getPropertiesFinished);
41
42 return QString();
43}
44
45void ObexAgentAdaptor::Cancel()
46{
47 m_agent->cancel();
48}
49
50void ObexAgentAdaptor::Release()
51{
52 m_agent->release();
53}
54
55void ObexAgentAdaptor::getPropertiesFinished(QDBusPendingCallWatcher *watcher)
56{
57 const QDBusPendingReply<QVariantMap> &reply = *watcher;
58 watcher->deleteLater();
59
60 if (reply.isError()) {
61 m_transferRequest.cancel();
62 return;
63 }
64
65 ObexTransferPtr transfer = ObexTransferPtr(new ObexTransfer(m_transferPath, reply.value()));
66 transfer->d->q = transfer.toWeakRef();
67
68 ObexSessionPtr session = m_manager->sessionForPath(transfer->objectPath());
69 Q_ASSERT(session);
70
71 if (!session) {
72 m_transferRequest.cancel();
73 return;
74 }
75
76 m_agent->authorizePush(transfer, session, m_transferRequest);
77}
78
79} // namespace BluezQt
80
81#include "moc_obexagentadaptor.cpp"
void setDelayedReply(bool enable) const const
QString path() const const
void finished(QDBusPendingCallWatcher *self)
bool isError() const const
typename Select< 0 >::Type value() const const
void deleteLater()
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:46:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.