1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 14:16:32 +02:00

updated snore api

This commit is contained in:
Patrick von Reth
2014-01-13 14:18:02 +01:00
parent d23a9c4fe2
commit 217c52cf32
2 changed files with 8 additions and 13 deletions

View File

@@ -50,7 +50,7 @@ SnoreNotifyPlugin::SnoreNotifyPlugin()
m_supportedPushTypes << InfoNotifyUser << InfoNowPlaying << InfoTrackUnresolved << InfoNowStopped << InfoInboxReceived; m_supportedPushTypes << InfoNotifyUser << InfoNowPlaying << InfoTrackUnresolved << InfoNowStopped << InfoInboxReceived;
m_snore = new Snore::SnoreCore(); m_snore = new Snore::SnoreCore();
m_snore->loadPlugins( Snore::PluginContainer::BACKEND ); m_snore->loadPlugins( Snore::SnorePlugin::BACKEND );
QString backend = qgetenv( "SNORE_BACKEND" ).constData(); QString backend = qgetenv( "SNORE_BACKEND" ).constData();
if( backend.isEmpty() ) if( backend.isEmpty() )
@@ -68,7 +68,7 @@ SnoreNotifyPlugin::SnoreNotifyPlugin()
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << m_snore->primaryNotificationBackend(); tDebug( LOGVERBOSE ) << Q_FUNC_INFO << m_snore->primaryNotificationBackend();
m_application = new Snore::Application( qApp->applicationName(), m_defaultIcon ); m_application = Snore::Application( qApp->applicationName(), m_defaultIcon );
addAlert( InfoNotifyUser, tr( "Notify User" ) ); addAlert( InfoNotifyUser, tr( "Notify User" ) );
addAlert( InfoNowPlaying, tr( "Now Playing" ) ); addAlert( InfoNowPlaying, tr( "Now Playing" ) );
@@ -87,12 +87,7 @@ SnoreNotifyPlugin::~SnoreNotifyPlugin()
tDebug( LOGVERBOSE ) << Q_FUNC_INFO; tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
m_snore->deregisterApplication( m_application ); m_snore->deregisterApplication( m_application );
foreach( Snore::Alert* alert, m_alerts )
{
alert->deleteLater();
}
m_snore->deleteLater(); m_snore->deleteLater();
m_application->deleteLater();
} }
void void
@@ -152,8 +147,8 @@ SnoreNotifyPlugin::notifyUser( Tomahawk::InfoSystem::InfoType type, const QStrin
{ {
icon = m_defaultIcon; icon = m_defaultIcon;
} }
Snore::Alert* alert = m_alerts[ type ]; const Snore::Alert &alert = m_alerts[ type ];
Snore::Notification n( qApp->applicationName(), alert->name(), alert->title(), messageText, icon ); Snore::Notification n( m_application , alert, alert.title(), messageText, icon );
m_snore->broadcastNotification( n ); m_snore->broadcastNotification( n );
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "showing notification:" << messageText; tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "showing notification:" << messageText;
@@ -162,8 +157,8 @@ SnoreNotifyPlugin::notifyUser( Tomahawk::InfoSystem::InfoType type, const QStrin
void void
SnoreNotifyPlugin::addAlert( Tomahawk::InfoSystem::InfoType type, const QString &title ) SnoreNotifyPlugin::addAlert( Tomahawk::InfoSystem::InfoType type, const QString &title )
{ {
Snore::Alert* alert = new Snore::Alert( title, title, m_defaultIcon ); Snore::Alert alert( title, title, m_defaultIcon );
m_application->addAlert( alert ); m_application.addAlert( alert );
m_alerts[ type ] = alert; m_alerts[ type ] = alert;
} }

View File

@@ -66,9 +66,9 @@ private:
void notifyUser( InfoType type, const QString &messageText, Snore::Icon icon = Snore::Icon() ); void notifyUser( InfoType type, const QString &messageText, Snore::Icon icon = Snore::Icon() );
void addAlert( Tomahawk::InfoSystem::InfoType type, const QString &title ); void addAlert( Tomahawk::InfoSystem::InfoType type, const QString &title );
Snore::SnoreCore *m_snore; Snore::SnoreCore *m_snore;
Snore::Application *m_application; Snore::Application m_application;
Snore::Icon m_defaultIcon; Snore::Icon m_defaultIcon;
QHash< Tomahawk::InfoSystem::InfoType, Snore::Alert* > m_alerts; QHash< Tomahawk::InfoSystem::InfoType, Snore::Alert > m_alerts;
void nowPlaying( const QVariant &input ); void nowPlaying( const QVariant &input );
void inboxReceived( const QVariant &input ); void inboxReceived( const QVariant &input );