BluezQt

obexmanager.h
1 /*
2  * BluezQt - Asynchronous BlueZ wrapper library
3  *
4  * SPDX-FileCopyrightText: 2014-2015 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 #ifndef BLUEZQT_OBEXMANAGER_H
10 #define BLUEZQT_OBEXMANAGER_H
11 
12 #include <QObject>
13 
14 #include "bluezqt_export.h"
15 #include "obexsession.h"
16 
17 class QDBusObjectPath;
18 
19 namespace BluezQt
20 {
21 class ObexAgent;
22 class PendingCall;
23 class InitObexManagerJob;
24 
25 /**
26  * @class BluezQt::ObexManager obexmanager.h <BluezQt/ObexManager>
27  *
28  * OBEX manager.
29  *
30  * The entry point to communicate with session BlueZ obex daemon.
31  *
32  * You must call init() before other functions can be used.
33  *
34  * @note If manager is not operational, all methods that returns a PendingCall
35  * will fail with PendingCall::InternalError.
36  */
37 class BLUEZQT_EXPORT ObexManager : public QObject
38 {
39  Q_OBJECT
40 
41  Q_PROPERTY(bool initialized READ isInitialized)
42  Q_PROPERTY(bool operational READ isOperational NOTIFY operationalChanged)
43  Q_PROPERTY(QList<ObexSessionPtr> sessions READ sessions)
44 
45 public:
46  /**
47  * Creates a new ObexManager object.
48  *
49  * @param parent
50  */
51  explicit ObexManager(QObject *parent = nullptr);
52 
53  /**
54  * Destroys an ObexManager object.
55  */
56  ~ObexManager() override;
57 
58  /**
59  * Creates a new init job.
60  *
61  * @return init manager job
62  */
64 
65  /**
66  * Returns whether the manager is initialized.
67  *
68  * @return true if manager is initialized
69  */
70  bool isInitialized() const;
71 
72  /**
73  * Returns whether the manager is operational.
74  *
75  * The manager is operational when initialization was successful
76  * and BlueZ session daemon is running.
77  *
78  * @return true if manager is operational
79  */
80  bool isOperational() const;
81 
82  /**
83  * Returns a list of all sessions.
84  *
85  * @return list of sessions
86  */
87  QList<ObexSessionPtr> sessions() const;
88 
89  /**
90  * Returns a session for specified path.
91  *
92  * The @p path does not need to be equal to ObexSession path, startsWith
93  * test is performed in the search. That means you can use this method
94  * to get ObexSession from path returned by createSession().
95  *
96  * @param path path of session
97  * @return null if there is no session with specified path
98  */
99  ObexSessionPtr sessionForPath(const QDBusObjectPath &path) const;
100 
101  /**
102  * Attempts to start org.bluez.obex service by D-Bus activation.
103  *
104  * Possible return values are 1 if the service was started,
105  * 2 if the service is already running or error if the service
106  * could not be started.
107  *
108  * @return quint32 pending call
109  */
110  static PendingCall *startService();
111 
112 public Q_SLOTS:
113  /**
114  * Registers agent.
115  *
116  * This agent will be used to authorize an incoming object push requests.
117  *
118  * Possible errors: PendingCall::AlreadyExists
119  *
120  * @param agent agent to be registered
121  * @return void pending call
122  */
123  PendingCall *registerAgent(ObexAgent *agent);
124 
125  /**
126  * Unregisters agent.
127  *
128  * Possible errors: PendingCall::DoesNotExist
129  *
130  * @param agent agent to be unregistered
131  * @return void pending call
132  */
133  PendingCall *unregisterAgent(ObexAgent *agent);
134 
135  /**
136  * Creates a new OBEX session.
137  *
138  * The @p args parameter is a dictionary to hold optional or
139  * type-specific parameters.
140  *
141  * Typical parameters:
142  * <ul>
143  * <li>QString target - type of session to be created</li>
144  * <li>QString source - device address to be used</li>
145  * </ul>
146  *
147  * Supported targets:
148  * <ul>
149  * <li>ftp - ObexFileTransfer</li>
150  * <li>map</li>
151  * <li>opp - ObexObjectPush</li>
152  * <li>pbap</li>
153  * <li>sync</li>
154  * </ul>
155  *
156  * Possible errors: PendingCall::InvalidArguments, PendingCall::Failed
157  *
158  * @param destination address of target device
159  * @param args session parameters
160  * @return QDBusObjectPath pending call
161  */
162  PendingCall *createSession(const QString &destination, const QVariantMap &args);
163 
164  /**
165  * Removes an existing OBEX session.
166  *
167  * Possible errors: PendingCall::InvalidArguments, PendingCall::NotAuthorized
168  *
169  * @param session session to be removed
170  * @return void pending call
171  */
172  PendingCall *removeSession(const QDBusObjectPath &session);
173 
174 Q_SIGNALS:
175  /**
176  * Indicates that operational state have changed.
177  */
178  void operationalChanged(bool operational);
179 
180  /**
181  * Indicates that the session was added.
182  */
183  void sessionAdded(ObexSessionPtr session);
184 
185  /**
186  * Indicates that the session was removed.
187  */
188  void sessionRemoved(ObexSessionPtr session);
189 
190 private:
191  class ObexManagerPrivate *const d;
192 
193  friend class ObexManagerPrivate;
194  friend class InitObexManagerJobPrivate;
195 };
196 
197 } // namespace BluezQt
198 
199 #endif // BLUEZQT_OBEXMANAGER_H
QCA_EXPORT void init()
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:19:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.