BluezQt

profile.cpp
1/*
2 * BluezQt - Asynchronous Bluez wrapper library
3 *
4 * SPDX-FileCopyrightText: 2014 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 "profile.h"
10#include "debug.h"
11#include "profile_p.h"
12
13#include <unistd.h>
14
15#include <QDBusUnixFileDescriptor>
16#include <QLocalSocket>
17
18namespace BluezQt
19{
21 : QObject(parent)
23{
24}
25
26Profile::~Profile() = default;
27
28void Profile::setName(const QString &name)
29{
30 d->options[QStringLiteral("Name")] = name;
31}
32
33void Profile::setService(const QString &service)
34{
35 d->options[QStringLiteral("Service")] = service;
36}
37
39{
41 switch (role) {
42 case ClientRole:
43 str = QStringLiteral("client");
44 break;
45
46 case ServerRole:
47 str = QStringLiteral("server");
48 break;
49
50 default:
51 break;
52 }
53
54 if (str.isEmpty()) {
55 qCWarning(BLUEZQT) << "Invalid local role!";
56 return;
57 }
58
59 d->options[QStringLiteral("Role")] = str;
60}
61
62void Profile::setChannel(quint16 channel)
63{
64 if (channel > 31) {
65 qCWarning(BLUEZQT) << "Invalid channel number. Must be 0-31!";
66 return;
67 }
68
69 d->options[QStringLiteral("Channel")] = QVariant::fromValue(channel);
70}
71
72void Profile::setPsm(quint16 psm)
73{
74 d->options[QStringLiteral("PSM")] = QVariant::fromValue(psm);
75}
76
78{
79 d->options[QStringLiteral("RequireAuthentication")] = require;
80}
81
83{
84 d->options[QStringLiteral("RequireAuthorization")] = require;
85}
86
88{
89 d->options[QStringLiteral("AutoConnect")] = autoConnect;
90}
91
93{
94 d->options[QStringLiteral("ServiceRecord")] = serviceRecord;
95}
96
97void Profile::setVersion(quint16 version)
98{
99 d->options[QStringLiteral("Version")] = QVariant::fromValue(version);
100}
101
102void Profile::setFeatures(quint16 features)
103{
104 d->options[QStringLiteral("Features")] = QVariant::fromValue(features);
105}
106
108{
109 int newfd = ::dup(fd.fileDescriptor());
111 socket->setSocketDescriptor(newfd);
112 return socket;
113}
114
115void Profile::newConnection(DevicePtr device, const QDBusUnixFileDescriptor &fd, const QVariantMap &properties, const Request<> &request)
116{
117 Q_UNUSED(device)
118 Q_UNUSED(fd)
119 Q_UNUSED(properties)
120
121 request.cancel();
122}
123
125{
126 Q_UNUSED(device)
127
128 request.cancel();
129}
130
132{
133}
134
135} // namespace BluezQt
136
137#include "moc_profile.cpp"
void setServiceRecord(const QString &serviceRecord)
Sets a SDP record.
Definition profile.cpp:92
void setLocalRole(LocalRole role)
Sets the local role to identify side.
Definition profile.cpp:38
QSharedPointer< QLocalSocket > createSocket(const QDBusUnixFileDescriptor &fd)
Creates a socket from file descriptor.
Definition profile.cpp:107
void setRequireAuthorization(bool require)
Sets whether the authorization is required to connect.
Definition profile.cpp:82
Profile(QObject *parent=nullptr)
Creates a new Profile object.
Definition profile.cpp:20
void setName(const QString &name)
Sets the human readable name of the profile.
Definition profile.cpp:28
void setAutoConnect(bool autoConnect)
Sets whether the profile is automatically connected.
Definition profile.cpp:87
void setRequireAuthentication(bool require)
Sets whether the pairing is required to connect.
Definition profile.cpp:77
virtual void release()
Indicates that the profile was unregistered.
Definition profile.cpp:131
void setFeatures(quint16 features)
Sets the profile features.
Definition profile.cpp:102
void setService(const QString &service)
Sets the primary service class UUID (if different from profile UUID).
Definition profile.cpp:33
virtual void requestDisconnection(DevicePtr device, const Request<> &request)
Requests the disconnection of the profile.
Definition profile.cpp:124
virtual void newConnection(DevicePtr device, const QDBusUnixFileDescriptor &fd, const QVariantMap &properties, const Request<> &request)
Requests the new connection.
Definition profile.cpp:115
void setPsm(quint16 psm)
Sets the L2CAP port number.
Definition profile.cpp:72
LocalRole
Local role to identify sides in asymmetric profiles.
Definition profile.h:56
@ ClientRole
Indicates that this is a client.
Definition profile.h:58
@ ServerRole
Indicates that this is a server.
Definition profile.h:60
void setVersion(quint16 version)
Sets the profile version.
Definition profile.cpp:97
~Profile() override
Destroys a Profile object.
void setChannel(quint16 channel)
Sets the RFCOMM channel number.
Definition profile.cpp:62
D-Bus request.
Definition request.h:39
void cancel() const
Cancels the request.
Definition request.cpp:138
int fileDescriptor() const const
QVariant fromValue(const T &value)
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.