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{
20Profile::Profile(QObject *parent)
21 : QObject(parent)
22 , d(new ProfilePrivate)
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
38void Profile::setLocalRole(Profile::LocalRole role)
39{
40 QString str;
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(value: channel);
70}
71
72void Profile::setPsm(quint16 psm)
73{
74 d->options[QStringLiteral("PSM")] = QVariant::fromValue(value: psm);
75}
76
77void Profile::setRequireAuthentication(bool require)
78{
79 d->options[QStringLiteral("RequireAuthentication")] = require;
80}
81
82void Profile::setRequireAuthorization(bool require)
83{
84 d->options[QStringLiteral("RequireAuthorization")] = require;
85}
86
87void Profile::setAutoConnect(bool autoConnect)
88{
89 d->options[QStringLiteral("AutoConnect")] = autoConnect;
90}
91
92void Profile::setServiceRecord(const QString &serviceRecord)
93{
94 d->options[QStringLiteral("ServiceRecord")] = serviceRecord;
95}
96
97void Profile::setVersion(quint16 version)
98{
99 d->options[QStringLiteral("Version")] = QVariant::fromValue(value: version);
100}
101
102void Profile::setFeatures(quint16 features)
103{
104 d->options[QStringLiteral("Features")] = QVariant::fromValue(value: features);
105}
106
107QSharedPointer<QLocalSocket> Profile::createSocket(const QDBusUnixFileDescriptor &fd)
108{
109 int newfd = ::dup(fd: fd.fileDescriptor());
110 QSharedPointer<QLocalSocket> socket(new QLocalSocket);
111 socket->setSocketDescriptor(socketDescriptor: 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
124void Profile::requestDisconnection(DevicePtr device, const Request<> &request)
125{
126 Q_UNUSED(device)
127
128 request.cancel();
129}
130
131void Profile::release()
132{
133}
134
135} // namespace BluezQt
136
137#include "moc_profile.cpp"
138

source code of bluez-qt/src/profile.cpp