diff --git a/src/App.cpp b/src/App.cpp --- a/src/App.cpp +++ b/src/App.cpp @@ -29,7 +29,7 @@ #include "configdialog/ConfigDialog.h" #include "configdialog/dialogs/PlaybackConfig.h" #include "core/capabilities/SourceInfoCapability.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/meta/Meta.h" #include "core/meta/support/MetaConstants.h" #include "core/meta/support/MetaUtility.h" @@ -41,6 +41,9 @@ #include "core/support/Debug.h" #include "core/transcoding/TranscodingController.h" #include "core-impl/collections/support/CollectionManager.h" +#ifdef DEBUG_BUILD_TYPE +#include "core-impl/logger/DebugLogger.h" +#endif // DEBUG_BUILD_TYPE #include "core-impl/playlists/types/file/PlaylistFileSupport.h" #include "core-impl/storage/StorageManager.h" #include "covermanager/CoverCache.h" @@ -442,6 +445,10 @@ AmarokConfig::instance( "amarokrc" ); +#ifdef DEBUG_BUILD_TYPE + new DebugLogger( this ); +#endif // DEBUG_BUILD_TYPE + new Amarok::DefaultApplicationController( this ); Amarok::Components::applicationController()->start(); @@ -573,7 +580,7 @@ KIO::Job *App::trashFiles( const QList &files ) { KIO::Job *job = KIO::trash( files ); - Amarok::Components::logger()->newProgressOperation( job, i18n("Moving files to trash") ); + Amarok::Logger::newProgressOperation( job, i18n("Moving files to trash") ); connect( job, &KIO::Job::result, this, &App::slotTrashResult ); return job; } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -612,7 +612,6 @@ ${libsynchronization_SRCS} ${statsyncing_SRCS} ${importers_SRCS} - core-impl/logger/ProxyLogger.cpp aboutdialog/AnimatedBarWidget.cpp aboutdialog/AnimatedWidget.cpp aboutdialog/ExtendedAboutDialog.cpp @@ -638,6 +637,7 @@ SvgHandler.cpp SvgTinter.cpp TrayIcon.cpp + core-impl/logger/DebugLogger.cpp core-impl/meta/timecode/TimecodeObserver.cpp core-impl/meta/timecode/TimecodeMeta.cpp core-impl/meta/timecode/TimecodeTrackProvider.cpp diff --git a/src/EngineController.cpp b/src/EngineController.cpp --- a/src/EngineController.cpp +++ b/src/EngineController.cpp @@ -30,7 +30,7 @@ #include "core/capabilities/MultiPlayableCapability.h" #include "core/capabilities/MultiSourceCapability.h" #include "core/capabilities/SourceInfoCapability.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/meta/Meta.h" #include "core/meta/support/MetaConstants.h" #include "core/meta/support/MetaUtility.h" @@ -1080,7 +1080,7 @@ // reset error count errorCount = 0; - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n( "Too many errors encountered in playlist. Playback stopped." ), Amarok::Logger::Warning ); diff --git a/src/browsers/BrowserDock.cpp b/src/browsers/BrowserDock.cpp --- a/src/browsers/BrowserDock.cpp +++ b/src/browsers/BrowserDock.cpp @@ -17,11 +17,10 @@ #include "BrowserDock.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Amarok.h" #include "core/support/Components.h" #include "core/support/Debug.h" -#include "core-impl/logger/ProxyLogger.h" #include "PaletteHandler.h" #include "widgets/BoxWidget.h" #include "widgets/HorizontalDivider.h" @@ -57,13 +56,6 @@ //TODO: set dynamic height for hidpi displays m_messageArea->setFixedHeight( 36 ); - Amarok::Logger *logger = Amarok::Components::logger(); - ProxyLogger *proxy = dynamic_cast( logger ); - if( proxy ) - proxy->setLogger( m_messageArea ); - else - error() << "Was not able to register BrowserDock as logger"; - ensurePolish(); } diff --git a/src/browsers/BrowserMessageArea.h b/src/browsers/BrowserMessageArea.h --- a/src/browsers/BrowserMessageArea.h +++ b/src/browsers/BrowserMessageArea.h @@ -17,7 +17,7 @@ #ifndef BROWSERMESSAGEAREA_H #define BROWSERMESSAGEAREA_H -#include "core-impl/logger/ProxyLogger.h" +#include "core/logger/Logger.h" #include "statusbar/CompoundProgressBar.h" #include "statusbar/KJobProgressBar.h" #include "statusbar/NetworkProgressBar.h" @@ -36,9 +36,10 @@ { } +protected: /* Amarok::Logger virtual methods */ - virtual void shortMessage( const QString &text ); - virtual void longMessage( const QString &text, MessageType type ); + virtual void shortMessageImpl( const QString &text ) override; + virtual void longMessageImpl( const QString &text, MessageType type ) override; virtual void newProgressOperationImpl( KJob * job, const QString & text, QObject *context, const std::function &function, Qt::ConnectionType type ) override; diff --git a/src/browsers/BrowserMessageArea.cpp b/src/browsers/BrowserMessageArea.cpp --- a/src/browsers/BrowserMessageArea.cpp +++ b/src/browsers/BrowserMessageArea.cpp @@ -50,7 +50,7 @@ } void -BrowserMessageArea::shortMessage( const QString &text ) +BrowserMessageArea::shortMessageImpl( const QString &text ) { if( !m_busy ) { @@ -66,7 +66,7 @@ } void -BrowserMessageArea::longMessage( const QString &text, MessageType type ) +BrowserMessageArea::longMessageImpl( const QString &text, MessageType type ) { // The purpose of this emit is to make the operation thread safe. If this // method is called from a non-GUI thread, the "emit" relays it over the diff --git a/src/core-impl/collections/daap/DaapCollection.cpp b/src/core-impl/collections/daap/DaapCollection.cpp --- a/src/core-impl/collections/daap/DaapCollection.cpp +++ b/src/core-impl/collections/daap/DaapCollection.cpp @@ -21,7 +21,7 @@ #include "DaapCollection.h" #include "amarokconfig.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" #include "DaapMeta.h" @@ -97,7 +97,7 @@ QString host = current.first(); quint16 port = current.last().toUShort(); - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n( "Loading remote collection from host %1", host), Amarok::Logger::Information ); diff --git a/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp b/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp --- a/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp +++ b/src/core-impl/collections/db/sql/SqlCollectionLocation.cpp @@ -24,7 +24,7 @@ #include "MetaTagLib.h" // for getting the uid #include "core/collections/CollectionLocationDelegate.h" #include -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" #include "core/meta/Meta.h" @@ -477,7 +477,7 @@ QString statusBarTxt = operationInProgressText( configuration, sources.count() ); m_transferjob = new TransferJob( this, configuration ); - Amarok::Components::logger()->newProgressOperation( m_transferjob, statusBarTxt, this, + Amarok::Logger::newProgressOperation( m_transferjob, statusBarTxt, this, &SqlCollectionLocation::slotTransferJobAborted ); connect( m_transferjob, &Collections::TransferJob::result, this, &SqlCollectionLocation::slotTransferJobFinished ); @@ -659,7 +659,7 @@ if( track->artist() ) name = QString( "%1 - %2" ).arg( track->artist()->name(), track->prettyName() ); - Amarok::Components::logger()->newProgressOperation( job, i18n( "Removing: %1", name ) ); + Amarok::Logger::newProgressOperation( job, i18n( "Removing: %1", name ) ); m_removejobs.insert( job, track ); return true; } diff --git a/src/core-impl/collections/ipodcollection/IpodCollection.cpp b/src/core-impl/collections/ipodcollection/IpodCollection.cpp --- a/src/core-impl/collections/ipodcollection/IpodCollection.cpp +++ b/src/core-impl/collections/ipodcollection/IpodCollection.cpp @@ -26,7 +26,7 @@ #include "support/IpodTranscodeCapability.h" #include "core/capabilities/ActionsCapability.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" #include "core-impl/collections/support/MemoryCollection.h" @@ -703,7 +703,7 @@ { QString message = i18nc( "%1: iPod collection name", "iTunes database successfully written to %1", prettyName() ); - Amarok::Components::logger()->shortMessage( message ); + Amarok::Logger::shortMessage( message ); } else { @@ -715,7 +715,7 @@ else message = i18nc( "%1: iPod collection name, %2: technical error from libgpod", "Writing iTunes database to %1 failed: %2", prettyName(), gpodError ); - Amarok::Components::logger()->longMessage( message ); + Amarok::Logger::longMessage( message ); } return success; } diff --git a/src/core-impl/collections/ipodcollection/IpodCollectionLocation.cpp b/src/core-impl/collections/ipodcollection/IpodCollectionLocation.cpp --- a/src/core-impl/collections/ipodcollection/IpodCollectionLocation.cpp +++ b/src/core-impl/collections/ipodcollection/IpodCollectionLocation.cpp @@ -17,7 +17,7 @@ #include "IpodCollectionLocation.h" #include "jobs/IpodDeleteTracksJob.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" @@ -72,7 +72,7 @@ IpodCopyTracksJob *job = new IpodCopyTracksJob( sources, m_coll, configuration, isGoingToRemoveSources() ); int trackCount = sources.size(); - Amarok::Components::logger()->newProgressOperation( job, + Amarok::Logger::newProgressOperation( job, operationInProgressText( configuration, trackCount ), trackCount, job, &IpodCopyTracksJob::abort ); diff --git a/src/core-impl/collections/ipodcollection/IpodPlaylistProvider.cpp b/src/core-impl/collections/ipodcollection/IpodPlaylistProvider.cpp --- a/src/core-impl/collections/ipodcollection/IpodPlaylistProvider.cpp +++ b/src/core-impl/collections/ipodcollection/IpodPlaylistProvider.cpp @@ -20,7 +20,7 @@ #include "IpodCollectionLocation.h" #include "IpodPlaylist.h" #include "core/capabilities/ActionsCapability.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" #include "core-impl/collections/support/FileCollectionLocation.h" @@ -319,7 +319,7 @@ "stale iTunes database entries, %2 stale database entries removed, %3 orphaned " "tracks added back to the iTunes database. %4", matched, removed, added, failedText ); - Amarok::Components::logger()->longMessage( text ); + Amarok::Logger::longMessage( text ); } void diff --git a/src/core-impl/collections/ipodcollection/jobs/IpodCopyTracksJob.cpp b/src/core-impl/collections/ipodcollection/jobs/IpodCopyTracksJob.cpp --- a/src/core-impl/collections/ipodcollection/jobs/IpodCopyTracksJob.cpp +++ b/src/core-impl/collections/ipodcollection/jobs/IpodCopyTracksJob.cpp @@ -18,7 +18,7 @@ #include "IpodMeta.h" #include "core/collections/QueryMaker.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" #include "core/transcoding/TranscodingController.h" @@ -229,21 +229,21 @@ if( successCount == sourceSize ) { - Amarok::Components::logger()->shortMessage( transferredText ); + Amarok::Logger::shortMessage( transferredText ); } else if( m_aborted ) { QString text = i18np( "Transfer aborted. Managed to transfer one track.", "Transfer aborted. Managed to transfer %1 tracks.", successCount ); - Amarok::Components::logger()->longMessage( text ); + Amarok::Logger::longMessage( text ); } else if( successCount + duplicateCount == sourceSize ) { QString text = i18ncp( "%2 is the 'Transferred 123 tracks to Some collection.' message", "%2 One track was already there.", "%2 %1 tracks were already there.", duplicateCount, transferredText ); - Amarok::Components::logger()->longMessage( text ); + Amarok::Logger::longMessage( text ); } else { diff --git a/src/core-impl/collections/ipodcollection/jobs/IpodDeleteTracksJob.cpp b/src/core-impl/collections/ipodcollection/jobs/IpodDeleteTracksJob.cpp --- a/src/core-impl/collections/ipodcollection/jobs/IpodDeleteTracksJob.cpp +++ b/src/core-impl/collections/ipodcollection/jobs/IpodDeleteTracksJob.cpp @@ -16,7 +16,7 @@ #include "IpodDeleteTracksJob.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core-impl/collections/ipodcollection/IpodMeta.h" @@ -43,7 +43,7 @@ int trackCount = m_sources.size(); QString operationText = i18np( "Removing one track from iPod", "Removing %1 tracks from iPod", trackCount ); - Amarok::Components::logger()->newProgressOperation( this, operationText, trackCount ); + Amarok::Logger::newProgressOperation( this, operationText, trackCount ); itdb_start_sync( m_coll->m_itdb ); QListIterator it( m_sources ); diff --git a/src/core-impl/collections/ipodcollection/jobs/IpodParseTracksJob.cpp b/src/core-impl/collections/ipodcollection/jobs/IpodParseTracksJob.cpp --- a/src/core-impl/collections/ipodcollection/jobs/IpodParseTracksJob.cpp +++ b/src/core-impl/collections/ipodcollection/jobs/IpodParseTracksJob.cpp @@ -19,7 +19,7 @@ #include "IpodCollection.h" #include "IpodMeta.h" #include "IpodPlaylistProvider.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" #include "core-impl/meta/file/File.h" @@ -55,7 +55,7 @@ guint32 trackNumber = itdb_tracks_number( itdb ); QString operationText = i18nc( "operation when iPod is connected", "Reading iPod tracks" ); - Amarok::Components::logger()->newProgressOperation( this, operationText, trackNumber, + Amarok::Logger::newProgressOperation( this, operationText, trackNumber, this, &IpodParseTracksJob::abort ); Meta::TrackList staleTracks; @@ -148,7 +148,7 @@ "the situation using the %2 collection action. You can also view the tracks " "under the Saved Playlists tab.", m_coll->prettyName(), m_coll->m_consolidateAction->text() ); - Amarok::Components::logger()->longMessage( text ); + Amarok::Logger::longMessage( text ); } } diff --git a/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.cpp b/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.cpp --- a/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.cpp +++ b/src/core-impl/collections/mediadevicecollection/handler/MediaDeviceHandler.cpp @@ -18,7 +18,7 @@ #include "MediaDeviceHandler.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core-impl/collections/mediadevicecollection/MediaDeviceCollection.h" #include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" @@ -437,7 +437,7 @@ // Set up progress bar - Amarok::Components::logger()->newProgressOperation( this, + Amarok::Logger::newProgressOperation( this, i18n( "Transferring Tracks to Device" ), m_tracksToCopy.size() ); // prepare to copy @@ -479,7 +479,7 @@ if ( m_copyFailed ) { - Amarok::Components::logger()->shortMessage( + Amarok::Logger::shortMessage( i18np( "%1 track failed to copy to the device", "%1 tracks failed to copy to the device", m_tracksFailed.size() ) ); } @@ -586,7 +586,7 @@ m_tracksToDelete = tracks; // Set up statusbar for deletion operation - Amarok::Components::logger()->newProgressOperation( this, + Amarok::Logger::newProgressOperation( this, i18np( "Removing Track from Device", "Removing Tracks from Device", tracks.size() ), tracks.size() ); @@ -653,7 +653,7 @@ /* if( m_tracksFailed.size() > 0 ) { - Amarok::Components::logger()->shortMessage( + Amarok::Logger::shortMessage( i18n( "%1 tracks failed to copy to the device", m_tracksFailed.size() ) ); } */ diff --git a/src/core-impl/collections/mtpcollection/handler/MtpHandler.cpp b/src/core-impl/collections/mtpcollection/handler/MtpHandler.cpp --- a/src/core-impl/collections/mtpcollection/handler/MtpHandler.cpp +++ b/src/core-impl/collections/mtpcollection/handler/MtpHandler.cpp @@ -26,7 +26,7 @@ #include "core/support/Debug.h" #include "core-impl/meta/file/File.h" // for KIO file handling -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include #include @@ -91,7 +91,7 @@ LIBMTP_Release_Device( m_device ); /* possible race condition with statusbar destructor, will uncomment when fixed */ - //Amarok::Components::logger()->longMessage( + //Amarok::Logger::longMessage( // i18n( "The MTP device %1 has been disconnected", prettyName() ), StatusBar::Information ); debug() << "Device released"; } @@ -359,7 +359,7 @@ LIBMTP_Release_Device( m_device ); /* possible race condition with statusbar destructor, will uncomment when fixed - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n( "The MTP device %1 has been disconnected", prettyName() ), Amarok::Logger::Information ); */ @@ -600,7 +600,7 @@ if ( status != 0 ) { debug() << "delete object failed"; - Amarok::Components::logger()->longMessage( i18n( "Delete failed" ), + Amarok::Logger::longMessage( i18n( "Delete failed" ), Amarok::Logger::Error ); // return false; diff --git a/src/core-impl/collections/nepomukcollection/NepomukCollectionFactory.cpp b/src/core-impl/collections/nepomukcollection/NepomukCollectionFactory.cpp --- a/src/core-impl/collections/nepomukcollection/NepomukCollectionFactory.cpp +++ b/src/core-impl/collections/nepomukcollection/NepomukCollectionFactory.cpp @@ -19,7 +19,7 @@ #include "NepomukCollection.h" #include "NepomukCollectionFactory.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" @@ -44,7 +44,7 @@ "Check if 'Nepomuk Semantic Desktop' is enabled in System Settings -> Desktop Search. " "Nepomuk Plugin won't be loaded unless Nepomuk is enabled."; - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n( "Couldn't initialize Nepomuk Collection. " "Check if 'Nepomuk Semantic Desktop' is enabled in System Settings -> Desktop Search. " "Nepomuk Plugin won't be loaded unless Nepomuk is enabled." ), diff --git a/src/core-impl/collections/support/CollectionLocationDelegateImpl.cpp b/src/core-impl/collections/support/CollectionLocationDelegateImpl.cpp --- a/src/core-impl/collections/support/CollectionLocationDelegateImpl.cpp +++ b/src/core-impl/collections/support/CollectionLocationDelegateImpl.cpp @@ -18,7 +18,7 @@ #include "CollectionLocationDelegateImpl.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/collections/CollectionLocation.h" #include "core/support/Components.h" #include "transcoding/TranscodingAssistantDialog.h" @@ -84,7 +84,7 @@ CollectionLocationDelegateImpl::notWriteable( CollectionLocation *loc ) const { Q_UNUSED( loc ) - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n( "The collection does not have enough free space available or is not writable." ), Amarok::Logger::Error ); } diff --git a/src/core-impl/collections/support/FileCollectionLocation.cpp b/src/core-impl/collections/support/FileCollectionLocation.cpp --- a/src/core-impl/collections/support/FileCollectionLocation.cpp +++ b/src/core-impl/collections/support/FileCollectionLocation.cpp @@ -18,7 +18,7 @@ #include "FileCollectionLocation.h" #include "core/collections/CollectionLocationDelegate.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" @@ -84,7 +84,7 @@ if( track->artist() ) name = QString( "%1 - %2" ).arg( track->artist()->name(), track->prettyName() ); - Amarok::Components::logger()->newProgressOperation( job, i18n( "Removing: %1", name ) ); + Amarok::Logger::newProgressOperation( job, i18n( "Removing: %1", name ) ); m_removejobs.insert( job, track ); } } diff --git a/src/core-impl/collections/support/TrashCollectionLocation.cpp b/src/core-impl/collections/support/TrashCollectionLocation.cpp --- a/src/core-impl/collections/support/TrashCollectionLocation.cpp +++ b/src/core-impl/collections/support/TrashCollectionLocation.cpp @@ -19,7 +19,7 @@ #include "TrashCollectionLocation.h" #include "core/collections/CollectionLocationDelegate.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" @@ -98,7 +98,7 @@ if( max == 0 && !tracks.isEmpty() ) name += " ..."; } - Amarok::Components::logger()->newProgressOperation( job, i18n( "Moving to trash: %1", name ) ); + Amarok::Logger::newProgressOperation( job, i18n( "Moving to trash: %1", name ) ); } } diff --git a/src/core-impl/collections/umscollection/UmsCollection.cpp b/src/core-impl/collections/umscollection/UmsCollection.cpp --- a/src/core-impl/collections/umscollection/UmsCollection.cpp +++ b/src/core-impl/collections/umscollection/UmsCollection.cpp @@ -22,7 +22,7 @@ #include "ui_UmsConfiguration.h" #include "collectionscanner/Track.h" #include "core/capabilities/ActionsCapability.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/meta/Meta.h" #include "core/support/Components.h" #include "core/support/Debug.h" @@ -288,7 +288,7 @@ "as music folder on the device, but it doesn't exist. Falling back to " "%3 instead", m_mountPoint + '/' + s_settingsFileName, m_musicUrl.toLocalFile(), m_mountPoint ); - Amarok::Components::logger()->longMessage( message, Amarok::Logger::Warning ); + Amarok::Logger::longMessage( message, Amarok::Logger::Warning ); m_musicUrl = QUrl::fromLocalFile(m_mountPoint); } } diff --git a/src/core-impl/collections/umscollection/UmsCollectionLocation.cpp b/src/core-impl/collections/umscollection/UmsCollectionLocation.cpp --- a/src/core-impl/collections/umscollection/UmsCollectionLocation.cpp +++ b/src/core-impl/collections/umscollection/UmsCollectionLocation.cpp @@ -18,7 +18,7 @@ #include "core/support/Components.h" #include "core/support/Debug.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/transcoding/TranscodingController.h" #include "core-impl/meta/file/File.h" #include "transcoding/TranscodingJob.h" @@ -107,7 +107,7 @@ this, &UmsCollectionLocation::slotCopyOperationFinished ); QString loggerText = operationInProgressText( configuration, sources.count(), m_umsCollection->prettyName() ); - Amarok::Components::logger()->newProgressOperation( transferJob, loggerText, transferJob, + Amarok::Logger::newProgressOperation( transferJob, loggerText, transferJob, &UmsTransferJob::slotCancel ); transferJob->start(); } @@ -127,7 +127,7 @@ "Removing %1 tracks from %2", sourceUrls.count(), m_umsCollection->prettyName() ); KIO::DeleteJob *delJob = KIO::del( sourceUrls, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( delJob, loggerText, delJob, &KIO::DeleteJob::kill, Qt::AutoConnection, KIO::Job::Quietly ); + Amarok::Logger::newProgressOperation( delJob, loggerText, delJob, &KIO::DeleteJob::kill, Qt::AutoConnection, KIO::Job::Quietly ); connect( delJob, &KIO::DeleteJob::finished, this, &UmsCollectionLocation::slotRemoveOperationFinished ); } diff --git a/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.cpp b/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.cpp --- a/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.cpp +++ b/src/core-impl/collections/upnpcollection/UpnpBrowseCollection.cpp @@ -18,7 +18,7 @@ #include "UpnpBrowseCollection.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" #include "MemoryQueryMaker.h" @@ -115,7 +115,7 @@ // TODO probably set abort slot // TODO figure out what to do with the total steps - Amarok::Components::logger()->newProgressOperation( this, i18n( "Scanning %1", prettyName() ) ); + Amarok::Logger::newProgressOperation( this, i18n( "Scanning %1", prettyName() ) ); startIncrementalScan( "/" ); @@ -199,7 +199,7 @@ DEBUG_BLOCK if( job->error() ) { - Amarok::Components::logger()->longMessage( i18n("UPnP Error: %1", job->errorString() ), + Amarok::Logger::longMessage( i18n("UPnP Error: %1", job->errorString() ), Amarok::Logger::Error ); return; } diff --git a/src/core-impl/logger/DebugLogger.h b/src/core-impl/logger/DebugLogger.h new file mode 100644 --- /dev/null +++ b/src/core-impl/logger/DebugLogger.h @@ -0,0 +1,45 @@ +/* + * Copyright 2018 Malte Veerman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef DEBUGLOGGER_H +#define DEBUGLOGGER_H + +#include + +#include + + +/** + * This class is for debugging messages send to the logging system. + */ +class DebugLogger : public Amarok::Logger, public QObject +{ +public: + DebugLogger( QObject *parent = nullptr ); + +protected: + virtual void shortMessageImpl( const QString& text ) override; + virtual void longMessageImpl( const QString& text, Amarok::Logger::MessageType type ) override; + virtual void newProgressOperationImpl( QObject* sender, const QMetaMethod& increment, const QMetaMethod& end, const QString& text, int maximum, QObject* context, const std::function& function, Qt::ConnectionType type ) override; + virtual void newProgressOperationImpl( QNetworkReply* reply, const QString& text, QObject* context, const std::function& function, Qt::ConnectionType type ) override; + virtual void newProgressOperationImpl( KJob* job, const QString& text, QObject* context, const std::function& function, Qt::ConnectionType type ) override; +}; + +#endif // DEBUGLOGGER_H diff --git a/src/core-impl/logger/DebugLogger.cpp b/src/core-impl/logger/DebugLogger.cpp new file mode 100644 --- /dev/null +++ b/src/core-impl/logger/DebugLogger.cpp @@ -0,0 +1,81 @@ +/* + * Copyright 2018 Malte Veerman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "DebugLogger.h" + +#include "core/support/Debug.h" + + +DebugLogger::DebugLogger( QObject *parent ) + : QObject( parent ) +{ + DEBUG_BLOCK +} + +void DebugLogger::shortMessageImpl( const QString& text ) +{ + DEBUG_BLOCK + + debug() << "Short message:" << text; +} + +void DebugLogger::longMessageImpl( const QString& text, Amarok::Logger::MessageType type ) +{ + DEBUG_BLOCK + + debug() << "Long message:" << text << type; +} + +void DebugLogger::newProgressOperationImpl( QObject* sender, const QMetaMethod& increment, const QMetaMethod& end, const QString& text, int maximum, QObject* context, const std::function& function, Qt::ConnectionType type ) +{ + Q_UNUSED( increment ) + Q_UNUSED( end ) + + DEBUG_BLOCK + + debug() << "New progress operation with generic QObject:" << sender; + debug() << "Text:" << text; + debug() << "Maximum:" << maximum; + debug() << "Object to call when canceled:" << context; + debug() << "Member function to call when canceled:" << function.target_type().name(); + debug() << "Connection type:" << type; +} + +void DebugLogger::newProgressOperationImpl( QNetworkReply* reply, const QString& text, QObject* context, const std::function& function, Qt::ConnectionType type ) +{ + DEBUG_BLOCK + + debug() << "New progress operation with QNetworkReply:" << reply; + debug() << "Text:" << text; + debug() << "Object to call when canceled:" << context; + debug() << "Member function to call when canceled:" << function.target_type().name(); + debug() << "Connection type:" << type; +} + +void DebugLogger::newProgressOperationImpl( KJob* job, const QString& text, QObject* context, const std::function& function, Qt::ConnectionType type ) +{ + DEBUG_BLOCK + + debug() << "New progress operation with KJob:" << job; + debug() << "Text:" << text; + debug() << "Object to call when canceled:" << context; + debug() << "Member function to call when canceled:" << function.target_type().name(); + debug() << "Connection type:" << type; +} diff --git a/src/core-impl/logger/ProxyLogger.h b/src/core-impl/logger/ProxyLogger.h deleted file mode 100644 --- a/src/core-impl/logger/ProxyLogger.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#ifndef AMAROK_PROXY_LOGGER_H -#define AMAROK_PROXY_LOGGER_H - -#include "core/interfaces/Logger.h" - -#include -#include -#include -#include -#include -#include - -#include - -#include - - -class QNetworkReply; - -typedef QPair LongMessage; - -struct ProgressData -{ - QPointer sender; - QMetaMethod increment; - QMetaMethod end; - QPointer job; - QPointer reply; - QString text; - int maximum; - QPointer cancelObject; - std::function function; - Qt::ConnectionType type; -}; - -/** - * Proxy implementation for the Amarok::Logger interface. - * This class does not notify the user, but forwards the notifications - * to a real logger if available. If no logger is available yet, it stores - * the notifications until another logger becomes available. - * - * This class can be only instantiated from the main thread and must reside in the main - * thread for its lifetime. - */ -class ProxyLogger : public QObject, public Amarok::Logger -{ - Q_OBJECT - Q_PROPERTY( Amarok::Logger* logger - READ logger - WRITE setLogger - DESIGNABLE false ) - -public: - ProxyLogger(); - virtual ~ProxyLogger(); - -public Q_SLOTS: - virtual void shortMessage( const QString &text ); - virtual void longMessage( const QString &text, MessageType type ); - virtual void newProgressOperationImpl( KJob * job, const QString & text, QObject * context, - const std::function &function, Qt::ConnectionType type ) override; - virtual void newProgressOperationImpl( QNetworkReply *reply, const QString &text, QObject *obj, - const std::function &function, - Qt::ConnectionType type ) override; - virtual void newProgressOperationImpl( QObject *sender, const QMetaMethod &increment, const QMetaMethod &end, - const QString &text, int maximum, QObject *obj, - const std::function &function, Qt::ConnectionType type ) override; - - /** - * Set the real logger. - * The proxy logger will forward notifications to this logger. - * @param logger The real logger to use. ProxyLogger does not take ownership of the pointer - */ - void setLogger( Logger *logger ); - Logger* logger() const; - -private Q_SLOTS: - void forwardNotifications(); - void slotStartTimer(); - void slotTotalSteps( int totalSteps ); - -Q_SIGNALS: - // timer can only be started from its thread, use signals & slots to pass thread barrier - void startTimer(); - -private: - Logger *m_logger; //!< stores the real logger - QMutex m_lock; //!< protect members that may be accessed from multiple threads - QTimer *m_timer; //!< internal timer that triggers forwarding of notifications - QQueue m_shortMessageQueue; //!< temporary storage for notifications that have not been forwarded yet - QQueue m_longMessageQueue; //!< temporary storage for notifications that have not been forwarded yet - QQueue m_progressQueue; //!< temporary storage for notifications that have not been forwarded yet -}; - -Q_DECLARE_METATYPE(ProxyLogger *) -#endif diff --git a/src/core-impl/logger/ProxyLogger.cpp b/src/core-impl/logger/ProxyLogger.cpp deleted file mode 100644 --- a/src/core-impl/logger/ProxyLogger.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "ProxyLogger.h" - -#include -#include -#include - -ProxyLogger::ProxyLogger() - : Amarok::Logger() - , m_logger( 0 ) - , m_timer( 0 ) -{ - // ensure that the object livs in the GUI thread - Q_ASSERT( thread() == QCoreApplication::instance()->thread() ); - - m_timer = new QTimer( this ); - connect( m_timer, &QTimer::timeout, this, &ProxyLogger::forwardNotifications ); - m_timer->setSingleShot( true ); - m_timer->setInterval( 0 ); - - connect( this, &ProxyLogger::startTimer, this, &ProxyLogger::slotStartTimer ); -} - -ProxyLogger::~ProxyLogger() -{ - //nothing to do -} - -void -ProxyLogger::setLogger( Amarok::Logger *logger ) -{ - m_logger = logger; - emit startTimer(); -} - -Amarok::Logger * -ProxyLogger::logger() const -{ - return m_logger; -} - -void -ProxyLogger::slotStartTimer() -{ - if( m_logger && !m_timer->isActive() ) - m_timer->start(); -} - -void -ProxyLogger::shortMessage( const QString &text ) -{ - QMutexLocker locker( &m_lock ); - m_shortMessageQueue.enqueue( text ); - emit startTimer(); -} - -void -ProxyLogger::longMessage( const QString &text, MessageType type ) -{ - QMutexLocker locker( &m_lock ); - LongMessage msg; - msg.first = text; - msg.second = type; - m_longMessageQueue.enqueue( msg ); - emit startTimer(); -} - -void ProxyLogger::newProgressOperationImpl( KJob* job, const QString& text, QObject* context, const std::function &function, Qt::ConnectionType type ) -{ - QMutexLocker locker( &m_lock ); - ProgressData data; - data.job = job; - data.text = text; - data.cancelObject = context; - data.function = function; - data.type = type; - m_progressQueue.enqueue( data ); - emit startTimer(); -} - -void -ProxyLogger::newProgressOperationImpl( QNetworkReply *reply, const QString &text, QObject *obj, const std::function &function, Qt::ConnectionType type ) -{ - QMutexLocker locker( &m_lock ); - ProgressData data; - data.reply = reply; - data.text = text; - data.cancelObject = obj; - data.function = function; - data.type = type; - m_progressQueue.enqueue( data ); - emit startTimer(); -} - -void -ProxyLogger::newProgressOperationImpl( QObject *sender, const QMetaMethod &increment, const QMetaMethod &end, const QString &text, - int maximum, QObject *obj, const std::function &function, Qt::ConnectionType type ) -{ - QMutexLocker locker( &m_lock ); - ProgressData data; - data.sender = sender; - data.increment = increment; - data.end = end; - data.text = text; - data.maximum = maximum; - data.cancelObject = obj; - data.function = function; - data.type = type; - m_progressQueue.enqueue( data ); - if( sender->staticMetaObject.indexOfSignal( SIGNAL(totalSteps(int)) ) != -1 ) - connect( sender, SIGNAL(totalSteps(int)), SLOT(slotTotalSteps(int)) ); - emit startTimer(); -} - -void -ProxyLogger::forwardNotifications() -{ - QMutexLocker locker( &m_lock ); - if( !m_logger ) - return; //can't do anything before m_logger is created. - - while( !m_shortMessageQueue.isEmpty() ) - { - m_logger->shortMessage( m_shortMessageQueue.dequeue() ); - } - while( !m_longMessageQueue.isEmpty() ) - { - LongMessage msg = m_longMessageQueue.dequeue(); - m_logger->longMessage( msg.first, msg.second ); - } - while( !m_progressQueue.isEmpty() ) - { - ProgressData d = m_progressQueue.dequeue(); - if( d.job ) - { - m_logger->newProgressOperationImpl( d.job.data(), d.text, d.cancelObject.data(), - d.function, d.type ); - } - else if( d.reply ) - { - m_logger->newProgressOperationImpl( d.reply.data(), d.text, d.cancelObject.data(), - d.function, d.type ); - } - else if( d.sender ) - { - // m_logger handles the signals from now on - disconnect( d.sender.data(), 0, this, 0 ); - m_logger->newProgressOperationImpl( d.sender.data(), d.increment, d.end, d.text, - d.maximum, d.cancelObject.data(), - d.function, d.type ); - } - } -} - -void -ProxyLogger::slotTotalSteps( int totalSteps ) -{ - QObject *operation = sender(); - if( !operation ) - // warning, slotTotalSteps can only be connected to progress operation QObject signal - return; - QMutableListIterator it( m_progressQueue ); - while( it.hasNext() ) - { - ProgressData &data = it.next(); - if( data.sender.data() != operation ) - continue; - data.maximum = totalSteps; - return; - } - // warning, operation not found in m_progressQueue -} - diff --git a/src/core-impl/playlists/types/file/PlaylistFileLoaderJob.cpp b/src/core-impl/playlists/types/file/PlaylistFileLoaderJob.cpp --- a/src/core-impl/playlists/types/file/PlaylistFileLoaderJob.cpp +++ b/src/core-impl/playlists/types/file/PlaylistFileLoaderJob.cpp @@ -17,7 +17,7 @@ #include "core/meta/Meta.h" #include "core/playlists/PlaylistFormat.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Amarok.h" #include "core/support/Components.h" #include "core/support/Debug.h" @@ -54,15 +54,15 @@ // m_tempFile.setFileTemplate( QDir::tempPath() + "/XXXXXX." + Amarok::extension( url.url() ) ); if( !m_tempFile.open() ) { - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n( "Could not create a temporary file to download playlist." ) ); m_downloadSemaphore.release(); // prevent deadlock return; } KIO::FileCopyJob *job = KIO::file_copy( url , QUrl::fromLocalFile(m_tempFile.fileName()), 0774, KIO::Overwrite | KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( job, + Amarok::Logger::newProgressOperation( job, i18n("Downloading remote playlist" ) ); if( playlist->isLoadingAsync() ) // job is started automatically by KIO @@ -88,9 +88,8 @@ QFile file( m_actualPlaylistFile ); if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) { - using namespace Amarok; - Components::logger()->longMessage( i18nc( "%1 is file path", - "Cannot read playlist from %1", m_actualPlaylistFile ), Logger::Error ); + Amarok::Logger::longMessage( i18nc( "%1 is file path", + "Cannot read playlist from %1", m_actualPlaylistFile ), Amarok::Logger::Error ); return; } diff --git a/src/core-impl/playlists/types/file/PlaylistFileSupport.cpp b/src/core-impl/playlists/types/file/PlaylistFileSupport.cpp --- a/src/core-impl/playlists/types/file/PlaylistFileSupport.cpp +++ b/src/core-impl/playlists/types/file/PlaylistFileSupport.cpp @@ -17,7 +17,7 @@ ****************************************************************************************/ #include "core/playlists/PlaylistFormat.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Amarok.h" #include "core-impl/playlists/types/file/PlaylistFileSupport.h" diff --git a/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp b/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp --- a/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp +++ b/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp @@ -25,7 +25,7 @@ // #include "context/popupdropper/libpud/PopupDropper.h" // #include "context/popupdropper/libpud/PopupDropperItem.h" #include -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/podcasts/PodcastImageFetcher.h" #include "core/podcasts/PodcastReader.h" #include "core/support/Amarok.h" @@ -474,7 +474,7 @@ { //Already subscribed to this Channel //notify the user. - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n( "Already subscribed to %1.", dbResult.first() ), Amarok::Logger::Error ); } else @@ -1050,7 +1050,7 @@ if( podcastReader->error() != QXmlStreamReader::NoError ) { debug() << podcastReader->errorString(); - Amarok::Components::logger()->longMessage( podcastReader->errorString(), + Amarok::Logger::longMessage( podcastReader->errorString(), Amarok::Logger::Error ); } debug() << "Finished updating: " << podcastReader->url(); @@ -1097,7 +1097,7 @@ const QString &description, Podcasts::PodcastReader* reader ) { - Amarok::Components::logger()->newProgressOperation( job, description, reader, &Podcasts::PodcastReader::slotAbort ); + Amarok::Logger::newProgressOperation( job, description, reader, &Podcasts::PodcastReader::slotAbort ); } void @@ -1154,15 +1154,15 @@ if( !tmpFile->open( QIODevice::WriteOnly | QIODevice::Append ) ) { - Amarok::Components::logger()->longMessage( i18n( "Unable to save podcast episode file to %1", + Amarok::Logger::longMessage( i18n( "Unable to save podcast episode file to %1", tmpFile->fileName() ) ); delete tmpFile; return; } debug() << "starting download for " << sqlEpisode->title() << " url: " << sqlEpisode->prettyUrl(); - Amarok::Components::logger()->newProgressOperation( transferJob + Amarok::Logger::newProgressOperation( transferJob , sqlEpisode->title().isEmpty() ? i18n( "Downloading Podcast Media" ) : i18n( "Downloading Podcast \"%1\"" @@ -1310,7 +1310,7 @@ void SqlPodcastProvider::slotStatusBarSorryMessage( const QString &message ) { - Amarok::Components::logger()->longMessage( message, Amarok::Logger::Error ); + Amarok::Logger::longMessage( message, Amarok::Logger::Error ); } void @@ -1326,7 +1326,7 @@ // in the statusbar when the user cancels a download if( job->error() != KJob::KilledJobError ) { - Amarok::Components::logger()->longMessage( job->errorText() ); + Amarok::Logger::longMessage( job->errorText() ); } error() << "Unable to retrieve podcast media. KIO Error: " << job->errorText(); error() << "keeping temporary file for download restart"; @@ -1402,7 +1402,7 @@ } else { - Amarok::Components::logger()->longMessage( i18n( "Unable to save podcast episode file to %1", + Amarok::Logger::longMessage( i18n( "Unable to save podcast episode file to %1", finalName ) ); downloadFailed = true; } diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,5 +1,4 @@ set(libcore_interfaces_SRCS - interfaces/Logger.cpp interfaces/MetaCapability.cpp ) @@ -80,6 +79,10 @@ transcoding/TranscodingProperty.cpp ) +set(libcore_logger_SRCS + logger/Logger.cpp +) + ##################################################################### # LIBCORE ##################################################################### @@ -93,6 +96,7 @@ ${libcore_capabilities_SRCS} ${libcore_support_SRCS} ${libcore_transcoding_SRCS} + ${libcore_logger_SRCS} ) add_library(amarokcore SHARED ${libcore_LIB_SRCS}) diff --git a/src/core/interfaces/Logger.cpp b/src/core/interfaces/Logger.cpp deleted file mode 100644 --- a/src/core/interfaces/Logger.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/**************************************************************************************** - * Copyright (c) 2010 Maximilian Kossick * - * * - * This program is free software; you can redistribute it and/or modify it under * - * the terms of the GNU General Public License as published by the Free Software * - * Foundation; either version 2 of the License, or (at your option) any later * - * version. * - * * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY * - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * - * PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License along with * - * this program. If not, see . * - ****************************************************************************************/ - -#include "Logger.h" diff --git a/src/core/interfaces/Logger.h b/src/core/logger/Logger.h rename from src/core/interfaces/Logger.h rename to src/core/logger/Logger.h --- a/src/core/interfaces/Logger.h +++ b/src/core/logger/Logger.h @@ -20,31 +20,34 @@ #include "core/amarokcore_export.h" #include +#include #include #include class KJob; class QNetworkReply; +struct ShortMessage; +struct LongMessage; +struct ProgressData; namespace Amarok { /** - * This interface provides methods that allow backend components to notify the user. + * This class provides methods that allow backend components to notify the user. * Users of this class may not make assumptions about the kind of notifications that * will be sent to the user. * * The class name is up for discussion btw. */ class AMAROK_CORE_EXPORT Logger { public: - enum MessageType { Information, Warning, Error }; - Logger() {} - virtual ~Logger() {} + Logger(); + virtual ~Logger(); /** * Informs the user about the progress of a job, i.e. a download job. @@ -58,10 +61,13 @@ * @param type The Qt connection type to use for the connection to the receiving slot. Defaults to Qt::AutoConnection */ template - void newProgressOperation( KJob *job, const QString &text, Object *obj = nullptr, Func slot = nullptr, Qt::ConnectionType type = Qt::AutoConnection ) + static void newProgressOperation( KJob *job, const QString &text, Object *obj = nullptr, Func slot = nullptr, Qt::ConnectionType type = Qt::AutoConnection ) { + if( !job ) + return; + std::function function = std::bind( slot, obj ); - newProgressOperationImpl( job, text, obj, obj ? function : nullptr, type ); + addProgressOperation( job, nullptr, nullptr, QMetaMethod(), QMetaMethod(), text, 100, obj, obj ? function : nullptr, type ); } /** @@ -77,10 +83,13 @@ * @param args Arguments given to the slot. */ template - void newProgressOperation( KJob *job, const QString &text, Object *obj, Func slot, Qt::ConnectionType type, FuncArgs... args ) + static void newProgressOperation( KJob *job, const QString &text, Object *obj, Func slot, Qt::ConnectionType type, FuncArgs... args ) { + if( !job ) + return; + std::function function = std::bind( slot, obj, args... ); - newProgressOperationImpl( job, text, obj, obj ? function : nullptr, type ); + addProgressOperation( job, nullptr, nullptr, QMetaMethod(), QMetaMethod(), text, 100, obj, obj ? function : nullptr, type ); } /** @@ -95,10 +104,13 @@ * @param type The Qt connection type to use for the connection to the receiving slot. Defaults to Qt::AutoConnection */ template - void newProgressOperation( QNetworkReply *reply, const QString &text, Object *obj = nullptr, Func slot = nullptr, Qt::ConnectionType type = Qt::AutoConnection ) + static void newProgressOperation( QNetworkReply *reply, const QString &text, Object *obj = nullptr, Func slot = nullptr, Qt::ConnectionType type = Qt::AutoConnection ) { + if( !reply ) + return; + std::function function = std::bind( slot, obj ); - newProgressOperationImpl( reply, text, obj, obj ? function : nullptr, type ); + addProgressOperation( nullptr, reply, nullptr, QMetaMethod(), QMetaMethod(), text, 100, obj, obj ? function : nullptr, type ); } /** @@ -114,10 +126,13 @@ * @param args Arguments given to the slot. */ template - void newProgressOperation( QNetworkReply *reply, const QString &text, Object *obj, Func slot, Qt::ConnectionType type, FuncArgs... args ) + static void newProgressOperation( QNetworkReply *reply, const QString &text, Object *obj, Func slot, Qt::ConnectionType type, FuncArgs... args ) { + if( !reply ) + return; + std::function function = std::bind( slot, obj, args... ); - newProgressOperationImpl( reply, text, obj, obj ? function : nullptr, type ); + addProgressOperation( nullptr, reply, nullptr, QMetaMethod(), QMetaMethod(), text, 100, obj, obj ? function : nullptr, type ); } /** @@ -137,14 +152,16 @@ * Defaults to Qt::AutoConnection */ template - typename std::enable_if::value && !std::is_convertible::value && std::is_convertible::value>::type + static typename std::enable_if::value && !std::is_convertible::value && std::is_convertible::value>::type newProgressOperation( Sender *sender, const QString &text, int maximum = 100, Object *obj = nullptr, Func slot = nullptr, Qt::ConnectionType type = Qt::AutoConnection) { + if( !sender ) + return; + auto increment = QMetaMethod::fromSignal( &Sender::incrementProgress ); auto end = QMetaMethod::fromSignal( &Sender::endProgressOperation ); - std::function function = std::bind( slot, obj ); - newProgressOperationImpl( sender, increment, end, text, maximum, obj, obj ? function : nullptr, type ); + addProgressOperation( nullptr, nullptr, sender, increment, end, text, maximum, obj, obj ? function : nullptr, type ); } /** @@ -163,35 +180,53 @@ * @param args Arguments given to the slot. */ template - typename std::enable_if::value && !std::is_convertible::value && std::is_convertible::value>::type + static typename std::enable_if::value && !std::is_convertible::value && std::is_convertible::value>::type newProgressOperation( Sender *sender, const QString &text, int maximum, Object *obj, Func slot, Qt::ConnectionType type, FuncArgs... args ) { + if( !sender ) + return; + auto increment = QMetaMethod::fromSignal( &Sender::incrementProgress ); auto end = QMetaMethod::fromSignal( &Sender::endProgressOperation ); std::function function = std::bind( slot, obj, args... ); - newProgressOperationImpl( sender, increment, end, text, maximum, obj, obj ? function : nullptr, type ); + addProgressOperation( nullptr, nullptr, sender, increment, end, text, maximum, obj, obj ? function : nullptr, type ); } /** * Sends a notification to the user. * This method will send a notification containing the given text to the user. * * @param text The text that the notification will contain */ - virtual void shortMessage( const QString &text ) = 0; + static void shortMessage( const QString &text ); /** * Send a notification to the user with an additional context. * A notification will be send to the user containing the given text. Additionally, it will convey the context given by @p type. * @param text The text that the notification will contain * @param type The context of the notification */ - virtual void longMessage( const QString &text, MessageType type = Information ) = 0; + static void longMessage( const QString &text, MessageType type = Information ); + protected: virtual void newProgressOperationImpl( KJob *job, const QString &text, QObject *context, const std::function &function, Qt::ConnectionType type ) = 0; virtual void newProgressOperationImpl( QNetworkReply *reply, const QString &text, QObject *context, const std::function &function, Qt::ConnectionType type ) = 0; virtual void newProgressOperationImpl( QObject *sender, const QMetaMethod &increment, const QMetaMethod &end, const QString &text, int maximum, QObject *context, const std::function &function, Qt::ConnectionType type ) = 0; + virtual void longMessageImpl( const QString &text, MessageType type = Information ) = 0; + virtual void shortMessageImpl( const QString &text ) = 0; + + private: + static void addProgressOperation( KJob *job = nullptr, QNetworkReply *reply = nullptr, QObject *sender = nullptr, const QMetaMethod &increment = QMetaMethod(), + const QMetaMethod &end = QMetaMethod(), const QString &text = QString(), int maximum = 100, QObject *context = nullptr, + const std::function &function = nullptr, Qt::ConnectionType type = Qt::AutoConnection ); + void loadExistingMessages(); + + static QMutex s_mutex; + static QList s_loggers; + static QList s_shortMessageList; + static QList s_longMessageList; + static QList s_progressList; }; } diff --git a/src/core/logger/Logger.cpp b/src/core/logger/Logger.cpp new file mode 100644 --- /dev/null +++ b/src/core/logger/Logger.cpp @@ -0,0 +1,186 @@ +/**************************************************************************************** + * Copyright (c) 2010 Maximilian Kossick * + * * + * This program is free software; you can redistribute it and/or modify it under * + * the terms of the GNU General Public License as published by the Free Software * + * Foundation; either version 2 of the License, or (at your option) any later * + * version. * + * * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY * + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * + * PARTICULAR PURPOSE. See the GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License along with * + * this program. If not, see . * + ****************************************************************************************/ + +#include "Logger.h" + +#include +#include +#include + +#include + + +// Durations for which messages are being saved. +#define SHORT_MESSAGE_DURATION 10000 +#define LONG_MESSAGE_DURATION 10000 + +struct LongMessage +{ + QString text; + Amarok::Logger::MessageType type; +}; + +struct ProgressData +{ + QPointer sender; + QMetaMethod increment; + QMetaMethod end; + QPointer job; + QPointer reply; + QString text; + int maximum; + QPointer cancelObject; + std::function function; + Qt::ConnectionType type; + + bool operator==( const ProgressData &other ) + { + return sender == other.sender && + job == other.job && + reply == other.reply && + increment == other.increment && + end == other.end && + text == other.text && + maximum == other.maximum && + cancelObject == other.cancelObject && + function.target_type() == other.function.target_type() && + type == other.type; + } +}; + +QMutex Amarok::Logger::s_mutex; +QList Amarok::Logger::s_loggers; +QList Amarok::Logger::s_shortMessageList; +QList Amarok::Logger::s_longMessageList; +QList Amarok::Logger::s_progressList; + +Amarok::Logger::Logger() +{ + QMutexLocker locker( &s_mutex ); + s_loggers << this; + + QTimer::singleShot( 0, [this] () { this->loadExistingMessages(); } ); +} + +Amarok::Logger::~Logger() +{ + QMutexLocker locker( &s_mutex ); + s_loggers.removeAll( this ); +} + +void Amarok::Logger::addProgressOperation( KJob* job, QNetworkReply* reply, QObject* sender, const QMetaMethod& increment, const QMetaMethod& end, + const QString& text, int maximum, QObject* context, const std::function& function, Qt::ConnectionType type ) +{ + ProgressData data; + data.sender = sender; + data.job = job; + data.reply = reply; + data.increment = increment; + data.end = end; + data.text = text; + data.maximum = maximum; + data.cancelObject = context; + data.function = function; + data.type = type; + + QMutexLocker locker( &s_mutex ); + s_progressList << data; + + auto removeFunction = [data] () { + QMutexLocker locker( &s_mutex ); + s_progressList.removeAll( data ); + }; + + if( job ) + { + QObject::connect( job, &QObject::destroyed, removeFunction ); + for( const auto &logger : s_loggers ) + logger->newProgressOperationImpl( job, text, context, function, type ); + } + else if( reply ) + { + QObject::connect( reply, &QObject::destroyed, removeFunction ); + for( const auto &logger : s_loggers ) + logger->newProgressOperationImpl( reply, text, context, function, type ); + } + else if( sender ) + { + QObject::connect( sender, &QObject::destroyed, removeFunction ); + for( const auto &logger : s_loggers ) + logger->newProgressOperationImpl( sender, increment, end, text, maximum, context, function, type ); + } +} + +void Amarok::Logger::shortMessage( const QString& text ) +{ + if( text.isEmpty() ) + return; + + QMutexLocker locker( &s_mutex ); + s_shortMessageList << text; + + for( const auto &logger : s_loggers ) + logger->shortMessageImpl( text ); + + auto removeFunction = [text] () { + QMutexLocker locker( &s_mutex ); + s_shortMessageList.removeAll( text ); + }; + + QTimer::singleShot( SHORT_MESSAGE_DURATION, removeFunction ); +} + +void Amarok::Logger::longMessage( const QString& text, Amarok::Logger::MessageType type ) +{ + if( text.isEmpty() ) + return; + + LongMessage message; + message.text = text; + message.type = type; + QMutexLocker locker( &s_mutex ); + s_longMessageList << message; + + for( const auto &logger : s_loggers ) + logger->longMessageImpl( text, type ); + + auto removeFunction = [text] () { + QMutexLocker locker( &s_mutex ); + s_shortMessageList.removeAll( text ); + }; + + QTimer::singleShot( LONG_MESSAGE_DURATION, removeFunction ); +} + +void Amarok::Logger::loadExistingMessages() +{ + QMutexLocker locker( &s_mutex ); + for( const auto &data : s_progressList ) + { + if( data.job ) + newProgressOperationImpl( data.job, data.text, data.cancelObject, data.function, data.type ); + else if( data.reply ) + newProgressOperationImpl( data.reply, data.text, data.cancelObject, data.function, data.type ); + else if( data.sender ) + newProgressOperationImpl( data.sender, data.increment, data.end, data.text, data.maximum, data.cancelObject, data.function, data.type ); + } + + for( const auto &data : s_shortMessageList ) + shortMessageImpl( data ); + + for( const auto &data : s_longMessageList ) + longMessageImpl( data.text, data.type ); +} diff --git a/src/core/support/Components.h b/src/core/support/Components.h --- a/src/core/support/Components.h +++ b/src/core/support/Components.h @@ -22,7 +22,6 @@ namespace Amarok { class ApplicationController; - class Logger; } namespace Collections @@ -57,9 +56,6 @@ AMAROK_CORE_EXPORT SqlStorage *sqlStorage(); AMAROK_CORE_EXPORT SqlStorage *setSqlStorage( SqlStorage *storage ); - AMAROK_CORE_EXPORT Amarok::Logger *logger(); - AMAROK_CORE_EXPORT Amarok::Logger *setLogger( Amarok::Logger *logger ); - AMAROK_CORE_EXPORT Amarok::ApplicationController *applicationController(); AMAROK_CORE_EXPORT Amarok::ApplicationController *setApplicationController( Amarok::ApplicationController *controller ); diff --git a/src/core/support/Components.cpp b/src/core/support/Components.cpp --- a/src/core/support/Components.cpp +++ b/src/core/support/Components.cpp @@ -24,7 +24,6 @@ : collectionManager( 0 ) , engineController( 0 ) , sqlStorage( 0 ) - , logger( 0 ) , applicationController( 0 ) , collectionLocationDelegate( 0 ) , transcodingController( 0 ) @@ -34,7 +33,6 @@ CollectionManager *collectionManager; EngineController *engineController; SqlStorage *sqlStorage; - Amarok::Logger *logger; Amarok::ApplicationController *applicationController; Collections::CollectionLocationDelegate *collectionLocationDelegate; Transcoding::Controller *transcodingController; @@ -67,8 +65,6 @@ COMPONENT_ACCESSORS( SqlStorage*, sqlStorage, setSqlStorage ) -COMPONENT_ACCESSORS( Amarok::Logger*, logger, setLogger ) - COMPONENT_ACCESSORS( Amarok::ApplicationController*, applicationController, setApplicationController ) COMPONENT_ACCESSORS( Collections::CollectionLocationDelegate*, collectionLocationDelegate, setCollectionLocationDelegate ) diff --git a/src/covermanager/CoverFetcher.cpp b/src/covermanager/CoverFetcher.cpp --- a/src/covermanager/CoverFetcher.cpp +++ b/src/covermanager/CoverFetcher.cpp @@ -23,7 +23,7 @@ #include "CoverFetcher.h" #include "amarokconfig.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/meta/Meta.h" #include "core/support/Amarok.h" #include "core/support/Components.h" @@ -172,7 +172,7 @@ if( payload->type() == CoverFetchPayload::Art ) { if( unit->isInteractive() ) - Amarok::Components::logger()->newProgressOperation( reply, i18n( "Fetching Cover" ) ); + Amarok::Logger::newProgressOperation( reply, i18n( "Fetching Cover" ) ); else return; // only one is needed when the fetch is non-interactive } @@ -335,7 +335,7 @@ // If the unit is an interactive one we have to incidate that we're // still fetching the cover. if( unit->isInteractive() ) - Amarok::Components::logger()->newProgressOperation( newReply, i18n( "Fetching Cover" ) ); + Amarok::Logger::newProgressOperation( newReply, i18n( "Fetching Cover" ) ); } } @@ -407,8 +407,7 @@ if( !albumName.isEmpty() ) { const QString text = i18n( "Retrieved cover successfully for '%1'.", albumName ); - if( Amarok::Components::logger() ) - Amarok::Components::logger()->shortMessage( text ); + Amarok::Logger::shortMessage( text ); debug() << "Finished successfully for album" << albumName; } album->setImage( m_selectedImages.take( unit ) ); @@ -419,7 +418,7 @@ if( !albumName.isEmpty() ) { const QString text = i18n( "Fetching cover for '%1' failed.", albumName ); - Amarok::Components::logger()->shortMessage( text ); + Amarok::Logger::shortMessage( text ); QString debugMessage; if( !message.isEmpty() ) debugMessage = '[' + message + ']'; @@ -432,7 +431,7 @@ if( !albumName.isEmpty() ) { const QString text = i18n( "Canceled fetching cover for '%1'.", albumName ); - Amarok::Components::logger()->shortMessage( text ); + Amarok::Logger::shortMessage( text ); debug() << "Finished, cancelled by user for album" << albumName; } break; @@ -442,7 +441,7 @@ { const QString text = i18n( "Unable to find a cover for '%1'.", albumName ); //FIXME: Not visible behind cover manager - Amarok::Components::logger()->shortMessage( text ); + Amarok::Logger::shortMessage( text ); m_errors += text; debug() << "Finished due to cover not found for album" << albumName; } diff --git a/src/dialogs/TagDialog.cpp b/src/dialogs/TagDialog.cpp --- a/src/dialogs/TagDialog.cpp +++ b/src/dialogs/TagDialog.cpp @@ -28,7 +28,7 @@ #include "MainWindow.h" #include "SvgHandler.h" #include "core/collections/QueryMaker.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/meta/Statistics.h" #include "core/meta/TrackEditor.h" #include "core/meta/support/MetaUtility.h" diff --git a/src/dynamic/BiasedPlaylist.cpp b/src/dynamic/BiasedPlaylist.cpp --- a/src/dynamic/BiasedPlaylist.cpp +++ b/src/dynamic/BiasedPlaylist.cpp @@ -24,7 +24,7 @@ #include "App.h" #include "amarokconfig.h" #include "core/collections/Collection.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/meta/Meta.h" #include "core/support/Components.h" #include "core/support/Debug.h" @@ -120,7 +120,7 @@ m_solver = new BiasSolver( numRequested, m_bias, getContext() ); connect( m_solver, &BiasSolver::done, this, &BiasedPlaylist::solverFinished ); - Amarok::Components::logger()->newProgressOperation( m_solver, + Amarok::Logger::newProgressOperation( m_solver, i18n( "Generating playlist..." ), 100, this, &BiasedPlaylist::requestAbort ); diff --git a/src/playlist/PlaylistActions.cpp b/src/playlist/PlaylistActions.cpp --- a/src/playlist/PlaylistActions.cpp +++ b/src/playlist/PlaylistActions.cpp @@ -30,7 +30,7 @@ #include "core/support/Amarok.h" #include "core/support/Components.h" #include "core/support/Debug.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core-impl/collections/support/CollectionManager.h" #include "core-impl/playlists/types/file/PlaylistFileSupport.h" #include "dynamic/DynamicModel.h" diff --git a/src/playlist/PlaylistRestorer.cpp b/src/playlist/PlaylistRestorer.cpp --- a/src/playlist/PlaylistRestorer.cpp +++ b/src/playlist/PlaylistRestorer.cpp @@ -17,7 +17,7 @@ #include "PlaylistRestorer.h" #include "amarokconfig.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core-impl/collections/support/CollectionManager.h" #include "core-impl/playlists/types/file/PlaylistFileSupport.h" #include "playlist/PlaylistActions.h" diff --git a/src/playlist/layouts/LayoutManager.cpp b/src/playlist/layouts/LayoutManager.cpp --- a/src/playlist/layouts/LayoutManager.cpp +++ b/src/playlist/layouts/LayoutManager.cpp @@ -21,7 +21,7 @@ #include "core/support/Amarok.h" #include "core/support/Components.h" #include "core/support/Debug.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "playlist/PlaylistDefines.h" #include "playlist/PlaylistModelStack.h" @@ -116,7 +116,7 @@ } - Amarok::Components::logger()->longMessage( i18n( "Current layout '%1' is read only. " \ + Amarok::Logger::longMessage( i18n( "Current layout '%1' is read only. " \ "Creating a new layout '%2' with your changes and setting this as active", m_activeLayout, newLayoutName ) ); diff --git a/src/playlistgenerator/ConstraintSolver.cpp b/src/playlistgenerator/ConstraintSolver.cpp --- a/src/playlistgenerator/ConstraintSolver.cpp +++ b/src/playlistgenerator/ConstraintSolver.cpp @@ -25,7 +25,7 @@ #include "core/meta/Meta.h" #include "core/support/Debug.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core-impl/collections/support/CollectionManager.h" #include "playlist/PlaylistModel.h" @@ -227,12 +227,12 @@ if (( m_domain.size() > 0 ) || m_domainReductionFailed ) { if ( m_domain.size() <= 0 ) { - Amarok::Components::logger()->shortMessage( i18n("The playlist generator failed to load any tracks from the collection.") ); + Amarok::Logger::shortMessage( i18n("The playlist generator failed to load any tracks from the collection.") ); } m_readyToRun = true; emit readyToRun(); } else { - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n("There are no tracks that match all constraints. " \ "The playlist generator will find the tracks that match best, " \ "but you may want to consider loosening the constraints to find more tracks.") ); diff --git a/src/playlistgenerator/Preset.cpp b/src/playlistgenerator/Preset.cpp --- a/src/playlistgenerator/Preset.cpp +++ b/src/playlistgenerator/Preset.cpp @@ -23,7 +23,7 @@ #include "ConstraintSolver.h" #include "constraints/TrackSpreader.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/meta/Meta.h" #include "core/support/Components.h" #include "core/support/Debug.h" @@ -129,7 +129,7 @@ emit lock( true ); ConstraintSolver* s = static_cast( sender() ); - Amarok::Components::logger()->newProgressOperation( s, i18n("Generating a new playlist"), s->iterationCount(), s, &ConstraintSolver::requestAbort, Qt::QueuedConnection ); + Amarok::Logger::newProgressOperation( s, i18n("Generating a new playlist"), s->iterationCount(), s, &ConstraintSolver::requestAbort, Qt::QueuedConnection ); connect( s, &APG::ConstraintSolver::done, this, &Preset::solverFinished, Qt::QueuedConnection ); m_constraintTreeRoot->addChild( ConstraintTypes::TrackSpreader::createNew( m_constraintTreeRoot ), 0 ); // private mandatory constraint @@ -146,7 +146,7 @@ if ( job->success() ) { debug() << "Solver" << solver->serial() << "finished successfully"; if ( !solver->satisfied() ) { - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n("The playlist generator created a playlist which does not meet all " "of your constraints. If you are not satisfied with the results, " "try loosening or removing some constraints and then generating a " diff --git a/src/playlistgenerator/PresetModel.cpp b/src/playlistgenerator/PresetModel.cpp --- a/src/playlistgenerator/PresetModel.cpp +++ b/src/playlistgenerator/PresetModel.cpp @@ -19,7 +19,7 @@ #include "PresetModel.h" #include "amarokconfig.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/collections/Collection.h" #include "core/support/Amarok.h" #include "core/support/Components.h" @@ -213,13 +213,13 @@ xmldoc.save( out, 2, QDomNode::EncodingFromTextStream ); if( !filename.contains( "playlistgenerator.xml" ) ) { - Amarok::Components::logger()->longMessage( i18n("Preset exported to %1", filename), + Amarok::Logger::longMessage( i18n("Preset exported to %1", filename), Amarok::Logger::Information ); } } else { - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n("Preset could not be exported to %1", filename), Amarok::Logger::Error ); error() << "Can not write presets to " << filename; } @@ -237,14 +237,14 @@ parseXmlToPresets( document ); } else { error() << "Failed to read" << filename; - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n("Presets could not be imported from %1", filename), Amarok::Logger::Error ); } file.close(); } else { if ( !createDefaults ) { - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n("%1 could not be opened for preset import", filename), Amarok::Logger::Error ); } else { diff --git a/src/playlistmanager/PlaylistManager.cpp b/src/playlistmanager/PlaylistManager.cpp --- a/src/playlistmanager/PlaylistManager.cpp +++ b/src/playlistmanager/PlaylistManager.cpp @@ -32,7 +32,7 @@ #include "playlistmanager/SyncedPlaylist.h" #include "core/support/Debug.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "browsers/playlistbrowser/UserPlaylistModel.h" #include diff --git a/src/playlistmanager/file/PlaylistFileProvider.cpp b/src/playlistmanager/file/PlaylistFileProvider.cpp --- a/src/playlistmanager/file/PlaylistFileProvider.cpp +++ b/src/playlistmanager/file/PlaylistFileProvider.cpp @@ -20,7 +20,7 @@ #include "core/support/Amarok.h" #include "core/support/Debug.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core-impl/playlists/types/file/asx/ASXPlaylist.h" #include "core-impl/playlists/types/file/m3u/M3UPlaylist.h" #include "core-impl/playlists/types/file/pls/PLSPlaylist.h" @@ -285,7 +285,7 @@ Playlists::PlaylistFilePtr playlist = Playlists::loadPlaylistFile( url, this ); if( !playlist ) { - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n("The playlist file \"%1\" could not be loaded.", url.fileName() ), Amarok::Logger::Error ); diff --git a/src/scanner/AbstractScanResultProcessor.cpp b/src/scanner/AbstractScanResultProcessor.cpp --- a/src/scanner/AbstractScanResultProcessor.cpp +++ b/src/scanner/AbstractScanResultProcessor.cpp @@ -25,7 +25,7 @@ #include "collectionscanner/Directory.h" #include "collectionscanner/Playlist.h" #include "collectionscanner/Track.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Debug.h" #include "core/support/Components.h" #include "core-impl/collections/support/ArtistHelper.h" @@ -62,12 +62,11 @@ m_type = type; // -- show the progress operation for the job - if( Amarok::Components::logger() ) - Amarok::Components::logger()->newProgressOperation( this, - i18n( "Scanning music" ), - 100, - this, - &AbstractScanResultProcessor::abort ); + Amarok::Logger::newProgressOperation( this, + i18n( "Scanning music" ), + 100, + this, + &AbstractScanResultProcessor::abort ); } diff --git a/src/scripting/scriptengine/AmarokStatusbarScript.cpp b/src/scripting/scriptengine/AmarokStatusbarScript.cpp --- a/src/scripting/scriptengine/AmarokStatusbarScript.cpp +++ b/src/scripting/scriptengine/AmarokStatusbarScript.cpp @@ -16,7 +16,7 @@ #include "AmarokStatusbarScript.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include @@ -35,11 +35,11 @@ void AmarokStatusbarScript::longMessage( const QString &text ) { - Amarok::Components::logger()->longMessage( text ); + Amarok::Logger::longMessage( text ); } void AmarokStatusbarScript::shortMessage( const QString &text ) { - Amarok::Components::logger()->shortMessage( text ); + Amarok::Logger::shortMessage( text ); } diff --git a/src/scripting/scriptmanager/ScriptItem.cpp b/src/scripting/scriptmanager/ScriptItem.cpp --- a/src/scripting/scriptmanager/ScriptItem.cpp +++ b/src/scripting/scriptmanager/ScriptItem.cpp @@ -27,7 +27,7 @@ #include "core/support/Amarok.h" #include "core/support/Debug.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "MainWindow.h" #include "amarokconfig.h" #include "config.h" @@ -327,7 +327,7 @@ , "The script %1 uses deprecated scripting API calls. Please contact the script" " author, %2 at %3, and ask him to upgrade it before the next Amarok release." , m_info.name(), m_info.author(), m_info.email() ); - Amarok::Components::logger()->longMessage( message ); + Amarok::Logger::longMessage( message ); } void diff --git a/src/scripting/scriptmanager/ScriptManager.cpp b/src/scripting/scriptmanager/ScriptManager.cpp --- a/src/scripting/scriptmanager/ScriptManager.cpp +++ b/src/scripting/scriptmanager/ScriptManager.cpp @@ -27,7 +27,7 @@ #include "core/support/Amarok.h" #include "core/support/Debug.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "MainWindow.h" #include "amarokconfig.h" #include // for the compile flags @@ -263,7 +263,7 @@ if (!engine) return; - Amarok::Components::logger()->longMessage( i18n( "Script error reported by: %1\n%2", scriptNameForEngine( engine ), value.toString() ), Amarok::Logger::Error ); + Amarok::Logger::longMessage( i18n( "Script error reported by: %1\n%2", scriptNameForEngine( engine ), value.toString() ), Amarok::Logger::Error ); } void diff --git a/src/services/ampache/AmpacheAccountLogin.cpp b/src/services/ampache/AmpacheAccountLogin.cpp --- a/src/services/ampache/AmpacheAccountLogin.cpp +++ b/src/services/ampache/AmpacheAccountLogin.cpp @@ -126,7 +126,7 @@ debug() << "Authenticating with string: " << url.url() << passPhrase; - // TODO: Amarok::Components::logger()->newProgressOperation( m_xmlDownloadJob, i18n( "Authenticating with Ampache" ) ); + // TODO: Amarok::Logger::newProgressOperation( m_xmlDownloadJob, i18n( "Authenticating with Ampache" ) ); m_authRequest = The::networkAccessManager()->getData( url, this, &AmpacheAccountLogin::authenticationComplete ); if( !m_authRequest ) diff --git a/src/services/ampache/AmpacheService.cpp b/src/services/ampache/AmpacheService.cpp --- a/src/services/ampache/AmpacheService.cpp +++ b/src/services/ampache/AmpacheService.cpp @@ -23,7 +23,7 @@ #include "core/support/Amarok.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "browsers/SingleCollectionTreeItemModel.h" #include "core-impl/collections/support/CollectionManager.h" #include diff --git a/src/services/gpodder/GpodderProvider.cpp b/src/services/gpodder/GpodderProvider.cpp --- a/src/services/gpodder/GpodderProvider.cpp +++ b/src/services/gpodder/GpodderProvider.cpp @@ -23,7 +23,7 @@ #include "core-impl/capabilities/timecode/TimecodeWriteCapability.h" #include "core-impl/podcasts/sql/SqlPodcastProvider.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Amarok.h" #include "core/support/Components.h" #include "core/support/Debug.h" @@ -465,7 +465,7 @@ connect( m_episodeActionsResult.data(), SIGNAL(parseError()), SLOT(synchronizeStatusParseError()) ); - Amarok::Components::logger()->shortMessage( i18n( "Trying to synchronize statuses with gpodder.net" ) ); + Amarok::Logger::shortMessage( i18n( "Trying to synchronize statuses with gpodder.net" ) ); } else m_timerSynchronizeStatus->stop(); @@ -525,7 +525,7 @@ connect( m_addRemoveResult.data(), SIGNAL(finished()), this, SLOT(slotSuccessfulSubscriptionSynchronisation()) ); - Amarok::Components::logger()->shortMessage( i18n( "Trying to synchronize subscriptions with gpodder.net" ) ); + Amarok::Logger::shortMessage( i18n( "Trying to synchronize subscriptions with gpodder.net" ) ); } else m_timerSynchronizeSubscriptions->stop(); @@ -774,7 +774,7 @@ QTimer::singleShot( 10000, this, SLOT(requestDeviceUpdates()) ); debug() << "deviceUpdates [Subscription Synchronization] - Parse error"; - Amarok::Components::logger()->shortMessage( i18n( "GPodder Service failed to get data from the server. Will retry in 10 seconds..." ) ); + Amarok::Logger::shortMessage( i18n( "GPodder Service failed to get data from the server. Will retry in 10 seconds..." ) ); } void @@ -785,7 +785,7 @@ QTimer::singleShot( 10000, this, SLOT(requestDeviceUpdates()) ); debug() << "deviceUpdates [Subscription Synchronization] - Request error nr.: " << error; - Amarok::Components::logger()->shortMessage( i18n( "GPodder Service failed to get data from the server. Will retry in 10 seconds..." ) ); + Amarok::Logger::shortMessage( i18n( "GPodder Service failed to get data from the server. Will retry in 10 seconds..." ) ); } void diff --git a/src/services/jamendo/JamendoService.cpp b/src/services/jamendo/JamendoService.cpp --- a/src/services/jamendo/JamendoService.cpp +++ b/src/services/jamendo/JamendoService.cpp @@ -22,7 +22,7 @@ #include "core-impl/collections/support/CollectionManager.h" #include "core/support/Debug.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "EngineController.h" #include "JamendoInfoParser.h" #include "ServiceSqlRegistry.h" @@ -190,7 +190,7 @@ /* Deprecated */ QUrl("http://imgjam.com/data/dbdump_artistalbumtrack.xml.gz"), QUrl::fromLocalFile( m_tempFileName ), 0700 , KIO::HideProgressInfo | KIO::Overwrite ); - Amarok::Components::logger()->newProgressOperation( m_listDownloadJob, i18n( "Downloading Jamendo.com database..." ), this, SLOT(listDownloadCancelled()) ); + Amarok::Logger::newProgressOperation( m_listDownloadJob, i18n( "Downloading Jamendo.com database..." ), this, SLOT(listDownloadCancelled()) ); connect( m_listDownloadJob, &KJob::result, this, &JamendoService::listDownloadComplete ); @@ -212,7 +212,7 @@ return; } - Amarok::Components::logger()->shortMessage( i18n( "Updating the local Jamendo database." ) ); + Amarok::Logger::shortMessage( i18n( "Updating the local Jamendo database." ) ); debug() << "JamendoService: create xml parser"; if( m_xmlParser == 0 ) diff --git a/src/services/jamendo/JamendoXmlParser.cpp b/src/services/jamendo/JamendoXmlParser.cpp --- a/src/services/jamendo/JamendoXmlParser.cpp +++ b/src/services/jamendo/JamendoXmlParser.cpp @@ -19,7 +19,7 @@ #include "core/support/Amarok.h" #include "core/support/Debug.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include @@ -167,7 +167,7 @@ if( m_aborted ) return; - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18ncp( "First part of: Jamendo.com database update complete. Added 3 tracks on 4 albums from 5 artists.", "Jamendo.com database update complete. Added 1 track on ", "Jamendo.com database update complete. Added %1 tracks on ", m_nNumberOfTracks) + i18ncp( "Middle part of: Jamendo.com database update complete. Added 3 tracks on 4 albums from 5 artists.", "1 album from ", "%1 albums from ", m_nNumberOfAlbums) + i18ncp( "Last part of: Jamendo.com database update complete. Added 3 tracks on 4 albums from 5 artists.", "1 artist.", "%1 artists.", m_nNumberOfArtists ) diff --git a/src/services/lastfm/LastFmService.cpp b/src/services/lastfm/LastFmService.cpp --- a/src/services/lastfm/LastFmService.cpp +++ b/src/services/lastfm/LastFmService.cpp @@ -34,7 +34,7 @@ #include "ScrobblerAdapter.h" #include "GlobalCurrentTrackActions.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "meta/LastFmMeta.h" #include "SynchronizationAdapter.h" #include "statsyncing/Controller.h" @@ -294,12 +294,12 @@ break; } case QNetworkReply::AuthenticationRequiredError: - Amarok::Components::logger()->longMessage( i18nc("Last.fm: errorMessage", + Amarok::Logger::longMessage( i18nc("Last.fm: errorMessage", "Either the username was not recognized, or the password was incorrect." ) ); break; default: - Amarok::Components::logger()->longMessage( i18nc("Last.fm: errorMessage", + Amarok::Logger::longMessage( i18nc("Last.fm: errorMessage", "There was a problem communicating with the Last.fm services. Please try again later." ) ); break; } diff --git a/src/services/lastfm/LastFmServiceConfig.cpp b/src/services/lastfm/LastFmServiceConfig.cpp --- a/src/services/lastfm/LastFmServiceConfig.cpp +++ b/src/services/lastfm/LastFmServiceConfig.cpp @@ -20,7 +20,7 @@ #include "LastFmServiceConfig.h" #include "App.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Amarok.h" #include "core/support/Components.h" #include "core/support/Debug.h" @@ -216,7 +216,7 @@ { warning() << __PRETTY_FUNCTION__ << "failed to open wallet"; QString message = i18n( "Failed to open KDE Wallet to read Last.fm credentials" ); - Amarok::Components::logger()->longMessage( message, Amarok::Logger::Warning ); + Amarok::Logger::longMessage( message, Amarok::Logger::Warning ); if( m_wallet ) m_wallet->deleteLater(); // no point in having invalid wallet around m_wallet = 0; diff --git a/src/services/lastfm/ScrobblerAdapter.cpp b/src/services/lastfm/ScrobblerAdapter.cpp --- a/src/services/lastfm/ScrobblerAdapter.cpp +++ b/src/services/lastfm/ScrobblerAdapter.cpp @@ -23,7 +23,7 @@ #include "MainWindow.h" #include "core/collections/Collection.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/meta/Meta.h" #include "core/meta/support/MetaConstants.h" #include "core/support/Components.h" @@ -155,7 +155,7 @@ lastfm::MutableTrack trackInfo; copyTrackMetadata( trackInfo, track ); trackInfo.love(); - Amarok::Components::logger()->shortMessage( i18nc( "As in Last.fm", "Loved Track: %1", track->prettyName() ) ); + Amarok::Logger::shortMessage( i18nc( "As in Last.fm", "Loved Track: %1", track->prettyName() ) ); } void @@ -167,7 +167,7 @@ lastfm::MutableTrack trackInfo; copyTrackMetadata( trackInfo, track ); trackInfo.ban(); - Amarok::Components::logger()->shortMessage( i18nc( "As in Last.fm", "Banned Track: %1", track->prettyName() ) ); + Amarok::Logger::shortMessage( i18nc( "As in Last.fm", "Banned Track: %1", track->prettyName() ) ); } void @@ -282,7 +282,7 @@ line = printCorrected( Meta::valAlbumArtist, track.albumArtist( orig ), track.albumArtist( correct ) ); if( !line.isEmpty() ) lines << line; - Amarok::Components::logger()->longMessage( lines.join( "
" ) ); + Amarok::Logger::longMessage( lines.join( "
" ) ); } bool diff --git a/src/services/lastfm/meta/LastFmMultiPlayableCapability.h b/src/services/lastfm/meta/LastFmMultiPlayableCapability.h --- a/src/services/lastfm/meta/LastFmMultiPlayableCapability.h +++ b/src/services/lastfm/meta/LastFmMultiPlayableCapability.h @@ -17,7 +17,6 @@ #ifndef AMAROK_MULTIPLAYABLECAPABILITYIMPL_P_H #define AMAROK_MULTIPLAYABLECAPABILITYIMPL_P_H -#include "core/interfaces/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" #include "MainWindow.h" diff --git a/src/services/lastfm/meta/LastFmMultiPlayableCapability.cpp b/src/services/lastfm/meta/LastFmMultiPlayableCapability.cpp --- a/src/services/lastfm/meta/LastFmMultiPlayableCapability.cpp +++ b/src/services/lastfm/meta/LastFmMultiPlayableCapability.cpp @@ -95,14 +95,14 @@ // a subscriber, even if the credentials are OK if( e == lastfm::ws::SubscribersOnly || e == lastfm::ws::AuthenticationFailed ) { - Amarok::Components::logger()->longMessage( i18n( "To listen to Last.fm streams " + Amarok::Logger::longMessage( i18n( "To listen to Last.fm streams " "and radio you need to be a paying Last.fm subscriber and you need to " "stream from a supported " "country. All other Last.fm features work fine." ) ); } else { - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18n( "Error starting track from Last.fm radio" ) ); } } diff --git a/src/services/magnatune/MagnatuneAlbumDownloader.cpp b/src/services/magnatune/MagnatuneAlbumDownloader.cpp --- a/src/services/magnatune/MagnatuneAlbumDownloader.cpp +++ b/src/services/magnatune/MagnatuneAlbumDownloader.cpp @@ -19,7 +19,7 @@ #include "core/support/Amarok.h" #include "core/support/Components.h" #include "core/support/Debug.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "MagnatuneMeta.h" #include @@ -71,7 +71,7 @@ msgText = i18n( "Downloading album from Magnatune.com" ); } - Amarok::Components::logger()->newProgressOperation( m_albumDownloadJob, msgText, this, &MagnatuneAlbumDownloader::albumDownloadAborted ); + Amarok::Logger::newProgressOperation( m_albumDownloadJob, msgText, this, &MagnatuneAlbumDownloader::albumDownloadAborted ); } void @@ -97,16 +97,16 @@ if ( !kzip.open( QIODevice::ReadOnly ) ) { - Amarok::Components::logger()->shortMessage( i18n( "Magnatune download seems to have failed. Cannot read zip file" ) ); + Amarok::Logger::shortMessage( i18n( "Magnatune download seems to have failed. Cannot read zip file" ) ); emit( downloadComplete( false ) ); return; } debug() << m_tempDir->path() + '/' + m_currentAlbumFileName << " opened for decompression"; const KArchiveDirectory * directory = kzip.directory(); - Amarok::Components::logger()->shortMessage( i18n( "Uncompressing Magnatune.com download..." ) ); + Amarok::Logger::shortMessage( i18n( "Uncompressing Magnatune.com download..." ) ); //Is this really blocking with no progress status!? Why is it not a KJob? @@ -130,7 +130,7 @@ connect( m_coverDownloadJob, &KJob::result, this, &MagnatuneAlbumDownloader::coverDownloadComplete ); - Amarok::Components::logger()->newProgressOperation( m_coverDownloadJob, i18n( "Adding album cover to collection" ), this, &MagnatuneAlbumDownloader::coverAddAborted ); + Amarok::Logger::newProgressOperation( m_coverDownloadJob, i18n( "Adding album cover to collection" ), this, &MagnatuneAlbumDownloader::coverAddAborted ); emit( downloadComplete( true ) ); } diff --git a/src/services/magnatune/MagnatuneDownloadHandler.cpp b/src/services/magnatune/MagnatuneDownloadHandler.cpp --- a/src/services/magnatune/MagnatuneDownloadHandler.cpp +++ b/src/services/magnatune/MagnatuneDownloadHandler.cpp @@ -16,7 +16,7 @@ #include "MagnatuneDownloadHandler.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Amarok.h" #include "core/support/Components.h" #include "core/support/Debug.h" @@ -79,7 +79,7 @@ m_membershipDownload = true; m_resultDownloadJob = KIO::storedGet( purchaseURL, KIO::NoReload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_resultDownloadJob, + Amarok::Logger::newProgressOperation( m_resultDownloadJob, i18n( "Processing download" ) ); connect( m_resultDownloadJob, &KJob::result, this, &MagnatuneDownloadHandler::xmlDownloadComplete ); } diff --git a/src/services/magnatune/MagnatuneInfoParser.cpp b/src/services/magnatune/MagnatuneInfoParser.cpp --- a/src/services/magnatune/MagnatuneInfoParser.cpp +++ b/src/services/magnatune/MagnatuneInfoParser.cpp @@ -17,7 +17,7 @@ #include "MagnatuneInfoParser.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "MagnatuneConfig.h" #include @@ -38,7 +38,7 @@ QString orgHtml;*/ m_infoDownloadJob = KIO::storedGet( magnatuneArtist->magnatuneUrl(), KIO::Reload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_infoDownloadJob, i18n( "Fetching %1 Artist Info", magnatuneArtist->prettyName() ) ); + Amarok::Logger::newProgressOperation( m_infoDownloadJob, i18n( "Fetching %1 Artist Info", magnatuneArtist->prettyName() ) ); connect( m_infoDownloadJob, &KJob::result, this, &MagnatuneInfoParser::artistInfoDownloadComplete ); } @@ -163,7 +163,7 @@ showLoading( i18n( "Loading Magnatune.com frontpage..." ) ); m_pageDownloadJob = KIO::storedGet( QUrl("http://magnatune.com/amarok_frontpage.html"), KIO::Reload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_pageDownloadJob, i18n( "Fetching Magnatune.com front page" ) ); + Amarok::Logger::newProgressOperation( m_pageDownloadJob, i18n( "Fetching Magnatune.com front page" ) ); connect( m_pageDownloadJob, &KJob::result, this, &MagnatuneInfoParser::frontpageDownloadComplete ); } @@ -188,7 +188,7 @@ QUrl url = QUrl::fromUserInput( "http://" + user + ":" + password + "@" + type.toLower() + ".magnatune.com/member/amarok_favorites.php" ); m_pageDownloadJob = KIO::storedGet( url, KIO::Reload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_pageDownloadJob, i18n( "Loading your Magnatune.com favorites page..." ) ); + Amarok::Logger::newProgressOperation( m_pageDownloadJob, i18n( "Loading your Magnatune.com favorites page..." ) ); connect( m_pageDownloadJob, &KJob::result, this, &MagnatuneInfoParser::userPageDownloadComplete ); } @@ -213,7 +213,7 @@ QUrl url = QUrl::fromUserInput( "http://" + user + ":" + password + "@" + type.toLower() + ".magnatune.com/member/amarok_recommendations.php" ); m_pageDownloadJob = KIO::storedGet( url, KIO::Reload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_pageDownloadJob, i18n( "Loading your personal Magnatune.com recommendations page..." ) ); + Amarok::Logger::newProgressOperation( m_pageDownloadJob, i18n( "Loading your personal Magnatune.com recommendations page..." ) ); connect( m_pageDownloadJob, &KJob::result, this, &MagnatuneInfoParser::userPageDownloadComplete ); } diff --git a/src/services/magnatune/MagnatuneRedownloadHandler.cpp b/src/services/magnatune/MagnatuneRedownloadHandler.cpp --- a/src/services/magnatune/MagnatuneRedownloadHandler.cpp +++ b/src/services/magnatune/MagnatuneRedownloadHandler.cpp @@ -20,7 +20,7 @@ #include "core/support/Amarok.h" #include "core/support/Debug.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include #include @@ -146,7 +146,7 @@ QUrl redownloadApiUrl = QUrl::fromUserInput( "http://magnatune.com/buy/redownload_xml?email=" + email ); m_redownloadApiJob = KIO::storedGet( redownloadApiUrl, KIO::NoReload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_redownloadApiJob, i18n( "Getting list of previous Magnatune.com purchases" ) ); + Amarok::Logger::newProgressOperation( m_redownloadApiJob, i18n( "Getting list of previous Magnatune.com purchases" ) ); connect( m_redownloadApiJob, &KIO::TransferJob::result, this, &MagnatuneRedownloadHandler::redownloadApiResult ); } diff --git a/src/services/magnatune/MagnatuneStore.cpp b/src/services/magnatune/MagnatuneStore.cpp --- a/src/services/magnatune/MagnatuneStore.cpp +++ b/src/services/magnatune/MagnatuneStore.cpp @@ -18,7 +18,7 @@ #include "core/support/Amarok.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "amarokurls/AmarokUrlHandler.h" #include "browsers/CollectionTreeItem.h" #include "browsers/CollectionTreeView.h" @@ -323,7 +323,7 @@ m_tempFileName = tempFile.fileName(); m_listDownloadJob = KIO::file_copy( QUrl("http://magnatune.com/info/album_info_xml.bz2"), QUrl::fromLocalFile( m_tempFileName ), 0700 , KIO::HideProgressInfo | KIO::Overwrite ); - Amarok::Components::logger()->newProgressOperation( m_listDownloadJob, i18n( "Downloading Magnatune.com database..." ), this, &MagnatuneStore::listDownloadCancelled ); + Amarok::Logger::newProgressOperation( m_listDownloadJob, i18n( "Downloading Magnatune.com database..." ), this, &MagnatuneStore::listDownloadCancelled ); connect( m_listDownloadJob, &KJob::result, this, &MagnatuneStore::listDownloadComplete ); @@ -352,7 +352,7 @@ } - Amarok::Components::logger()->shortMessage( i18n( "Updating the local Magnatune database." ) ); + Amarok::Logger::shortMessage( i18n( "Updating the local Magnatune database." ) ); MagnatuneXmlParser * parser = new MagnatuneXmlParser( m_tempFileName ); parser->setDbHandler( new MagnatuneDatabaseHandler() ); connect( parser, &MagnatuneXmlParser::doneParsing, this, &MagnatuneStore::doneParsing ); @@ -725,7 +725,7 @@ QString result = m_favoritesJob->data(); - Amarok::Components::logger()->longMessage( result ); + Amarok::Logger::longMessage( result ); //show the favorites page showFavoritesPage(); diff --git a/src/services/magnatune/MagnatuneXmlParser.cpp b/src/services/magnatune/MagnatuneXmlParser.cpp --- a/src/services/magnatune/MagnatuneXmlParser.cpp +++ b/src/services/magnatune/MagnatuneXmlParser.cpp @@ -19,7 +19,7 @@ #include "core/support/Amarok.h" #include "core/support/Debug.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include #include @@ -72,7 +72,7 @@ void MagnatuneXmlParser::completeJob( ) { - Amarok::Components::logger()->longMessage( + Amarok::Logger::longMessage( i18ncp( "First part of: Magnatune.com database update complete. Database contains 3 tracks on 4 albums from 5 artists.", "Magnatune.com database update complete. Database contains 1 track on ", "Magnatune.com database update complete. Database contains %1 tracks on ", diff --git a/src/services/mp3tunes/Mp3tunesService.cpp b/src/services/mp3tunes/Mp3tunesService.cpp --- a/src/services/mp3tunes/Mp3tunesService.cpp +++ b/src/services/mp3tunes/Mp3tunesService.cpp @@ -21,7 +21,7 @@ #include "browsers/SingleCollectionTreeItemModel.h" #include "core-impl/collections/support/CollectionManager.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" #include "Mp3tunesConfig.h" @@ -214,7 +214,7 @@ debug() << "Daemon running"; m_harmonyEnabled = true; - Amarok::Components::logger()->shortMessage( i18n( "MP3tunes AutoSync Enabled" ) ); + Amarok::Logger::shortMessage( i18n( "MP3tunes AutoSync Enabled" ) ); polish(); } @@ -230,7 +230,7 @@ m_harmonyEnabled = false; polish(); - Amarok::Components::logger()->shortMessage( i18n( "MP3tunes AutoSync Disabled" ) ); + Amarok::Logger::shortMessage( i18n( "MP3tunes AutoSync Disabled" ) ); } void Mp3tunesService::authenticate( const QString & uname, const QString & passwd ) @@ -250,7 +250,7 @@ //debug() << "Connection complete. Enqueueing.."; ThreadWeaver::Queue::instance()->enqueue( QSharedPointer(m_loginWorker) ); //debug() << "LoginWorker queue"; - Amarok::Components::logger()->shortMessage( i18n( "Authenticating" ) ); + Amarok::Logger::shortMessage( i18n( "Authenticating" ) ); } @@ -267,7 +267,7 @@ { error = m_locker->errorMessage(); // Not sure how to i18n this } - Amarok::Components::logger()->longMessage( error ); + Amarok::Logger::longMessage( error ); setServiceReady( false ); m_authenticationFailed = true; @@ -292,14 +292,14 @@ { DEBUG_BLOCK debug() << "Harmony Disconnected!"; - Amarok::Components::logger()->shortMessage( i18n( "MP3tunes Harmony: Disconnected" ) ); + Amarok::Logger::shortMessage( i18n( "MP3tunes Harmony: Disconnected" ) ); } void Mp3tunesService::harmonyWaitingForEmail( const QString &pin ) { DEBUG_BLOCK debug() << "Waiting for user to input PIN: " << pin; - Amarok::Components::logger()->shortMessage( i18n( "MP3tunes Harmony: Waiting for PIN Input" ) ); + Amarok::Logger::shortMessage( i18n( "MP3tunes Harmony: Waiting for PIN Input" ) ); KMessageBox::information( this, "Please go to mp3tunes.com/pin and enter the following pin.\n\tPIN: " + pin, "MP3tunes Harmony", @@ -312,7 +312,7 @@ DEBUG_BLOCK QString pin = m_harmony->pin(); debug() << "Waiting for user to input PIN: " << pin; - Amarok::Components::logger()->shortMessage( i18n( "MP3tunes Harmony: Waiting for PIN Input" ) ); + Amarok::Logger::shortMessage( i18n( "MP3tunes Harmony: Waiting for PIN Input" ) ); KMessageBox::information( this, "Please go to mp3tunes.com/pin and enter the following pin.\n\tPIN: " + pin, "MP3tunes Harmony", @@ -324,7 +324,7 @@ { DEBUG_BLOCK debug() << "Harmony Connected!"; - Amarok::Components::logger()->shortMessage( i18n( "MP3tunes Harmony: Successfully Connected" ) ); + Amarok::Logger::shortMessage( i18n( "MP3tunes Harmony: Successfully Connected" ) ); /* at this point since the user has input the pin, we will save the info for later authentication*/ Mp3tunesConfig config; @@ -339,7 +339,7 @@ { DEBUG_BLOCK debug() << "Harmony Error: " << error; - Amarok::Components::logger()->longMessage( i18n( "MP3tunes Harmony Error\n%1", error ) ); + Amarok::Logger::longMessage( i18n( "MP3tunes Harmony Error\n%1", error ) ); } void Mp3tunesService::harmonyDownloadReady( const QVariantMap &download ) diff --git a/src/services/mp3tunes/Mp3tunesServiceCollectionLocation.cpp b/src/services/mp3tunes/Mp3tunesServiceCollectionLocation.cpp --- a/src/services/mp3tunes/Mp3tunesServiceCollectionLocation.cpp +++ b/src/services/mp3tunes/Mp3tunesServiceCollectionLocation.cpp @@ -17,7 +17,7 @@ #include "Mp3tunesServiceCollectionLocation.h" #include "Mp3tunesWorkers.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include @@ -80,7 +80,7 @@ } } if( !error.isEmpty() ) - Amarok::Components::logger()->longMessage( error ); + Amarok::Logger::longMessage( error ); Mp3tunesSimpleUploader * uploadWorker = new Mp3tunesSimpleUploader( m_collection->locker(), urls ); connect( uploadWorker, &Mp3tunesSimpleUploader::uploadComplete, this, &Mp3tunesServiceCollectionLocation::slotCopyOperationFinished ); ThreadWeaver::Queue::instance()->enqueue( QSharedPointer(uploadWorker) ); diff --git a/src/services/mp3tunes/Mp3tunesWorkers.cpp b/src/services/mp3tunes/Mp3tunesWorkers.cpp --- a/src/services/mp3tunes/Mp3tunesWorkers.cpp +++ b/src/services/mp3tunes/Mp3tunesWorkers.cpp @@ -16,7 +16,7 @@ #include "Mp3tunesWorkers.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Components.h" #include "core/support/Debug.h" #include "Mp3tunesMeta.h" @@ -341,7 +341,7 @@ m_locker = locker; m_tracklist = tracklist; - Amarok::Components::logger()->newProgressOperation( this, i18n( "Upload to MP3tunes Initiated" ), m_tracklist.count() ); + Amarok::Logger::newProgressOperation( this, i18n( "Upload to MP3tunes Initiated" ), m_tracklist.count() ); //TODO: port to Amarok::Logger signals // connect( this, SIGNAL(incrementProgress()), The::statusBar(), SLOT(incrementProgress()), Qt::QueuedConnection ); } diff --git a/src/services/opmldirectory/OpmlDirectoryInfoParser.cpp b/src/services/opmldirectory/OpmlDirectoryInfoParser.cpp --- a/src/services/opmldirectory/OpmlDirectoryInfoParser.cpp +++ b/src/services/opmldirectory/OpmlDirectoryInfoParser.cpp @@ -18,7 +18,7 @@ #include "core/support/Debug.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "OpmlDirectoryMeta.h" #include @@ -62,7 +62,7 @@ debug() << "OpmlDirectoryInfoParser: getInfo about feed: " << feed->uidUrl(); m_rssDownloadJob = KIO::storedGet( QUrl( feed->uidUrl() ), KIO::Reload, KIO::HideProgressInfo ); - Amarok::Components::logger()->newProgressOperation( m_rssDownloadJob, + Amarok::Logger::newProgressOperation( m_rssDownloadJob, i18n( "Fetching Podcast Info" ) ); connect( m_rssDownloadJob, &KJob::result, this, &OpmlDirectoryInfoParser::rssDownloadComplete ); } diff --git a/src/services/opmldirectory/OpmlDirectoryService.cpp b/src/services/opmldirectory/OpmlDirectoryService.cpp --- a/src/services/opmldirectory/OpmlDirectoryService.cpp +++ b/src/services/opmldirectory/OpmlDirectoryService.cpp @@ -19,7 +19,7 @@ #include "amarokurls/AmarokUrlHandler.h" #include "core/support/Debug.h" #include "core/support/Components.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "browsers/CollectionTreeItem.h" #include "browsers/SingleCollectionTreeItemModel.h" #include "OpmlDirectoryInfoParser.h" diff --git a/src/statemanagement/DefaultApplicationController.h b/src/statemanagement/DefaultApplicationController.h --- a/src/statemanagement/DefaultApplicationController.h +++ b/src/statemanagement/DefaultApplicationController.h @@ -33,7 +33,6 @@ virtual void shutdown(); private: - void initCoreServiceProxies(); void initSqlStorage(); void initEngineController(); void initCollectionManager(); diff --git a/src/statemanagement/DefaultApplicationController.cpp b/src/statemanagement/DefaultApplicationController.cpp --- a/src/statemanagement/DefaultApplicationController.cpp +++ b/src/statemanagement/DefaultApplicationController.cpp @@ -20,7 +20,6 @@ #include "EngineController.h" #include "core-impl/collections/support/CollectionLocationDelegateImpl.h" -#include "core-impl/logger/ProxyLogger.h" #include @@ -44,7 +43,6 @@ DefaultApplicationController::start() { //construct all central components - initCoreServiceProxies(); initSqlStorage(); initEngineController(); initCollectionManager(); @@ -60,19 +58,6 @@ delete Components::setEngineController( 0 ); delete Components::setCollectionLocationDelegate( 0 ); - delete Components::setLogger( 0 ); -} - -void -DefaultApplicationController::initCoreServiceProxies() -{ - //we have core services that (e.g. StatusBar) that - //basically all other components could sensibly use - //unfortunately some of these components are GUI - //components and can only be constructed quite late - //therefore we provide proxies here that won't do anything, but forward - //to the real implementation as soon as possible - Components::setLogger( new ProxyLogger() ); } void diff --git a/src/statsyncing/Controller.cpp b/src/statsyncing/Controller.cpp --- a/src/statsyncing/Controller.cpp +++ b/src/statsyncing/Controller.cpp @@ -21,7 +21,7 @@ #include "ProviderFactory.h" #include "amarokconfig.h" #include "core/collections/Collection.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/meta/Meta.h" #include "core/support/Amarok.h" #include "core/support/Components.h" @@ -377,7 +377,7 @@ { QString text = i18n( "You only seem to have the Local Collection. Statistics " "synchronization only makes sense if there is more than one collection." ); - Amarok::Components::logger()->longMessage( text ); + Amarok::Logger::longMessage( text ); } return; } diff --git a/src/statsyncing/Process.cpp b/src/statsyncing/Process.cpp --- a/src/statsyncing/Process.cpp +++ b/src/statsyncing/Process.cpp @@ -18,7 +18,7 @@ #include "MainWindow.h" #include "MetaValues.h" -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" #include "core/support/Amarok.h" #include "core/support/Debug.h" #include "core/support/Components.h" @@ -127,7 +127,7 @@ } else // background operation { - Amarok::Components::logger()->newProgressOperation( job, text, 100, job, &MatchTracksJob::abort ); + Amarok::Logger::newProgressOperation( job, text, 100, job, &MatchTracksJob::abort ); } connect( job, &StatSyncing::MatchTracksJob::done, this, &Process::slotTracksMatched ); @@ -228,7 +228,7 @@ SynchronizeTracksJob *job = new SynchronizeTracksJob( m_matchedTracksModel->matchedTuples(), m_tracksToScrobble, m_options ); QString text = i18n( "Synchronizing Track Statistics" ); - Amarok::Components::logger()->newProgressOperation( job, text, 100, job, &SynchronizeTracksJob::abort ); + Amarok::Logger::newProgressOperation( job, text, 100, job, &SynchronizeTracksJob::abort ); connect( job, &StatSyncing::SynchronizeTracksJob::done, this, &Process::slotLogSynchronization ); connect( job, &StatSyncing::SynchronizeTracksJob::done, job, &StatSyncing::SynchronizeTracksJob::deleteLater ); ThreadWeaver::Queue::instance()->enqueue( QSharedPointer(job) ); @@ -297,7 +297,7 @@ "Scrobbling of %1 tracks was skipped as configured by the user.", scrobbleErrorCounts[ ScrobblingService::SkippedByUser ] ); - Amarok::Components::logger()->longMessage( text.join( "
\n" ) ); + Amarok::Logger::longMessage( text.join( "
\n" ) ); } void diff --git a/src/statusbar/LongMessageWidget.h b/src/statusbar/LongMessageWidget.h --- a/src/statusbar/LongMessageWidget.h +++ b/src/statusbar/LongMessageWidget.h @@ -19,7 +19,7 @@ #define LONGMESSAGEWIDGET_H #include "PopupWidget.h" -#include "core/interfaces/Logger.h" + class CountdownFrame : public QFrame { diff --git a/tests/core-impl/CMakeLists.txt b/tests/core-impl/CMakeLists.txt --- a/tests/core-impl/CMakeLists.txt +++ b/tests/core-impl/CMakeLists.txt @@ -1,5 +1,4 @@ add_subdirectory( collections ) -add_subdirectory( logger ) add_subdirectory( meta ) add_subdirectory( playlists ) add_subdirectory( support ) diff --git a/tests/core-impl/collections/db/sql/CMakeLists.txt b/tests/core-impl/collections/db/sql/CMakeLists.txt --- a/tests/core-impl/collections/db/sql/CMakeLists.txt +++ b/tests/core-impl/collections/db/sql/CMakeLists.txt @@ -36,7 +36,6 @@ ${AMAROK_TEST_TREE} ${AMAROK_SOURCE_TREE} ${AMAROK_SOURCE_TREE}/core-impl/collections/db/sql - ${AMAROK_SOURCE_TREE}/core-impl/logger ${AMAROK_UTILITY_TREE} ${CMAKE_BINARY_DIR}/src ${CMAKE_BINARY_DIR}/tests @@ -115,8 +114,7 @@ set( testsqlcollectionlocation_SRCS TestSqlCollectionLocation.cpp - ${AMAROK_SOURCE_TREE}/core/interfaces/Logger.cpp - ${AMAROK_SOURCE_TREE}/core-impl/logger/ProxyLogger.cpp + ${AMAROK_SOURCE_TREE}/core/logger/Logger.cpp ${GOOGLEMOCK_SRCS} ) diff --git a/tests/core-impl/collections/db/sql/TestSqlCollectionLocation.cpp b/tests/core-impl/collections/db/sql/TestSqlCollectionLocation.cpp --- a/tests/core-impl/collections/db/sql/TestSqlCollectionLocation.cpp +++ b/tests/core-impl/collections/db/sql/TestSqlCollectionLocation.cpp @@ -19,7 +19,6 @@ #include "DatabaseUpdater.h" #include "core/support/Debug.h" #include "core/support/Components.h" -#include "core-impl/logger/ProxyLogger.h" #include "DefaultSqlQueryMakerFactory.h" #include "core/meta/Meta.h" #include "core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h" @@ -111,7 +110,6 @@ void TestSqlCollectionLocation::initTestCase() { - Amarok::Components::setLogger( new ProxyLogger() ); m_tmpDir = new QTemporaryDir(); m_storage = QSharedPointer( new MySqlEmbeddedStorage() ); QVERIFY( m_storage->init( m_tmpDir->path() ) ); @@ -137,7 +135,6 @@ TestSqlCollectionLocation::cleanupTestCase() { delete m_collection; - delete Amarok::Components::setLogger( 0 ); //m_storage is deleted by SqlCollection delete m_tmpDir; } diff --git a/tests/core-impl/logger/CMakeLists.txt b/tests/core-impl/logger/CMakeLists.txt deleted file mode 100644 --- a/tests/core-impl/logger/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -include_directories( - ${AMAROK_TEST_TREE} - ${AMAROK_SOURCE_TREE} - ${AMAROK_UTILITY_TREE} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/tests - - - ${GOOGLEMOCK_INCLUDE_DIR} - ) - -#------------------------ Test ProxyLogger ----------------------------- - -set( testproxylogger_SRCS - TestProxyLogger.cpp - ${AMAROK_SOURCE_TREE}/core/interfaces/Logger.cpp - ${AMAROK_SOURCE_TREE}/core-impl/logger/ProxyLogger.cpp - ${GOOGLEMOCK_SRCS} - ) - - -add_executable( testproxylogger - ${testproxylogger_SRCS} - ) -add_test(NAME testproxylogger COMMAND $) -ecm_mark_as_test(testproxylogger) - -target_link_libraries( testproxylogger - Qt5::Test - Qt5::Core - Qt5::Network - KF5::CoreAddons - KF5::ThreadWeaver - ${GOOGLEMOCK_LIBRARIES} - ${CMAKE_DL_LIBS}) diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt --- a/tests/core/CMakeLists.txt +++ b/tests/core/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory( capabilities ) add_subdirectory( collections ) add_subdirectory( interfaces ) +add_subdirectory( logger ) add_subdirectory( meta ) add_subdirectory( playlists ) diff --git a/tests/core/logger/CMakeLists.txt b/tests/core/logger/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/tests/core/logger/CMakeLists.txt @@ -0,0 +1,34 @@ +include_directories( + ${AMAROK_TEST_TREE} + ${AMAROK_SOURCE_TREE} + ${AMAROK_UTILITY_TREE} + ${CMAKE_BINARY_DIR}/src + ${CMAKE_BINARY_DIR}/tests + + + ${GOOGLEMOCK_INCLUDE_DIR} + ) + +#------------------------ Test Logger ----------------------------- + +set( testlogger_SRCS + TestLogger.cpp + ${AMAROK_SOURCE_TREE}/core/logger/Logger.cpp + ${GOOGLEMOCK_SRCS} + ) + + +add_executable( testlogger + ${testlogger_SRCS} + ) +add_test(NAME testlogger COMMAND $) +ecm_mark_as_test(testlogger) + +target_link_libraries( testlogger + Qt5::Test + Qt5::Core + Qt5::Network + KF5::CoreAddons + KF5::ThreadWeaver + ${GOOGLEMOCK_LIBRARIES} + ${CMAKE_DL_LIBS}) diff --git a/tests/core-impl/logger/TestProxyLogger.h b/tests/core/logger/TestLogger.h rename from tests/core-impl/logger/TestProxyLogger.h rename to tests/core/logger/TestLogger.h --- a/tests/core-impl/logger/TestProxyLogger.h +++ b/tests/core/logger/TestLogger.h @@ -14,16 +14,16 @@ * this program. If not, see . * ****************************************************************************************/ -#ifndef TEST_PROXY_LOGGER_H -#define TEST_PROXY_LOGGER_H +#ifndef TEST_LOGGER_H +#define TEST_LOGGER_H #include -class TestProxyLogger : public QObject +class TestLogger : public QObject { Q_OBJECT public: - TestProxyLogger(); + TestLogger(); private Q_SLOTS: void init(); diff --git a/tests/core-impl/logger/TestProxyLogger.cpp b/tests/core/logger/TestLogger.cpp rename from tests/core-impl/logger/TestProxyLogger.cpp rename to tests/core/logger/TestLogger.cpp --- a/tests/core-impl/logger/TestProxyLogger.cpp +++ b/tests/core/logger/TestLogger.cpp @@ -14,36 +14,36 @@ * this program. If not, see . * ****************************************************************************************/ -#include "TestProxyLogger.h" +#include "TestLogger.h" -#include "core/interfaces/Logger.h" -#include "core-impl/logger/ProxyLogger.h" +#include "core/logger/Logger.h" #include "mocks/MockLogger.h" #include #include #include +#include + #include -QTEST_GUILESS_MAIN( TestProxyLogger ) +QTEST_GUILESS_MAIN( TestLogger ) using ::testing::Return; using ::testing::AnyNumber; using ::testing::_; using ::testing::Mock; -static ProxyLogger *s_logger; class DummyJob : public KJob { public: virtual void start() {} }; -TestProxyLogger::TestProxyLogger() +TestLogger::TestLogger() { int argc = 1; char **argv = (char **) malloc(sizeof(char *)); @@ -53,15 +53,13 @@ } void -TestProxyLogger::init() +TestLogger::init() { - s_logger = 0; } void -TestProxyLogger::cleanup() +TestLogger::cleanup() { - delete s_logger; } class ProgressJob : public QObject, public ThreadWeaver::Job @@ -75,7 +73,7 @@ Q_UNUSED(thread); KJob *job = new DummyJob(); QObject *obj = new QObject(); - s_logger->newProgressOperation( job, QString( "foo" ), obj ); + Amarok::Logger::newProgressOperation( job, QString( "foo" ), obj ); if( deleteJob ) delete job; if( deleteObject ) delete obj; @@ -111,99 +109,79 @@ }; void -TestProxyLogger::testDoNotForwardDeletedJob() +TestLogger::testDoNotForwardDeletedJob() { - s_logger = new ProxyLogger(); - Amarok::MockLogger *mock = new Amarok::MockLogger(); EXPECT_CALL( *mock, newProgressOperationImpl( An(), _, _, _, _ ) ).Times( 0 ); - s_logger->setLogger( mock ); - ProgressJob *job = new ProgressJob(); job->deleteJob = true; ThreadWeaver::Queue::instance()->enqueue( QSharedPointer(job) ); QTest::qSleep( 10 ); //ensure that the job has time to run - QTest::qWait( 20 ); //give the ProxyLogger-internal timer time to fire + QTest::qWait( 20 ); //give the Logger-internal timer time to fire QVERIFY( Mock::VerifyAndClearExpectations( &mock ) ); delete mock; } void -TestProxyLogger::testDoNotForwardDeletedSlot() +TestLogger::testDoNotForwardDeletedSlot() { - s_logger = new ProxyLogger(); - Amarok::MockLogger *mock = new Amarok::MockLogger(); EXPECT_CALL( *mock, newProgressOperationImpl( An(), _, nullptr, _, _ ) ).Times( 1 ).WillOnce( Return() ); - s_logger->setLogger( mock ); - ProgressJob *job = new ProgressJob(); job->deleteObject = true; ThreadWeaver::Queue::instance()->enqueue( QSharedPointer(job) ); QTest::qSleep( 10 ); //ensure that the job has time to run - QTest::qWait( 20 ); //give the ProxyLogger-internal timer time to fire + QTest::qWait( 20 ); //give the Logger-internal timer time to fire QVERIFY( Mock::VerifyAndClearExpectations( &mock ) ); delete mock; } void -TestProxyLogger::testForwardLongMessage() +TestLogger::testForwardLongMessage() { - s_logger = new ProxyLogger(); - Amarok::MockLogger *mock = new Amarok::MockLogger(); - EXPECT_CALL( *mock, longMessage( _, _ ) ).Times( 1 ).WillOnce( Return() ); + EXPECT_CALL( *mock, longMessageImpl( _, _ ) ).Times( 1 ).WillOnce( Return() ); - s_logger->setLogger( mock ); - - s_logger->longMessage( "foo", Amarok::Logger::Information ); + Amarok::Logger::longMessage( "foo", Amarok::Logger::Information ); QTest::qWait( 20 ); QVERIFY( Mock::VerifyAndClearExpectations( &mock ) ); delete mock; } void -TestProxyLogger::testForwardProgressOperation() +TestLogger::testForwardProgressOperation() { - s_logger = new ProxyLogger(); - Amarok::MockLogger *mock = new Amarok::MockLogger(); EXPECT_CALL( *mock, newProgressOperationImpl( An(), _, _, _, _ ) ).Times( 1 ).WillOnce( Return() ); - s_logger->setLogger( mock ); - - s_logger->newProgressOperation( new DummyJob(), QString( "foo" ) ); + Amarok::Logger::newProgressOperation( new DummyJob(), QString( "foo" ) ); QTest::qWait( 20 ); QVERIFY( Mock::VerifyAndClearExpectations( &mock ) ); delete mock; } void -TestProxyLogger::testForwardShortMessage() +TestLogger::testForwardShortMessage() { - s_logger = new ProxyLogger(); - Amarok::MockLogger *mock = new Amarok::MockLogger(); - EXPECT_CALL( *mock, shortMessage( _ ) ).Times( 1 ).WillOnce( Return() ); - - s_logger->setLogger( mock ); + EXPECT_CALL( *mock, shortMessageImpl( _ ) ).Times( 1 ).WillOnce( Return() ); - s_logger->shortMessage( "foo" ); + Amarok::Logger::shortMessage( "foo" ); QTest::qWait( 20 ); QVERIFY( Mock::VerifyAndClearExpectations( &mock ) ); delete mock; } -#include "TestProxyLogger.moc" +#include "TestLogger.moc" diff --git a/tests/mocks/MockLogger.h b/tests/mocks/MockLogger.h --- a/tests/mocks/MockLogger.h +++ b/tests/mocks/MockLogger.h @@ -19,7 +19,7 @@ #include -#include "core/interfaces/Logger.h" +#include "core/logger/Logger.h" using ::testing::Return; using ::testing::An; @@ -32,15 +32,15 @@ public: MockLogger() : Amarok::Logger() { - ON_CALL( *this, shortMessage( _ ) ).WillByDefault( Return() ); - ON_CALL( *this, longMessage( _, _ ) ).WillByDefault( Return() ); + ON_CALL( *this, shortMessageImpl( _ ) ).WillByDefault( Return() ); + ON_CALL( *this, longMessageImpl( _, _ ) ).WillByDefault( Return() ); ON_CALL( *this, newProgressOperationImpl( An(), _, _, _, _ ) ).WillByDefault( Return() ); ON_CALL( *this, newProgressOperationImpl( An(), _, _, _, _ ) ).WillByDefault( Return() ); ON_CALL( *this, newProgressOperationImpl( An(), _, _, _, _, _, _, _ ) ).WillByDefault( Return() ); } - MOCK_METHOD1( shortMessage, void( const QString& ) ); - MOCK_METHOD2( longMessage, void( const QString&, Amarok::Logger::MessageType ) ); + MOCK_METHOD1( shortMessageImpl, void( const QString& ) ); + MOCK_METHOD2( longMessageImpl, void( const QString&, Amarok::Logger::MessageType ) ); MOCK_METHOD5( newProgressOperationImpl, void( KJob*, const QString&, QObject*, const std::function&, Qt::ConnectionType ) ); MOCK_METHOD5( newProgressOperationImpl, void( QNetworkReply*, const QString&, QObject*,