File indexing completed on 2024-04-28 15:17:55

0001 /*
0002  * BluezQt - Asynchronous BlueZ wrapper library
0003  *
0004  * SPDX-FileCopyrightText: 2014-2015 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 #ifndef BLUEZQT_OBEXAGENT_H
0010 #define BLUEZQT_OBEXAGENT_H
0011 
0012 #include <QObject>
0013 
0014 #include "bluezqt_export.h"
0015 #include "request.h"
0016 #include "types.h"
0017 
0018 class QDBusObjectPath;
0019 
0020 namespace BluezQt
0021 {
0022 class ObexTransfer;
0023 
0024 /**
0025  * @class BluezQt::ObexAgent obexagent.h <BluezQt/ObexAgent>
0026  *
0027  * Bluetooth OBEX agent.
0028  *
0029  * This class represents a Bluetooth OBEX agent.
0030  *
0031  * The agent is used to authorize an incoming object push requests.
0032  *
0033  * @note The return value of request will be sent asynchronously with Request class.
0034  *       It is also possible to cancel/reject the request.
0035  */
0036 class BLUEZQT_EXPORT ObexAgent : public QObject
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041     /**
0042      * Creates a new ObexAgent object.
0043      *
0044      * @param parent
0045      */
0046     explicit ObexAgent(QObject *parent = nullptr);
0047 
0048     /**
0049      * D-Bus object path of the agent.
0050      *
0051      * The path where the agent will be registered.
0052      *
0053      * @note You must provide valid object path!
0054      *
0055      * @return object path of agent
0056      */
0057     virtual QDBusObjectPath objectPath() const = 0;
0058 
0059     /**
0060      * Requests the agent to authorize an incoming object push request.
0061      *
0062      * This method gets called when the Bluetooth daemon
0063      * needs to accept/reject a Bluetooth object push request.
0064      *
0065      * The return value should be full path where the incoming object
0066      * will be saved.
0067      *
0068      * The ObexTransfer::fileName() contains the default location
0069      * and name that can be returned.
0070      *
0071      * You can use @p session to get device and adapter this transfer
0072      * belongs to.
0073      *
0074      * @param transfer transfer object
0075      * @param session transfer session
0076      * @param request request to be used for sending reply
0077      */
0078     virtual void authorizePush(ObexTransferPtr transfer, ObexSessionPtr session, const Request<QString> &request);
0079 
0080     /**
0081      * Indicate that the agent request failed before receiving reply.
0082      *
0083      * This method gets called to indicate that the agent
0084      * request failed before a reply was returned.
0085      *
0086      * It cancels the previous request.
0087      */
0088     virtual void cancel();
0089 
0090     /**
0091      * Indicates that the agent was unregistered.
0092      *
0093      * This method gets called when the Bluetooth daemon
0094      * unregisters the agent.
0095      *
0096      * An agent can use it to do cleanup tasks. There is no need
0097      * to unregister the agent, because when this method gets called
0098      * it has already been unregistered.
0099      */
0100     virtual void release();
0101 };
0102 
0103 } // namespace BluezQt
0104 
0105 #endif // BLUEZQT_OBEXAGENT_H