From 27e906f712b693e1c0cf5733f5b867e1bee0bf7b Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 28 Dec 2010 06:12:48 +0100 Subject: [PATCH] * Split tomahawk into application and tomahawklib. * Plugins link to and interface with tomahawklib. * Compiles on Linux and Win32, but needs some more export macro love for the sip plugins on Win32. --- CMakeLists.txt | 1 + admin/win/revision.txt | 2 +- admin/win/tomahawk.nsi | 5 + include/tomahawk/tomahawkapp.h | 30 +--- include/tomahawk/tomahawkplugin.h | 3 +- libportfwd/CMakeLists.txt | 4 +- src/CMakeLists.linux.txt | 1 + src/CMakeLists.txt | 108 +------------ src/CMakeLists.win32.txt | 13 +- src/audio/audioengine.cpp | 6 +- src/audio/audioengine.h | 4 +- src/audiocontrols.cpp | 2 +- src/audiocontrols.h | 4 +- src/infowidgets/sourceinfowidget.h | 6 +- src/libtomahawk/CMakeLists.txt | 150 ++++++++++++++++++ src/{ => libtomahawk}/album.cpp | 7 +- {include/tomahawk => src/libtomahawk}/album.h | 12 +- src/{ => libtomahawk}/artist.cpp | 5 +- .../tomahawk => src/libtomahawk}/artist.h | 8 +- src/{ => libtomahawk}/collection.cpp | 4 +- .../tomahawk => src/libtomahawk}/collection.h | 12 +- src/{ => libtomahawk}/database/README.txt | 0 src/{ => libtomahawk}/database/database.cpp | 11 ++ src/{ => libtomahawk}/database/database.h | 14 +- .../database/databasecollection.cpp | 9 +- .../database/databasecollection.h | 8 +- .../database/databasecommand.cpp | 0 .../database/databasecommand.h | 8 +- .../database/databasecommand_addfiles.cpp | 11 +- .../database/databasecommand_addfiles.h | 6 +- .../database/databasecommand_addsource.cpp | 0 .../database/databasecommand_addsource.h | 4 +- .../database/databasecommand_allalbums.cpp | 0 .../database/databasecommand_allalbums.h | 10 +- .../database/databasecommand_alltracks.cpp | 0 .../database/databasecommand_alltracks.h | 10 +- .../databasecommand_collectionstats.cpp | 0 .../databasecommand_collectionstats.h | 8 +- .../databasecommand_createplaylist.cpp | 4 +- .../database/databasecommand_createplaylist.h | 8 +- .../databasecommand_deleteplaylist.cpp | 4 +- .../database/databasecommand_deleteplaylist.h | 8 +- .../database/databasecommand_dirmtimes.cpp | 0 .../database/databasecommand_dirmtimes.h | 4 +- .../databasecommand_importplaylist.cpp | 0 .../database/databasecommand_importplaylist.h | 6 +- .../databasecommand_loadallplaylists.cpp | 2 +- .../databasecommand_loadallplaylists.h | 6 +- .../database/databasecommand_loadfile.cpp | 2 +- .../database/databasecommand_loadfile.h | 4 +- .../database/databasecommand_loadops.cpp | 0 .../database/databasecommand_loadops.h | 6 +- .../databasecommand_loadplaylistentries.cpp | 0 .../databasecommand_loadplaylistentries.h | 6 +- .../databasecommand_modifyplaylist.cpp | 0 .../database/databasecommand_modifyplaylist.h | 8 +- .../databasecommand_renameplaylist.cpp | 4 +- .../database/databasecommand_renameplaylist.h | 8 +- .../database/databasecommand_resolve.cpp | 8 +- .../database/databasecommand_resolve.h | 6 +- .../databasecommand_setplaylistrevision.cpp | 4 +- .../databasecommand_setplaylistrevision.h | 8 +- .../databasecommand_sourceoffline.cpp | 0 .../database/databasecommand_sourceoffline.h | 4 +- .../databasecommand_updatesearchindex.cpp | 0 .../databasecommand_updatesearchindex.h | 4 +- .../database/databasecommandloggable.cpp | 0 .../database/databasecommandloggable.h | 4 +- .../database/databaseimpl.cpp | 11 +- src/{ => libtomahawk}/database/databaseimpl.h | 0 .../database/databaseresolver.cpp | 10 +- .../database/databaseresolver.h | 10 +- .../database/databaseworker.cpp | 3 +- .../database/databaseworker.h | 0 src/{ => libtomahawk}/database/fuzzyindex.cpp | 0 src/{ => libtomahawk}/database/fuzzyindex.h | 0 .../database/gen_schema.h.sh | 0 src/{ => libtomahawk}/database/op.h | 0 src/{ => libtomahawk}/database/schema.sql | 0 src/{ => libtomahawk}/database/schema.sql.h | 0 .../database/tomahawksqlquery.h | 0 src/libtomahawk/dllmacro.h | 14 ++ .../libtomahawk}/functimeout.h | 0 .../network/bufferiodevice.cpp | 0 .../network/bufferiodevice.h | 0 src/{ => libtomahawk}/network/connection.cpp | 2 +- src/{ => libtomahawk}/network/connection.h | 4 +- .../network/controlconnection.cpp | 8 +- .../network/controlconnection.h | 10 +- .../network/dbsyncconnection.cpp | 33 ++-- .../network/dbsyncconnection.h | 4 +- .../network/filetransferconnection.cpp | 22 +-- .../network/filetransferconnection.h | 4 +- src/{ => libtomahawk}/network/msg.h | 0 .../network/msgprocessor.cpp | 21 ++- src/{ => libtomahawk}/network/msgprocessor.h | 0 .../network/remotecollection.cpp | 0 .../network/remotecollection.h | 6 +- src/{ => libtomahawk}/network/servent.cpp | 123 +++++++++++--- src/{ => libtomahawk}/network/servent.h | 24 ++- src/{ => libtomahawk}/pipeline.cpp | 20 ++- .../tomahawk => src/libtomahawk}/pipeline.h | 16 +- src/{ => libtomahawk}/playlist.cpp | 32 ++-- .../tomahawk => src/libtomahawk}/playlist.h | 10 +- .../libtomahawk}/playlistinterface.h | 6 +- src/{ => libtomahawk}/pluginapi.cpp | 13 +- .../tomahawk => src/libtomahawk}/pluginapi.h | 8 +- src/{ => libtomahawk}/query.cpp | 2 +- {include/tomahawk => src/libtomahawk}/query.h | 10 +- .../tomahawk => src/libtomahawk}/resolver.h | 6 +- src/{ => libtomahawk}/result.cpp | 4 +- .../tomahawk => src/libtomahawk}/result.h | 6 +- src/{ => libtomahawk}/sip/SipPlugin.cpp | 0 src/{ => libtomahawk}/sip/SipPlugin.h | 4 +- src/{ => libtomahawk}/source.cpp | 22 +-- .../tomahawk => src/libtomahawk}/source.h | 6 +- src/{ => libtomahawk}/sourcelist.cpp | 16 +- .../tomahawk => src/libtomahawk}/sourcelist.h | 12 +- src/{ => libtomahawk}/tomahawksettings.cpp | 13 +- src/{ => libtomahawk}/tomahawksettings.h | 11 +- {include/tomahawk => src/libtomahawk}/track.h | 8 +- .../tomahawk => src/libtomahawk}/typedefs.h | 0 src/musicscanner.cpp | 21 +-- src/playlist/albumitem.h | 2 +- src/playlist/albumitemdelegate.cpp | 4 +- src/playlist/albummodel.cpp | 6 +- src/playlist/albummodel.h | 6 +- src/playlist/albumproxymodel.cpp | 2 +- src/playlist/albumproxymodel.h | 2 +- src/playlist/collectionflatmodel.cpp | 7 +- src/playlist/collectionflatmodel.h | 13 +- src/playlist/collectionmodel.cpp | 5 +- src/playlist/collectionmodel.h | 11 +- src/playlist/collectionproxymodel.cpp | 4 +- src/playlist/playlistitemdelegate.cpp | 4 +- src/playlist/playlistmanager.cpp | 5 +- src/playlist/playlistmanager.h | 4 +- src/playlist/playlistmodel.cpp | 2 +- src/playlist/playlistmodel.h | 10 +- src/playlist/plitem.h | 5 +- src/playlist/trackheader.cpp | 6 +- src/playlist/trackmodel.cpp | 2 +- src/playlist/trackmodel.h | 2 +- src/playlist/trackproxymodel.cpp | 4 +- src/playlist/trackproxymodel.h | 2 +- src/scriptresolver.cpp | 16 +- src/scriptresolver.h | 4 +- src/scrobbler.cpp | 36 ++--- src/scrobbler.h | 2 +- src/settingsdialog.cpp | 8 +- src/sip/SipHandler.cpp | 30 ++-- src/sip/jabber/CMakeLists.txt | 8 + src/sip/jabber/jabber.cpp | 13 +- src/sip/jabber/jabber.h | 2 +- src/sip/zeroconf/CMakeLists.txt | 8 + src/sip/zeroconf/tomahawkzeroconf.h | 7 +- src/sip/zeroconf/zeroconf.cpp | 9 +- src/sip/zeroconf/zeroconf.h | 2 +- src/sourcetree/sourcesmodel.cpp | 10 +- src/sourcetree/sourcesmodel.h | 4 +- src/sourcetree/sourcetreeitem.cpp | 4 +- src/sourcetree/sourcetreeitem.h | 2 +- src/sourcetree/sourcetreeitemwidget.cpp | 8 +- src/sourcetree/sourcetreeitemwidget.h | 2 +- src/sourcetree/sourcetreeview.cpp | 7 +- src/sourcetree/sourcetreeview.h | 2 +- src/tomahawkapp.cpp | 114 +++---------- src/tomahawktrayicon.h | 2 +- src/tomahawkwindow.cpp | 21 ++- src/tomahawkwindow.h | 2 +- src/topbar/topbar.cpp | 1 - src/topbar/topbar.h | 2 +- src/transferview.cpp | 4 +- src/transferview.h | 2 +- src/web/api_v1.h | 14 +- src/xmppbot/xmppbot.cpp | 13 +- src/xmppbot/xmppbot.h | 2 +- src/xspfloader.cpp | 5 +- src/xspfloader.h | 4 +- 179 files changed, 946 insertions(+), 691 deletions(-) create mode 100644 src/libtomahawk/CMakeLists.txt rename src/{ => libtomahawk}/album.cpp (91%) rename {include/tomahawk => src/libtomahawk}/album.h (90%) rename src/{ => libtomahawk}/artist.cpp (87%) rename {include/tomahawk => src/libtomahawk}/artist.h (86%) rename src/{ => libtomahawk}/collection.cpp (96%) rename {include/tomahawk => src/libtomahawk}/collection.h (93%) rename src/{ => libtomahawk}/database/README.txt (100%) rename src/{ => libtomahawk}/database/database.cpp (88%) rename src/{ => libtomahawk}/database/database.h (82%) rename src/{ => libtomahawk}/database/databasecollection.cpp (86%) rename src/{ => libtomahawk}/database/databasecollection.h (81%) rename src/{ => libtomahawk}/database/databasecommand.cpp (100%) rename src/{ => libtomahawk}/database/databasecommand.h (94%) rename src/{ => libtomahawk}/database/databasecommand_addfiles.cpp (96%) rename src/{ => libtomahawk}/database/databasecommand_addfiles.h (90%) rename src/{ => libtomahawk}/database/databasecommand_addsource.cpp (100%) rename src/{ => libtomahawk}/database/databasecommand_addsource.h (86%) rename src/{ => libtomahawk}/database/databasecommand_allalbums.cpp (100%) rename src/{ => libtomahawk}/database/databasecommand_allalbums.h (89%) rename src/{ => libtomahawk}/database/databasecommand_alltracks.cpp (100%) rename src/{ => libtomahawk}/database/databasecommand_alltracks.h (90%) rename src/{ => libtomahawk}/database/databasecommand_collectionstats.cpp (100%) rename src/{ => libtomahawk}/database/databasecommand_collectionstats.h (79%) rename src/{ => libtomahawk}/database/databasecommand_createplaylist.cpp (96%) rename src/{ => libtomahawk}/database/databasecommand_createplaylist.h (89%) rename src/{ => libtomahawk}/database/databasecommand_deleteplaylist.cpp (93%) rename src/{ => libtomahawk}/database/databasecommand_deleteplaylist.h (85%) rename src/{ => libtomahawk}/database/databasecommand_dirmtimes.cpp (100%) rename src/{ => libtomahawk}/database/databasecommand_dirmtimes.h (92%) rename src/{ => libtomahawk}/database/databasecommand_importplaylist.cpp (100%) rename src/{ => libtomahawk}/database/databasecommand_importplaylist.h (86%) rename src/{ => libtomahawk}/database/databasecommand_loadallplaylists.cpp (97%) rename src/{ => libtomahawk}/database/databasecommand_loadallplaylists.h (83%) rename src/{ => libtomahawk}/database/databasecommand_loadfile.cpp (94%) rename src/{ => libtomahawk}/database/databasecommand_loadfile.h (86%) rename src/{ => libtomahawk}/database/databasecommand_loadops.cpp (100%) rename src/{ => libtomahawk}/database/databasecommand_loadops.h (85%) rename src/{ => libtomahawk}/database/databasecommand_loadplaylistentries.cpp (100%) rename src/{ => libtomahawk}/database/databasecommand_loadplaylistentries.h (87%) rename src/{ => libtomahawk}/database/databasecommand_modifyplaylist.cpp (100%) rename src/{ => libtomahawk}/database/databasecommand_modifyplaylist.h (85%) rename src/{ => libtomahawk}/database/databasecommand_renameplaylist.cpp (93%) rename src/{ => libtomahawk}/database/databasecommand_renameplaylist.h (88%) rename src/{ => libtomahawk}/database/databasecommand_resolve.cpp (97%) rename src/{ => libtomahawk}/database/databasecommand_resolve.h (96%) rename src/{ => libtomahawk}/database/databasecommand_setplaylistrevision.cpp (98%) rename src/{ => libtomahawk}/database/databasecommand_setplaylistrevision.h (94%) rename src/{ => libtomahawk}/database/databasecommand_sourceoffline.cpp (100%) rename src/{ => libtomahawk}/database/databasecommand_sourceoffline.h (79%) rename src/{ => libtomahawk}/database/databasecommand_updatesearchindex.cpp (100%) rename src/{ => libtomahawk}/database/databasecommand_updatesearchindex.h (85%) rename src/{ => libtomahawk}/database/databasecommandloggable.cpp (100%) rename src/{ => libtomahawk}/database/databasecommandloggable.h (89%) rename src/{ => libtomahawk}/database/databaseimpl.cpp (98%) rename src/{ => libtomahawk}/database/databaseimpl.h (100%) rename src/{ => libtomahawk}/database/databaseresolver.cpp (78%) rename src/{ => libtomahawk}/database/databaseresolver.h (79%) rename src/{ => libtomahawk}/database/databaseworker.cpp (99%) rename src/{ => libtomahawk}/database/databaseworker.h (100%) rename src/{ => libtomahawk}/database/fuzzyindex.cpp (100%) rename src/{ => libtomahawk}/database/fuzzyindex.h (100%) rename src/{ => libtomahawk}/database/gen_schema.h.sh (100%) rename src/{ => libtomahawk}/database/op.h (100%) rename src/{ => libtomahawk}/database/schema.sql (100%) rename src/{ => libtomahawk}/database/schema.sql.h (100%) rename src/{ => libtomahawk}/database/tomahawksqlquery.h (100%) create mode 100644 src/libtomahawk/dllmacro.h rename {include/tomahawk => src/libtomahawk}/functimeout.h (100%) rename src/{ => libtomahawk}/network/bufferiodevice.cpp (100%) rename src/{ => libtomahawk}/network/bufferiodevice.h (100%) rename src/{ => libtomahawk}/network/connection.cpp (99%) rename src/{ => libtomahawk}/network/connection.h (97%) rename src/{ => libtomahawk}/network/controlconnection.cpp (97%) rename src/{ => libtomahawk}/network/controlconnection.h (86%) rename src/{ => libtomahawk}/network/dbsyncconnection.cpp (88%) rename src/{ => libtomahawk}/network/dbsyncconnection.h (95%) rename src/{ => libtomahawk}/network/filetransferconnection.cpp (90%) rename src/{ => libtomahawk}/network/filetransferconnection.h (96%) rename src/{ => libtomahawk}/network/msg.h (100%) rename src/{ => libtomahawk}/network/msgprocessor.cpp (90%) rename src/{ => libtomahawk}/network/msgprocessor.h (100%) rename src/{ => libtomahawk}/network/remotecollection.cpp (100%) rename src/{ => libtomahawk}/network/remotecollection.h (83%) rename src/{ => libtomahawk}/network/servent.cpp (85%) rename src/{ => libtomahawk}/network/servent.h (83%) rename src/{ => libtomahawk}/pipeline.cpp (93%) rename {include/tomahawk => src/libtomahawk}/pipeline.h (85%) rename src/{ => libtomahawk}/playlist.cpp (92%) rename {include/tomahawk => src/libtomahawk}/playlist.h (97%) rename {include/tomahawk => src/libtomahawk}/playlistinterface.h (94%) rename src/{ => libtomahawk}/pluginapi.cpp (70%) rename {include/tomahawk => src/libtomahawk}/pluginapi.h (89%) rename src/{ => libtomahawk}/query.cpp (98%) rename {include/tomahawk => src/libtomahawk}/query.h (93%) rename {include/tomahawk => src/libtomahawk}/resolver.h (89%) rename src/{ => libtomahawk}/result.cpp (96%) rename {include/tomahawk => src/libtomahawk}/result.h (95%) rename src/{ => libtomahawk}/sip/SipPlugin.cpp (100%) rename src/{ => libtomahawk}/sip/SipPlugin.h (92%) rename src/{ => libtomahawk}/source.cpp (82%) rename {include/tomahawk => src/libtomahawk}/source.h (95%) rename src/{ => libtomahawk}/sourcelist.cpp (90%) rename {include/tomahawk => src/libtomahawk}/sourcelist.h (83%) rename src/{ => libtomahawk}/tomahawksettings.cpp (97%) rename src/{ => libtomahawk}/tomahawksettings.h (92%) rename {include/tomahawk => src/libtomahawk}/track.h (81%) rename {include/tomahawk => src/libtomahawk}/typedefs.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf7f00762..73079fa95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,5 +25,6 @@ ENDIF( UNIX AND NOT APPLE ) ADD_SUBDIRECTORY( libportfwd ) ADD_SUBDIRECTORY( qxt ) +ADD_SUBDIRECTORY( src/libtomahawk ) ADD_SUBDIRECTORY( src ) diff --git a/admin/win/revision.txt b/admin/win/revision.txt index 801f18010..8783e3051 100644 --- a/admin/win/revision.txt +++ b/admin/win/revision.txt @@ -1 +1 @@ -47 \ No newline at end of file +53 \ No newline at end of file diff --git a/admin/win/tomahawk.nsi b/admin/win/tomahawk.nsi index 8cd675d9c..3212d7a51 100755 --- a/admin/win/tomahawk.nsi +++ b/admin/win/tomahawk.nsi @@ -253,6 +253,11 @@ Section "Tomahawk Player" SEC_TOMAHAWK_PLAYER ;Main executable. File "${ROOT_PATH}\build\tomahawk.exe" + ;Plugins + File "${ROOT_PATH}\build\src\libtomahawk\libtomahawklib.dll" + File "${ROOT_PATH}\build\libsip_jabber.dll" + File "${ROOT_PATH}\build\libsip_zeroconf.dll" + ;License & release notes. File "${ROOT_PATH}\LICENSE.txt" File /oname=NOTES.txt RELEASE_NOTES.txt diff --git a/include/tomahawk/tomahawkapp.h b/include/tomahawk/tomahawkapp.h index 46c0623e2..839022079 100644 --- a/include/tomahawk/tomahawkapp.h +++ b/include/tomahawk/tomahawkapp.h @@ -16,17 +16,12 @@ #include "QxtHttpServerConnector" #include "QxtHttpSessionManager" -#include "tomahawk/functimeout.h" -#include "tomahawk/typedefs.h" #include "tomahawk/tomahawkplugin.h" -#include "tomahawk/playlist.h" -#include "tomahawk/pipeline.h" +#include "typedefs.h" +#include "playlist.h" #include "utils/tomahawkutils.h" -#include "sourcelist.h" -#include "servent.h" - class AudioEngine; class Database; class SipHandler; @@ -66,17 +61,12 @@ public: static TomahawkApp* instance(); - Tomahawk::Pipeline* pipeline() { return &m_pipeline; } AudioEngine* audioEngine() { return m_audioEngine; } - Database* database() { return m_db; } - SourceList& sourcelist() { return m_sources; } - Servent& servent() { return m_servent; } SipHandler* sipHandler() { return m_sipHandler; } QNetworkAccessManager* nam() { return m_nam; } QNetworkProxy* proxy() { return m_proxy; } Tomahawk::InfoSystem::InfoSystem* infoSystem() { return m_infoSystem; } XMPPBot* xmppBot() { return m_xmppBot; } - const QString& nodeID() const; #ifndef TOMAHAWK_HEADLESS AudioControls* audioControls(); @@ -84,18 +74,9 @@ public: TomahawkWindow* mainWindow() const { return m_mainwindow; } #endif - void registerIODeviceFactory( const QString &proto, boost::function(Tomahawk::result_ptr)> fac ); - QSharedPointer localFileIODeviceFactory( const Tomahawk::result_ptr& result ); - QSharedPointer httpIODeviceFactory( const Tomahawk::result_ptr& result ); - - TomahawkSettings* settings() { return m_settings; } - signals: void settingsChanged(); -public slots: - QSharedPointer getIODeviceForUrl( const Tomahawk::result_ptr& result ); - private: void initLocalCollection(); void loadPlugins(); @@ -109,11 +90,7 @@ private: QList m_collections; QList m_plugins; - Tomahawk::Pipeline m_pipeline; AudioEngine* m_audioEngine; - Database* m_db; - Servent m_servent; - SourceList m_sources; SipHandler* m_sipHandler; XMPPBot* m_xmppBot; @@ -125,10 +102,7 @@ private: TomahawkWindow* m_mainwindow; #endif - QMap< QString,boost::function(Tomahawk::result_ptr)> > m_iofactories; - bool m_headless; - TomahawkSettings* m_settings; QNetworkAccessManager* m_nam; QNetworkProxy* m_proxy; diff --git a/include/tomahawk/tomahawkplugin.h b/include/tomahawk/tomahawkplugin.h index f27e2d5ea..9f5f81d0e 100644 --- a/include/tomahawk/tomahawkplugin.h +++ b/include/tomahawk/tomahawkplugin.h @@ -1,9 +1,10 @@ #ifndef TOMAHAWK_PLUGIN_H #define TOMAHAWK_PLUGIN_H + #include #include -#include "tomahawk/pluginapi.h" +#include "pluginapi.h" class TomahawkPlugin { diff --git a/libportfwd/CMakeLists.txt b/libportfwd/CMakeLists.txt index 88ccaf107..b95d603b8 100644 --- a/libportfwd/CMakeLists.txt +++ b/libportfwd/CMakeLists.txt @@ -38,7 +38,7 @@ ADD_LIBRARY(portfwd STATIC ) IF(WIN32) - TARGET_LINK_LIBRARIES( portfwd "ws2_32.dll" ) + TARGET_LINK_LIBRARIES( portfwd "ws2_32.dll" "iphlpapi.a" ) ENDIF() #ADD_EXECUTABLE(portfwd-demo @@ -46,6 +46,6 @@ ENDIF() # ) #TARGET_LINK_LIBRARIES(portfwd-demo portfwd) -#INSTALL(TARGETS portfwd ARCHIVE DESTINATION lib) +INSTALL(TARGETS portfwd ARCHIVE DESTINATION .) #INSTALL(TARGETS portfwd-demo RUNTIME DESTINATION bin) #INSTALL(DIRECTORY include/portfwd DESTINATION include PATTERN "*~" EXCLUDE) diff --git a/src/CMakeLists.linux.txt b/src/CMakeLists.linux.txt index edbcafd3a..eacb2d368 100644 --- a/src/CMakeLists.linux.txt +++ b/src/CMakeLists.linux.txt @@ -1,6 +1,7 @@ SET( OS_SPECIFIC_LINK_LIBRARIES ${OS_SPECIFIC_LINK_LIBRARIES} alsaplayback + tomahawklib ) IF( "${gui}" STREQUAL "no" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8a4b9a37b..3013e524d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,16 +27,6 @@ SET( TOMAHAWK_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../include/" ) #ENDFOREACH( moddir ) SET( tomahawkSources ${tomahawkSources} - artist.cpp - album.cpp - pipeline.cpp - playlist.cpp - pluginapi.cpp - query.cpp - result.cpp - source.cpp - sourcelist.cpp - audio/madtranscode.cpp audio/vorbistranscode.cpp audio/flactranscode.cpp @@ -45,57 +35,18 @@ SET( tomahawkSources ${tomahawkSources} utils/tomahawkutils.cpp sip/SipHandler.cpp - sip/SipPlugin.cpp infosystem/infosystem.cpp infosystem/infoplugins/echonestplugin.cpp infosystem/infoplugins/musixmatchplugin.cpp - collection.cpp musicscanner.cpp scriptresolver.cpp - network/bufferiodevice.cpp - network/msgprocessor.cpp - network/connection.cpp - network/controlconnection.cpp - network/filetransferconnection.cpp - network/dbsyncconnection.cpp - network/remotecollection.cpp - network/servent.cpp - - database/fuzzyindex.cpp - database/database.cpp - database/databaseworker.cpp - database/databaseimpl.cpp - database/databaseresolver.cpp - database/databasecommand.cpp - database/databasecommandloggable.cpp - database/databasecommand_resolve.cpp - database/databasecommand_allalbums.cpp - database/databasecommand_alltracks.cpp - database/databasecommand_addfiles.cpp - database/databasecommand_dirmtimes.cpp - database/databasecommand_loadfile.cpp - database/databasecommand_addsource.cpp - database/databasecommand_sourceoffline.cpp - database/databasecommand_collectionstats.cpp - database/databasecommand_loadplaylistentries.cpp - database/databasecommand_modifyplaylist.cpp - database/databasecommand_setplaylistrevision.cpp - database/databasecommand_loadallplaylists.cpp - database/databasecommand_createplaylist.cpp - database/databasecommand_deleteplaylist.cpp - database/databasecommand_renameplaylist.cpp - database/databasecommand_loadops.cpp - database/databasecommand_updatesearchindex.cpp - database/databasecollection.cpp - scrobbler.cpp xmppbot/xmppbot.cpp web/api_v1.cpp - tomahawksettings.cpp tomahawkapp.cpp main.cpp ) @@ -155,76 +106,21 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui} SET( tomahawkHeaders ${tomahawkHeaders} "${TOMAHAWK_INC_DIR}/tomahawk/tomahawkapp.h" - "${TOMAHAWK_INC_DIR}/tomahawk/collection.h" - "${TOMAHAWK_INC_DIR}/tomahawk/pipeline.h" - "${TOMAHAWK_INC_DIR}/tomahawk/pluginapi.h" - "${TOMAHAWK_INC_DIR}/tomahawk/query.h" - "${TOMAHAWK_INC_DIR}/tomahawk/resolver.h" - "${TOMAHAWK_INC_DIR}/tomahawk/result.h" - "${TOMAHAWK_INC_DIR}/tomahawk/source.h" - "${TOMAHAWK_INC_DIR}/tomahawk/sourcelist.h" - - "${TOMAHAWK_INC_DIR}/tomahawk/artist.h" - "${TOMAHAWK_INC_DIR}/tomahawk/album.h" - "${TOMAHAWK_INC_DIR}/tomahawk/track.h" - "${TOMAHAWK_INC_DIR}/tomahawk/playlist.h" - "${TOMAHAWK_INC_DIR}/tomahawk/infosystem.h" - "${TOMAHAWK_INC_DIR}/tomahawk/functimeout.h" -# "${TOMAHAWK_INC_DIR}/tomahawk/tomahawkplugin.h" - audio/transcodeinterface.h audio/madtranscode.h audio/vorbistranscode.h audio/flactranscode.h audio/audioengine.h - database/fuzzyindex.h - database/database.h - database/databaseworker.h - database/databaseimpl.h - database/databaseresolver.h - database/databasecommand.h - database/databasecommandloggable.h - database/databasecommand_resolve.h - database/databasecommand_allalbums.h - database/databasecommand_alltracks.h - database/databasecommand_addfiles.h - database/databasecommand_dirmtimes.h - database/databasecommand_loadfile.h - database/databasecommand_addsource.h - database/databasecommand_sourceoffline.h - database/databasecommand_collectionstats.h - database/databasecommand_loadplaylistentries.h - database/databasecommand_modifyplaylist.h - database/databasecommand_setplaylistrevision.h - database/databasecommand_loadallplaylists.h - database/databasecommand_createplaylist.h - database/databasecommand_deleteplaylist.h - database/databasecommand_renameplaylist.h - database/databasecommand_loadops.h - database/databasecommand_updatesearchindex.h - database/databasecollection.h - sip/SipHandler.h - sip/SipPlugin.h infosystem/infoplugins/echonestplugin.h infosystem/infoplugins/musixmatchplugin.h - network/bufferiodevice.h - network/msgprocessor.h - network/remotecollection.h - network/servent.h - network/connection.h - network/controlconnection.h - network/filetransferconnection.h - network/dbsyncconnection.h - musicscanner.h scriptresolver.h - tomahawksettings.h scrobbler.h xmppbot/xmppbot.h @@ -307,10 +203,10 @@ INCLUDE_DIRECTORIES( sourcetree topbar utils + libtomahawk ../rtaudio ../alsa-playback - ../libportfwd/include ../qxt/qxtweb-standalone/qxtweb /usr/include/taglib @@ -361,9 +257,9 @@ MESSAGE( STATUS "OS_SPECIFIC_LINK_LIBRARIES: ${OS_SPECIFIC_LINK_LIBRARIES}" ) TARGET_LINK_LIBRARIES( tomahawk ${QT_LIBRARIES} ${MAC_EXTRA_LIBS} - portfwd ${OS_SPECIFIC_LINK_LIBRARIES} ${LIBECHONEST_LIBRARY} + qjson tag ) diff --git a/src/CMakeLists.win32.txt b/src/CMakeLists.win32.txt index cb53f3f23..ea504bb25 100644 --- a/src/CMakeLists.win32.txt +++ b/src/CMakeLists.win32.txt @@ -1,6 +1,7 @@ ADD_DEFINITIONS( /DNOMINMAX ) ADD_DEFINITIONS( /DWIN32_LEAN_AND_MEAN ) ADD_DEFINITIONS( -static-libgcc ) + #ADD_DEFINITIONS( /DNO_LIBLASTFM ) #ADD_DEFINITIONS( -DNO_OGG ) @@ -17,18 +18,23 @@ INCLUDE_DIRECTORIES( ../../taglib-1.6.3/taglib/toolkit ) + +SET( GLOOX_LIBS + ${GLOOX_LIBS} + gloox +) + SET( OS_SPECIFIC_LINK_LIBRARIES ${LIBLASTFM_LIBRARY} - gloox + ${GLOOX_LIBS} ) SET( OS_SPECIFIC_LINK_LIBRARIES ${OS_SPECIFIC_LINK_LIBRARIES} "secur32.dll" "crypt32.dll" - "ws2_32.dll" - "dnsapi.dll" "${CMAKE_CURRENT_SOURCE_DIR}/../qxt/qxtweb-standalone/libqxtweb-standalone.dll" + "${CMAKE_CURRENT_SOURCE_DIR}/../build/src/libtomahawk/libtomahawklib.dll" ) SET( tomahawkSourcesGui ${tomahawkSourcesGui} audio/rtaudiooutput.cpp ) @@ -45,4 +51,3 @@ SET( OS_SPECIFIC_LINK_LIBRARIES "FLAC++" "${CMAKE_CURRENT_SOURCE_DIR}/../rtaudio/librtaudio.dll" ) - diff --git a/src/audio/audioengine.cpp b/src/audio/audioengine.cpp index 92048f98b..7dd7b0a7e 100644 --- a/src/audio/audioengine.cpp +++ b/src/audio/audioengine.cpp @@ -3,8 +3,8 @@ #include #include -#include -#include "tomahawk/playlistinterface.h" +#include "playlistinterface.h" +#include "network/servent.h" #include "madtranscode.h" #ifndef NO_OGG @@ -158,7 +158,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result ) emit finished( m_lastTrack ); m_currentTrack = result; - io = TomahawkApp::instance()->getIODeviceForUrl( m_currentTrack ); + io = Servent::instance()->getIODeviceForUrl( m_currentTrack ); if ( !io || io.isNull() ) { diff --git a/src/audio/audioengine.h b/src/audio/audioengine.h index 0244695ff..fdda5dd33 100644 --- a/src/audio/audioengine.h +++ b/src/audio/audioengine.h @@ -5,8 +5,8 @@ #include #include -#include "tomahawk/result.h" -#include "tomahawk/typedefs.h" +#include "result.h" +#include "typedefs.h" #include "rtaudiooutput.h" #include "alsaplayback.h" diff --git a/src/audiocontrols.cpp b/src/audiocontrols.cpp index aa2e01f2f..640b44b46 100644 --- a/src/audiocontrols.cpp +++ b/src/audiocontrols.cpp @@ -4,7 +4,7 @@ #include #include "tomahawk/tomahawkapp.h" -#include "tomahawk/album.h" +#include "album.h" #include "utils/tomahawkutils.h" #include "audioengine.h" diff --git a/src/audiocontrols.h b/src/audiocontrols.h index df8feb795..2ba63eeed 100644 --- a/src/audiocontrols.h +++ b/src/audiocontrols.h @@ -3,8 +3,8 @@ #include -#include "tomahawk/result.h" -#include "tomahawk/playlistinterface.h" +#include "result.h" +#include "playlistinterface.h" namespace Ui { diff --git a/src/infowidgets/sourceinfowidget.h b/src/infowidgets/sourceinfowidget.h index c16b55b37..0af88baa6 100644 --- a/src/infowidgets/sourceinfowidget.h +++ b/src/infowidgets/sourceinfowidget.h @@ -3,9 +3,9 @@ #include -#include "tomahawk/album.h" -#include "tomahawk/result.h" -#include "tomahawk/playlistinterface.h" +#include "album.h" +#include "result.h" +#include "playlistinterface.h" class AlbumModel; class CollectionFlatModel; diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt new file mode 100644 index 000000000..e9f8893c3 --- /dev/null +++ b/src/libtomahawk/CMakeLists.txt @@ -0,0 +1,150 @@ +project( tomahawklib ) + +SET( QT_USE_QTSQL TRUE ) +SET( QT_USE_QTNETWORK TRUE ) +SET( QT_USE_QTXML TRUE ) +include( ${QT_USE_FILE} ) +add_definitions( ${QT_DEFINITIONS} ) +add_definitions( -DQT_SHARED ) +add_definitions( -DDLLEXPORT_PRO ) + +set( libSources + tomahawksettings.cpp + sourcelist.cpp + pipeline.cpp + + artist.cpp + album.cpp + collection.cpp + playlist.cpp + pluginapi.cpp + query.cpp + result.cpp + source.cpp + + sip/SipPlugin.cpp + + network/bufferiodevice.cpp + network/msgprocessor.cpp + network/filetransferconnection.cpp + network/dbsyncconnection.cpp + network/remotecollection.cpp + + database/fuzzyindex.cpp + database/databaseworker.cpp + database/databaseimpl.cpp + database/databaseresolver.cpp + database/databasecommand.cpp + database/databasecommandloggable.cpp + database/databasecommand_resolve.cpp + database/databasecommand_allalbums.cpp + database/databasecommand_alltracks.cpp + database/databasecommand_addfiles.cpp + database/databasecommand_dirmtimes.cpp + database/databasecommand_loadfile.cpp + database/databasecommand_addsource.cpp + database/databasecommand_sourceoffline.cpp + database/databasecommand_collectionstats.cpp + database/databasecommand_loadplaylistentries.cpp + database/databasecommand_modifyplaylist.cpp + database/databasecommand_setplaylistrevision.cpp + database/databasecommand_loadallplaylists.cpp + database/databasecommand_createplaylist.cpp + database/databasecommand_deleteplaylist.cpp + database/databasecommand_renameplaylist.cpp + database/databasecommand_loadops.cpp + database/databasecommand_updatesearchindex.cpp + database/databasecollection.cpp + + database/database.cpp + + network/servent.cpp + network/connection.cpp + network/controlconnection.cpp +) + +set( libHeaders + tomahawksettings.h + sourcelist.h + pipeline.h + functimeout.h + + collection.h + pluginapi.h + query.h + resolver.h + result.h + source.h + + artist.h + album.h + track.h + playlist.h + + sip/SipPlugin.h + + database/database.h + database/fuzzyindex.h + database/databaseworker.h + database/databaseimpl.h + database/databaseresolver.h + database/databasecommand.h + database/databasecommandloggable.h + database/databasecommand_resolve.h + database/databasecommand_allalbums.h + database/databasecommand_alltracks.h + database/databasecommand_addfiles.h + database/databasecommand_dirmtimes.h + database/databasecommand_loadfile.h + database/databasecommand_addsource.h + database/databasecommand_sourceoffline.h + database/databasecommand_collectionstats.h + database/databasecommand_loadplaylistentries.h + database/databasecommand_modifyplaylist.h + database/databasecommand_setplaylistrevision.h + database/databasecommand_loadallplaylists.h + database/databasecommand_createplaylist.h + database/databasecommand_deleteplaylist.h + database/databasecommand_renameplaylist.h + database/databasecommand_loadops.h + database/databasecommand_updatesearchindex.h + database/databasecollection.h + + network/bufferiodevice.h + network/msgprocessor.h + network/remotecollection.h + network/filetransferconnection.h + network/dbsyncconnection.h + network/servent.h + network/connection.h + network/controlconnection.h +) + +include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. + ${QT_INCLUDE_DIR} + ../../libportfwd/include + ../../include + ../network + ../../qxt/qxtweb-standalone/qxtweb +) + +qt4_wrap_cpp( libMoc ${libHeaders} ) +add_library( tomahawklib SHARED ${libSources} ${libMoc} ) + +IF( WIN32 ) +SET( OS_SPECIFIC_LINK_LIBRARIES + ${OS_SPECIFIC_LINK_LIBRARIES} + "iphlpapi.a" + "ws2_32.dll" + "dnsapi.dll" +) +ENDIF( WIN32 ) + +target_link_libraries( tomahawklib + ${QT_LIBRARIES} + ${OS_SPECIFIC_LINK_LIBRARIES} + portfwd + qjson +) + +install( TARGETS tomahawklib DESTINATION . ) diff --git a/src/album.cpp b/src/libtomahawk/album.cpp similarity index 91% rename from src/album.cpp rename to src/libtomahawk/album.cpp index 110bf755b..a2032a858 100644 --- a/src/album.cpp +++ b/src/libtomahawk/album.cpp @@ -1,9 +1,8 @@ -#include "tomahawk/album.h" +#include "album.h" #include -#include "tomahawk/collection.h" -#include "tomahawk/tomahawkapp.h" +#include "collection.h" #include "database/database.h" #include "database/databasecommand_alltracks.h" @@ -77,7 +76,7 @@ Album::tracks() connect( cmd, SIGNAL( tracks( QList, Tomahawk::collection_ptr ) ), SLOT( onTracksAdded( QList, Tomahawk::collection_ptr ) ) ); - APP->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } return m_queries; diff --git a/include/tomahawk/album.h b/src/libtomahawk/album.h similarity index 90% rename from include/tomahawk/album.h rename to src/libtomahawk/album.h index 9267b62d8..21ca7483d 100644 --- a/include/tomahawk/album.h +++ b/src/libtomahawk/album.h @@ -4,16 +4,18 @@ #include #include -#include "tomahawk/typedefs.h" -#include "tomahawk/artist.h" -#include "tomahawk/collection.h" +#include "typedefs.h" +#include "artist.h" +#include "collection.h" -#include "tomahawk/playlistinterface.h" +#include "playlistinterface.h" + +#include "dllmacro.h" namespace Tomahawk { -class Album : public QObject, public PlaylistInterface +class DLLEXPORT Album : public QObject, public PlaylistInterface { Q_OBJECT diff --git a/src/artist.cpp b/src/libtomahawk/artist.cpp similarity index 87% rename from src/artist.cpp rename to src/libtomahawk/artist.cpp index 1933750b1..1a22250e2 100644 --- a/src/artist.cpp +++ b/src/libtomahawk/artist.cpp @@ -1,9 +1,8 @@ -#include "tomahawk/artist.h" +#include "artist.h" #include -#include "tomahawk/collection.h" -#include "tomahawk/tomahawkapp.h" +#include "collection.h" #include "database/database.h" #include "database/databasecommand_alltracks.h" diff --git a/include/tomahawk/artist.h b/src/libtomahawk/artist.h similarity index 86% rename from include/tomahawk/artist.h rename to src/libtomahawk/artist.h index 645011e40..eb426a217 100644 --- a/include/tomahawk/artist.h +++ b/src/libtomahawk/artist.h @@ -4,13 +4,15 @@ #include #include -#include "tomahawk/typedefs.h" -#include "tomahawk/collection.h" +#include "typedefs.h" +#include "collection.h" + +#include "dllmacro.h" namespace Tomahawk { -class Artist : public QObject +class DLLEXPORT Artist : public QObject { Q_OBJECT diff --git a/src/collection.cpp b/src/libtomahawk/collection.cpp similarity index 96% rename from src/collection.cpp rename to src/libtomahawk/collection.cpp index 18b7c7a5b..1ee308137 100644 --- a/src/collection.cpp +++ b/src/libtomahawk/collection.cpp @@ -1,9 +1,9 @@ -#include "tomahawk/collection.h" +#include "collection.h" #include #include -#include "tomahawk/playlist.h" +#include "playlist.h" using namespace Tomahawk; diff --git a/include/tomahawk/collection.h b/src/libtomahawk/collection.h similarity index 93% rename from include/tomahawk/collection.h rename to src/libtomahawk/collection.h index af1bc7dc4..7f4648be5 100644 --- a/include/tomahawk/collection.h +++ b/src/libtomahawk/collection.h @@ -13,15 +13,17 @@ #include #include -#include "tomahawk/functimeout.h" -#include "tomahawk/playlist.h" -#include "tomahawk/source.h" -#include "tomahawk/typedefs.h" +#include "functimeout.h" +#include "playlist.h" +#include "source.h" +#include "typedefs.h" + +#include "dllmacro.h" namespace Tomahawk { -class Collection : public QObject +class DLLEXPORT Collection : public QObject { Q_OBJECT diff --git a/src/database/README.txt b/src/libtomahawk/database/README.txt similarity index 100% rename from src/database/README.txt rename to src/libtomahawk/database/README.txt diff --git a/src/database/database.cpp b/src/libtomahawk/database/database.cpp similarity index 88% rename from src/database/database.cpp rename to src/libtomahawk/database/database.cpp index e415e1650..59a3f540c 100644 --- a/src/database/database.cpp +++ b/src/libtomahawk/database/database.cpp @@ -1,5 +1,14 @@ #include "database.h" +Database* Database::s_instance = 0; + + +Database* +Database::instance() +{ + return s_instance; +} + Database::Database( const QString& dbname, QObject* parent ) : QObject( parent ) @@ -7,6 +16,8 @@ Database::Database( const QString& dbname, QObject* parent ) , m_workerRO( new DatabaseWorker( m_impl, this, false ) ) , m_workerRW( new DatabaseWorker( m_impl, this, true ) ) { + s_instance = this; + m_workerRO->start(); m_workerRW->start(); } diff --git a/src/database/database.h b/src/libtomahawk/database/database.h similarity index 82% rename from src/database/database.h rename to src/libtomahawk/database/database.h index 4b388f223..b62ebe050 100644 --- a/src/database/database.h +++ b/src/libtomahawk/database/database.h @@ -4,9 +4,11 @@ #include #include -#include "databaseimpl.h" -#include "databasecommand.h" -#include "databaseworker.h" +#include "database/databaseimpl.h" +#include "database/databasecommand.h" +#include "database/databaseworker.h" + +#include "dllmacro.h" /* This class is really a firewall/pimpl - the public functions of LibraryImpl @@ -19,10 +21,12 @@ Update: 1 thread for mutates, one for readonly queries. */ -class Database : public QObject +class DLLEXPORT Database : public QObject { Q_OBJECT public: + static Database* instance(); + explicit Database( const QString& dbname, QObject* parent = 0 ); ~Database(); @@ -43,6 +47,8 @@ private: DatabaseImpl* m_impl; DatabaseWorker *m_workerRO, *m_workerRW; bool m_indexReady; + + static Database* s_instance; }; #endif // DATABASE_H diff --git a/src/database/databasecollection.cpp b/src/libtomahawk/database/databasecollection.cpp similarity index 86% rename from src/database/databasecollection.cpp rename to src/libtomahawk/database/databasecollection.cpp index 771291096..7ebd1dc64 100644 --- a/src/database/databasecollection.cpp +++ b/src/libtomahawk/database/databasecollection.cpp @@ -1,7 +1,6 @@ #include "databasecollection.h" -#include "tomahawk/tomahawkapp.h" -#include "database.h" +#include "database/database.h" #include "databasecommand_alltracks.h" #include "databasecommand_addfiles.h" #include "databasecommand_loadallplaylists.h" @@ -24,7 +23,7 @@ DatabaseCollection::loadPlaylists() connect( cmd, SIGNAL( done( const QList& ) ), SLOT( setPlaylists( const QList& ) ) ); - TomahawkApp::instance()->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } @@ -39,7 +38,7 @@ DatabaseCollection::loadTracks() /* connect( cmd, SIGNAL( done( Tomahawk::collection_ptr ) ), SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ) );*/ - TomahawkApp::instance()->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } @@ -49,7 +48,7 @@ DatabaseCollection::addTracks( const QList &newitems ) qDebug() << Q_FUNC_INFO << newitems.length(); DatabaseCommand_AddFiles* cmd = new DatabaseCommand_AddFiles( newitems, source() ); - TomahawkApp::instance()->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } diff --git a/src/database/databasecollection.h b/src/libtomahawk/database/databasecollection.h similarity index 81% rename from src/database/databasecollection.h rename to src/libtomahawk/database/databasecollection.h index 37b658bed..e60cd96a0 100644 --- a/src/database/databasecollection.h +++ b/src/libtomahawk/database/databasecollection.h @@ -1,10 +1,12 @@ #ifndef DATABASECOLLECTION_H #define DATABASECOLLECTION_H -#include "tomahawk/collection.h" -#include "tomahawk/typedefs.h" +#include "collection.h" +#include "typedefs.h" -class DatabaseCollection : public Tomahawk::Collection +#include "dllmacro.h" + +class DLLEXPORT DatabaseCollection : public Tomahawk::Collection { Q_OBJECT diff --git a/src/database/databasecommand.cpp b/src/libtomahawk/database/databasecommand.cpp similarity index 100% rename from src/database/databasecommand.cpp rename to src/libtomahawk/database/databasecommand.cpp diff --git a/src/database/databasecommand.h b/src/libtomahawk/database/databasecommand.h similarity index 94% rename from src/database/databasecommand.h rename to src/libtomahawk/database/databasecommand.h index 9aa0fd020..d747769da 100644 --- a/src/database/databasecommand.h +++ b/src/libtomahawk/database/databasecommand.h @@ -6,13 +6,15 @@ #include #include -#include "tomahawk/source.h" -#include "tomahawk/typedefs.h" +#include "source.h" +#include "typedefs.h" #include "database/op.h" +#include "dllmacro.h" + class DatabaseImpl; -class DatabaseCommand : public QObject +class DLLEXPORT DatabaseCommand : public QObject { Q_OBJECT Q_PROPERTY( QString guid READ guid WRITE setGuid ) diff --git a/src/database/databasecommand_addfiles.cpp b/src/libtomahawk/database/databasecommand_addfiles.cpp similarity index 96% rename from src/database/databasecommand_addfiles.cpp rename to src/libtomahawk/database/databasecommand_addfiles.cpp index 942df663a..c4cabccc5 100644 --- a/src/database/databasecommand_addfiles.cpp +++ b/src/libtomahawk/database/databasecommand_addfiles.cpp @@ -2,12 +2,11 @@ #include -#include "tomahawk/collection.h" -#include "tomahawk/tomahawkapp.h" -#include "database.h" +#include "collection.h" +#include "database/database.h" #include "databasecommand_collectionstats.h" #include "databaseimpl.h" -#include "controlconnection.h" +#include "network/controlconnection.h" using namespace Tomahawk; @@ -49,10 +48,10 @@ DatabaseCommand_AddFiles::postCommitHook() DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( source() ); connect( cmd, SIGNAL( done( const QVariantMap& ) ), source().data(), SLOT( setStats( const QVariantMap& ) ), Qt::QueuedConnection ); - APP->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); if( source()->isLocal() ) - APP->servent().triggerDBSync(); + Servent::instance()->triggerDBSync(); } diff --git a/src/database/databasecommand_addfiles.h b/src/libtomahawk/database/databasecommand_addfiles.h similarity index 90% rename from src/database/databasecommand_addfiles.h rename to src/libtomahawk/database/databasecommand_addfiles.h index bfd6a368e..d3193c54f 100644 --- a/src/database/databasecommand_addfiles.h +++ b/src/libtomahawk/database/databasecommand_addfiles.h @@ -5,9 +5,11 @@ #include #include "database/databasecommandloggable.h" -#include "tomahawk/typedefs.h" +#include "typedefs.h" -class DatabaseCommand_AddFiles : public DatabaseCommandLoggable +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_AddFiles : public DatabaseCommandLoggable { Q_OBJECT Q_PROPERTY( QVariantList files READ files WRITE setFiles ) diff --git a/src/database/databasecommand_addsource.cpp b/src/libtomahawk/database/databasecommand_addsource.cpp similarity index 100% rename from src/database/databasecommand_addsource.cpp rename to src/libtomahawk/database/databasecommand_addsource.cpp diff --git a/src/database/databasecommand_addsource.h b/src/libtomahawk/database/databasecommand_addsource.h similarity index 86% rename from src/database/databasecommand_addsource.h rename to src/libtomahawk/database/databasecommand_addsource.h index a45fcfa4e..aa657aae8 100644 --- a/src/database/databasecommand_addsource.h +++ b/src/libtomahawk/database/databasecommand_addsource.h @@ -6,7 +6,9 @@ #include "databasecommand.h" -class DatabaseCommand_addSource : public DatabaseCommand +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_addSource : public DatabaseCommand { Q_OBJECT diff --git a/src/database/databasecommand_allalbums.cpp b/src/libtomahawk/database/databasecommand_allalbums.cpp similarity index 100% rename from src/database/databasecommand_allalbums.cpp rename to src/libtomahawk/database/databasecommand_allalbums.cpp diff --git a/src/database/databasecommand_allalbums.h b/src/libtomahawk/database/databasecommand_allalbums.h similarity index 89% rename from src/database/databasecommand_allalbums.h rename to src/libtomahawk/database/databasecommand_allalbums.h index 69ec71ced..37b6d0db2 100644 --- a/src/database/databasecommand_allalbums.h +++ b/src/libtomahawk/database/databasecommand_allalbums.h @@ -5,11 +5,13 @@ #include #include "databasecommand.h" -#include "tomahawk/album.h" -#include "tomahawk/collection.h" -#include "tomahawk/typedefs.h" +#include "album.h" +#include "collection.h" +#include "typedefs.h" -class DatabaseCommand_AllAlbums : public DatabaseCommand +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_AllAlbums : public DatabaseCommand { Q_OBJECT public: diff --git a/src/database/databasecommand_alltracks.cpp b/src/libtomahawk/database/databasecommand_alltracks.cpp similarity index 100% rename from src/database/databasecommand_alltracks.cpp rename to src/libtomahawk/database/databasecommand_alltracks.cpp diff --git a/src/database/databasecommand_alltracks.h b/src/libtomahawk/database/databasecommand_alltracks.h similarity index 90% rename from src/database/databasecommand_alltracks.h rename to src/libtomahawk/database/databasecommand_alltracks.h index 80ec99361..7cdc6dfd9 100644 --- a/src/database/databasecommand_alltracks.h +++ b/src/libtomahawk/database/databasecommand_alltracks.h @@ -5,11 +5,13 @@ #include #include "databasecommand.h" -#include "tomahawk/album.h" -#include "tomahawk/collection.h" -#include "tomahawk/typedefs.h" +#include "album.h" +#include "collection.h" +#include "typedefs.h" -class DatabaseCommand_AllTracks : public DatabaseCommand +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_AllTracks : public DatabaseCommand { Q_OBJECT public: diff --git a/src/database/databasecommand_collectionstats.cpp b/src/libtomahawk/database/databasecommand_collectionstats.cpp similarity index 100% rename from src/database/databasecommand_collectionstats.cpp rename to src/libtomahawk/database/databasecommand_collectionstats.cpp diff --git a/src/database/databasecommand_collectionstats.h b/src/libtomahawk/database/databasecommand_collectionstats.h similarity index 79% rename from src/database/databasecommand_collectionstats.h rename to src/libtomahawk/database/databasecommand_collectionstats.h index 50dcee941..1c14a3eb4 100644 --- a/src/database/databasecommand_collectionstats.h +++ b/src/libtomahawk/database/databasecommand_collectionstats.h @@ -4,10 +4,12 @@ #include #include "databasecommand.h" -#include "tomahawk/source.h" -#include "tomahawk/typedefs.h" +#include "source.h" +#include "typedefs.h" -class DatabaseCommand_CollectionStats : public DatabaseCommand +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_CollectionStats : public DatabaseCommand { Q_OBJECT diff --git a/src/database/databasecommand_createplaylist.cpp b/src/libtomahawk/database/databasecommand_createplaylist.cpp similarity index 96% rename from src/database/databasecommand_createplaylist.cpp rename to src/libtomahawk/database/databasecommand_createplaylist.cpp index 13d35144e..f8fd377ff 100644 --- a/src/database/databasecommand_createplaylist.cpp +++ b/src/libtomahawk/database/databasecommand_createplaylist.cpp @@ -2,7 +2,7 @@ #include -#include "tomahawk/tomahawkapp.h" +#include "network/servent.h" using namespace Tomahawk; @@ -60,5 +60,5 @@ DatabaseCommand_CreatePlaylist::postCommitHook() m_playlist->reportCreated( m_playlist ); if( source()->isLocal() ) - APP->servent().triggerDBSync(); + Servent::instance()->triggerDBSync(); } diff --git a/src/database/databasecommand_createplaylist.h b/src/libtomahawk/database/databasecommand_createplaylist.h similarity index 89% rename from src/database/databasecommand_createplaylist.h rename to src/libtomahawk/database/databasecommand_createplaylist.h index bd259eece..5c91c479f 100644 --- a/src/database/databasecommand_createplaylist.h +++ b/src/libtomahawk/database/databasecommand_createplaylist.h @@ -3,10 +3,12 @@ #include "databaseimpl.h" #include "databasecommandloggable.h" -#include "tomahawk/playlist.h" -#include "tomahawk/typedefs.h" +#include "playlist.h" +#include "typedefs.h" -class DatabaseCommand_CreatePlaylist : public DatabaseCommandLoggable +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_CreatePlaylist : public DatabaseCommandLoggable { Q_OBJECT Q_PROPERTY( QVariant playlist READ playlistV WRITE setPlaylistV ) diff --git a/src/database/databasecommand_deleteplaylist.cpp b/src/libtomahawk/database/databasecommand_deleteplaylist.cpp similarity index 93% rename from src/database/databasecommand_deleteplaylist.cpp rename to src/libtomahawk/database/databasecommand_deleteplaylist.cpp index 840fbb019..2f85a5a0e 100644 --- a/src/database/databasecommand_deleteplaylist.cpp +++ b/src/libtomahawk/database/databasecommand_deleteplaylist.cpp @@ -2,7 +2,7 @@ #include -#include "tomahawk/tomahawkapp.h" +#include "network/servent.h" using namespace Tomahawk; @@ -41,5 +41,5 @@ DatabaseCommand_DeletePlaylist::postCommitHook() playlist->reportDeleted( playlist ); if( source()->isLocal() ) - APP->servent().triggerDBSync(); + Servent::instance()->triggerDBSync(); } diff --git a/src/database/databasecommand_deleteplaylist.h b/src/libtomahawk/database/databasecommand_deleteplaylist.h similarity index 85% rename from src/database/databasecommand_deleteplaylist.h rename to src/libtomahawk/database/databasecommand_deleteplaylist.h index 84d069750..838f6fd46 100644 --- a/src/database/databasecommand_deleteplaylist.h +++ b/src/libtomahawk/database/databasecommand_deleteplaylist.h @@ -3,10 +3,12 @@ #include "databaseimpl.h" #include "databasecommandloggable.h" -#include "tomahawk/source.h" -#include "tomahawk/typedefs.h" +#include "source.h" +#include "typedefs.h" -class DatabaseCommand_DeletePlaylist : public DatabaseCommandLoggable +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_DeletePlaylist : public DatabaseCommandLoggable { Q_OBJECT Q_PROPERTY( QString playlistguid READ playlistguid WRITE setPlaylistguid ) diff --git a/src/database/databasecommand_dirmtimes.cpp b/src/libtomahawk/database/databasecommand_dirmtimes.cpp similarity index 100% rename from src/database/databasecommand_dirmtimes.cpp rename to src/libtomahawk/database/databasecommand_dirmtimes.cpp diff --git a/src/database/databasecommand_dirmtimes.h b/src/libtomahawk/database/databasecommand_dirmtimes.h similarity index 92% rename from src/database/databasecommand_dirmtimes.h rename to src/libtomahawk/database/databasecommand_dirmtimes.h index bc9ba4bef..9071599e0 100644 --- a/src/database/databasecommand_dirmtimes.h +++ b/src/libtomahawk/database/databasecommand_dirmtimes.h @@ -7,9 +7,11 @@ #include "databasecommand.h" +#include "dllmacro.h" + // Not loggable, mtimes only used to speed up our local scanner. -class DatabaseCommand_DirMtimes : public DatabaseCommand +class DLLEXPORT DatabaseCommand_DirMtimes : public DatabaseCommand { Q_OBJECT diff --git a/src/database/databasecommand_importplaylist.cpp b/src/libtomahawk/database/databasecommand_importplaylist.cpp similarity index 100% rename from src/database/databasecommand_importplaylist.cpp rename to src/libtomahawk/database/databasecommand_importplaylist.cpp diff --git a/src/database/databasecommand_importplaylist.h b/src/libtomahawk/database/databasecommand_importplaylist.h similarity index 86% rename from src/database/databasecommand_importplaylist.h rename to src/libtomahawk/database/databasecommand_importplaylist.h index 19832a4d2..62e3a5d3f 100644 --- a/src/database/databasecommand_importplaylist.h +++ b/src/libtomahawk/database/databasecommand_importplaylist.h @@ -1,13 +1,17 @@ #ifndef DATABASECOMMAND_IMPORTPLAYLIST_H #define DATABASECOMMAND_IMPORTPLAYLIST_H + #include #include + #include "databasecommand.h" #include "tomahawk/source.h" +#include "dllmacro.h" + class Playlist; -class DatabaseCommand_ImportPlaylist : public DatabaseCommand +class DLLEXPORT DatabaseCommand_ImportPlaylist : public DatabaseCommand { Q_OBJECT public: diff --git a/src/database/databasecommand_loadallplaylists.cpp b/src/libtomahawk/database/databasecommand_loadallplaylists.cpp similarity index 97% rename from src/database/databasecommand_loadallplaylists.cpp rename to src/libtomahawk/database/databasecommand_loadallplaylists.cpp index 1822532d1..860f9873f 100644 --- a/src/database/databasecommand_loadallplaylists.cpp +++ b/src/libtomahawk/database/databasecommand_loadallplaylists.cpp @@ -2,7 +2,7 @@ #include -#include "tomahawk/playlist.h" +#include "playlist.h" #include "databaseimpl.h" using namespace Tomahawk; diff --git a/src/database/databasecommand_loadallplaylists.h b/src/libtomahawk/database/databasecommand_loadallplaylists.h similarity index 83% rename from src/database/databasecommand_loadallplaylists.h rename to src/libtomahawk/database/databasecommand_loadallplaylists.h index 371651eea..2738f26df 100644 --- a/src/database/databasecommand_loadallplaylists.h +++ b/src/libtomahawk/database/databasecommand_loadallplaylists.h @@ -5,9 +5,11 @@ #include #include "databasecommand.h" -#include "tomahawk/typedefs.h" +#include "typedefs.h" -class DatabaseCommand_LoadAllPlaylists : public DatabaseCommand +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_LoadAllPlaylists : public DatabaseCommand { Q_OBJECT diff --git a/src/database/databasecommand_loadfile.cpp b/src/libtomahawk/database/databasecommand_loadfile.cpp similarity index 94% rename from src/database/databasecommand_loadfile.cpp rename to src/libtomahawk/database/databasecommand_loadfile.cpp index 2542eda70..6b1870e26 100644 --- a/src/database/databasecommand_loadfile.cpp +++ b/src/libtomahawk/database/databasecommand_loadfile.cpp @@ -1,7 +1,7 @@ #include "databasecommand_loadfile.h" #include "databaseimpl.h" -#include "tomahawk/collection.h" +#include "collection.h" DatabaseCommand_LoadFile::DatabaseCommand_LoadFile( const QString& id, QObject* parent ) diff --git a/src/database/databasecommand_loadfile.h b/src/libtomahawk/database/databasecommand_loadfile.h similarity index 86% rename from src/database/databasecommand_loadfile.h rename to src/libtomahawk/database/databasecommand_loadfile.h index f4d596ea7..7cc2fdf89 100644 --- a/src/database/databasecommand_loadfile.h +++ b/src/libtomahawk/database/databasecommand_loadfile.h @@ -7,7 +7,9 @@ #include "databasecommand.h" -class DatabaseCommand_LoadFile : public DatabaseCommand +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_LoadFile : public DatabaseCommand { Q_OBJECT diff --git a/src/database/databasecommand_loadops.cpp b/src/libtomahawk/database/databasecommand_loadops.cpp similarity index 100% rename from src/database/databasecommand_loadops.cpp rename to src/libtomahawk/database/databasecommand_loadops.cpp diff --git a/src/database/databasecommand_loadops.h b/src/libtomahawk/database/databasecommand_loadops.h similarity index 85% rename from src/database/databasecommand_loadops.h rename to src/libtomahawk/database/databasecommand_loadops.h index f6e11b09a..15c015e1d 100644 --- a/src/database/databasecommand_loadops.h +++ b/src/libtomahawk/database/databasecommand_loadops.h @@ -1,12 +1,14 @@ #ifndef DATABASECOMMAND_LOADOPS_H #define DATABASECOMMAND_LOADOPS_H -#include "tomahawk/typedefs.h" +#include "typedefs.h" #include "databasecommand.h" #include "databaseimpl.h" #include "op.h" -class DatabaseCommand_loadOps : public DatabaseCommand +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_loadOps : public DatabaseCommand { Q_OBJECT public: diff --git a/src/database/databasecommand_loadplaylistentries.cpp b/src/libtomahawk/database/databasecommand_loadplaylistentries.cpp similarity index 100% rename from src/database/databasecommand_loadplaylistentries.cpp rename to src/libtomahawk/database/databasecommand_loadplaylistentries.cpp diff --git a/src/database/databasecommand_loadplaylistentries.h b/src/libtomahawk/database/databasecommand_loadplaylistentries.h similarity index 87% rename from src/database/databasecommand_loadplaylistentries.h rename to src/libtomahawk/database/databasecommand_loadplaylistentries.h index d9333e9eb..de59a904f 100644 --- a/src/database/databasecommand_loadplaylistentries.h +++ b/src/libtomahawk/database/databasecommand_loadplaylistentries.h @@ -5,9 +5,11 @@ #include #include "databasecommand.h" -#include "tomahawk/playlist.h" +#include "playlist.h" -class DatabaseCommand_LoadPlaylistEntries : public DatabaseCommand +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_LoadPlaylistEntries : public DatabaseCommand { Q_OBJECT diff --git a/src/database/databasecommand_modifyplaylist.cpp b/src/libtomahawk/database/databasecommand_modifyplaylist.cpp similarity index 100% rename from src/database/databasecommand_modifyplaylist.cpp rename to src/libtomahawk/database/databasecommand_modifyplaylist.cpp diff --git a/src/database/databasecommand_modifyplaylist.h b/src/libtomahawk/database/databasecommand_modifyplaylist.h similarity index 85% rename from src/database/databasecommand_modifyplaylist.h rename to src/libtomahawk/database/databasecommand_modifyplaylist.h index 9bae6f0d4..e967bdb29 100644 --- a/src/database/databasecommand_modifyplaylist.h +++ b/src/libtomahawk/database/databasecommand_modifyplaylist.h @@ -5,10 +5,12 @@ #include #include "databasecommand.h" -#include "tomahawk/source.h" -#include "tomahawk/playlist.h" +#include "source.h" +#include "playlist.h" -class DatabaseCommand_ModifyPlaylist : public DatabaseCommand +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_ModifyPlaylist : public DatabaseCommand { Q_OBJECT Q_PROPERTY( int mode READ mode WRITE setMode ) diff --git a/src/database/databasecommand_renameplaylist.cpp b/src/libtomahawk/database/databasecommand_renameplaylist.cpp similarity index 93% rename from src/database/databasecommand_renameplaylist.cpp rename to src/libtomahawk/database/databasecommand_renameplaylist.cpp index 51da0ff6d..9b3737ae9 100644 --- a/src/database/databasecommand_renameplaylist.cpp +++ b/src/libtomahawk/database/databasecommand_renameplaylist.cpp @@ -2,7 +2,7 @@ #include -#include "tomahawk/tomahawkapp.h" +#include "network/servent.h" using namespace Tomahawk; @@ -44,5 +44,5 @@ DatabaseCommand_RenamePlaylist::postCommitHook() playlist->setTitle( m_playlistTitle ); if( source()->isLocal() ) - APP->servent().triggerDBSync(); + Servent::instance()->triggerDBSync(); } diff --git a/src/database/databasecommand_renameplaylist.h b/src/libtomahawk/database/databasecommand_renameplaylist.h similarity index 88% rename from src/database/databasecommand_renameplaylist.h rename to src/libtomahawk/database/databasecommand_renameplaylist.h index a5e3c186e..c6692dcff 100644 --- a/src/database/databasecommand_renameplaylist.h +++ b/src/libtomahawk/database/databasecommand_renameplaylist.h @@ -3,10 +3,12 @@ #include "databaseimpl.h" #include "databasecommandloggable.h" -#include "tomahawk/source.h" -#include "tomahawk/typedefs.h" +#include "source.h" +#include "typedefs.h" -class DatabaseCommand_RenamePlaylist : public DatabaseCommandLoggable +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_RenamePlaylist : public DatabaseCommandLoggable { Q_OBJECT Q_PROPERTY( QString playlistguid READ playlistguid WRITE setPlaylistguid ) diff --git a/src/database/databasecommand_resolve.cpp b/src/libtomahawk/database/databasecommand_resolve.cpp similarity index 97% rename from src/database/databasecommand_resolve.cpp rename to src/libtomahawk/database/databasecommand_resolve.cpp index bd28d6f0d..0bd1f915d 100644 --- a/src/database/databasecommand_resolve.cpp +++ b/src/libtomahawk/database/databasecommand_resolve.cpp @@ -1,7 +1,7 @@ #include "databasecommand_resolve.h" -#include "tomahawk/tomahawkapp.h" -#include "tomahawk/album.h" +#include "album.h" +#include "sourcelist.h" #define MINSCORE 0.5 @@ -114,13 +114,13 @@ DatabaseCommand_Resolve::exec( DatabaseImpl* lib ) const QString url_str = files_query.value( 0 ).toString(); if( m_searchlocal ) { - coll = APP->sourcelist().getLocal()->collection(); + coll = SourceList::instance()->getLocal()->collection(); m["url"] = url_str; m["source"] = "Local Database"; // TODO } else { - source_ptr s = APP->sourcelist().get( files_query.value( 13 ).toUInt() ); + source_ptr s = SourceList::instance()->get( files_query.value( 13 ).toUInt() ); if( s.isNull() ) { //qDebug() << "Skipping result for offline sourceid:" << files_query.value(13).toUInt(); diff --git a/src/database/databasecommand_resolve.h b/src/libtomahawk/database/databasecommand_resolve.h similarity index 96% rename from src/database/databasecommand_resolve.h rename to src/libtomahawk/database/databasecommand_resolve.h index 26945698a..81ab23263 100644 --- a/src/database/databasecommand_resolve.h +++ b/src/libtomahawk/database/databasecommand_resolve.h @@ -3,11 +3,13 @@ #include "databasecommand.h" #include "databaseimpl.h" -#include "tomahawk/result.h" +#include "result.h" #include -class DatabaseCommand_Resolve : public DatabaseCommand +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_Resolve : public DatabaseCommand { Q_OBJECT public: diff --git a/src/database/databasecommand_setplaylistrevision.cpp b/src/libtomahawk/database/databasecommand_setplaylistrevision.cpp similarity index 98% rename from src/database/databasecommand_setplaylistrevision.cpp rename to src/libtomahawk/database/databasecommand_setplaylistrevision.cpp index be2dbdfda..2d509f49c 100644 --- a/src/database/databasecommand_setplaylistrevision.cpp +++ b/src/libtomahawk/database/databasecommand_setplaylistrevision.cpp @@ -3,7 +3,7 @@ #include #include "tomahawksqlquery.h" -#include "tomahawk/tomahawkapp.h" +#include "network/servent.h" DatabaseCommand_SetPlaylistRevision::DatabaseCommand_SetPlaylistRevision( @@ -56,7 +56,7 @@ DatabaseCommand_SetPlaylistRevision::postCommitHook() m_applied ); if( source()->isLocal() ) - APP->servent().triggerDBSync(); + Servent::instance()->triggerDBSync(); } diff --git a/src/database/databasecommand_setplaylistrevision.h b/src/libtomahawk/database/databasecommand_setplaylistrevision.h similarity index 94% rename from src/database/databasecommand_setplaylistrevision.h rename to src/libtomahawk/database/databasecommand_setplaylistrevision.h index f9d420df0..970cf767e 100644 --- a/src/database/databasecommand_setplaylistrevision.h +++ b/src/libtomahawk/database/databasecommand_setplaylistrevision.h @@ -3,12 +3,14 @@ #include "databasecommandloggable.h" #include "databaseimpl.h" -#include "tomahawk/collection.h" -#include "tomahawk/playlist.h" +#include "collection.h" +#include "playlist.h" + +#include "dllmacro.h" using namespace Tomahawk; -class DatabaseCommand_SetPlaylistRevision : public DatabaseCommandLoggable +class DLLEXPORT DatabaseCommand_SetPlaylistRevision : public DatabaseCommandLoggable { Q_OBJECT Q_PROPERTY( QString playlistguid READ playlistguid WRITE setPlaylistguid ) diff --git a/src/database/databasecommand_sourceoffline.cpp b/src/libtomahawk/database/databasecommand_sourceoffline.cpp similarity index 100% rename from src/database/databasecommand_sourceoffline.cpp rename to src/libtomahawk/database/databasecommand_sourceoffline.cpp diff --git a/src/database/databasecommand_sourceoffline.h b/src/libtomahawk/database/databasecommand_sourceoffline.h similarity index 79% rename from src/database/databasecommand_sourceoffline.h rename to src/libtomahawk/database/databasecommand_sourceoffline.h index c5988d378..02ccc1571 100644 --- a/src/database/databasecommand_sourceoffline.h +++ b/src/libtomahawk/database/databasecommand_sourceoffline.h @@ -4,7 +4,9 @@ #include "databasecommand.h" #include "databaseimpl.h" -class DatabaseCommand_SourceOffline : public DatabaseCommand +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_SourceOffline : public DatabaseCommand { Q_OBJECT diff --git a/src/database/databasecommand_updatesearchindex.cpp b/src/libtomahawk/database/databasecommand_updatesearchindex.cpp similarity index 100% rename from src/database/databasecommand_updatesearchindex.cpp rename to src/libtomahawk/database/databasecommand_updatesearchindex.cpp diff --git a/src/database/databasecommand_updatesearchindex.h b/src/libtomahawk/database/databasecommand_updatesearchindex.h similarity index 85% rename from src/database/databasecommand_updatesearchindex.h rename to src/libtomahawk/database/databasecommand_updatesearchindex.h index 87d886ff8..c9278e0cb 100644 --- a/src/database/databasecommand_updatesearchindex.h +++ b/src/libtomahawk/database/databasecommand_updatesearchindex.h @@ -4,7 +4,9 @@ #include "databasecommand.h" #include "databaseimpl.h" -class DatabaseCommand_UpdateSearchIndex : public DatabaseCommand +#include "dllmacro.h" + +class DLLEXPORT DatabaseCommand_UpdateSearchIndex : public DatabaseCommand { Q_OBJECT public: diff --git a/src/database/databasecommandloggable.cpp b/src/libtomahawk/database/databasecommandloggable.cpp similarity index 100% rename from src/database/databasecommandloggable.cpp rename to src/libtomahawk/database/databasecommandloggable.cpp diff --git a/src/database/databasecommandloggable.h b/src/libtomahawk/database/databasecommandloggable.h similarity index 89% rename from src/database/databasecommandloggable.h rename to src/libtomahawk/database/databasecommandloggable.h index 90dfab1e4..9877085ae 100644 --- a/src/database/databasecommandloggable.h +++ b/src/libtomahawk/database/databasecommandloggable.h @@ -3,9 +3,11 @@ #include "database/databasecommand.h" +#include "dllmacro.h" + /// A Database Command that will be added to the oplog and sent over the network /// so peers can sync up and changes to our collection in their cached copy. -class DatabaseCommandLoggable : public DatabaseCommand +class DLLEXPORT DatabaseCommandLoggable : public DatabaseCommand { Q_OBJECT Q_PROPERTY(QString command READ commandname) diff --git a/src/database/databaseimpl.cpp b/src/libtomahawk/database/databaseimpl.cpp similarity index 98% rename from src/database/databaseimpl.cpp rename to src/libtomahawk/database/databaseimpl.cpp index 53e6f6ca2..48382f454 100644 --- a/src/database/databaseimpl.cpp +++ b/src/libtomahawk/database/databaseimpl.cpp @@ -1,11 +1,12 @@ #include "databaseimpl.h" +#include #include #include #include #include -#include "database.h" -#include "tomahawk/tomahawkapp.h" + +#include "database/database.h" #include "databasecommand_updatesearchindex.h" /* !!!! You need to manually generate schema.sql.h when the schema changes: @@ -69,7 +70,7 @@ DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent ) else { Q_ASSERT(0); - QTimer::singleShot( 0, APP, SLOT( quit() ) ); + QTimer::singleShot( 0, qApp, SLOT( quit() ) ); return; } } @@ -102,7 +103,7 @@ DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent ) DatabaseImpl::~DatabaseImpl() { m_indexThread.quit(); - m_indexThread.wait(5000); + m_indexThread.wait( 5000 ); } @@ -121,7 +122,7 @@ void DatabaseImpl::updateSearchIndex( const QString& table, int pkey ) { DatabaseCommand* cmd = new DatabaseCommand_UpdateSearchIndex(table, pkey); - APP->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } diff --git a/src/database/databaseimpl.h b/src/libtomahawk/database/databaseimpl.h similarity index 100% rename from src/database/databaseimpl.h rename to src/libtomahawk/database/databaseimpl.h diff --git a/src/database/databaseresolver.cpp b/src/libtomahawk/database/databaseresolver.cpp similarity index 78% rename from src/database/databaseresolver.cpp rename to src/libtomahawk/database/databaseresolver.cpp index e0bb8b6d8..60326949f 100644 --- a/src/database/databaseresolver.cpp +++ b/src/libtomahawk/database/databaseresolver.cpp @@ -1,7 +1,7 @@ #include "databaseresolver.h" -#include "tomahawk/tomahawkapp.h" -#include "database.h" +#include "network/servent.h" +#include "database/database.h" #include "database/databasecommand_resolve.h" DatabaseResolver::DatabaseResolver( bool searchlocal, int weight ) @@ -19,7 +19,7 @@ DatabaseResolver::resolve( const QVariant& v ) if( !m_searchlocal ) { - if( APP->servent().numConnectedPeers() == 0 ) + if( Servent::instance()->numConnectedPeers() == 0 ) return; } @@ -28,7 +28,7 @@ DatabaseResolver::resolve( const QVariant& v ) connect( cmd, SIGNAL( results( Tomahawk::QID, QList< Tomahawk::result_ptr> ) ), SLOT( gotResults( Tomahawk::QID, QList< Tomahawk::result_ptr> ) ), Qt::QueuedConnection ); - APP->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } @@ -38,7 +38,7 @@ DatabaseResolver::gotResults( const Tomahawk::QID qid, QList< Tomahawk::result_p { // qDebug() << Q_FUNC_INFO << qid << results.length(); - APP->pipeline()->reportResults( qid, results ); + Tomahawk::Pipeline::instance()->reportResults( qid, results ); } diff --git a/src/database/databaseresolver.h b/src/libtomahawk/database/databaseresolver.h similarity index 79% rename from src/database/databaseresolver.h rename to src/libtomahawk/database/databaseresolver.h index f9bbd2696..b40f2a200 100644 --- a/src/database/databaseresolver.h +++ b/src/libtomahawk/database/databaseresolver.h @@ -1,10 +1,14 @@ #ifndef DATABASERESOLVER_H #define DATABASERESOLVER_H -#include "tomahawk/resolver.h" -#include "tomahawk/result.h" +#include "pipeline.h" -class DatabaseResolver : public Tomahawk::Resolver +#include "resolver.h" +#include "result.h" + +#include "dllmacro.h" + +class DLLEXPORT DatabaseResolver : public Tomahawk::Resolver { Q_OBJECT diff --git a/src/database/databaseworker.cpp b/src/libtomahawk/database/databaseworker.cpp similarity index 99% rename from src/database/databaseworker.cpp rename to src/libtomahawk/database/databaseworker.cpp index 699c4437a..c58835ded 100644 --- a/src/database/databaseworker.cpp +++ b/src/libtomahawk/database/databaseworker.cpp @@ -4,8 +4,7 @@ #include #include -#include "tomahawk/tomahawkapp.h" -#include "database.h" +#include "database/database.h" #include "database/databasecommandloggable.h" diff --git a/src/database/databaseworker.h b/src/libtomahawk/database/databaseworker.h similarity index 100% rename from src/database/databaseworker.h rename to src/libtomahawk/database/databaseworker.h diff --git a/src/database/fuzzyindex.cpp b/src/libtomahawk/database/fuzzyindex.cpp similarity index 100% rename from src/database/fuzzyindex.cpp rename to src/libtomahawk/database/fuzzyindex.cpp diff --git a/src/database/fuzzyindex.h b/src/libtomahawk/database/fuzzyindex.h similarity index 100% rename from src/database/fuzzyindex.h rename to src/libtomahawk/database/fuzzyindex.h diff --git a/src/database/gen_schema.h.sh b/src/libtomahawk/database/gen_schema.h.sh similarity index 100% rename from src/database/gen_schema.h.sh rename to src/libtomahawk/database/gen_schema.h.sh diff --git a/src/database/op.h b/src/libtomahawk/database/op.h similarity index 100% rename from src/database/op.h rename to src/libtomahawk/database/op.h diff --git a/src/database/schema.sql b/src/libtomahawk/database/schema.sql similarity index 100% rename from src/database/schema.sql rename to src/libtomahawk/database/schema.sql diff --git a/src/database/schema.sql.h b/src/libtomahawk/database/schema.sql.h similarity index 100% rename from src/database/schema.sql.h rename to src/libtomahawk/database/schema.sql.h diff --git a/src/database/tomahawksqlquery.h b/src/libtomahawk/database/tomahawksqlquery.h similarity index 100% rename from src/database/tomahawksqlquery.h rename to src/libtomahawk/database/tomahawksqlquery.h diff --git a/src/libtomahawk/dllmacro.h b/src/libtomahawk/dllmacro.h new file mode 100644 index 000000000..b4b199505 --- /dev/null +++ b/src/libtomahawk/dllmacro.h @@ -0,0 +1,14 @@ +#ifndef DLLMACRO_H +#define DLLMACRO_H + +#ifdef WIN32 + #ifdef DLLEXPORT_PRO + #define DLLEXPORT __declspec(dllexport) + #else + #define DLLEXPORT __declspec(dllimport) + #endif +#else + #define DLLEXPORT +#endif + +#endif diff --git a/include/tomahawk/functimeout.h b/src/libtomahawk/functimeout.h similarity index 100% rename from include/tomahawk/functimeout.h rename to src/libtomahawk/functimeout.h diff --git a/src/network/bufferiodevice.cpp b/src/libtomahawk/network/bufferiodevice.cpp similarity index 100% rename from src/network/bufferiodevice.cpp rename to src/libtomahawk/network/bufferiodevice.cpp diff --git a/src/network/bufferiodevice.h b/src/libtomahawk/network/bufferiodevice.h similarity index 100% rename from src/network/bufferiodevice.h rename to src/libtomahawk/network/bufferiodevice.h diff --git a/src/network/connection.cpp b/src/libtomahawk/network/connection.cpp similarity index 99% rename from src/network/connection.cpp rename to src/libtomahawk/network/connection.cpp index 3e83e650f..2dc64db52 100644 --- a/src/network/connection.cpp +++ b/src/libtomahawk/network/connection.cpp @@ -3,7 +3,7 @@ #include #include -#include "servent.h" +#include "network/servent.h" #define PROTOVER "3" // must match remote peer, or we can't talk. diff --git a/src/network/connection.h b/src/libtomahawk/network/connection.h similarity index 97% rename from src/network/connection.h rename to src/libtomahawk/network/connection.h index 7c964913a..4bcefe214 100644 --- a/src/network/connection.h +++ b/src/libtomahawk/network/connection.h @@ -21,9 +21,11 @@ #include "msg.h" #include "msgprocessor.h" +#include "dllmacro.h" + class Servent; -class Connection : public QObject +class DLLEXPORT Connection : public QObject { Q_OBJECT diff --git a/src/network/controlconnection.cpp b/src/libtomahawk/network/controlconnection.cpp similarity index 97% rename from src/network/controlconnection.cpp rename to src/libtomahawk/network/controlconnection.cpp index e05511653..a9aec0ba7 100644 --- a/src/network/controlconnection.cpp +++ b/src/libtomahawk/network/controlconnection.cpp @@ -1,11 +1,11 @@ #include "controlconnection.h" -#include "tomahawk/tomahawkapp.h" #include "remotecollection.h" #include "filetransferconnection.h" -#include "database.h" -#include "databasecommand_collectionstats.h" +#include "database/database.h" +#include "database/databasecommand_collectionstats.h" #include "dbsyncconnection.h" +#include "sourcelist.h" #define TCP_TIMEOUT 600 @@ -96,7 +96,7 @@ ControlConnection::registerSource() collection_ptr coll( new RemoteCollection( m_source ) ); m_source->addCollection( coll ); - TomahawkApp::instance()->sourcelist().add( m_source ); + SourceList::instance()->add( m_source ); m_registered = true; setupDbSyncConnection(); diff --git a/src/network/controlconnection.h b/src/libtomahawk/network/controlconnection.h similarity index 86% rename from src/network/controlconnection.h rename to src/libtomahawk/network/controlconnection.h index cad4941f9..77261ffd3 100644 --- a/src/network/controlconnection.h +++ b/src/libtomahawk/network/controlconnection.h @@ -9,13 +9,15 @@ #define CONTROLCONNECTION_H #include "connection.h" -#include "servent.h" -#include "tomahawk/source.h" -#include "tomahawk/typedefs.h" +#include "network/servent.h" +#include "source.h" +#include "typedefs.h" + +#include "dllmacro.h" class FileTransferSession; -class ControlConnection : public Connection +class DLLEXPORT ControlConnection : public Connection { Q_OBJECT diff --git a/src/network/dbsyncconnection.cpp b/src/libtomahawk/network/dbsyncconnection.cpp similarity index 88% rename from src/network/dbsyncconnection.cpp rename to src/libtomahawk/network/dbsyncconnection.cpp index 16a3d1d02..6f0ebdd8f 100644 --- a/src/network/dbsyncconnection.cpp +++ b/src/libtomahawk/network/dbsyncconnection.cpp @@ -14,14 +14,14 @@ #include -#include "tomahawk/tomahawkapp.h" -#include "tomahawk/source.h" +#include "source.h" -#include "database.h" -#include "databasecommand.h" -#include "databasecommand_collectionstats.h" -#include "databasecommand_loadops.h" +#include "database/database.h" +#include "database/databasecommand.h" +#include "database/databasecommand_collectionstats.h" +#include "database/databasecommand_loadops.h" #include "remotecollection.h" +#include "sourcelist.h" // close the dbsync connection after this much inactivity. // it's automatically reestablished as needed. @@ -120,7 +120,7 @@ DBSyncConnection::check() // load last-modified etc data for our collection and theirs from our DB: DatabaseCommand_CollectionStats * cmd_us = - new DatabaseCommand_CollectionStats( APP->sourcelist().getLocal() ); + new DatabaseCommand_CollectionStats( SourceList::instance()->getLocal() ); DatabaseCommand_CollectionStats * cmd_them = new DatabaseCommand_CollectionStats( m_source ); @@ -132,9 +132,8 @@ DBSyncConnection::check() this, SLOT( gotThemCache(const QVariantMap&) ) ); - APP->database()->enqueue( QSharedPointer(cmd_us) ); - - APP->database()->enqueue( QSharedPointer(cmd_them) ); + Database::instance()->enqueue( QSharedPointer(cmd_us) ); + Database::instance()->enqueue( QSharedPointer(cmd_them) ); // restarts idle countdown m_timer.start(); @@ -178,13 +177,13 @@ DBSyncConnection::handleMsg( msg_ptr msg ) msg->payload() == "ok" ) { qDebug() << "No ops to apply, we are synced."; - changeState(SYNCED); + changeState( SYNCED ); // calc the collection stats, to updates the "X tracks" in the sidebar etc // this is done automatically if you run a dbcmd to add files. - DatabaseCommand_CollectionStats * cmd = new DatabaseCommand_CollectionStats( m_source ); + DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( m_source ); connect( cmd, SIGNAL( done( const QVariantMap & ) ), m_source.data(), SLOT( setStats( const QVariantMap& ) ), Qt::QueuedConnection ); - APP->database()->enqueue( QSharedPointer(cmd) ); + Database::instance()->enqueue( QSharedPointer(cmd) ); return; } @@ -218,7 +217,7 @@ DBSyncConnection::handleMsg( msg_ptr msg ) changeState( SAVING ); // just DB work left to complete connect( cmd, SIGNAL( finished() ), this, SLOT( lastOpApplied() ) ); } - APP->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); return; } @@ -261,13 +260,13 @@ DBSyncConnection::sendOps() qDebug() << "Will send peer all ops since" << sinceguid; - source_ptr src = APP->sourcelist().getLocal(); + source_ptr src = SourceList::instance()->getLocal(); - DatabaseCommand_loadOps * cmd = new DatabaseCommand_loadOps( src, sinceguid ); + DatabaseCommand_loadOps* cmd = new DatabaseCommand_loadOps( src, sinceguid ); connect( cmd, SIGNAL( done( QString, QList< dbop_ptr > ) ), this, SLOT( sendOpsData( QString, QList< dbop_ptr > ) ) ); - APP->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } diff --git a/src/network/dbsyncconnection.h b/src/libtomahawk/network/dbsyncconnection.h similarity index 95% rename from src/network/dbsyncconnection.h rename to src/libtomahawk/network/dbsyncconnection.h index 762a01111..2a888ce97 100644 --- a/src/network/dbsyncconnection.h +++ b/src/libtomahawk/network/dbsyncconnection.h @@ -6,9 +6,9 @@ #include #include -#include "connection.h" +#include "network/connection.h" #include "database/op.h" -#include "tomahawk/typedefs.h" +#include "typedefs.h" class DBSyncConnection : public Connection { diff --git a/src/network/filetransferconnection.cpp b/src/libtomahawk/network/filetransferconnection.cpp similarity index 90% rename from src/network/filetransferconnection.cpp rename to src/libtomahawk/network/filetransferconnection.cpp index 7d64d0ee1..ea9e9a924 100644 --- a/src/network/filetransferconnection.cpp +++ b/src/libtomahawk/network/filetransferconnection.cpp @@ -2,13 +2,13 @@ #include -#include "tomahawk/tomahawkapp.h" -#include "tomahawk/result.h" +#include "result.h" #include "bufferiodevice.h" -#include "controlconnection.h" -#include "databasecommand_loadfile.h" -#include "database.h" +#include "network/controlconnection.h" +#include "database/databasecommand_loadfile.h" +#include "database/database.h" +#include "sourcelist.h" // Msgs are framed, this is the size each msg we send containing audio data: #define BLOCKSIZE 4096 @@ -33,7 +33,7 @@ FileTransferConnection::FileTransferConnection( Servent* s, ControlConnection* c m_iodev = QSharedPointer( bio ); // device audio data gets written to m_iodev->open( QIODevice::ReadWrite ); - APP->servent().registerFileTransferConnection( this ); + Servent::instance()->registerFileTransferConnection( this ); // if the audioengine closes the iodev (skip/stop/etc) then kill the connection // immediately to avoid unnecessary network transfer @@ -58,7 +58,7 @@ FileTransferConnection::FileTransferConnection( Servent* s, ControlConnection* c , m_allok( false ) , m_transferRate( 0 ) { - APP->servent().registerFileTransferConnection( this ); + Servent::instance()->registerFileTransferConnection( this ); // auto delete when connection closes: connect( this, SIGNAL( finished() ), SLOT( deleteLater() ), Qt::QueuedConnection ); } @@ -78,7 +78,7 @@ FileTransferConnection::~FileTransferConnection() ((BufferIODevice*)m_iodev.data())->inputComplete(); } - APP->servent().onFileTransferFinished( this ); + Servent::instance()->onFileTransferFinished( this ); } @@ -109,7 +109,7 @@ FileTransferConnection::showStats( qint64 tx, qint64 rx ) void FileTransferConnection::setup() { - QList sources = APP->sourcelist().sources(); + QList sources = SourceList::instance()->sources(); foreach( const source_ptr& src, sources ) { // local src doesnt have a control connection, skip it: @@ -135,7 +135,7 @@ FileTransferConnection::setup() DatabaseCommand_LoadFile* cmd = new DatabaseCommand_LoadFile( m_fid ); connect( cmd, SIGNAL( result( Tomahawk::result_ptr ) ), SLOT( startSending( Tomahawk::result_ptr ) ) ); - TomahawkApp::instance()->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } @@ -152,7 +152,7 @@ FileTransferConnection::startSending( const Tomahawk::result_ptr& result ) m_result = result; qDebug() << "Starting to transmit" << m_result->url(); - QSharedPointer io = TomahawkApp::instance()->getIODeviceForUrl( m_result ); + QSharedPointer io = Servent::instance()->getIODeviceForUrl( m_result ); if( !io ) { qDebug() << "Couldn't read from source:" << m_result->url(); diff --git a/src/network/filetransferconnection.h b/src/libtomahawk/network/filetransferconnection.h similarity index 96% rename from src/network/filetransferconnection.h rename to src/libtomahawk/network/filetransferconnection.h index 1badf186d..467eb8d46 100644 --- a/src/network/filetransferconnection.h +++ b/src/libtomahawk/network/filetransferconnection.h @@ -5,8 +5,8 @@ #include #include -#include "connection.h" -#include "tomahawk/result.h" +#include "network/connection.h" +#include "result.h" class ControlConnection; class BufferIODevice; diff --git a/src/network/msg.h b/src/libtomahawk/network/msg.h similarity index 100% rename from src/network/msg.h rename to src/libtomahawk/network/msg.h diff --git a/src/network/msgprocessor.cpp b/src/libtomahawk/network/msgprocessor.cpp similarity index 90% rename from src/network/msgprocessor.cpp rename to src/libtomahawk/network/msgprocessor.cpp index f910b62a6..c84107a22 100644 --- a/src/network/msgprocessor.cpp +++ b/src/libtomahawk/network/msgprocessor.cpp @@ -1,14 +1,17 @@ #include "msgprocessor.h" -#include "tomahawk/tomahawkapp.h" + +#include "network/servent.h" + MsgProcessor::MsgProcessor( quint32 mode, quint32 t ) : QObject(), m_mode( mode ), m_threshold( t ), m_totmsgsize( 0 ) { - moveToThread( APP->servent().thread() ); + moveToThread( Servent::instance()->thread() ); } -void MsgProcessor::append( msg_ptr msg ) +void +MsgProcessor::append( msg_ptr msg ) { if( QThread::currentThread() != thread() ) { @@ -39,7 +42,8 @@ void MsgProcessor::append( msg_ptr msg ) } -void MsgProcessor::processed() +void +MsgProcessor::processed() { QFutureWatcher * watcher = (QFutureWatcher *) sender(); msg_ptr msg = watcher->result(); @@ -47,7 +51,9 @@ void MsgProcessor::processed() handleProcessedMsg( msg ); } -void MsgProcessor::handleProcessedMsg( msg_ptr msg ) + +void +MsgProcessor::handleProcessedMsg( msg_ptr msg ) { Q_ASSERT( QThread::currentThread() == thread() ); @@ -74,7 +80,8 @@ void MsgProcessor::handleProcessedMsg( msg_ptr msg ) /// This method is run by QtConcurrent: -msg_ptr MsgProcessor::process( msg_ptr msg, quint32 mode, quint32 threshold ) +msg_ptr +MsgProcessor::process( msg_ptr msg, quint32 mode, quint32 threshold ) { // uncompress if needed if( (mode & UNCOMPRESS_ALL) && msg->is( Msg::COMPRESSED ) ) @@ -109,5 +116,3 @@ msg_ptr MsgProcessor::process( msg_ptr msg, quint32 mode, quint32 threshold ) } return msg; } - - diff --git a/src/network/msgprocessor.h b/src/libtomahawk/network/msgprocessor.h similarity index 100% rename from src/network/msgprocessor.h rename to src/libtomahawk/network/msgprocessor.h diff --git a/src/network/remotecollection.cpp b/src/libtomahawk/network/remotecollection.cpp similarity index 100% rename from src/network/remotecollection.cpp rename to src/libtomahawk/network/remotecollection.cpp diff --git a/src/network/remotecollection.h b/src/libtomahawk/network/remotecollection.h similarity index 83% rename from src/network/remotecollection.h rename to src/libtomahawk/network/remotecollection.h index bde90af93..63124d618 100644 --- a/src/network/remotecollection.h +++ b/src/libtomahawk/network/remotecollection.h @@ -1,10 +1,10 @@ #ifndef REMOTECOLLECTION_H #define REMOTECOLLECTION_H -#include "tomahawk/typedefs.h" +#include "typedefs.h" -#include "controlconnection.h" -#include "databasecollection.h" +#include "network/controlconnection.h" +#include "database/databasecollection.h" class RemoteCollection : public DatabaseCollection { diff --git a/src/network/servent.cpp b/src/libtomahawk/network/servent.cpp similarity index 85% rename from src/network/servent.cpp rename to src/libtomahawk/network/servent.cpp index 59480e429..3c0967d34 100644 --- a/src/network/servent.cpp +++ b/src/libtomahawk/network/servent.cpp @@ -1,27 +1,64 @@ #include "servent.h" +#include #include #include +#include #include #include +#include +#include -#include "tomahawk/tomahawkapp.h" -#include "tomahawk/result.h" -#include "tomahawk/source.h" +#include "result.h" +#include "source.h" #include "bufferiodevice.h" #include "connection.h" #include "controlconnection.h" +#include "database/database.h" #include "filetransferconnection.h" +#include "sourcelist.h" + +#include "portfwd/portfwd.h" using namespace Tomahawk; +Servent* Servent::s_instance = 0; + + +Servent* +Servent::instance() +{ + return s_instance; +} + Servent::Servent( QObject* parent ) : QTcpServer( parent ) , m_port( 0 ) , m_externalPort( 0 ) + , pf( new Portfwd() ) { + s_instance = this; + qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) ); + + { + boost::function(result_ptr)> fac = + boost::bind( &Servent::localFileIODeviceFactory, this, _1 ); + this->registerIODeviceFactory( "file", fac ); + } + + { + boost::function(result_ptr)> fac = + boost::bind( &Servent::remoteIODeviceFactory, this, _1 ); + this->registerIODeviceFactory( "servent", fac ); + } + + { + boost::function(result_ptr)> fac = + boost::bind( &Servent::httpIODeviceFactory, this, _1 ); + this->registerIODeviceFactory( "http", fac ); + } } @@ -30,7 +67,7 @@ Servent::~Servent() if( m_externalPort ) { qDebug() << "Unregistering port fwd"; - pf.remove( m_externalPort ); + pf->remove( m_externalPort ); } } @@ -56,30 +93,30 @@ Servent::startListening( QHostAddress ha, bool upnp, int port ) if( upnp ) { // try and pick an available port: - if( pf.init( 2000 ) ) + if( pf->init( 2000 ) ) { int tryport = m_port; // last.fm office firewall policy hack // (corp. firewall allows outgoing connections to this port, // so listen on this if you want lastfmers to connect to you) - if( APP->arguments().contains("--porthack") ) + if( qApp->arguments().contains("--porthack") ) { tryport = 3389; - pf.remove( tryport ); + pf->remove( tryport ); } for( int r=0; r<5; ++r ) { qDebug() << "Trying to setup portfwd on" << tryport; - if( pf.add( tryport, m_port ) ) + if( pf->add( tryport, m_port ) ) { - QString pubip = QString( pf.external_ip().c_str() ); + QString pubip = QString( pf->external_ip().c_str() ); m_externalAddress = QHostAddress( pubip ); m_externalPort = tryport; qDebug() << "External servent address detected as" << pubip << ":" << m_externalPort; - qDebug() << "Max upstream " << pf.max_upstream_bps() << "bps"; - qDebug() << "Max downstream" << pf.max_downstream_bps() << "bps"; + qDebug() << "Max upstream " << pf->max_upstream_bps() << "bps"; + qDebug() << "Max downstream" << pf->max_downstream_bps() << "bps"; break; } tryport = 10000 + 50000 * (float)qrand()/RAND_MAX; @@ -98,7 +135,7 @@ Servent::startListening( QHostAddress ha, bool upnp, int port ) } // --lanhack means to advertise your LAN IP over jabber as if it were externallyVisible - if( TomahawkApp::instance()->arguments().contains( "--lanhack" ) ) + if( qApp->arguments().contains( "--lanhack" ) ) { QList ifs = QNetworkInterface::allAddresses(); foreach( QHostAddress ha, ifs ) @@ -327,7 +364,7 @@ Servent::createParallelConnection( Connection* orig_conn, Connection* new_conn, m.insert( "key", tmpkey ); m.insert( "offer", key ); m.insert( "port", externalPort() ); - m.insert( "controlid", APP->nodeID() ); + m.insert( "controlid", Database::instance()->dbid() ); QJson::Serializer ser; orig_conn->sendMsg( Msg::factory( ser.serialize(m), Msg::JSON ) ); @@ -404,7 +441,7 @@ Servent::connectToPeer( const QString& ha, int port, const QString &key, const Q m["conntype"] = "accept-offer"; m["key"] = key; m["port"] = externalPort(); - m["nodeid"] = APP->nodeID(); + m["nodeid"] = Database::instance()->dbid(); conn->setFirstMessage( m ); if( name.length() ) @@ -432,7 +469,7 @@ Servent::connectToPeer( const QString& ha, int port, const QString &key, Connect m["conntype"] = "accept-offer"; m["key"] = key; m["port"] = externalPort(); - m["controlid"] = APP->nodeID(); + m["controlid"] = Database::instance()->dbid(); conn->setFirstMessage( m ); } @@ -471,7 +508,7 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& key, m["conntype"] = "push-offer"; m["key"] = theirkey; m["port"] = externalPort(); - m["controlid"] = APP->nodeID(); + m["controlid"] = Database::instance()->dbid(); new_conn->setFirstMessage( m ); createParallelConnection( orig_conn, new_conn, QString() ); } @@ -572,7 +609,7 @@ Servent::remoteIODeviceFactory( const result_ptr& result ) QStringList parts = result->url().mid( QString( "servent://" ).length()).split( "\t" ); const QString& sourceName = parts.at( 0 ); const QString& fileId = parts.at( 1 ); - const source_ptr& s = TomahawkApp::instance()->sourcelist().get( sourceName ); + const source_ptr& s = SourceList::instance()->get( sourceName ); if ( s.isNull() ) return sp; @@ -668,7 +705,7 @@ Servent::triggerDBSync() qDebug() << Q_FUNC_INFO; // tell peers we have new stuff they should sync - QList sources = APP->sourcelist().sources(); + QList sources = SourceList::instance()->sources(); foreach( const source_ptr& src, sources ) { // local src doesnt have a control connection, skip it: @@ -678,3 +715,53 @@ Servent::triggerDBSync() src->controlConnection()->dbSyncConnection()->trigger(); } } + + +void +Servent::registerIODeviceFactory( const QString &proto, boost::function(Tomahawk::result_ptr)> fac ) +{ + m_iofactories.insert( proto, fac ); + qDebug() << "Registered IODevice Factory for" << proto; +} + + + +QSharedPointer +Servent::getIODeviceForUrl( const Tomahawk::result_ptr& result ) +{ + qDebug() << Q_FUNC_INFO << thread(); + QSharedPointer sp; + + QRegExp rx( "^([a-zA-Z0-9]+)://(.+)$" ); + if ( rx.indexIn( result->url() ) == -1 ) + return sp; + + const QString proto = rx.cap( 1 ); + //const QString urlpart = rx.cap( 2 ); + if ( !m_iofactories.contains( proto ) ) + return sp; + + return m_iofactories.value( proto )( result ); +} + + +QSharedPointer +Servent::localFileIODeviceFactory( const Tomahawk::result_ptr& result ) +{ + // ignore "file://" at front of url + QFile * io = new QFile( result->url().mid( QString( "file://" ).length() ) ); + if ( io ) + io->open( QIODevice::ReadOnly ); + + return QSharedPointer( io ); +} + + +QSharedPointer +Servent::httpIODeviceFactory( const Tomahawk::result_ptr& result ) +{ +/* qDebug() << Q_FUNC_INFO << result->url(); + QNetworkRequest req( result->url() ); + QNetworkReply* reply = APP->nam()->get( req ); + return QSharedPointer( reply );*/ +} diff --git a/src/network/servent.h b/src/libtomahawk/network/servent.h similarity index 83% rename from src/network/servent.h rename to src/libtomahawk/network/servent.h index 625ceb434..9082ce14a 100644 --- a/src/network/servent.h +++ b/src/libtomahawk/network/servent.h @@ -20,20 +20,24 @@ #include #include -#include "portfwd/portfwd.h" -#include "tomahawk/typedefs.h" +#include "typedefs.h" #include "msg.h" +#include + +#include "dllmacro.h" + class Connection; class Connector; class ControlConnection; class FileTransferConnection; class ProxyConnection; class RemoteCollectionConnection; +class Portfwd; // this is used to hold a bit of state, so when a connected signal is emitted // from a socket, we can associate it with a Connection object etc. -class QTcpSocketExtra : public QTcpSocket +class DLLEXPORT QTcpSocketExtra : public QTcpSocket { Q_OBJECT @@ -59,11 +63,13 @@ private slots: } }; -class Servent : public QTcpServer +class DLLEXPORT Servent : public QTcpServer { Q_OBJECT public: + static Servent* instance(); + explicit Servent( QObject* parent = 0 ); virtual ~Servent(); @@ -97,6 +103,11 @@ public: QList< FileTransferConnection* > fileTransfers() const { return m_ftsessions; } + QSharedPointer getIODeviceForUrl( const Tomahawk::result_ptr& result ); + void registerIODeviceFactory( const QString &proto, boost::function(Tomahawk::result_ptr)> fac ); + QSharedPointer localFileIODeviceFactory( const Tomahawk::result_ptr& result ); + QSharedPointer httpIODeviceFactory( const Tomahawk::result_ptr& result ); + signals: void fileTransferStarted( FileTransferConnection* ); void fileTransferFinished( FileTransferConnection* ); @@ -134,7 +145,10 @@ private: QList< FileTransferConnection* > m_ftsessions; QMutex m_ftsession_mut; - Portfwd pf; + Portfwd* pf; + QMap< QString,boost::function(Tomahawk::result_ptr)> > m_iofactories; + + static Servent* s_instance; }; #endif // SERVENT_H diff --git a/src/pipeline.cpp b/src/libtomahawk/pipeline.cpp similarity index 93% rename from src/pipeline.cpp rename to src/libtomahawk/pipeline.cpp index b5a294221..92951bf19 100644 --- a/src/pipeline.cpp +++ b/src/libtomahawk/pipeline.cpp @@ -1,28 +1,36 @@ -#include "tomahawk/pipeline.h" +#include "pipeline.h" #include #include -#include "tomahawk/functimeout.h" -#include "tomahawk/tomahawkapp.h" +#include "functimeout.h" #include "database/database.h" using namespace Tomahawk; +Pipeline* Pipeline::s_instance = 0; + + +Pipeline* +Pipeline::instance() +{ + return s_instance; +} + Pipeline::Pipeline( QObject* parent ) : QObject( parent ) , m_index_ready( false ) { - + s_instance = this; } void Pipeline::databaseReady() { - connect( APP->database(), SIGNAL(indexReady()), this, SLOT(indexReady()), Qt::QueuedConnection ); - APP->database()->loadIndex(); + connect( Database::instance(), SIGNAL(indexReady()), this, SLOT(indexReady()), Qt::QueuedConnection ); + Database::instance()->loadIndex(); } diff --git a/include/tomahawk/pipeline.h b/src/libtomahawk/pipeline.h similarity index 85% rename from include/tomahawk/pipeline.h rename to src/libtomahawk/pipeline.h index 17dce1895..e62cad4f9 100644 --- a/include/tomahawk/pipeline.h +++ b/src/libtomahawk/pipeline.h @@ -6,21 +6,25 @@ #include #include -#include "tomahawk/typedefs.h" -#include "tomahawk/query.h" -#include "tomahawk/result.h" -#include "tomahawk/resolver.h" +#include "typedefs.h" +#include "query.h" +#include "result.h" +#include "resolver.h" + +#include "dllmacro.h" namespace Tomahawk { class Resolver; -class Pipeline : public QObject +class DLLEXPORT Pipeline : public QObject { Q_OBJECT public: + static Pipeline* instance(); + explicit Pipeline( QObject* parent = 0 ); // const query_ptr& query( QID qid ) const; @@ -63,6 +67,8 @@ private: // store queries here until DB index is loaded, then shunt them all QList< query_ptr > m_queries_pending; bool m_index_ready; + + static Pipeline* s_instance; }; }; //ns diff --git a/src/playlist.cpp b/src/libtomahawk/playlist.cpp similarity index 92% rename from src/playlist.cpp rename to src/libtomahawk/playlist.cpp index 824e34c48..00fe3ba5b 100644 --- a/src/playlist.cpp +++ b/src/libtomahawk/playlist.cpp @@ -1,15 +1,17 @@ -#include "tomahawk/playlist.h" +#include "playlist.h" #include #include -#include "tomahawk/tomahawkapp.h" -#include "database.h" -#include "databasecommand_loadplaylistentries.h" -#include "databasecommand_setplaylistrevision.h" -#include "databasecommand_createplaylist.h" -#include "databasecommand_deleteplaylist.h" -#include "databasecommand_renameplaylist.h" +#include "database/database.h" +#include "database/databasecommand_loadplaylistentries.h" +#include "database/databasecommand_setplaylistrevision.h" +#include "database/databasecommand_createplaylist.h" +#include "database/databasecommand_deleteplaylist.h" +#include "database/databasecommand_renameplaylist.h" + +#include "pipeline.h" +#include "sourcelist.h" using namespace Tomahawk; @@ -93,7 +95,7 @@ Playlist::create( const source_ptr& author, DatabaseCommand_CreatePlaylist* cmd = new DatabaseCommand_CreatePlaylist( author, playlist ); connect( cmd, SIGNAL(finished()), playlist.data(), SIGNAL(created()) ); - APP->database()->enqueue( QSharedPointer(cmd) ); + Database::instance()->enqueue( QSharedPointer(cmd) ); playlist->reportCreated( playlist ); return playlist; } @@ -103,7 +105,7 @@ bool Playlist::remove( const playlist_ptr& playlist ) { DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeletePlaylist( playlist->author(), playlist->guid() ); - APP->database()->enqueue( QSharedPointer(cmd) ); + Database::instance()->enqueue( QSharedPointer(cmd) ); return true; // FIXME } @@ -113,7 +115,7 @@ bool Playlist::rename( const QString& title ) { DatabaseCommand_RenamePlaylist* cmd = new DatabaseCommand_RenamePlaylist( author(), guid(), title ); - APP->database()->enqueue( QSharedPointer(cmd) ); + Database::instance()->enqueue( QSharedPointer(cmd) ); return true; // FIXME } @@ -159,7 +161,7 @@ Playlist::loadRevision( const QString& rev ) const QMap< QString, Tomahawk::plentry_ptr >&, bool ) ) ); - APP->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } @@ -185,7 +187,7 @@ Playlist::createNewRevision( const QString& newrev, const QString& oldrev, const } // source making the change (localy user in this case) - source_ptr author = APP->sourcelist().getLocal(); + source_ptr author = SourceList::instance()->getLocal(); // command writes new rev to DB and calls setRevision, which emits our signal DatabaseCommand_SetPlaylistRevision* cmd = new DatabaseCommand_SetPlaylistRevision( author, @@ -194,7 +196,7 @@ Playlist::createNewRevision( const QString& newrev, const QString& oldrev, const oldrev, orderedguids, added ); - APP->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } @@ -321,7 +323,7 @@ void Playlist::resolve() { qlist << p->query(); } - APP->pipeline()->add( qlist ); + Pipeline::instance()->add( qlist ); } diff --git a/include/tomahawk/playlist.h b/src/libtomahawk/playlist.h similarity index 97% rename from include/tomahawk/playlist.h rename to src/libtomahawk/playlist.h index 92ae6d280..a1afff28c 100644 --- a/include/tomahawk/playlist.h +++ b/src/libtomahawk/playlist.h @@ -5,8 +5,10 @@ #include #include -#include "tomahawk/query.h" -#include "tomahawk/typedefs.h" +#include "query.h" +#include "typedefs.h" + +#include "dllmacro.h" class DatabaseCommand_LoadAllPlaylists; class DatabaseCommand_SetPlaylistRevision; @@ -15,7 +17,7 @@ class DatabaseCommand_CreatePlaylist; namespace Tomahawk { -class PlaylistEntry : public QObject +class DLLEXPORT PlaylistEntry : public QObject { Q_OBJECT Q_PROPERTY( QString guid READ guid WRITE setGuid ) @@ -73,7 +75,7 @@ struct PlaylistRevision }; -class Playlist : public QObject +class DLLEXPORT Playlist : public QObject { Q_OBJECT Q_PROPERTY( QString guid READ guid WRITE setGuid ) diff --git a/include/tomahawk/playlistinterface.h b/src/libtomahawk/playlistinterface.h similarity index 94% rename from include/tomahawk/playlistinterface.h rename to src/libtomahawk/playlistinterface.h index 0e6d053c6..1c220bdc9 100644 --- a/include/tomahawk/playlistinterface.h +++ b/src/libtomahawk/playlistinterface.h @@ -4,9 +4,11 @@ #include #include -#include "tomahawk/typedefs.h" +#include "typedefs.h" -class PlaylistInterface +#include "dllmacro.h" + +class DLLEXPORT PlaylistInterface { public: enum RepeatMode { NoRepeat, RepeatOne, RepeatAll }; diff --git a/src/pluginapi.cpp b/src/libtomahawk/pluginapi.cpp similarity index 70% rename from src/pluginapi.cpp rename to src/libtomahawk/pluginapi.cpp index 0649c6fb4..850d693df 100644 --- a/src/pluginapi.cpp +++ b/src/libtomahawk/pluginapi.cpp @@ -1,8 +1,11 @@ -#include "tomahawk/pluginapi.h" -#include "tomahawk/tomahawkapp.h" +#include "pluginapi.h" + +#include "pipeline.h" +#include "sourcelist.h" using namespace Tomahawk; + PluginAPI::PluginAPI( Pipeline* p ) : m_pipeline( p ) { @@ -25,19 +28,19 @@ PluginAPI::reportResults( const QString& qid, const QList& vresults void PluginAPI::addSource( source_ptr s ) { - TomahawkApp::instance()->sourcelist().add( s ); + SourceList::instance()->add( s ); } void PluginAPI::removeSource( source_ptr s ) { - TomahawkApp::instance()->sourcelist().remove( s ); + SourceList::instance()->remove( s ); } void PluginAPI::addResolver( Resolver* r ) { - TomahawkApp::instance()->pipeline()->addResolver( r ); + Pipeline::instance()->addResolver( r ); } diff --git a/include/tomahawk/pluginapi.h b/src/libtomahawk/pluginapi.h similarity index 89% rename from include/tomahawk/pluginapi.h rename to src/libtomahawk/pluginapi.h index 3f6ab07fa..b824a3204 100644 --- a/include/tomahawk/pluginapi.h +++ b/src/libtomahawk/pluginapi.h @@ -4,8 +4,10 @@ #include #include -#include "tomahawk/collection.h" -#include "tomahawk/source.h" +#include "collection.h" +#include "source.h" + +#include "dllmacro.h" /* This is the only API plugins have access to. @@ -18,7 +20,7 @@ namespace Tomahawk class Resolver; class Pipeline; -class PluginAPI : public QObject +class DLLEXPORT PluginAPI : public QObject { Q_OBJECT diff --git a/src/query.cpp b/src/libtomahawk/query.cpp similarity index 98% rename from src/query.cpp rename to src/libtomahawk/query.cpp index b5de0088e..611757985 100644 --- a/src/query.cpp +++ b/src/libtomahawk/query.cpp @@ -1,4 +1,4 @@ -#include "tomahawk/query.h" +#include "query.h" #include diff --git a/include/tomahawk/query.h b/src/libtomahawk/query.h similarity index 93% rename from include/tomahawk/query.h rename to src/libtomahawk/query.h index 3ce6064eb..2270396f7 100644 --- a/include/tomahawk/query.h +++ b/src/libtomahawk/query.h @@ -6,14 +6,16 @@ #include #include -#include "tomahawk/collection.h" -#include "tomahawk/result.h" -#include "tomahawk/typedefs.h" +#include "collection.h" +#include "result.h" +#include "typedefs.h" + +#include "dllmacro.h" namespace Tomahawk { -class Query : public QObject +class DLLEXPORT Query : public QObject { Q_OBJECT diff --git a/include/tomahawk/resolver.h b/src/libtomahawk/resolver.h similarity index 89% rename from include/tomahawk/resolver.h rename to src/libtomahawk/resolver.h index 16e55bda2..da898d6b2 100644 --- a/include/tomahawk/resolver.h +++ b/src/libtomahawk/resolver.h @@ -3,7 +3,9 @@ #include -#include "tomahawk/pluginapi.h" +#include "pluginapi.h" + +#include "dllmacro.h" // implement this if you can resolve queries to content @@ -17,7 +19,7 @@ namespace Tomahawk { class PluginAPI; -class Resolver : public QObject +class DLLEXPORT Resolver : public QObject { Q_OBJECT diff --git a/src/result.cpp b/src/libtomahawk/result.cpp similarity index 96% rename from src/result.cpp rename to src/libtomahawk/result.cpp index 1f483f63d..ea875f66b 100644 --- a/src/result.cpp +++ b/src/libtomahawk/result.cpp @@ -1,6 +1,6 @@ -#include "tomahawk/result.h" +#include "result.h" -#include "tomahawk/album.h" +#include "album.h" using namespace Tomahawk; diff --git a/include/tomahawk/result.h b/src/libtomahawk/result.h similarity index 95% rename from include/tomahawk/result.h rename to src/libtomahawk/result.h index 193c799e4..ed6299c59 100644 --- a/include/tomahawk/result.h +++ b/src/libtomahawk/result.h @@ -3,15 +3,17 @@ #include -#include "tomahawk/typedefs.h" +#include "typedefs.h" #include "collection.h" #include "artist.h" #include "album.h" +#include "dllmacro.h" + namespace Tomahawk { -class Result : public QObject +class DLLEXPORT Result : public QObject { Q_OBJECT diff --git a/src/sip/SipPlugin.cpp b/src/libtomahawk/sip/SipPlugin.cpp similarity index 100% rename from src/sip/SipPlugin.cpp rename to src/libtomahawk/sip/SipPlugin.cpp diff --git a/src/sip/SipPlugin.h b/src/libtomahawk/sip/SipPlugin.h similarity index 92% rename from src/sip/SipPlugin.h rename to src/libtomahawk/sip/SipPlugin.h index 5f0c12674..b0d046740 100644 --- a/src/sip/SipPlugin.h +++ b/src/libtomahawk/sip/SipPlugin.h @@ -4,7 +4,9 @@ #include #include -class SipPlugin : public QObject +#include "dllmacro.h" + +class DLLEXPORT SipPlugin : public QObject { Q_OBJECT diff --git a/src/source.cpp b/src/libtomahawk/source.cpp similarity index 82% rename from src/source.cpp rename to src/libtomahawk/source.cpp index 5900858f7..aee81816e 100644 --- a/src/source.cpp +++ b/src/libtomahawk/source.cpp @@ -1,12 +1,12 @@ -#include "tomahawk/source.h" +#include "source.h" -#include "tomahawk/tomahawkapp.h" -#include "tomahawk/collection.h" +#include "collection.h" +#include "sourcelist.h" -#include "controlconnection.h" -#include "databasecommand_addsource.h" -#include "databasecommand_sourceoffline.h" -#include "database.h" +#include "network/controlconnection.h" +#include "database/databasecommand_addsource.h" +#include "database/databasecommand_sourceoffline.h" +#include "database/database.h" using namespace Tomahawk; @@ -44,7 +44,7 @@ Source::~Source() return; // TODO mark source as offline in database DatabaseCommand_SourceOffline* cmd = new DatabaseCommand_SourceOffline( id() ); - APP->database()->enqueue( QSharedPointer(cmd) ); + Database::instance()->enqueue( QSharedPointer(cmd) ); } @@ -63,10 +63,10 @@ void Source::doDBSync() { // ensure username is in the database - DatabaseCommand_addSource * cmd = new DatabaseCommand_addSource( m_username, m_friendlyname ); + DatabaseCommand_addSource* cmd = new DatabaseCommand_addSource( m_username, m_friendlyname ); connect( cmd, SIGNAL( done( unsigned int, QString ) ), SLOT( dbLoaded( unsigned int, const QString& ) ) ); - APP->database()->enqueue( QSharedPointer(cmd) ); + Database::instance()->enqueue( QSharedPointer(cmd) ); } @@ -85,7 +85,7 @@ Source::remove() m_cc = 0; emit offline(); - APP->sourcelist().remove( this ); + SourceList::instance()->remove( this ); m_collections.clear(); } diff --git a/include/tomahawk/source.h b/src/libtomahawk/source.h similarity index 95% rename from include/tomahawk/source.h rename to src/libtomahawk/source.h index baf1af09e..58adb6071 100644 --- a/include/tomahawk/source.h +++ b/src/libtomahawk/source.h @@ -5,17 +5,19 @@ #include #include -#include "dbsyncconnection.h" +#include "network/dbsyncconnection.h" #include "collection.h" #include "typedefs.h" +#include "dllmacro.h" + class ControlConnection; class FileTransferConnection; namespace Tomahawk { -class Source : public QObject +class DLLEXPORT Source : public QObject { Q_OBJECT diff --git a/src/sourcelist.cpp b/src/libtomahawk/sourcelist.cpp similarity index 90% rename from src/sourcelist.cpp rename to src/libtomahawk/sourcelist.cpp index 631028ad6..7d2dc94ee 100644 --- a/src/sourcelist.cpp +++ b/src/libtomahawk/sourcelist.cpp @@ -1,9 +1,23 @@ -#include "tomahawk/sourcelist.h" +#include "sourcelist.h" #include using namespace Tomahawk; +SourceList* SourceList::s_instance = 0; + + +SourceList* +SourceList::instance() +{ + if ( !s_instance ) + { + s_instance = new SourceList(); + } + + return s_instance; +} + SourceList::SourceList( QObject* parent ) : QObject( parent ) { diff --git a/include/tomahawk/sourcelist.h b/src/libtomahawk/sourcelist.h similarity index 83% rename from include/tomahawk/sourcelist.h rename to src/libtomahawk/sourcelist.h index 4998ff350..ad31b2c92 100644 --- a/include/tomahawk/sourcelist.h +++ b/src/libtomahawk/sourcelist.h @@ -5,14 +5,18 @@ #include #include -#include "tomahawk/source.h" -#include "tomahawk/typedefs.h" +#include "source.h" +#include "typedefs.h" -class SourceList : public QObject +#include "dllmacro.h" + +class DLLEXPORT SourceList : public QObject { Q_OBJECT public: + static SourceList* instance(); + explicit SourceList( QObject* parent = 0 ); const Tomahawk::source_ptr& getLocal(); @@ -36,6 +40,8 @@ private: Tomahawk::source_ptr m_local; mutable QMutex m_mut; // mutable so const methods can use a lock + + static SourceList* s_instance; }; #endif // SOURCELIST_H diff --git a/src/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp similarity index 97% rename from src/tomahawksettings.cpp rename to src/libtomahawk/tomahawksettings.cpp index 44c1aa029..862f2f2e4 100644 --- a/src/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -1,4 +1,3 @@ -#include "tomahawk/tomahawkapp.h" #include "tomahawksettings.h" #ifndef TOMAHAWK_HEADLESS @@ -9,10 +8,21 @@ #include #include +TomahawkSettings* TomahawkSettings::s_instance = 0; + + +TomahawkSettings* +TomahawkSettings::instance() +{ + return s_instance; +} + TomahawkSettings::TomahawkSettings( QObject* parent ) : QSettings( parent ) { + s_instance = this; + #ifndef TOMAHAWK_HEADLESS if( !contains( "configversion") ) { @@ -33,6 +43,7 @@ TomahawkSettings::TomahawkSettings( QObject* parent ) TomahawkSettings::~TomahawkSettings() { + s_instance = 0; } diff --git a/src/tomahawksettings.h b/src/libtomahawk/tomahawksettings.h similarity index 92% rename from src/tomahawksettings.h rename to src/libtomahawk/tomahawksettings.h index 450c2884c..9bd8ea710 100644 --- a/src/tomahawksettings.h +++ b/src/libtomahawk/tomahawksettings.h @@ -3,14 +3,18 @@ #include +#include "dllmacro.h" + /** * Convenience wrapper around QSettings for tomahawk-specific config */ -class TomahawkSettings : public QSettings +class DLLEXPORT TomahawkSettings : public QSettings { Q_OBJECT public: - explicit TomahawkSettings(QObject* parent = 0); + static TomahawkSettings* instance(); + + explicit TomahawkSettings( QObject* parent = 0 ); virtual ~TomahawkSettings(); /// General settings @@ -91,6 +95,9 @@ public: int xmppBotPort() const; void setXmppBotPort( const int port ); + +private: + static TomahawkSettings* s_instance; }; #endif diff --git a/include/tomahawk/track.h b/src/libtomahawk/track.h similarity index 81% rename from include/tomahawk/track.h rename to src/libtomahawk/track.h index f5967619c..55ce10404 100644 --- a/include/tomahawk/track.h +++ b/src/libtomahawk/track.h @@ -4,13 +4,15 @@ #include #include -#include "tomahawk/artist.h" -#include "tomahawk/typedefs.h" +#include "artist.h" +#include "typedefs.h" + +#include "dllmacro.h" namespace Tomahawk { -class Track : public QObject +class DLLEXPORT Track : public QObject { Q_OBJECT diff --git a/include/tomahawk/typedefs.h b/src/libtomahawk/typedefs.h similarity index 100% rename from include/tomahawk/typedefs.h rename to src/libtomahawk/typedefs.h diff --git a/src/musicscanner.cpp b/src/musicscanner.cpp index da5e302c1..3652059bf 100644 --- a/src/musicscanner.cpp +++ b/src/musicscanner.cpp @@ -1,9 +1,10 @@ #include "musicscanner.h" #include "tomahawk/tomahawkapp.h" -#include "database.h" -#include "databasecommand_dirmtimes.h" -#include "databasecommand_addfiles.h" +#include "sourcelist.h" +#include "database/database.h" +#include "database/databasecommand_dirmtimes.h" +#include "database/databasecommand_addfiles.h" using namespace Tomahawk; @@ -53,7 +54,7 @@ MusicScanner::startScan() connect( cmd, SIGNAL( done( const QMap& ) ), SLOT( scan() ), Qt::DirectConnection ); - TomahawkApp::instance()->database()->enqueue( QSharedPointer(cmd) ); + Database::instance()->enqueue( QSharedPointer(cmd) ); } @@ -67,7 +68,7 @@ MusicScanner::setMtimes( const QMap& m ) void MusicScanner::scan() { - TomahawkApp::instance()->sourcelist().getLocal()->scanningProgress( 0 ); + SourceList::instance()->getLocal()->scanningProgress( 0 ); qDebug() << "Scanning, num saved mtimes from last scan:" << m_dirmtimes.size(); connect( this, SIGNAL( batchReady( QVariantList ) ), @@ -95,14 +96,14 @@ MusicScanner::listerFinished( const QMap& newmtimes ) // any remaining stuff that wasnt emitted as a batch: if( m_scannedfiles.length() ) { - TomahawkApp::instance()->sourcelist().getLocal()->scanningProgress( m_scanned ); + SourceList::instance()->getLocal()->scanningProgress( m_scanned ); commitBatch( m_scannedfiles ); } // save mtimes, then quit thread DatabaseCommand_DirMtimes* cmd = new DatabaseCommand_DirMtimes( newmtimes ); connect( cmd, SIGNAL( finished() ), SLOT( quit() ) ); - TomahawkApp::instance()->database()->enqueue( QSharedPointer(cmd) ); + Database::instance()->enqueue( QSharedPointer(cmd) ); qDebug() << "Scanning complete, saving to database. " "(scanned" << m_scanned << "skipped" << m_skipped << ")"; @@ -119,8 +120,8 @@ MusicScanner::commitBatch( const QVariantList& tracks ) if ( tracks.length() ) { qDebug() << Q_FUNC_INFO << tracks.length(); - source_ptr localsrc = TomahawkApp::instance()->sourcelist().getLocal(); - TomahawkApp::instance()->database()->enqueue( + source_ptr localsrc = SourceList::instance()->getLocal(); + Database::instance()->enqueue( QSharedPointer( new DatabaseCommand_AddFiles( tracks, localsrc ) ) ); } @@ -155,7 +156,7 @@ MusicScanner::readFile( const QFileInfo& fi ) } if( m_scanned % 3 == 0 ) - TomahawkApp::instance()->sourcelist().getLocal()->scanningProgress( m_scanned ); + SourceList::instance()->getLocal()->scanningProgress( m_scanned ); if( m_scanned % 100 == 0 ) qDebug() << "SCAN" << m_scanned << fi.absoluteFilePath(); diff --git a/src/playlist/albumitem.h b/src/playlist/albumitem.h index 15866dd88..028f018a1 100644 --- a/src/playlist/albumitem.h +++ b/src/playlist/albumitem.h @@ -6,7 +6,7 @@ #include #include -#include "tomahawk/album.h" +#include "album.h" class AlbumItem : public QObject { diff --git a/src/playlist/albumitemdelegate.cpp b/src/playlist/albumitemdelegate.cpp index f4941fff5..508a4256f 100644 --- a/src/playlist/albumitemdelegate.cpp +++ b/src/playlist/albumitemdelegate.cpp @@ -4,8 +4,8 @@ #include #include -#include "tomahawk/query.h" -#include "tomahawk/result.h" +#include "query.h" +#include "result.h" #include "tomahawk/tomahawkapp.h" #include "playlist/albumitem.h" diff --git a/src/playlist/albummodel.cpp b/src/playlist/albummodel.cpp index 4ef709f69..b791c79c9 100644 --- a/src/playlist/albummodel.cpp +++ b/src/playlist/albummodel.cpp @@ -6,7 +6,7 @@ #include #include "tomahawk/tomahawkapp.h" -#include "database.h" +#include "database/database.h" #define LASTFM_DEFAULT_COVER "http://cdn.last.fm/flatness/catalogue/noimage" @@ -223,7 +223,7 @@ AlbumModel::addCollection( const collection_ptr& collection ) connect( cmd, SIGNAL( albums( QList, Tomahawk::collection_ptr ) ), SLOT( onAlbumsAdded( QList, Tomahawk::collection_ptr ) ) ); - TomahawkApp::instance()->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } @@ -243,7 +243,7 @@ AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned in connect( cmd, SIGNAL( albums( QList, Tomahawk::collection_ptr ) ), SLOT( onAlbumsAdded( QList, Tomahawk::collection_ptr ) ) ); - TomahawkApp::instance()->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } diff --git a/src/playlist/albummodel.h b/src/playlist/albummodel.h index 63cc70da8..46f8ce29f 100644 --- a/src/playlist/albummodel.h +++ b/src/playlist/albummodel.h @@ -4,9 +4,9 @@ #include #include -#include "tomahawk/album.h" -#include "tomahawk/collection.h" -#include "tomahawk/playlistinterface.h" +#include "album.h" +#include "collection.h" +#include "playlistinterface.h" #include "database/databasecommand_allalbums.h" #include "albumitem.h" diff --git a/src/playlist/albumproxymodel.cpp b/src/playlist/albumproxymodel.cpp index f880a01a8..36c470fe7 100644 --- a/src/playlist/albumproxymodel.cpp +++ b/src/playlist/albumproxymodel.cpp @@ -3,7 +3,7 @@ #include #include -#include "tomahawk/query.h" +#include "query.h" #include "collectionmodel.h" diff --git a/src/playlist/albumproxymodel.h b/src/playlist/albumproxymodel.h index 598dbaa08..f259f79f2 100644 --- a/src/playlist/albumproxymodel.h +++ b/src/playlist/albumproxymodel.h @@ -3,7 +3,7 @@ #include -#include "tomahawk/playlistinterface.h" +#include "playlistinterface.h" #include "playlist/albummodel.h" class AlbumProxyModel : public QSortFilterProxyModel, public PlaylistInterface diff --git a/src/playlist/collectionflatmodel.cpp b/src/playlist/collectionflatmodel.cpp index dfdd2f4d7..167398d6e 100644 --- a/src/playlist/collectionflatmodel.cpp +++ b/src/playlist/collectionflatmodel.cpp @@ -4,7 +4,8 @@ #include #include -#include "database.h" +#include "database/database.h" +#include "sourcelist.h" using namespace Tomahawk; @@ -14,7 +15,7 @@ CollectionFlatModel::CollectionFlatModel( QObject* parent ) { qDebug() << Q_FUNC_INFO; - connect( &APP->sourcelist(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceOffline( Tomahawk::source_ptr ) ) ); + connect( SourceList::instance(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceOffline( Tomahawk::source_ptr ) ) ); } @@ -80,7 +81,7 @@ CollectionFlatModel::addFilteredCollection( const collection_ptr& collection, un connect( cmd, SIGNAL( tracks( QList, Tomahawk::collection_ptr ) ), SLOT( onTracksAdded( QList, Tomahawk::collection_ptr ) ), Qt::QueuedConnection ); - TomahawkApp::instance()->database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } diff --git a/src/playlist/collectionflatmodel.h b/src/playlist/collectionflatmodel.h index 56cc6c1a1..25cb62f23 100644 --- a/src/playlist/collectionflatmodel.h +++ b/src/playlist/collectionflatmodel.h @@ -7,14 +7,13 @@ #include "plitem.h" #include "trackmodel.h" -#include "tomahawk/tomahawkapp.h" -#include "tomahawk/collection.h" -#include "tomahawk/query.h" -#include "tomahawk/typedefs.h" -#include "tomahawk/playlist.h" -#include "tomahawk/playlistinterface.h" +#include "collection.h" +#include "query.h" +#include "typedefs.h" +#include "playlist.h" +#include "playlistinterface.h" -#include "databasecommand_alltracks.h" +#include "database/databasecommand_alltracks.h" class QMetaData; diff --git a/src/playlist/collectionmodel.cpp b/src/playlist/collectionmodel.cpp index d127bba9c..d951b4aed 100644 --- a/src/playlist/collectionmodel.cpp +++ b/src/playlist/collectionmodel.cpp @@ -4,6 +4,9 @@ #include #include +#include "sourcelist.h" +#include "utils/tomahawkutils.h" + using namespace Tomahawk; @@ -13,7 +16,7 @@ CollectionModel::CollectionModel( QObject* parent ) { qDebug() << Q_FUNC_INFO; - connect( &APP->sourcelist(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceOffline( Tomahawk::source_ptr ) ) ); + connect( SourceList::instance(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceOffline( Tomahawk::source_ptr ) ) ); } diff --git a/src/playlist/collectionmodel.h b/src/playlist/collectionmodel.h index 6dcef3249..4eb918d3a 100644 --- a/src/playlist/collectionmodel.h +++ b/src/playlist/collectionmodel.h @@ -6,12 +6,11 @@ #include #include "plitem.h" -#include "tomahawk/tomahawkapp.h" -#include "tomahawk/collection.h" -#include "tomahawk/query.h" -#include "tomahawk/typedefs.h" -#include "tomahawk/playlist.h" -#include "tomahawk/playlistinterface.h" +#include "collection.h" +#include "query.h" +#include "typedefs.h" +#include "playlist.h" +#include "playlistinterface.h" class QMetaData; diff --git a/src/playlist/collectionproxymodel.cpp b/src/playlist/collectionproxymodel.cpp index e0be4b0fc..b477d2d17 100644 --- a/src/playlist/collectionproxymodel.cpp +++ b/src/playlist/collectionproxymodel.cpp @@ -3,8 +3,8 @@ #include #include -#include "tomahawk/album.h" -#include "tomahawk/query.h" +#include "album.h" +#include "query.h" #include "collectionmodel.h" diff --git a/src/playlist/playlistitemdelegate.cpp b/src/playlist/playlistitemdelegate.cpp index 10a536ccc..bb7583168 100644 --- a/src/playlist/playlistitemdelegate.cpp +++ b/src/playlist/playlistitemdelegate.cpp @@ -4,8 +4,8 @@ #include #include -#include "tomahawk/query.h" -#include "tomahawk/result.h" +#include "query.h" +#include "result.h" #include "tomahawk/tomahawkapp.h" #include "playlist/plitem.h" diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index 74bcd0363..555bbc01d 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -16,6 +16,7 @@ #include "albumview.h" #include "albumproxymodel.h" #include "albummodel.h" +#include "sourcelist.h" #include "infowidgets/sourceinfowidget.h" @@ -113,7 +114,7 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist ) m_modesAvailable = false; linkPlaylist(); - emit numSourcesChanged( APP->sourcelist().count() ); + emit numSourcesChanged( SourceList::instance()->count() ); return true; } @@ -250,7 +251,7 @@ PlaylistManager::show( const Tomahawk::source_ptr& source ) bool PlaylistManager::showSuperCollection() { - foreach( const Tomahawk::source_ptr& source, APP->sourcelist().sources() ) + foreach( const Tomahawk::source_ptr& source, SourceList::instance()->sources() ) { if ( !m_superCollections.contains( source->collection() ) ) { diff --git a/src/playlist/playlistmanager.h b/src/playlist/playlistmanager.h index 278551e6e..cfeaf52f4 100644 --- a/src/playlist/playlistmanager.h +++ b/src/playlist/playlistmanager.h @@ -5,8 +5,8 @@ #include #include -#include "tomahawk/collection.h" -#include "tomahawk/playlistinterface.h" +#include "collection.h" +#include "playlistinterface.h" class AnimatedSplitter; class AlbumModel; diff --git a/src/playlist/playlistmodel.cpp b/src/playlist/playlistmodel.cpp index a24769e61..256c88caf 100644 --- a/src/playlist/playlistmodel.cpp +++ b/src/playlist/playlistmodel.cpp @@ -4,7 +4,7 @@ #include #include -#include "tomahawk/album.h" +#include "album.h" using namespace Tomahawk; diff --git a/src/playlist/playlistmodel.h b/src/playlist/playlistmodel.h index ee7938b37..5fce18b96 100644 --- a/src/playlist/playlistmodel.h +++ b/src/playlist/playlistmodel.h @@ -7,11 +7,11 @@ #include "plitem.h" #include "trackmodel.h" #include "tomahawk/tomahawkapp.h" -#include "tomahawk/collection.h" -#include "tomahawk/query.h" -#include "tomahawk/typedefs.h" -#include "tomahawk/playlist.h" -#include "tomahawk/playlistinterface.h" +#include "collection.h" +#include "query.h" +#include "typedefs.h" +#include "playlist.h" +#include "playlistinterface.h" class QMetaData; diff --git a/src/playlist/plitem.h b/src/playlist/plitem.h index ca2372f26..4ffcd6076 100644 --- a/src/playlist/plitem.h +++ b/src/playlist/plitem.h @@ -5,9 +5,8 @@ #include #include -#include "tomahawk/query.h" - -#include "tomahawk/typedefs.h" +#include "query.h" +#include "typedefs.h" class PlItem : public QObject { diff --git a/src/playlist/trackheader.cpp b/src/playlist/trackheader.cpp index 64ba237ba..ae30f5b9c 100644 --- a/src/playlist/trackheader.cpp +++ b/src/playlist/trackheader.cpp @@ -83,8 +83,7 @@ TrackHeader::onResized() void TrackHeader::restoreColumnsState() { - TomahawkSettings* s = APP->settings(); - QList list = s->playlistColumnSizes(); + QList list = TomahawkSettings::instance()->playlistColumnSizes(); if ( list.count() != count() ) // FIXME: const { @@ -101,13 +100,12 @@ TrackHeader::restoreColumnsState() void TrackHeader::saveColumnsState() { - TomahawkSettings *s = APP->settings(); QList wlist; foreach( double w, m_columnWeights ) wlist << QVariant( w ); - s->setPlaylistColumnSizes( wlist ); + TomahawkSettings::instance()->setPlaylistColumnSizes( wlist ); } diff --git a/src/playlist/trackmodel.cpp b/src/playlist/trackmodel.cpp index 25bcd2fc4..d4e348d9f 100644 --- a/src/playlist/trackmodel.cpp +++ b/src/playlist/trackmodel.cpp @@ -5,7 +5,7 @@ #include #include "tomahawk/tomahawkapp.h" -#include "tomahawk/album.h" +#include "album.h" using namespace Tomahawk; diff --git a/src/playlist/trackmodel.h b/src/playlist/trackmodel.h index 054346731..7bb11f93a 100644 --- a/src/playlist/trackmodel.h +++ b/src/playlist/trackmodel.h @@ -3,7 +3,7 @@ #include -#include "tomahawk/playlistinterface.h" +#include "playlistinterface.h" #include "playlist/plitem.h" class QMetaData; diff --git a/src/playlist/trackproxymodel.cpp b/src/playlist/trackproxymodel.cpp index 45bafa59c..c6a6536ad 100644 --- a/src/playlist/trackproxymodel.cpp +++ b/src/playlist/trackproxymodel.cpp @@ -3,8 +3,8 @@ #include #include -#include "tomahawk/album.h" -#include "tomahawk/query.h" +#include "album.h" +#include "query.h" #include "collectionmodel.h" diff --git a/src/playlist/trackproxymodel.h b/src/playlist/trackproxymodel.h index cb48287a5..88552dd27 100644 --- a/src/playlist/trackproxymodel.h +++ b/src/playlist/trackproxymodel.h @@ -3,7 +3,7 @@ #include -#include "tomahawk/playlistinterface.h" +#include "playlistinterface.h" #include "playlist/trackmodel.h" class TrackProxyModel : public QSortFilterProxyModel, public PlaylistInterface diff --git a/src/scriptresolver.cpp b/src/scriptresolver.cpp index c240f03ab..bac5774d3 100644 --- a/src/scriptresolver.cpp +++ b/src/scriptresolver.cpp @@ -1,7 +1,11 @@ -#include -#include "tomahawk/tomahawkapp.h" #include "scriptresolver.h" +#include + +#include "pipeline.h" +#include "sourcelist.h" + + ScriptResolver::ScriptResolver(const QString& exe) : Tomahawk::Resolver() , m_cmd( exe ) @@ -88,14 +92,14 @@ void ScriptResolver::handleMsg( const QByteArray& msg ) QList< Tomahawk::result_ptr > results; const QString& qid = m.value( "qid" ).toString(); const QVariantList& reslist = m.value( "results" ).toList(); - Tomahawk::collection_ptr coll = APP->sourcelist().getLocal()->collection(); + Tomahawk::collection_ptr coll = SourceList::instance()->getLocal()->collection(); foreach( const QVariant& rv, reslist ) { qDebug() << "RES" << rv; Tomahawk::result_ptr rp( new Tomahawk::Result( rv, coll ) ); results << rp; } - APP->pipeline()->reportResults( qid, results ); + Tomahawk::Pipeline::instance()->reportResults( qid, results ); } } @@ -104,7 +108,7 @@ void ScriptResolver::cmdExited(int code, QProcess::ExitStatus status) { m_ready = false; qDebug() << Q_FUNC_INFO << "SCRIPT EXITED, code" << code << "status" << status << m_cmd; - APP->pipeline()->removeResolver( this ); + Tomahawk::Pipeline::instance()->removeResolver( this ); if( m_num_restarts < 10 ) { @@ -142,5 +146,5 @@ void ScriptResolver::doSetup( const QVariantMap& m ) << " preference" << m_preference ; m_ready = true; - APP->pipeline()->addResolver( this ); + Tomahawk::Pipeline::instance()->addResolver( this ); } diff --git a/src/scriptresolver.h b/src/scriptresolver.h index 6b37ae482..a5164fbdb 100644 --- a/src/scriptresolver.h +++ b/src/scriptresolver.h @@ -7,8 +7,8 @@ #include #include -#include "tomahawk/resolver.h" -#include "tomahawk/result.h" +#include "resolver.h" +#include "result.h" class ScriptResolver : public Tomahawk::Resolver { diff --git a/src/scrobbler.cpp b/src/scrobbler.cpp index 7cbb94659..67dc21cf8 100644 --- a/src/scrobbler.cpp +++ b/src/scrobbler.cpp @@ -4,11 +4,11 @@ #include #include -#include -#include "tomahawk/album.h" -#include "tomahawk/typedefs.h" +#include "album.h" +#include "typedefs.h" #include "audio/audioengine.h" #include "tomahawksettings.h" +#include "tomahawk/tomahawkapp.h" #include #include @@ -30,11 +30,11 @@ Scrobbler::Scrobbler( QObject* parent ) { lastfm::ws::ApiKey = "2aa1089093868876bba20b0482b9cef9"; lastfm::ws::SharedSecret = "a7085ef81d7b46fe6ffe11c15b85902f"; - lastfm::ws::Username = TomahawkApp::instance()->settings()->lastFmUsername(); + lastfm::ws::Username = TomahawkSettings::instance()->lastFmUsername(); - m_pw = TomahawkApp::instance()->settings()->lastFmPassword(); + m_pw = TomahawkSettings::instance()->lastFmPassword(); - if( TomahawkApp::instance()->settings()->scrobblingEnabled() && !lastfm::ws::Username.isEmpty() ) + if( TomahawkSettings::instance()->scrobblingEnabled() && !lastfm::ws::Username.isEmpty() ) { createScrobbler(); } @@ -141,22 +141,22 @@ Scrobbler::scrobble() void Scrobbler::settingsChanged() { - if( !m_scrobbler && TomahawkApp::instance()->settings()->scrobblingEnabled() ) + if( !m_scrobbler && TomahawkSettings::instance()->scrobblingEnabled() ) { // can simply create the scrobbler - lastfm::ws::Username = TomahawkApp::instance()->settings()->lastFmUsername(); - m_pw = TomahawkApp::instance()->settings()->lastFmPassword(); + lastfm::ws::Username = TomahawkSettings::instance()->lastFmUsername(); + m_pw = TomahawkSettings::instance()->lastFmPassword(); createScrobbler(); } - else if( m_scrobbler && !TomahawkApp::instance()->settings()->scrobblingEnabled() ) + else if( m_scrobbler && !TomahawkSettings::instance()->scrobblingEnabled() ) { delete m_scrobbler; m_scrobbler = 0; } - else if( TomahawkApp::instance()->settings()->lastFmUsername() != lastfm::ws::Username || - TomahawkApp::instance()->settings()->lastFmPassword() != m_pw ) + else if( TomahawkSettings::instance()->lastFmUsername() != lastfm::ws::Username || + TomahawkSettings::instance()->lastFmPassword() != m_pw ) { - lastfm::ws::Username = TomahawkApp::instance()->settings()->lastFmUsername(); + lastfm::ws::Username = TomahawkSettings::instance()->lastFmUsername(); // credentials have changed, have to re-create scrobbler for them to take effect if( m_scrobbler ) delete m_scrobbler; @@ -182,16 +182,16 @@ Scrobbler::onAuthenticated() if( lfm.children( "error" ).size() > 0 ) { qDebug() << "Error from authenticating with Last.fm service:" << lfm.text(); - TomahawkApp::instance()->settings()->setLastFmSessionKey( QByteArray() ); + TomahawkSettings::instance()->setLastFmSessionKey( QByteArray() ); } else { lastfm::ws::SessionKey = lfm[ "session" ][ "key" ].text(); - TomahawkApp::instance()->settings()->setLastFmSessionKey( lastfm::ws::SessionKey.toLatin1() ); + TomahawkSettings::instance()->setLastFmSessionKey( lastfm::ws::SessionKey.toLatin1() ); - if( TomahawkApp::instance()->settings()->scrobblingEnabled() ) + if( TomahawkSettings::instance()->scrobblingEnabled() ) m_scrobbler = new lastfm::Audioscrobbler( "tst" ); } } @@ -207,7 +207,7 @@ Scrobbler::onAuthenticated() void Scrobbler::createScrobbler() { - if( TomahawkApp::instance()->settings()->lastFmSessionKey().isEmpty() ) // no session key, so get one + if( TomahawkSettings::instance()->lastFmSessionKey().isEmpty() ) // no session key, so get one { QString authToken = md5( ( lastfm::ws::Username.toLower() + md5( m_pw.toUtf8() ) ).toUtf8() ); @@ -221,7 +221,7 @@ Scrobbler::createScrobbler() } else { - lastfm::ws::SessionKey = TomahawkApp::instance()->settings()->lastFmSessionKey(); + lastfm::ws::SessionKey = TomahawkSettings::instance()->lastFmSessionKey(); m_scrobbler = new lastfm::Audioscrobbler( "tst" ); m_scrobbler->moveToThread( thread() ); diff --git a/src/scrobbler.h b/src/scrobbler.h index 72c5a3a55..927913d47 100644 --- a/src/scrobbler.h +++ b/src/scrobbler.h @@ -2,7 +2,7 @@ #ifndef TOMAHAWK_SCROBBLER_H #define TOMAHAWK_SCROBBLER_H -#include "tomahawk/result.h" +#include "result.h" #include #include diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 938dd021e..e8f6e4c5c 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -36,7 +36,7 @@ SettingsDialog::SettingsDialog( QWidget *parent ) , m_testLastFmQuery( 0 ) { ui->setupUi( this ); - TomahawkSettings* s = TomahawkApp::instance()->settings(); + TomahawkSettings* s = TomahawkSettings::instance(); ui->checkBoxHttp->setChecked( s->httpEnabled() ); ui->checkBoxUpnp->setChecked( s->upnpEnabled() ); @@ -84,7 +84,7 @@ SettingsDialog::~SettingsDialog() if ( !m_rejected ) { - TomahawkSettings* s = TomahawkApp::instance()->settings(); + TomahawkSettings* s = TomahawkSettings::instance(); // if jabber or scan dir changed, reconnect/rescan bool rescan = ui->lineEditMusicPath->text() != s->scannerPath(); @@ -270,7 +270,7 @@ ProxyDialog::ProxyDialog( QWidget *parent ) ui->typeBox->insertItem( i, "SOCKS 5", QNetworkProxy::Socks5Proxy ); enumMap[QNetworkProxy::Socks5Proxy] = i++; - TomahawkSettings* s = TomahawkApp::instance()->settings(); + TomahawkSettings* s = TomahawkSettings::instance(); ui->typeBox->setCurrentIndex( enumMap[s->proxyType()] ); ui->hostLineEdit->setText( s->proxyHost() ); @@ -286,7 +286,7 @@ ProxyDialog::saveSettings() qDebug() << Q_FUNC_INFO; //First set settings - TomahawkSettings* s = TomahawkApp::instance()->settings(); + TomahawkSettings* s = TomahawkSettings::instance(); s->setProxyHost( ui->hostLineEdit->text() ); bool ok; diff --git a/src/sip/SipHandler.cpp b/src/sip/SipHandler.cpp index 93a714988..e5ef7fb05 100644 --- a/src/sip/SipHandler.cpp +++ b/src/sip/SipHandler.cpp @@ -1,12 +1,14 @@ #include "SipHandler.h" #include "sip/SipPlugin.h" +#include #include #include #include -#include "tomahawk/tomahawkapp.h" -#include "controlconnection.h" +#include "database/database.h" +#include "network/controlconnection.h" +#include "sourcelist.h" SipHandler::SipHandler( QObject* parent ) @@ -25,9 +27,7 @@ SipHandler::~SipHandler() void SipHandler::loadPlugins() { - qDebug() << TomahawkApp::instance(); - qDebug() << TomahawkApp::instance()->applicationDirPath(); - QDir pluginsDir( TomahawkApp::instance()->applicationDirPath() ); + QDir pluginsDir( qApp->applicationDirPath() ); #if defined(Q_OS_WIN) if ( pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release" ) @@ -91,7 +91,7 @@ SipHandler::disconnect() { foreach( SipPlugin* sip, m_plugins ) sip->disconnect(); - APP->sourcelist().removeAllRemote(); + SourceList::instance()->removeAllRemote(); m_connected = false; } @@ -114,19 +114,19 @@ SipHandler::onPeerOnline( const QString& jid ) SipPlugin* sip = qobject_cast(sender()); QVariantMap m; - if( APP->servent().visibleExternally() ) + if( Servent::instance()->visibleExternally() ) { QString key = uuid(); - ControlConnection* conn = new ControlConnection( &APP->servent() ); + ControlConnection* conn = new ControlConnection( Servent::instance() ); - const QString& nodeid = APP->nodeID(); + const QString& nodeid = Database::instance()->dbid(); conn->setName( jid.left( jid.indexOf( "/" ) ) ); conn->setId( nodeid ); - APP->servent().registerOffer( key, conn ); + Servent::instance()->registerOffer( key, conn ); m["visible"] = true; - m["ip"] = APP->servent().externalAddress().toString(); - m["port"] = APP->servent().externalPort(); + m["ip"] = Servent::instance()->externalAddress().toString(); + m["port"] = Servent::instance()->externalPort(); m["key"] = key; m["uniqname"] = nodeid; @@ -176,11 +176,11 @@ SipHandler::onMessage( const QString& from, const QString& msg ) */ if ( m.value( "visible" ).toBool() ) { - if( !APP->servent().visibleExternally() || - APP->servent().externalAddress().toString() <= m.value( "ip" ).toString() ) + if( !Servent::instance()->visibleExternally() || + Servent::instance()->externalAddress().toString() <= m.value( "ip" ).toString() ) { qDebug() << "Initiate connection to" << from; - APP->servent().connectToPeer( m.value( "ip" ).toString(), + Servent::instance()->connectToPeer( m.value( "ip" ).toString(), m.value( "port" ).toInt(), m.value( "key" ).toString(), from, diff --git a/src/sip/jabber/CMakeLists.txt b/src/sip/jabber/CMakeLists.txt index 4f3cc8c1b..5520c5de1 100644 --- a/src/sip/jabber/CMakeLists.txt +++ b/src/sip/jabber/CMakeLists.txt @@ -22,9 +22,17 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. qt4_wrap_cpp( jabberMoc ${jabberHeaders} ) add_library( sip_jabber SHARED ${jabberSources} ${jabberMoc} ) +IF( WIN32 ) +SET( OS_SPECIFIC_LINK_LIBRARIES + ${OS_SPECIFIC_LINK_LIBRARIES} + "${CMAKE_CURRENT_SOURCE_DIR}/../build/src/libtomahawk/libtomahawklib.dll" +) +ENDIF( WIN32 ) + target_link_libraries( sip_jabber ${QT_LIBRARIES} ${GLOOX_LIBS} + ${OS_SPECIFIC_LINK_LIBRARIES} ) IF( APPLE ) diff --git a/src/sip/jabber/jabber.cpp b/src/sip/jabber/jabber.cpp index 05b72edb3..6748c0577 100644 --- a/src/sip/jabber/jabber.cpp +++ b/src/sip/jabber/jabber.cpp @@ -1,8 +1,9 @@ #include "jabber.h" -#include "tomahawk/tomahawkapp.h" #include "tomahawksettings.h" +#include + void JabberPlugin::setProxy( QNetworkProxy* proxy ) @@ -14,13 +15,13 @@ JabberPlugin::setProxy( QNetworkProxy* proxy ) bool JabberPlugin::connect() { - if ( !APP->settings()->value( "jabber/autoconnect", true ).toBool() ) + if ( !TomahawkSettings::instance()->value( "jabber/autoconnect", true ).toBool() ) return false; - QString jid = APP->settings()->value( "jabber/username" ).toString(); - QString server = APP->settings()->value( "jabber/server" ).toString(); - QString password = APP->settings()->value( "jabber/password" ).toString(); - unsigned int port = APP->settings()->value( "jabber/port", 5222 ).toUInt(); + QString jid = TomahawkSettings::instance()->value( "jabber/username" ).toString(); + QString server = TomahawkSettings::instance()->value( "jabber/server" ).toString(); + QString password = TomahawkSettings::instance()->value( "jabber/password" ).toString(); + unsigned int port = TomahawkSettings::instance()->value( "jabber/port", 5222 ).toUInt(); // gtalk check if( server.isEmpty() && ( jid.contains( "@gmail.com" ) || jid.contains( "@googlemail.com" ) ) ) diff --git a/src/sip/jabber/jabber.h b/src/sip/jabber/jabber.h index 69710549d..372eeb9d6 100644 --- a/src/sip/jabber/jabber.h +++ b/src/sip/jabber/jabber.h @@ -1,7 +1,7 @@ #ifndef JABBER_H #define JABBER_H -#include "SipPlugin.h" +#include "sip/SipPlugin.h" #include "jabber_p.h" class JabberPlugin : public SipPlugin diff --git a/src/sip/zeroconf/CMakeLists.txt b/src/sip/zeroconf/CMakeLists.txt index baf3ecebd..10de7e856 100644 --- a/src/sip/zeroconf/CMakeLists.txt +++ b/src/sip/zeroconf/CMakeLists.txt @@ -21,8 +21,16 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. qt4_wrap_cpp( zeroconfMoc ${zeroconfHeaders} ) add_library( sip_zeroconf SHARED ${zeroconfSources} ${zeroconfMoc} ) +IF( WIN32 ) +SET( OS_SPECIFIC_LINK_LIBRARIES + ${OS_SPECIFIC_LINK_LIBRARIES} + "${CMAKE_CURRENT_SOURCE_DIR}/../build/src/libtomahawk/libtomahawklib.dll" +) +ENDIF( WIN32 ) + target_link_libraries( sip_zeroconf ${QT_LIBRARIES} + ${OS_SPECIFIC_LINK_LIBRARIES} ) IF( APPLE ) diff --git a/src/sip/zeroconf/tomahawkzeroconf.h b/src/sip/zeroconf/tomahawkzeroconf.h index c88a1d06a..56b7acc45 100644 --- a/src/sip/zeroconf/tomahawkzeroconf.h +++ b/src/sip/zeroconf/tomahawkzeroconf.h @@ -10,7 +10,8 @@ #include #include -#include "tomahawk/tomahawkapp.h" +#include "database/database.h" +#include "network/servent.h" class Node : public QObject { @@ -68,7 +69,7 @@ public slots: qDebug() << "Advertising us on the LAN"; QByteArray advert = QString( "TOMAHAWKADVERT:%1:%2" ) .arg( m_port ) - .arg( TomahawkApp::instance()->nodeID() ) + .arg( Database::instance()->dbid() ) .toAscii(); m_sock.writeDatagram( advert.data(), advert.size(), QHostAddress::Broadcast, ZCONF_PORT ); @@ -100,7 +101,7 @@ private slots: { bool ok; int port = parts.at(1).toInt( &ok ); - if(ok && TomahawkApp::instance()->nodeID() != parts.at( 2 ) ) + if(ok && Database::instance()->dbid() != parts.at( 2 ) ) { qDebug() << "ADVERT received:" << sender << port; Node *n = new Node( sender.toString(), parts.at( 2 ), port ); diff --git a/src/sip/zeroconf/zeroconf.cpp b/src/sip/zeroconf/zeroconf.cpp index 297ba734f..1462d5d45 100644 --- a/src/sip/zeroconf/zeroconf.cpp +++ b/src/sip/zeroconf/zeroconf.cpp @@ -1,14 +1,13 @@ #include "zeroconf.h" -#include "tomahawk/tomahawkapp.h" -#include "tomahawksettings.h" +#include bool ZeroconfPlugin::connect() { delete m_zeroconf; - m_zeroconf = new TomahawkZeroconf( APP->servent().port(), this ); + m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this ); QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ), SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) ); @@ -23,8 +22,8 @@ ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name { qDebug() << "Found LAN host:" << host << port << nodeid; - if ( !APP->servent().connectedToSession( nodeid ) ) - APP->servent().connectToPeer( host, port, "whitelist", name, nodeid ); + if ( !Servent::instance()->connectedToSession( nodeid ) ) + Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid ); } Q_EXPORT_PLUGIN2( sip, ZeroconfPlugin ) diff --git a/src/sip/zeroconf/zeroconf.h b/src/sip/zeroconf/zeroconf.h index b0ff0095a..ed52f5942 100644 --- a/src/sip/zeroconf/zeroconf.h +++ b/src/sip/zeroconf/zeroconf.h @@ -1,7 +1,7 @@ #ifndef ZEROCONF_H #define ZEROCONF_H -#include "SipPlugin.h" +#include "sip/SipPlugin.h" #include "tomahawkzeroconf.h" class ZeroconfPlugin : public SipPlugin diff --git a/src/sourcetree/sourcesmodel.cpp b/src/sourcetree/sourcesmodel.cpp index 17bbae89d..ed58b5009 100644 --- a/src/sourcetree/sourcesmodel.cpp +++ b/src/sourcetree/sourcesmodel.cpp @@ -6,8 +6,8 @@ #include #include "tomahawk/tomahawkapp.h" -#include "tomahawk/query.h" -#include "tomahawk/sourcelist.h" +#include "query.h" +#include "sourcelist.h" #include "sourcetreeitem.h" #include "imagebutton.h" @@ -19,8 +19,8 @@ SourcesModel::SourcesModel( QObject* parent ) { setColumnCount( 1 ); - connect( &APP->sourcelist(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) ); - connect( &APP->sourcelist(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceRemoved( Tomahawk::source_ptr ) ) ); + connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) ); + connect( SourceList::instance(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceRemoved( Tomahawk::source_ptr ) ) ); connect( parent, SIGNAL( onOnline( QModelIndex ) ), SLOT( onItemOnline( QModelIndex ) ) ); connect( parent, SIGNAL( onOffline( QModelIndex ) ), SLOT( onItemOffline( QModelIndex ) ) ); @@ -79,7 +79,7 @@ SourcesModel::data( const QModelIndex& index, int role ) const void SourcesModel::loadSources() { - QList sources = APP->sourcelist().sources(); + QList sources = SourceList::instance()->sources(); foreach( const source_ptr& source, sources ) appendItem( source ); diff --git a/src/sourcetree/sourcesmodel.h b/src/sourcetree/sourcesmodel.h index e39f3b11c..bc3a78117 100644 --- a/src/sourcetree/sourcesmodel.h +++ b/src/sourcetree/sourcesmodel.h @@ -3,8 +3,8 @@ #include -#include "tomahawk/source.h" -#include "tomahawk/typedefs.h" +#include "source.h" +#include "typedefs.h" class SourceTreeItem; diff --git a/src/sourcetree/sourcetreeitem.cpp b/src/sourcetree/sourcetreeitem.cpp index 39ce2aaa2..f085f985c 100644 --- a/src/sourcetree/sourcetreeitem.cpp +++ b/src/sourcetree/sourcetreeitem.cpp @@ -3,8 +3,8 @@ #include #include -#include "tomahawk/collection.h" -#include "tomahawk/playlist.h" +#include "collection.h" +#include "playlist.h" #include "tomahawk/tomahawkapp.h" using namespace Tomahawk; diff --git a/src/sourcetree/sourcetreeitem.h b/src/sourcetree/sourcetreeitem.h index 66bf8fb97..bf3ae8062 100644 --- a/src/sourcetree/sourcetreeitem.h +++ b/src/sourcetree/sourcetreeitem.h @@ -4,7 +4,7 @@ #include #include -#include "tomahawk/typedefs.h" +#include "typedefs.h" #include "sourcetreeitemwidget.h" class SourceTreeItem : public QObject diff --git a/src/sourcetree/sourcetreeitemwidget.cpp b/src/sourcetree/sourcetreeitemwidget.cpp index b10aeecdb..edfffc93b 100644 --- a/src/sourcetree/sourcetreeitemwidget.cpp +++ b/src/sourcetree/sourcetreeitemwidget.cpp @@ -3,10 +3,10 @@ #include "ui_sourcetreeitemwidget.h" #include "tomahawk/tomahawkapp.h" -#include "tomahawk/album.h" -#include "database.h" -#include "databasecommand_collectionstats.h" -#include "dbsyncconnection.h" +#include "album.h" +#include "database/database.h" +#include "database/databasecommand_collectionstats.h" +#include "network/dbsyncconnection.h" #include "playlistmanager.h" using namespace Tomahawk; diff --git a/src/sourcetree/sourcetreeitemwidget.h b/src/sourcetree/sourcetreeitemwidget.h index 942ac9753..eae2c115e 100644 --- a/src/sourcetree/sourcetreeitemwidget.h +++ b/src/sourcetree/sourcetreeitemwidget.h @@ -3,7 +3,7 @@ #include -#include "tomahawk/source.h" +#include "source.h" namespace Ui { diff --git a/src/sourcetree/sourcetreeview.cpp b/src/sourcetree/sourcetreeview.cpp index 6c0d1bb73..6017709a0 100644 --- a/src/sourcetree/sourcetreeview.cpp +++ b/src/sourcetree/sourcetreeview.cpp @@ -1,11 +1,12 @@ #include "sourcetreeview.h" -#include "tomahawk/tomahawkapp.h" -#include "tomahawk/playlist.h" +#include "playlist.h" #include "collectionmodel.h" #include "playlistmanager.h" #include "sourcetreeitem.h" #include "sourcesmodel.h" +#include "sourcelist.h" +#include "tomahawk/tomahawkapp.h" #include #include @@ -70,7 +71,7 @@ SourceTreeView::SourceTreeView( QWidget* parent ) connect( this, SIGNAL( clicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) ); connect( selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), SLOT( onSelectionChanged() ) ); - connect( &APP->sourcelist(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceOffline( Tomahawk::source_ptr ) ) ); + connect( SourceList::instance(), SIGNAL( sourceRemoved( Tomahawk::source_ptr ) ), SLOT( onSourceOffline( Tomahawk::source_ptr ) ) ); m_model->appendItem( source_ptr() ); } diff --git a/src/sourcetree/sourcetreeview.h b/src/sourcetree/sourcetreeview.h index 169f710eb..f896823c8 100644 --- a/src/sourcetree/sourcetreeview.h +++ b/src/sourcetree/sourcetreeview.h @@ -4,7 +4,7 @@ #include #include -#include "tomahawk/source.h" +#include "source.h" class CollectionModel; class PlaylistModel; diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index 680607f38..760ad5f84 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -6,9 +6,9 @@ #include #include -#include "tomahawk/artist.h" -#include "tomahawk/album.h" -#include "tomahawk/collection.h" +#include "artist.h" +#include "album.h" +#include "collection.h" #include "tomahawk/infosystem.h" #include "database/database.h" #include "database/databasecollection.h" @@ -19,6 +19,7 @@ #include "xmppbot/xmppbot.h" #include "web/api_v1.h" #include "scriptresolver.h" +#include "sourcelist.h" #include "audioengine.h" @@ -101,13 +102,16 @@ using namespace Tomahawk; TomahawkApp::TomahawkApp( int& argc, char *argv[] ) : TOMAHAWK_APPLICATION( argc, argv ) , m_audioEngine( 0 ) - , m_settings( 0 ) , m_nam( 0 ) , m_proxy( 0 ) , m_infoSystem( 0 ) { qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) ); + new Pipeline( this ); + new SourceList( this ); + new Servent( this ); + #ifdef TOMAHAWK_HEADLESS m_headless = true; #else @@ -128,7 +132,7 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] ) registerMetaTypes(); setupLogfile(); - m_settings = new TomahawkSettings( this ); + new TomahawkSettings( this ); m_audioEngine = new AudioEngine; setupDatabase(); @@ -152,10 +156,10 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] ) #endif // Set up proxy - if( m_settings->proxyType() != QNetworkProxy::NoProxy && !m_settings->proxyHost().isEmpty() ) + if( TomahawkSettings::instance()->proxyType() != QNetworkProxy::NoProxy && !TomahawkSettings::instance()->proxyHost().isEmpty() ) { qDebug() << "Setting proxy to saved values"; - m_proxy = new QNetworkProxy( static_cast(m_settings->proxyType()), m_settings->proxyHost(), m_settings->proxyPort(), m_settings->proxyUsername(), m_settings->proxyPassword() ); + m_proxy = new QNetworkProxy( static_cast(TomahawkSettings::instance()->proxyType()), TomahawkSettings::instance()->proxyHost(), TomahawkSettings::instance()->proxyPort(), TomahawkSettings::instance()->proxyUsername(), TomahawkSettings::instance()->proxyPassword() ); qDebug() << "Proxy type = " << QString::number( static_cast(m_proxy->type()) ); qDebug() << "Proxy host = " << m_proxy->hostName(); QNetworkAccessManager* nam = TomahawkApp::instance()->nam(); @@ -168,10 +172,6 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] ) m_infoSystem = new Tomahawk::InfoSystem::InfoSystem( this ); - boost::function(result_ptr)> fac = - boost::bind( &TomahawkApp::httpIODeviceFactory, this, _1 ); - this->registerIODeviceFactory( "http", fac ); - if( !arguments().contains("--nojabber") ) { setupSIP(); @@ -193,13 +193,13 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] ) startServent(); //loadPlugins(); - if( arguments().contains( "--http" ) || settings()->value( "network/http", true ).toBool() ) + if( arguments().contains( "--http" ) || TomahawkSettings::instance()->value( "network/http", true ).toBool() ) startHTTP(); m_sipHandler->connect(); #ifndef TOMAHAWK_HEADLESS - if ( !m_settings->hasScannerPath() ) + if ( !TomahawkSettings::instance()->hasScannerPath() ) { m_mainwindow->showSettingsDialog(); } @@ -217,12 +217,6 @@ TomahawkApp::~TomahawkApp() delete m_mainwindow; delete m_audioEngine; #endif - - delete m_db; - m_db = 0; - - // always last thing, incase other objects save state on exit: - delete m_settings; } @@ -299,8 +293,8 @@ TomahawkApp::setupDatabase() } qDebug() << "Using database:" << dbpath; - m_db = new Database( dbpath, this ); - m_pipeline.databaseReady(); + new Database( dbpath, this ); + Pipeline::instance()->databaseReady(); } @@ -324,8 +318,8 @@ void TomahawkApp::setupPipeline() { // setup resolvers for local content, and (cached) remote collection content - m_pipeline.addResolver( new DatabaseResolver( true, 100 ) ); - m_pipeline.addResolver( new DatabaseResolver( false, 90 ) ); + Pipeline::instance()->addResolver( new DatabaseResolver( true, 100 ) ); + Pipeline::instance()->addResolver( new DatabaseResolver( false, 90 ) ); // new ScriptResolver("/home/rj/src/tomahawk-core/contrib/magnatune/magnatune-resolver.php"); } @@ -338,26 +332,22 @@ TomahawkApp::initLocalCollection() collection_ptr coll( new DatabaseCollection( src ) ); src->addCollection( coll ); - this->sourcelist().add( src ); - - boost::function(result_ptr)> fac = - boost::bind( &TomahawkApp::localFileIODeviceFactory, this, _1 ); - this->registerIODeviceFactory( "file", fac ); + SourceList::instance()->add( src ); // to make the stats signal be emitted by our local source // this will update the sidebar, etc. DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( src ); connect( cmd, SIGNAL( done( const QVariantMap& ) ), src.data(), SLOT( setStats( const QVariantMap& ) ), Qt::QueuedConnection ); - database()->enqueue( QSharedPointer( cmd ) ); + Database::instance()->enqueue( QSharedPointer( cmd ) ); } void TomahawkApp::startServent() { - bool upnp = !arguments().contains( "--noupnp" ) && settings()->value( "network/upnp", true ).toBool(); - if ( !m_servent.startListening( QHostAddress( QHostAddress::Any ), upnp ) ) + bool upnp = !arguments().contains( "--noupnp" ) && TomahawkSettings::instance()->value( "network/upnp", true ).toBool(); + if ( !Servent::instance()->startListening( QHostAddress( QHostAddress::Any ), upnp ) ) { qDebug() << "Failed to start listening with servent"; exit( 1 ); @@ -365,11 +355,6 @@ TomahawkApp::startServent() //QString key = m_servent.createConnectionKey(); //qDebug() << "Generated an offer key: " << key; - - boost::function(result_ptr)> fac = - boost::bind( &Servent::remoteIODeviceFactory, &m_servent, _1 ); - - this->registerIODeviceFactory( "servent", fac ); } @@ -393,7 +378,7 @@ TomahawkApp::loadPlugins() if ( !pluginst ) continue; - PluginAPI* api = new PluginAPI( this->pipeline() ); + PluginAPI* api = new PluginAPI( Pipeline::instance() ); TomahawkPlugin* plugin = pluginst->factory( api ); qDebug() << "Loaded Plugin:" << plugin->name(); qDebug() << plugin->description(); @@ -420,58 +405,3 @@ TomahawkApp::setupSIP() // m_sipHandler->setProxy( m_proxy ); } - -void -TomahawkApp::registerIODeviceFactory( const QString &proto, boost::function(Tomahawk::result_ptr)> fac ) -{ - m_iofactories.insert( proto, fac ); - qDebug() << "Registered IODevice Factory for" << proto; -} - - -QSharedPointer -TomahawkApp::getIODeviceForUrl( const Tomahawk::result_ptr& result ) -{ - qDebug() << Q_FUNC_INFO << thread(); - QSharedPointer sp; - - QRegExp rx( "^([a-zA-Z0-9]+)://(.+)$" ); - if ( rx.indexIn( result->url() ) == -1 ) - return sp; - - const QString proto = rx.cap( 1 ); - //const QString urlpart = rx.cap( 2 ); - if ( !m_iofactories.contains( proto ) ) - return sp; - - return m_iofactories.value( proto )( result ); -} - - -QSharedPointer -TomahawkApp::localFileIODeviceFactory( const Tomahawk::result_ptr& result ) -{ - // ignore "file://" at front of url - QFile * io = new QFile( result->url().mid( QString( "file://" ).length() ) ); - if ( io ) - io->open( QIODevice::ReadOnly ); - - return QSharedPointer( io ); -} - - -QSharedPointer -TomahawkApp::httpIODeviceFactory( const Tomahawk::result_ptr& result ) -{ - qDebug() << Q_FUNC_INFO << result->url(); - QNetworkRequest req( result->url() ); - QNetworkReply* reply = APP->nam()->get( req ); - return QSharedPointer( reply ); -} - - -const QString& -TomahawkApp::nodeID() const -{ - return m_db->dbid(); -} diff --git a/src/tomahawktrayicon.h b/src/tomahawktrayicon.h index d975f93f2..c73a85781 100644 --- a/src/tomahawktrayicon.h +++ b/src/tomahawktrayicon.h @@ -5,7 +5,7 @@ #include #include -#include "tomahawk/result.h" +#include "result.h" class TomahawkTrayIcon : public QSystemTrayIcon { diff --git a/src/tomahawkwindow.cpp b/src/tomahawkwindow.cpp index bb5ceed0a..d7a4f036e 100644 --- a/src/tomahawkwindow.cpp +++ b/src/tomahawkwindow.cpp @@ -13,9 +13,8 @@ #include #include "tomahawk/tomahawkapp.h" -#include "tomahawk/functimeout.h" -#include "tomahawk/playlist.h" -#include "tomahawk/query.h" +#include "playlist.h" +#include "query.h" #include "database/databasecommand_collectionstats.h" #include "topbar/topbar.h" @@ -23,8 +22,8 @@ #include "sip/SipHandler.h" #include "audiocontrols.h" -#include "controlconnection.h" -#include "database.h" +#include "network/controlconnection.h" +#include "database/database.h" #include "musicscanner.h" #include "playlistmanager.h" #include "proxystyle.h" @@ -98,7 +97,7 @@ TomahawkWindow::~TomahawkWindow() void TomahawkWindow::loadSettings() { - TomahawkSettings* s = APP->settings(); + TomahawkSettings* s = TomahawkSettings::instance(); if ( !s->mainWindowGeometry().isEmpty() ) restoreGeometry( s->mainWindowGeometry() ); @@ -110,7 +109,7 @@ TomahawkWindow::loadSettings() void TomahawkWindow::saveSettings() { - TomahawkSettings* s = APP->settings(); + TomahawkSettings* s = TomahawkSettings::instance(); s->setMainWindowGeometry( saveGeometry() ); s->setMainWindowState( saveState() ); } @@ -235,7 +234,7 @@ TomahawkWindow::showSettingsDialog() void TomahawkWindow::rescanCollectionManually() { - TomahawkSettings* s = APP->settings(); + TomahawkSettings* s = TomahawkSettings::instance(); bool ok; QString path = QInputDialog::getText( this, tr( "Enter path to music dir:" ), tr( "Path pls" ), QLineEdit::Normal, @@ -262,7 +261,7 @@ TomahawkWindow::scanFinished() void TomahawkWindow::addPeerManually() { - TomahawkSettings* s = APP->settings(); + TomahawkSettings* s = TomahawkSettings::instance(); bool ok; QString addr = QInputDialog::getText( this, tr( "Connect To Peer" ), tr( "Enter peer address:" ), QLineEdit::Normal, @@ -286,7 +285,7 @@ TomahawkWindow::addPeerManually() return; qDebug() << "Attempting to connect to" << addr; - APP->servent().connectToPeer( addr, port, key ); + Servent::instance()->connectToPeer( addr, port, key ); } @@ -330,7 +329,7 @@ TomahawkWindow::createPlaylist() if ( !ok || name.isEmpty() ) return; - source_ptr author = APP->sourcelist().getLocal(); + source_ptr author = SourceList::instance()->getLocal(); QString id = uuid(); QString info = ""; // FIXME QString creator = "someone"; // FIXME diff --git a/src/tomahawkwindow.h b/src/tomahawkwindow.h index 06a574c5b..a7291addb 100644 --- a/src/tomahawkwindow.h +++ b/src/tomahawkwindow.h @@ -7,7 +7,7 @@ #include #include -#include "tomahawk/pipeline.h" +#include "result.h" class QAction; diff --git a/src/topbar/topbar.cpp b/src/topbar/topbar.cpp index 9b41878ac..a144bcdc7 100644 --- a/src/topbar/topbar.cpp +++ b/src/topbar/topbar.cpp @@ -6,7 +6,6 @@ #include #include -#include "tomahawk/functimeout.h" #include "tomahawk/tomahawkapp.h" #define MAXDUDES 3 diff --git a/src/topbar/topbar.h b/src/topbar/topbar.h index eccdcf886..8d113a847 100644 --- a/src/topbar/topbar.h +++ b/src/topbar/topbar.h @@ -5,7 +5,7 @@ #include #include -#include "tomahawk/sourcelist.h" +#include "sourcelist.h" namespace Ui { diff --git a/src/transferview.cpp b/src/transferview.cpp index 74a6da876..5b0f4aa92 100644 --- a/src/transferview.cpp +++ b/src/transferview.cpp @@ -19,8 +19,8 @@ TransferView::TransferView( AnimatedSplitter* parent ) layout()->setMargin( 0 ); layout()->addWidget( m_tree ); - connect( &APP->servent(), SIGNAL( fileTransferStarted( FileTransferConnection* ) ), SLOT( fileTransferRegistered( FileTransferConnection* ) ) ); - connect( &APP->servent(), SIGNAL( fileTransferFinished( FileTransferConnection* ) ), SLOT( fileTransferFinished( FileTransferConnection* ) ) ); + connect( Servent::instance(), SIGNAL( fileTransferStarted( FileTransferConnection* ) ), SLOT( fileTransferRegistered( FileTransferConnection* ) ) ); + connect( Servent::instance(), SIGNAL( fileTransferFinished( FileTransferConnection* ) ), SLOT( fileTransferFinished( FileTransferConnection* ) ) ); QStringList headers; headers << tr( "Peer" ) << tr( "Rate" ) << tr( "Track" ); diff --git a/src/transferview.h b/src/transferview.h index cad77fae2..3520c03be 100644 --- a/src/transferview.h +++ b/src/transferview.h @@ -4,7 +4,7 @@ #include #include -#include "tomahawk/typedefs.h" +#include "typedefs.h" #include "utils/animatedsplitter.h" class FileTransferConnection; diff --git a/src/web/api_v1.h b/src/web/api_v1.h index 89b65b822..0a77a679d 100644 --- a/src/web/api_v1.h +++ b/src/web/api_v1.h @@ -3,8 +3,8 @@ // See: http://doc.libqxt.org/tip/qxtweb.html -#include "tomahawk/tomahawkapp.h" -#include "tomahawk/query.h" +#include "query.h" +#include "pipeline.h" #include "QxtHttpServerConnector" #include "QxtHttpSessionManager" @@ -18,6 +18,8 @@ #include #include +#include "network/servent.h" + class Api_v1 : public QxtWebSlotService { Q_OBJECT @@ -55,12 +57,12 @@ public slots: using namespace Tomahawk; RID rid = event->url.path().mid(5); qDebug() << "Request for sid " << rid; - result_ptr rp = APP->pipeline()->result( rid ); + result_ptr rp = Pipeline::instance()->result( rid ); if( rp.isNull() ) { return send404( event ); } - QSharedPointer iodev = APP->getIODeviceForUrl( rp ); + QSharedPointer iodev = Servent::instance()->getIODeviceForUrl( rp ); if( iodev.isNull() ) { return send404( event ); // 503? @@ -111,7 +113,7 @@ public slots: m.insert( "qid", qid ); Tomahawk::query_ptr qry( new Tomahawk::Query( m ) ); - APP->pipeline()->add( qry ); + Tomahawk::Pipeline::instance()->add( qry ); QVariantMap r; r.insert( "qid", qid ); @@ -127,7 +129,7 @@ public slots: } using namespace Tomahawk; - query_ptr qry = APP->pipeline()->query( event->url.queryItemValue("qid") ); + query_ptr qry = Pipeline::instance()->query( event->url.queryItemValue("qid") ); if( qry.isNull() ) { send404( event ); diff --git a/src/xmppbot/xmppbot.cpp b/src/xmppbot/xmppbot.cpp index 9da87516b..84f3ea9ff 100644 --- a/src/xmppbot/xmppbot.cpp +++ b/src/xmppbot/xmppbot.cpp @@ -2,10 +2,11 @@ #include "tomahawk/tomahawkapp.h" #include "tomahawk/infosystem.h" -#include "tomahawk/album.h" -#include "tomahawk/typedefs.h" -#include -#include