mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 03:10:12 +02:00
Add necessary hooks for hatchet dbcmd syncing
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "network/ControlConnection.h"
|
||||
#include "database/DatabaseCommand_AddSource.h"
|
||||
#include "database/DatabaseCommand_CollectionStats.h"
|
||||
#include "database/DatabaseCommand_LoadAllSources.h"
|
||||
#include "database/DatabaseCommand_SourceOffline.h"
|
||||
#include "database/DatabaseCommand_UpdateSearchIndex.h"
|
||||
#include "database/Database.h"
|
||||
@@ -415,6 +416,15 @@ Source::lastCmdGuid() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Source::setLastCmdGuid( const QString& guid )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "name is " << friendlyName() << " and guid is " << guid;
|
||||
QMutexLocker lock( &m_cmdMutex );
|
||||
m_lastCmdGuid = guid;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Source::addCommand( const QSharedPointer<DatabaseCommand>& command )
|
||||
{
|
||||
|
@@ -33,10 +33,11 @@
|
||||
#include "DllMacro.h"
|
||||
|
||||
class ControlConnection;
|
||||
class DatabaseCommand_DeleteFiles;
|
||||
class DatabaseCommand_LoadAllSources;
|
||||
class DatabaseCommand_LogPlayback;
|
||||
class DatabaseCommand_SocialAction;
|
||||
class DatabaseCommand_UpdateSearchIndex;
|
||||
class DatabaseCommand_DeleteFiles;
|
||||
class MusicScanner;
|
||||
|
||||
namespace Tomahawk
|
||||
@@ -48,10 +49,11 @@ Q_OBJECT
|
||||
|
||||
friend class ::DBSyncConnection;
|
||||
friend class ::ControlConnection;
|
||||
friend class ::DatabaseCommand_LogPlayback;
|
||||
friend class ::DatabaseCommand_SocialAction;
|
||||
friend class ::DatabaseCommand_AddFiles;
|
||||
friend class ::DatabaseCommand_DeleteFiles;
|
||||
friend class ::DatabaseCommand_LoadAllSources;
|
||||
friend class ::DatabaseCommand_LogPlayback;
|
||||
friend class ::DatabaseCommand_SocialAction;
|
||||
friend class ::MusicScanner;
|
||||
|
||||
public:
|
||||
@@ -124,10 +126,11 @@ signals:
|
||||
|
||||
public slots:
|
||||
void setStats( const QVariantMap& m );
|
||||
QString lastCmdGuid() const;
|
||||
|
||||
private slots:
|
||||
void setLastCmdGuid( const QString& guid );
|
||||
void dbLoaded( unsigned int id, const QString& fname );
|
||||
QString lastCmdGuid() const;
|
||||
void updateIndexWhenSynced();
|
||||
|
||||
void setOffline();
|
||||
|
@@ -21,7 +21,7 @@
|
||||
#include <QSqlQuery>
|
||||
|
||||
#include "network/Servent.h"
|
||||
#include "Source.h"
|
||||
#include "SourceList.h"
|
||||
#include "DatabaseImpl.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
@@ -33,7 +33,15 @@ DatabaseCommand_LoadAllSources::exec( DatabaseImpl* dbi )
|
||||
{
|
||||
TomahawkSqlQuery query = dbi->newquery();
|
||||
|
||||
query.exec( QString( "SELECT id, name, friendlyname "
|
||||
query.exec( QString( "SELECT guid "
|
||||
"FROM oplog "
|
||||
"WHERE source IS NULL "
|
||||
"ORDER BY id DESC LIMIT 1" ) );
|
||||
if ( query.next() )
|
||||
if ( SourceList::instance() && !SourceList::instance()->getLocal().isNull() )
|
||||
SourceList::instance()->getLocal()->setLastCmdGuid( query.value( 0 ).toString() );
|
||||
|
||||
query.exec( QString( "SELECT id, name, friendlyname, lastop "
|
||||
"FROM source" ) );
|
||||
|
||||
QList<source_ptr> sources;
|
||||
@@ -41,6 +49,7 @@ DatabaseCommand_LoadAllSources::exec( DatabaseImpl* dbi )
|
||||
{
|
||||
source_ptr src( new Source( query.value( 0 ).toUInt(), query.value( 1 ).toString() ) );
|
||||
src->setDbFriendlyName( query.value( 2 ).toString() );
|
||||
src->setLastCmdGuid( query.value( 3 ).toString() );
|
||||
sources << src;
|
||||
}
|
||||
|
||||
|
@@ -1051,7 +1051,7 @@ void
|
||||
Servent::triggerDBSync()
|
||||
{
|
||||
// tell peers we have new stuff they should sync
|
||||
QList<source_ptr> sources = SourceList::instance()->sources();
|
||||
QList< source_ptr > sources = SourceList::instance()->sources();
|
||||
foreach ( const source_ptr& src, sources )
|
||||
{
|
||||
// skip local source
|
||||
@@ -1061,6 +1061,7 @@ Servent::triggerDBSync()
|
||||
if ( src->controlConnection() && src->controlConnection()->dbSyncConnection() ) // source online?
|
||||
src->controlConnection()->dbSyncConnection()->trigger();
|
||||
}
|
||||
emit dbSyncTriggered();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -137,6 +137,7 @@ public:
|
||||
bool isReady() const { return m_ready; };
|
||||
|
||||
signals:
|
||||
void dbSyncTriggered();
|
||||
void streamStarted( StreamConnection* );
|
||||
void streamFinished( StreamConnection* );
|
||||
void ready();
|
||||
|
Reference in New Issue
Block a user