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

Proposed by Aurélien Gâteau on 2009-07-17
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
1=== modified file 'debian/changelog'
2--- debian/changelog 2009-07-11 02:56:04 +0000
3+++ debian/changelog 2009-07-17 13:41:39 +0000
4@@ -1,3 +1,11 @@
5+kdebase-runtime (4:4.2.96-0ubuntu2) karmic; urgency=low
6+
7+ * Backport support for freedesktop.org notifications. Makes it possible for
8+ GNOME and KDE applications to display notifications using the native
9+ desktop notification system.
10+
11+ -- Aurélien Gâteau <aurelien.gateau@canonical.com> Fri, 17 Jul 2009 14:13:55 +0200
12+
13 kdebase-runtime (4:4.2.96-0ubuntu1) karmic; urgency=low
14
15 [ Christian Mangold ]
16
17=== added file 'debian/patches/kubuntu_86_fdo_notifications.diff'
18--- debian/patches/kubuntu_86_fdo_notifications.diff 1970-01-01 00:00:00 +0000
19+++ debian/patches/kubuntu_86_fdo_notifications.diff 2009-07-17 13:41:39 +0000
20@@ -0,0 +1,16 @@
21+From 8861cfc7b4a8a3278773db766b836bbdce33e718 Mon Sep 17 00:00:00 2001
22+From: =?utf-8?q?Aur=C3=A9lien=20G=C3=A2teau?= <agateau@kde.org>
23+Date: Wed, 17 Jun 2009 15:26:14 +0200
24+Subject: [PATCH] Removed event-id
25+
26+---
27+--- a/knotify/notifybypopup.cpp
28++++ b/knotify/notifybypopup.cpp
29+@@ -357,7 +357,6 @@ bool NotifyByPopup::sendNotificationDBus(int id, int replacesId, KNotifyConfig*
30+
31+ args.append( appCaption ); // app_name
32+ args.append( dbus_replaces_id ); // replaces_id
33+- args.append( config->eventid ); // event_id
34+ args.append( iconName ); // app_icon
35+ args.append( config->title ); // summary
36+ args.append( config->text ); // body
37
38=== added file 'debian/patches/kubuntu_87_fdo_notifications.diff'
39--- debian/patches/kubuntu_87_fdo_notifications.diff 1970-01-01 00:00:00 +0000
40+++ debian/patches/kubuntu_87_fdo_notifications.diff 2009-07-17 13:41:39 +0000
41@@ -0,0 +1,40 @@
42+From 86dd34fb4efba8163272c171912484ea077b0ed0 Mon Sep 17 00:00:00 2001
43+From: =?utf-8?q?Aur=C3=A9lien=20G=C3=A2teau?= <agateau@kde.org>
44+Date: Thu, 18 Jun 2009 17:45:23 +0200
45+Subject: [PATCH] Switch to org.freedesktop.Notifications
46+
47+---
48+--- a/knotify/notifybypopup.cpp
49++++ b/knotify/notifybypopup.cpp
50+@@ -38,9 +38,9 @@
51+ #include <QDBusConnectionInterface>
52+ #include <kconfiggroup.h>
53+
54+-static const char dbusServiceName[] = "org.kde.VisualNotifications";
55+-static const char dbusInterfaceName[] = "org.kde.VisualNotifications";
56+-static const char dbusPath[] = "/VisualNotifications";
57++static const char dbusServiceName[] = "org.freedesktop.Notifications";
58++static const char dbusInterfaceName[] = "org.freedesktop.Notifications";
59++static const char dbusPath[] = "/org/freedesktop/Notifications";
60+
61+ NotifyByPopup::NotifyByPopup(QObject *parent)
62+ : KNotifyPlugin(parent) , m_animationTimer(0), m_dbusServiceExists(false)
63+@@ -348,7 +348,8 @@ bool NotifyByPopup::sendNotificationDBus(int id, int replacesId, KNotifyConfig*
64+ // NOTE readEntry here is not KConfigGroup::readEntry - this is a custom class
65+ // It returns QString.
66+ QString timeoutStr = config->readEntry( "Timeout" );
67+- int timeout = !timeoutStr.isEmpty() ? timeoutStr.toInt() : 0;
68++ // -1 means: notification server decides
69++ int timeout = !timeoutStr.isEmpty() ? timeoutStr.toInt() : -1;
70+
71+ QList<QVariant> args;
72+
73+@@ -358,7 +359,7 @@ bool NotifyByPopup::sendNotificationDBus(int id, int replacesId, KNotifyConfig*
74+ args.append( appCaption ); // app_name
75+ args.append( dbus_replaces_id ); // replaces_id
76+ args.append( iconName ); // app_icon
77+- args.append( config->title ); // summary
78++ args.append( config->title.isEmpty() ? appCaption : config->title ); // summary
79+ args.append( config->text ); // body
80+ // galago spec defines action list to be list like
81+ // (act_id1, action1, act_id2, action2, ...)
82
83=== added file 'debian/patches/kubuntu_88_fdo_notifications.diff'
84--- debian/patches/kubuntu_88_fdo_notifications.diff 1970-01-01 00:00:00 +0000
85+++ debian/patches/kubuntu_88_fdo_notifications.diff 2009-07-17 13:41:39 +0000
86@@ -0,0 +1,182 @@
87+From da943498b3affdfa6f61befd16e01c6311b01721 Mon Sep 17 00:00:00 2001
88+From: =?utf-8?q?Aur=C3=A9lien=20G=C3=A2teau?= <agateau@kde.org>
89+Date: Tue, 30 Jun 2009 11:58:22 +0200
90+Subject: [PATCH] Use the correct format for image_data hint
91+
92+---
93+--- a/knotify/CMakeLists.txt
94++++ b/knotify/CMakeLists.txt
95+@@ -12,6 +12,7 @@ notifybylogfile.cpp
96+ notifybytaskbar.cpp
97+ notifybyexecute.cpp
98+ notifybyktts.cpp
99++imageconverter.cpp
100+ )
101+
102+ qt4_add_dbus_interfaces(knotify_SRCS ${KDE4_DBUS_INTERFACES_DIR}/org.kde.KSpeech.xml)
103+--- /dev/null
104++++ b/knotify/imageconverter.cpp
105+@@ -0,0 +1,101 @@
106++/*
107++ Copyright (C) 2009 by Aurélien Gâteau <agateau@kde.org>
108++
109++ This program is free software; you can redistribute it and/or modify
110++ it under the terms of the GNU General Public License as published by
111++ the Free Software Foundation; either version 2, or (at your option)
112++ any later version.
113++
114++ This program is distributed in the hope that it will be useful,
115++ but WITHOUT ANY WARRANTY; without even the implied warranty of
116++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
117++ GNU General Public License for more details.
118++
119++ You should have received a copy of the GNU General Public License
120++ along with this program; if not, write to the Free Software
121++ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
122++
123++ */
124++#include "imageconverter.h"
125++
126++#include <QDBusArgument>
127++#include <QDBusMetaType>
128++#include <QImage>
129++
130++namespace ImageConverter
131++{
132++
133++/**
134++ * A structure representing an image which can be marshalled to fit the
135++ * notification spec.
136++ */
137++struct SpecImage
138++{
139++ int width, height, rowStride;
140++ bool hasAlpha;
141++ int bitsPerSample, channels;
142++ QByteArray data;
143++};
144++
145++QDBusArgument &operator<<(QDBusArgument &argument, const SpecImage &image)
146++{
147++ argument.beginStructure();
148++ argument << image.width << image.height << image.rowStride << image.hasAlpha;
149++ argument << image.bitsPerSample << image.channels << image.data;
150++ argument.endStructure();
151++ return argument;
152++}
153++
154++const QDBusArgument &operator>>(const QDBusArgument &argument, SpecImage &image)
155++{
156++ argument.beginStructure();
157++ argument >> image.width >> image.height >> image.rowStride >> image.hasAlpha;
158++ argument >> image.bitsPerSample >> image.channels >> image.data;
159++ argument.endStructure();
160++ return argument;
161++}
162++
163++QVariant variantForImage(const QImage &_image)
164++{
165++ qDBusRegisterMetaType<SpecImage>();
166++
167++ QImage image = _image.convertToFormat(QImage::Format_ARGB32);
168++
169++ int rowStride = image.width() * 4;
170++
171++ // Notification spec stores pixels in R,G,B,A order, regardless of
172++ // endianess
173++ // Qt represents pixels as 32 bit unsigned int. So the order depend on
174++ // endianess:
175++ // - In big endian the order is A,R,G,B
176++ // - In little endian the order is B,G,R,A
177++ QByteArray data;
178++ data.resize(rowStride * image.height());
179++ char* dst = data.data();
180++ for (int y=0; y<image.height(); ++y) {
181++ QRgb* src = (QRgb*)image.scanLine(y);
182++ QRgb* end = src + image.width();
183++ for (;src != end; ++src) {
184++ // Probably slow, but free of endianess issues
185++ *dst++ = qRed(*src);
186++ *dst++ = qGreen(*src);
187++ *dst++ = qBlue(*src);
188++ *dst++ = qAlpha(*src);
189++ }
190++ }
191++
192++ SpecImage specImage;
193++ specImage.width = image.width();
194++ specImage.height = image.height();
195++ specImage.rowStride = rowStride;
196++ specImage.hasAlpha = true;
197++ specImage.bitsPerSample = 8;
198++ specImage.channels = 4;
199++ specImage.data = data;
200++
201++ return QVariant::fromValue(specImage);
202++}
203++
204++} // namespace
205++
206++Q_DECLARE_METATYPE(ImageConverter::SpecImage)
207+--- /dev/null
208++++ b/knotify/imageconverter.h
209+@@ -0,0 +1,36 @@
210++/*
211++ Copyright (C) 2009 by Aurélien Gâteau <agateau@kde.org>
212++
213++ This program is free software; you can redistribute it and/or modify
214++ it under the terms of the GNU General Public License as published by
215++ the Free Software Foundation; either version 2, or (at your option)
216++ any later version.
217++
218++ This program is distributed in the hope that it will be useful,
219++ but WITHOUT ANY WARRANTY; without even the implied warranty of
220++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
221++ GNU General Public License for more details.
222++
223++ You should have received a copy of the GNU General Public License
224++ along with this program; if not, write to the Free Software
225++ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
226++
227++ */
228++#ifndef IMAGECONVERTER_H
229++#define IMAGECONVERTER_H
230++
231++class QVariant;
232++class QImage;
233++
234++namespace ImageConverter
235++{
236++
237++/**
238++ * Returns a variant representing an image using the format describe in the
239++ * galago spec
240++ */
241++QVariant variantForImage(const QImage &image);
242++
243++} // namespace
244++
245++#endif /* IMAGECONVERTER_H */
246+--- a/knotify/notifybypopup.cpp
247++++ b/knotify/notifybypopup.cpp
248+@@ -20,6 +20,7 @@
249+
250+ #include "notifybypopup.h"
251+ #include "knotifyconfig.h"
252++#include "imageconverter.h"
253+
254+ #include <kdebug.h>
255+ #include <kpassivepopup.h>
256+@@ -378,8 +379,10 @@ bool NotifyByPopup::sendNotificationDBus(int id, int replacesId, KNotifyConfig*
257+
258+ QVariantMap map;
259+ // let's see if we've got an image, and store the image in the hints map
260+- if (!config->image.isNull())
261+- map["image_data"] = config->image.data();
262++ if (!config->image.isNull()) {
263++ QImage image = config->image.toImage();
264++ map["image_data"] = ImageConverter::variantForImage(image);
265++ }
266+
267+ args.append( map ); // hints
268+ args.append( timeout ); // expire timout
269
270=== added file 'debian/patches/kubuntu_89_fdo_notifications.diff'
271--- debian/patches/kubuntu_89_fdo_notifications.diff 1970-01-01 00:00:00 +0000
272+++ debian/patches/kubuntu_89_fdo_notifications.diff 2009-07-17 13:41:39 +0000
273@@ -0,0 +1,127 @@
274+From 3b884757032294e77c4094fb5e10cab20e6b987d Mon Sep 17 00:00:00 2001
275+From: =?utf-8?q?Aur=C3=A9lien=20G=C3=A2teau?= <agateau@kde.org>
276+Date: Tue, 30 Jun 2009 15:20:33 +0200
277+Subject: [PATCH] Move notification timeout handling to knotify.
278+
279+---
280+--- a/knotify/knotify.cpp
281++++ b/knotify/knotify.cpp
282+@@ -110,7 +110,7 @@ void KNotify::closeNotification(int id)
283+ delete e;
284+ }
285+
286+-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 )
287++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 )
288+ {
289+ m_counter++;
290+ Event *e=new Event(appname , contexts , event );
291+@@ -121,6 +121,7 @@ int KNotify::event( const QString & event, const QString & appname, const Contex
292+ e->config.text=text;
293+ e->config.actions=actions;
294+ e->config.image=image;
295++ e->config.timeout=timeout;
296+ e->config.winId=(WId)winId;
297+
298+ m_notifications.insert(m_counter,e);
299+@@ -207,7 +208,8 @@ void KNotifyAdaptor::closeNotification(int id)
300+ }
301+
302+ int KNotifyAdaptor::event(const QString &event, const QString &fromApp, const QVariantList& contexts,
303+- const QString &title, const QString &text, const QByteArray& image, const QStringList& actions , qlonglong winId)
304++ const QString &title, const QString &text, const QByteArray& image, const QStringList& actions,
305++ int timeout, qlonglong winId)
306+ // const QDBusMessage & , int _return )
307+
308+ {
309+@@ -231,7 +233,7 @@ int KNotifyAdaptor::event(const QString &event, const QString &fromApp, const QV
310+ contextlist << qMakePair(context_key , s);
311+ }
312+
313+- return static_cast<KNotify *>(parent())->event(event, fromApp, contextlist, title, text, image, actions, WId(winId));
314++ return static_cast<KNotify *>(parent())->event(event, fromApp, contextlist, title, text, image, actions, timeout, WId(winId));
315+ }
316+
317+ void KNotifyAdaptor::reemit(int id, const QVariantList& contexts)
318+--- a/knotify/knotify.h
319++++ b/knotify/knotify.h
320+@@ -52,7 +52,8 @@ class KNotify : public QObject
321+ void closeNotification( int id);
322+
323+ int event(const QString &event, const QString &fromApp, const ContextList& contexts ,
324+- const QString &title, const QString &text, const KNotifyImage& image, const QStringList& actions , WId winId = 0);
325++ const QString &title, const QString &text, const KNotifyImage& image, const QStringList& actions,
326++ int timeout, WId winId = 0);
327+
328+ void update(int id, const QString &title, const QString &text, const KNotifyImage& image, const QStringList& actions);
329+ void reemit(int id, const ContextList& contexts);
330+@@ -108,6 +109,7 @@ class KNotifyAdaptor : public QDBusAbstractAdaptor
331+ "<arg name=\"text\" type=\"s\" direction=\"in\"/>"
332+ "<arg name=\"pixmap\" type=\"ay\" direction=\"in\"/>"
333+ "<arg name=\"actions\" type=\"as\" direction=\"in\"/>"
334++ "<arg name=\"timeout\" type=\"i\" direction=\"in\"/>"
335+ "<arg name=\"winId\" type=\"x\" direction=\"in\"/>"
336+ "</method>"
337+ "<method name=\"update\">"
338+@@ -134,7 +136,8 @@ class KNotifyAdaptor : public QDBusAbstractAdaptor
339+ void closeNotification( int id);
340+
341+ int event(const QString &event, const QString &fromApp, const QVariantList& contexts ,
342+- const QString &title, const QString &text, const QByteArray& pixmap, const QStringList& actions , qlonglong winId );
343++ const QString &title, const QString &text, const QByteArray& pixmap, const QStringList& actions , int timeout,
344++ qlonglong winId );
345+
346+ void reemit(int id, const QVariantList& contexts);
347+ void update(int id, const QString &title, const QString &text, const QByteArray& pixmap, const QStringList& actions );
348+--- a/knotify/knotifyconfig.h
349++++ b/knotify/knotifyconfig.h
350+@@ -84,6 +84,12 @@ class KNotifyConfig
351+ */
352+ KNotifyImage image;
353+ /**
354++ * How long the notification should be presented (in seconds).
355++ * -1 means server decides,
356++ * 0 means infinite.
357++ */
358++ int timeout;
359++ /**
360+ * The windowsID of the window that initiated the notification
361+ * (it is a window in the client)
362+ */
363+--- a/knotify/notifybypopup.cpp
364++++ b/knotify/notifybypopup.cpp
365+@@ -95,10 +95,9 @@ void NotifyByPopup::notify( int id, KNotifyConfig * config )
366+ pop->setAutoDelete( true );
367+ connect(pop, SIGNAL(destroyed()) , this, SLOT(slotPopupDestroyed()) );
368+
369+- // NOTE readEntry here is not KConfigGroup::readEntry - this is a custom class
370+- // It returns QString.
371+- QString timeoutStr = config->readEntry( "Timeout" );
372+- pop->setTimeout( !timeoutStr.isEmpty() ? timeoutStr.toInt() : 0 );
373++ // Default to 6 seconds if no timeout has been defined
374++ int timeout = config->timeout == -1 ? 6 : config->timeout;
375++ pop->setTimeout(timeout);
376+
377+ pop->adjustSize();
378+ pop->show(QPoint(screen.left() + screen.width()/2 - pop->width()/2 , m_nextPosition));
379+@@ -346,12 +345,6 @@ bool NotifyByPopup::sendNotificationDBus(int id, int replacesId, KNotifyConfig*
380+
381+ QDBusMessage m = QDBusMessage::createMethodCall( dbusServiceName, dbusPath, dbusInterfaceName, "Notify" );
382+
383+- // NOTE readEntry here is not KConfigGroup::readEntry - this is a custom class
384+- // It returns QString.
385+- QString timeoutStr = config->readEntry( "Timeout" );
386+- // -1 means: notification server decides
387+- int timeout = !timeoutStr.isEmpty() ? timeoutStr.toInt() : -1;
388+-
389+ QList<QVariant> args;
390+
391+ QString appCaption, iconName;
392+@@ -385,7 +378,7 @@ bool NotifyByPopup::sendNotificationDBus(int id, int replacesId, KNotifyConfig*
393+ }
394+
395+ args.append( map ); // hints
396+- args.append( timeout ); // expire timout
397++ args.append( config->timeout ); // expire timout
398+
399+ m.setArguments( args );
400+ QDBusMessage replyMsg = QDBusConnection::sessionBus().call(m);
401
402=== modified file 'debian/patches/series'
403--- debian/patches/series 2009-05-13 17:38:23 +0000
404+++ debian/patches/series 2009-07-17 13:41:39 +0000
405@@ -6,3 +6,7 @@
406 kubuntu_07_oxygenify_knetattach_icon.diff
407 kubuntu_08_suggest_soprano_backend_sesame.diff
408 kubuntu_85_language_selector.diff
409+kubuntu_86_fdo_notifications.diff
410+kubuntu_87_fdo_notifications.diff
411+kubuntu_88_fdo_notifications.diff
412+kubuntu_89_fdo_notifications.diff

Subscribers

People subscribed via source and target branches

to all changes: