mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-19 23:41:51 +02:00
* 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.
This commit is contained in:
parent
1496d322bf
commit
27e906f712
@ -25,5 +25,6 @@ ENDIF( UNIX AND NOT APPLE )
|
||||
|
||||
ADD_SUBDIRECTORY( libportfwd )
|
||||
ADD_SUBDIRECTORY( qxt )
|
||||
ADD_SUBDIRECTORY( src/libtomahawk )
|
||||
ADD_SUBDIRECTORY( src )
|
||||
|
||||
|
@ -1 +1 @@
|
||||
47
|
||||
53
|
@ -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
|
||||
|
@ -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<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> fac );
|
||||
QSharedPointer<QIODevice> localFileIODeviceFactory( const Tomahawk::result_ptr& result );
|
||||
QSharedPointer<QIODevice> httpIODeviceFactory( const Tomahawk::result_ptr& result );
|
||||
|
||||
TomahawkSettings* settings() { return m_settings; }
|
||||
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
||||
public slots:
|
||||
QSharedPointer<QIODevice> getIODeviceForUrl( const Tomahawk::result_ptr& result );
|
||||
|
||||
private:
|
||||
void initLocalCollection();
|
||||
void loadPlugins();
|
||||
@ -109,11 +90,7 @@ private:
|
||||
QList<Tomahawk::collection_ptr> m_collections;
|
||||
QList<TomahawkPlugin*> 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<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> > m_iofactories;
|
||||
|
||||
bool m_headless;
|
||||
TomahawkSettings* m_settings;
|
||||
|
||||
QNetworkAccessManager* m_nam;
|
||||
QNetworkProxy* m_proxy;
|
||||
|
@ -1,9 +1,10 @@
|
||||
#ifndef TOMAHAWK_PLUGIN_H
|
||||
#define TOMAHAWK_PLUGIN_H
|
||||
|
||||
#include <QString>
|
||||
#include <QtPlugin>
|
||||
|
||||
#include "tomahawk/pluginapi.h"
|
||||
#include "pluginapi.h"
|
||||
|
||||
class TomahawkPlugin
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -1,6 +1,7 @@
|
||||
SET( OS_SPECIFIC_LINK_LIBRARIES
|
||||
${OS_SPECIFIC_LINK_LIBRARIES}
|
||||
alsaplayback
|
||||
tomahawklib
|
||||
)
|
||||
|
||||
IF( "${gui}" STREQUAL "no" )
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
#include <QUrl>
|
||||
#include <QMutexLocker>
|
||||
|
||||
#include <tomahawk/tomahawkapp.h>
|
||||
#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() )
|
||||
{
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include <QMutex>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "tomahawk/result.h"
|
||||
#include "tomahawk/typedefs.h"
|
||||
#include "result.h"
|
||||
#include "typedefs.h"
|
||||
|
||||
#include "rtaudiooutput.h"
|
||||
#include "alsaplayback.h"
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "tomahawk/album.h"
|
||||
#include "album.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#include "audioengine.h"
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "tomahawk/result.h"
|
||||
#include "tomahawk/playlistinterface.h"
|
||||
#include "result.h"
|
||||
#include "playlistinterface.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#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;
|
||||
|
150
src/libtomahawk/CMakeLists.txt
Normal file
150
src/libtomahawk/CMakeLists.txt
Normal file
@ -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 . )
|
@ -1,9 +1,8 @@
|
||||
#include "tomahawk/album.h"
|
||||
#include "album.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#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::query_ptr>, Tomahawk::collection_ptr ) ),
|
||||
SLOT( onTracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ) );
|
||||
|
||||
APP->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
return m_queries;
|
@ -4,16 +4,18 @@
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#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
|
||||
|
@ -1,9 +1,8 @@
|
||||
#include "tomahawk/artist.h"
|
||||
#include "artist.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "tomahawk/collection.h"
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "collection.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databasecommand_alltracks.h"
|
||||
|
@ -4,13 +4,15 @@
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#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
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "tomahawk/collection.h"
|
||||
#include "collection.h"
|
||||
|
||||
#include <QMetaObject>
|
||||
#include <QGenericArgument>
|
||||
|
||||
#include "tomahawk/playlist.h"
|
||||
#include "playlist.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
@ -13,15 +13,17 @@
|
||||
#include <QSharedPointer>
|
||||
#include <QDebug>
|
||||
|
||||
#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
|
||||
|
@ -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();
|
||||
}
|
@ -4,9 +4,11 @@
|
||||
#include <QSharedPointer>
|
||||
#include <QVariant>
|
||||
|
||||
#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
|
@ -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<Tomahawk::playlist_ptr>& ) ),
|
||||
SLOT( setPlaylists( const QList<Tomahawk::playlist_ptr>& ) ) );
|
||||
|
||||
TomahawkApp::instance()->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +38,7 @@ DatabaseCollection::loadTracks()
|
||||
/* connect( cmd, SIGNAL( done( Tomahawk::collection_ptr ) ),
|
||||
SIGNAL( tracksFinished( Tomahawk::collection_ptr ) ) );*/
|
||||
|
||||
TomahawkApp::instance()->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +48,7 @@ DatabaseCollection::addTracks( const QList<QVariant> &newitems )
|
||||
qDebug() << Q_FUNC_INFO << newitems.length();
|
||||
DatabaseCommand_AddFiles* cmd = new DatabaseCommand_AddFiles( newitems, source() );
|
||||
|
||||
TomahawkApp::instance()->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -6,13 +6,15 @@
|
||||
#include <QTime>
|
||||
#include <QSqlQuery>
|
||||
|
||||
#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 )
|
@ -2,12 +2,11 @@
|
||||
|
||||
#include <QSqlQuery>
|
||||
|
||||
#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<DatabaseCommand>( cmd ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
|
||||
if( source()->isLocal() )
|
||||
APP->servent().triggerDBSync();
|
||||
Servent::instance()->triggerDBSync();
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,11 @@
|
||||
#include <QVariantMap>
|
||||
|
||||
#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 )
|
@ -6,7 +6,9 @@
|
||||
|
||||
#include "databasecommand.h"
|
||||
|
||||
class DatabaseCommand_addSource : public DatabaseCommand
|
||||
#include "dllmacro.h"
|
||||
|
||||
class DLLEXPORT DatabaseCommand_addSource : public DatabaseCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -5,11 +5,13 @@
|
||||
#include <QVariantMap>
|
||||
|
||||
#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:
|
@ -5,11 +5,13 @@
|
||||
#include <QVariantMap>
|
||||
|
||||
#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:
|
@ -4,10 +4,12 @@
|
||||
#include <QVariantMap>
|
||||
|
||||
#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
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <QSqlQuery>
|
||||
|
||||
#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();
|
||||
}
|
@ -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 )
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <QSqlQuery>
|
||||
|
||||
#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();
|
||||
}
|
@ -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 )
|
@ -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
|
||||
|
@ -1,13 +1,17 @@
|
||||
#ifndef DATABASECOMMAND_IMPORTPLAYLIST_H
|
||||
#define DATABASECOMMAND_IMPORTPLAYLIST_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#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:
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <QSqlQuery>
|
||||
|
||||
#include "tomahawk/playlist.h"
|
||||
#include "playlist.h"
|
||||
#include "databaseimpl.h"
|
||||
|
||||
using namespace Tomahawk;
|
@ -5,9 +5,11 @@
|
||||
#include <QVariantMap>
|
||||
|
||||
#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
|
||||
|
@ -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 )
|
@ -7,7 +7,9 @@
|
||||
|
||||
#include "databasecommand.h"
|
||||
|
||||
class DatabaseCommand_LoadFile : public DatabaseCommand
|
||||
#include "dllmacro.h"
|
||||
|
||||
class DLLEXPORT DatabaseCommand_LoadFile : public DatabaseCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -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:
|
@ -5,9 +5,11 @@
|
||||
#include <QVariantMap>
|
||||
|
||||
#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
|
||||
|
@ -5,10 +5,12 @@
|
||||
#include <QVariantMap>
|
||||
|
||||
#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 )
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <QSqlQuery>
|
||||
|
||||
#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();
|
||||
}
|
@ -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 )
|
@ -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();
|
@ -3,11 +3,13 @@
|
||||
|
||||
#include "databasecommand.h"
|
||||
#include "databaseimpl.h"
|
||||
#include "tomahawk/result.h"
|
||||
#include "result.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
class DatabaseCommand_Resolve : public DatabaseCommand
|
||||
#include "dllmacro.h"
|
||||
|
||||
class DLLEXPORT DatabaseCommand_Resolve : public DatabaseCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
@ -3,7 +3,7 @@
|
||||
#include <QSqlQuery>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
|
@ -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 )
|
@ -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
|
||||
|
@ -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:
|
@ -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)
|
@ -1,11 +1,12 @@
|
||||
#include "databaseimpl.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QRegExp>
|
||||
#include <QStringList>
|
||||
#include <QtAlgorithms>
|
||||
#include <QFile>
|
||||
#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<DatabaseCommand>( cmd ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
@ -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<DatabaseCommand>( cmd ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( 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 );
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -4,8 +4,7 @@
|
||||
#include <QTime>
|
||||
#include <QSqlQuery>
|
||||
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "database.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databasecommandloggable.h"
|
||||
|
||||
|
14
src/libtomahawk/dllmacro.h
Normal file
14
src/libtomahawk/dllmacro.h
Normal file
@ -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
|
@ -3,7 +3,7 @@
|
||||
#include <QTime>
|
||||
#include <QThread>
|
||||
|
||||
#include "servent.h"
|
||||
#include "network/servent.h"
|
||||
|
||||
#define PROTOVER "3" // must match remote peer, or we can't talk.
|
||||
|
@ -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
|
||||
|
@ -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();
|
@ -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
|
||||
|
@ -14,14 +14,14 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#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<DatabaseCommand>(cmd_us) );
|
||||
|
||||
APP->database()->enqueue( QSharedPointer<DatabaseCommand>(cmd_them) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd_us) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(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<DatabaseCommand>(cmd) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(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<DatabaseCommand>( cmd ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( 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<DatabaseCommand>( cmd ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,9 @@
|
||||
#include <QSharedPointer>
|
||||
#include <QIODevice>
|
||||
|
||||
#include "connection.h"
|
||||
#include "network/connection.h"
|
||||
#include "database/op.h"
|
||||
#include "tomahawk/typedefs.h"
|
||||
#include "typedefs.h"
|
||||
|
||||
class DBSyncConnection : public Connection
|
||||
{
|
@ -2,13 +2,13 @@
|
||||
|
||||
#include <QFile>
|
||||
|
||||
#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<QIODevice>( 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<source_ptr> sources = APP->sourcelist().sources();
|
||||
QList<source_ptr> 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<DatabaseCommand>( cmd ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ FileTransferConnection::startSending( const Tomahawk::result_ptr& result )
|
||||
m_result = result;
|
||||
qDebug() << "Starting to transmit" << m_result->url();
|
||||
|
||||
QSharedPointer<QIODevice> io = TomahawkApp::instance()->getIODeviceForUrl( m_result );
|
||||
QSharedPointer<QIODevice> io = Servent::instance()->getIODeviceForUrl( m_result );
|
||||
if( !io )
|
||||
{
|
||||
qDebug() << "Couldn't read from source:" << m_result->url();
|
@ -5,8 +5,8 @@
|
||||
#include <QSharedPointer>
|
||||
#include <QIODevice>
|
||||
|
||||
#include "connection.h"
|
||||
#include "tomahawk/result.h"
|
||||
#include "network/connection.h"
|
||||
#include "result.h"
|
||||
|
||||
class ControlConnection;
|
||||
class BufferIODevice;
|
@ -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<msg_ptr> * watcher = (QFutureWatcher<msg_ptr> *) 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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
{
|
@ -1,27 +1,64 @@
|
||||
#include "servent.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QMutexLocker>
|
||||
#include <QNetworkInterface>
|
||||
#include <QFile>
|
||||
#include <QTime>
|
||||
#include <QThread>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#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<QSharedPointer<QIODevice>(result_ptr)> fac =
|
||||
boost::bind( &Servent::localFileIODeviceFactory, this, _1 );
|
||||
this->registerIODeviceFactory( "file", fac );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<QSharedPointer<QIODevice>(result_ptr)> fac =
|
||||
boost::bind( &Servent::remoteIODeviceFactory, this, _1 );
|
||||
this->registerIODeviceFactory( "servent", fac );
|
||||
}
|
||||
|
||||
{
|
||||
boost::function<QSharedPointer<QIODevice>(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<QHostAddress> 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<source_ptr> sources = APP->sourcelist().sources();
|
||||
QList<source_ptr> 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<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> fac )
|
||||
{
|
||||
m_iofactories.insert( proto, fac );
|
||||
qDebug() << "Registered IODevice Factory for" << proto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QSharedPointer<QIODevice>
|
||||
Servent::getIODeviceForUrl( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << thread();
|
||||
QSharedPointer<QIODevice> 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<QIODevice>
|
||||
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<QIODevice>( io );
|
||||
}
|
||||
|
||||
|
||||
QSharedPointer<QIODevice>
|
||||
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<QIODevice>( reply );*/
|
||||
}
|
@ -20,20 +20,24 @@
|
||||
#include <qjson/serializer.h>
|
||||
#include <qjson/qobjecthelper.h>
|
||||
|
||||
#include "portfwd/portfwd.h"
|
||||
#include "tomahawk/typedefs.h"
|
||||
#include "typedefs.h"
|
||||
#include "msg.h"
|
||||
|
||||
#include <boost/function.hpp>
|
||||
|
||||
#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<QIODevice> getIODeviceForUrl( const Tomahawk::result_ptr& result );
|
||||
void registerIODeviceFactory( const QString &proto, boost::function<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> fac );
|
||||
QSharedPointer<QIODevice> localFileIODeviceFactory( const Tomahawk::result_ptr& result );
|
||||
QSharedPointer<QIODevice> 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<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> > m_iofactories;
|
||||
|
||||
static Servent* s_instance;
|
||||
};
|
||||
|
||||
#endif // SERVENT_H
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user