mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 12:34:19 +00:00
Get rid of libnotify dependency (Use DBus instead)
This commit is contained in:
parent
ba7ece348c
commit
d0afd46fd3
72
configure
vendored
72
configure
vendored
@ -27,7 +27,6 @@ Dependency options:
|
|||||||
files
|
files
|
||||||
--with-libboost-lib=[path] Path to libboost library
|
--with-libboost-lib=[path] Path to libboost library
|
||||||
files
|
files
|
||||||
--disable-libnotify Disable use of libnotify
|
|
||||||
--disable-geoip-database Disable use of geoip-database
|
--disable-geoip-database Disable use of geoip-database
|
||||||
--with-geoip-database-embedded Geoip Database will be
|
--with-geoip-database-embedded Geoip Database will be
|
||||||
embedded in qBittorrent
|
embedded in qBittorrent
|
||||||
@ -178,11 +177,6 @@ while [ $# -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--disable-libnotify)
|
|
||||||
QC_DISABLE_libnotify="Y"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
--disable-geoip-database)
|
--disable-geoip-database)
|
||||||
QC_DISABLE_geoip_database="Y"
|
QC_DISABLE_geoip_database="Y"
|
||||||
shift
|
shift
|
||||||
@ -224,7 +218,6 @@ echo QC_DISABLE_GUI=$QC_DISABLE_GUI
|
|||||||
echo QC_DISABLE_qt_dbus=$QC_DISABLE_qt_dbus
|
echo QC_DISABLE_qt_dbus=$QC_DISABLE_qt_dbus
|
||||||
echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC
|
echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC
|
||||||
echo QC_WITH_LIBBOOST_LIB=$QC_WITH_LIBBOOST_LIB
|
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_DISABLE_geoip_database=$QC_DISABLE_geoip_database
|
||||||
echo QC_WITH_GEOIP_DATABASE_EMBEDDED=$QC_WITH_GEOIP_DATABASE_EMBEDDED
|
echo QC_WITH_GEOIP_DATABASE_EMBEDDED=$QC_WITH_GEOIP_DATABASE_EMBEDDED
|
||||||
echo QC_WITH_QTSINGLEAPPLICATION=$QC_WITH_QTSINGLEAPPLICATION
|
echo QC_WITH_QTSINGLEAPPLICATION=$QC_WITH_QTSINGLEAPPLICATION
|
||||||
@ -552,67 +545,6 @@ public:
|
|||||||
return true;
|
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"
|
#line 1 "geoip-database.qcm"
|
||||||
/*
|
/*
|
||||||
-----BEGIN QCMOD-----
|
-----BEGIN QCMOD-----
|
||||||
@ -696,9 +628,6 @@ cat >$1/modules_new.cpp <<EOT
|
|||||||
o = new qc_libboost(conf);
|
o = new qc_libboost(conf);
|
||||||
o->required = true;
|
o->required = true;
|
||||||
o->disabled = false;
|
o->disabled = false;
|
||||||
o = new qc_libnotify(conf);
|
|
||||||
o->required = false;
|
|
||||||
o->disabled = false;
|
|
||||||
o = new qc_geoip_database(conf);
|
o = new qc_geoip_database(conf);
|
||||||
o->required = false;
|
o->required = false;
|
||||||
o->disabled = false;
|
o->disabled = false;
|
||||||
@ -1655,7 +1584,6 @@ export QC_DISABLE_GUI
|
|||||||
export QC_DISABLE_qt_dbus
|
export QC_DISABLE_qt_dbus
|
||||||
export QC_WITH_LIBBOOST_INC
|
export QC_WITH_LIBBOOST_INC
|
||||||
export QC_WITH_LIBBOOST_LIB
|
export QC_WITH_LIBBOOST_LIB
|
||||||
export QC_DISABLE_libnotify
|
|
||||||
export QC_DISABLE_geoip_database
|
export QC_DISABLE_geoip_database
|
||||||
export QC_WITH_GEOIP_DATABASE_EMBEDDED
|
export QC_WITH_GEOIP_DATABASE_EMBEDDED
|
||||||
export QC_WITH_QTSINGLEAPPLICATION
|
export QC_WITH_QTSINGLEAPPLICATION
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
<dep type='libboost'>
|
<dep type='libboost'>
|
||||||
<required/>
|
<required/>
|
||||||
</dep>
|
</dep>
|
||||||
<dep type='libnotify'>
|
|
||||||
</dep>
|
|
||||||
<dep type='geoip-database'>
|
<dep type='geoip-database'>
|
||||||
</dep>
|
</dep>
|
||||||
<dep type='qtsingleapplication'>
|
<dep type='qtsingleapplication'>
|
||||||
|
@ -27,10 +27,11 @@
|
|||||||
*
|
*
|
||||||
* Contact : chris@qbittorrent.org
|
* Contact : chris@qbittorrent.org
|
||||||
*/
|
*/
|
||||||
#ifdef WITH_LIBNOTIFY
|
|
||||||
#include <glib.h>
|
#include <QtGlobal>
|
||||||
#include <unistd.h>
|
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
||||||
#include <libnotify/notify.h>
|
#include <QDBusConnection>
|
||||||
|
#include "notifications.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@ -1101,21 +1102,16 @@ void MainWindow::updateGUI() {
|
|||||||
|
|
||||||
void MainWindow::showNotificationBaloon(QString title, QString msg) const {
|
void MainWindow::showNotificationBaloon(QString title, QString msg) const {
|
||||||
if(!Preferences().useProgramNotification()) return;
|
if(!Preferences().useProgramNotification()) return;
|
||||||
#ifdef WITH_LIBNOTIFY
|
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
||||||
if (notify_init ("summary-body")) {
|
org::freedesktop::Notifications notifications("org.freedesktop.Notifications",
|
||||||
NotifyNotification* notification;
|
"/org/freedesktop/Notifications",
|
||||||
|
QDBusConnection::sessionBus());
|
||||||
notification = notify_notification_new (qPrintable(title), qPrintable(msg), "qbittorrent"
|
if(notifications.isValid()) {
|
||||||
#if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7)
|
QDBusPendingReply<uint> reply = notifications.Notify("qBittorrent", 0, "qbittorrent", title,
|
||||||
, 0
|
msg, QStringList(), QVariantMap(), -1);
|
||||||
#endif
|
reply.waitForFinished();
|
||||||
);
|
if(!reply.isError())
|
||||||
gboolean success = notify_notification_show (notification, NULL);
|
|
||||||
g_object_unref(G_OBJECT(notification));
|
|
||||||
notify_uninit ();
|
|
||||||
if(success) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(systrayIcon && QSystemTrayIcon::supportsMessages())
|
if(systrayIcon && QSystemTrayIcon::supportsMessages())
|
||||||
|
26
src/qtnotify/notifications.cpp
Normal file
26
src/qtnotify/notifications.cpp
Normal file
@ -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()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
84
src/qtnotify/notifications.h
Normal file
84
src/qtnotify/notifications.h
Normal file
@ -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
|
31
src/qtnotify/notifications.xml
Normal file
31
src/qtnotify/notifications.xml
Normal file
@ -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>
|
||||||
|
|
5
src/qtnotify/qtnotify.pri
Normal file
5
src/qtnotify/qtnotify.pri
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
|
||||||
|
HEADERS += $$PWD/notifications.h
|
||||||
|
|
||||||
|
SOURCES += $$PWD/notifications.cpp
|
@ -10,10 +10,6 @@ QMAKE_LFLAGS_APP += -rdynamic
|
|||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
PKGCONFIG += libtorrent-rasterbar
|
PKGCONFIG += libtorrent-rasterbar
|
||||||
|
|
||||||
libnotify {
|
|
||||||
DEFINES += WITH_LIBNOTIFY
|
|
||||||
}
|
|
||||||
|
|
||||||
# Man page
|
# Man page
|
||||||
nox {
|
nox {
|
||||||
man.files = ../doc/qbittorrent-nox.1
|
man.files = ../doc/qbittorrent-nox.1
|
||||||
@ -73,6 +69,10 @@ INSTALLS += man
|
|||||||
target.path = $$PREFIX/bin/
|
target.path = $$PREFIX/bin/
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
|
||||||
|
dbus {
|
||||||
|
include(src/qtnotify/qtnotify.pri)
|
||||||
|
}
|
||||||
|
|
||||||
!nox {
|
!nox {
|
||||||
# DEFINE added by configure
|
# DEFINE added by configure
|
||||||
contains(DEFINES, WITH_GEOIP_EMBEDDED) {
|
contains(DEFINES, WITH_GEOIP_EMBEDDED) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user