From 395a1a58c2d444770d43f56a70083d1b6631d407 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 6 Jan 2011 12:19:44 +0100 Subject: [PATCH] * Keep an internal last op guid for DbSyncConnection. --- src/libtomahawk/database/databaseimpl.cpp | 2 +- src/libtomahawk/network/dbsyncconnection.cpp | 21 ++++++++++---------- src/libtomahawk/network/dbsyncconnection.h | 2 ++ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/libtomahawk/database/databaseimpl.cpp b/src/libtomahawk/database/databaseimpl.cpp index 85264628c..bce48c5aa 100644 --- a/src/libtomahawk/database/databaseimpl.cpp +++ b/src/libtomahawk/database/databaseimpl.cpp @@ -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(); diff --git a/src/libtomahawk/network/dbsyncconnection.cpp b/src/libtomahawk/network/dbsyncconnection.cpp index 6f0ebdd8f..342e55939 100644 --- a/src/libtomahawk/network/dbsyncconnection.cpp +++ b/src/libtomahawk/network/dbsyncconnection.cpp @@ -14,13 +14,12 @@ #include -#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 > ) ) ); diff --git a/src/libtomahawk/network/dbsyncconnection.h b/src/libtomahawk/network/dbsyncconnection.h index 2a888ce97..b6e8b72ec 100644 --- a/src/libtomahawk/network/dbsyncconnection.h +++ b/src/libtomahawk/network/dbsyncconnection.h @@ -60,6 +60,8 @@ private: QVariantMap m_us, m_uscache, m_themcache; State m_state; + QString m_lastSentOp; + QTimer m_timer; };