Merge lp:~agateau/kde-runtime/fdo-notifications into lp:~kubuntu-packagers/kubuntu-packaging/kde-runtime

Proposed by Aurélien Gâteau
Status: Merged
Merged at revision: not available
Proposed branch: lp:~agateau/kde-runtime/fdo-notifications
Merge into: lp:~kubuntu-packagers/kubuntu-packaging/kde-runtime
Diff against target: None lines
To merge this branch: bzr merge lp:~agateau/kde-runtime/fdo-notifications
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2009-07-11 02:56:04 +0000
+++ debian/changelog 2009-07-17 13:41:39 +0000
@@ -1,3 +1,11 @@
1kdebase-runtime (4:4.2.96-0ubuntu2) karmic; urgency=low
2
3 * Backport support for freedesktop.org notifications. Makes it possible for
4 GNOME and KDE applications to display notifications using the native
5 desktop notification system.
6
7 -- Aurélien Gâteau <aurelien.gateau@canonical.com> Fri, 17 Jul 2009 14:13:55 +0200
8
1kdebase-runtime (4:4.2.96-0ubuntu1) karmic; urgency=low9kdebase-runtime (4:4.2.96-0ubuntu1) karmic; urgency=low
210
3 [ Christian Mangold ]11 [ Christian Mangold ]
412
=== added file 'debian/patches/kubuntu_86_fdo_notifications.diff'
--- debian/patches/kubuntu_86_fdo_notifications.diff 1970-01-01 00:00:00 +0000
+++ debian/patches/kubuntu_86_fdo_notifications.diff 2009-07-17 13:41:39 +0000
@@ -0,0 +1,16 @@
1From 8861cfc7b4a8a3278773db766b836bbdce33e718 Mon Sep 17 00:00:00 2001
2From: =?utf-8?q?Aur=C3=A9lien=20G=C3=A2teau?= <agateau@kde.org>
3Date: Wed, 17 Jun 2009 15:26:14 +0200
4Subject: [PATCH] Removed event-id
5
6---
7--- a/knotify/notifybypopup.cpp
8+++ b/knotify/notifybypopup.cpp
9@@ -357,7 +357,6 @@ bool NotifyByPopup::sendNotificationDBus(int id, int replacesId, KNotifyConfig*
10
11 args.append( appCaption ); // app_name
12 args.append( dbus_replaces_id ); // replaces_id
13- args.append( config->eventid ); // event_id
14 args.append( iconName ); // app_icon
15 args.append( config->title ); // summary
16 args.append( config->text ); // body
017
=== added file 'debian/patches/kubuntu_87_fdo_notifications.diff'
--- debian/patches/kubuntu_87_fdo_notifications.diff 1970-01-01 00:00:00 +0000
+++ debian/patches/kubuntu_87_fdo_notifications.diff 2009-07-17 13:41:39 +0000
@@ -0,0 +1,40 @@
1From 86dd34fb4efba8163272c171912484ea077b0ed0 Mon Sep 17 00:00:00 2001
2From: =?utf-8?q?Aur=C3=A9lien=20G=C3=A2teau?= <agateau@kde.org>
3Date: Thu, 18 Jun 2009 17:45:23 +0200
4Subject: [PATCH] Switch to org.freedesktop.Notifications
5
6---
7--- a/knotify/notifybypopup.cpp
8+++ b/knotify/notifybypopup.cpp
9@@ -38,9 +38,9 @@
10 #include <QDBusConnectionInterface>
11 #include <kconfiggroup.h>
12
13-static const char dbusServiceName[] = "org.kde.VisualNotifications";
14-static const char dbusInterfaceName[] = "org.kde.VisualNotifications";
15-static const char dbusPath[] = "/VisualNotifications";
16+static const char dbusServiceName[] = "org.freedesktop.Notifications";
17+static const char dbusInterfaceName[] = "org.freedesktop.Notifications";
18+static const char dbusPath[] = "/org/freedesktop/Notifications";
19
20 NotifyByPopup::NotifyByPopup(QObject *parent)
21 : KNotifyPlugin(parent) , m_animationTimer(0), m_dbusServiceExists(false)
22@@ -348,7 +348,8 @@ bool NotifyByPopup::sendNotificationDBus(int id, int replacesId, KNotifyConfig*
23 // NOTE readEntry here is not KConfigGroup::readEntry - this is a custom class
24 // It returns QString.
25 QString timeoutStr = config->readEntry( "Timeout" );
26- int timeout = !timeoutStr.isEmpty() ? timeoutStr.toInt() : 0;
27+ // -1 means: notification server decides
28+ int timeout = !timeoutStr.isEmpty() ? timeoutStr.toInt() : -1;
29
30 QList<QVariant> args;
31
32@@ -358,7 +359,7 @@ bool NotifyByPopup::sendNotificationDBus(int id, int replacesId, KNotifyConfig*
33 args.append( appCaption ); // app_name
34 args.append( dbus_replaces_id ); // replaces_id
35 args.append( iconName ); // app_icon
36- args.append( config->title ); // summary
37+ args.append( config->title.isEmpty() ? appCaption : config->title ); // summary
38 args.append( config->text ); // body
39 // galago spec defines action list to be list like
40 // (act_id1, action1, act_id2, action2, ...)
041
=== added file 'debian/patches/kubuntu_88_fdo_notifications.diff'
--- debian/patches/kubuntu_88_fdo_notifications.diff 1970-01-01 00:00:00 +0000
+++ debian/patches/kubuntu_88_fdo_notifications.diff 2009-07-17 13:41:39 +0000
@@ -0,0 +1,182 @@
1From da943498b3affdfa6f61befd16e01c6311b01721 Mon Sep 17 00:00:00 2001
2From: =?utf-8?q?Aur=C3=A9lien=20G=C3=A2teau?= <agateau@kde.org>
3Date: Tue, 30 Jun 2009 11:58:22 +0200
4Subject: [PATCH] Use the correct format for image_data hint
5
6---
7--- a/knotify/CMakeLists.txt
8+++ b/knotify/CMakeLists.txt
9@@ -12,6 +12,7 @@ notifybylogfile.cpp
10 notifybytaskbar.cpp
11 notifybyexecute.cpp
12 notifybyktts.cpp
13+imageconverter.cpp
14 )
15
16 qt4_add_dbus_interfaces(knotify_SRCS ${KDE4_DBUS_INTERFACES_DIR}/org.kde.KSpeech.xml)
17--- /dev/null
18+++ b/knotify/imageconverter.cpp
19@@ -0,0 +1,101 @@
20+/*
21+ Copyright (C) 2009 by Aurélien Gâteau <agateau@kde.org>
22+
23+ This program is free software; you can redistribute it and/or modify
24+ it under the terms of the GNU General Public License as published by
25+ the Free Software Foundation; either version 2, or (at your option)
26+ any later version.
27+
28+ This program is distributed in the hope that it will be useful,
29+ but WITHOUT ANY WARRANTY; without even the implied warranty of
30+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31+ GNU General Public License for more details.
32+
33+ You should have received a copy of the GNU General Public License
34+ along with this program; if not, write to the Free Software
35+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36+
37+ */
38+#include "imageconverter.h"
39+
40+#include <QDBusArgument>
41+#include <QDBusMetaType>
42+#include <QImage>
43+
44+namespace ImageConverter
45+{
46+
47+/**
48+ * A structure representing an image which can be marshalled to fit the
49+ * notification spec.
50+ */
51+struct SpecImage
52+{
53+ int width, height, rowStride;
54+ bool hasAlpha;
55+ int bitsPerSample, channels;
56+ QByteArray data;
57+};
58+
59+QDBusArgument &operator<<(QDBusArgument &argument, const SpecImage &image)
60+{
61+ argument.beginStructure();
62+ argument << image.width << image.height << image.rowStride << image.hasAlpha;
63+ argument << image.bitsPerSample << image.channels << image.data;
64+ argument.endStructure();
65+ return argument;
66+}
67+
68+const QDBusArgument &operator>>(const QDBusArgument &argument, SpecImage &image)
69+{
70+ argument.beginStructure();
71+ argument >> image.width >> image.height >> image.rowStride >> image.hasAlpha;
72+ argument >> image.bitsPerSample >> image.channels >> image.data;
73+ argument.endStructure();
74+ return argument;
75+}
76+
77+QVariant variantForImage(const QImage &_image)
78+{
79+ qDBusRegisterMetaType<SpecImage>();
80+
81+ QImage image = _image.convertToFormat(QImage::Format_ARGB32);
82+
83+ int rowStride = image.width() * 4;
84+
85+ // Notification spec stores pixels in R,G,B,A order, regardless of
86+ // endianess
87+ // Qt represents pixels as 32 bit unsigned int. So the order depend on
88+ // endianess:
89+ // - In big endian the order is A,R,G,B
90+ // - In little endian the order is B,G,R,A
91+ QByteArray data;
92+ data.resize(rowStride * image.height());
93+ char* dst = data.data();
94+ for (int y=0; y<image.height(); ++y) {
95+ QRgb* src = (QRgb*)image.scanLine(y);
96+ QRgb* end = src + image.width();
97+ for (;src != end; ++src) {
98+ // Probably slow, but free of endianess issues
99+ *dst++ = qRed(*src);
100+ *dst++ = qGreen(*src);
101+ *dst++ = qBlue(*src);
102+ *dst++ = qAlpha(*src);
103+ }
104+ }
105+
106+ SpecImage specImage;
107+ specImage.width = image.width();
108+ specImage.height = image.height();
109+ specImage.rowStride = rowStride;
110+ specImage.hasAlpha = true;
111+ specImage.bitsPerSample = 8;
112+ specImage.channels = 4;
113+ specImage.data = data;
114+
115+ return QVariant::fromValue(specImage);
116+}
117+
118+} // namespace
119+
120+Q_DECLARE_METATYPE(ImageConverter::SpecImage)
121--- /dev/null
122+++ b/knotify/imageconverter.h
123@@ -0,0 +1,36 @@
124+/*
125+ Copyright (C) 2009 by Aurélien Gâteau <agateau@kde.org>
126+
127+ This program is free software; you can redistribute it and/or modify
128+ it under the terms of the GNU General Public License as published by
129+ the Free Software Foundation; either version 2, or (at your option)
130+ any later version.
131+
132+ This program is distributed in the hope that it will be useful,
133+ but WITHOUT ANY WARRANTY; without even the implied warranty of
134+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
135+ GNU General Public License for more details.
136+
137+ You should have received a copy of the GNU General Public License
138+ along with this program; if not, write to the Free Software
139+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
140+
141+ */
142+#ifndef IMAGECONVERTER_H
143+#define IMAGECONVERTER_H
144+
145+class QVariant;
146+class QImage;
147+
148+namespace ImageConverter
149+{
150+
151+/**
152+ * Returns a variant representing an image using the format describe in the
153+ * galago spec
154+ */
155+QVariant variantForImage(const QImage &image);
156+
157+} // namespace
158+
159+#endif /* IMAGECONVERTER_H */
160--- a/knotify/notifybypopup.cpp
161+++ b/knotify/notifybypopup.cpp
162@@ -20,6 +20,7 @@
163
164 #include "notifybypopup.h"
165 #include "knotifyconfig.h"
166+#include "imageconverter.h"
167
168 #include <kdebug.h>
169 #include <kpassivepopup.h>
170@@ -378,8 +379,10 @@ bool NotifyByPopup::sendNotificationDBus(int id, int replacesId, KNotifyConfig*
171
172 QVariantMap map;
173 // let's see if we've got an image, and store the image in the hints map
174- if (!config->image.isNull())
175- map["image_data"] = config->image.data();
176+ if (!config->image.isNull()) {
177+ QImage image = config->image.toImage();
178+ map["image_data"] = ImageConverter::variantForImage(image);
179+ }
180
181 args.append( map ); // hints
182 args.append( timeout ); // expire timout
0183
=== added file 'debian/patches/kubuntu_89_fdo_notifications.diff'
--- debian/patches/kubuntu_89_fdo_notifications.diff 1970-01-01 00:00:00 +0000
+++ debian/patches/kubuntu_89_fdo_notifications.diff 2009-07-17 13:41:39 +0000
@@ -0,0 +1,127 @@
1From 3b884757032294e77c4094fb5e10cab20e6b987d Mon Sep 17 00:00:00 2001
2From: =?utf-8?q?Aur=C3=A9lien=20G=C3=A2teau?= <agateau@kde.org>
3Date: Tue, 30 Jun 2009 15:20:33 +0200
4Subject: [PATCH] Move notification timeout handling to knotify.
5
6---
7--- a/knotify/knotify.cpp
8+++ b/knotify/knotify.cpp
9@@ -110,7 +110,7 @@ void KNotify::closeNotification(int id)
10 delete e;
11 }
12
13-int KNotify::event( const QString & event, const QString & appname, const ContextList & contexts, const QString & title, const QString & text, const KNotifyImage & image, const QStringList & actions, WId winId )
14+int KNotify::event( const QString & event, const QString & appname, const ContextList & contexts, const QString & title, const QString & text, const KNotifyImage & image, const QStringList & actions, int timeout, WId winId )
15 {
16 m_counter++;
17 Event *e=new Event(appname , contexts , event );
18@@ -121,6 +121,7 @@ int KNotify::event( const QString & event, const QString & appname, const Contex
19 e->config.text=text;
20 e->config.actions=actions;
21 e->config.image=image;
22+ e->config.timeout=timeout;
23 e->config.winId=(WId)winId;
24
25 m_notifications.insert(m_counter,e);
26@@ -207,7 +208,8 @@ void KNotifyAdaptor::closeNotification(int id)
27 }
28
29 int KNotifyAdaptor::event(const QString &event, const QString &fromApp, const QVariantList& contexts,
30- const QString &title, const QString &text, const QByteArray& image, const QStringList& actions , qlonglong winId)
31+ const QString &title, const QString &text, const QByteArray& image, const QStringList& actions,
32+ int timeout, qlonglong winId)
33 // const QDBusMessage & , int _return )
34
35 {
36@@ -231,7 +233,7 @@ int KNotifyAdaptor::event(const QString &event, const QString &fromApp, const QV
37 contextlist << qMakePair(context_key , s);
38 }
39
40- return static_cast<KNotify *>(parent())->event(event, fromApp, contextlist, title, text, image, actions, WId(winId));
41+ return static_cast<KNotify *>(parent())->event(event, fromApp, contextlist, title, text, image, actions, timeout, WId(winId));
42 }
43
44 void KNotifyAdaptor::reemit(int id, const QVariantList& contexts)
45--- a/knotify/knotify.h
46+++ b/knotify/knotify.h
47@@ -52,7 +52,8 @@ class KNotify : public QObject
48 void closeNotification( int id);
49
50 int event(const QString &event, const QString &fromApp, const ContextList& contexts ,
51- const QString &title, const QString &text, const KNotifyImage& image, const QStringList& actions , WId winId = 0);
52+ const QString &title, const QString &text, const KNotifyImage& image, const QStringList& actions,
53+ int timeout, WId winId = 0);
54
55 void update(int id, const QString &title, const QString &text, const KNotifyImage& image, const QStringList& actions);
56 void reemit(int id, const ContextList& contexts);
57@@ -108,6 +109,7 @@ class KNotifyAdaptor : public QDBusAbstractAdaptor
58 "<arg name=\"text\" type=\"s\" direction=\"in\"/>"
59 "<arg name=\"pixmap\" type=\"ay\" direction=\"in\"/>"
60 "<arg name=\"actions\" type=\"as\" direction=\"in\"/>"
61+ "<arg name=\"timeout\" type=\"i\" direction=\"in\"/>"
62 "<arg name=\"winId\" type=\"x\" direction=\"in\"/>"
63 "</method>"
64 "<method name=\"update\">"
65@@ -134,7 +136,8 @@ class KNotifyAdaptor : public QDBusAbstractAdaptor
66 void closeNotification( int id);
67
68 int event(const QString &event, const QString &fromApp, const QVariantList& contexts ,
69- const QString &title, const QString &text, const QByteArray& pixmap, const QStringList& actions , qlonglong winId );
70+ const QString &title, const QString &text, const QByteArray& pixmap, const QStringList& actions , int timeout,
71+ qlonglong winId );
72
73 void reemit(int id, const QVariantList& contexts);
74 void update(int id, const QString &title, const QString &text, const QByteArray& pixmap, const QStringList& actions );
75--- a/knotify/knotifyconfig.h
76+++ b/knotify/knotifyconfig.h
77@@ -84,6 +84,12 @@ class KNotifyConfig
78 */
79 KNotifyImage image;
80 /**
81+ * How long the notification should be presented (in seconds).
82+ * -1 means server decides,
83+ * 0 means infinite.
84+ */
85+ int timeout;
86+ /**
87 * The windowsID of the window that initiated the notification
88 * (it is a window in the client)
89 */
90--- a/knotify/notifybypopup.cpp
91+++ b/knotify/notifybypopup.cpp
92@@ -95,10 +95,9 @@ void NotifyByPopup::notify( int id, KNotifyConfig * config )
93 pop->setAutoDelete( true );
94 connect(pop, SIGNAL(destroyed()) , this, SLOT(slotPopupDestroyed()) );
95
96- // NOTE readEntry here is not KConfigGroup::readEntry - this is a custom class
97- // It returns QString.
98- QString timeoutStr = config->readEntry( "Timeout" );
99- pop->setTimeout( !timeoutStr.isEmpty() ? timeoutStr.toInt() : 0 );
100+ // Default to 6 seconds if no timeout has been defined
101+ int timeout = config->timeout == -1 ? 6 : config->timeout;
102+ pop->setTimeout(timeout);
103
104 pop->adjustSize();
105 pop->show(QPoint(screen.left() + screen.width()/2 - pop->width()/2 , m_nextPosition));
106@@ -346,12 +345,6 @@ bool NotifyByPopup::sendNotificationDBus(int id, int replacesId, KNotifyConfig*
107
108 QDBusMessage m = QDBusMessage::createMethodCall( dbusServiceName, dbusPath, dbusInterfaceName, "Notify" );
109
110- // NOTE readEntry here is not KConfigGroup::readEntry - this is a custom class
111- // It returns QString.
112- QString timeoutStr = config->readEntry( "Timeout" );
113- // -1 means: notification server decides
114- int timeout = !timeoutStr.isEmpty() ? timeoutStr.toInt() : -1;
115-
116 QList<QVariant> args;
117
118 QString appCaption, iconName;
119@@ -385,7 +378,7 @@ bool NotifyByPopup::sendNotificationDBus(int id, int replacesId, KNotifyConfig*
120 }
121
122 args.append( map ); // hints
123- args.append( timeout ); // expire timout
124+ args.append( config->timeout ); // expire timout
125
126 m.setArguments( args );
127 QDBusMessage replyMsg = QDBusConnection::sessionBus().call(m);
0128
=== modified file 'debian/patches/series'
--- debian/patches/series 2009-05-13 17:38:23 +0000
+++ debian/patches/series 2009-07-17 13:41:39 +0000
@@ -6,3 +6,7 @@
6kubuntu_07_oxygenify_knetattach_icon.diff6kubuntu_07_oxygenify_knetattach_icon.diff
7kubuntu_08_suggest_soprano_backend_sesame.diff7kubuntu_08_suggest_soprano_backend_sesame.diff
8kubuntu_85_language_selector.diff8kubuntu_85_language_selector.diff
9kubuntu_86_fdo_notifications.diff
10kubuntu_87_fdo_notifications.diff
11kubuntu_88_fdo_notifications.diff
12kubuntu_89_fdo_notifications.diff

Subscribers

People subscribed via source and target branches

to all changes: