BluezQt

bluezqtextensionplugin.cpp
1 /*
2  * BluezQt - Asynchronous BlueZ wrapper library
3  *
4  * SPDX-FileCopyrightText: 2014 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 #include "bluezqtextensionplugin.h"
10 #include "declarativeadapter.h"
11 #include "declarativebattery.h"
12 #include "declarativedevice.h"
13 #include "declarativedevicesmodel.h"
14 #include "declarativeinput.h"
15 #include "declarativemanager.h"
16 #include "declarativemediaplayer.h"
17 #include "device.h"
18 #include "pendingcall.h"
19 #include "rfkill.h"
20 #include "services.h"
21 
22 #include <QtQml> // krazy:exclude=includes
23 
24 static QObject *manager_singleton(QQmlEngine *engine, QJSEngine *scriptEngine)
25 {
26  Q_UNUSED(engine)
27  Q_UNUSED(scriptEngine)
28 
29  return new DeclarativeManager;
30 }
31 
32 static QJSValue services_singleton(QQmlEngine *engine, QJSEngine *scriptEngine)
33 {
34  Q_UNUSED(engine)
35 
36  QJSValue object = scriptEngine->newObject();
37  object.setProperty(QStringLiteral("ServiceDiscoveryServer"), BluezQt::Services::ServiceDiscoveryServer);
38  object.setProperty(QStringLiteral("SerialPort"), BluezQt::Services::SerialPort);
39  object.setProperty(QStringLiteral("DialupNetworking"), BluezQt::Services::DialupNetworking);
40  object.setProperty(QStringLiteral("ObexObjectPush"), BluezQt::Services::ObexObjectPush);
41  object.setProperty(QStringLiteral("ObexFileTransfer"), BluezQt::Services::ObexFileTransfer);
42  object.setProperty(QStringLiteral("Headset"), BluezQt::Services::Headset);
43  object.setProperty(QStringLiteral("AudioSource"), BluezQt::Services::AudioSource);
44  object.setProperty(QStringLiteral("AudioSink"), BluezQt::Services::AudioSink);
45  object.setProperty(QStringLiteral("AudioVideoRemoteControlTarget"), BluezQt::Services::AudioVideoRemoteControlTarget);
46  object.setProperty(QStringLiteral("AdvancedAudioDistribution"), BluezQt::Services::AdvancedAudioDistribution);
47  object.setProperty(QStringLiteral("AudioVideoRemoteControl"), BluezQt::Services::AudioVideoRemoteControl);
48  object.setProperty(QStringLiteral("HeadsetAudioGateway"), BluezQt::Services::HeadsetAudioGateway);
49  object.setProperty(QStringLiteral("Panu"), BluezQt::Services::Panu);
50  object.setProperty(QStringLiteral("Nap"), BluezQt::Services::Nap);
51  object.setProperty(QStringLiteral("Handsfree"), BluezQt::Services::Handsfree);
52  object.setProperty(QStringLiteral("HandsfreeAudioGateway"), BluezQt::Services::HandsfreeAudioGateway);
53  object.setProperty(QStringLiteral("HumanInterfaceDevice"), BluezQt::Services::HumanInterfaceDevice);
54  object.setProperty(QStringLiteral("SimAccess"), BluezQt::Services::SimAccess);
55  object.setProperty(QStringLiteral("PhonebookAccessServer"), BluezQt::Services::PhonebookAccessServer);
56  object.setProperty(QStringLiteral("MessageAccessServer"), BluezQt::Services::MessageAccessServer);
57  object.setProperty(QStringLiteral("PnpInformation"), BluezQt::Services::PnpInformation);
58  object.setProperty(QStringLiteral("GenericAccess"), BluezQt::Services::GenericAccess);
59  object.setProperty(QStringLiteral("GenericAcces"), BluezQt::Services::GenericAccess); // TODO KF6: Remove the one with typo
60  object.setProperty(QStringLiteral("GenericAttribute"), BluezQt::Services::GenericAttribute);
61  object.setProperty(QStringLiteral("ImmediateAlert"), BluezQt::Services::ImmediateAlert);
62  object.setProperty(QStringLiteral("LinkLoss"), BluezQt::Services::LinkLoss);
63  object.setProperty(QStringLiteral("TxPower"), BluezQt::Services::TxPower);
64  object.setProperty(QStringLiteral("HeartRate"), BluezQt::Services::HeartRate);
65  return object;
66 }
67 
68 void BluezQtExtensionPlugin::registerTypes(const char *uri)
69 {
70  using namespace BluezQt;
71 
72  Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.bluezqt"));
73 
74  qmlRegisterSingletonType<DeclarativeManager>(uri, 1, 0, "Manager", manager_singleton);
75  qmlRegisterType<DeclarativeDevicesModel>(uri, 1, 0, "DevicesModelPrivate");
76  qmlRegisterUncreatableType<DeclarativeAdapter>(uri, 1, 0, "Adapter", QStringLiteral("Adapter cannot be created"));
77  qmlRegisterUncreatableType<DeclarativeBattery>(uri, 1, 0, "Battery", QStringLiteral("Battery cannot be created"));
78  qmlRegisterUncreatableType<DeclarativeDevice>(uri, 1, 0, "Device", QStringLiteral("Device cannot be created"));
79  qmlRegisterUncreatableType<DeclarativeInput>(uri, 1, 0, "Input", QStringLiteral("Input cannot be created"));
80  qmlRegisterUncreatableType<DeclarativeMediaPlayer>(uri, 1, 0, "MediaPlayer", QStringLiteral("MediaPlayer cannot be created"));
81  qmlRegisterUncreatableType<PendingCall>(uri, 1, 0, "PendingCall", QStringLiteral("PendingCall cannot be created"));
82  qmlRegisterUncreatableType<Rfkill>(uri, 1, 0, "Rfkill", QStringLiteral("Rfkill cannot be created"));
83  qmlRegisterSingletonType(uri, 1, 0, "Services", services_singleton);
84 }
QJSValue newObject()
void setProperty(const QString &name, const QJSValue &value)
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.