mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-22 13:43:11 +02:00
Make growl plugin work, sorta
This commit is contained in:
@@ -373,15 +373,18 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.
|
||||
|
||||
${LIBPORTFWD_INCLUDE_DIR}
|
||||
${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb
|
||||
${THIRDPARTY_DIR}/gntp-send/gntp-send/headers
|
||||
${CMAKE_BINARY_DIR}/thirdparty/liblastfm2/src
|
||||
)
|
||||
|
||||
IF( UNIX AND NOT APPLE )
|
||||
SET( libSources ${libSources}
|
||||
infosystem/infoplugins/win/gfwnotifyplugin.cpp
|
||||
infosystem/infoplugins/unix/fdonotifyplugin.cpp
|
||||
infosystem/infoplugins/unix/imageconverter.cpp )
|
||||
|
||||
SET( libHeaders ${libHeaders}
|
||||
infosystem/infoplugins/win/gfwnotifyplugin.h
|
||||
infosystem/infoplugins/unix/fdonotifyplugin.h
|
||||
infosystem/infoplugins/unix/imageconverter.h )
|
||||
ENDIF( UNIX AND NOT APPLE )
|
||||
@@ -439,6 +442,8 @@ target_link_libraries( tomahawklib
|
||||
# Thirdparty shipped with tomahawk
|
||||
${LIBPORTFWD_LIBRARIES}
|
||||
|
||||
tomahawk_growl
|
||||
|
||||
# External deps
|
||||
${QJSON_LIBRARIES}
|
||||
${PHONON_LIBS}
|
||||
|
@@ -36,31 +36,36 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "fdonotifyplugin.h"
|
||||
#include "gfwnotifyplugin.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "imageconverter.h"
|
||||
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QImage>
|
||||
#include "growl.h"
|
||||
#include "growl++.hpp"
|
||||
|
||||
using namespace Tomahawk::InfoSystem;
|
||||
|
||||
FdoNotifyPlugin::FdoNotifyPlugin()
|
||||
GfwNotifyPlugin::GfwNotifyPlugin()
|
||||
: InfoPlugin()
|
||||
, m_arg()
|
||||
, m_growl( 0 )
|
||||
{
|
||||
const char* notifications[1];
|
||||
const char* name = "Notification";
|
||||
notifications[0] = name;
|
||||
const char* host = "192.168.10.45";
|
||||
const char* password = "testing";
|
||||
const char* application = "Tomahawk";
|
||||
m_growl = new Growl( GROWL_TCP, host, password, application, notifications, 1 );
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
m_supportedPushTypes << Tomahawk::InfoSystem::InfoNotifyUser;
|
||||
}
|
||||
|
||||
FdoNotifyPlugin::~FdoNotifyPlugin()
|
||||
GfwNotifyPlugin::~GfwNotifyPlugin()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
void
|
||||
FdoNotifyPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant pushData )
|
||||
GfwNotifyPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant pushData )
|
||||
{
|
||||
Q_UNUSED( caller );
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
@@ -76,19 +81,8 @@ FdoNotifyPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::Inf
|
||||
return;
|
||||
}
|
||||
|
||||
QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify" );
|
||||
QList<QVariant> arguments;
|
||||
arguments << QString( "Tomahawk" ); //app_name
|
||||
arguments << quint32( 0 ); //notification_id
|
||||
arguments << QString(); //app_icon
|
||||
arguments << QString( "Tomahawk" ); //summary
|
||||
arguments << hash["message"]; //body
|
||||
arguments << QStringList(); //actions
|
||||
QVariantMap dict;
|
||||
dict["desktop-entry"] = QString( "tomahawk" );
|
||||
dict["image_data"] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-128x128.png" ) );
|
||||
arguments << dict; //hints
|
||||
arguments << qint32( -1 ); //expire_timeout
|
||||
message.setArguments( arguments );
|
||||
QDBusConnection::sessionBus().send( message );
|
||||
const char* name = "Notification";
|
||||
const char* title = "Tomahawk";
|
||||
const char* message = strdup( hash["message"].toLocal8Bit().constData() );
|
||||
m_growl->Notify( name, title, message );
|
||||
}
|
||||
|
@@ -16,13 +16,12 @@
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FDONOTIFYPLUGIN_H
|
||||
#define FDONOTIFYPLUGIN_H
|
||||
#ifndef GFWNOTIFYPLUGIN_H
|
||||
#define GFWNOTIFYPLUGIN_H
|
||||
|
||||
#include "infosystem/infosystem.h"
|
||||
#include "infosystem/infosystemworker.h"
|
||||
|
||||
#include <QtDBus/QDBusArgument>
|
||||
class Growl;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
@@ -30,13 +29,13 @@ namespace Tomahawk
|
||||
namespace InfoSystem
|
||||
{
|
||||
|
||||
class FdoNotifyPlugin : public InfoPlugin
|
||||
class GfwNotifyPlugin : public InfoPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FdoNotifyPlugin();
|
||||
virtual ~FdoNotifyPlugin();
|
||||
GfwNotifyPlugin();
|
||||
virtual ~GfwNotifyPlugin();
|
||||
|
||||
virtual void namChangedSlot( QNetworkAccessManager* ) {}
|
||||
|
||||
@@ -61,11 +60,11 @@ protected slots:
|
||||
}
|
||||
|
||||
private:
|
||||
QDBusArgument m_arg;
|
||||
Growl* m_growl;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // FDONOTIFYPLUGIN_H
|
||||
#endif // GFWNOTIFYPLUGIN_H
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#endif
|
||||
#ifdef Q_WS_X11
|
||||
#include "infoplugins/unix/fdonotifyplugin.h"
|
||||
#include "infoplugins/win/gfwnotifyplugin.h"
|
||||
#endif
|
||||
|
||||
#include "lastfm/NetworkAccessManager"
|
||||
@@ -81,6 +82,9 @@ InfoSystemWorker::init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache> cac
|
||||
InfoPluginPtr fdonotifyptr( new FdoNotifyPlugin() );
|
||||
m_plugins.append( fdonotifyptr );
|
||||
registerInfoTypes( fdonotifyptr, fdonotifyptr.data()->supportedGetTypes(), fdonotifyptr.data()->supportedPushTypes() );
|
||||
InfoPluginPtr gfwnotifyptr( new GfwNotifyPlugin() );
|
||||
m_plugins.append( gfwnotifyptr );
|
||||
registerInfoTypes( gfwnotifyptr, gfwnotifyptr.data()->supportedGetTypes(), gfwnotifyptr.data()->supportedPushTypes() );
|
||||
#endif
|
||||
|
||||
Q_FOREACH( InfoPluginPtr plugin, m_plugins )
|
||||
|
Reference in New Issue
Block a user