Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Get rid of libnotify dependency (Use DBus instead)

  • Loading branch information...
commit d0afd46fd307f1d086aa2ed71a0766fa19529025 1 parent ba7ece3
@cdumez cdumez authored
View
72 configure
@@ -27,7 +27,6 @@ Dependency options:
files
--with-libboost-lib=[path] Path to libboost library
files
- --disable-libnotify Disable use of libnotify
--disable-geoip-database Disable use of geoip-database
--with-geoip-database-embedded Geoip Database will be
embedded in qBittorrent
@@ -178,11 +177,6 @@ while [ $# -gt 0 ]; do
shift
;;
- --disable-libnotify)
- QC_DISABLE_libnotify="Y"
- shift
- ;;
-
--disable-geoip-database)
QC_DISABLE_geoip_database="Y"
shift
@@ -224,7 +218,6 @@ echo QC_DISABLE_GUI=$QC_DISABLE_GUI
echo QC_DISABLE_qt_dbus=$QC_DISABLE_qt_dbus
echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC
echo QC_WITH_LIBBOOST_LIB=$QC_WITH_LIBBOOST_LIB
-echo QC_DISABLE_libnotify=$QC_DISABLE_libnotify
echo QC_DISABLE_geoip_database=$QC_DISABLE_geoip_database
echo QC_WITH_GEOIP_DATABASE_EMBEDDED=$QC_WITH_GEOIP_DATABASE_EMBEDDED
echo QC_WITH_QTSINGLEAPPLICATION=$QC_WITH_QTSINGLEAPPLICATION
@@ -552,67 +545,6 @@ public:
return true;
}
};
-#line 1 "libnotify.qcm"
-/*
------BEGIN QCMOD-----
-name: libnotify
------END QCMOD-----
-*/
-// see Conf::findPkgConfig
-class qc_libnotify : public ConfObj
-{
-public:
- qc_libnotify(Conf *c) : ConfObj(c) {}
- QString name() const { return "libnotify >= 0.4.2 (optional)"; }
- QString shortname() const { return "libnotify"; }
- QString checkString() const {
- if(!conf->getenv("QC_DISABLE_libnotify").isEmpty() || !conf->getenv("QC_DISABLE_GUI").isEmpty())
- return "";
- return ConfObj::checkString();
- }
- bool exec(){
- if(!conf->getenv("QC_DISABLE_libnotify").isEmpty() || !conf->getenv("QC_DISABLE_GUI").isEmpty()) {
- return false;
- }
- QStringList incs;
- QString req_ver = "0.4.2";
- QString version, libs, other;
- VersionMode mode = VersionMin;
- if(conf->findPkgConfig("libnotify", mode, req_ver, &version, &incs, &libs, &other)) {
- conf->addExtra("CONFIG += libnotify");
- for(int n = 0; n < incs.count(); ++n)
- conf->addIncludePath(incs[n]);
- if(!libs.isEmpty())
- conf->addLib(libs);
- QStringList incs2;
- QString req_ver2 = "2.0";
- QString version2, libs2, other2;
- if(conf->findPkgConfig("glib-2.0", mode, req_ver2, &version2, &incs2, &libs2, &other2)) {
- for(int n = 0; n < incs2.count(); ++n)
- conf->addIncludePath(incs2[n]);
- if(!libs2.isEmpty())
- conf->addLib(libs2);
- } else {
- return false;
- }
- QStringList incs3;
- QString req_ver3 = "2.0";
- QString version3, libs3, other3;
- if(conf->findPkgConfig("gtk+-2.0", mode, req_ver3, &version3, &incs3, &libs3, &other3)) {
- for(int n = 0; n < incs3.count(); ++n)
- conf->addIncludePath(incs3[n]);
- if(!libs3.isEmpty())
- conf->addLib(libs3);
- } else {
- return false;
- }
- } else {
- return false;
- }
-
- return true;
- }
-};
#line 1 "geoip-database.qcm"
/*
-----BEGIN QCMOD-----
@@ -696,9 +628,6 @@ cat >$1/modules_new.cpp <<EOT
o = new qc_libboost(conf);
o->required = true;
o->disabled = false;
- o = new qc_libnotify(conf);
- o->required = false;
- o->disabled = false;
o = new qc_geoip_database(conf);
o->required = false;
o->disabled = false;
@@ -1655,7 +1584,6 @@ export QC_DISABLE_GUI
export QC_DISABLE_qt_dbus
export QC_WITH_LIBBOOST_INC
export QC_WITH_LIBBOOST_LIB
-export QC_DISABLE_libnotify
export QC_DISABLE_geoip_database
export QC_WITH_GEOIP_DATABASE_EMBEDDED
export QC_WITH_QTSINGLEAPPLICATION
View
2  qbittorrent.qc
@@ -17,8 +17,6 @@
<dep type='libboost'>
<required/>
</dep>
- <dep type='libnotify'>
- </dep>
<dep type='geoip-database'>
</dep>
<dep type='qtsingleapplication'>
View
32 src/mainwindow.cpp
@@ -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())
View
26 src/qtnotify/notifications.cpp
@@ -0,0 +1,26 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp -p notifications.h:notifications.cpp notifications.xml
+ *
+ * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "notifications.h"
+
+/*
+ * Implementation of interface class OrgFreedesktopNotificationsInterface
+ */
+
+OrgFreedesktopNotificationsInterface::OrgFreedesktopNotificationsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+OrgFreedesktopNotificationsInterface::~OrgFreedesktopNotificationsInterface()
+{
+}
+
View
84 src/qtnotify/notifications.h
@@ -0,0 +1,84 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp -p notifications.h:notifications.cpp notifications.xml
+ *
+ * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef NOTIFICATIONS_H_1301681398
+#define NOTIFICATIONS_H_1301681398
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * Proxy class for interface org.freedesktop.Notifications
+ */
+class OrgFreedesktopNotificationsInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.freedesktop.Notifications"; }
+
+public:
+ OrgFreedesktopNotificationsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~OrgFreedesktopNotificationsInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<> CloseNotification(uint id)
+ {
+ QList<QVariant> argumentList;
+ argumentList << qVariantFromValue(id);
+ return asyncCallWithArgumentList(QLatin1String("CloseNotification"), argumentList);
+ }
+
+ inline QDBusPendingReply<QStringList> GetCapabilities()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("GetCapabilities"), argumentList);
+ }
+
+ inline QDBusPendingReply<QString, QString, QString, QString> GetServerInformation()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QLatin1String("GetServerInformation"), argumentList);
+ }
+ inline QDBusReply<QString> GetServerInformation(QString &return_vendor, QString &return_version, QString &return_spec_version)
+ {
+ QList<QVariant> argumentList;
+ QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("GetServerInformation"), argumentList);
+ if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 4) {
+ return_vendor = qdbus_cast<QString>(reply.arguments().at(1));
+ return_version = qdbus_cast<QString>(reply.arguments().at(2));
+ return_spec_version = qdbus_cast<QString>(reply.arguments().at(3));
+ }
+ return reply;
+ }
+
+ inline QDBusPendingReply<uint> Notify(const QString &app_name, uint id, const QString &icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout)
+ {
+ QList<QVariant> argumentList;
+ argumentList << qVariantFromValue(app_name) << qVariantFromValue(id) << qVariantFromValue(icon) << qVariantFromValue(summary) << qVariantFromValue(body) << qVariantFromValue(actions) << qVariantFromValue(hints) << qVariantFromValue(timeout);
+ return asyncCallWithArgumentList(QLatin1String("Notify"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+};
+
+namespace org {
+ namespace freedesktop {
+ typedef ::OrgFreedesktopNotificationsInterface Notifications;
+ }
+}
+#endif
View
31 src/qtnotify/notifications.xml
@@ -0,0 +1,31 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.freedesktop.Notifications">
+ <method name="GetServerInformation">
+ <arg name="return_name" type="s" direction="out"/>
+ <arg name="return_vendor" type="s" direction="out"/>
+ <arg name="return_version" type="s" direction="out"/>
+ <arg name="return_spec_version" type="s" direction="out"/>
+ </method>
+ <method name="GetCapabilities">
+ <arg name="return_caps" type="as" direction="out"/>
+ </method>
+ <method name="CloseNotification">
+ <arg name="id" type="u" direction="in"/>
+ </method>
+ <method name="Notify">
+ <arg name="app_name" type="s" direction="in"/>
+ <arg name="id" type="u" direction="in"/>
+ <arg name="icon" type="s" direction="in"/>
+ <arg name="summary" type="s" direction="in"/>
+ <arg name="body" type="s" direction="in"/>
+ <arg name="actions" type="as" direction="in"/>
+ <arg name="hints" type="a{sv}" direction="in"/>
+ <annotation name="com.trolltech.QtDBus.QtTypeName.In6" value="QVariantMap"/>
+ <arg name="timeout" type="i" direction="in"/>
+ <arg name="return_id" type="u" direction="out"/>
+ </method>
+ </interface>
+</node>
+
View
5 src/qtnotify/qtnotify.pri
@@ -0,0 +1,5 @@
+INCLUDEPATH += $$PWD
+
+HEADERS += $$PWD/notifications.h
+
+SOURCES += $$PWD/notifications.cpp
View
8 unixconf.pri
@@ -10,10 +10,6 @@ QMAKE_LFLAGS_APP += -rdynamic
CONFIG += link_pkgconfig
PKGCONFIG += libtorrent-rasterbar
-libnotify {
- DEFINES += WITH_LIBNOTIFY
-}
-
# Man page
nox {
man.files = ../doc/qbittorrent-nox.1
@@ -73,6 +69,10 @@ INSTALLS += man
target.path = $$PREFIX/bin/
INSTALLS += target
+dbus {
+ include(src/qtnotify/qtnotify.pri)
+}
+
!nox {
# DEFINE added by configure
contains(DEFINES, WITH_GEOIP_EMBEDDED) {
Please sign in to comment.
Something went wrong with that request. Please try again.