mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-22 05:33:32 +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}
|
${LIBPORTFWD_INCLUDE_DIR}
|
||||||
${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb
|
${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb
|
||||||
|
${THIRDPARTY_DIR}/gntp-send/gntp-send/headers
|
||||||
${CMAKE_BINARY_DIR}/thirdparty/liblastfm2/src
|
${CMAKE_BINARY_DIR}/thirdparty/liblastfm2/src
|
||||||
)
|
)
|
||||||
|
|
||||||
IF( UNIX AND NOT APPLE )
|
IF( UNIX AND NOT APPLE )
|
||||||
SET( libSources ${libSources}
|
SET( libSources ${libSources}
|
||||||
|
infosystem/infoplugins/win/gfwnotifyplugin.cpp
|
||||||
infosystem/infoplugins/unix/fdonotifyplugin.cpp
|
infosystem/infoplugins/unix/fdonotifyplugin.cpp
|
||||||
infosystem/infoplugins/unix/imageconverter.cpp )
|
infosystem/infoplugins/unix/imageconverter.cpp )
|
||||||
|
|
||||||
SET( libHeaders ${libHeaders}
|
SET( libHeaders ${libHeaders}
|
||||||
|
infosystem/infoplugins/win/gfwnotifyplugin.h
|
||||||
infosystem/infoplugins/unix/fdonotifyplugin.h
|
infosystem/infoplugins/unix/fdonotifyplugin.h
|
||||||
infosystem/infoplugins/unix/imageconverter.h )
|
infosystem/infoplugins/unix/imageconverter.h )
|
||||||
ENDIF( UNIX AND NOT APPLE )
|
ENDIF( UNIX AND NOT APPLE )
|
||||||
@@ -439,6 +442,8 @@ target_link_libraries( tomahawklib
|
|||||||
# Thirdparty shipped with tomahawk
|
# Thirdparty shipped with tomahawk
|
||||||
${LIBPORTFWD_LIBRARIES}
|
${LIBPORTFWD_LIBRARIES}
|
||||||
|
|
||||||
|
tomahawk_growl
|
||||||
|
|
||||||
# External deps
|
# External deps
|
||||||
${QJSON_LIBRARIES}
|
${QJSON_LIBRARIES}
|
||||||
${PHONON_LIBS}
|
${PHONON_LIBS}
|
||||||
|
@@ -36,31 +36,36 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fdonotifyplugin.h"
|
#include "gfwnotifyplugin.h"
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
#include "imageconverter.h"
|
|
||||||
|
|
||||||
#include <QtDBus/QDBusConnection>
|
#include "growl.h"
|
||||||
#include <QtDBus/QDBusMessage>
|
#include "growl++.hpp"
|
||||||
#include <QImage>
|
|
||||||
|
|
||||||
using namespace Tomahawk::InfoSystem;
|
using namespace Tomahawk::InfoSystem;
|
||||||
|
|
||||||
FdoNotifyPlugin::FdoNotifyPlugin()
|
GfwNotifyPlugin::GfwNotifyPlugin()
|
||||||
: InfoPlugin()
|
: 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;
|
qDebug() << Q_FUNC_INFO;
|
||||||
m_supportedPushTypes << Tomahawk::InfoSystem::InfoNotifyUser;
|
m_supportedPushTypes << Tomahawk::InfoSystem::InfoNotifyUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
FdoNotifyPlugin::~FdoNotifyPlugin()
|
GfwNotifyPlugin::~GfwNotifyPlugin()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 );
|
Q_UNUSED( caller );
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
@@ -76,19 +81,8 @@ FdoNotifyPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::Inf
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify" );
|
const char* name = "Notification";
|
||||||
QList<QVariant> arguments;
|
const char* title = "Tomahawk";
|
||||||
arguments << QString( "Tomahawk" ); //app_name
|
const char* message = strdup( hash["message"].toLocal8Bit().constData() );
|
||||||
arguments << quint32( 0 ); //notification_id
|
m_growl->Notify( name, title, message );
|
||||||
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 );
|
|
||||||
}
|
}
|
||||||
|
@@ -16,13 +16,12 @@
|
|||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FDONOTIFYPLUGIN_H
|
#ifndef GFWNOTIFYPLUGIN_H
|
||||||
#define FDONOTIFYPLUGIN_H
|
#define GFWNOTIFYPLUGIN_H
|
||||||
|
|
||||||
#include "infosystem/infosystem.h"
|
#include "infosystem/infosystem.h"
|
||||||
#include "infosystem/infosystemworker.h"
|
|
||||||
|
|
||||||
#include <QtDBus/QDBusArgument>
|
class Growl;
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
@@ -30,13 +29,13 @@ namespace Tomahawk
|
|||||||
namespace InfoSystem
|
namespace InfoSystem
|
||||||
{
|
{
|
||||||
|
|
||||||
class FdoNotifyPlugin : public InfoPlugin
|
class GfwNotifyPlugin : public InfoPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FdoNotifyPlugin();
|
GfwNotifyPlugin();
|
||||||
virtual ~FdoNotifyPlugin();
|
virtual ~GfwNotifyPlugin();
|
||||||
|
|
||||||
virtual void namChangedSlot( QNetworkAccessManager* ) {}
|
virtual void namChangedSlot( QNetworkAccessManager* ) {}
|
||||||
|
|
||||||
@@ -61,11 +60,11 @@ protected slots:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDBusArgument m_arg;
|
Growl* m_growl;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FDONOTIFYPLUGIN_H
|
#endif // GFWNOTIFYPLUGIN_H
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
#include "infoplugins/unix/fdonotifyplugin.h"
|
#include "infoplugins/unix/fdonotifyplugin.h"
|
||||||
|
#include "infoplugins/win/gfwnotifyplugin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "lastfm/NetworkAccessManager"
|
#include "lastfm/NetworkAccessManager"
|
||||||
@@ -81,6 +82,9 @@ InfoSystemWorker::init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache> cac
|
|||||||
InfoPluginPtr fdonotifyptr( new FdoNotifyPlugin() );
|
InfoPluginPtr fdonotifyptr( new FdoNotifyPlugin() );
|
||||||
m_plugins.append( fdonotifyptr );
|
m_plugins.append( fdonotifyptr );
|
||||||
registerInfoTypes( fdonotifyptr, fdonotifyptr.data()->supportedGetTypes(), fdonotifyptr.data()->supportedPushTypes() );
|
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
|
#endif
|
||||||
|
|
||||||
Q_FOREACH( InfoPluginPtr plugin, m_plugins )
|
Q_FOREACH( InfoPluginPtr plugin, m_plugins )
|
||||||
|
Reference in New Issue
Block a user