mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
* Make sure we always access dbimpl's mutex-protected.
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include "TomahawkSettings.h"
|
#include "TomahawkSettings.h"
|
||||||
#include "utils/TomahawkUtils.h"
|
#include "utils/TomahawkUtils.h"
|
||||||
#include "database/Database.h"
|
#include "database/Database.h"
|
||||||
|
#include "database/DatabaseImpl.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
|
|
||||||
#include "TomahawkOAuthTwitter.h"
|
#include "TomahawkOAuthTwitter.h"
|
||||||
@@ -241,7 +242,7 @@ TwitterConfigWidget::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &use
|
|||||||
connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postGotTomahawkStatusUpdateReply(const QTweetStatus &) ) );
|
connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postGotTomahawkStatusUpdateReply(const QTweetStatus &) ) );
|
||||||
connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
|
connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
|
||||||
QString uuid = QUuid::createUuid();
|
QString uuid = QUuid::createUuid();
|
||||||
QString message = QString( "Got Tomahawk? {" ) + Database::instance()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) + QString( " http://gettomahawk.com" );
|
QString message = QString( "Got Tomahawk? {" ) + Database::instance()->impl()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) + QString( " http://gettomahawk.com" );
|
||||||
if ( m_postGTtype == "@Mention" )
|
if ( m_postGTtype == "@Mention" )
|
||||||
{
|
{
|
||||||
QString user = m_ui->twitterUserTweetLineEdit->text();
|
QString user = m_ui->twitterUserTweetLineEdit->text();
|
||||||
@@ -257,7 +258,7 @@ TwitterConfigWidget::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &use
|
|||||||
connect( statUpdate, SIGNAL( parsedDirectMessage(const QTweetDMStatus &)), SLOT( postGotTomahawkDirectMessageReply(const QTweetDMStatus &) ) );
|
connect( statUpdate, SIGNAL( parsedDirectMessage(const QTweetDMStatus &)), SLOT( postGotTomahawkDirectMessageReply(const QTweetDMStatus &) ) );
|
||||||
connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
|
connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
|
||||||
QString uuid = QUuid::createUuid();
|
QString uuid = QUuid::createUuid();
|
||||||
QString message = QString( "Got Tomahawk? {" ) + Database::instance()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) + QString( " http://gettomahawk.com" );
|
QString message = QString( "Got Tomahawk? {" ) + Database::instance()->impl()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) + QString( " http://gettomahawk.com" );
|
||||||
QString user = m_ui->twitterUserTweetLineEdit->text();
|
QString user = m_ui->twitterUserTweetLineEdit->text();
|
||||||
if ( user.startsWith( "@" ) )
|
if ( user.startsWith( "@" ) )
|
||||||
user.remove( 0, 1 );
|
user.remove( 0, 1 );
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
#include <utils/TomahawkUtils.h>
|
#include <utils/TomahawkUtils.h>
|
||||||
#include <TomahawkSettings.h>
|
#include <TomahawkSettings.h>
|
||||||
#include <database/Database.h>
|
#include <database/Database.h>
|
||||||
|
#include <database/DatabaseImpl.h>
|
||||||
#include <network/Servent.h>
|
#include <network/Servent.h>
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
|
|
||||||
@@ -63,10 +64,10 @@ TwitterSipPlugin::TwitterSipPlugin( Tomahawk::Accounts::Account* account )
|
|||||||
|
|
||||||
m_configuration = account->configuration();
|
m_configuration = account->configuration();
|
||||||
qDebug() << "SIP configuration:" << m_configuration << m_configuration[ "cachedpeers" ];
|
qDebug() << "SIP configuration:" << m_configuration << m_configuration[ "cachedpeers" ];
|
||||||
if ( Database::instance()->dbid() != m_account->configuration()[ "saveddbid" ].toString() )
|
if ( Database::instance()->impl()->dbid() != m_account->configuration()[ "saveddbid" ].toString() )
|
||||||
{
|
{
|
||||||
m_configuration[ "cachedpeers" ] = QVariantHash();
|
m_configuration[ "cachedpeers" ] = QVariantHash();
|
||||||
m_configuration[ "saveddbid" ] = Database::instance()->dbid();
|
m_configuration[ "saveddbid" ] = Database::instance()->impl()->dbid();
|
||||||
syncConfig();
|
syncConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +227,7 @@ TwitterSipPlugin::registerOffers( const QStringList &peerList )
|
|||||||
{
|
{
|
||||||
QVariantHash peerData = m_cachedPeers[screenName].toHash();
|
QVariantHash peerData = m_cachedPeers[screenName].toHash();
|
||||||
|
|
||||||
if ( peerData.contains( "onod" ) && peerData["onod"] != Database::instance()->dbid() )
|
if ( peerData.contains( "onod" ) && peerData["onod"] != Database::instance()->impl()->dbid() )
|
||||||
{
|
{
|
||||||
m_cachedPeers.remove( screenName );
|
m_cachedPeers.remove( screenName );
|
||||||
m_configuration[ "cachedpeers" ] = m_cachedPeers;
|
m_configuration[ "cachedpeers" ] = m_cachedPeers;
|
||||||
@@ -313,7 +314,7 @@ TwitterSipPlugin::parseGotTomahawk( const QRegExp ®ex, const QString &screenN
|
|||||||
else
|
else
|
||||||
qDebug() << "TwitterSipPlugin parsed node " << node << " out of the tweet";
|
qDebug() << "TwitterSipPlugin parsed node " << node << " out of the tweet";
|
||||||
|
|
||||||
if ( node == Database::instance()->dbid() )
|
if ( node == Database::instance()->impl()->dbid() )
|
||||||
{
|
{
|
||||||
qDebug() << "My dbid found; ignoring";
|
qDebug() << "My dbid found; ignoring";
|
||||||
return;
|
return;
|
||||||
@@ -489,7 +490,7 @@ TwitterSipPlugin::directMessages( const QList< QTweetDMStatus > &messages )
|
|||||||
|
|
||||||
QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.senderScreenName() ), Q_ARG( QVariantHash, peerData ) );
|
QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.senderScreenName() ), Q_ARG( QVariantHash, peerData ) );
|
||||||
|
|
||||||
if ( Database::instance()->dbid().startsWith( splitNode[1] ) )
|
if ( Database::instance()->impl()->dbid().startsWith( splitNode[1] ) )
|
||||||
{
|
{
|
||||||
qDebug() << "TwitterSipPlugin found message destined for this node; destroying it";
|
qDebug() << "TwitterSipPlugin found message destined for this node; destroying it";
|
||||||
if ( !m_directMessageDestroy.isNull() )
|
if ( !m_directMessageDestroy.isNull() )
|
||||||
@@ -533,12 +534,12 @@ TwitterSipPlugin::registerOffer( const QString &screenName, const QVariantHash &
|
|||||||
|
|
||||||
if ( !_peerData.contains( "okey" ) ||
|
if ( !_peerData.contains( "okey" ) ||
|
||||||
!_peerData.contains( "onod" ) ||
|
!_peerData.contains( "onod" ) ||
|
||||||
( _peerData.contains( "onod" ) && _peerData["onod"] != Database::instance()->dbid() ) )
|
( _peerData.contains( "onod" ) && _peerData["onod"] != Database::instance()->impl()->dbid() ) )
|
||||||
{
|
{
|
||||||
QString okey = QUuid::createUuid().toString().split( '-' ).last();
|
QString okey = QUuid::createUuid().toString().split( '-' ).last();
|
||||||
okey.chop( 1 );
|
okey.chop( 1 );
|
||||||
_peerData["okey"] = QVariant::fromValue< QString >( okey );
|
_peerData["okey"] = QVariant::fromValue< QString >( okey );
|
||||||
_peerData["onod"] = QVariant::fromValue< QString >( Database::instance()->dbid() );
|
_peerData["onod"] = QVariant::fromValue< QString >( Database::instance()->impl()->dbid() );
|
||||||
peersChanged = true;
|
peersChanged = true;
|
||||||
needToAddToCache = true;
|
needToAddToCache = true;
|
||||||
needToSend = true;
|
needToSend = true;
|
||||||
@@ -593,7 +594,7 @@ TwitterSipPlugin::sendOffer( const QString &screenName, const QVariantHash &peer
|
|||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:Node=%3*%4:PKey=%5" ).arg( peerData["ohst"].toString() )
|
QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:Node=%3*%4:PKey=%5" ).arg( peerData["ohst"].toString() )
|
||||||
.arg( peerData["oprt"].toString() )
|
.arg( peerData["oprt"].toString() )
|
||||||
.arg( Database::instance()->dbid() )
|
.arg( Database::instance()->impl()->dbid() )
|
||||||
.arg( peerData["node"].toString().left( 8 ) )
|
.arg( peerData["node"].toString().left( 8 ) )
|
||||||
.arg( peerData["okey"].toString() );
|
.arg( peerData["okey"].toString() );
|
||||||
qDebug() << "TwitterSipPlugin sending message to " << screenName << ": " << offerString;
|
qDebug() << "TwitterSipPlugin sending message to " << screenName << ": " << offerString;
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "database/Database.h"
|
#include "database/Database.h"
|
||||||
|
#include "database/DatabaseImpl.h"
|
||||||
#include "network/Servent.h"
|
#include "network/Servent.h"
|
||||||
#include "accounts/AccountDllMacro.h"
|
#include "accounts/AccountDllMacro.h"
|
||||||
|
|
||||||
@@ -101,14 +102,14 @@ public slots:
|
|||||||
// Keep newer versions first
|
// Keep newer versions first
|
||||||
QByteArray advert = QString( "TOMAHAWKADVERT:%1:%2:%3" )
|
QByteArray advert = QString( "TOMAHAWKADVERT:%1:%2:%3" )
|
||||||
.arg( m_port )
|
.arg( m_port )
|
||||||
.arg( Database::instance()->dbid() )
|
.arg( Database::instance()->impl()->dbid() )
|
||||||
.arg( QHostInfo::localHostName() )
|
.arg( QHostInfo::localHostName() )
|
||||||
.toAscii();
|
.toAscii();
|
||||||
m_sock.writeDatagram( advert.data(), advert.size(),
|
m_sock.writeDatagram( advert.data(), advert.size(),
|
||||||
QHostAddress::Broadcast, ZCONF_PORT );
|
QHostAddress::Broadcast, ZCONF_PORT );
|
||||||
advert = QString( "TOMAHAWKADVERT:%1:%2" )
|
advert = QString( "TOMAHAWKADVERT:%1:%2" )
|
||||||
.arg( m_port )
|
.arg( m_port )
|
||||||
.arg( Database::instance()->dbid() )
|
.arg( Database::instance()->impl()->dbid() )
|
||||||
.toAscii();
|
.toAscii();
|
||||||
m_sock.writeDatagram( advert.data(), advert.size(),
|
m_sock.writeDatagram( advert.data(), advert.size(),
|
||||||
QHostAddress::Broadcast, ZCONF_PORT );
|
QHostAddress::Broadcast, ZCONF_PORT );
|
||||||
@@ -140,7 +141,7 @@ private slots:
|
|||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
int port = parts.at(1).toInt( &ok );
|
int port = parts.at(1).toInt( &ok );
|
||||||
if ( ok && Database::instance()->dbid() != parts.at( 2 ) )
|
if ( ok && Database::instance()->impl()->dbid() != parts.at( 2 ) )
|
||||||
{
|
{
|
||||||
emit tomahawkHostFound( sender.toString(), port, parts.at( 3 ), parts.at( 2 ) );
|
emit tomahawkHostFound( sender.toString(), port, parts.at( 3 ), parts.at( 2 ) );
|
||||||
}
|
}
|
||||||
@@ -149,7 +150,7 @@ private slots:
|
|||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
int port = parts.at(1).toInt( &ok );
|
int port = parts.at(1).toInt( &ok );
|
||||||
if ( ok && Database::instance()->dbid() != parts.at( 2 ) )
|
if ( ok && Database::instance()->impl()->dbid() != parts.at( 2 ) )
|
||||||
{
|
{
|
||||||
qDebug() << "ADVERT received:" << sender << port;
|
qDebug() << "ADVERT received:" << sender << port;
|
||||||
Node *n = new Node( sender.toString(), parts.at( 2 ), port );
|
Node *n = new Node( sender.toString(), parts.at( 2 ), port );
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "Collection.h"
|
#include "Collection.h"
|
||||||
#include "database/Database.h"
|
#include "database/Database.h"
|
||||||
|
#include "database/DatabaseImpl.h"
|
||||||
#include "database/DatabaseCommand_GenericSelect.h"
|
#include "database/DatabaseCommand_GenericSelect.h"
|
||||||
#include "database/DatabaseCommand_SetCollectionAttributes.h"
|
#include "database/DatabaseCommand_SetCollectionAttributes.h"
|
||||||
#include "database/DatabaseCommand_LoadFiles.h"
|
#include "database/DatabaseCommand_LoadFiles.h"
|
||||||
@@ -134,13 +135,14 @@ void
|
|||||||
EchonestCatalogSynchronizer::uploadDb()
|
EchonestCatalogSynchronizer::uploadDb()
|
||||||
{
|
{
|
||||||
// create two catalogs: uuid_song, and uuid_artist.
|
// create two catalogs: uuid_song, and uuid_artist.
|
||||||
QNetworkReply* r = Echonest::Catalog::create( QString( "%1_song" ).arg( Database::instance()->dbid() ), Echonest::CatalogTypes::Song );
|
QNetworkReply* r = Echonest::Catalog::create( QString( "%1_song" ).arg( Database::instance()->impl()->dbid() ), Echonest::CatalogTypes::Song );
|
||||||
connect( r, SIGNAL( finished() ), this, SLOT( songCreateFinished() ) );
|
connect( r, SIGNAL( finished() ), this, SLOT( songCreateFinished() ) );
|
||||||
|
|
||||||
// r = Echonest::Catalog::create( QString( "%1_artist" ).arg( Database::instance()->dbid() ), Echonest::CatalogTypes::Artist );
|
// r = Echonest::Catalog::create( QString( "%1_artist" ).arg( Database::instance()->dbid() ), Echonest::CatalogTypes::Artist );
|
||||||
// connect( r, SIGNAL( finished() ), this, SLOT( artistCreateFinished() ) );
|
// connect( r, SIGNAL( finished() ), this, SLOT( artistCreateFinished() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EchonestCatalogSynchronizer::songCreateFinished()
|
EchonestCatalogSynchronizer::songCreateFinished()
|
||||||
{
|
{
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#include "SourceList.h"
|
#include "SourceList.h"
|
||||||
|
|
||||||
#include "database/Database.h"
|
#include "database/Database.h"
|
||||||
|
#include "database/DatabaseImpl.h"
|
||||||
#include "database/DatabaseCommand_LoadAllSources.h"
|
#include "database/DatabaseCommand_LoadAllSources.h"
|
||||||
#include "network/RemoteCollection.h"
|
#include "network/RemoteCollection.h"
|
||||||
#include "network/ControlConnection.h"
|
#include "network/ControlConnection.h"
|
||||||
@@ -189,7 +190,7 @@ SourceList::get( const QString& username, const QString& friendlyName )
|
|||||||
QMutexLocker lock( &m_mut );
|
QMutexLocker lock( &m_mut );
|
||||||
|
|
||||||
source_ptr source;
|
source_ptr source;
|
||||||
if ( Database::instance()->dbid() == username )
|
if ( Database::instance()->impl()->dbid() == username )
|
||||||
{
|
{
|
||||||
return m_local;
|
return m_local;
|
||||||
}
|
}
|
||||||
|
@@ -144,10 +144,3 @@ Database::impl()
|
|||||||
|
|
||||||
return m_implHash.value( thread );
|
return m_implHash.value( thread );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
|
||||||
Database::dbid() const
|
|
||||||
{
|
|
||||||
return m_impl->dbid();
|
|
||||||
}
|
|
||||||
|
@@ -52,8 +52,6 @@ public:
|
|||||||
explicit Database( const QString& dbname, QObject* parent = 0 );
|
explicit Database( const QString& dbname, QObject* parent = 0 );
|
||||||
~Database();
|
~Database();
|
||||||
|
|
||||||
QString dbid() const;
|
|
||||||
|
|
||||||
void loadIndex();
|
void loadIndex();
|
||||||
bool isReady() const { return m_ready; }
|
bool isReady() const { return m_ready; }
|
||||||
|
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include "Connection.h"
|
#include "Connection.h"
|
||||||
#include "ControlConnection.h"
|
#include "ControlConnection.h"
|
||||||
#include "database/Database.h"
|
#include "database/Database.h"
|
||||||
|
#include "database/DatabaseImpl.h"
|
||||||
#include "StreamConnection.h"
|
#include "StreamConnection.h"
|
||||||
#include "SourceList.h"
|
#include "SourceList.h"
|
||||||
|
|
||||||
@@ -437,7 +438,7 @@ Servent::createParallelConnection( Connection* orig_conn, Connection* new_conn,
|
|||||||
m.insert( "key", tmpkey );
|
m.insert( "key", tmpkey );
|
||||||
m.insert( "offer", key );
|
m.insert( "offer", key );
|
||||||
m.insert( "port", externalPort() );
|
m.insert( "port", externalPort() );
|
||||||
m.insert( "controlid", Database::instance()->dbid() );
|
m.insert( "controlid", Database::instance()->impl()->dbid() );
|
||||||
|
|
||||||
QJson::Serializer ser;
|
QJson::Serializer ser;
|
||||||
orig_conn->sendMsg( Msg::factory( ser.serialize(m), Msg::JSON ) );
|
orig_conn->sendMsg( Msg::factory( ser.serialize(m), Msg::JSON ) );
|
||||||
@@ -527,7 +528,7 @@ Servent::connectToPeer( const QString& ha, int port, const QString &key, const Q
|
|||||||
m["conntype"] = "accept-offer";
|
m["conntype"] = "accept-offer";
|
||||||
m["key"] = key;
|
m["key"] = key;
|
||||||
m["port"] = externalPort();
|
m["port"] = externalPort();
|
||||||
m["nodeid"] = Database::instance()->dbid();
|
m["nodeid"] = Database::instance()->impl()->dbid();
|
||||||
|
|
||||||
conn->setFirstMessage( m );
|
conn->setFirstMessage( m );
|
||||||
if( name.length() )
|
if( name.length() )
|
||||||
@@ -563,7 +564,7 @@ Servent::connectToPeer( const QString& ha, int port, const QString &key, Connect
|
|||||||
m["conntype"] = "accept-offer";
|
m["conntype"] = "accept-offer";
|
||||||
m["key"] = key;
|
m["key"] = key;
|
||||||
m["port"] = externalPort();
|
m["port"] = externalPort();
|
||||||
m["controlid"] = Database::instance()->dbid();
|
m["controlid"] = Database::instance()->impl()->dbid();
|
||||||
conn->setFirstMessage( m );
|
conn->setFirstMessage( m );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,7 +603,7 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& their
|
|||||||
m["conntype"] = "push-offer";
|
m["conntype"] = "push-offer";
|
||||||
m["key"] = theirkey;
|
m["key"] = theirkey;
|
||||||
m["port"] = externalPort();
|
m["port"] = externalPort();
|
||||||
m["controlid"] = Database::instance()->dbid();
|
m["controlid"] = Database::instance()->impl()->dbid();
|
||||||
new_conn->setFirstMessage( m );
|
new_conn->setFirstMessage( m );
|
||||||
createParallelConnection( orig_conn, new_conn, QString() );
|
createParallelConnection( orig_conn, new_conn, QString() );
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include "FuncTimeout.h"
|
#include "FuncTimeout.h"
|
||||||
|
|
||||||
#include "database/Database.h"
|
#include "database/Database.h"
|
||||||
|
#include "database/DatabaseImpl.h"
|
||||||
#include "network/ControlConnection.h"
|
#include "network/ControlConnection.h"
|
||||||
#include "network/Servent.h"
|
#include "network/Servent.h"
|
||||||
#include "SourceList.h"
|
#include "SourceList.h"
|
||||||
@@ -130,7 +131,7 @@ SipHandler::onPeerOnline( const QString& jid )
|
|||||||
QString key = uuid();
|
QString key = uuid();
|
||||||
ControlConnection* conn = new ControlConnection( Servent::instance(), QString() );
|
ControlConnection* conn = new ControlConnection( Servent::instance(), QString() );
|
||||||
|
|
||||||
const QString& nodeid = Database::instance()->dbid();
|
const QString& nodeid = Database::instance()->impl()->dbid();
|
||||||
conn->setName( jid.left( jid.indexOf( "/" ) ) );
|
conn->setName( jid.left( jid.indexOf( "/" ) ) );
|
||||||
conn->setId( nodeid );
|
conn->setId( nodeid );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user