1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 17:29:42 +01:00

Make now-playing FDO notifications reuse, and fix a logic bug in audioengine that would cause missed notifictions

This commit is contained in:
Jeff Mitchell 2012-04-11 11:32:29 -04:00
parent 28c76e73bd
commit 75d1ab7bbe
2 changed files with 9 additions and 8 deletions

View File

@ -327,8 +327,7 @@ AudioEngine::sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ty
onNowPlayingInfoReady( type );
else
{
_detail::Closure* closure = NewClosure( m_currentTrack->album().data(), SIGNAL( updated() ), const_cast< AudioEngine* >( this ), SLOT( onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType ) ), type );
Q_UNUSED( closure );
NewClosure( m_currentTrack->album().data(), SIGNAL( updated() ), const_cast< AudioEngine* >( this ), SLOT( onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType ) ), type );
m_currentTrack->album()->cover( QSize( 0, 0 ), true );
}
#endif
@ -338,14 +337,11 @@ AudioEngine::sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ty
void
AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << type;
if ( m_currentTrack.isNull() ||
m_currentTrack->track().isNull() ||
m_currentTrack->artist().isNull() )
return;
if ( !m_currentTrack->album().isNull() && sender() && m_currentTrack->album().data() != sender() )
return;
QVariantMap playInfo;
@ -392,6 +388,7 @@ AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
Tomahawk::InfoSystem::InfoPushData pushData ( s_aeInfoIdentifier, type, playInfo, Tomahawk::InfoSystem::PushShortUrlFlag );
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "pushing data with type " << type;
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );
}

View File

@ -49,6 +49,7 @@
using namespace Tomahawk::InfoSystem;
static const int s_nowPlayingNotificationId = 1;
FdoNotifyPlugin::FdoNotifyPlugin()
: InfoPlugin()
@ -119,6 +120,7 @@ FdoNotifyPlugin::notifyUser( const QString &messageText )
void
FdoNotifyPlugin::nowPlaying( const QVariant &input )
{
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
if ( !input.canConvert< QVariantMap >() )
return;
@ -135,11 +137,13 @@ FdoNotifyPlugin::nowPlaying( const QVariant &input )
.arg( hash[ "title" ] )
.arg( hash[ "artist" ] )
.arg( hash[ "album" ].isEmpty() ? QString() : QString( " %1" ).arg( tr( "on \"%1\"" ).arg( hash[ "album" ] ) ) );
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "sending message" << messageText;
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 << quint32( s_nowPlayingNotificationId ); //notification_id
arguments << QString(); //app_icon
arguments << QString( "Tomahawk" ); //summary
arguments << messageText; //body