Get rid of libnotify dependency (Use DBus instead)

This commit is contained in:
Christophe Dumez 2011-04-02 08:54:28 +00:00
parent ba7ece348c
commit d0afd46fd3
8 changed files with 164 additions and 96 deletions

View file

@ -27,10 +27,11 @@
*
* Contact : chris@qbittorrent.org
*/
#ifdef WITH_LIBNOTIFY
#include <glib.h>
#include <unistd.h>
#include <libnotify/notify.h>
#include <QtGlobal>
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
#include <QDBusConnection>
#include "notifications.h"
#endif
#include <QFileDialog>
@ -1101,21 +1102,16 @@ void MainWindow::updateGUI() {
void MainWindow::showNotificationBaloon(QString title, QString msg) const {
if(!Preferences().useProgramNotification()) return;
#ifdef WITH_LIBNOTIFY
if (notify_init ("summary-body")) {
NotifyNotification* notification;
notification = notify_notification_new (qPrintable(title), qPrintable(msg), "qbittorrent"
#if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7)
, 0
#endif
);
gboolean success = notify_notification_show (notification, NULL);
g_object_unref(G_OBJECT(notification));
notify_uninit ();
if(success) {
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
org::freedesktop::Notifications notifications("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
QDBusConnection::sessionBus());
if(notifications.isValid()) {
QDBusPendingReply<uint> reply = notifications.Notify("qBittorrent", 0, "qbittorrent", title,
msg, QStringList(), QVariantMap(), -1);
reply.waitForFinished();
if(!reply.isError())
return;
}
}
#endif
if(systrayIcon && QSystemTrayIcon::supportsMessages())