Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
simpler way to send the signal
Browse files Browse the repository at this point in the history
  • Loading branch information
wdehoog committed Jan 18, 2021
1 parent 6920e47 commit f20cb5e
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions plugins/Broadcaster/Broadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,47 @@

#include <glib.h>

#define BROADCAST_SERVICE "com.ubports.Lomiri.Broadcast"
#define BROADCAST_PATH "/com/ubports/Lomiri/Broadcast"
#define BROADCAST_INTERFACE "com.ubports.Lomiri.Broadcast"

//#define BROADCAST_SERVICE "com.canonical.Unity.Broadcast"
//#define BROADCAST_SERVICE "com.canonical.Unity"
//#define BROADCAST_PATH "/com/canonical/Unity/Broadcast"
//#define BROADCAST_INTERFACE "com.canonical.Unity.Broadcast"

Broadcaster::Broadcaster(QObject* parent)
: QObject(parent)
{

auto connection = QDBusConnection::SM_BUSNAME();
auto interface = connection.interface();
interface->startService(QStringLiteral("com.ubports.Lomiri.Broadcast"));
//auto interface = connection.interface();
//auto reply = interface->startService(QStringLiteral(BROADCAST_INTERFACE));
//if(!reply.isValid())
// qWarning() << "Failed to start DBus service " << BROADCAST_SERVICE << ": " << reply.error().message();

m_broadcaster = new QDBusInterface(QStringLiteral("com.ubports.Lomiri.Broadcast"),
QStringLiteral("/com/ubports/Lomiri/Broadcast"),
QStringLiteral("com.ubports.Lomiri.Broadcast"),
/*m_broadcaster = new QDBusInterface(QStringLiteral(BROADCAST_SERVICE),
QStringLiteral(BROADCAST_PATH),
QStringLiteral(BROADCAST_INTERFACE),
connection, this);

*/
}

void Broadcaster::notifyMediaKey(const QString &keyMsg)
{
m_broadcaster->asyncCall(QStringLiteral("MediaKey"), keyMsg);

auto connection = QDBusConnection::SM_BUSNAME();
QDBusMessage msg = QDBusMessage::createSignal("/com/ubports/Lomiri/Broadcast", "com.ubports.Lomiri.Broadcast", "MediaKey");

QVariantMap args;
args.insert("key-msg", keyMsg);
msg << args; // keyMsg;

connection.send(msg);

//m_broadcaster->asyncCall(QStringLiteral("MediaKey"), args);
/*QDBusReply<void> reply = m_broadcaster->call(QStringLiteral("MediaKey"), args);
if(!reply.isValid())
qWarning() << "Failed to signal MediaKey: " << reply.error().message();
*/
}

0 comments on commit f20cb5e

Please sign in to comment.