This repository has been archived by the owner on Nov 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
include_directories(${GLIB_INCLUDE_DIRS}) | ||
add_definitions(-DSM_BUSNAME=sessionBus) | ||
|
||
add_library(HandleMediaKeys-qml MODULE | ||
HandleMediaKeys.cpp | ||
plugin.cpp | ||
) | ||
|
||
qt5_use_modules(HandleMediaKeys-qml DBus Qml) | ||
|
||
target_link_libraries(HandleMediaKeys-qml | ||
${GLIB_LIBRARIES} | ||
) | ||
|
||
add_unity8_plugin(HandleMediaKeys 0.1 HandleMediaKeys TARGETS HandleMediaKeys-qml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (C) 2020 UBports Foundation | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "HandleMediaKeys.h" | ||
#include <QDBusConnection> | ||
#include <QDBusConnectionInterface> | ||
#include <QDBusInterface> | ||
#include <QDebug> | ||
|
||
#include <glib.h> | ||
|
||
HandleMediaKeys::HandleMediaKeys(QObject* parent) | ||
: QObject(parent) | ||
{ | ||
|
||
auto connection = QDBusConnection::SM_BUSNAME(); | ||
auto interface = connection.interface(); | ||
interface->startService(QStringLiteral("com.ubports.Lomiri.Broadcast")); | ||
|
||
m_broadcaster = new QDBusInterface(QStringLiteral("com.ubports.Lomiri.Broadcast"), | ||
QStringLiteral("/com/ubports/Lomiri/Broadcast"), | ||
QStringLiteral("com.ubports.Lomiri.Broadcast"), | ||
connection, this); | ||
|
||
connect(m_broadcaster, SIGNAL(MediaKey(int key)), | ||
this, SLOT(onMediaKey(int key))); | ||
|
||
} | ||
|
||
void HandleMediaKeys::notifyMediaKey(int key) | ||
{ | ||
qDebug() << "notifyMediaKey(" << key << ")"; | ||
m_broadcaster->asyncCall(QStringLiteral("MediaKey"), key); | ||
} | ||
|
||
void HandleMediaKeys::onMediaKey(int key) | ||
{ | ||
Q_EMIT mediaKey(key); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (C) 2020 UBports Foundation | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef LOMIRI_HANDLEMEDIAKEYS_H | ||
#define LOMIRI_HANDLEMEDIAKEYS_H | ||
|
||
#include <QObject> | ||
#include <QString> | ||
|
||
class QDBusInterface; | ||
|
||
class HandleMediaKeys: public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit HandleMediaKeys(QObject *parent = 0); | ||
|
||
Q_INVOKABLE void notifyMediaKey(int key); | ||
|
||
Q_SIGNALS: | ||
void mediaKey(int key); | ||
|
||
private Q_SLOTS: | ||
void onMediaKey(int key); | ||
|
||
private: | ||
QDBusInterface *m_broadcaster; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (C) 2020 UBports Foundation | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "plugin.h" | ||
#include "HandleMediaKeys.h" | ||
|
||
#include <QtQml/qqml.h> | ||
|
||
static QObject *broadcast_provider(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
{ | ||
Q_UNUSED(engine) | ||
Q_UNUSED(scriptEngine) | ||
return new HandleMediaKeys(); | ||
} | ||
|
||
void HandleMediaKeysPlugin::registerTypes(const char *uri) | ||
{ | ||
Q_ASSERT(uri == QLatin1String("HandleMediaKeys")); | ||
qmlRegisterSingletonType<HandleMediaKeys>(uri, 0, 1, "HandleMediaKeys", broadcast_provider); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2020 UBports Foundation | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#ifndef LOMIRI_HANDLEMEDIAKEYS_PLUGIN | ||
#define LOMIRI_HANDLEMEDIAKEYS_PLUGIN | ||
|
||
#include <QQmlExtensionPlugin> | ||
|
||
class HandleMediaKeysPlugin : public QQmlExtensionPlugin | ||
{ | ||
Q_OBJECT | ||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
|
||
public: | ||
void registerTypes(const char *uri) override; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module HandleMediaKeys | ||
plugin HandleMediaKeys-qml | ||
typeinfo HandleMediaKeys.qmltypes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters