1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-22 00:42:04 +02:00

* Keep an internal last op guid for DbSyncConnection.

This commit is contained in:
Christian Muehlhaeuser 2011-01-06 12:19:44 +01:00
parent 64ebd68c1d
commit 395a1a58c2
3 changed files with 13 additions and 12 deletions

View File

@ -173,7 +173,7 @@ DatabaseImpl::file( int fid )
m["bitrate"] = query.value( 6 ).toInt();
m["artistid"] = query.value( 7 ).toInt();
m["albumid"] = query.value( 8 ).toInt();
m["trackid"] = query.value( 8 ).toInt();
m["trackid"] = query.value( 9 ).toInt();
m["artist"] = query.value( 10 ).toString();
m["album"] = query.value( 11 ).toString();
m["track"] = query.value( 12 ).toString();

View File

@ -14,13 +14,12 @@
#include <QDebug>
#include "source.h"
#include "database/database.h"
#include "database/databasecommand.h"
#include "database/databasecommand_collectionstats.h"
#include "database/databasecommand_loadops.h"
#include "remotecollection.h"
#include "source.h"
#include "sourcelist.h"
// close the dbsync connection after this much inactivity.
@ -60,7 +59,7 @@ void
DBSyncConnection::idleTimeout()
{
qDebug() << Q_FUNC_INFO << "*************";
shutdown(true);
shutdown( true );
}
@ -155,11 +154,13 @@ void
DBSyncConnection::gotThemCache( const QVariantMap& m )
{
m_themcache = m;
qDebug() << "Sending a FETCHOPS cmd since:" << m.value("lastop").toString();
changeState(FETCHING);
qDebug() << "Sending a FETCHOPS cmd since:" << m_themcache.value( "lastop" ).toString();
QVariantMap msg;
msg.insert( "method", "fetchops" );
msg.insert( "lastop", m_themcache.value("lastop").toString() );
msg.insert( "lastop", m_themcache.value( "lastop" ).toString() );
sendMsg( msg );
}
@ -190,9 +191,6 @@ DBSyncConnection::handleMsg( msg_ptr msg )
Q_ASSERT( msg->is( Msg::JSON ) );
QVariantMap m = msg->json().toMap();
//qDebug() << ">>>>" << m;
if( m.empty() )
{
qDebug() << "Failed to parse msg in dbsync";
@ -256,13 +254,14 @@ DBSyncConnection::sendOps()
{
qDebug() << Q_FUNC_INFO;
const QString sinceguid = m_uscache.value( "lastop" ).toString();
if ( m_lastSentOp.isEmpty() )
m_lastSentOp = m_uscache.value( "lastop" ).toString();
qDebug() << "Will send peer all ops since" << sinceguid;
qDebug() << "Will send peer all ops since" << m_lastSentOp;
source_ptr src = SourceList::instance()->getLocal();
DatabaseCommand_loadOps* cmd = new DatabaseCommand_loadOps( src, sinceguid );
DatabaseCommand_loadOps* cmd = new DatabaseCommand_loadOps( src, m_lastSentOp );
connect( cmd, SIGNAL( done( QString, QList< dbop_ptr > ) ),
this, SLOT( sendOpsData( QString, QList< dbop_ptr > ) ) );

View File

@ -60,6 +60,8 @@ private:
QVariantMap m_us, m_uscache, m_themcache;
State m_state;
QString m_lastSentOp;
QTimer m_timer;
};