0002-Improved-support-for-org.freedesktop.Notifications.patch
src/client/client.pri | ||
---|---|---|
2 | 2 |
QT_MOD = core network gui |
3 | 3 | |
4 | 4 |
SRCS += buffer.cpp buffersettings.cpp clientbacklogmanager.cpp treemodel.cpp networkmodel.cpp buffermodel.cpp \ |
5 |
client.cpp clientsettings.cpp clientsyncer.cpp mappedselectionmodel.cpp selectionmodelsynchronizer.cpp |
|
5 |
client.cpp clientsettings.cpp clientsyncer.cpp mappedselectionmodel.cpp selectionmodelsynchronizer.cpp \ |
|
6 |
desktopnotifications.cpp |
|
6 | 7 |
HDRS += buffer.h buffersettings.h clientbacklogmanager.h treemodel.h networkmodel.h buffermodel.h \ |
7 |
client.h clientsettings.h clientsyncer.h quasselui.h mappedselectionmodel.h selectionmodelsynchronizer.h |
|
8 |
client.h clientsettings.h clientsyncer.h quasselui.h mappedselectionmodel.h selectionmodelsynchronizer.h \ |
|
9 |
desktopnotifications.h |
|
8 | 10 | |
9 | 11 |
sputdev { |
10 | 12 |
SRCS += messagemodel.cpp |
src/client/desktopnotifications.cpp | ||
---|---|---|
1 |
/* |
|
2 |
* This file was generated by dbusxml2cpp version 0.6 |
|
3 |
* Command line was: dbusxml2cpp -p desktopnotifications org.freedesktop.Notifications.xml |
|
4 |
* |
|
5 |
* dbusxml2cpp is Copyright (C) 2006 Trolltech ASA. All rights reserved. |
|
6 |
* |
|
7 |
* This is an auto-generated file. |
|
8 |
* This file may have been hand-edited. Look for HAND-EDIT comments |
|
9 |
* before re-generating it. |
|
10 |
*/ |
|
11 | ||
12 |
#include "desktopnotifications.h" |
|
13 | ||
14 |
/* |
|
15 |
* Implementation of interface class OrgFreedesktopNotificationsInterface |
|
16 |
*/ |
|
17 | ||
18 |
OrgFreedesktopNotificationsInterface::OrgFreedesktopNotificationsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) |
|
19 |
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) |
|
20 |
{ |
|
21 |
} |
|
22 | ||
23 |
OrgFreedesktopNotificationsInterface::~OrgFreedesktopNotificationsInterface() |
|
24 |
{ |
|
25 |
} |
|
26 |
src/client/desktopnotifications.h | ||
---|---|---|
1 |
/* |
|
2 |
* This file was generated by dbusxml2cpp version 0.6 |
|
3 |
* Command line was: dbusxml2cpp -p desktopnotifications org.freedesktop.Notifications.xml |
|
4 |
* |
|
5 |
* dbusxml2cpp is Copyright (C) 2006 Trolltech ASA. All rights reserved. |
|
6 |
* |
|
7 |
* This is an auto-generated file. |
|
8 |
* Do not edit! All changes made to it will be lost. |
|
9 |
*/ |
|
10 | ||
11 |
#ifndef DESKTOPNOTIFICATIONS_H_1211193208 |
|
12 |
#define DESKTOPNOTIFICATIONS_H_1211193208 |
|
13 | ||
14 |
#include <QtCore/QObject> |
|
15 |
#include <QtCore/QByteArray> |
|
16 |
#include <QtCore/QList> |
|
17 |
#include <QtCore/QMap> |
|
18 |
#include <QtCore/QString> |
|
19 |
#include <QtCore/QStringList> |
|
20 |
#include <QtCore/QVariant> |
|
21 |
#include <QtDBus/QtDBus> |
|
22 | ||
23 |
/* |
|
24 |
* Proxy class for interface org.freedesktop.Notifications |
|
25 |
*/ |
|
26 |
class OrgFreedesktopNotificationsInterface: public QDBusAbstractInterface |
|
27 |
{ |
|
28 |
Q_OBJECT |
|
29 |
public: |
|
30 |
static inline const char *staticInterfaceName() |
|
31 |
{ return "org.freedesktop.Notifications"; } |
|
32 | ||
33 |
public: |
|
34 |
OrgFreedesktopNotificationsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); |
|
35 | ||
36 |
~OrgFreedesktopNotificationsInterface(); |
|
37 | ||
38 |
public Q_SLOTS: // METHODS |
|
39 |
inline QDBusReply<void> CloseNotification(uint id) |
|
40 |
{ |
|
41 |
QList<QVariant> argumentList; |
|
42 |
argumentList << qVariantFromValue(id); |
|
43 |
return callWithArgumentList(QDBus::Block, QLatin1String("CloseNotification"), argumentList); |
|
44 |
} |
|
45 | ||
46 |
inline QDBusReply<QStringList> GetCapabilities() |
|
47 |
{ |
|
48 |
QList<QVariant> argumentList; |
|
49 |
return callWithArgumentList(QDBus::Block, QLatin1String("GetCapabilities"), argumentList); |
|
50 |
} |
|
51 | ||
52 |
inline QDBusReply<QString> GetServerInformation(QString &vendor, QString &version) |
|
53 |
{ |
|
54 |
QList<QVariant> argumentList; |
|
55 |
QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("GetServerInformation"), argumentList); |
|
56 |
if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 3) { |
|
57 |
vendor = qdbus_cast<QString>(reply.arguments().at(1)); |
|
58 |
version = qdbus_cast<QString>(reply.arguments().at(2)); |
|
59 |
} |
|
60 |
return reply; |
|
61 |
} |
|
62 | ||
63 |
inline QDBusReply<uint> Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int expire_timeout) |
|
64 |
{ |
|
65 |
QList<QVariant> argumentList; |
|
66 |
argumentList << qVariantFromValue(app_name) << qVariantFromValue(replaces_id) << qVariantFromValue(app_icon) << qVariantFromValue(summary) << qVariantFromValue(body) << qVariantFromValue(actions) << qVariantFromValue(hints) << qVariantFromValue(expire_timeout); |
|
67 |
return callWithArgumentList(QDBus::Block, QLatin1String("Notify"), argumentList); |
|
68 |
} |
|
69 | ||
70 |
Q_SIGNALS: // SIGNALS |
|
71 |
void ActionInvoked(uint id, const QString &action); |
|
72 |
void NotificationClosed(uint id, uint reason); |
|
73 |
}; |
|
74 | ||
75 |
namespace org { |
|
76 |
namespace freedesktop { |
|
77 |
typedef ::OrgFreedesktopNotificationsInterface Notifications; |
|
78 |
} |
|
79 |
} |
|
80 |
#endif |
src/client/org.freedesktop.Notifications.xml | ||
---|---|---|
1 |
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> |
|
2 |
<node> |
|
3 |
<interface name="org.freedesktop.Notifications"> |
|
4 |
<signal name="NotificationClosed"> |
|
5 |
<arg name="id" type="u" direction="out"/> |
|
6 |
<arg name="reason" type="u" direction="out"/> |
|
7 |
</signal> |
|
8 |
<signal name="ActionInvoked"> |
|
9 |
<arg name="id" type="u" direction="out"/> |
|
10 |
<arg name="action" type="s" direction="out"/> |
|
11 |
</signal> |
|
12 |
<method name="GetCapabilities"> |
|
13 |
<arg type="as" direction="out"/> |
|
14 |
</method> |
|
15 |
<method name="GetServerInformation"> |
|
16 |
<arg name="name" type="s" direction="out"/> |
|
17 |
<arg name="vendor" type="s" direction="out"/> |
|
18 |
<arg name="version" type="s" direction="out"/> |
|
19 |
</method> |
|
20 |
<method name="Notify"> |
|
21 |
<arg type="u" direction="out"/> |
|
22 |
<arg name="app_name" type="s" direction="in"/> |
|
23 |
<arg name="replaces_id" type="u" direction="in"/> |
|
24 |
<arg name="app_icon" type="s" direction="in"/> |
|
25 |
<arg name="summary" type="s" direction="in"/> |
|
26 |
<arg name="body" type="s" direction="in"/> |
|
27 |
<arg name="actions" type="as" direction="in"/> |
|
28 |
<arg name="hints" type="a{sv}" direction="in"/> |
|
29 |
<annotation name="com.trolltech.QtDBus.QtTypeName.In6" value="QVariantMap"/> |
|
30 |
<arg name="expire_timeout" type="i" direction="in"/> |
|
31 |
</method> |
|
32 |
<method name="CloseNotification"> |
|
33 |
<arg name="id" type="u" direction="in"/> |
|
34 |
</method> |
|
35 |
</interface> |
|
36 |
</node> |
src/qtui/mainwin.cpp | ||
---|---|---|
60 | 60 |
#include "global.h" |
61 | 61 |
#include "qtuistyle.h" |
62 | 62 | |
63 |
#include <Qt/QtDBus>
|
|
63 |
#include "desktopnotifications.h"
|
|
64 | 64 | |
65 | 65 | |
66 | 66 |
MainWin::MainWin(QtUi *_gui, QWidget *parent) |
... | ... | |
75 | 75 |
trayIconActive(false), |
76 | 76 |
timer(new QTimer(this)), |
77 | 77 |
settingsDlg(new SettingsDlg(this)), |
78 |
debugConsole(new DebugConsole(this)) |
|
78 |
debugConsole(new DebugConsole(this)), |
|
79 |
desktopNotifications(new org::freedesktop::Notifications( |
|
80 |
"org.freedesktop.Notifications", |
|
81 |
"/org/freedesktop/Notifications", |
|
82 |
QDBusConnection::sessionBus(), this)), |
|
83 |
notificationId(0) |
|
79 | 84 |
{ |
80 | 85 |
ui.setupUi(this); |
81 | 86 |
setWindowTitle("Quassel IRC"); |
... | ... | |
93 | 98 |
if(style != "") { |
94 | 99 |
QApplication::setStyle(style); |
95 | 100 |
} |
101 | ||
102 |
connect(desktopNotifications, SIGNAL(NotificationClosed(uint, uint)), this, SLOT(desktopNotificationClosed(uint, uint))); |
|
103 |
connect(desktopNotifications, SIGNAL(ActionInvoked(uint, const QString&)), this, SLOT(desktopNotificationInvoked(uint, const QString&))); |
|
96 | 104 |
} |
97 | 105 | |
98 | 106 |
void MainWin::init() { |
... | ... | |
599 | 607 |
{ |
600 | 608 |
QStringList actions; |
601 | 609 |
QMap<QString, QVariant> hints; |
602 |
QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "", "Notify"); |
|
603 | 610 | |
604 | 611 |
hints["x"] = 100; // Standard hint: x location for the popup to show up |
605 | 612 |
hints["y"] = 100; // Standard hint: y location for the popup to show up |
606 | 613 | |
607 |
msg << "Quassel"; // Application name |
|
608 |
msg << quint32(0); // ID of previous notification to replace |
|
609 |
msg << ""; // Icon to display |
|
610 |
msg << "Quassel: " + title; // Summary / Header of the message to display |
|
611 |
msg << message; // Body of the message to display |
|
612 |
msg << actions; // Actions from which the user may choose |
|
613 |
msg << hints; // Hints to the server displaying the message |
|
614 |
msg << qint32(10000); // Timeout in milliseconds |
|
614 |
actions << "click" << "Click Me!"; |
|
615 | ||
616 |
QDBusReply<uint> reply = desktopNotifications->Notify( |
|
617 |
"Quassel", // Application name |
|
618 |
notificationId, // ID of previous notification to replace |
|
619 |
"", // Icon to display |
|
620 |
title, // Summary / Header of the message to display |
|
621 |
QString("%1: %2:\n%2").arg(QTime::currentTime().toString()).arg(title).arg(message), // Body of the message to display |
|
622 |
actions, // Actions from which the user may choose |
|
623 |
hints, // Hints to the server displaying the message |
|
624 |
5000 // Timeout in milliseconds |
|
625 |
); |
|
626 | ||
627 |
if (!reply.isValid()) |
|
628 |
{ |
|
629 |
/* ERROR */ |
|
630 |
qDebug() << "Error on sending notification..."; |
|
631 |
return; |
|
632 |
} |
|
633 | ||
634 |
notificationId = reply.value(); |
|
635 | ||
636 |
qDebug() << "ID: " << notificationId << " Time: " << QTime::currentTime().toString(); |
|
637 |
} |
|
638 | ||
639 | ||
640 |
void MainWin::desktopNotificationClosed(uint id, uint reason) |
|
641 |
{ |
|
642 |
qDebug() << "OID: " << notificationId << " ID: " << id << " Reason: " << reason << " Time: " << QTime::currentTime().toString(); |
|
643 |
notificationId = 0; |
|
644 |
} |
|
645 | ||
615 | 646 | |
616 |
(void)QDBusConnection::sessionBus().call(msg); // Would return a message containing the id of this notification |
|
647 |
void MainWin::desktopNotificationInvoked(uint id, const QString & action) |
|
648 |
{ |
|
649 |
qDebug() << "OID: " << notificationId << " ID: " << id << " Action: " << action << " Time: " << QTime::currentTime().toString(); |
|
617 | 650 |
} |
618 | 651 | |
619 | 652 |
src/qtui/mainwin.h | ||
---|---|---|
40 | 40 |
class NickListWidget; |
41 | 41 |
class DebugConsole; |
42 | 42 | |
43 |
#include "desktopnotifications.h" |
|
43 | 44 | |
44 | 45 |
//!\brief The main window of Quassel's QtUi. |
45 | 46 |
class MainWin : public QMainWindow { |
... | ... | |
97 | 98 |
void loadLayout(); |
98 | 99 |
void saveLayout(); |
99 | 100 | |
101 |
void desktopNotificationClosed(uint id, uint reason); |
|
102 |
void desktopNotificationInvoked(uint id, const QString & action); |
|
103 | ||
100 | 104 |
signals: |
101 | 105 |
void connectToCore(const QVariantMap &connInfo); |
102 | 106 |
void disconnectFromCore(); |
... | ... | |
146 | 150 |
QAction *actionEditNetworks; |
147 | 151 |
QList<QAction *> networkActions; |
148 | 152 | |
153 |
org::freedesktop::Notifications *desktopNotifications; |
|
154 |
quint32 notificationId; |
|
155 | ||
149 | 156 |
friend class QtUi; |
150 | 157 |
}; |
151 | 158 | |
152 |
- |