mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-09-16 08:52:28 +02:00
Compare commits
19 Commits
threadedau
...
0.3.1
Author | SHA1 | Date | |
---|---|---|---|
|
9a81ce8b89 | ||
|
c805d283d4 | ||
|
03379f361c | ||
|
c671c0e898 | ||
|
edaf49b4c5 | ||
|
682903b0cb | ||
|
53f7f599d5 | ||
|
cc669fc20f | ||
|
4e7496a38a | ||
|
5842cdceee | ||
|
b7e0be8d9d | ||
|
a203b60cbb | ||
|
2be08af321 | ||
|
ad4c229a6b | ||
|
b2e0206e34 | ||
|
743ae013ea | ||
|
767cf7c1b9 | ||
|
6be94ab81c | ||
|
b1ed304a61 |
@@ -16,7 +16,7 @@ SET( TOMAHAWK_DESCRIPTION_SUMMARY "The social media player" )
|
||||
|
||||
SET( TOMAHAWK_VERSION_MAJOR 0 )
|
||||
SET( TOMAHAWK_VERSION_MINOR 3 )
|
||||
SET( TOMAHAWK_VERSION_PATCH 99 )
|
||||
SET( TOMAHAWK_VERSION_PATCH 1 )
|
||||
|
||||
#SET( TOMAHAWK_VERSION_RC 0 )
|
||||
|
||||
@@ -211,6 +211,4 @@ ADD_SUBDIRECTORY( src/libtomahawk )
|
||||
SET( TOMAHAWK_LIBRARIES tomahawklib )
|
||||
ADD_SUBDIRECTORY( src )
|
||||
ADD_SUBDIRECTORY( admin )
|
||||
IF(BUILD_GUI)
|
||||
ADD_SUBDIRECTORY( src/breakpad/CrashReporter )
|
||||
ENDIF()
|
||||
ADD_SUBDIRECTORY( src/breakpad/CrashReporter )
|
||||
|
@@ -26,7 +26,7 @@ Version 0.3.0:
|
||||
* Added YouTube resolver.
|
||||
* Fixed bug where going offline then online would not re-connect to many
|
||||
peers.
|
||||
* Added support for auto-updating live XSPF playlists.
|
||||
* Added support for auto-updating live XSPF playlists.
|
||||
* Don't show an age of 41 years for tracks that have no age information.
|
||||
* Show config UI for resolvers that have them as soon as you add them.
|
||||
* Add support for Echo Nest Personal Catalogs and User Radio. Synchronize
|
||||
|
@@ -97,8 +97,8 @@ IF(LIBLASTFM_FOUND)
|
||||
ENDIF(LIBLASTFM_FOUND)
|
||||
|
||||
IF(LIBATTICA_FOUND)
|
||||
SET( tomahawkSourcesGui ${tomahawkSourcesGui} GetNewStuffDialog.cpp GetNewStuffDelegate.cpp GetNewStuffModel.cpp )
|
||||
SET( tomahawkHeadersGui ${tomahawkHeadersGui} GetNewStuffDialog.h GetNewStuffDelegate.h GetNewStuffModel.h )
|
||||
SET( tomahawkSources ${tomahawkSources} GetNewStuffDialog.cpp GetNewStuffDelegate.cpp GetNewStuffModel.cpp )
|
||||
SET( tomahawkHeaders ${tomahawkHeaders} GetNewStuffDialog.h GetNewStuffDelegate.h GetNewStuffModel.h )
|
||||
INCLUDE_DIRECTORIES( ${LIBATTICA_INCLUDE_DIR} )
|
||||
ENDIF(LIBATTICA_FOUND)
|
||||
|
||||
@@ -200,6 +200,10 @@ IF(QCA2_FOUND)
|
||||
INCLUDE_DIRECTORIES( ${QCA2_INCLUDE_DIR} )
|
||||
ENDIF(QCA2_FOUND)
|
||||
|
||||
kde4_add_app_icon( tomahawkSources "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" )
|
||||
qt4_add_resources( RC_SRCS "../resources.qrc" )
|
||||
qt4_wrap_cpp( tomahawkMoc ${tomahawkHeaders} )
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
@@ -207,17 +211,13 @@ include( ${CMAKE_SOURCE_DIR}/lang/translations.cmake )
|
||||
|
||||
SET( final_src ${final_src} ${tomahawkMoc} ${tomahawkSources} ${tomahawkHeaders} ${trans_outfile})
|
||||
|
||||
IF( BUILD_GUI )
|
||||
LIST(APPEND tomahawkHeaders ${tomahawkHeadersGui})
|
||||
LIST(APPEND tomahawkSources ${tomahawkSourcesGui})
|
||||
IF( "${gui}" STREQUAL "no" )
|
||||
ELSE()
|
||||
qt4_wrap_ui( tomahawkUI_H ${tomahawkUI} )
|
||||
qt4_wrap_cpp( tomahawkMocGui ${tomahawkHeadersGui} )
|
||||
SET( final_src ${final_src} ${tomahawkUI_H} ${tomahawkMocGui} ${tomahawkSourcesGui} ${RC_SRCS} )
|
||||
ENDIF()
|
||||
|
||||
kde4_add_app_icon( tomahawkSources "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" )
|
||||
qt4_add_resources( RC_SRCS "../resources.qrc" )
|
||||
qt4_wrap_cpp( tomahawkMoc ${tomahawkHeaders} )
|
||||
SET( final_src ${final_src} ${tomahawkUI_H} ${tomahawkMoc} ${tomahawkSources} ${RC_SRCS} )
|
||||
|
||||
IF( UNIX AND NOT APPLE )
|
||||
ADD_EXECUTABLE( tomahawk ${final_src} )
|
||||
ENDIF( UNIX AND NOT APPLE )
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#cmakedefine DEBUG_BUILD
|
||||
|
||||
#define CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}"
|
||||
#define CMAKE_INSTALL_LIBEXECDIR "${CMAKE_INSTALL_LIBEXECDIR}"
|
||||
#define CMAKE_SYSTEM "${CMAKE_SYSTEM}"
|
||||
|
||||
#cmakedefine LION
|
||||
|
@@ -52,8 +52,7 @@ public:
|
||||
setMinimumSize( sizeHint() );
|
||||
setMaximumSize( sizeHint() ); // to remove the resize grip on osx this is the only way
|
||||
|
||||
if( conf->metaObject()->indexOfSignal( "sizeHintChanged()" ) > -1 )
|
||||
connect( conf, SIGNAL( sizeHintChanged() ), this, SLOT( updateSizeHint() ) );
|
||||
connect( conf, SIGNAL( sizeHintChanged() ), this, SLOT( updateSizeHint() ) );
|
||||
#else
|
||||
m_widget->setVisible( true );
|
||||
#endif
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#ifdef ENABLE_HEADLESS
|
||||
|
||||
#define TOMAHAWK_APPLICATION QCoreApplication
|
||||
#include <QCoreApplication>
|
||||
#include <QApplication>
|
||||
|
||||
#else
|
||||
|
||||
|
@@ -12,260 +12,6 @@ add_definitions( ${QT_DEFINITIONS} )
|
||||
add_definitions( -DQT_SHARED )
|
||||
add_definitions( -DDLLEXPORT_PRO )
|
||||
|
||||
set( libGuiSources
|
||||
contextmenu.cpp
|
||||
dropjob.cpp
|
||||
globalactionmanager.cpp
|
||||
viewpage.cpp
|
||||
viewmanager.cpp
|
||||
|
||||
context/ContextPage.cpp
|
||||
context/ContextWidget.cpp
|
||||
context/pages/TopTracksContext.cpp
|
||||
context/pages/RelatedArtistsContext.cpp
|
||||
context/pages/WikipediaContext.cpp
|
||||
context/pages/WebContext.cpp
|
||||
|
||||
jobview/JobStatusView.cpp
|
||||
jobview/JobStatusModel.cpp
|
||||
jobview/JobStatusDelegate.cpp
|
||||
jobview/PipelineStatusItem.cpp
|
||||
jobview/TransferStatusItem.cpp
|
||||
jobview/LatchedStatusItem.cpp
|
||||
|
||||
infobar/infobar.cpp
|
||||
|
||||
infosystem/infoplugins/generic/echonestplugin.cpp
|
||||
infosystem/infoplugins/generic/lastfmplugin.cpp
|
||||
infosystem/infoplugins/generic/chartsplugin.cpp
|
||||
infosystem/infoplugins/generic/spotifyPlugin.cpp
|
||||
infosystem/infoplugins/generic/hypemPlugin.cpp
|
||||
infosystem/infoplugins/generic/musixmatchplugin.cpp
|
||||
infosystem/infoplugins/generic/musicbrainzPlugin.cpp
|
||||
infosystem/infoplugins/generic/RoviPlugin.cpp
|
||||
|
||||
playlist/treemodel.cpp
|
||||
playlist/treeproxymodel.cpp
|
||||
playlist/treeheader.cpp
|
||||
playlist/treeitemdelegate.cpp
|
||||
playlist/collectionproxymodel.cpp
|
||||
playlist/collectionflatmodel.cpp
|
||||
playlist/collectionview.cpp
|
||||
playlist/playlistmodel.cpp
|
||||
playlist/playlistproxymodel.cpp
|
||||
playlist/playlistview.cpp
|
||||
playlist/playlistitemdelegate.cpp
|
||||
playlist/queueproxymodel.cpp
|
||||
playlist/queueview.cpp
|
||||
playlist/trackmodel.cpp
|
||||
playlist/trackmodelitem.cpp
|
||||
playlist/trackproxymodel.cpp
|
||||
playlist/trackview.cpp
|
||||
playlist/trackheader.cpp
|
||||
playlist/treemodelitem.cpp
|
||||
playlist/albumitem.cpp
|
||||
playlist/albummodel.cpp
|
||||
playlist/albumproxymodel.cpp
|
||||
playlist/albumitemdelegate.cpp
|
||||
playlist/albumview.cpp
|
||||
playlist/artistview.cpp
|
||||
playlist/customplaylistview.cpp
|
||||
playlist/ViewHeader.cpp
|
||||
|
||||
playlist/dynamic/DynamicPlaylist.cpp
|
||||
playlist/dynamic/DynamicView.cpp
|
||||
playlist/dynamic/DynamicModel.cpp
|
||||
playlist/dynamic/echonest/EchonestGenerator.cpp
|
||||
playlist/dynamic/echonest/EchonestControl.cpp
|
||||
playlist/dynamic/echonest/EchonestSteerer.cpp
|
||||
playlist/dynamic/widgets/DynamicWidget.cpp
|
||||
playlist/dynamic/widgets/DynamicControlWrapper.cpp
|
||||
playlist/dynamic/widgets/DynamicControlList.cpp
|
||||
playlist/dynamic/widgets/ReadOrWriteWidget.cpp
|
||||
playlist/dynamic/widgets/MiscControlWidgets.cpp
|
||||
playlist/dynamic/widgets/CollapsibleControls.cpp
|
||||
playlist/dynamic/widgets/DynamicSetupWidget.cpp
|
||||
playlist/dynamic/widgets/LoadingSpinner.cpp
|
||||
|
||||
playlist/topbar/topbar.cpp
|
||||
playlist/topbar/clearbutton.cpp
|
||||
playlist/topbar/searchlineedit.cpp
|
||||
playlist/topbar/lineedit.cpp
|
||||
playlist/topbar/searchbutton.cpp
|
||||
|
||||
resolvers/scriptresolver.cpp
|
||||
resolvers/qtscriptresolver.cpp
|
||||
|
||||
sip/SipModel.cpp
|
||||
|
||||
utils/widgetdragfilter.cpp
|
||||
utils/xspfgenerator.cpp
|
||||
utils/jspfloader.cpp
|
||||
utils/spotifyparser.cpp
|
||||
utils/itunesparser.cpp
|
||||
utils/rdioparser.cpp
|
||||
utils/shortenedlinkparser.cpp
|
||||
utils/stylehelper.cpp
|
||||
utils/dropjobnotifier.cpp
|
||||
utils/proxystyle.cpp
|
||||
|
||||
widgets/checkdirtree.cpp
|
||||
widgets/querylabel.cpp
|
||||
widgets/imagebutton.cpp
|
||||
widgets/animatedsplitter.cpp
|
||||
widgets/elidedlabel.cpp
|
||||
widgets/newplaylistwidget.cpp
|
||||
widgets/searchwidget.cpp
|
||||
widgets/SeekSlider.cpp
|
||||
widgets/playlisttypeselectordlg.cpp
|
||||
widgets/welcomewidget.cpp
|
||||
widgets/whatshotwidget.cpp
|
||||
widgets/RecentlyPlayedPlaylistsModel.cpp
|
||||
widgets/RecentPlaylistsModel.cpp
|
||||
widgets/OverlayButton.cpp
|
||||
widgets/overlaywidget.cpp
|
||||
widgets/HeaderLabel.cpp
|
||||
widgets/HeaderWidget.cpp
|
||||
widgets/combobox.cpp
|
||||
widgets/ToggleButton.cpp
|
||||
widgets/SocialPlaylistWidget.cpp
|
||||
widgets/infowidgets/sourceinfowidget.cpp
|
||||
widgets/infowidgets/ArtistInfoWidget.cpp
|
||||
widgets/infowidgets/AlbumInfoWidget.cpp
|
||||
widgets/Breadcrumb.cpp
|
||||
widgets/BreadcrumbButton.cpp
|
||||
)
|
||||
|
||||
set( libGuiHeaders
|
||||
contextmenu.h
|
||||
dropjob.h
|
||||
viewpage.h
|
||||
viewmanager.h
|
||||
globalactionmanager.h
|
||||
|
||||
context/ContextPage.h
|
||||
context/ContextWidget.h
|
||||
context/pages/TopTracksContext.h
|
||||
context/pages/RelatedArtistsContext.h
|
||||
context/pages/WikipediaContext.h
|
||||
context/pages/WebContext.h
|
||||
|
||||
infobar/infobar.h
|
||||
|
||||
infosystem/infoplugins/generic/echonestplugin.h
|
||||
infosystem/infoplugins/generic/lastfmplugin.h
|
||||
infosystem/infoplugins/generic/chartsplugin.h
|
||||
infosystem/infoplugins/generic/spotifyPlugin.h
|
||||
infosystem/infoplugins/generic/hypemPlugin.h
|
||||
infosystem/infoplugins/generic/musixmatchplugin.h
|
||||
infosystem/infoplugins/generic/musicbrainzPlugin.h
|
||||
infosystem/infoplugins/generic/RoviPlugin.h
|
||||
|
||||
playlist/topbar/topbar.h
|
||||
playlist/topbar/clearbutton.h
|
||||
playlist/topbar/searchlineedit.h
|
||||
playlist/topbar/lineedit.h
|
||||
playlist/topbar/lineedit_p.h
|
||||
playlist/topbar/searchbutton.h
|
||||
|
||||
playlist/treemodel.h
|
||||
playlist/treeproxymodel.h
|
||||
playlist/treeheader.h
|
||||
playlist/treeitemdelegate.h
|
||||
playlist/collectionproxymodel.h
|
||||
playlist/collectionflatmodel.h
|
||||
playlist/collectionview.h
|
||||
playlist/playlistmodel.h
|
||||
playlist/playlistproxymodel.h
|
||||
playlist/playlistview.h
|
||||
playlist/playlistitemdelegate.h
|
||||
playlist/queueproxymodel.h
|
||||
playlist/queueview.h
|
||||
playlist/trackmodel.h
|
||||
playlist/trackmodelitem.h
|
||||
playlist/trackproxymodel.h
|
||||
playlist/trackview.h
|
||||
playlist/trackheader.h
|
||||
playlist/treemodelitem.h
|
||||
playlist/albumitem.h
|
||||
playlist/albummodel.h
|
||||
playlist/albumproxymodel.h
|
||||
playlist/albumitemdelegate.h
|
||||
playlist/albumview.h
|
||||
playlist/artistview.h
|
||||
playlist/customplaylistview.h
|
||||
playlist/ViewHeader.h
|
||||
|
||||
playlist/dynamic/DynamicPlaylist.h
|
||||
playlist/dynamic/GeneratorInterface.h
|
||||
playlist/dynamic/DynamicView.h
|
||||
playlist/dynamic/DynamicModel.h
|
||||
playlist/dynamic/echonest/EchonestGenerator.h
|
||||
playlist/dynamic/echonest/EchonestControl.h
|
||||
playlist/dynamic/echonest/EchonestSteerer.h
|
||||
playlist/dynamic/widgets/DynamicWidget.h
|
||||
playlist/dynamic/widgets/DynamicControlWrapper.h
|
||||
playlist/dynamic/widgets/DynamicControlList.h
|
||||
playlist/dynamic/widgets/ReadOrWriteWidget.h
|
||||
playlist/dynamic/widgets/MiscControlWidgets.h
|
||||
playlist/dynamic/widgets/CollapsibleControls.h
|
||||
playlist/dynamic/widgets/DynamicSetupWidget.h
|
||||
playlist/dynamic/widgets/LoadingSpinner.h
|
||||
|
||||
resolvers/scriptresolver.h
|
||||
resolvers/qtscriptresolver.h
|
||||
|
||||
sip/SipModel.h
|
||||
|
||||
utils/widgetdragfilter.h
|
||||
utils/xspfgenerator.h
|
||||
utils/jspfloader.h
|
||||
utils/spotifyparser.h
|
||||
utils/itunesparser.h
|
||||
utils/rdioparser.h
|
||||
utils/shortenedlinkparser.h
|
||||
utils/dropjobnotifier.h
|
||||
|
||||
widgets/checkdirtree.h
|
||||
widgets/querylabel.h
|
||||
widgets/animatedcounterlabel.h
|
||||
widgets/imagebutton.h
|
||||
widgets/animatedsplitter.h
|
||||
widgets/elidedlabel.h
|
||||
widgets/newplaylistwidget.h
|
||||
widgets/searchwidget.h
|
||||
widgets/SeekSlider.h
|
||||
widgets/playlisttypeselectordlg.h
|
||||
widgets/welcomewidget.h
|
||||
widgets/whatshotwidget.h
|
||||
widgets/RecentlyPlayedPlaylistsModel.h
|
||||
widgets/RecentPlaylistsModel.h
|
||||
widgets/OverlayButton.h
|
||||
widgets/overlaywidget.h
|
||||
widgets/HeaderLabel.h
|
||||
widgets/HeaderWidget.h
|
||||
widgets/combobox.h
|
||||
widgets/ToggleButton.h
|
||||
widgets/SocialPlaylistWidget.h
|
||||
widgets/infowidgets/sourceinfowidget.h
|
||||
widgets/infowidgets/ArtistInfoWidget.h
|
||||
widgets/infowidgets/ArtistInfoWidget_p.h
|
||||
widgets/infowidgets/AlbumInfoWidget.h
|
||||
widgets/Breadcrumb.h
|
||||
widgets/BreadcrumbButton.h
|
||||
|
||||
jobview/JobStatusView.h
|
||||
jobview/JobStatusModel.h
|
||||
jobview/JobStatusDelegate.h
|
||||
jobview/JobStatusItem.h
|
||||
jobview/PipelineStatusItem.h
|
||||
jobview/TransferStatusItem.h
|
||||
jobview/LatchedStatusItem.h
|
||||
|
||||
thirdparty/Qocoa/qsearchfield.h
|
||||
|
||||
)
|
||||
|
||||
set( libSources
|
||||
tomahawksettings.cpp
|
||||
sourcelist.cpp
|
||||
@@ -282,6 +28,11 @@ set( libSources
|
||||
result.cpp
|
||||
source.cpp
|
||||
sourceplaylistinterface.cpp
|
||||
viewpage.cpp
|
||||
viewmanager.cpp
|
||||
globalactionmanager.cpp
|
||||
contextmenu.cpp
|
||||
dropjob.cpp
|
||||
playlistinterface.cpp
|
||||
LatchManager.cpp
|
||||
|
||||
@@ -289,10 +40,17 @@ set( libSources
|
||||
|
||||
sip/SipPlugin.cpp
|
||||
sip/SipHandler.cpp
|
||||
sip/SipModel.cpp
|
||||
sip/sipinfo.cpp
|
||||
|
||||
audio/audioengine.cpp
|
||||
audio/audioenginethread.cpp
|
||||
|
||||
context/ContextPage.cpp
|
||||
context/ContextWidget.cpp
|
||||
context/pages/TopTracksContext.cpp
|
||||
context/pages/RelatedArtistsContext.cpp
|
||||
context/pages/WikipediaContext.cpp
|
||||
context/pages/WebContext.cpp
|
||||
|
||||
database/database.cpp
|
||||
database/fuzzyindex.cpp
|
||||
@@ -346,9 +104,79 @@ set( libSources
|
||||
database/databasecommand_settrackattributes.cpp
|
||||
database/database.cpp
|
||||
|
||||
infosystem/infosystem.cpp
|
||||
infobar/infobar.cpp
|
||||
|
||||
infosystem/infosystemcache.cpp
|
||||
infosystem/infosystem.cpp
|
||||
infosystem/infosystemworker.cpp
|
||||
infosystem/infoplugins/generic/echonestplugin.cpp
|
||||
infosystem/infoplugins/generic/lastfmplugin.cpp
|
||||
infosystem/infoplugins/generic/chartsplugin.cpp
|
||||
infosystem/infoplugins/generic/spotifyPlugin.cpp
|
||||
infosystem/infoplugins/generic/hypemPlugin.cpp
|
||||
infosystem/infoplugins/generic/musixmatchplugin.cpp
|
||||
infosystem/infoplugins/generic/musicbrainzPlugin.cpp
|
||||
infosystem/infoplugins/generic/RoviPlugin.cpp
|
||||
|
||||
playlist/treemodel.cpp
|
||||
playlist/treeproxymodel.cpp
|
||||
playlist/treeheader.cpp
|
||||
playlist/treeitemdelegate.cpp
|
||||
playlist/collectionproxymodel.cpp
|
||||
playlist/collectionflatmodel.cpp
|
||||
playlist/collectionview.cpp
|
||||
playlist/playlistmodel.cpp
|
||||
playlist/playlistproxymodel.cpp
|
||||
playlist/playlistview.cpp
|
||||
playlist/playlistitemdelegate.cpp
|
||||
playlist/queueproxymodel.cpp
|
||||
playlist/queueview.cpp
|
||||
playlist/trackmodel.cpp
|
||||
playlist/trackmodelitem.cpp
|
||||
playlist/trackproxymodel.cpp
|
||||
playlist/trackview.cpp
|
||||
playlist/trackheader.cpp
|
||||
playlist/treemodelitem.cpp
|
||||
playlist/albumitem.cpp
|
||||
playlist/albummodel.cpp
|
||||
playlist/albumproxymodel.cpp
|
||||
playlist/albumitemdelegate.cpp
|
||||
playlist/albumview.cpp
|
||||
playlist/artistview.cpp
|
||||
playlist/customplaylistview.cpp
|
||||
playlist/ViewHeader.cpp
|
||||
playlist/PlaylistUpdaterInterface.cpp
|
||||
playlist/XspfUpdater.cpp
|
||||
|
||||
playlist/topbar/topbar.cpp
|
||||
playlist/topbar/clearbutton.cpp
|
||||
playlist/topbar/searchlineedit.cpp
|
||||
playlist/topbar/lineedit.cpp
|
||||
playlist/topbar/searchbutton.cpp
|
||||
|
||||
playlist/dynamic/DynamicPlaylist.cpp
|
||||
playlist/dynamic/DynamicControl.cpp
|
||||
playlist/dynamic/GeneratorFactory.cpp
|
||||
playlist/dynamic/GeneratorInterface.cpp
|
||||
playlist/dynamic/DynamicView.cpp
|
||||
playlist/dynamic/DynamicModel.cpp
|
||||
playlist/dynamic/DynamicPlaylistRevision.cpp
|
||||
playlist/dynamic/echonest/EchonestGenerator.cpp
|
||||
playlist/dynamic/echonest/EchonestControl.cpp
|
||||
playlist/dynamic/echonest/EchonestSteerer.cpp
|
||||
playlist/dynamic/widgets/DynamicWidget.cpp
|
||||
playlist/dynamic/widgets/DynamicControlWrapper.cpp
|
||||
playlist/dynamic/widgets/DynamicControlList.cpp
|
||||
playlist/dynamic/widgets/ReadOrWriteWidget.cpp
|
||||
playlist/dynamic/widgets/MiscControlWidgets.cpp
|
||||
playlist/dynamic/widgets/CollapsibleControls.cpp
|
||||
playlist/dynamic/widgets/DynamicSetupWidget.cpp
|
||||
playlist/dynamic/widgets/LoadingSpinner.cpp
|
||||
playlist/dynamic/database/DatabaseControl.cpp
|
||||
playlist/dynamic/database/DatabaseGenerator.cpp
|
||||
|
||||
resolvers/scriptresolver.cpp
|
||||
resolvers/qtscriptresolver.cpp
|
||||
|
||||
network/bufferiodevice.cpp
|
||||
network/msgprocessor.cpp
|
||||
@@ -360,20 +188,53 @@ set( libSources
|
||||
network/connection.cpp
|
||||
network/controlconnection.cpp
|
||||
|
||||
playlist/PlaylistUpdaterInterface.cpp
|
||||
playlist/dynamic/DynamicPlaylist.cpp
|
||||
playlist/dynamic/GeneratorFactory.cpp
|
||||
playlist/dynamic/GeneratorInterface.cpp
|
||||
playlist/dynamic/DynamicPlaylistRevision.cpp
|
||||
playlist/XspfUpdater.cpp
|
||||
playlist/dynamic/database/DatabaseGenerator.cpp
|
||||
playlist/dynamic/database/DatabaseControl.cpp
|
||||
playlist/dynamic/DynamicControl.cpp
|
||||
|
||||
utils/tomahawkutils.cpp
|
||||
utils/logger.cpp
|
||||
utils/qnr_iodevicestream.cpp
|
||||
utils/proxystyle.cpp
|
||||
utils/widgetdragfilter.cpp
|
||||
utils/xspfloader.cpp
|
||||
utils/xspfgenerator.cpp
|
||||
utils/jspfloader.cpp
|
||||
utils/spotifyparser.cpp
|
||||
utils/itunesparser.cpp
|
||||
utils/rdioparser.cpp
|
||||
utils/shortenedlinkparser.cpp
|
||||
utils/stylehelper.cpp
|
||||
utils/qnr_iodevicestream.cpp
|
||||
utils/dropjobnotifier.cpp
|
||||
|
||||
widgets/checkdirtree.cpp
|
||||
widgets/querylabel.cpp
|
||||
widgets/imagebutton.cpp
|
||||
widgets/animatedsplitter.cpp
|
||||
widgets/elidedlabel.cpp
|
||||
widgets/newplaylistwidget.cpp
|
||||
widgets/searchwidget.cpp
|
||||
widgets/SeekSlider.cpp
|
||||
widgets/playlisttypeselectordlg.cpp
|
||||
widgets/welcomewidget.cpp
|
||||
widgets/whatshotwidget.cpp
|
||||
widgets/RecentlyPlayedPlaylistsModel.cpp
|
||||
widgets/RecentPlaylistsModel.cpp
|
||||
widgets/OverlayButton.cpp
|
||||
widgets/overlaywidget.cpp
|
||||
widgets/HeaderLabel.cpp
|
||||
widgets/HeaderWidget.cpp
|
||||
widgets/combobox.cpp
|
||||
widgets/ToggleButton.cpp
|
||||
widgets/SocialPlaylistWidget.cpp
|
||||
widgets/infowidgets/sourceinfowidget.cpp
|
||||
widgets/infowidgets/ArtistInfoWidget.cpp
|
||||
widgets/infowidgets/AlbumInfoWidget.cpp
|
||||
widgets/Breadcrumb.cpp
|
||||
widgets/BreadcrumbButton.cpp
|
||||
|
||||
jobview/JobStatusView.cpp
|
||||
jobview/JobStatusModel.cpp
|
||||
jobview/JobStatusDelegate.cpp
|
||||
jobview/PipelineStatusItem.cpp
|
||||
jobview/TransferStatusItem.cpp
|
||||
jobview/LatchedStatusItem.cpp
|
||||
|
||||
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.cpp
|
||||
thirdparty/kdsingleapplicationguard/kdsharedmemorylocker.cpp
|
||||
@@ -395,6 +256,11 @@ set( libHeaders
|
||||
result.h
|
||||
source.h
|
||||
sourceplaylistinterface.h
|
||||
viewmanager.h
|
||||
globalactionmanager.h
|
||||
contextmenu.h
|
||||
dropjob.h
|
||||
AtticaManager.h
|
||||
LatchManager.h
|
||||
|
||||
artist.h
|
||||
@@ -405,10 +271,17 @@ set( libHeaders
|
||||
|
||||
sip/SipPlugin.h
|
||||
sip/SipHandler.h
|
||||
sip/SipModel.h
|
||||
sip/sipinfo.h
|
||||
|
||||
audio/audioengine.h
|
||||
audio/audioenginethread.h
|
||||
|
||||
context/ContextPage.h
|
||||
context/ContextWidget.h
|
||||
context/pages/TopTracksContext.h
|
||||
context/pages/RelatedArtistsContext.h
|
||||
context/pages/WikipediaContext.h
|
||||
context/pages/WebContext.h
|
||||
|
||||
database/database.h
|
||||
database/fuzzyindex.h
|
||||
@@ -461,10 +334,19 @@ set( libHeaders
|
||||
database/databasecommand_trackattributes.h
|
||||
database/databasecommand_settrackattributes.h
|
||||
|
||||
infosystem/infosystem.h
|
||||
infobar/infobar.h
|
||||
|
||||
infosystem/infosystem.h
|
||||
infosystem/infosystemworker.h
|
||||
infosystem/infosystemcache.h
|
||||
infosystem/infoplugins/generic/echonestplugin.h
|
||||
infosystem/infoplugins/generic/lastfmplugin.h
|
||||
infosystem/infoplugins/generic/chartsplugin.h
|
||||
infosystem/infoplugins/generic/spotifyPlugin.h
|
||||
infosystem/infoplugins/generic/hypemPlugin.h
|
||||
infosystem/infoplugins/generic/musixmatchplugin.h
|
||||
infosystem/infoplugins/generic/musicbrainzPlugin.h
|
||||
infosystem/infoplugins/generic/RoviPlugin.h
|
||||
|
||||
network/bufferiodevice.h
|
||||
network/msgprocessor.h
|
||||
@@ -476,24 +358,124 @@ set( libHeaders
|
||||
network/controlconnection.h
|
||||
network/portfwdthread.h
|
||||
|
||||
playlist/treemodel.h
|
||||
playlist/treeproxymodel.h
|
||||
playlist/treeheader.h
|
||||
playlist/treeitemdelegate.h
|
||||
playlist/collectionproxymodel.h
|
||||
playlist/collectionflatmodel.h
|
||||
playlist/collectionview.h
|
||||
playlist/playlistmodel.h
|
||||
playlist/playlistproxymodel.h
|
||||
playlist/playlistview.h
|
||||
playlist/playlistitemdelegate.h
|
||||
playlist/queueproxymodel.h
|
||||
playlist/queueview.h
|
||||
playlist/trackmodel.h
|
||||
playlist/trackmodelitem.h
|
||||
playlist/trackproxymodel.h
|
||||
playlist/trackview.h
|
||||
playlist/trackheader.h
|
||||
playlist/treemodelitem.h
|
||||
playlist/albumitem.h
|
||||
playlist/albummodel.h
|
||||
playlist/albumproxymodel.h
|
||||
playlist/albumitemdelegate.h
|
||||
playlist/albumview.h
|
||||
playlist/artistview.h
|
||||
playlist/customplaylistview.h
|
||||
playlist/ViewHeader.h
|
||||
playlist/PlaylistUpdaterInterface.h
|
||||
playlist/dynamic/DynamicPlaylist.h
|
||||
playlist/dynamic/GeneratorInterface.h
|
||||
playlist/dynamic/GeneratorFactory.h
|
||||
playlist/XspfUpdater.h
|
||||
playlist/dynamic/database/DatabaseGenerator.h
|
||||
playlist/dynamic/database/DatabaseControl.h
|
||||
|
||||
playlist/topbar/topbar.h
|
||||
playlist/topbar/clearbutton.h
|
||||
playlist/topbar/searchlineedit.h
|
||||
playlist/topbar/lineedit.h
|
||||
playlist/topbar/lineedit_p.h
|
||||
playlist/topbar/searchbutton.h
|
||||
|
||||
playlist/dynamic/DynamicPlaylist.h
|
||||
playlist/dynamic/DynamicControl.h
|
||||
playlist/dynamic/GeneratorInterface.h
|
||||
playlist/dynamic/DynamicView.h
|
||||
playlist/dynamic/DynamicModel.h
|
||||
playlist/dynamic/echonest/EchonestGenerator.h
|
||||
playlist/dynamic/echonest/EchonestControl.h
|
||||
playlist/dynamic/echonest/EchonestSteerer.h
|
||||
playlist/dynamic/widgets/DynamicWidget.h
|
||||
playlist/dynamic/widgets/DynamicControlWrapper.h
|
||||
playlist/dynamic/widgets/DynamicControlList.h
|
||||
playlist/dynamic/widgets/ReadOrWriteWidget.h
|
||||
playlist/dynamic/widgets/MiscControlWidgets.h
|
||||
playlist/dynamic/widgets/CollapsibleControls.h
|
||||
playlist/dynamic/widgets/DynamicSetupWidget.h
|
||||
playlist/dynamic/widgets/LoadingSpinner.h
|
||||
playlist/dynamic/database/DatabaseControl.h
|
||||
playlist/dynamic/database/DatabaseGenerator.h
|
||||
|
||||
resolvers/scriptresolver.h
|
||||
resolvers/qtscriptresolver.h
|
||||
|
||||
utils/widgetdragfilter.h
|
||||
utils/xspfloader.h
|
||||
utils/xspfgenerator.h
|
||||
utils/jspfloader.h
|
||||
utils/spotifyparser.h
|
||||
utils/itunesparser.h
|
||||
utils/rdioparser.h
|
||||
utils/shortenedlinkparser.h
|
||||
utils/qnr_iodevicestream.h
|
||||
utils/dropjobnotifier.h
|
||||
|
||||
widgets/checkdirtree.h
|
||||
widgets/querylabel.h
|
||||
widgets/animatedcounterlabel.h
|
||||
widgets/imagebutton.h
|
||||
widgets/animatedsplitter.h
|
||||
widgets/elidedlabel.h
|
||||
widgets/newplaylistwidget.h
|
||||
widgets/searchwidget.h
|
||||
widgets/SeekSlider.h
|
||||
widgets/playlisttypeselectordlg.h
|
||||
widgets/welcomewidget.h
|
||||
widgets/whatshotwidget.h
|
||||
widgets/RecentlyPlayedPlaylistsModel.h
|
||||
widgets/RecentPlaylistsModel.h
|
||||
widgets/OverlayButton.h
|
||||
widgets/overlaywidget.h
|
||||
widgets/HeaderLabel.h
|
||||
widgets/HeaderWidget.h
|
||||
widgets/combobox.h
|
||||
widgets/ToggleButton.h
|
||||
widgets/SocialPlaylistWidget.h
|
||||
widgets/infowidgets/sourceinfowidget.h
|
||||
widgets/infowidgets/ArtistInfoWidget.h
|
||||
widgets/infowidgets/ArtistInfoWidget_p.h
|
||||
widgets/infowidgets/AlbumInfoWidget.h
|
||||
widgets/Breadcrumb.h
|
||||
widgets/BreadcrumbButton.h
|
||||
|
||||
jobview/JobStatusView.h
|
||||
jobview/JobStatusModel.h
|
||||
jobview/JobStatusDelegate.h
|
||||
jobview/JobStatusItem.h
|
||||
jobview/PipelineStatusItem.h
|
||||
jobview/TransferStatusItem.h
|
||||
jobview/LatchedStatusItem.h
|
||||
|
||||
thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h
|
||||
|
||||
utils/xspfloader.h
|
||||
utils/qnr_iodevicestream.h
|
||||
thirdparty/Qocoa/qsearchfield.h
|
||||
)
|
||||
|
||||
set( libHeaders_NoMOC
|
||||
viewpage.h
|
||||
|
||||
infosystem/infoplugins/unix/imageconverter.h
|
||||
|
||||
playlist/dynamic/GeneratorInterface.h
|
||||
playlist/dynamic/GeneratorFactory.h
|
||||
|
||||
utils/tomahawkutils.h
|
||||
)
|
||||
|
||||
@@ -535,20 +517,20 @@ IF(QCA2_FOUND)
|
||||
ENDIF(QCA2_FOUND)
|
||||
|
||||
IF(LIBATTICA_FOUND)
|
||||
SET( libGuiSources ${libGuiSources} AtticaManager.cpp )
|
||||
SET( libGuiHeaders ${libGuiHeaders} AtticaManager.h )
|
||||
SET( libSources ${libSources} AtticaManager.cpp )
|
||||
SET( libHeaders ${libHeaders} AtticaManager.h )
|
||||
INCLUDE_DIRECTORIES( ${LIBATTICA_INCLUDE_DIR} )
|
||||
ENDIF(LIBATTICA_FOUND)
|
||||
|
||||
IF( UNIX AND NOT APPLE )
|
||||
SET( libGuiSources ${libGuiSources}
|
||||
SET( libSources ${libSources}
|
||||
infosystem/infoplugins/unix/mprispluginrootadaptor.cpp
|
||||
infosystem/infoplugins/unix/mprispluginplayeradaptor.cpp
|
||||
infosystem/infoplugins/unix/mprisplugin.cpp
|
||||
infosystem/infoplugins/unix/fdonotifyplugin.cpp
|
||||
infosystem/infoplugins/unix/imageconverter.cpp )
|
||||
|
||||
SET( libGuiHeaders ${libGuiHeaders}
|
||||
SET( libHeaders ${libHeaders}
|
||||
infosystem/infoplugins/unix/mprispluginrootadaptor.h
|
||||
infosystem/infoplugins/unix/mprispluginplayeradaptor.h
|
||||
infosystem/infoplugins/unix/mprisplugin.h
|
||||
@@ -602,18 +584,13 @@ IF( APPLE )
|
||||
/System/Library/Frameworks/AppKit.framework
|
||||
)
|
||||
ELSE( APPLE )
|
||||
SET( libGuiSources ${libGuiSources} thirdparty/Qocoa/qsearchfield.cpp )
|
||||
SET( libSources ${libSources} thirdparty/Qocoa/qsearchfield.cpp )
|
||||
ENDIF( APPLE )
|
||||
|
||||
IF(LIBLASTFM_FOUND)
|
||||
SET(LINK_LIBRARIES ${LINK_LIBRARIES} tomahawk_lastfm2 )
|
||||
ENDIF(LIBLASTFM_FOUND)
|
||||
|
||||
IF(BUILD_GUI)
|
||||
LIST(APPEND libSources ${libGuiSources} )
|
||||
LIST(APPEND libHeaders ${libGuiHeaders} )
|
||||
ENDIF()
|
||||
|
||||
qt4_wrap_ui( libUI_H ${libUI} )
|
||||
qt4_wrap_cpp( libMoc ${libHeaders} )
|
||||
|
||||
|
@@ -100,14 +100,12 @@ AudioEngine::~AudioEngine()
|
||||
|
||||
delete m_audioOutput;
|
||||
delete m_mediaObject;
|
||||
s_instance = 0;
|
||||
}
|
||||
|
||||
|
||||
QStringList
|
||||
AudioEngine::supportedMimeTypes() const
|
||||
{
|
||||
QMutexLocker locker( &m_mimeTypeMutex );
|
||||
if ( m_supportedMimeTypes.isEmpty() )
|
||||
{
|
||||
m_supportedMimeTypes = Phonon::BackendCapabilities::availableMimeTypes();
|
||||
@@ -123,13 +121,7 @@ AudioEngine::supportedMimeTypes() const
|
||||
void
|
||||
AudioEngine::playPause()
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "playPause" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_mediaObject->state() == Phonon::PlayingState )
|
||||
if ( isPlaying() )
|
||||
pause();
|
||||
else
|
||||
play();
|
||||
@@ -139,21 +131,14 @@ AudioEngine::playPause()
|
||||
void
|
||||
AudioEngine::play()
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "play" );
|
||||
return;
|
||||
}
|
||||
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
|
||||
if ( m_mediaObject->state() == Phonon::PausedState )
|
||||
if ( isPaused() )
|
||||
{
|
||||
m_mediaObject->play();
|
||||
emit resumed();
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
|
||||
QMutexLocker locker( &m_currentTrackMutex );
|
||||
trackInfo["title"] = m_currentTrack->track();
|
||||
trackInfo["artist"] = m_currentTrack->artist()->name();
|
||||
trackInfo["album"] = m_currentTrack->album()->name();
|
||||
@@ -169,12 +154,6 @@ AudioEngine::play()
|
||||
void
|
||||
AudioEngine::pause()
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "pause" );
|
||||
return;
|
||||
}
|
||||
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
|
||||
m_mediaObject->pause();
|
||||
@@ -187,15 +166,8 @@ AudioEngine::pause()
|
||||
void
|
||||
AudioEngine::stop()
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "stop" );
|
||||
return;
|
||||
}
|
||||
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
QMutexLocker locker( &m_playlistMutex );
|
||||
if ( m_mediaObject->state() == Phonon::StoppedState )
|
||||
if ( isStopped() )
|
||||
return;
|
||||
|
||||
setState( Stopped );
|
||||
@@ -203,11 +175,8 @@ AudioEngine::stop()
|
||||
|
||||
if ( !m_playlist.isNull() )
|
||||
m_playlist.data()->reset();
|
||||
|
||||
m_currentTrackMutex.lock();
|
||||
if ( !m_currentTrack.isNull() )
|
||||
emit timerPercentage( ( (double)m_timeElapsed / (double)m_currentTrack->duration() ) * 100.0 );
|
||||
m_currentTrackMutex.unlock();
|
||||
|
||||
emit stopped();
|
||||
setCurrentTrack( Tomahawk::result_ptr() );
|
||||
@@ -233,12 +202,6 @@ AudioEngine::stop()
|
||||
void
|
||||
AudioEngine::previous()
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "previous" );
|
||||
return;
|
||||
}
|
||||
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
|
||||
if ( canGoPrevious() )
|
||||
@@ -249,12 +212,6 @@ AudioEngine::previous()
|
||||
void
|
||||
AudioEngine::next()
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "next" );
|
||||
return;
|
||||
}
|
||||
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
|
||||
if ( canGoNext() )
|
||||
@@ -266,9 +223,6 @@ bool
|
||||
AudioEngine::canGoNext()
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||
QMutexLocker plocker( &m_playlistMutex );
|
||||
QMutexLocker qlocker( &m_queueMutex );
|
||||
QMutexLocker ctlocker( &m_currentTrackMutex );
|
||||
|
||||
if ( m_queue && m_queue->trackCount() )
|
||||
return true;
|
||||
@@ -296,7 +250,6 @@ AudioEngine::canGoNext()
|
||||
bool
|
||||
AudioEngine::canGoPrevious()
|
||||
{
|
||||
QMutexLocker locker( &m_playlistMutex );
|
||||
if ( m_playlist.isNull() )
|
||||
return false;
|
||||
|
||||
@@ -311,7 +264,6 @@ AudioEngine::canGoPrevious()
|
||||
bool
|
||||
AudioEngine::canSeek()
|
||||
{
|
||||
QMutexLocker locker( &m_playlistMutex );
|
||||
bool phononCanSeek = true;
|
||||
/* TODO: When phonon properly reports this, re-enable it
|
||||
if ( m_mediaObject && m_mediaObject->isValid() )
|
||||
@@ -324,19 +276,13 @@ AudioEngine::canSeek()
|
||||
void
|
||||
AudioEngine::seek( qint64 ms )
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "seek", Q_ARG( qint64, ms ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !canSeek() )
|
||||
{
|
||||
tDebug( LOGEXTRA ) << "Could not seek!";
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_mediaObject->state() == Phonon::PlayingState || m_mediaObject->state() == Phonon::PausedState )
|
||||
if ( isPlaying() || isPaused() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << ms;
|
||||
m_mediaObject->seek( ms );
|
||||
@@ -355,12 +301,6 @@ AudioEngine::seek( int ms )
|
||||
void
|
||||
AudioEngine::setVolume( int percentage )
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "setVolume", Q_ARG( int, percentage ) );
|
||||
return;
|
||||
}
|
||||
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << percentage;
|
||||
|
||||
percentage = qBound( 0, percentage, 100 );
|
||||
@@ -368,27 +308,6 @@ AudioEngine::setVolume( int percentage )
|
||||
emit volumeChanged( percentage );
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngine::lowerVolume()
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "lowerVolume" );
|
||||
return;
|
||||
}
|
||||
setVolume( volume() - AUDIO_VOLUME_STEP );
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngine::raiseVolume()
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "raiseVolume" );
|
||||
return;
|
||||
}
|
||||
setVolume( volume() + AUDIO_VOLUME_STEP );
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngine::mute()
|
||||
@@ -424,7 +343,6 @@ AudioEngine::sendNowPlayingNotification()
|
||||
m_infoSystemConnected = true;
|
||||
}
|
||||
|
||||
QMutexLocker locker( &m_currentTrackMutex );
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
trackInfo["artist"] = m_currentTrack->album()->artist()->name();
|
||||
trackInfo["album"] = m_currentTrack->album()->name();
|
||||
@@ -442,7 +360,6 @@ AudioEngine::sendNowPlayingNotification()
|
||||
void
|
||||
AudioEngine::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||
{
|
||||
QMutexLocker locker( &m_currentTrackMutex );
|
||||
if ( requestData.caller != s_aeInfoIdentifier ||
|
||||
requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
|
||||
{
|
||||
@@ -516,7 +433,6 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
setCurrentTrack( result );
|
||||
|
||||
QMutexLocker locker( &m_currentTrackMutex );
|
||||
if ( !isHttpResult( m_currentTrack->url() ) && !isLocalResult( m_currentTrack->url() ) )
|
||||
{
|
||||
io = Servent::instance()->getIODeviceForUrl( m_currentTrack );
|
||||
@@ -531,10 +447,12 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
|
||||
if ( !err )
|
||||
{
|
||||
QMutexLocker locker( &m_currentTrackMutex );
|
||||
tLog() << "Starting new song:" << m_currentTrack->url();
|
||||
emit loading( m_currentTrack );
|
||||
|
||||
if ( QNetworkReply* qnr_io = qobject_cast< QNetworkReply* >( io.data() ) )
|
||||
connect( qnr_io, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( ioStreamError( QNetworkReply::NetworkError ) ) );
|
||||
|
||||
if ( !isHttpResult( m_currentTrack->url() ) && !isLocalResult( m_currentTrack->url() ) )
|
||||
{
|
||||
if ( QNetworkReply* qnr_io = qobject_cast< QNetworkReply* >( io.data() ) )
|
||||
@@ -615,8 +533,7 @@ void
|
||||
AudioEngine::loadPreviousTrack()
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
QMutexLocker locker( &m_playlistMutex );
|
||||
|
||||
|
||||
if ( m_playlist.isNull() )
|
||||
{
|
||||
stop();
|
||||
@@ -635,8 +552,6 @@ void
|
||||
AudioEngine::loadNextTrack()
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
QMutexLocker plocker( &m_playlistMutex );
|
||||
QMutexLocker qlocker( &m_queueMutex );
|
||||
|
||||
Tomahawk::result_ptr result;
|
||||
|
||||
@@ -649,9 +564,7 @@ AudioEngine::loadNextTrack()
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO << "Loading playlist's next item";
|
||||
result = m_playlist.data()->nextItem();
|
||||
m_currentTrackPlaylistMutex.lock();
|
||||
m_currentTrackPlaylist = m_playlist;
|
||||
m_currentTrackPlaylistMutex.unlock();
|
||||
}
|
||||
|
||||
if ( !result.isNull() )
|
||||
@@ -672,35 +585,36 @@ AudioEngine::loadNextTrack()
|
||||
void
|
||||
AudioEngine::playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::result_ptr& result )
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "playItem", Q_ARG( Tomahawk::PlaylistInterface*, playlist ), Q_ARG( const Tomahawk::result_ptr&, result ) );
|
||||
return;
|
||||
}
|
||||
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO << ( result.isNull() ? QString() : result->url() );
|
||||
QMutexLocker locker( &m_playlistMutex );
|
||||
|
||||
if ( !m_playlist.isNull() )
|
||||
m_playlist.data()->reset();
|
||||
|
||||
setPlaylist( playlist );
|
||||
m_currentTrackPlaylistMutex.lock();
|
||||
m_currentTrackPlaylist = playlist->getSharedPointer();
|
||||
m_currentTrackPlaylistMutex.unlock();
|
||||
|
||||
if ( !result.isNull() )
|
||||
loadTrack( result );
|
||||
else if ( !m_playlist.isNull() && m_playlist.data()->retryMode() == PlaylistInterface::Retry )
|
||||
{
|
||||
m_waitingOnNewTrack = true;
|
||||
if ( m_mediaObject->state() == Phonon::StoppedState )
|
||||
if ( isStopped() )
|
||||
sendWaitingNotification();
|
||||
else
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngine::ioStreamError( QNetworkReply::NetworkError error )
|
||||
{
|
||||
if ( error != QNetworkReply::NoError )
|
||||
{
|
||||
if ( canGoNext() )
|
||||
loadNextTrack();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::playlistNextTrackReady()
|
||||
@@ -725,21 +639,14 @@ void
|
||||
AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << oldState << newState << m_expectStop;
|
||||
QMutexLocker plocker( &m_playlistMutex );
|
||||
QMutexLocker vlocker( &m_volumeMutex );
|
||||
m_volume = m_audioOutput->volume() * 100.0;
|
||||
|
||||
|
||||
if ( newState == Phonon::ErrorState )
|
||||
{
|
||||
tLog() << "Phonon Error:" << m_mediaObject->errorString() << m_mediaObject->errorType();
|
||||
return;
|
||||
}
|
||||
if ( newState == Phonon::PlayingState )
|
||||
{
|
||||
QMutexLocker locker( &m_currentTrackMutex );
|
||||
m_currentTrackTotalTime = m_mediaObject->totalTime() > 0 ? m_mediaObject->totalTime() : m_currentTrack->duration() * 1000;
|
||||
setState( Playing );
|
||||
}
|
||||
|
||||
if ( oldState == Phonon::PlayingState )
|
||||
{
|
||||
@@ -748,7 +655,6 @@ AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
|
||||
{
|
||||
case Phonon::PausedState:
|
||||
{
|
||||
QMutexLocker locker( &m_currentTrackMutex );
|
||||
qint64 duration = m_mediaObject->totalTime() > 0 ? m_mediaObject->totalTime() : m_currentTrack->duration() * 1000;
|
||||
stopped = ( duration - 1000 < m_mediaObject->currentTime() );
|
||||
if ( !stopped )
|
||||
@@ -785,8 +691,6 @@ AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
|
||||
void
|
||||
AudioEngine::timerTriggered( qint64 time )
|
||||
{
|
||||
QMutexLocker locker( &m_currentTrackMutex );
|
||||
m_currentTime = time;
|
||||
emit timerMilliSeconds( time );
|
||||
|
||||
if ( m_timeElapsed != time / 1000 )
|
||||
@@ -812,14 +716,6 @@ AudioEngine::timerTriggered( qint64 time )
|
||||
void
|
||||
AudioEngine::setPlaylist( PlaylistInterface* playlist )
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "setPlaylist", Q_ARG( Tomahawk::PlaylistInterface*, playlist ) );
|
||||
return;
|
||||
}
|
||||
|
||||
QMutexLocker locker( &m_playlistMutex );
|
||||
|
||||
if ( !m_playlist.isNull() )
|
||||
{
|
||||
if ( m_playlist.data()->object() && m_playlist.data()->retryMode() == PlaylistInterface::Retry )
|
||||
@@ -843,25 +739,9 @@ AudioEngine::setPlaylist( PlaylistInterface* playlist )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::setQueue( Tomahawk::PlaylistInterface* queue )
|
||||
{
|
||||
if ( QThread::currentThread() != AudioEngine::instance()->thread() )
|
||||
{
|
||||
QMetaObject::invokeMethod( AudioEngine::instance(), "setQueue", Q_ARG( Tomahawk::PlaylistInterface*, queue ) );
|
||||
return;
|
||||
}
|
||||
|
||||
QMutexLocker locker( &m_queueMutex );
|
||||
|
||||
m_queue = queue;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
QMutexLocker locker( &m_currentTrackMutex );
|
||||
m_lastTrack = m_currentTrack;
|
||||
if ( !m_lastTrack.isNull() )
|
||||
{
|
||||
@@ -895,7 +775,6 @@ AudioEngine::isLocalResult( const QString& url ) const
|
||||
void
|
||||
AudioEngine::setState( AudioState state )
|
||||
{
|
||||
QMutexLocker locker( &m_stateMutex );
|
||||
AudioState oldState = m_state;
|
||||
m_state = state;
|
||||
|
||||
|
@@ -19,9 +19,9 @@
|
||||
#ifndef AUDIOENGINE_H
|
||||
#define AUDIOENGINE_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include <phonon/MediaObject>
|
||||
#include <phonon/AudioOutput>
|
||||
@@ -55,23 +55,23 @@ public:
|
||||
~AudioEngine();
|
||||
|
||||
QStringList supportedMimeTypes() const;
|
||||
unsigned int volume() const { return m_volume; } // in percent
|
||||
unsigned int volume() const { return m_audioOutput->volume() * 100.0; } // in percent
|
||||
|
||||
AudioState state() const { QMutexLocker locker( &m_stateMutex ); return m_state; }
|
||||
bool isPlaying() const { QMutexLocker locker( &m_stateMutex ); return m_state == Playing; }
|
||||
bool isPaused() const { QMutexLocker locker( &m_stateMutex ); return m_state == Paused; }
|
||||
bool isStopped() const { QMutexLocker locker( &m_stateMutex ); return m_state == Stopped; }
|
||||
AudioState state() const { return m_state; }
|
||||
bool isPlaying() const { return m_state == Playing; }
|
||||
bool isPaused() const { return m_state == Paused; }
|
||||
bool isStopped() const { return m_state == Stopped; }
|
||||
|
||||
/* Returns the PlaylistInterface of the currently playing track. Note: This might be different to the current playlist! */
|
||||
Tomahawk::PlaylistInterface* currentTrackPlaylist() const { QMutexLocker locker( &m_currentTrackPlaylistMutex ); return m_currentTrackPlaylist.data(); }
|
||||
Tomahawk::PlaylistInterface* currentTrackPlaylist() const { return m_currentTrackPlaylist.data(); }
|
||||
|
||||
/* Returns the PlaylistInterface of the current playlist. Note: The currently playing track might still be from a different playlist! */
|
||||
Tomahawk::PlaylistInterface* playlist() const { QMutexLocker locker( &m_playlistMutex ); return m_playlist.data(); }
|
||||
Tomahawk::PlaylistInterface* playlist() const { return m_playlist.data(); }
|
||||
|
||||
Tomahawk::result_ptr currentTrack() const { QMutexLocker locker( &m_currentTrackMutex ); return m_currentTrack; }
|
||||
Tomahawk::result_ptr currentTrack() const { return m_currentTrack; }
|
||||
|
||||
qint64 currentTime() const { QMutexLocker locker( &m_currentTrackMutex ); return m_currentTime; }
|
||||
qint64 currentTrackTotalTime() const { QMutexLocker locker( &m_currentTrackMutex ); return m_currentTrackTotalTime; }
|
||||
qint64 currentTime() const { return m_mediaObject->currentTime(); }
|
||||
qint64 currentTrackTotalTime() const { return m_mediaObject->totalTime(); }
|
||||
|
||||
public slots:
|
||||
void playPause();
|
||||
@@ -89,14 +89,14 @@ public slots:
|
||||
void seek( qint64 ms );
|
||||
void seek( int ms ); // for compatibility with seekbar in audiocontrols
|
||||
void setVolume( int percentage );
|
||||
void lowerVolume();
|
||||
void raiseVolume();
|
||||
void onVolumeChanged( qreal volume ) { QMutexLocker locker( &m_volumeMutex ); m_volume = volume * 100; emit volumeChanged( volume * 100 ); }
|
||||
void lowerVolume() { setVolume( volume() - AUDIO_VOLUME_STEP ); }
|
||||
void raiseVolume() { setVolume( volume() + AUDIO_VOLUME_STEP ); }
|
||||
void onVolumeChanged( qreal volume ) { emit volumeChanged( volume * 100 ); }
|
||||
void mute();
|
||||
|
||||
void playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::result_ptr& result );
|
||||
void setPlaylist( Tomahawk::PlaylistInterface* playlist );
|
||||
void setQueue( Tomahawk::PlaylistInterface* queue );
|
||||
void setQueue( Tomahawk::PlaylistInterface* queue ) { m_queue = queue; }
|
||||
|
||||
void playlistNextTrackReady();
|
||||
|
||||
@@ -137,6 +137,7 @@ private slots:
|
||||
|
||||
void setCurrentTrack( const Tomahawk::result_ptr& result );
|
||||
|
||||
void ioStreamError( QNetworkReply::NetworkError );
|
||||
private:
|
||||
void setState( AudioState state );
|
||||
|
||||
@@ -167,18 +168,6 @@ private:
|
||||
AudioState m_state;
|
||||
|
||||
static AudioEngine* s_instance;
|
||||
|
||||
mutable QMutex m_stateMutex;
|
||||
mutable QMutex m_mimeTypeMutex;
|
||||
mutable QMutex m_currentTrackMutex;
|
||||
mutable QMutex m_currentTrackPlaylistMutex;
|
||||
mutable QMutex m_playlistMutex;
|
||||
mutable QMutex m_queueMutex;
|
||||
mutable QMutex m_volumeMutex;
|
||||
|
||||
qint64 m_currentTime;
|
||||
qint64 m_currentTrackTotalTime;
|
||||
unsigned int m_volume;
|
||||
};
|
||||
|
||||
#endif // AUDIOENGINE_H
|
||||
|
@@ -1,41 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "audioenginethread.h"
|
||||
#include <utils/logger.h>
|
||||
#include <audio/audioengine.h>
|
||||
|
||||
AudioEngineThread::AudioEngineThread( QObject *parent )
|
||||
: QThread( parent )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
AudioEngineThread::~AudioEngineThread()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngineThread::AudioEngineThread::run()
|
||||
{
|
||||
m_audioEngine = QWeakPointer< AudioEngine >( new AudioEngine() );
|
||||
exec();
|
||||
if( !m_audioEngine.isNull() )
|
||||
delete m_audioEngine.data();
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef AUDIOENGINETHREAD_H
|
||||
#define AUDIOENGINETHREAD_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QWeakPointer>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class AudioEngine;
|
||||
|
||||
class DLLEXPORT AudioEngineThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioEngineThread( QObject *parent = 0 );
|
||||
virtual ~AudioEngineThread();
|
||||
|
||||
void run();
|
||||
|
||||
private:
|
||||
QWeakPointer< AudioEngine > m_audioEngine;
|
||||
};
|
||||
|
||||
#endif // AUDIOENGINETHREAD_H
|
@@ -33,12 +33,10 @@ Collection::Collection( const source_ptr& source, const QString& name, QObject*
|
||||
: QObject( parent )
|
||||
, m_name( name )
|
||||
, m_lastmodified( 0 )
|
||||
, m_changed( false )
|
||||
, m_isLoaded( false )
|
||||
, m_source( source )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << name << source->friendlyName();
|
||||
|
||||
connect( source.data(), SIGNAL( synced() ), SLOT( onSynced() ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -213,8 +211,8 @@ Collection::setTracks( const QList<unsigned int>& ids )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << ids.count() << name();
|
||||
|
||||
m_changed = true;
|
||||
emit tracksAdded( ids );
|
||||
emit changed();
|
||||
}
|
||||
|
||||
|
||||
@@ -223,19 +221,8 @@ Collection::delTracks( const QList<unsigned int>& ids )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << ids.count() << name();
|
||||
|
||||
m_changed = true;
|
||||
emit tracksRemoved( ids );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Collection::onSynced()
|
||||
{
|
||||
if ( m_changed )
|
||||
{
|
||||
m_changed = false;
|
||||
emit changed();
|
||||
}
|
||||
emit changed();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -49,6 +49,8 @@ public:
|
||||
Collection( const source_ptr& source, const QString& name, QObject* parent = 0 );
|
||||
virtual ~Collection();
|
||||
|
||||
virtual void setLoaded() { m_isLoaded = true; }
|
||||
virtual bool isLoaded() const { return m_isLoaded; }
|
||||
virtual QString name() const;
|
||||
|
||||
virtual void loadPlaylists() { qDebug() << Q_FUNC_INFO; }
|
||||
@@ -105,11 +107,8 @@ protected:
|
||||
QString m_name;
|
||||
unsigned int m_lastmodified; // unix time of last change to collection
|
||||
|
||||
private slots:
|
||||
void onSynced();
|
||||
|
||||
private:
|
||||
bool m_changed;
|
||||
bool m_isLoaded;
|
||||
|
||||
source_ptr m_source;
|
||||
QHash< QString, Tomahawk::playlist_ptr > m_playlists;
|
||||
|
@@ -73,15 +73,7 @@ Database::loadIndex()
|
||||
|
||||
|
||||
void
|
||||
Database::enqueue( const QList< QSharedPointer<DatabaseCommand> >& lc )
|
||||
{
|
||||
qDebug() << "Enqueueing" << lc.count() << "commands to rw thread";
|
||||
m_workerRW->enqueue( lc );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Database::enqueue( const QSharedPointer<DatabaseCommand>& lc )
|
||||
Database::enqueue( QSharedPointer<DatabaseCommand> lc )
|
||||
{
|
||||
if ( lc->doesMutates() )
|
||||
{
|
||||
|
@@ -66,8 +66,7 @@ signals:
|
||||
void newJobRW( QSharedPointer<DatabaseCommand> );
|
||||
|
||||
public slots:
|
||||
void enqueue( const QSharedPointer<DatabaseCommand>& lc );
|
||||
void enqueue( const QList< QSharedPointer<DatabaseCommand> >& lc );
|
||||
void enqueue( QSharedPointer<DatabaseCommand> lc );
|
||||
|
||||
private slots:
|
||||
void setIsReadyTrue() { m_ready = true; }
|
||||
|
@@ -69,8 +69,22 @@ DatabaseCollection::loadStations()
|
||||
connect( cmd, SIGNAL( stationLoaded( Tomahawk::source_ptr, QVariantList ) ),
|
||||
SLOT( stationCreated( const Tomahawk::source_ptr&, const QVariantList& ) ) );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );}
|
||||
|
||||
|
||||
/*void
|
||||
DatabaseCollection::loadTracks()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << source()->userName();
|
||||
|
||||
setLoaded();
|
||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( source()->collection() );
|
||||
|
||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
|
||||
SLOT( setTracks( QList<Tomahawk::query_ptr> ) ) );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
void
|
||||
@@ -129,10 +143,20 @@ DatabaseCollection::stations()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DatabaseCollection::autoPlaylistCreated( const source_ptr& source, const QVariantList& data )
|
||||
/*QList< Tomahawk::query_ptr >
|
||||
DatabaseCollection::tracks()
|
||||
{
|
||||
if ( !isLoaded() )
|
||||
{
|
||||
loadTracks();
|
||||
}
|
||||
|
||||
return Collection::tracks();
|
||||
}*/
|
||||
|
||||
|
||||
void DatabaseCollection::autoPlaylistCreated( const source_ptr& source, const QVariantList& data )
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
dynplaylist_ptr p( new DynamicPlaylist( source, //src
|
||||
data[0].toString(), //current rev
|
||||
data[1].toString(), //title
|
||||
@@ -145,14 +169,11 @@ DatabaseCollection::autoPlaylistCreated( const source_ptr& source, const QVarian
|
||||
data[8].toInt(), //lastmod
|
||||
data[9].toString() ) ); //GUID
|
||||
addAutoPlaylist( p );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DatabaseCollection::stationCreated( const source_ptr& source, const QVariantList& data )
|
||||
void DatabaseCollection::stationCreated( const source_ptr& source, const QVariantList& data )
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
dynplaylist_ptr p( new DynamicPlaylist( source, //src
|
||||
data[0].toString(), //current rev
|
||||
data[1].toString(), //title
|
||||
@@ -165,7 +186,6 @@ DatabaseCollection::stationCreated( const source_ptr& source, const QVariantList
|
||||
data[8].toInt(), //lastmod
|
||||
data[9].toString() ) ); //GUID
|
||||
addStation( p );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@@ -80,14 +80,12 @@ DatabaseCommand::setSource( const Tomahawk::source_ptr& s )
|
||||
m_source = s;
|
||||
}
|
||||
|
||||
|
||||
const Tomahawk::source_ptr&
|
||||
DatabaseCommand::source() const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
|
||||
DatabaseCommand*
|
||||
DatabaseCommand::factory( const QVariant& op, const source_ptr& source )
|
||||
{
|
||||
@@ -141,8 +139,7 @@ DatabaseCommand::factory( const QVariant& op, const source_ptr& source )
|
||||
cmd->setSource( source );
|
||||
QJson::QObjectHelper::qvariant2qobject( op.toMap(), cmd );
|
||||
return cmd;
|
||||
}
|
||||
else if( name == "createdynamicplaylist" )
|
||||
} else if( name == "createdynamicplaylist" )
|
||||
{
|
||||
DatabaseCommand_CreateDynamicPlaylist * cmd = new DatabaseCommand_CreateDynamicPlaylist;
|
||||
cmd->setSource( source );
|
||||
@@ -186,7 +183,7 @@ DatabaseCommand::factory( const QVariant& op, const source_ptr& source )
|
||||
return cmd;
|
||||
}
|
||||
|
||||
qDebug() << "Unknown database command" << name;
|
||||
qDebug() << "ERROR in" << Q_FUNC_INFO << name;
|
||||
// Q_ASSERT( false );
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -70,7 +70,6 @@ public:
|
||||
const Tomahawk::source_ptr& source() const;
|
||||
|
||||
virtual bool loggable() const { return false; }
|
||||
virtual bool groupable() const { return false; }
|
||||
virtual bool singletonCmd() const { return false; }
|
||||
virtual bool localOnly() const { return false; }
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include "album.h"
|
||||
#include "collection.h"
|
||||
#include "database/database.h"
|
||||
#include "databasecommand_collectionstats.h"
|
||||
#include "databaseimpl.h"
|
||||
#include "network/dbsyncconnection.h"
|
||||
#include "network/servent.h"
|
||||
@@ -72,7 +73,15 @@ DatabaseCommand_AddFiles::postCommitHook()
|
||||
emit notify( m_ids );
|
||||
|
||||
if ( source()->isLocal() )
|
||||
{
|
||||
Servent::instance()->triggerDBSync();
|
||||
|
||||
// Re-calculate local db stats
|
||||
DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( SourceList::instance()->getLocal() );
|
||||
connect( cmd, SIGNAL( done( QVariantMap ) ),
|
||||
SourceList::instance()->getLocal().data(), SLOT( setStats( QVariantMap ) ), Qt::QueuedConnection );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -28,13 +28,10 @@
|
||||
#include "dynamic/GeneratorInterface.h"
|
||||
|
||||
#include "source.h"
|
||||
#include "viewmanager.h"
|
||||
#include "network/servent.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include "viewmanager.h"
|
||||
#endif
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
@@ -114,13 +111,11 @@ DatabaseCommand_CreateDynamicPlaylist::postCommitHook()
|
||||
qDebug() << Q_FUNC_INFO << "..reporting..";
|
||||
if( m_playlist.isNull() ) {
|
||||
source_ptr src = source();
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QMetaObject::invokeMethod( ViewManager::instance(),
|
||||
"createDynamicPlaylist",
|
||||
Qt::BlockingQueuedConnection,
|
||||
QGenericArgument( "Tomahawk::source_ptr", (const void*)&src ),
|
||||
Q_ARG( QVariant, m_v ) );
|
||||
#endif
|
||||
} else {
|
||||
m_playlist->reportCreated( m_playlist );
|
||||
}
|
||||
|
@@ -21,15 +21,12 @@
|
||||
#include <QSqlQuery>
|
||||
|
||||
#include "source.h"
|
||||
#include "viewmanager.h"
|
||||
#include "databaseimpl.h"
|
||||
#include "tomahawksqlquery.h"
|
||||
#include "network/servent.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include "viewmanager.h"
|
||||
#endif
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
@@ -82,13 +79,11 @@ DatabaseCommand_CreatePlaylist::postCommitHook()
|
||||
if ( m_playlist.isNull() )
|
||||
{
|
||||
source_ptr src = source();
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QMetaObject::invokeMethod( ViewManager::instance(),
|
||||
"createPlaylist",
|
||||
Qt::BlockingQueuedConnection,
|
||||
QGenericArgument( "Tomahawk::source_ptr", (const void*)&src ),
|
||||
Q_ARG( QVariant, m_v ) );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "collection.h"
|
||||
#include "source.h"
|
||||
#include "database/database.h"
|
||||
#include "databasecommand_collectionstats.h"
|
||||
#include "databaseimpl.h"
|
||||
#include "network/servent.h"
|
||||
#include "utils/logger.h"
|
||||
@@ -53,7 +54,7 @@ DatabaseCommand_DeleteFiles::postCommitHook()
|
||||
ids << id.toUInt();
|
||||
emit notify( ids );
|
||||
|
||||
if ( source()->isLocal() )
|
||||
if( source()->isLocal() )
|
||||
Servent::instance()->triggerDBSync();
|
||||
}
|
||||
|
||||
|
@@ -64,7 +64,6 @@ public:
|
||||
virtual void exec( DatabaseImpl* );
|
||||
virtual bool doesMutates() const { return true; }
|
||||
virtual bool localOnly() const { return false; }
|
||||
virtual bool groupable() const { return true; }
|
||||
virtual void postCommitHook();
|
||||
|
||||
QVariantList ids() const { return m_ids; }
|
||||
|
@@ -68,7 +68,6 @@ public:
|
||||
virtual bool doesMutates() const { return true; }
|
||||
virtual bool singletonCmd() const { return ( m_action == Started ); }
|
||||
virtual bool localOnly() const;
|
||||
virtual bool groupable() const { return true; }
|
||||
|
||||
QString artist() const { return m_artist; }
|
||||
void setArtist( const QString& s ) { m_artist = s; }
|
||||
|
@@ -157,6 +157,7 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
|
||||
result->setRID( uuid() );
|
||||
result->setAlbumPos( files_query.value( 14 ).toUInt() );
|
||||
result->setTrackId( files_query.value( 9 ).toUInt() );
|
||||
result->setYear( files_query.value( 17 ).toUInt() );
|
||||
|
||||
TomahawkSqlQuery attrQuery = lib->newquery();
|
||||
QVariantMap attr;
|
||||
|
@@ -87,7 +87,6 @@ DatabaseCommand_SetDynamicPlaylistRevision::controlsV()
|
||||
void
|
||||
DatabaseCommand_SetDynamicPlaylistRevision::postCommitHook()
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
if ( source().isNull() || source()->collection().isNull() )
|
||||
{
|
||||
tDebug() << "Source has gone offline, not emitting to GUI.";
|
||||
@@ -173,7 +172,6 @@ DatabaseCommand_SetDynamicPlaylistRevision::postCommitHook()
|
||||
|
||||
if ( source()->isLocal() )
|
||||
Servent::instance()->triggerDBSync();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@@ -60,7 +60,6 @@ public:
|
||||
virtual void exec( DatabaseImpl* lib );
|
||||
virtual void postCommitHook();
|
||||
virtual bool doesMutates() const { return true; }
|
||||
virtual bool groupable() const { return true; }
|
||||
|
||||
void setControlsV( const QVariantList& vlist )
|
||||
{
|
||||
|
@@ -212,6 +212,6 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib )
|
||||
else if ( !m_oldrev.isEmpty() )
|
||||
{
|
||||
tDebug() << "Not updating current revision, optimistic locking fail";
|
||||
// Q_ASSERT( false );
|
||||
Q_ASSERT( false );
|
||||
}
|
||||
}
|
||||
|
@@ -58,7 +58,6 @@ public:
|
||||
|
||||
virtual bool doesMutates() const { return true; }
|
||||
virtual bool localOnly() const { return m_localOnly; }
|
||||
virtual bool groupable() const { return true; }
|
||||
|
||||
void setAddedentriesV( const QVariantList& vlist )
|
||||
{
|
||||
|
@@ -170,7 +170,6 @@ public:
|
||||
void setTimestamp( const int ts ) { m_timestamp = ts; }
|
||||
|
||||
virtual bool doesMutates() const { return true; }
|
||||
virtual bool groupable() const { return true; }
|
||||
|
||||
private:
|
||||
Tomahawk::result_ptr m_result;
|
||||
|
@@ -72,21 +72,16 @@ DatabaseWorker::run()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DatabaseWorker::enqueue( const QList< QSharedPointer<DatabaseCommand> >& cmds )
|
||||
{
|
||||
QMutexLocker lock( &m_mut );
|
||||
m_outstanding += cmds.count();
|
||||
m_commands << cmds;
|
||||
|
||||
if ( m_outstanding == cmds.count() )
|
||||
QTimer::singleShot( 0, this, SLOT( doWork() ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DatabaseWorker::enqueue( const QSharedPointer<DatabaseCommand>& cmd )
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO << "Reinvoking in correct thread.";
|
||||
QMetaObject::invokeMethod( this, "enqueue", Qt::QueuedConnection, Q_ARG( QSharedPointer<DatabaseCommand>, cmd ) );
|
||||
return;
|
||||
}
|
||||
|
||||
QMutexLocker lock( &m_mut );
|
||||
m_outstanding++;
|
||||
m_commands << cmd;
|
||||
@@ -112,7 +107,6 @@ DatabaseWorker::doWork()
|
||||
timer.start();
|
||||
#endif
|
||||
|
||||
QList< QSharedPointer<DatabaseCommand> > cmdGroup;
|
||||
QSharedPointer<DatabaseCommand> cmd;
|
||||
{
|
||||
QMutexLocker lock( &m_mut );
|
||||
@@ -125,66 +119,47 @@ DatabaseWorker::doWork()
|
||||
Q_ASSERT( transok );
|
||||
Q_UNUSED( transok );
|
||||
}
|
||||
|
||||
unsigned int completed = 0;
|
||||
try
|
||||
{
|
||||
bool finished = false;
|
||||
{
|
||||
while ( !finished )
|
||||
// tDebug() << "Executing cmd:" << cmd->guid();
|
||||
cmd->_exec( m_dbimpl ); // runs actual SQL stuff
|
||||
|
||||
if ( cmd->loggable() )
|
||||
{
|
||||
completed++;
|
||||
cmd->_exec( m_dbimpl ); // runs actual SQL stuff
|
||||
|
||||
if ( cmd->loggable() )
|
||||
// We only save our own ops to the oplog, since incoming ops from peers
|
||||
// are applied immediately.
|
||||
//
|
||||
// Crazy idea: if peers had keypairs and could sign ops/msgs, in theory it
|
||||
// would be safe to sync ops for friend A from friend B's cache, if he saved them,
|
||||
// which would mean you could get updates even if a peer was offline.
|
||||
if ( cmd->source()->isLocal() && !cmd->localOnly() )
|
||||
{
|
||||
// We only save our own ops to the oplog, since incoming ops from peers
|
||||
// are applied immediately.
|
||||
// save to op-log
|
||||
DatabaseCommandLoggable* command = (DatabaseCommandLoggable*)cmd.data();
|
||||
logOp( command );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make a note of the last guid we applied for this source
|
||||
// so we can always request just the newer ops in future.
|
||||
//
|
||||
// Crazy idea: if peers had keypairs and could sign ops/msgs, in theory it
|
||||
// would be safe to sync ops for friend A from friend B's cache, if he saved them,
|
||||
// which would mean you could get updates even if a peer was offline.
|
||||
if ( cmd->source()->isLocal() && !cmd->localOnly() )
|
||||
if ( !cmd->singletonCmd() )
|
||||
{
|
||||
// save to op-log
|
||||
DatabaseCommandLoggable* command = (DatabaseCommandLoggable*)cmd.data();
|
||||
logOp( command );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make a note of the last guid we applied for this source
|
||||
// so we can always request just the newer ops in future.
|
||||
//
|
||||
if ( !cmd->singletonCmd() )
|
||||
{
|
||||
TomahawkSqlQuery query = m_dbimpl->newquery();
|
||||
query.prepare( "UPDATE source SET lastop = ? WHERE id = ?" );
|
||||
query.addBindValue( cmd->guid() );
|
||||
query.addBindValue( cmd->source()->id() );
|
||||
// qDebug() << "Setting lastop for source" << cmd->source()->id() << "to" << cmd->guid();
|
||||
|
||||
if ( !query.exec() )
|
||||
{
|
||||
throw "Failed to set lastop";
|
||||
}
|
||||
TomahawkSqlQuery query = m_dbimpl->newquery();
|
||||
query.prepare( "UPDATE source SET lastop = ? WHERE id = ?" );
|
||||
query.addBindValue( cmd->guid() );
|
||||
query.addBindValue( cmd->source()->id() );
|
||||
|
||||
if ( !query.exec() )
|
||||
{
|
||||
qDebug() << "Failed to set lastop";
|
||||
throw "Failed to set lastop";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmdGroup << cmd;
|
||||
if ( cmd->groupable() && !m_commands.isEmpty() )
|
||||
{
|
||||
QMutexLocker lock( &m_mut );
|
||||
if ( m_commands.first()->groupable() )
|
||||
{
|
||||
cmd = m_commands.takeFirst();
|
||||
}
|
||||
else
|
||||
{
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
finished = true;
|
||||
}
|
||||
|
||||
if ( cmd->doesMutates() )
|
||||
@@ -192,7 +167,8 @@ DatabaseWorker::doWork()
|
||||
qDebug() << "Committing" << cmd->commandname() << cmd->guid();
|
||||
if ( !m_dbimpl->database().commit() )
|
||||
{
|
||||
tDebug() << "FAILED TO COMMIT TRANSACTION*";
|
||||
|
||||
qDebug() << "*FAILED TO COMMIT TRANSACTION*";
|
||||
throw "commit failed";
|
||||
}
|
||||
}
|
||||
@@ -202,8 +178,7 @@ DatabaseWorker::doWork()
|
||||
tDebug() << "DBCmd Duration:" << duration << "ms, now running postcommit for" << cmd->commandname();
|
||||
#endif
|
||||
|
||||
foreach ( QSharedPointer<DatabaseCommand> c, cmdGroup )
|
||||
c->postCommit();
|
||||
cmd->postCommit();
|
||||
|
||||
#ifdef DEBUG_TIMING
|
||||
tDebug() << "Post commit finished in" << timer.elapsed() - duration << "ms for" << cmd->commandname();
|
||||
@@ -220,7 +195,7 @@ DatabaseWorker::doWork()
|
||||
<< m_dbimpl->database().lastError().driverText()
|
||||
<< endl;
|
||||
|
||||
if ( cmd->doesMutates() )
|
||||
if( cmd->doesMutates() )
|
||||
m_dbimpl->database().rollback();
|
||||
|
||||
Q_ASSERT( false );
|
||||
@@ -228,19 +203,17 @@ DatabaseWorker::doWork()
|
||||
catch(...)
|
||||
{
|
||||
qDebug() << "Uncaught exception processing dbcmd";
|
||||
if ( cmd->doesMutates() )
|
||||
if( cmd->doesMutates() )
|
||||
m_dbimpl->database().rollback();
|
||||
|
||||
Q_ASSERT( false );
|
||||
throw;
|
||||
}
|
||||
|
||||
foreach ( QSharedPointer<DatabaseCommand> c, cmdGroup )
|
||||
c->emitFinished();
|
||||
cmd->emitFinished();
|
||||
|
||||
QMutexLocker lock( &m_mut );
|
||||
m_outstanding -= completed;
|
||||
if ( m_outstanding > 0 )
|
||||
if ( --m_outstanding > 0 )
|
||||
QTimer::singleShot( 0, this, SLOT( doWork() ) );
|
||||
}
|
||||
|
||||
|
@@ -47,7 +47,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void enqueue( const QSharedPointer<DatabaseCommand>& );
|
||||
void enqueue( const QList< QSharedPointer<DatabaseCommand> >& );
|
||||
|
||||
protected:
|
||||
void run();
|
||||
|
@@ -21,13 +21,10 @@
|
||||
#include "localcollection.h"
|
||||
|
||||
#include "sourcelist.h"
|
||||
#include "viewmanager.h"
|
||||
#include <tomahawksettings.h>
|
||||
#include "utils/logger.h"
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include "viewmanager.h"
|
||||
#endif
|
||||
|
||||
|
||||
LocalCollection::LocalCollection( const Tomahawk::source_ptr& source, QObject* parent )
|
||||
: DatabaseCollection( source, parent )
|
||||
@@ -52,12 +49,10 @@ LocalCollection::createBookmarksPlaylist()
|
||||
if( bookmarksPlaylist().isNull() ) {
|
||||
QString guid = uuid();
|
||||
Tomahawk::playlist_ptr p = Tomahawk::Playlist::create( SourceList::instance()->getLocal(), guid, tr( "Bookmarks" ), tr( "Saved tracks" ), QString(), false );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
ViewManager::instance()->createPageForPlaylist( p );
|
||||
// connect( p.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( loaded( Tomahawk::PlaylistRevision ) ), Qt::QueuedConnection );
|
||||
connect( p.data(), SIGNAL( created() ), this, SLOT( created() ) );
|
||||
#endif
|
||||
|
||||
TomahawkSettings::instance()->setBookmarkPlaylist( guid );
|
||||
// p->createNewRevision( uuid(), p->currentrevision(), QList< Tomahawk::plentry_ptr >() );
|
||||
}
|
||||
|
@@ -18,10 +18,8 @@
|
||||
|
||||
#include "globalactionmanager.h"
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include <QClipboard>
|
||||
#endif
|
||||
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QMimeData>
|
||||
#include <QUrl>
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
@@ -33,10 +31,13 @@
|
||||
#include "album.h"
|
||||
#include "sourcelist.h"
|
||||
#include "pipeline.h"
|
||||
#include "viewmanager.h"
|
||||
#include "tomahawksettings.h"
|
||||
#include "audio/audioengine.h"
|
||||
#include "database/localcollection.h"
|
||||
#include "playlist/dynamic/GeneratorInterface.h"
|
||||
#include "playlist/topbar/topbar.h"
|
||||
#include "playlist/playlistview.h"
|
||||
|
||||
#include "echonest/Playlist.h"
|
||||
|
||||
@@ -49,15 +50,7 @@
|
||||
#include "utils/spotifyparser.h"
|
||||
#include "utils/shortenedlinkparser.h"
|
||||
#include "utils/rdioparser.h"
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include <QApplication>
|
||||
#include "widgets/searchwidget.h"
|
||||
#include "viewmanager.h"
|
||||
#include "playlist/topbar/topbar.h"
|
||||
#include "playlist/playlistview.h"
|
||||
|
||||
#endif
|
||||
#include "widgets/searchwidget.h"
|
||||
|
||||
GlobalActionManager* GlobalActionManager::s_instance = 0;
|
||||
|
||||
|
@@ -19,10 +19,12 @@
|
||||
|
||||
#include "chartsplugin.h"
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtNetwork/QNetworkConfiguration>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QCryptographicHash>
|
||||
#include <QNetworkConfiguration>
|
||||
#include <QNetworkReply>
|
||||
#include <QDomElement>
|
||||
|
||||
#include "album.h"
|
||||
#include "chartsplugin_data_p.h"
|
||||
@@ -48,12 +50,27 @@ ChartsPlugin::ChartsPlugin()
|
||||
m_chartResources << "billboard" << "itunes" << "rdio" << "wearehunted" << "ex.fm";
|
||||
m_supportedGetTypes << InfoChart << InfoChartCapabilities;
|
||||
|
||||
/// Then get each chart from resource
|
||||
/// We want to prepopulate the breadcrumb to fetch them before they are asked for
|
||||
if ( !m_chartResources.isEmpty() && m_allChartsMap.isEmpty() )
|
||||
{
|
||||
tDebug() << "ChartsPlugin: InfoChart fetching possible resources";
|
||||
foreach ( QVariant resource, m_chartResources )
|
||||
{
|
||||
QUrl url = QUrl( QString( CHART_URL "source/%1" ).arg(resource.toString() ) );
|
||||
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
|
||||
tDebug() << "fetching:" << url;
|
||||
connect( reply, SIGNAL( finished() ), SLOT( chartTypes() ) );
|
||||
|
||||
m_chartsFetchJobs++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ChartsPlugin::~ChartsPlugin()
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,27 +85,27 @@ ChartsPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
void
|
||||
ChartsPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
//qDebug() << Q_FUNC_INFO << requestData.caller;
|
||||
//qDebug() << Q_FUNC_INFO << requestData.customData;
|
||||
qDebug() << Q_FUNC_INFO << requestData.caller;
|
||||
qDebug() << Q_FUNC_INFO << requestData.customData;
|
||||
|
||||
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
bool foundSource = false;
|
||||
|
||||
switch ( requestData.type )
|
||||
{
|
||||
|
||||
case InfoChart:
|
||||
/// We need something to check if the request is actually ment to go to this plugin
|
||||
if ( !hash.contains( "chart_source" ) )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Hash did not contain required param!";
|
||||
dataError( requestData );
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach( QString resource, m_chartResources )
|
||||
foreach( QVariant resource, m_chartResources )
|
||||
{
|
||||
if( resource == hash["chart_source"] )
|
||||
if( resource.toString() == hash["chart_source"] )
|
||||
{
|
||||
foundSource = true;
|
||||
}
|
||||
@@ -113,6 +130,15 @@ ChartsPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChartsPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input )
|
||||
{
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type)
|
||||
Q_UNUSED( input )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChartsPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
@@ -129,7 +155,6 @@ ChartsPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
/// Each request needs to contain both a id and source
|
||||
if ( !hash.contains( "chart_id" ) && !hash.contains( "chart_source" ) )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Hash did not contain required params!";
|
||||
dataError( requestData );
|
||||
return;
|
||||
|
||||
@@ -138,7 +163,7 @@ ChartsPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
criteria["chart_id"] = hash["chart_id"];
|
||||
criteria["chart_source"] = hash["chart_source"];
|
||||
|
||||
emit getCachedInfo( criteria, 86400000, requestData );
|
||||
emit getCachedInfo( criteria, 0, requestData );
|
||||
}
|
||||
|
||||
void
|
||||
@@ -146,14 +171,13 @@ ChartsPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requ
|
||||
{
|
||||
if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Could not convert requestData to InfoStringHash!";
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
criteria[ "InfoChartCapabilities" ] = "chartsplugin";
|
||||
emit getCachedInfo( criteria, 604800000, requestData );
|
||||
|
||||
emit getCachedInfo( criteria, 0, requestData );
|
||||
}
|
||||
|
||||
void
|
||||
@@ -163,11 +187,9 @@ ChartsPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSy
|
||||
{
|
||||
case InfoChart:
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "InfoChart not in cache! Fetching...";
|
||||
|
||||
/// Fetch the chart, we need source and id
|
||||
QUrl url = QUrl( QString( CHART_URL "source/%1/chart/%2" ).arg( criteria["chart_source"] ).arg( criteria["chart_id"] ) );
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Getting chart url" << url;
|
||||
qDebug() << Q_FUNC_INFO << "Getting chart url" << url;
|
||||
|
||||
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
|
||||
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
|
||||
@@ -179,33 +201,9 @@ ChartsPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSy
|
||||
|
||||
case InfoChartCapabilities:
|
||||
{
|
||||
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "InfoChartCapabilities not in cache! Fetching...";
|
||||
// we never need to re-fetch
|
||||
if ( !m_allChartsMap.isEmpty() )
|
||||
return;
|
||||
|
||||
/// Then get each chart from resource
|
||||
|
||||
if ( !m_chartResources.isEmpty() && m_allChartsMap.isEmpty() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "InfoChart fetching possible resources";
|
||||
foreach ( QString resource, m_chartResources )
|
||||
{
|
||||
QUrl url = QUrl( QString( CHART_URL "source/%1" ).arg( resource ) );
|
||||
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
|
||||
reply->setProperty( "chart_resource", resource);
|
||||
|
||||
tDebug() << "fetching:" << url;
|
||||
connect( reply, SIGNAL( finished() ), SLOT( chartTypes() ) );
|
||||
|
||||
m_chartsFetchJobs++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_chartsFetchJobs > 0 )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "InfoChartCapabilities still fetching!";
|
||||
qDebug() << Q_FUNC_INFO << "InfoChartCapabilities still fetching!";
|
||||
m_cachedRequests.append( requestData );
|
||||
return;
|
||||
}
|
||||
@@ -228,10 +226,9 @@ void
|
||||
ChartsPlugin::chartTypes()
|
||||
{
|
||||
/// Get possible chart type for specificChartsPlugin: InfoChart types returned chart source
|
||||
tDebug( LOGVERBOSE ) << "Got chart type result";
|
||||
tDebug() << "Got chart type result";
|
||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
||||
|
||||
|
||||
if ( reply->error() == QNetworkReply::NoError )
|
||||
{
|
||||
QJson::Parser p;
|
||||
@@ -265,8 +262,7 @@ ChartsPlugin::chartTypes()
|
||||
QHash< QString, QVariantMap > extraType;
|
||||
foreach( const QVariant& chartObj, chartObjs.values() )
|
||||
{
|
||||
if( !chartObj.toMap().isEmpty() )
|
||||
{
|
||||
if( !chartObj.toMap().isEmpty() ){
|
||||
const QVariantMap chart = chartObj.toMap();
|
||||
const QString id = chart.value( "id" ).toString();
|
||||
const QString geo = chart.value( "geo" ).toString();
|
||||
@@ -275,8 +271,7 @@ ChartsPlugin::chartTypes()
|
||||
const bool isDefault = ( chart.contains( "default" ) && chart[ "default" ].toInt() == 1 );
|
||||
|
||||
QString extra;
|
||||
if( !geo.isEmpty() )
|
||||
{
|
||||
if( !geo.isEmpty() ){
|
||||
|
||||
if ( !m_cachedCountries.contains( geo ) )
|
||||
{
|
||||
@@ -294,10 +289,10 @@ ChartsPlugin::chartTypes()
|
||||
m_cachedCountries[ geo ] = extra;
|
||||
}
|
||||
else
|
||||
{
|
||||
extra = m_cachedCountries[ geo ];
|
||||
}
|
||||
else
|
||||
extra = chart.value( "extra" ).toString();
|
||||
}
|
||||
}else extra = chart.value( "extra" ).toString();
|
||||
|
||||
if ( name.isEmpty() ) // not a specific chart, an all chart
|
||||
name = tr( "Top Overall" );
|
||||
@@ -309,10 +304,10 @@ ChartsPlugin::chartTypes()
|
||||
if ( isDefault )
|
||||
c[ "default" ] = "true";
|
||||
|
||||
QList< Tomahawk::InfoSystem::InfoStringHash > extraTypeData = extraType[ extra ][ type ].value< QList< Tomahawk::InfoSystem::InfoStringHash > >();
|
||||
QList<InfoStringHash> extraTypeData = extraType[ extra ][ type ].value< QList< InfoStringHash > >();
|
||||
extraTypeData.append( c );
|
||||
extraType[ extra ][ type ] = QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > >( extraTypeData );
|
||||
|
||||
extraType[ extra ].insert( type, QVariant::fromValue< QList< InfoStringHash > >( extraTypeData ) );
|
||||
if ( isDefault )
|
||||
{
|
||||
defaultChain.clear();
|
||||
@@ -324,7 +319,7 @@ ChartsPlugin::chartTypes()
|
||||
foreach( const QString& c, extraType.keys() )
|
||||
{
|
||||
charts[ c ] = extraType[ c ];
|
||||
// tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "extraType has types:" << c;
|
||||
// qDebug() << "extraType has types:" << c;
|
||||
}
|
||||
if( source == "itunes" ){
|
||||
chartName = "iTunes";
|
||||
@@ -335,8 +330,7 @@ ChartsPlugin::chartTypes()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
}else
|
||||
{
|
||||
// We'll just build:
|
||||
// [Source] - Album - Chart Type
|
||||
@@ -386,11 +380,11 @@ ChartsPlugin::chartTypes()
|
||||
}
|
||||
}
|
||||
if( !artistCharts.isEmpty() )
|
||||
charts.insert( tr( "Artists" ), QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > >( artistCharts ) );
|
||||
charts.insert( tr( "Artists" ), QVariant::fromValue< QList< InfoStringHash > >( artistCharts ) );
|
||||
if( !albumCharts.isEmpty() )
|
||||
charts.insert( tr( "Albums" ), QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > >( albumCharts ) );
|
||||
charts.insert( tr( "Albums" ), QVariant::fromValue< QList< InfoStringHash > >( albumCharts ) );
|
||||
if( !trackCharts.isEmpty() )
|
||||
charts.insert( tr( "Tracks" ), QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > >( trackCharts ) );
|
||||
charts.insert( tr( "Tracks" ), QVariant::fromValue< QList< InfoStringHash > >( trackCharts ) );
|
||||
|
||||
/// @note For displaying purposes, upper the first letter
|
||||
/// @note Remeber to lower it when fetching this!
|
||||
@@ -400,7 +394,7 @@ ChartsPlugin::chartTypes()
|
||||
}
|
||||
|
||||
/// Add the possible charts and its types to breadcrumb
|
||||
// tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "ADDING CHART TYPE TO CHARTS:" << chartName;
|
||||
// qDebug() << "ADDING CHART TYPE TO CHARTS:" << chartName;
|
||||
QVariantMap defaultMap = m_allChartsMap.value( "defaults" ).value< QVariantMap >();
|
||||
defaultMap[ source ] = defaultChain;
|
||||
m_allChartsMap[ "defaults" ] = defaultMap;
|
||||
@@ -419,10 +413,6 @@ ChartsPlugin::chartTypes()
|
||||
foreach ( InfoRequestData request, m_cachedRequests )
|
||||
{
|
||||
emit info( request, m_allChartsMap );
|
||||
// update cache
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
criteria[ "InfoChartCapabilities" ] = "chartsplugin";
|
||||
emit updateCache( criteria, 604800000, request.type, m_allChartsMap );
|
||||
}
|
||||
m_cachedRequests.clear();
|
||||
}
|
||||
@@ -451,8 +441,8 @@ ChartsPlugin::chartReturned()
|
||||
|
||||
/// SO we have a result, parse it!
|
||||
QVariantList chartResponse = res.value( "list" ).toList();
|
||||
QList< Tomahawk::InfoSystem::InfoStringHash > top_tracks;
|
||||
QList< Tomahawk::InfoSystem::InfoStringHash > top_albums;
|
||||
QList< InfoStringHash > top_tracks;
|
||||
QList< InfoStringHash > top_albums;
|
||||
QStringList top_artists;
|
||||
|
||||
/// Deside what type, we need to handle it differently
|
||||
@@ -488,16 +478,16 @@ ChartsPlugin::chartReturned()
|
||||
|
||||
if ( album.isEmpty() && artist.isEmpty() ) // don't have enough...
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << "Didn't get an artist and album name from chart, not enough to build a query on. Aborting" << title << album << artist;
|
||||
tLog() << "Didn't get an artist and album name from chart, not enough to build a query on. Aborting" << title << album << artist;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash pair;
|
||||
qDebug() << Q_FUNC_INFO << album << artist;
|
||||
InfoStringHash pair;
|
||||
pair["artist"] = artist;
|
||||
pair["album"] = album;
|
||||
top_albums.append( pair );
|
||||
top_albums << pair;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -507,28 +497,28 @@ ChartsPlugin::chartReturned()
|
||||
|
||||
if ( title.isEmpty() && artist.isEmpty() ) // don't have enough...
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << "Didn't get an artist and track name from charts, not enough to build a query on. Aborting" << title << artist << album;
|
||||
tLog() << "Didn't get an artist and track name from charts, not enough to build a query on. Aborting" << title << artist << album;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash pair;
|
||||
InfoStringHash pair;
|
||||
pair["artist"] = artist;
|
||||
pair["track"] = title;
|
||||
top_tracks.append( pair );
|
||||
top_tracks << pair;
|
||||
|
||||
}
|
||||
}else if( chartType() == Artist )
|
||||
{
|
||||
if ( artist.isEmpty() ) // don't have enough...
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << "Didn't get an artist from charts, not enough to build a query on. Aborting" << artist;
|
||||
tLog() << "Didn't get an artist from charts, not enough to build a query on. Aborting" << artist;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
top_artists.append( artist );
|
||||
top_artists << artist;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -538,35 +528,31 @@ ChartsPlugin::chartReturned()
|
||||
if( chartType() == Artist )
|
||||
{
|
||||
tDebug() << "ChartsPlugin:" << "\tgot " << top_artists.size() << " artists";
|
||||
returnedData[ "artists" ] = QVariant::fromValue< QStringList >( top_artists );
|
||||
returnedData[ "type" ] = "artists";
|
||||
returnedData["artists"] = QVariant::fromValue( top_artists );
|
||||
returnedData["type"] = "artists";
|
||||
}
|
||||
|
||||
if( chartType() == Track )
|
||||
{
|
||||
tDebug() << "ChartsPlugin:" << "\tgot " << top_tracks.size() << " tracks";
|
||||
returnedData[ "tracks" ] = QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > >( top_tracks );
|
||||
returnedData[ "type" ] = "tracks";
|
||||
returnedData["tracks"] = QVariant::fromValue( top_tracks );
|
||||
returnedData["type"] = "tracks";
|
||||
}
|
||||
|
||||
if( chartType() == Album )
|
||||
{
|
||||
tDebug() << "ChartsPlugin:" << "\tgot " << top_albums.size() << " albums";
|
||||
returnedData[ "albums" ] = QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > >( top_albums );
|
||||
returnedData[ "type" ] = "albums";
|
||||
returnedData["albums"] = QVariant::fromValue( top_albums );
|
||||
returnedData["type"] = "albums";
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
|
||||
|
||||
emit info( requestData, returnedData );
|
||||
// update cache
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
criteria[ "chart_id" ] = origData[ "chart_id" ];
|
||||
criteria[ "chart_source" ] = origData[ "chart_source" ];
|
||||
emit updateCache( criteria, 86400000, requestData.type, returnedData );
|
||||
// TODO update cache
|
||||
}
|
||||
else
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Network error in fetching chart:" << reply->url().toString();
|
||||
qDebug() << "Network error in fetching chart:" << reply->url().toString();
|
||||
|
||||
}
|
||||
|
@@ -21,8 +21,8 @@
|
||||
|
||||
#include "infosystem/infosystem.h"
|
||||
#include "infosystem/infosystemworker.h"
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QtCore/QObject>
|
||||
#include <QNetworkReply>
|
||||
#include <QObject>
|
||||
|
||||
class QNetworkReply;
|
||||
|
||||
@@ -47,9 +47,8 @@ public:
|
||||
Artist = 0x04
|
||||
|
||||
};
|
||||
|
||||
void setChartType( ChartType type ) { m_chartType = type; }
|
||||
ChartType chartType() const { return m_chartType; }
|
||||
void setChartType( ChartType type ) { m_chartType = type; }
|
||||
ChartType chartType() const { return m_chartType; }
|
||||
|
||||
public slots:
|
||||
void chartReturned();
|
||||
@@ -59,20 +58,15 @@ protected slots:
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data )
|
||||
{
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type )
|
||||
Q_UNUSED( data )
|
||||
}
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data );
|
||||
|
||||
private:
|
||||
void fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void dataError( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
||||
QStringList m_chartResources;
|
||||
QList< InfoStringHash > m_charts;
|
||||
QVariantList m_chartResources;
|
||||
QList<InfoStringHash> m_charts;
|
||||
ChartType m_chartType;
|
||||
|
||||
QVariantMap m_allChartsMap;
|
||||
|
@@ -23,9 +23,11 @@
|
||||
#include <QCryptographicHash>
|
||||
#include <QNetworkConfiguration>
|
||||
#include <QNetworkReply>
|
||||
#include <QDomElement>
|
||||
|
||||
#include "album.h"
|
||||
#include "typedefs.h"
|
||||
#include "audio/audioengine.h"
|
||||
#include "tomahawksettings.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
@@ -138,6 +140,16 @@ hypemPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
hypemPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input )
|
||||
{
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type)
|
||||
Q_UNUSED( input )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
hypemPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
@@ -161,9 +173,8 @@ hypemPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
/// Set the criterias for current chart
|
||||
criteria["chart_id"] = hash["chart_id"];
|
||||
criteria["chart_source"] = hash["chart_source"];
|
||||
/// @todo
|
||||
/// set cache time based on wether requested type is 3day, lastweek or recent.
|
||||
emit getCachedInfo( criteria, 86400000, requestData );
|
||||
|
||||
emit getCachedInfo( criteria, 0, requestData );
|
||||
}
|
||||
|
||||
void
|
||||
@@ -187,7 +198,7 @@ hypemPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSys
|
||||
case InfoChart:
|
||||
{
|
||||
/// Fetch the chart, we need source and id
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "InfoChart not in cache! Fetching...";
|
||||
|
||||
QUrl url = QUrl( QString( HYPEM_URL "%1/%2" ).arg( criteria["chart_id"].toLower() ).arg(HYPEM_END_URL) );
|
||||
qDebug() << Q_FUNC_INFO << "Getting chart url" << url;
|
||||
|
||||
@@ -201,7 +212,6 @@ hypemPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSys
|
||||
|
||||
case InfoChartCapabilities:
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "InfoChartCapabilities not in cache! Fetching...";
|
||||
if ( m_chartsFetchJobs > 0 )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "InfoChartCapabilities still fetching!";
|
||||
@@ -380,14 +390,7 @@ hypemPlugin::chartReturned()
|
||||
|
||||
|
||||
emit info( requestData, returnedData );
|
||||
// update cache
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
criteria[ "chart_id" ] = origData[ "chart_id" ];
|
||||
criteria[ "chart_source" ] = origData[ "chart_source" ];
|
||||
/// @todo
|
||||
/// set cache time based on wether requested type is 3day, lastweek or recent.
|
||||
emit updateCache( criteria, 86400000, requestData.type, returnedData );
|
||||
// TODO update cache
|
||||
}
|
||||
else
|
||||
qDebug() << "Network error in fetching chart:" << reply->url().toString();
|
||||
|
@@ -57,13 +57,8 @@ public slots:
|
||||
protected slots:
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input )
|
||||
{
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type)
|
||||
Q_UNUSED( input )
|
||||
}
|
||||
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data );
|
||||
|
||||
private:
|
||||
void fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include <QCryptographicHash>
|
||||
#include <QNetworkConfiguration>
|
||||
#include <QNetworkReply>
|
||||
#include <QDomElement>
|
||||
|
||||
#include "album.h"
|
||||
#include "typedefs.h"
|
||||
@@ -46,6 +47,19 @@ SpotifyPlugin::SpotifyPlugin()
|
||||
|
||||
m_supportedGetTypes << InfoChart << InfoChartCapabilities;
|
||||
|
||||
// we never need to re-fetch
|
||||
if ( !m_allChartsMap.isEmpty() )
|
||||
return;
|
||||
|
||||
/// We need to fetch possible types before they are asked for
|
||||
tDebug() << "SpotifyPlugin: InfoChart fetching possible resources";
|
||||
|
||||
QUrl url = QUrl( QString( SPOTIFY_API_URL "toplist/charts" ) );
|
||||
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
|
||||
tDebug() << Q_FUNC_INFO << "fetching:" << url;
|
||||
connect( reply, SIGNAL( finished() ), SLOT( chartTypes() ) );
|
||||
m_chartsFetchJobs++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +107,14 @@ SpotifyPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SpotifyPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input )
|
||||
{
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type)
|
||||
Q_UNUSED( input )
|
||||
}
|
||||
|
||||
void
|
||||
SpotifyPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
{
|
||||
@@ -101,22 +123,17 @@ SpotifyPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
dataError( requestData );
|
||||
return;
|
||||
}
|
||||
|
||||
InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
/// Each request needs to contain both a id and source
|
||||
if ( !hash.contains( "chart_id" ) && !hash.contains( "chart_source" ) )
|
||||
if ( !hash.contains( "chart_id" ) )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Hash did not contain required params!";
|
||||
dataError( requestData );
|
||||
return;
|
||||
|
||||
} else {
|
||||
criteria["chart_id"] = hash["chart_id"];
|
||||
}
|
||||
/// Set the criterias for current chart
|
||||
criteria["chart_id"] = hash["chart_id"];
|
||||
criteria["chart_source"] = hash["chart_source"];
|
||||
|
||||
emit getCachedInfo( criteria, 86400000 /* Expire chart cache in 1 day */, requestData );
|
||||
emit getCachedInfo( criteria, 604800000 /* Expire chart cache in 1 week */, requestData );
|
||||
}
|
||||
void
|
||||
SpotifyPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
@@ -128,8 +145,7 @@ SpotifyPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData req
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
criteria[ "InfoChartCapabilities" ] = "spotifyplugin";
|
||||
emit getCachedInfo( criteria, 604800000, requestData );
|
||||
emit getCachedInfo( criteria, 0, requestData );
|
||||
}
|
||||
|
||||
void
|
||||
@@ -141,7 +157,6 @@ SpotifyPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, To
|
||||
case InfoChart:
|
||||
{
|
||||
/// Fetch the chart, we need source and id
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "InfoChart not in cache! Fetching...";
|
||||
QUrl url = QUrl( QString( SPOTIFY_API_URL "toplist/%1/" ).arg( criteria["chart_id"] ) );
|
||||
qDebug() << Q_FUNC_INFO << "Getting chart url" << url;
|
||||
|
||||
@@ -154,21 +169,6 @@ SpotifyPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, To
|
||||
}
|
||||
case InfoChartCapabilities:
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "InfoChartCapabilities not in cache! Fetching...";
|
||||
|
||||
// we never need to re-fetch
|
||||
if ( !m_allChartsMap.isEmpty() )
|
||||
return;
|
||||
|
||||
/// We need to fetch possible types before they are asked for
|
||||
tDebug() << "SpotifyPlugin: InfoChart fetching possible resources";
|
||||
|
||||
QUrl url = QUrl( QString( SPOTIFY_API_URL "toplist/charts" ) );
|
||||
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
|
||||
tDebug() << Q_FUNC_INFO << "fetching:" << url;
|
||||
connect( reply, SIGNAL( finished() ), SLOT( chartTypes() ) );
|
||||
m_chartsFetchJobs++;
|
||||
|
||||
if ( m_chartsFetchJobs > 0 )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "InfoChartCapabilities still fetching!";
|
||||
@@ -275,9 +275,6 @@ SpotifyPlugin::chartTypes()
|
||||
foreach ( InfoRequestData request, m_cachedRequests )
|
||||
{
|
||||
emit info( request, m_allChartsMap );
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
criteria[ "InfoChartCapabilities" ] = "spotifyplugin";
|
||||
emit updateCache( criteria,604800000, request.type, m_allChartsMap );
|
||||
}
|
||||
m_cachedRequests.clear();
|
||||
}
|
||||
@@ -382,14 +379,9 @@ SpotifyPlugin::chartReturned()
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
|
||||
|
||||
emit info( requestData, returnedData );
|
||||
|
||||
// update cache
|
||||
Tomahawk::InfoSystem::InfoStringHash criteria;
|
||||
Tomahawk::InfoSystem::InfoStringHash origData = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
||||
criteria[ "chart_id" ] = origData[ "chart_id" ];
|
||||
criteria[ "chart_source" ] = origData[ "chart_source" ];
|
||||
emit updateCache( criteria, 86400000, requestData.type, returnedData );
|
||||
}
|
||||
else
|
||||
qDebug() << "Network error in fetching chart:" << reply->url().toString();
|
||||
|
@@ -57,12 +57,7 @@ public slots:
|
||||
protected slots:
|
||||
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
virtual void pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoType type, const QVariant input )
|
||||
{
|
||||
Q_UNUSED( caller )
|
||||
Q_UNUSED( type)
|
||||
Q_UNUSED( input )
|
||||
}
|
||||
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data );
|
||||
|
||||
private:
|
||||
void fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
|
@@ -51,7 +51,6 @@ InfoSystem::instance()
|
||||
|
||||
InfoSystem::InfoSystem( QObject *parent )
|
||||
: QObject( parent )
|
||||
, m_inited( false )
|
||||
, m_infoSystemCacheThreadController( 0 )
|
||||
, m_infoSystemWorkerThreadController( 0 )
|
||||
{
|
||||
@@ -60,94 +59,71 @@ InfoSystem::InfoSystem( QObject *parent )
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_infoSystemCacheThreadController = new InfoSystemCacheThread( this );
|
||||
m_cache = QWeakPointer< InfoSystemCache >( new InfoSystemCache() );
|
||||
m_cache.data()->moveToThread( m_infoSystemCacheThreadController );
|
||||
m_infoSystemCacheThreadController->setCache( m_cache );
|
||||
m_infoSystemCacheThreadController->start( QThread::IdlePriority );
|
||||
|
||||
m_infoSystemWorkerThreadController = new InfoSystemWorkerThread( this );
|
||||
m_worker = QWeakPointer< InfoSystemWorker >( new InfoSystemWorker() );
|
||||
m_worker.data()->moveToThread( m_infoSystemWorkerThreadController );
|
||||
m_infoSystemWorkerThreadController->setWorker( m_worker );
|
||||
m_infoSystemWorkerThreadController->start();
|
||||
|
||||
QTimer::singleShot( 0, this, SLOT( init() ) );
|
||||
}
|
||||
QMetaObject::invokeMethod( m_worker.data(), "init", Qt::QueuedConnection, Q_ARG( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache >, m_cache ) );
|
||||
|
||||
connect( m_cache.data(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
m_worker.data(), SLOT( infoSlot( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
|
||||
|
||||
connect( m_worker.data(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
this, SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
|
||||
|
||||
connect( m_worker.data(), SIGNAL( finished( QString ) ), this, SIGNAL( finished( QString ) ), Qt::UniqueConnection );
|
||||
|
||||
connect( m_worker.data(), SIGNAL( finished( QString, Tomahawk::InfoSystem::InfoType ) ),
|
||||
this, SIGNAL( finished( QString, Tomahawk::InfoSystem::InfoType ) ), Qt::UniqueConnection );
|
||||
}
|
||||
|
||||
InfoSystem::~InfoSystem()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << " beginning";
|
||||
qDebug() << Q_FUNC_INFO << " beginning";
|
||||
|
||||
if ( m_infoSystemWorkerThreadController->worker() )
|
||||
if ( !m_worker.isNull() )
|
||||
{
|
||||
m_infoSystemWorkerThreadController->quit();
|
||||
m_infoSystemWorkerThreadController->wait( 60000 );
|
||||
|
||||
//delete m_worker.data();
|
||||
delete m_infoSystemWorkerThreadController;
|
||||
m_infoSystemWorkerThreadController = 0;
|
||||
}
|
||||
tDebug() << Q_FUNC_INFO << " done deleting worker";
|
||||
qDebug() << Q_FUNC_INFO << " done deleting worker";
|
||||
|
||||
if( m_infoSystemCacheThreadController->cache() )
|
||||
if( m_infoSystemCacheThreadController )
|
||||
{
|
||||
m_infoSystemCacheThreadController->quit();
|
||||
m_infoSystemCacheThreadController->wait( 60000 );
|
||||
|
||||
//delete m_cache.data();
|
||||
delete m_infoSystemCacheThreadController;
|
||||
m_infoSystemCacheThreadController = 0;
|
||||
}
|
||||
|
||||
tDebug() << Q_FUNC_INFO << " done deleting cache";
|
||||
qDebug() << Q_FUNC_INFO << " done deleting cache";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InfoSystem::init()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
if ( !m_infoSystemCacheThreadController->cache() || !m_infoSystemWorkerThreadController->worker() )
|
||||
{
|
||||
QTimer::singleShot( 0, this, SLOT( init() ) );
|
||||
return;
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoSystemCache* cache = m_infoSystemCacheThreadController->cache();
|
||||
Tomahawk::InfoSystem::InfoSystemWorker* worker = m_infoSystemWorkerThreadController->worker();
|
||||
|
||||
connect( cache, SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
worker, SLOT( infoSlot( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
|
||||
|
||||
connect( worker, SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
this, SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
|
||||
|
||||
connect( worker, SIGNAL( finished( QString ) ), this, SIGNAL( finished( QString ) ), Qt::UniqueConnection );
|
||||
|
||||
connect( worker, SIGNAL( finished( QString, Tomahawk::InfoSystem::InfoType ) ),
|
||||
this, SIGNAL( finished( QString, Tomahawk::InfoSystem::InfoType ) ), Qt::UniqueConnection );
|
||||
|
||||
QMetaObject::invokeMethod( worker, "init", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoSystemCache*, cache ) );
|
||||
|
||||
m_inited = true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
InfoSystem::getInfo( const InfoRequestData &requestData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
||||
{
|
||||
init();
|
||||
return false;
|
||||
}
|
||||
QMetaObject::invokeMethod( m_infoSystemWorkerThreadController->worker(), "getInfo", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ) );
|
||||
return true;
|
||||
QMetaObject::invokeMethod( m_worker.data(), "getInfo", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ) );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
void
|
||||
InfoSystem::getInfo( const QString &caller, const QVariantMap &customData, const InfoTypeMap &inputMap, const InfoTimeoutMap &timeoutMap, bool allSources )
|
||||
{
|
||||
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
||||
{
|
||||
init();
|
||||
return false;
|
||||
}
|
||||
InfoRequestData requestData;
|
||||
requestData.caller = caller;
|
||||
requestData.customData = customData;
|
||||
@@ -157,102 +133,82 @@ InfoSystem::getInfo( const QString &caller, const QVariantMap &customData, const
|
||||
requestData.type = type;
|
||||
requestData.input = inputMap[ type ];
|
||||
requestData.timeoutMillis = timeoutMap.contains( type ) ? timeoutMap[ type ] : 10000;
|
||||
QMetaObject::invokeMethod( m_infoSystemWorkerThreadController->worker(), "getInfo", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ) );
|
||||
QMetaObject::invokeMethod( m_worker.data(), "getInfo", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
void
|
||||
InfoSystem::pushInfo( const QString &caller, const InfoType type, const QVariant& input )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
||||
{
|
||||
init();
|
||||
return false;
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod( m_infoSystemWorkerThreadController->worker(), "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input ) );
|
||||
|
||||
return true;
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( m_worker.data(), "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input ) );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
void
|
||||
InfoSystem::pushInfo( const QString &caller, const InfoTypeMap &input )
|
||||
{
|
||||
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
||||
{
|
||||
init();
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_FOREACH( InfoType type, input.keys() )
|
||||
QMetaObject::invokeMethod( m_infoSystemWorkerThreadController->worker(), "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input[ type ] ) );
|
||||
|
||||
return true;
|
||||
QMetaObject::invokeMethod( m_worker.data(), "pushInfo", Qt::QueuedConnection, Q_ARG( QString, caller ), Q_ARG( Tomahawk::InfoSystem::InfoType, type ), Q_ARG( QVariant, input[ type ] ) );
|
||||
}
|
||||
|
||||
|
||||
InfoSystemCacheThread::InfoSystemCacheThread( QObject *parent )
|
||||
: QThread( parent )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
|
||||
InfoSystemCacheThread::~InfoSystemCacheThread()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
delete m_cache.data();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InfoSystemCacheThread::InfoSystemCacheThread::run()
|
||||
{
|
||||
m_cache = QWeakPointer< InfoSystemCache >( new InfoSystemCache() );
|
||||
exec();
|
||||
if ( !m_cache.isNull() )
|
||||
delete m_cache.data();
|
||||
}
|
||||
|
||||
|
||||
InfoSystemCache*
|
||||
QWeakPointer< InfoSystemCache >
|
||||
InfoSystemCacheThread::cache() const
|
||||
{
|
||||
if ( m_cache.isNull() )
|
||||
return 0;
|
||||
return m_cache.data();
|
||||
return m_cache;
|
||||
}
|
||||
|
||||
void
|
||||
InfoSystemCacheThread::setCache( QWeakPointer< InfoSystemCache > cache )
|
||||
{
|
||||
m_cache = cache;
|
||||
}
|
||||
|
||||
InfoSystemWorkerThread::InfoSystemWorkerThread( QObject *parent )
|
||||
: QThread( parent )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
InfoSystemWorkerThread::~InfoSystemWorkerThread()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
void
|
||||
InfoSystemWorkerThread::InfoSystemWorkerThread::run()
|
||||
{
|
||||
m_worker = QWeakPointer< InfoSystemWorker >( new InfoSystemWorker() );
|
||||
exec();
|
||||
if( !m_worker.isNull() )
|
||||
if( m_worker )
|
||||
delete m_worker.data();
|
||||
}
|
||||
|
||||
InfoSystemWorker*
|
||||
QWeakPointer< InfoSystemWorker >
|
||||
InfoSystemWorkerThread::worker() const
|
||||
{
|
||||
if ( m_worker.isNull() )
|
||||
return 0;
|
||||
return m_worker.data();
|
||||
return m_worker;
|
||||
}
|
||||
|
||||
void
|
||||
InfoSystemWorkerThread::setWorker( QWeakPointer< InfoSystemWorker > worker )
|
||||
{
|
||||
m_worker = worker;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -205,7 +205,8 @@ public:
|
||||
virtual ~InfoSystemCacheThread();
|
||||
|
||||
void run();
|
||||
InfoSystemCache* cache() const;
|
||||
QWeakPointer< InfoSystemCache > cache() const;
|
||||
void setCache( QWeakPointer< InfoSystemCache > cache );
|
||||
|
||||
private:
|
||||
QWeakPointer< InfoSystemCache > m_cache;
|
||||
@@ -220,7 +221,8 @@ public:
|
||||
virtual ~InfoSystemWorkerThread();
|
||||
|
||||
void run();
|
||||
InfoSystemWorker* worker() const;
|
||||
QWeakPointer< InfoSystemWorker > worker() const;
|
||||
void setWorker( QWeakPointer< InfoSystemWorker > worker );
|
||||
|
||||
private:
|
||||
QWeakPointer< InfoSystemWorker > m_worker;
|
||||
@@ -236,22 +238,20 @@ public:
|
||||
InfoSystem( QObject *parent );
|
||||
~InfoSystem();
|
||||
|
||||
bool getInfo( const InfoRequestData &requestData );
|
||||
void getInfo( const InfoRequestData &requestData );
|
||||
//WARNING: if changing timeoutMillis above, also change in below function in .cpp file
|
||||
bool getInfo( const QString &caller, const QVariantMap &customData, const InfoTypeMap &inputMap, const InfoTimeoutMap &timeoutMap = InfoTimeoutMap(), bool allSources = false );
|
||||
bool pushInfo( const QString &caller, const InfoType type, const QVariant &input );
|
||||
bool pushInfo( const QString &caller, const InfoTypeMap &input );
|
||||
void getInfo( const QString &caller, const QVariantMap &customData, const InfoTypeMap &inputMap, const InfoTimeoutMap &timeoutMap = InfoTimeoutMap(), bool allSources = false );
|
||||
void pushInfo( const QString &caller, const InfoType type, const QVariant &input );
|
||||
void pushInfo( const QString &caller, const InfoTypeMap &input );
|
||||
|
||||
signals:
|
||||
void info( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void finished( QString target );
|
||||
void finished( QString target, Tomahawk::InfoSystem::InfoType type );
|
||||
|
||||
private slots:
|
||||
void init();
|
||||
|
||||
private:
|
||||
bool m_inited;
|
||||
QWeakPointer< InfoSystemCache > m_cache;
|
||||
QWeakPointer< InfoSystemWorker > m_worker;
|
||||
InfoSystemCacheThread* m_infoSystemCacheThreadController;
|
||||
InfoSystemWorkerThread* m_infoSystemWorkerThreadController;
|
||||
|
||||
@@ -287,7 +287,7 @@ inline uint qHash( Tomahawk::InfoSystem::InfoStringHash hash )
|
||||
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoRequestData );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoStringHash );
|
||||
Q_DECLARE_METATYPE( Tomahawk::InfoSystem::InfoSystemCache* );
|
||||
Q_DECLARE_METATYPE( QList< Tomahawk::InfoSystem::InfoStringHash > );
|
||||
Q_DECLARE_METATYPE( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > );
|
||||
Q_DECLARE_METATYPE( QList<Tomahawk::InfoSystem::InfoStringHash> );
|
||||
|
||||
#endif // TOMAHAWK_INFOSYSTEM_H
|
||||
|
@@ -17,15 +17,11 @@
|
||||
*/
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include <QDesktopServices>
|
||||
#endif
|
||||
|
||||
#include "infosystemcache.h"
|
||||
#include "tomahawksettings.h"
|
||||
#include "utils/logger.h"
|
||||
@@ -40,14 +36,9 @@ namespace InfoSystem
|
||||
|
||||
InfoSystemCache::InfoSystemCache( QObject* parent )
|
||||
: QObject( parent )
|
||||
#ifndef ENABLE_HEADLESS
|
||||
, m_cacheBaseDir( QDesktopServices::storageLocation( QDesktopServices::CacheLocation ) + "/InfoSystemCache/" )
|
||||
#else
|
||||
, m_cacheBaseDir( QDir::tempPath() )
|
||||
#endif
|
||||
, m_cacheVersion( 2 )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
TomahawkSettings *s = TomahawkSettings::instance();
|
||||
if ( s->infoSystemCacheVersion() != m_cacheVersion )
|
||||
{
|
||||
@@ -73,7 +64,6 @@ InfoSystemCache::InfoSystemCache( QObject* parent )
|
||||
|
||||
InfoSystemCache::~InfoSystemCache()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -53,7 +53,7 @@ namespace InfoSystem
|
||||
InfoSystemWorker::InfoSystemWorker()
|
||||
: QObject()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_checkTimeoutsTimer.setInterval( 1000 );
|
||||
m_checkTimeoutsTimer.setSingleShot( false );
|
||||
@@ -64,21 +64,21 @@ InfoSystemWorker::InfoSystemWorker()
|
||||
|
||||
InfoSystemWorker::~InfoSystemWorker()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << " beginning";
|
||||
// qDebug() << Q_FUNC_INFO << " beginning";
|
||||
Q_FOREACH( InfoPluginPtr plugin, m_plugins )
|
||||
{
|
||||
if( plugin )
|
||||
delete plugin.data();
|
||||
}
|
||||
tDebug() << Q_FUNC_INFO << " finished";
|
||||
// qDebug() << Q_FUNC_INFO << " finished";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InfoSystemWorker::init( Tomahawk::InfoSystem::InfoSystemCache* cache )
|
||||
InfoSystemWorker::init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache> cache )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
#ifndef ENABLE_HEADLESS
|
||||
// qDebug() << Q_FUNC_INFO << "and cache is" << cache.data();
|
||||
|
||||
InfoPluginPtr enptr( new EchoNestPlugin() );
|
||||
m_plugins.append( enptr );
|
||||
registerInfoTypes( enptr, enptr.data()->supportedGetTypes(), enptr.data()->supportedPushTypes() );
|
||||
@@ -103,14 +103,13 @@ InfoSystemWorker::init( Tomahawk::InfoSystem::InfoSystemCache* cache )
|
||||
InfoPluginPtr hypeptr( new hypemPlugin() );
|
||||
m_plugins.append( hypeptr );
|
||||
registerInfoTypes( hypeptr, hypeptr.data()->supportedGetTypes(), hypeptr.data()->supportedPushTypes() );
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
InfoPluginPtr admptr( new AdiumPlugin() );
|
||||
m_plugins.append( admptr );
|
||||
registerInfoTypes( admptr, admptr.data()->supportedGetTypes(), admptr.data()->supportedPushTypes() );
|
||||
#endif
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifdef Q_WS_X11
|
||||
InfoPluginPtr fdonotifyptr( new FdoNotifyPlugin() );
|
||||
m_plugins.append( fdonotifyptr );
|
||||
@@ -119,7 +118,7 @@ InfoSystemWorker::init( Tomahawk::InfoSystem::InfoSystemCache* cache )
|
||||
m_plugins.append( mprisptr );
|
||||
registerInfoTypes( mprisptr, mprisptr.data()->supportedGetTypes(), mprisptr.data()->supportedPushTypes() );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Q_FOREACH( InfoPluginPtr plugin, m_plugins )
|
||||
{
|
||||
connect(
|
||||
@@ -133,13 +132,13 @@ InfoSystemWorker::init( Tomahawk::InfoSystem::InfoSystemCache* cache )
|
||||
connect(
|
||||
plugin.data(),
|
||||
SIGNAL( getCachedInfo( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) ),
|
||||
cache,
|
||||
cache.data(),
|
||||
SLOT( getCachedInfoSlot( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoRequestData ) )
|
||||
);
|
||||
connect(
|
||||
plugin.data(),
|
||||
SIGNAL( updateCache( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ),
|
||||
cache,
|
||||
cache.data(),
|
||||
SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) )
|
||||
);
|
||||
}
|
||||
@@ -277,7 +276,7 @@ InfoSystemWorker::checkFinished( const Tomahawk::InfoSystem::InfoRequestData &re
|
||||
{
|
||||
if ( m_dataTracker[ requestData.caller ][ requestData.type ] == 0 )
|
||||
emit finished( requestData.caller, requestData.type );
|
||||
|
||||
|
||||
Q_FOREACH( InfoType testtype, m_dataTracker[ requestData.caller ].keys() )
|
||||
{
|
||||
if ( m_dataTracker[ requestData.caller ][ testtype ] != 0 )
|
||||
|
@@ -55,7 +55,7 @@ signals:
|
||||
void finished( QString target, Tomahawk::InfoSystem::InfoType type );
|
||||
|
||||
public slots:
|
||||
void init( Tomahawk::InfoSystem::InfoSystemCache* cache );
|
||||
void init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > cache );
|
||||
void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input );
|
||||
|
||||
|
@@ -63,7 +63,7 @@ Connection::Connection( Servent* parent )
|
||||
|
||||
Connection::~Connection()
|
||||
{
|
||||
tDebug() << "DTOR connection (super)" << id() << thread() << m_sock.isNull();
|
||||
qDebug() << "DTOR connection (super)" << id() << thread() << m_sock.isNull();
|
||||
if( !m_sock.isNull() )
|
||||
{
|
||||
// qDebug() << "deleteLatering sock" << m_sock;
|
||||
@@ -144,13 +144,13 @@ void
|
||||
Connection::actualShutdown()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << m_actually_shutting_down << id();
|
||||
if ( m_actually_shutting_down )
|
||||
if( m_actually_shutting_down )
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_actually_shutting_down = true;
|
||||
|
||||
if ( !m_sock.isNull() && m_sock->isOpen() )
|
||||
if( !m_sock.isNull() && m_sock->isOpen() )
|
||||
{
|
||||
m_sock->disconnectFromHost();
|
||||
}
|
||||
@@ -261,7 +261,7 @@ Connection::doSetup()
|
||||
void
|
||||
Connection::socketDisconnected()
|
||||
{
|
||||
tDebug() << "SOCKET DISCONNECTED" << this->name() << id()
|
||||
qDebug() << "SOCKET DISCONNECTED" << this->name() << id()
|
||||
<< "shutdown will happen after incoming queue empties."
|
||||
<< "bytesavail:" << m_sock->bytesAvailable()
|
||||
<< "bytesRecvd" << bytesReceived();
|
||||
@@ -423,16 +423,16 @@ Connection::sendMsg_now( msg_ptr msg )
|
||||
{
|
||||
//qDebug() << Q_FUNC_INFO << thread() << QThread::currentThread();
|
||||
Q_ASSERT( QThread::currentThread() == thread() );
|
||||
// Q_ASSERT( this->isRunning() );
|
||||
Q_ASSERT( this->isRunning() );
|
||||
|
||||
if ( m_sock.isNull() || !m_sock->isOpen() || !m_sock->isWritable() )
|
||||
if( m_sock.isNull() || !m_sock->isOpen() || !m_sock->isWritable() )
|
||||
{
|
||||
qDebug() << "***** Socket problem, whilst in sendMsg(). Cleaning up. *****";
|
||||
shutdown( false );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !msg->write( m_sock.data() ) )
|
||||
if( ! msg->write( m_sock.data() ) )
|
||||
{
|
||||
//qDebug() << "Error writing to socket in sendMsg() *************";
|
||||
shutdown( false );
|
||||
|
@@ -130,13 +130,11 @@ ControlConnection::registerSource()
|
||||
Q_UNUSED( source )
|
||||
Q_ASSERT( source == m_source.data() );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
// qDebug() << Q_FUNC_INFO << "Setting avatar ... " << name() << !SipHandler::instance()->avatar( name() ).isNull();
|
||||
if( !SipHandler::instance()->avatar( name() ).isNull() )
|
||||
{
|
||||
source->setAvatar( SipHandler::instance()->avatar( name() ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
m_registered = true;
|
||||
m_servent->registerControlConnection( this );
|
||||
|
@@ -39,6 +39,10 @@
|
||||
#include "sourcelist.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
// close the dbsync connection after this much inactivity.
|
||||
// it's automatically reestablished as needed.
|
||||
#define IDLE_TIMEOUT 300000
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
@@ -48,11 +52,11 @@ DBSyncConnection::DBSyncConnection( Servent* s, const source_ptr& src )
|
||||
, m_state( UNKNOWN )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << src->id() << thread();
|
||||
|
||||
connect( this, SIGNAL( stateChanged( DBSyncConnection::State, DBSyncConnection::State, QString ) ),
|
||||
m_source.data(), SLOT( onStateChanged( DBSyncConnection::State, DBSyncConnection::State, QString ) ) );
|
||||
connect( m_source.data(), SIGNAL( commandsFinished() ),
|
||||
this, SLOT( lastOpApplied() ) );
|
||||
|
||||
m_timer.setInterval( IDLE_TIMEOUT );
|
||||
connect( &m_timer, SIGNAL( timeout() ), SLOT( idleTimeout() ) );
|
||||
|
||||
this->setMsgProcessorModeIn( MsgProcessor::PARSE_JSON | MsgProcessor::UNCOMPRESS_ALL );
|
||||
|
||||
@@ -63,11 +67,19 @@ DBSyncConnection::DBSyncConnection( Servent* s, const source_ptr& src )
|
||||
|
||||
DBSyncConnection::~DBSyncConnection()
|
||||
{
|
||||
tDebug() << "DTOR" << Q_FUNC_INFO << m_source->friendlyName();
|
||||
qDebug() << "DTOR" << Q_FUNC_INFO;
|
||||
m_state = SHUTDOWN;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DBSyncConnection::idleTimeout()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
shutdown( true );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DBSyncConnection::changeState( State newstate )
|
||||
{
|
||||
@@ -84,6 +96,7 @@ DBSyncConnection::changeState( State newstate )
|
||||
void
|
||||
DBSyncConnection::setup()
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
setId( QString( "DBSyncConnection/%1" ).arg( socket()->peerAddress().toString() ) );
|
||||
check();
|
||||
}
|
||||
@@ -92,12 +105,16 @@ DBSyncConnection::setup()
|
||||
void
|
||||
DBSyncConnection::trigger()
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
|
||||
// if we're still setting up the connection, do nothing - we sync on first connect anyway:
|
||||
if ( !isRunning() )
|
||||
return;
|
||||
|
||||
QMetaObject::invokeMethod( this, "sendMsg", Qt::QueuedConnection,
|
||||
Q_ARG( msg_ptr, Msg::factory( "{\"method\":\"trigger\"}", Msg::JSON ) ) );
|
||||
Q_ARG( msg_ptr,
|
||||
Msg::factory( "{\"method\":\"trigger\"}", Msg::JSON ) )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +133,7 @@ DBSyncConnection::check()
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT( m_cmds.isEmpty() );
|
||||
m_uscache.clear();
|
||||
m_us.clear();
|
||||
|
||||
@@ -136,6 +154,9 @@ DBSyncConnection::check()
|
||||
{
|
||||
fetchOpsData( m_source->lastCmdGuid() );
|
||||
}
|
||||
|
||||
// restarts idle countdown
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
|
||||
@@ -210,16 +231,19 @@ DBSyncConnection::handleMsg( msg_ptr msg )
|
||||
if ( msg->is( Msg::DBOP ) )
|
||||
{
|
||||
DatabaseCommand* cmd = DatabaseCommand::factory( m, m_source );
|
||||
if ( cmd )
|
||||
if ( !cmd )
|
||||
{
|
||||
QSharedPointer<DatabaseCommand> cmdsp = QSharedPointer<DatabaseCommand>(cmd);
|
||||
m_source->addCommand( cmdsp );
|
||||
qDebug() << "UNKNOWN DBOP CMD";
|
||||
return;
|
||||
}
|
||||
|
||||
QSharedPointer<DatabaseCommand> cmdsp = QSharedPointer<DatabaseCommand>(cmd);
|
||||
m_cmds << cmdsp;
|
||||
|
||||
if ( !msg->is( Msg::FRAGMENT ) ) // last msg in this batch
|
||||
{
|
||||
changeState( SAVING ); // just DB work left to complete
|
||||
m_source->executeCommands();
|
||||
executeCommands();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -245,11 +269,23 @@ DBSyncConnection::handleMsg( msg_ptr msg )
|
||||
|
||||
|
||||
void
|
||||
DBSyncConnection::lastOpApplied()
|
||||
DBSyncConnection::executeCommands()
|
||||
{
|
||||
changeState( SYNCED );
|
||||
// check again, until peer responds we have no new ops to process
|
||||
check();
|
||||
if ( !m_cmds.isEmpty() )
|
||||
{
|
||||
QSharedPointer<DatabaseCommand> cmd = m_cmds.takeFirst();
|
||||
if ( !cmd->singletonCmd() )
|
||||
m_source->setLastCmdGuid( cmd->guid() );
|
||||
|
||||
connect( cmd.data(), SIGNAL( finished() ), SLOT( executeCommands() ) );
|
||||
Database::instance()->enqueue( cmd );
|
||||
}
|
||||
else
|
||||
{
|
||||
changeState( SYNCED );
|
||||
// check again, until peer responds we have no new ops to process
|
||||
check();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -262,8 +298,8 @@ DBSyncConnection::sendOps()
|
||||
source_ptr src = SourceList::instance()->getLocal();
|
||||
|
||||
DatabaseCommand_loadOps* cmd = new DatabaseCommand_loadOps( src, m_uscache.value( "lastop" ).toString() );
|
||||
connect( cmd, SIGNAL( done( QString, QString, QList< dbop_ptr > ) ),
|
||||
SLOT( sendOpsData( QString, QString, QList< dbop_ptr > ) ) );
|
||||
connect( cmd, SIGNAL( done( QString, QString, QList< dbop_ptr > ) ),
|
||||
SLOT( sendOpsData( QString, QString, QList< dbop_ptr > ) ) );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
@@ -70,9 +70,10 @@ private slots:
|
||||
|
||||
void fetchOpsData( const QString& sinceguid );
|
||||
void sendOpsData( QString sinceguid, QString lastguid, QList< dbop_ptr > ops );
|
||||
void lastOpApplied();
|
||||
void executeCommands();
|
||||
|
||||
void check();
|
||||
void idleTimeout();
|
||||
|
||||
private:
|
||||
void synced();
|
||||
@@ -81,9 +82,11 @@ private:
|
||||
Tomahawk::source_ptr m_source;
|
||||
QVariantMap m_us, m_uscache;
|
||||
|
||||
QList< QSharedPointer<DatabaseCommand> > m_cmds;
|
||||
QString m_lastSentOp;
|
||||
|
||||
State m_state;
|
||||
QTimer m_timer;
|
||||
};
|
||||
|
||||
#endif // DBSYNCCONNECTION_H
|
||||
|
@@ -18,8 +18,7 @@
|
||||
|
||||
#include "portfwdthread.h"
|
||||
|
||||
#include "headlesscheck.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QNetworkInterface>
|
||||
#include <QStringList>
|
||||
#include <QTime>
|
||||
|
@@ -26,11 +26,8 @@
|
||||
#include <QNetworkProxy>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "result.h"
|
||||
#include "source.h"
|
||||
@@ -263,7 +260,6 @@ Servent::unregisterControlConnection( ControlConnection* conn )
|
||||
if( c!=conn )
|
||||
n.append( c );
|
||||
|
||||
m_connectedNodes.removeAll( conn->id() );
|
||||
m_controlconnections = n;
|
||||
}
|
||||
|
||||
@@ -331,6 +327,7 @@ Servent::readyRead()
|
||||
|
||||
ControlConnection* cc = 0;
|
||||
bool ok;
|
||||
// int pport; //FIXME?
|
||||
QString key, conntype, nodeid, controlid;
|
||||
QVariantMap m = parser.parse( sock->_msg->payload(), &ok ).toMap();
|
||||
if( !ok )
|
||||
@@ -338,9 +335,9 @@ Servent::readyRead()
|
||||
tDebug() << "Invalid JSON on new connection, aborting";
|
||||
goto closeconnection;
|
||||
}
|
||||
|
||||
conntype = m.value( "conntype" ).toString();
|
||||
key = m.value( "key" ).toString();
|
||||
// pport = m.value( "port" ).toInt();
|
||||
nodeid = m.value( "nodeid" ).toString();
|
||||
controlid = m.value( "controlid" ).toString();
|
||||
|
||||
@@ -348,25 +345,14 @@ Servent::readyRead()
|
||||
|
||||
if( !nodeid.isEmpty() ) // only control connections send nodeid
|
||||
{
|
||||
bool dupe = false;
|
||||
if ( m_connectedNodes.contains( nodeid ) )
|
||||
dupe = true;
|
||||
|
||||
foreach( ControlConnection* con, m_controlconnections )
|
||||
{
|
||||
tDebug() << "known connection:" << con->id() << con->source()->friendlyName();
|
||||
if( con->id() == nodeid )
|
||||
{
|
||||
dupe = true;
|
||||
break;
|
||||
tLog() << "Duplicate control connection detected, dropping:" << nodeid << conntype;
|
||||
goto closeconnection;
|
||||
}
|
||||
}
|
||||
|
||||
if ( dupe )
|
||||
{
|
||||
tLog() << "Duplicate control connection detected, dropping:" << nodeid << conntype;
|
||||
goto closeconnection;
|
||||
}
|
||||
}
|
||||
|
||||
foreach( ControlConnection* con, m_controlconnections )
|
||||
@@ -385,12 +371,11 @@ Servent::readyRead()
|
||||
Connection* conn = claimOffer( cc, nodeid, key, sock->peerAddress() );
|
||||
if( !conn )
|
||||
{
|
||||
tLog() << "claimOffer FAILED, key:" << key << nodeid;
|
||||
tLog() << "claimOffer FAILED, key:" << key;
|
||||
goto closeconnection;
|
||||
}
|
||||
tDebug( LOGVERBOSE ) << "claimOffer OK:" << key << nodeid;
|
||||
tDebug( LOGVERBOSE ) << "claimOffer OK:" << key;
|
||||
|
||||
m_connectedNodes << nodeid;
|
||||
if( !nodeid.isEmpty() )
|
||||
conn->setId( nodeid );
|
||||
|
||||
@@ -699,7 +684,7 @@ Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialo
|
||||
if( peerStatus == ACLSystem::Deny )
|
||||
return false;
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
//FIXME: Actually enable it when it makes sense
|
||||
return true;
|
||||
if( peerStatus == ACLSystem::NotFound )
|
||||
|
@@ -159,8 +159,6 @@ private:
|
||||
QJson::Parser parser;
|
||||
QList< ControlConnection* > m_controlconnections; // canonical list of authed peers
|
||||
QMap< QString, QWeakPointer<Connection> > m_offers;
|
||||
QStringList m_connectedNodes;
|
||||
|
||||
int m_port, m_externalPort;
|
||||
QHostAddress m_externalAddress;
|
||||
QString m_externalHostname;
|
||||
|
@@ -118,7 +118,6 @@ Tomahawk::ExternalResolver*
|
||||
Pipeline::addScriptResolver( const QString& path, bool start )
|
||||
{
|
||||
ExternalResolver* res = 0;
|
||||
#ifndef ENABLE_HEADLESS
|
||||
const QFileInfo fi( path );
|
||||
|
||||
if ( fi.suffix() == "js" || fi.suffix() == "script" )
|
||||
@@ -129,7 +128,6 @@ Pipeline::addScriptResolver( const QString& path, bool start )
|
||||
m_scriptResolvers << res;
|
||||
if ( start )
|
||||
res->start();
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@@ -182,12 +182,12 @@ PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem&
|
||||
else
|
||||
{
|
||||
upperText = QString( "%1 - %2" ).arg( artist ).arg( track );
|
||||
QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->query()->playedBy().second ), true );
|
||||
QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->query()->playedBy().second ) );
|
||||
|
||||
if ( source == SourceList::instance()->getLocal() )
|
||||
lowerText = QString( "played %1 by you" ).arg( playtime );
|
||||
lowerText = QString( "played %1 ago by you" ).arg( playtime );
|
||||
else
|
||||
lowerText = QString( "played %1 by %2" ).arg( playtime ).arg( source->friendlyName() );
|
||||
lowerText = QString( "played %1 ago by %2" ).arg( playtime ).arg( source->friendlyName() );
|
||||
|
||||
if ( useAvatars )
|
||||
pixmap = source->avatar( Source::FancyStyle );
|
||||
|
@@ -101,9 +101,9 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
|
||||
|
||||
setReadOnly( !m_playlist->author()->isLocal() );
|
||||
setTitle( playlist->title() );
|
||||
setDescription( tr( "A playlist by %1, created %2" )
|
||||
setDescription( tr( "A playlist by %1, created %2 ago" )
|
||||
.arg( playlist->author()->isLocal() ? tr( "you" ) : playlist->author()->friendlyName() )
|
||||
.arg( TomahawkUtils::ageToString( QDateTime::fromTime_t( playlist->createdOn() ), true ) ) );
|
||||
.arg( TomahawkUtils::ageToString( QDateTime::fromTime_t( playlist->createdOn() ) ) ) );
|
||||
|
||||
m_isTemporary = false;
|
||||
if ( !loadEntries )
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#define PLAYLISTINTERFACE_H
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <QWidget>
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "dllmacro.h"
|
||||
|
@@ -18,26 +18,21 @@
|
||||
|
||||
#include "resolver.h"
|
||||
|
||||
|
||||
#include <QWidget>
|
||||
#include <QtUiTools/QUiLoader>
|
||||
#include <QMetaProperty>
|
||||
#include <QBuffer>
|
||||
#include <QDir>
|
||||
#include <QIcon>
|
||||
|
||||
#include "utils/logger.h"
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include <QIcon>
|
||||
#include <QWidget>
|
||||
#endif
|
||||
#include <QUiLoader>
|
||||
|
||||
Tomahawk::ExternalResolver::ErrorState
|
||||
Tomahawk::ExternalResolver::error() const
|
||||
{
|
||||
return NoError;
|
||||
}
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QVariant
|
||||
Tomahawk::ExternalResolver::configMsgFromWidget( QWidget* w )
|
||||
{
|
||||
@@ -50,7 +45,7 @@ Tomahawk::ExternalResolver::configMsgFromWidget( QWidget* w )
|
||||
// qDebug() << "Generated widget variant:" << widgetMap;
|
||||
return widgetMap;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
Tomahawk::ExternalResolver::addChildProperties( QObject* widget, QVariantMap& m )
|
||||
|
@@ -31,10 +31,7 @@
|
||||
#include <network/servent.h>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
#include <QMessageBox>
|
||||
|
||||
// FIXME: bloody hack, remove this for 0.3
|
||||
// this one adds new functionality to old resolvers
|
||||
@@ -176,10 +173,6 @@ QtScriptResolverHelper::customIODeviceFactory( const Tomahawk::result_ptr& resul
|
||||
.arg( QString( QUrl( result->url() ).toEncoded() ) );
|
||||
|
||||
QString urlStr = m_resolver->m_engine->mainFrame()->evaluateJavaScript( getUrl ).toString();
|
||||
|
||||
if ( urlStr.isEmpty() )
|
||||
return QSharedPointer< QIODevice >();
|
||||
|
||||
QUrl url = QUrl::fromEncoded( urlStr.toUtf8() );
|
||||
QNetworkRequest req( url );
|
||||
tDebug() << "Creating a QNetowrkReply with url:" << req.url().toString();
|
||||
@@ -194,11 +187,9 @@ ScriptEngine::javaScriptConsoleMessage( const QString& message, int lineNumber,
|
||||
tLog() << "JAVASCRIPT:" << m_scriptPath << message << lineNumber << sourceID;
|
||||
/// I guess there is somereason for a assert in here, maybe fatal js errors, but
|
||||
/// undefined is not so fatal
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifdef QT_DEBUG
|
||||
QMessageBox::critical( 0, "Script Resolver Error", QString( "%1 %2 %3 %4" ).arg( m_scriptPath ).arg( message ).arg( lineNumber ).arg( sourceID ) );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QThread>
|
||||
|
@@ -22,10 +22,7 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QPluginLoader>
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "functimeout.h"
|
||||
|
||||
@@ -71,7 +68,6 @@ SipHandler::~SipHandler()
|
||||
}
|
||||
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
const QPixmap
|
||||
SipHandler::avatar( const QString& name ) const
|
||||
{
|
||||
@@ -88,7 +84,7 @@ SipHandler::avatar( const QString& name ) const
|
||||
return QPixmap();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
const SipInfo
|
||||
SipHandler::sipInfo(const QString& peerId) const
|
||||
@@ -377,7 +373,7 @@ SipHandler::enablePlugin( SipPlugin* p )
|
||||
void
|
||||
SipHandler::connectPlugin( bool startup, const QString &pluginId )
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
if ( !TomahawkSettings::instance()->acceptedLegalWarning() )
|
||||
{
|
||||
int result = QMessageBox::question(
|
||||
@@ -603,7 +599,7 @@ SipHandler::onStateChanged( SipPlugin::ConnectionState state )
|
||||
emit stateChanged( sip, state );
|
||||
}
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
|
||||
void
|
||||
SipHandler::onAvatarReceived( const QString& from, const QPixmap& avatar )
|
||||
{
|
||||
@@ -648,7 +644,6 @@ SipHandler::onAvatarReceived( const QPixmap& avatar )
|
||||
// qDebug() << Q_FUNC_INFO << "Set own avatar on MyCollection";
|
||||
SourceList::instance()->getLocal()->setAvatar( avatar );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
QString
|
||||
|
@@ -24,13 +24,9 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include <QPixmap>
|
||||
#endif
|
||||
|
||||
|
||||
class DLLEXPORT SipHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -53,10 +49,7 @@ public:
|
||||
bool hasPluginType( const QString& factoryId ) const;
|
||||
SipPluginFactory* factoryFromPlugin( SipPlugin* p ) const;
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
const QPixmap avatar( const QString& name ) const;
|
||||
#endif
|
||||
|
||||
//TODO: implement a proper SipInfo class and maybe attach it to the source
|
||||
const SipInfo sipInfo( const QString& peerId ) const;
|
||||
const QString versionString( const QString& peerId ) const;
|
||||
@@ -104,13 +97,11 @@ private slots:
|
||||
|
||||
void onSettingsChanged();
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
// set data for local source
|
||||
void onAvatarReceived( const QPixmap& avatar );
|
||||
|
||||
// set data for other sources
|
||||
void onAvatarReceived( const QString& from, const QPixmap& avatar );
|
||||
#endif
|
||||
|
||||
private:
|
||||
static SipHandler *s_instance;
|
||||
@@ -131,10 +122,8 @@ private:
|
||||
|
||||
//TODO: move this to source
|
||||
QHash<QString, SipInfo> m_peersSipInfos;
|
||||
QHash<QString, QString> m_peersSoftwareVersions;
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QHash<QString, QPixmap> m_usernameAvatars;
|
||||
#endif
|
||||
QHash<QString, QString> m_peersSoftwareVersions;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -52,7 +52,6 @@ SipPlugin::pluginId() const
|
||||
}
|
||||
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QMenu*
|
||||
SipPlugin::menu()
|
||||
{
|
||||
@@ -67,14 +66,6 @@ SipPlugin::configWidget()
|
||||
}
|
||||
|
||||
|
||||
QIcon
|
||||
SipPlugin::icon() const
|
||||
{
|
||||
return QIcon();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
QString
|
||||
SipPlugin::errorMessage() const
|
||||
{
|
||||
@@ -82,6 +73,13 @@ SipPlugin::errorMessage() const
|
||||
}
|
||||
|
||||
|
||||
QIcon
|
||||
SipPlugin::icon() const
|
||||
{
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
|
||||
const QStringList
|
||||
SipPlugin::peersOnline() const
|
||||
{
|
||||
|
@@ -24,12 +24,9 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QMenu>
|
||||
#include <QNetworkProxy>
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include <QMenu>
|
||||
#endif
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class SipPlugin;
|
||||
@@ -45,12 +42,8 @@ public:
|
||||
virtual QString prettyName() const = 0;
|
||||
// internal name
|
||||
virtual QString factoryId() const = 0;
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
// if the user can create multiple
|
||||
virtual QIcon icon() const { return QIcon(); }
|
||||
#endif
|
||||
|
||||
virtual bool isUnique() const { return false; }
|
||||
|
||||
virtual SipPlugin* createPlugin( const QString& pluginId = QString() ) = 0;
|
||||
@@ -80,12 +73,10 @@ public:
|
||||
virtual const QString accountName() const = 0;
|
||||
virtual ConnectionState connectionState() const = 0;
|
||||
virtual QString errorMessage() const;
|
||||
#ifndef ENABLE_HEADLESS
|
||||
virtual QMenu* menu();
|
||||
virtual QWidget* configWidget();
|
||||
virtual QIcon icon() const;
|
||||
#endif
|
||||
virtual void saveConfig() {} // called when the widget has been edited
|
||||
virtual QIcon icon() const;
|
||||
|
||||
// peer infos
|
||||
virtual const QStringList peersOnline() const;
|
||||
@@ -113,16 +104,15 @@ signals:
|
||||
void sipInfoReceived( const QString& peerId, const SipInfo& info );
|
||||
void softwareVersionReceived( const QString& peerId, const QString& versionString );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
// new data for own source
|
||||
void avatarReceived ( const QPixmap& avatar );
|
||||
|
||||
// new data for other sources;
|
||||
void avatarReceived ( const QString& from, const QPixmap& avatar);
|
||||
|
||||
|
||||
void addMenu( QMenu* menu );
|
||||
void removeMenu( QMenu* menu );
|
||||
#endif
|
||||
|
||||
void dataError( bool );
|
||||
|
||||
|
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "network/controlconnection.h"
|
||||
#include "database/databasecommand_addsource.h"
|
||||
#include "database/databasecommand_collectionstats.h"
|
||||
#include "database/databasecommand_sourceoffline.h"
|
||||
#include "database/databasecommand_updatesearchindex.h"
|
||||
#include "database/database.h"
|
||||
@@ -47,7 +46,6 @@ Source::Source( int id, const QString& username )
|
||||
, m_updateIndexWhenSynced( false )
|
||||
, m_state( DBSyncConnection::UNKNOWN )
|
||||
, m_cc( 0 )
|
||||
, m_commandCount( 0 )
|
||||
, m_avatar( 0 )
|
||||
, m_fancyAvatar( 0 )
|
||||
{
|
||||
@@ -118,7 +116,6 @@ Source::friendlyName() const
|
||||
}
|
||||
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
void
|
||||
Source::setAvatar( const QPixmap& avatar )
|
||||
{
|
||||
@@ -140,7 +137,6 @@ Source::avatar( AvatarStyle style ) const
|
||||
else
|
||||
return QPixmap();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
@@ -228,17 +224,8 @@ void
|
||||
Source::scanningFinished( unsigned int files )
|
||||
{
|
||||
Q_UNUSED( files );
|
||||
|
||||
m_textStatus = QString();
|
||||
|
||||
if ( m_updateIndexWhenSynced )
|
||||
{
|
||||
m_updateIndexWhenSynced = false;
|
||||
updateTracks();
|
||||
}
|
||||
|
||||
emit stateChanged();
|
||||
emit synced();
|
||||
}
|
||||
|
||||
|
||||
@@ -264,16 +251,29 @@ Source::onStateChanged( DBSyncConnection::State newstate, DBSyncConnection::Stat
|
||||
msg = tr( "Parsing" );
|
||||
break;
|
||||
}
|
||||
case DBSyncConnection::SCANNING:
|
||||
case DBSyncConnection::SAVING:
|
||||
{
|
||||
msg = tr( "Scanning (%L1 tracks)" ).arg( info );
|
||||
msg = tr( "Saving" );
|
||||
break;
|
||||
}
|
||||
case DBSyncConnection::SYNCED:
|
||||
{
|
||||
if ( m_updateIndexWhenSynced )
|
||||
{
|
||||
m_updateIndexWhenSynced = false;
|
||||
|
||||
DatabaseCommand* cmd = new DatabaseCommand_UpdateSearchIndex();
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
msg = QString();
|
||||
break;
|
||||
}
|
||||
case DBSyncConnection::SCANNING:
|
||||
{
|
||||
msg = tr( "Scanning (%L1 tracks)" ).arg( info );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
msg = QString();
|
||||
@@ -336,67 +336,6 @@ Source::trackTimerFired()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Source::addCommand( const QSharedPointer<DatabaseCommand>& command )
|
||||
{
|
||||
m_cmds << command;
|
||||
if ( !command->singletonCmd() )
|
||||
m_lastCmdGuid = command->guid();
|
||||
|
||||
m_commandCount = m_cmds.count();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Source::executeCommands()
|
||||
{
|
||||
if ( !m_cmds.isEmpty() )
|
||||
{
|
||||
QList< QSharedPointer<DatabaseCommand> > cmdGroup;
|
||||
QSharedPointer<DatabaseCommand> cmd = m_cmds.takeFirst();
|
||||
while ( cmd->groupable() )
|
||||
{
|
||||
cmdGroup << cmd;
|
||||
if ( !m_cmds.isEmpty() && m_cmds.first()->groupable() && m_cmds.first()->commandname() == cmd->commandname() )
|
||||
cmd = m_cmds.takeFirst();
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
// return here when the last command finished
|
||||
connect( cmd.data(), SIGNAL( finished() ), SLOT( executeCommands() ) );
|
||||
|
||||
if ( cmdGroup.count() )
|
||||
{
|
||||
Database::instance()->enqueue( cmdGroup );
|
||||
}
|
||||
else
|
||||
{
|
||||
Database::instance()->enqueue( cmd );
|
||||
}
|
||||
|
||||
int percentage = ( float( m_commandCount - m_cmds.count() ) / (float)m_commandCount ) * 100.0;
|
||||
m_textStatus = tr( "Saving (%1%)" ).arg( percentage );
|
||||
emit stateChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_updateIndexWhenSynced )
|
||||
{
|
||||
m_updateIndexWhenSynced = false;
|
||||
updateTracks();
|
||||
}
|
||||
|
||||
m_textStatus = QString();
|
||||
m_state = DBSyncConnection::SYNCED;
|
||||
|
||||
emit commandsFinished();
|
||||
emit stateChanged();
|
||||
emit synced();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Source::reportSocialAttributesChanged( DatabaseCommand_SocialAction* action )
|
||||
{
|
||||
@@ -418,27 +357,13 @@ Source::reportSocialAttributesChanged( DatabaseCommand_SocialAction* action )
|
||||
|
||||
|
||||
void
|
||||
Source::updateTracks()
|
||||
Source::updateIndexWhenSynced()
|
||||
{
|
||||
if ( isLocal() )
|
||||
{
|
||||
DatabaseCommand* cmd = new DatabaseCommand_UpdateSearchIndex();
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
{
|
||||
// Re-calculate local db stats
|
||||
DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( SourceList::instance()->get( id() ) );
|
||||
connect( cmd, SIGNAL( done( QVariantMap ) ),
|
||||
this, SLOT( setStats( QVariantMap ) ), Qt::QueuedConnection );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
|
||||
connect( cmd, SIGNAL( finished() ), SIGNAL( stateChanged() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Source::updateIndexWhenSynced()
|
||||
{
|
||||
m_updateIndexWhenSynced = true;
|
||||
else
|
||||
m_updateIndexWhenSynced = true;
|
||||
}
|
||||
|
@@ -61,10 +61,8 @@ public:
|
||||
QString friendlyName() const;
|
||||
void setFriendlyName( const QString& fname );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
void setAvatar( const QPixmap& avatar );
|
||||
QPixmap avatar( AvatarStyle style = Original ) const;
|
||||
#endif
|
||||
|
||||
collection_ptr collection() const;
|
||||
void addCollection( const Tomahawk::collection_ptr& c );
|
||||
@@ -87,8 +85,6 @@ public:
|
||||
|
||||
signals:
|
||||
void syncedWithDatabase();
|
||||
void synced();
|
||||
|
||||
void online();
|
||||
void offline();
|
||||
|
||||
@@ -102,7 +98,6 @@ signals:
|
||||
void playbackFinished( const Tomahawk::query_ptr& query );
|
||||
|
||||
void stateChanged();
|
||||
void commandsFinished();
|
||||
|
||||
void socialAttributesChanged();
|
||||
|
||||
@@ -115,22 +110,18 @@ public slots:
|
||||
private slots:
|
||||
void dbLoaded( unsigned int id, const QString& fname );
|
||||
QString lastCmdGuid() const { return m_lastCmdGuid; }
|
||||
void setLastCmdGuid( const QString& guid ) { m_lastCmdGuid = guid; }
|
||||
void updateIndexWhenSynced();
|
||||
|
||||
void setOffline();
|
||||
void setOnline();
|
||||
|
||||
void onStateChanged( DBSyncConnection::State newstate, DBSyncConnection::State oldstate, const QString& info );
|
||||
|
||||
void onPlaybackStarted( const Tomahawk::query_ptr& query );
|
||||
void onPlaybackFinished( const Tomahawk::query_ptr& query );
|
||||
void trackTimerFired();
|
||||
|
||||
void executeCommands();
|
||||
|
||||
private:
|
||||
void addCommand( const QSharedPointer<DatabaseCommand>& command );
|
||||
void updateTracks();
|
||||
void reportSocialAttributesChanged( DatabaseCommand_SocialAction* action );
|
||||
|
||||
QList< QSharedPointer<Collection> > m_collections;
|
||||
@@ -151,8 +142,6 @@ private:
|
||||
QTimer m_currentTrackTimer;
|
||||
|
||||
ControlConnection* m_cc;
|
||||
QList< QSharedPointer<DatabaseCommand> > m_cmds;
|
||||
int m_commandCount;
|
||||
|
||||
QPixmap* m_avatar;
|
||||
mutable QPixmap* m_fancyAvatar;
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "tomahawksettings.h"
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
#include <QDesktopServices>
|
||||
#include "settingsdialog.h"
|
||||
#endif
|
||||
@@ -40,7 +40,7 @@ using namespace Tomahawk;
|
||||
|
||||
TomahawkSettings* TomahawkSettings::s_instance = 0;
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
|
||||
inline QDataStream& operator<<(QDataStream& out, const AtticaManager::StateHash& states)
|
||||
{
|
||||
out << VERSION;
|
||||
@@ -72,7 +72,6 @@ inline QDataStream& operator>>(QDataStream& in, AtticaManager::StateHash& states
|
||||
}
|
||||
return in;
|
||||
}
|
||||
#endif
|
||||
|
||||
TomahawkSettings*
|
||||
TomahawkSettings::instance()
|
||||
@@ -108,11 +107,8 @@ TomahawkSettings::TomahawkSettings( QObject* parent )
|
||||
setValue( "configversion", VERSION );
|
||||
}
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
qRegisterMetaType< AtticaManager::StateHash >( "AtticaManager::StateHash" );
|
||||
qRegisterMetaTypeStreamOperators<AtticaManager::StateHash>("AtticaManager::StateHash");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +264,7 @@ TomahawkSettings::scannerPaths()
|
||||
{
|
||||
QString musicLocation;
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
musicLocation = QDesktopServices::storageLocation( QDesktopServices::MusicLocation );
|
||||
#endif
|
||||
|
||||
@@ -916,7 +912,6 @@ TomahawkSettings::setEnabledScriptResolvers( const QStringList& resolvers )
|
||||
setValue( "script/loadedresolvers", resolvers );
|
||||
}
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
void
|
||||
TomahawkSettings::setAtticaResolverState( const QString& resolver, AtticaManager::ResolverState state )
|
||||
{
|
||||
@@ -949,7 +944,6 @@ TomahawkSettings::removeAtticaResolverState ( const QString& resolver )
|
||||
resolvers.remove( resolver );
|
||||
setValue( "script/atticaresolverstates", QVariant::fromValue< AtticaManager::StateHash >( resolvers ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
QString
|
||||
TomahawkSettings::scriptDefaultPath() const
|
||||
|
@@ -19,16 +19,15 @@
|
||||
#ifndef TOMAHAWK_SETTINGS_H
|
||||
#define TOMAHAWK_SETTINGS_H
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include "AtticaManager.h"
|
||||
#endif
|
||||
|
||||
#include "playlist.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QtNetwork/QNetworkProxy>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include "AtticaManager.h"
|
||||
#include "playlist.h"
|
||||
|
||||
#include <QtNetwork/QNetworkProxy>
|
||||
|
||||
/**
|
||||
* Convenience wrapper around QSettings for tomahawk-specific config
|
||||
*/
|
||||
@@ -188,13 +187,11 @@ public:
|
||||
QStringList enabledScriptResolvers() const;
|
||||
void setEnabledScriptResolvers( const QStringList& resolvers );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
AtticaManager::StateHash atticaResolverStates() const;
|
||||
void setAtticaResolverStates( const AtticaManager::StateHash states );
|
||||
|
||||
void setAtticaResolverState( const QString& resolver, AtticaManager::ResolverState state );
|
||||
void removeAtticaResolverState( const QString& resolver );
|
||||
#endif
|
||||
|
||||
QString scriptDefaultPath() const;
|
||||
void setScriptDefaultPath( const QString& path );
|
||||
@@ -214,7 +211,7 @@ public:
|
||||
};
|
||||
PrivateListeningMode privateListeningMode() const;
|
||||
void setPrivateListeningMode( PrivateListeningMode mode );
|
||||
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
void recentlyPlayedPlaylistAdded( const Tomahawk::playlist_ptr& playlist );
|
||||
@@ -229,8 +226,6 @@ private:
|
||||
static TomahawkSettings* s_instance;
|
||||
};
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
Q_DECLARE_METATYPE(AtticaManager::StateHash);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -374,6 +374,7 @@ RdioParser::pixmap() const
|
||||
if ( !s_pixmap )
|
||||
s_pixmap = new QPixmap( RESPATH "images/rdio.png" );
|
||||
|
||||
|
||||
return *s_pixmap;
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
@@ -212,13 +212,12 @@ timeToString( int seconds )
|
||||
|
||||
|
||||
QString
|
||||
ageToString( const QDateTime& time, bool appendAgoString )
|
||||
ageToString( const QDateTime& time )
|
||||
{
|
||||
if ( time.toTime_t() == 0 )
|
||||
return QString();
|
||||
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
QString agoToken = appendAgoString ? QString( " %1" ).arg( QObject::tr( "ago" ) ) : QString();
|
||||
|
||||
int mins = time.secsTo( now ) / 60;
|
||||
int hours = mins / 60;
|
||||
@@ -227,56 +226,53 @@ ageToString( const QDateTime& time, bool appendAgoString )
|
||||
int months = days / 30.42;
|
||||
int years = months / 12;
|
||||
|
||||
if ( mins > 0 )
|
||||
if ( years )
|
||||
{
|
||||
if ( years )
|
||||
{
|
||||
if ( years > 1 )
|
||||
return QObject::tr( "%1 years%2" ).arg( years ).arg( agoToken );
|
||||
else
|
||||
return QObject::tr( "%1 year%2" ).arg( years ).arg( agoToken );
|
||||
}
|
||||
|
||||
if ( months )
|
||||
{
|
||||
if ( months > 1 )
|
||||
return QObject::tr( "%1 months%2" ).arg( months ).arg( agoToken );
|
||||
else
|
||||
return QObject::tr( "%1 month%2" ).arg( months ).arg( agoToken );
|
||||
}
|
||||
|
||||
if ( weeks )
|
||||
{
|
||||
if ( weeks > 1 )
|
||||
return QObject::tr( "%1 weeks%2" ).arg( weeks ).arg( agoToken );
|
||||
else
|
||||
return QObject::tr( "%1 week%2" ).arg( weeks ).arg( agoToken );
|
||||
}
|
||||
|
||||
if ( days )
|
||||
{
|
||||
if ( days > 1 )
|
||||
return QObject::tr( "%1 days%2" ).arg( days ).arg( agoToken );
|
||||
else if ( hours >= 24 )
|
||||
return QObject::tr( "%1 day%2" ).arg( days ).arg( agoToken );
|
||||
}
|
||||
|
||||
if ( hours )
|
||||
{
|
||||
if ( hours > 1 )
|
||||
return QObject::tr( "%1 hours%2" ).arg( hours ).arg( agoToken );
|
||||
else
|
||||
return QObject::tr( "%1 hour%2" ).arg( hours ).arg( agoToken );
|
||||
}
|
||||
|
||||
if ( mins )
|
||||
{
|
||||
if ( mins > 1 )
|
||||
return QObject::tr( "%1 minutes%2" ).arg( mins ).arg( agoToken );
|
||||
}
|
||||
if ( years > 1 )
|
||||
return QObject::tr( "%1 years" ).arg( years );
|
||||
else
|
||||
return QObject::tr( "%1 year" ).arg( years );
|
||||
}
|
||||
|
||||
return QObject::tr( "just now" );
|
||||
if ( months )
|
||||
{
|
||||
if ( months > 1 )
|
||||
return QObject::tr( "%1 months" ).arg( months );
|
||||
else
|
||||
return QObject::tr( "%1 month" ).arg( months );
|
||||
}
|
||||
|
||||
if ( weeks )
|
||||
{
|
||||
if ( weeks > 1 )
|
||||
return QObject::tr( "%1 weeks" ).arg( weeks );
|
||||
else
|
||||
return QObject::tr( "%1 week" ).arg( weeks );
|
||||
}
|
||||
|
||||
if ( days )
|
||||
{
|
||||
if ( days > 1 )
|
||||
return QObject::tr( "%1 days" ).arg( days );
|
||||
else
|
||||
return QObject::tr( "%1 day" ).arg( days );
|
||||
}
|
||||
|
||||
if ( hours )
|
||||
{
|
||||
if ( hours > 1 )
|
||||
return QObject::tr( "%1 hours" ).arg( hours );
|
||||
else
|
||||
return QObject::tr( "%1 hour" ).arg( hours );
|
||||
}
|
||||
|
||||
if ( mins )
|
||||
{
|
||||
if ( mins > 1 )
|
||||
return QObject::tr( "%1 minutes" ).arg( mins );
|
||||
}
|
||||
|
||||
return QObject::tr( "1 minute" );
|
||||
}
|
||||
|
||||
|
||||
@@ -450,7 +446,6 @@ drawBackgroundAndNumbers( QPainter* painter, const QString& text, const QRect& f
|
||||
painter->drawText( figRect.adjusted( -5, 0, 6, 0 ), text, to );
|
||||
}
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
void
|
||||
drawQueryBackground( QPainter* p, const QPalette& palette, const QRect& r, qreal lightnessFactor )
|
||||
{
|
||||
@@ -474,7 +469,6 @@ unmarginLayout( QLayout* layout )
|
||||
unmarginLayout( childLayout );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
NetworkProxyFactory::NetworkProxyFactory( const NetworkProxyFactory& other )
|
||||
@@ -643,7 +637,7 @@ nam()
|
||||
s_threadNamHash[ QThread::currentThread() ] = newNam;
|
||||
|
||||
tDebug( LOGEXTRA ) << "created new nam for thread " << QThread::currentThread();
|
||||
|
||||
|
||||
return newNam;
|
||||
}
|
||||
|
||||
@@ -667,8 +661,6 @@ setNam( QNetworkAccessManager* nam, bool noMutexLocker )
|
||||
tDebug( LOGEXTRA ) << "Setting proxy to saved values";
|
||||
QNetworkProxy proxy( s->proxyType(), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() );
|
||||
proxyFactory->setProxy( proxy );
|
||||
//FIXME: Jreen is broke without this
|
||||
QNetworkProxy::setApplicationProxy( proxy );
|
||||
}
|
||||
if ( !s->proxyNoProxyHosts().isEmpty() )
|
||||
proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ',', QString::SkipEmptyParts ) );
|
||||
@@ -686,7 +678,8 @@ setNam( QNetworkAccessManager* nam, bool noMutexLocker )
|
||||
}
|
||||
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
|
||||
QWidget*
|
||||
tomahawkWindow()
|
||||
{
|
||||
|
@@ -26,10 +26,7 @@
|
||||
#include <QtNetwork/QNetworkProxy>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QRect>
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include <QPalette>
|
||||
#endif
|
||||
#include <QPalette>
|
||||
|
||||
#define RESPATH ":/data/"
|
||||
|
||||
@@ -85,7 +82,7 @@ namespace TomahawkUtils
|
||||
|
||||
DLLEXPORT QString sqlEscape( QString sql );
|
||||
DLLEXPORT QString timeToString( int seconds );
|
||||
DLLEXPORT QString ageToString( const QDateTime& time, bool appendAgoString = false );
|
||||
DLLEXPORT QString ageToString( const QDateTime& time );
|
||||
DLLEXPORT QString filesizeToString( unsigned int size );
|
||||
DLLEXPORT QString extensionToMimetype( const QString& extension );
|
||||
|
||||
@@ -93,14 +90,8 @@ namespace TomahawkUtils
|
||||
DLLEXPORT QPixmap createDragPixmap( MediaType type, int itemCount = 1 );
|
||||
|
||||
DLLEXPORT void drawBackgroundAndNumbers( QPainter* p, const QString& text, const QRect& rect );
|
||||
#ifndef ENABLE_HEADLESS
|
||||
DLLEXPORT void drawQueryBackground( QPainter* p, const QPalette& palette, const QRect& r, qreal lightnessFactor = 1 );
|
||||
DLLEXPORT QWidget* tomahawkWindow();
|
||||
/// Platform-specific bringing tomahawk mainwindow to front, b/c qt's activate() and such don't seem to work well enough for us
|
||||
DLLEXPORT void bringToFront();
|
||||
|
||||
DLLEXPORT QPixmap createAvatarFrame( const QPixmap &avatar );
|
||||
#endif
|
||||
DLLEXPORT void unmarginLayout( QLayout* layout );
|
||||
|
||||
DLLEXPORT NetworkProxyFactory* proxyFactory( bool noMutexLocker = false );
|
||||
@@ -109,6 +100,12 @@ namespace TomahawkUtils
|
||||
DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory, bool noMutexLocker = false );
|
||||
DLLEXPORT void setNam( QNetworkAccessManager* nam, bool noMutexLocker = false );
|
||||
|
||||
DLLEXPORT QWidget* tomahawkWindow();
|
||||
/// Platform-specific bringing tomahawk mainwindow to front, b/c qt's activate() and such don't seem to work well enough for us
|
||||
DLLEXPORT void bringToFront();
|
||||
|
||||
DLLEXPORT QPixmap createAvatarFrame( const QPixmap &avatar );
|
||||
|
||||
DLLEXPORT void crash();
|
||||
|
||||
DLLEXPORT int headerHeight();
|
||||
|
@@ -18,8 +18,7 @@
|
||||
|
||||
#include "xspfloader.h"
|
||||
|
||||
#include "headlesscheck.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDomDocument>
|
||||
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
@@ -299,9 +299,6 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
QRect r( option.rect.width() - avatar.width() - 10, option.rect.top() + option.rect.height()/2 - avatar.height()/2, avatar.width(), avatar.height() );
|
||||
painter->drawPixmap( r, avatar );
|
||||
|
||||
QFont font2 = font;
|
||||
font2.setPointSize( font2.pointSize() - 1 );
|
||||
painter->setFont( font2 );
|
||||
QString author = index.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >()->author()->friendlyName();
|
||||
if ( author.contains( "@" ) )
|
||||
author = author.mid( 0, author.indexOf( '@' ) );
|
||||
@@ -321,6 +318,9 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
}
|
||||
QColor c = painter->pen().color();
|
||||
painter->setPen( QColor( Qt::gray ).darker() );
|
||||
QFont font2 = font;
|
||||
font2.setPointSize( font2.pointSize() - 1 );
|
||||
painter->setFont( font2 );
|
||||
|
||||
QRect rectText = option.rect.adjusted( 66, 20, -leftEdge - 10, -8 );
|
||||
#ifdef Q_WS_MAC
|
||||
|
@@ -20,9 +20,9 @@
|
||||
#include "whatshotwidget.h"
|
||||
#include "ui_whatshotwidget.h"
|
||||
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QStandardItemModel>
|
||||
#include <QtGui/QStandardItem>
|
||||
#include <QPainter>
|
||||
#include <QStandardItemModel>
|
||||
#include <QStandardItem>
|
||||
|
||||
#include "viewmanager.h"
|
||||
#include "sourcelist.h"
|
||||
@@ -156,15 +156,9 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
return;
|
||||
}
|
||||
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot: got something...";
|
||||
if ( !output.canConvert< QVariantMap >() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot: Could not parse output";
|
||||
return;
|
||||
}
|
||||
|
||||
tDebug( LOGVERBOSE ) << "WhatsHot: got something...";
|
||||
QVariantMap returnedData = output.toMap();
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot::" << returnedData;
|
||||
qDebug() << "WhatsHot::" << returnedData;
|
||||
switch ( requestData.type )
|
||||
{
|
||||
case InfoSystem::InfoChartCapabilities:
|
||||
@@ -180,9 +174,9 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
|
||||
foreach ( const QString label, returnedData.keys() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot:: parsing " << label;
|
||||
tDebug( LOGVERBOSE ) << "WhatsHot:: parsing " << label;
|
||||
QStandardItem *childItem = parseNode( rootItem, label, returnedData[label] );
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot:: appending" << childItem->text();
|
||||
tDebug( LOGVERBOSE ) << "WhatsHot:: appending" << childItem->text();
|
||||
rootItem->appendRow(childItem);
|
||||
}
|
||||
|
||||
@@ -193,7 +187,7 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
QStandardItem* source = rootItem->child( i, 0 );
|
||||
if ( defaultSource.toLower() == source->text().toLower() )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Setting DEFAULT SOURCE:" << source->text();
|
||||
qDebug() << "Setting DEFAULT SOURCE:" << source->text();
|
||||
source->setData( true, Breadcrumb::DefaultRole );
|
||||
}
|
||||
|
||||
@@ -209,7 +203,7 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
{
|
||||
if ( cur->child( k, 0 )->text() == index )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Found DEFAULT ITEM:" << index;
|
||||
tDebug() << "Found DEFAULT ITEM:" << index;
|
||||
cur = cur->child( k, 0 ); // this is the default, drill down into the default to pick the next default
|
||||
cur->setData( true, Breadcrumb::DefaultRole );
|
||||
break;
|
||||
@@ -235,11 +229,11 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
const QString chartId = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >().value( "chart_id" );
|
||||
|
||||
m_queuedFetches.remove( chartId );
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot: got chart! " << type << " on " << side;
|
||||
tDebug( LOGVERBOSE ) << "WhatsHot: got chart! " << type << " on " << side;
|
||||
if( type == "artists" )
|
||||
{
|
||||
const QStringList artists = returnedData["artists"].toStringList();
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot: got artists! " << artists.size();
|
||||
tDebug( LOGVERBOSE ) << "WhatsHot: got artists! " << artists.size();
|
||||
|
||||
TreeModel* artistsModel = new TreeModel( ui->artistsViewLeft );
|
||||
artistsModel->setColumnStyle( TreeModel::TrackOnly );
|
||||
@@ -257,19 +251,19 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
else if( type == "albums" )
|
||||
{
|
||||
QList<album_ptr> al;
|
||||
const QList< Tomahawk::InfoSystem::InfoStringHash > albums = returnedData[ "albums" ].value< QList< Tomahawk::InfoSystem::InfoStringHash > >();
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot: got albums! " << albums.size();
|
||||
const QList<Tomahawk::InfoSystem::InfoStringHash> albums = returnedData[ "albums" ].value<QList<Tomahawk::InfoSystem::InfoStringHash> >();
|
||||
tDebug( LOGVERBOSE ) << "WhatsHot: got albums! " << albums.size();
|
||||
|
||||
AlbumModel* albumModel = new AlbumModel( ui->additionsView );
|
||||
foreach ( const Tomahawk::InfoSystem::InfoStringHash& album, albums )
|
||||
{
|
||||
tDebug( LOGVERBOSE) << Q_FUNC_INFO << "Getting album" << album[ "album" ] << "By" << album[ "artist" ];
|
||||
qDebug() << "Getting album" << album[ "album" ] << "By" << album[ "artist" ];
|
||||
artist_ptr artistPtr = Artist::get( album[ "artist" ], false );
|
||||
album_ptr albumPtr = Album::get( artistPtr, album[ "album" ], false );
|
||||
al << albumPtr;
|
||||
|
||||
}
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Adding albums to model";
|
||||
qDebug() << "Adding albums to model";
|
||||
albumModel->addAlbums( al );
|
||||
|
||||
m_albumModels[ chartId ] = albumModel;
|
||||
@@ -279,7 +273,7 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
}
|
||||
else if( type == "tracks" )
|
||||
{
|
||||
const QList< Tomahawk::InfoSystem::InfoStringHash > tracks = returnedData[ "tracks" ].value< QList< Tomahawk::InfoSystem::InfoStringHash > >();
|
||||
const QList<Tomahawk::InfoSystem::InfoStringHash> tracks = returnedData[ "tracks" ].value<QList<Tomahawk::InfoSystem::InfoStringHash> >();
|
||||
tDebug( LOGVERBOSE ) << "WhatsHot: got tracks! " << tracks.size();
|
||||
|
||||
PlaylistModel* trackModel = new PlaylistModel( ui->tracksViewLeft );
|
||||
@@ -300,7 +294,7 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
|
||||
}
|
||||
else
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "WhatsHot: got unknown chart type" << type;
|
||||
tDebug( LOGVERBOSE ) << "WhatsHot: got unknown chart type" << type;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@@ -56,11 +56,8 @@
|
||||
- (Tomahawk::PlatformInterface*) application_handler;
|
||||
- (void) setApplicationHandler: (Tomahawk::PlatformInterface*)handler;
|
||||
|
||||
#ifdef HAVE_SPARKLE
|
||||
// SUUpdaterDelegate
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -212,14 +209,12 @@
|
||||
[super sendEvent: event];
|
||||
}
|
||||
|
||||
#ifdef HAVE_SPARKLE
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update
|
||||
{
|
||||
tLog() << "NSApp in willInstallUpdate, deleting Phonon objects";
|
||||
AudioEngine::instance()->stop();
|
||||
delete AudioEngine::instance();
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
@@ -16,13 +16,12 @@
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "tomahawkapp.h"
|
||||
|
||||
#include "thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h"
|
||||
#include <QTranslator>
|
||||
|
||||
|
||||
#include "breakpad/BreakPad.h"
|
||||
#include "ubuntuunityhack.h"
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
@@ -31,9 +30,6 @@
|
||||
static pascal OSErr appleEventHandler( const AppleEvent*, AppleEvent*, long );
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include "breakpad/BreakPad.h"
|
||||
#endif
|
||||
|
||||
int
|
||||
main( int argc, char *argv[] )
|
||||
@@ -58,10 +54,7 @@ main( int argc, char *argv[] )
|
||||
#endif
|
||||
|
||||
TomahawkApp a( argc, argv );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
new BreakPad( QDir::tempPath() );
|
||||
#endif
|
||||
|
||||
KDSingleApplicationGuard guard( &a, KDSingleApplicationGuard::AutoKillOtherInstances );
|
||||
QObject::connect( &guard, SIGNAL( instanceStarted( KDSingleApplicationGuard::Instance ) ), &a, SLOT( instanceStarted( KDSingleApplicationGuard::Instance ) ) );
|
||||
|
@@ -194,7 +194,7 @@ MusicScanner::listerFinished()
|
||||
commitBatch( m_scannedfiles, m_filesToDelete );
|
||||
m_scannedfiles.clear();
|
||||
m_filesToDelete.clear();
|
||||
|
||||
|
||||
tDebug( LOGINFO ) << "Scanning complete, saving to database. "
|
||||
"( scanned" << m_scanned << "skipped" << m_skipped << ")";
|
||||
|
||||
|
@@ -197,12 +197,13 @@ ResolversModel::addInstalledResolvers()
|
||||
|
||||
QDir appDir( qApp->applicationDirPath() );
|
||||
QDir libDir( CMAKE_INSTALL_PREFIX "/lib" );
|
||||
QDir libexecDir( CMAKE_INSTALL_LIBEXECDIR );
|
||||
|
||||
QDir lib64Dir( appDir );
|
||||
lib64Dir.cdUp();
|
||||
lib64Dir.cd( "lib64" );
|
||||
|
||||
pluginDirs << appDir << libDir << lib64Dir << QDir( qApp->applicationDirPath() );
|
||||
pluginDirs << appDir << libDir << lib64Dir << libexecDir << QDir( qApp->applicationDirPath() );
|
||||
foreach ( const QDir& pluginDir, pluginDirs )
|
||||
{
|
||||
qDebug() << "Checking directory for resolvers:" << pluginDir;
|
||||
|
@@ -2,8 +2,8 @@ IF( LIBJREEN_FOUND )
|
||||
ADD_SUBDIRECTORY( jabber )
|
||||
ENDIF( LIBJREEN_FOUND )
|
||||
|
||||
IF( QTWEETLIB_FOUND AND BUILD_GUI )
|
||||
IF( QTWEETLIB_FOUND )
|
||||
ADD_SUBDIRECTORY( twitter )
|
||||
ENDIF()
|
||||
ENDIF( QTWEETLIB_FOUND )
|
||||
|
||||
ADD_SUBDIRECTORY( zeroconf )
|
||||
|
@@ -10,16 +10,12 @@ set( jabberSources
|
||||
jabber.cpp
|
||||
tomahawksipmessage.cpp
|
||||
tomahawksipmessagefactory.cpp
|
||||
)
|
||||
set( jabberSourcesGui
|
||||
avatarmanager.cpp
|
||||
xmlconsole.cpp
|
||||
)
|
||||
|
||||
set( jabberHeaders
|
||||
jabber.h
|
||||
)
|
||||
set( jabberHeadersGui
|
||||
avatarmanager.h
|
||||
xmlconsole.h
|
||||
)
|
||||
@@ -29,11 +25,6 @@ set( jabberUI
|
||||
xmlconsole.ui
|
||||
)
|
||||
|
||||
if(BUILD_GUI)
|
||||
list(APPEND jabberSources ${jabberSourcesGui})
|
||||
list(APPEND jabberHeaders ${jabberHeadersGui})
|
||||
endif()
|
||||
|
||||
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
|
||||
${QT_INCLUDE_DIR}
|
||||
${LIBJREEN_INCLUDE_DIR}
|
||||
@@ -66,6 +57,5 @@ ENDIF( APPLE )
|
||||
|
||||
install( TARGETS tomahawk_sipjabber DESTINATION lib${LIB_SUFFIX} )
|
||||
|
||||
if(BUILD_GUI)
|
||||
add_subdirectory(googlewrapper)
|
||||
endif()
|
||||
|
||||
add_subdirectory(googlewrapper)
|
||||
|
@@ -20,6 +20,8 @@
|
||||
#include "jabber.h"
|
||||
#include "ui_configwidget.h"
|
||||
|
||||
#include "xmlconsole.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "tomahawksettings.h"
|
||||
@@ -40,16 +42,12 @@
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QStringList>
|
||||
#include <QInputDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QDateTime>
|
||||
#include <QTimer>
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include <QInputDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
|
||||
|
||||
#include <utils/tomahawkutils.h>
|
||||
#include "utils/logger.h"
|
||||
|
||||
@@ -67,34 +65,30 @@ JabberFactory::icon() const
|
||||
|
||||
JabberPlugin::JabberPlugin( const QString& pluginId )
|
||||
: SipPlugin( pluginId )
|
||||
#ifndef ENABLE_HEADLESS
|
||||
, m_menu( 0 )
|
||||
, m_xmlConsole( 0 )
|
||||
#endif
|
||||
, m_state( Disconnected )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_configWidget = QWeakPointer< QWidget >( new QWidget );
|
||||
m_ui = new Ui_JabberConfig;
|
||||
m_ui->setupUi( m_configWidget.data() );
|
||||
m_configWidget.data()->setVisible( false );
|
||||
|
||||
m_currentUsername = accountName();
|
||||
m_currentServer = readServer();
|
||||
m_currentPassword = readPassword();
|
||||
m_currentPort = readPort();
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
m_configWidget = QWeakPointer< QWidget >( new QWidget );
|
||||
m_ui = new Ui_JabberConfig;
|
||||
m_ui->setupUi( m_configWidget.data() );
|
||||
m_configWidget.data()->setVisible( false );
|
||||
|
||||
m_ui->jabberUsername->setText( m_currentUsername );
|
||||
m_ui->jabberPassword->setText( m_currentPassword );
|
||||
m_ui->jabberServer->setText( m_currentServer );
|
||||
m_ui->jabberPort->setValue( m_currentPort );
|
||||
m_ui->jidExistsLabel->hide();
|
||||
|
||||
|
||||
connect( m_ui->jabberUsername, SIGNAL( textChanged( QString ) ), SLOT( onCheckJidExists( QString ) ) );
|
||||
#endif
|
||||
|
||||
|
||||
// setup JID object
|
||||
Jreen::JID jid = Jreen::JID( accountName() );
|
||||
|
||||
@@ -106,24 +100,21 @@ JabberPlugin::JabberPlugin( const QString& pluginId )
|
||||
m_currentResource = QString::fromAscii( "tomahawk%1" ).arg( QString::number( qrand() % 10000 ) );
|
||||
m_client->setResource( m_currentResource );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
// instantiate XmlConsole
|
||||
if( readXmlConsoleEnabled() )
|
||||
{
|
||||
m_xmlConsole = new XmlConsole( m_client );
|
||||
m_xmlConsole->show();
|
||||
}
|
||||
#endif
|
||||
|
||||
// add VCardUpdate extension to own presence
|
||||
m_client->presence().addExtension( new Jreen::VCardUpdate() );
|
||||
|
||||
// initaliaze the roster
|
||||
m_roster = new Jreen::SimpleRoster( m_client );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
// initialize the AvatarManager
|
||||
m_avatarManager = new AvatarManager( m_client );
|
||||
#endif
|
||||
|
||||
// setup disco
|
||||
m_client->disco()->setSoftwareVersion( "Tomahawk Player", TOMAHAWK_VERSION, CMAKE_SYSTEM );
|
||||
@@ -151,18 +142,14 @@ JabberPlugin::JabberPlugin( const QString& pluginId )
|
||||
connect(m_roster, SIGNAL(subscriptionReceived(Jreen::RosterItem::Ptr,Jreen::Presence)),
|
||||
SLOT(onSubscriptionReceived(Jreen::RosterItem::Ptr,Jreen::Presence)));
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
connect(m_avatarManager, SIGNAL(newAvatar(QString)), SLOT(onNewAvatar(QString)));
|
||||
#endif
|
||||
}
|
||||
|
||||
JabberPlugin::~JabberPlugin()
|
||||
{
|
||||
delete m_avatarManager;
|
||||
delete m_roster;
|
||||
#ifndef ENABLE_HEADLESS
|
||||
delete m_xmlConsole;
|
||||
#endif
|
||||
delete m_client;
|
||||
delete m_ui;
|
||||
}
|
||||
@@ -186,7 +173,6 @@ JabberPlugin::accountName() const
|
||||
return TomahawkSettings::instance()->value( pluginId() + "/username" ).toString();
|
||||
}
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QMenu*
|
||||
JabberPlugin::menu()
|
||||
{
|
||||
@@ -204,7 +190,7 @@ JabberPlugin::icon() const
|
||||
{
|
||||
return QIcon( ":/jabber-icon.png" );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool
|
||||
JabberPlugin::connectPlugin( bool startup )
|
||||
@@ -470,7 +456,6 @@ JabberPlugin::addContact(const QString& jid, const QString& msg)
|
||||
void
|
||||
JabberPlugin::showAddFriendDialog()
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
bool ok;
|
||||
QString id = QInputDialog::getText( TomahawkUtils::tomahawkWindow(), tr( "Add Friend" ),
|
||||
tr( "Enter Jabber ID:" ), QLineEdit::Normal, "", &ok );
|
||||
@@ -479,7 +464,6 @@ JabberPlugin::showAddFriendDialog()
|
||||
|
||||
qDebug() << "Attempting to add jabber contact to roster:" << id;
|
||||
addContact( id );
|
||||
#endif
|
||||
}
|
||||
|
||||
QString
|
||||
@@ -492,9 +476,7 @@ JabberPlugin::defaultSuffix() const
|
||||
void
|
||||
JabberPlugin::showXmlConsole()
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
m_xmlConsole->show();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@@ -571,7 +553,6 @@ void JabberPlugin::setupClientHelper()
|
||||
|
||||
void JabberPlugin::addMenuHelper()
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
if( !m_menu )
|
||||
{
|
||||
m_menu = new QMenu( QString( "%1 (" ).arg( friendlyName() ).append( accountName() ).append(")" ) );
|
||||
@@ -587,12 +568,10 @@ void JabberPlugin::addMenuHelper()
|
||||
|
||||
emit addMenu( m_menu );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void JabberPlugin::removeMenuHelper()
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
if( m_menu )
|
||||
{
|
||||
emit removeMenu( m_menu );
|
||||
@@ -600,7 +579,6 @@ void JabberPlugin::removeMenuHelper()
|
||||
delete m_menu;
|
||||
m_menu = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void JabberPlugin::onNewMessage(const Jreen::Message& message)
|
||||
@@ -721,7 +699,7 @@ void JabberPlugin::onSubscriptionReceived(const Jreen::RosterItem::Ptr& item, co
|
||||
|
||||
return;
|
||||
}
|
||||
#ifndef ENABLE_HEADLESS
|
||||
|
||||
// preparing the confirm box for the user
|
||||
QMessageBox *confirmBox = new QMessageBox(
|
||||
QMessageBox::Question,
|
||||
@@ -736,13 +714,11 @@ void JabberPlugin::onSubscriptionReceived(const Jreen::RosterItem::Ptr& item, co
|
||||
|
||||
// display the box and wait for the answer
|
||||
confirmBox->open( this, SLOT( onSubscriptionRequestConfirmed( int ) ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
JabberPlugin::onSubscriptionRequestConfirmed( int result )
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
qDebug() << Q_FUNC_INFO << result;
|
||||
|
||||
QList< QMessageBox* > confirmBoxes = m_subscriptionConfirmBoxes.values();
|
||||
@@ -773,7 +749,6 @@ JabberPlugin::onSubscriptionRequestConfirmed( int result )
|
||||
}
|
||||
|
||||
m_roster->allowSubscription( jid, allowSubscription == QMessageBox::Yes );
|
||||
#endif
|
||||
}
|
||||
|
||||
void JabberPlugin::onNewIq(const Jreen::IQ& iq)
|
||||
@@ -901,10 +876,8 @@ void JabberPlugin::handlePeerStatus(const Jreen::JID& jid, Jreen::Presence::Type
|
||||
|
||||
emit peerOnline( fulljid );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
if(!m_avatarManager->avatar(jid.bare()).isNull())
|
||||
onNewAvatar( jid.bare() );
|
||||
#endif
|
||||
|
||||
// request software version
|
||||
Jreen::IQ versionIq( Jreen::IQ::Get, jid );
|
||||
@@ -922,7 +895,6 @@ void JabberPlugin::handlePeerStatus(const Jreen::JID& jid, Jreen::Presence::Type
|
||||
|
||||
void JabberPlugin::onNewAvatar(const QString& jid)
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
// qDebug() << Q_FUNC_INFO << jid;
|
||||
if ( m_state != Connected )
|
||||
return;
|
||||
@@ -945,7 +917,6 @@ void JabberPlugin::onNewAvatar(const QString& jid)
|
||||
else
|
||||
// someone else's avatar
|
||||
emit avatarReceived ( jid, m_avatarManager->avatar( jid ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
|
@@ -23,10 +23,7 @@
|
||||
#include "sip/SipPlugin.h"
|
||||
|
||||
#include "avatarmanager.h"
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include "xmlconsole.h"
|
||||
#endif
|
||||
#include "xmlconsole.h"
|
||||
|
||||
#include <jreen/client.h>
|
||||
#include <jreen/disco.h>
|
||||
@@ -41,9 +38,7 @@
|
||||
#include <jreen/connection.h>
|
||||
#include <jreen/mucroom.h>
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
#include <QMessageBox>
|
||||
|
||||
#define MYNAME "SIPJREEN"
|
||||
#define TOMAHAWK_FEATURE QLatin1String( "tomahawk:sip:v1" )
|
||||
@@ -82,12 +77,9 @@ public:
|
||||
virtual const QString friendlyName() const;
|
||||
virtual const QString accountName() const;
|
||||
virtual ConnectionState connectionState() const;
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
virtual QMenu* menu();
|
||||
virtual QIcon icon() const;
|
||||
virtual QWidget* configWidget();
|
||||
#endif
|
||||
virtual void saveConfig();
|
||||
virtual void deletePlugin();
|
||||
|
||||
@@ -140,6 +132,8 @@ private:
|
||||
|
||||
using SipPlugin::errorMessage;
|
||||
|
||||
QMenu* m_menu;
|
||||
XmlConsole* m_xmlConsole;
|
||||
QString m_currentUsername;
|
||||
QString m_currentPassword;
|
||||
QString m_currentServer;
|
||||
@@ -156,11 +150,7 @@ private:
|
||||
Jreen::MUCRoom *m_room;
|
||||
Jreen::SimpleRoster *m_roster;
|
||||
QHash<Jreen::JID, Jreen::Presence::Type> m_peers;
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QHash<Jreen::JID, QMessageBox*> m_subscriptionConfirmBoxes;
|
||||
QMenu* m_menu;
|
||||
XmlConsole* m_xmlConsole;
|
||||
#endif
|
||||
enum IqContext { NoContext, RequestDisco, RequestedDisco, SipMessageSent, RequestedVCard, RequestVersion, RequestedVersion };
|
||||
AvatarManager *m_avatarManager;
|
||||
};
|
||||
|
@@ -168,7 +168,7 @@ TwitterPlugin::connectPlugin( bool startup )
|
||||
qStableSort( peerList.begin(), peerList.end() );
|
||||
|
||||
registerOffers( peerList );
|
||||
|
||||
|
||||
if ( twitterOAuthToken().isEmpty() || twitterOAuthTokenSecret().isEmpty() )
|
||||
{
|
||||
qDebug() << "TwitterPlugin has empty Twitter credentials; not connecting";
|
||||
@@ -337,7 +337,7 @@ TwitterPlugin::registerOffers( const QStringList &peerList )
|
||||
m_cachedPeers.remove( screenName );
|
||||
syncConfig();
|
||||
}
|
||||
|
||||
|
||||
if ( Servent::instance()->connectedToSession( peerData["node"].toString() ) )
|
||||
{
|
||||
peerData["lastseen"] = QDateTime::currentMSecsSinceEpoch();
|
||||
@@ -354,13 +354,13 @@ TwitterPlugin::registerOffers( const QStringList &peerList )
|
||||
m_cachedAvatars.remove( screenName );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) )
|
||||
{
|
||||
qDebug() << "TwitterPlugin does not have host, port and/or pkey values for " << screenName << " (this is usually *not* a bug or problem but a normal part of the process)";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), Q_ARG( QVariantHash, peerData ) );
|
||||
}
|
||||
}
|
||||
|
@@ -72,13 +72,12 @@ ZeroconfPlugin::connectionState() const
|
||||
return m_state;
|
||||
}
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QIcon
|
||||
ZeroconfFactory::icon() const
|
||||
{
|
||||
return QIcon( ":/zeroconf-icon.png" );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool
|
||||
ZeroconfPlugin::connectPlugin( bool /*startup*/ )
|
||||
@@ -99,7 +98,7 @@ ZeroconfPlugin::connectPlugin( bool /*startup*/ )
|
||||
m_cachedNodes.clear();
|
||||
|
||||
m_advertisementTimer.start();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -113,14 +112,11 @@ ZeroconfPlugin::disconnectPlugin()
|
||||
m_zeroconf = 0;
|
||||
}
|
||||
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QIcon
|
||||
ZeroconfPlugin::icon() const
|
||||
{
|
||||
return QIcon( ":/zeroconf-icon.png" );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
|
@@ -39,9 +39,7 @@ public:
|
||||
virtual QString factoryId() const { return "sipzeroconf"; }
|
||||
virtual QString prettyName() const { return "Local Network"; }
|
||||
virtual bool isUnique() const { return true; }
|
||||
#ifndef ENABLE_HEADLESS
|
||||
virtual QIcon icon() const;
|
||||
#endif
|
||||
|
||||
|
||||
virtual SipPlugin* createPlugin ( const QString& pluginId = QString() );
|
||||
@@ -62,9 +60,7 @@ public:
|
||||
virtual const QString accountName() const;
|
||||
virtual ConnectionState connectionState() const;
|
||||
virtual bool isValid() const { return true; }
|
||||
#ifndef ENABLE_HEADLESS
|
||||
virtual QIcon icon() const;
|
||||
#endif
|
||||
virtual void checkSettings() {}
|
||||
|
||||
public slots:
|
||||
|
@@ -40,7 +40,7 @@ private slots:
|
||||
void parsedDroppedTracks( const QList< Tomahawk::query_ptr >& tracks );
|
||||
void dialogClosed( int ret );
|
||||
|
||||
// Do the rename only after the revision is loaded
|
||||
//
|
||||
void playlistToRenameLoaded();
|
||||
private:
|
||||
SourcesModel::CategoryType m_categoryType;
|
||||
|
@@ -454,15 +454,11 @@ SourceDelegate::editorEvent ( QEvent* event, QAbstractItemModel* model, const QS
|
||||
// tDebug() << "CHECKING CLICK RECT:" << headphonesRect;
|
||||
if ( headphonesRect.contains( ev->pos() ) )
|
||||
{
|
||||
if ( event->type() == QEvent::MouseButtonRelease )
|
||||
{
|
||||
if ( index.data( SourcesModel::LatchedOnRole ).toBool() )
|
||||
// unlatch
|
||||
emit latchOff( colItem->source() );
|
||||
else
|
||||
emit latchOn( colItem->source() );
|
||||
}
|
||||
return true;
|
||||
if ( index.data( SourcesModel::LatchedOnRole ).toBool() )
|
||||
// unlatch
|
||||
emit latchOff( colItem->source() );
|
||||
else
|
||||
emit latchOn( colItem->source() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,15 +21,14 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QtCore/QPluginLoader>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QMetaType>
|
||||
#include <QtCore/QTime>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtNetwork/QNetworkProxy>
|
||||
#include <QtCore/QThread>
|
||||
#include <QPluginLoader>
|
||||
#include <QDir>
|
||||
#include <QMetaType>
|
||||
#include <QTime>
|
||||
#include <QNetworkReply>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QNetworkProxy>
|
||||
|
||||
#include "actioncollection.h"
|
||||
#include "artist.h"
|
||||
@@ -53,12 +52,14 @@
|
||||
#include "globalactionmanager.h"
|
||||
#include "database/localcollection.h"
|
||||
#include "musicscanner.h"
|
||||
#include "AtticaManager.h"
|
||||
#include "pipeline.h"
|
||||
#include "utils/spotifyparser.h"
|
||||
#include "dropjob.h"
|
||||
#include "EchonestCatalogSynchronizer.h"
|
||||
#include "widgets/HeaderLabel.h"
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "audio/audioenginethread.h"
|
||||
#include "utils/xspfloader.h"
|
||||
#include "utils/jspfloader.h"
|
||||
#include "utils/logger.h"
|
||||
@@ -67,14 +68,10 @@
|
||||
#include <lastfm/ws.h>
|
||||
#include "config.h"
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include "utils/spotifyparser.h"
|
||||
#include "AtticaManager.h"
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
#include "tomahawkwindow.h"
|
||||
#include "settingsdialog.h"
|
||||
#include <QtGui/QMessageBox>
|
||||
#include "widgets/HeaderLabel.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
|
||||
// should go to a plugin actually
|
||||
@@ -144,19 +141,19 @@ TomahawkApp::init()
|
||||
|
||||
tLog() << "Starting Tomahawk...";
|
||||
|
||||
#ifdef ENABLE_HEADLESS
|
||||
#ifdef TOMAHAWK_HEADLESS
|
||||
m_headless = true;
|
||||
#else
|
||||
m_mainwindow = 0;
|
||||
m_headless = arguments().contains( "--headless" );
|
||||
setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) );
|
||||
setQuitOnLastWindowClosed( false );
|
||||
#endif
|
||||
|
||||
QFont f = APP->font();
|
||||
f.setPixelSize( HeaderLabel::defaultFontSize() );
|
||||
QFontMetrics fm( f );
|
||||
TomahawkUtils::setHeaderHeight( fm.height() + 8 );
|
||||
#endif
|
||||
|
||||
new TomahawkSettings( this );
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
@@ -167,13 +164,11 @@ TomahawkApp::init()
|
||||
// Cause the creation of the nam, but don't need to address it directly, so prevent warning
|
||||
Q_UNUSED( TomahawkUtils::nam() );
|
||||
|
||||
m_audioEngineThread = QWeakPointer< AudioEngineThread >( new AudioEngineThread( this ) );
|
||||
m_audioEngineThread.data()->start( QThread::HighPriority );
|
||||
|
||||
m_scanManager = QWeakPointer< ScanManager >( new ScanManager( this ) );
|
||||
m_audioEngine = QWeakPointer<AudioEngine>( new AudioEngine );
|
||||
m_scanManager = QWeakPointer<ScanManager>( new ScanManager( this ) );
|
||||
new Pipeline( this );
|
||||
|
||||
m_servent = QWeakPointer< Servent >( new Servent( this ) );
|
||||
m_servent = QWeakPointer<Servent>( new Servent( this ) );
|
||||
connect( m_servent.data(), SIGNAL( ready() ), SLOT( initSIP() ) );
|
||||
|
||||
tDebug() << "Init Database.";
|
||||
@@ -185,10 +180,8 @@ TomahawkApp::init()
|
||||
for ( int i=0; i<length; i++ ) magic[i] = magic[i] ^ wand[i%n2];
|
||||
Echonest::Config::instance()->setAPIKey( magic );
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
tDebug() << "Init Echonest Factory.";
|
||||
GeneratorFactory::registerFactory( "echonest", new EchonestFactory );
|
||||
#endif
|
||||
tDebug() << "Init Database Factory.";
|
||||
GeneratorFactory::registerFactory( "database", new DatabaseFactory );
|
||||
|
||||
@@ -202,37 +195,32 @@ TomahawkApp::init()
|
||||
#endif
|
||||
|
||||
// Connect up shortcuts
|
||||
if ( !m_shortcutHandler.isNull() && AudioEngine::instance() )
|
||||
if ( !m_shortcutHandler.isNull() )
|
||||
{
|
||||
AudioEngine* audioEngine = AudioEngine::instance();
|
||||
connect( m_shortcutHandler.data(), SIGNAL( playPause() ), audioEngine, SLOT( playPause() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( pause() ), audioEngine, SLOT( pause() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( stop() ), audioEngine, SLOT( stop() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( previous() ), audioEngine, SLOT( previous() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( next() ), audioEngine, SLOT( next() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( volumeUp() ), audioEngine, SLOT( raiseVolume() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( volumeDown() ), audioEngine, SLOT( lowerVolume() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( mute() ), audioEngine, SLOT( mute() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( playPause() ), m_audioEngine.data(), SLOT( playPause() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( pause() ), m_audioEngine.data(), SLOT( pause() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( stop() ), m_audioEngine.data(), SLOT( stop() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( previous() ), m_audioEngine.data(), SLOT( previous() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( next() ), m_audioEngine.data(), SLOT( next() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( volumeUp() ), m_audioEngine.data(), SLOT( raiseVolume() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( volumeDown() ), m_audioEngine.data(), SLOT( lowerVolume() ) );
|
||||
connect( m_shortcutHandler.data(), SIGNAL( mute() ), m_audioEngine.data(), SLOT( mute() ) );
|
||||
}
|
||||
|
||||
tDebug() << "Init InfoSystem.";
|
||||
m_infoSystem = QWeakPointer<Tomahawk::InfoSystem::InfoSystem>( new Tomahawk::InfoSystem::InfoSystem( this ) );
|
||||
|
||||
Echonest::Config::instance()->setNetworkAccessManager( TomahawkUtils::nam() );
|
||||
#ifndef ENABLE_HEADLESS
|
||||
EchonestGenerator::setupCatalogs();
|
||||
|
||||
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
if ( !m_headless )
|
||||
{
|
||||
tDebug() << "Init MainWindow.";
|
||||
m_mainwindow = new TomahawkWindow();
|
||||
m_mainwindow->setWindowTitle( "Tomahawk" );
|
||||
m_mainwindow->setObjectName( "TH_Main_Window" );
|
||||
if ( !arguments().contains( "--hide" ) )
|
||||
{
|
||||
m_mainwindow->show();
|
||||
}
|
||||
m_mainwindow->show();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -242,10 +230,8 @@ TomahawkApp::init()
|
||||
initPipeline();
|
||||
|
||||
#ifdef LIBATTICA_FOUND
|
||||
#ifndef ENABLE_HEADLESS
|
||||
// load remote list of resolvers able to be installed
|
||||
AtticaManager::instance();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if ( arguments().contains( "--http" ) || TomahawkSettings::instance()->value( "network/http", true ).toBool() )
|
||||
@@ -253,7 +239,7 @@ TomahawkApp::init()
|
||||
initHTTP();
|
||||
}
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
if ( !s->hasScannerPaths() )
|
||||
{
|
||||
m_mainwindow->showSettingsDialog();
|
||||
@@ -270,17 +256,14 @@ TomahawkApp::init()
|
||||
m_scanManager.data()->runScan( true );
|
||||
}
|
||||
|
||||
// Set up echonest catalog synchronizer
|
||||
Tomahawk::EchonestCatalogSynchronizer::instance();
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
// Make sure to init GAM in the gui thread
|
||||
GlobalActionManager::instance();
|
||||
|
||||
// Set up echonest catalog synchronizer
|
||||
Tomahawk::EchonestCatalogSynchronizer::instance();
|
||||
// check if our spotify playlist api server is up and running, and enable spotify playlist drops if so
|
||||
QNetworkReply* r = TomahawkUtils::nam()->get( QNetworkRequest( QUrl( SPOTIFY_PLAYLIST_API_URL "/playlist/test" ) ) );
|
||||
connect( r, SIGNAL( finished() ), this, SLOT( spotifyApiCheckFinished() ) );
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
// Make sure to do this after main window is inited
|
||||
@@ -298,17 +281,11 @@ TomahawkApp::~TomahawkApp()
|
||||
if ( !m_scanManager.isNull() )
|
||||
delete m_scanManager.data();
|
||||
|
||||
if ( AudioEngine::instance() )
|
||||
{
|
||||
m_audioEngineThread.data()->quit();
|
||||
m_audioEngineThread.data()->wait( 60000 );
|
||||
|
||||
delete m_audioEngineThread.data();
|
||||
m_audioEngineThread.clear();
|
||||
}
|
||||
if ( !m_audioEngine.isNull() )
|
||||
delete m_audioEngine.data();
|
||||
|
||||
if ( !m_infoSystem.isNull() )
|
||||
delete m_infoSystem.data();
|
||||
/* if ( !m_infoSystem.isNull() )
|
||||
delete m_infoSystem.data(); */ // FIXME: this causes a shutdown crash on Windows
|
||||
|
||||
//FIXME: delete GeneratorFactory::registerFactory( "echonest", new EchonestFactory ); ?
|
||||
|
||||
@@ -321,13 +298,12 @@ TomahawkApp::~TomahawkApp()
|
||||
|
||||
delete Pipeline::instance();
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
delete m_mainwindow;
|
||||
#ifdef LIBATTICA_FOUND
|
||||
delete AtticaManager::instance();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LIBATTICA_FOUND
|
||||
delete AtticaManager::instance();
|
||||
#endif
|
||||
|
||||
tLog() << "Finished shutdown.";
|
||||
}
|
||||
@@ -350,7 +326,6 @@ TomahawkApp::printHelp()
|
||||
echo( " --help Show this help\n" );
|
||||
echo( " --http Initialize HTTP server\n" );
|
||||
echo( " --filescan Scan for files on startup\n" );
|
||||
echo( " --hide Hide main window on startup\n" );
|
||||
echo( " --testdb Use a test database instead of real collection\n" );
|
||||
echo( " --noupnp Disable UPNP\n" );
|
||||
echo( " --nosip Disable SIP\n" );
|
||||
@@ -359,7 +334,7 @@ TomahawkApp::printHelp()
|
||||
}
|
||||
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
AudioControls*
|
||||
TomahawkApp::audioControls()
|
||||
{
|
||||
@@ -416,19 +391,17 @@ TomahawkApp::registerMetaTypes()
|
||||
qRegisterMetaType< QList<Tomahawk::source_ptr> >("QList<Tomahawk::source_ptr>");
|
||||
qRegisterMetaType< QMap< QString, Tomahawk::plentry_ptr > >("QMap< QString, Tomahawk::plentry_ptr >");
|
||||
qRegisterMetaType< Tomahawk::PlaylistRevision >("Tomahawk::PlaylistRevision");
|
||||
qRegisterMetaType< Tomahawk::PlaylistInterface* >( "Tomahawk::PlaylistInterface*" );
|
||||
qRegisterMetaType< Tomahawk::DynamicPlaylistRevision >("Tomahawk::DynamicPlaylistRevision");
|
||||
qRegisterMetaType< Tomahawk::QID >("Tomahawk::QID");
|
||||
|
||||
qRegisterMetaType< AudioErrorCode >("AudioErrorCode");
|
||||
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoStringHash >( "Tomahawk::InfoSystem::InfoStringHash" );
|
||||
qRegisterMetaType< QHash< QString, QString > >( "Tomahawk::InfoSystem::InfoStringHash" );
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoType >( "Tomahawk::InfoSystem::InfoType" );
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoRequestData >( "Tomahawk::InfoSystem::InfoRequestData" );
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoSystemCache* >( "Tomahawk::InfoSystem::InfoSystemCache*" );
|
||||
qRegisterMetaType< QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > >( "QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache >" );
|
||||
|
||||
qRegisterMetaType< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
|
||||
qRegisterMetaTypeStreamOperators< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
|
||||
qRegisterMetaType< QList<Tomahawk::InfoSystem::InfoStringHash> >("QList<Tomahawk::InfoSystem::InfoStringHash>");
|
||||
qRegisterMetaType< QPersistentModelIndex >( "QPersistentModelIndex" );
|
||||
}
|
||||
|
||||
@@ -539,7 +512,6 @@ TomahawkApp::initSIP()
|
||||
void
|
||||
TomahawkApp::spotifyApiCheckFinished()
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
|
||||
Q_ASSERT( reply );
|
||||
|
||||
@@ -547,14 +519,13 @@ TomahawkApp::spotifyApiCheckFinished()
|
||||
DropJob::setCanParseSpotifyPlaylists( true );
|
||||
else
|
||||
DropJob::setCanParseSpotifyPlaylists( false );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkApp::activate()
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
TomahawkUtils::bringToFront();
|
||||
#endif
|
||||
}
|
||||
@@ -563,7 +534,6 @@ TomahawkApp::activate()
|
||||
bool
|
||||
TomahawkApp::loadUrl( const QString& url )
|
||||
{
|
||||
#ifndef ENABLE_HEADLESS
|
||||
if ( url.startsWith( "tomahawk://" ) )
|
||||
return GlobalActionManager::instance()->parseTomahawkLink( url );
|
||||
else if ( url.contains( "open.spotify.com" ) || url.contains( "spotify:track" ) )
|
||||
@@ -591,7 +561,7 @@ TomahawkApp::loadUrl( const QString& url )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -608,3 +578,4 @@ TomahawkApp::instanceStarted( KDSingleApplicationGuard::Instance instance )
|
||||
QString arg1 = instance.arguments[ 1 ];
|
||||
loadUrl( arg1 );
|
||||
}
|
||||
|
||||
|
@@ -24,11 +24,11 @@
|
||||
#include "headlesscheck.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QPersistentModelIndex>
|
||||
#include <QRegExp>
|
||||
#include <QFile>
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
#include <QPersistentModelIndex>
|
||||
|
||||
#include "QxtHttpServerConnector"
|
||||
#include "QxtHttpSessionManager"
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h"
|
||||
|
||||
class AudioEngineThread;
|
||||
class AudioEngine;
|
||||
class Database;
|
||||
class ScanManager;
|
||||
@@ -82,7 +81,7 @@ public:
|
||||
|
||||
XMPPBot* xmppBot() { return m_xmppBot.data(); }
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
AudioControls* audioControls();
|
||||
TomahawkWindow* mainWindow() const { return m_mainwindow; }
|
||||
#endif
|
||||
@@ -114,7 +113,7 @@ private:
|
||||
|
||||
QWeakPointer<Database> m_database;
|
||||
QWeakPointer<ScanManager> m_scanManager;
|
||||
QWeakPointer<AudioEngineThread> m_audioEngineThread;
|
||||
QWeakPointer<AudioEngine> m_audioEngine;
|
||||
QWeakPointer<Servent> m_servent;
|
||||
QWeakPointer<Tomahawk::InfoSystem::InfoSystem> m_infoSystem;
|
||||
QWeakPointer<XMPPBot> m_xmppBot;
|
||||
|
2
thirdparty/libportfwd/src/portfwd.cpp
vendored
2
thirdparty/libportfwd/src/portfwd.cpp
vendored
@@ -149,7 +149,7 @@ Portfwd::get_status()
|
||||
|
||||
// get external IP adress
|
||||
char ip[16];
|
||||
if ( 0 != UPNP_GetExternalIPAddress( m_urls->controlURL, m_data->first.servicetype, (char*)&ip ) )
|
||||
if ( 0 != UPNP_GetExternalIPAddress( m_urls->controlURL, m_data->CIF.servicetype, (char*)&ip ) )
|
||||
{
|
||||
m_externalip = ""; //failed
|
||||
}
|
||||
|
Reference in New Issue
Block a user