BluezQt

request.h
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#ifndef BLUEZQT_REQUEST_H
10#define BLUEZQT_REQUEST_H
11
12#include <QSharedPointer>
13
14#include "bluezqt_export.h"
15
16class QDBusMessage;
17
18namespace BluezQt
19{
20enum RequestOriginatingType {
21 OrgBluezAgent,
22 OrgBluezProfile,
23 OrgBluezObexAgent,
24 OrgBluezMediaEndpoint,
25};
26
27/**
28 * @class BluezQt::Request request.h <BluezQt/Request>
29 *
30 * D-Bus request.
31 *
32 * This class represents a request from a Bluetooth daemon. It is a convenient
33 * wrapper around QDBusMessage and easily allows sending replies and handling errors.
34 *
35 * @see Agent, ObexAgent, Profile
36 */
37template<typename T = void>
39{
40public:
41 /**
42 * Creates a new Request object.
43 */
44 explicit Request();
45
46 /**
47 * Destroys a Request object.
48 */
49 virtual ~Request();
50
51 /**
52 * Copy constructor.
53 *
54 * @param other
55 */
56 Request(const Request &other);
57
58 /**
59 * Copy assignment operator.
60 *
61 * @param other
62 */
64
65 /**
66 * Accepts the request.
67 *
68 * This method should be called to send a reply to indicate
69 * the request was accepted.
70 *
71 * In case the request is of type void, this method does not
72 * take any parameter.
73 *
74 * @param returnValue return value of request
75 */
76 void accept(T returnValue) const;
77
78 /**
79 * Rejects the request.
80 *
81 * This method should be called to send an error reply to
82 * indicate the request was rejected.
83 */
84 void reject() const;
85
86 /**
87 * Cancels the request.
88 *
89 * This method should be called to send an error reply to
90 * indicate the request was canceled.
91 */
92 void cancel() const;
93
94private:
95 explicit Request(RequestOriginatingType type, const QDBusMessage &message);
96
98
99 friend class AgentAdaptor;
100 friend class ObexAgentAdaptor;
101 friend class ProfileAdaptor;
102 friend class MediaEndpointAdaptor;
103};
104
105// void
106template<>
108{
109public:
110 explicit Request();
111 virtual ~Request();
112
113 Request(const Request &other);
115
116 void accept() const;
117 void reject() const;
118 void cancel() const;
119
120private:
121 explicit Request(RequestOriginatingType type, const QDBusMessage &message);
122
124
125 friend class AgentAdaptor;
126 friend class ObexAgentAdaptor;
127 friend class ProfileAdaptor;
128};
129
130} // namespace BluezQt
131
132#endif // BLUEZQT_REQUEST_H
D-Bus request.
Definition request.h:39
void accept(T returnValue) const
Accepts the request.
Definition request.cpp:126
Request & operator=(const Request &other)
Copy assignment operator.
Definition request.cpp:117
void cancel() const
Cancels the request.
Definition request.cpp:138
void reject() const
Rejects the request.
Definition request.cpp:132
virtual ~Request()
Destroys a Request object.
Definition request.cpp:106
Request()
Creates a new Request object.
Definition request.cpp:92
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:39:12 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.