mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 08:34:34 +02:00
Streamline API: source->userName() -> source->nodeId()
This commit is contained in:
@@ -81,7 +81,7 @@ LatchManager::playlistChanged( Tomahawk::playlistinterface_ptr )
|
|||||||
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction();
|
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction();
|
||||||
cmd->setSource( SourceList::instance()->getLocal() );
|
cmd->setSource( SourceList::instance()->getLocal() );
|
||||||
cmd->setAction( "latchOn");
|
cmd->setAction( "latchOn");
|
||||||
cmd->setComment( m_latchedOnTo->userName() );
|
cmd->setComment( m_latchedOnTo->nodeId() );
|
||||||
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
||||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ LatchManager::playlistChanged( Tomahawk::playlistinterface_ptr )
|
|||||||
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction();
|
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction();
|
||||||
cmd->setSource( SourceList::instance()->getLocal() );
|
cmd->setSource( SourceList::instance()->getLocal() );
|
||||||
cmd->setAction( "latchOff");
|
cmd->setAction( "latchOff");
|
||||||
cmd->setComment( source->userName() );
|
cmd->setComment( source->nodeId() );
|
||||||
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
||||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||||
|
|
||||||
|
@@ -46,11 +46,11 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
Source::Source( int id, const QString& username )
|
Source::Source( int id, const QString& nodeId )
|
||||||
: QObject()
|
: QObject()
|
||||||
, m_isLocal( false )
|
, m_isLocal( false )
|
||||||
, m_online( false )
|
, m_online( false )
|
||||||
, m_username( username )
|
, m_nodeId( nodeId )
|
||||||
, m_id( id )
|
, m_id( id )
|
||||||
, m_updateIndexWhenSynced( false )
|
, m_updateIndexWhenSynced( false )
|
||||||
, m_state( DBSyncConnection::UNKNOWN )
|
, m_state( DBSyncConnection::UNKNOWN )
|
||||||
@@ -125,7 +125,7 @@ QString
|
|||||||
Source::friendlyName() const
|
Source::friendlyName() const
|
||||||
{
|
{
|
||||||
if ( m_friendlyname.isEmpty() )
|
if ( m_friendlyname.isEmpty() )
|
||||||
return m_username;
|
return m_nodeId;
|
||||||
|
|
||||||
//TODO: this is a terrible assumption, help me clean this up, mighty muesli!
|
//TODO: this is a terrible assumption, help me clean this up, mighty muesli!
|
||||||
if ( m_friendlyname.contains( "@conference." ) )
|
if ( m_friendlyname.contains( "@conference." ) )
|
||||||
@@ -228,7 +228,7 @@ Source::setOnline()
|
|||||||
if ( !isLocal() )
|
if ( !isLocal() )
|
||||||
{
|
{
|
||||||
// ensure username is in the database
|
// ensure username is in the database
|
||||||
DatabaseCommand_addSource* cmd = new DatabaseCommand_addSource( m_username, friendlyName() );
|
DatabaseCommand_addSource* cmd = new DatabaseCommand_addSource( m_nodeId, friendlyName() );
|
||||||
connect( cmd, SIGNAL( done( unsigned int, QString ) ),
|
connect( cmd, SIGNAL( done( unsigned int, QString ) ),
|
||||||
SLOT( dbLoaded( unsigned int, const QString& ) ) );
|
SLOT( dbLoaded( unsigned int, const QString& ) ) );
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||||
|
@@ -55,13 +55,13 @@ friend class ::DatabaseCommand_DeleteFiles;
|
|||||||
friend class ::MusicScanner;
|
friend class ::MusicScanner;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Source( int id, const QString& username = QString() );
|
explicit Source( int id, const QString& nodeId = QString() );
|
||||||
virtual ~Source();
|
virtual ~Source();
|
||||||
|
|
||||||
bool isLocal() const { return m_isLocal; }
|
bool isLocal() const { return m_isLocal; }
|
||||||
bool isOnline() const { return m_online || m_isLocal; }
|
bool isOnline() const { return m_online || m_isLocal; }
|
||||||
|
|
||||||
QString userName() const { return m_username; }
|
QString nodeId() const { return m_nodeId; }
|
||||||
QString friendlyName() const;
|
QString friendlyName() const;
|
||||||
void setFriendlyName( const QString& fname );
|
void setFriendlyName( const QString& fname );
|
||||||
|
|
||||||
@@ -101,7 +101,6 @@ signals:
|
|||||||
void collectionRemoved( const collection_ptr& collection );
|
void collectionRemoved( const collection_ptr& collection );
|
||||||
|
|
||||||
void stats( const QVariantMap& );
|
void stats( const QVariantMap& );
|
||||||
void usernameChanged( const QString& );
|
|
||||||
|
|
||||||
void playbackStarted( const Tomahawk::query_ptr& query );
|
void playbackStarted( const Tomahawk::query_ptr& query );
|
||||||
void playbackFinished( const Tomahawk::query_ptr& query );
|
void playbackFinished( const Tomahawk::query_ptr& query );
|
||||||
@@ -143,7 +142,7 @@ private:
|
|||||||
|
|
||||||
bool m_isLocal;
|
bool m_isLocal;
|
||||||
bool m_online;
|
bool m_online;
|
||||||
QString m_username;
|
QString m_nodeId;
|
||||||
QString m_friendlyname;
|
QString m_friendlyname;
|
||||||
int m_id;
|
int m_id;
|
||||||
bool m_scrubFriendlyName;
|
bool m_scrubFriendlyName;
|
||||||
|
@@ -111,7 +111,7 @@ SourceList::setLocal( const Tomahawk::source_ptr& localSrc )
|
|||||||
|
|
||||||
{
|
{
|
||||||
QMutexLocker lock( &m_mut );
|
QMutexLocker lock( &m_mut );
|
||||||
m_sources.insert( localSrc->userName(), localSrc );
|
m_sources.insert( localSrc->nodeId(), localSrc );
|
||||||
m_local = localSrc;
|
m_local = localSrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,11 +127,11 @@ SourceList::add( const source_ptr& source )
|
|||||||
{
|
{
|
||||||
Q_ASSERT( m_isReady );
|
Q_ASSERT( m_isReady );
|
||||||
|
|
||||||
// qDebug() << "Adding to sources:" << source->userName() << source->id();
|
// qDebug() << "Adding to sources:" << source->nodeId() << source->id();
|
||||||
m_sources.insert( source->userName(), source );
|
m_sources.insert( source->nodeId(), source );
|
||||||
|
|
||||||
if ( source->id() > 0 )
|
if ( source->id() > 0 )
|
||||||
m_sources_id2name.insert( source->id(), source->userName() );
|
m_sources_id2name.insert( source->id(), source->nodeId() );
|
||||||
connect( source.data(), SIGNAL( syncedWithDatabase() ), SLOT( sourceSynced() ) );
|
connect( source.data(), SIGNAL( syncedWithDatabase() ), SLOT( sourceSynced() ) );
|
||||||
|
|
||||||
collection_ptr coll( new RemoteCollection( source ) );
|
collection_ptr coll( new RemoteCollection( source ) );
|
||||||
@@ -239,7 +239,7 @@ SourceList::sourceSynced()
|
|||||||
{
|
{
|
||||||
Source* src = qobject_cast< Source* >( sender() );
|
Source* src = qobject_cast< Source* >( sender() );
|
||||||
|
|
||||||
m_sources_id2name.insert( src->id(), src->userName() );
|
m_sources_id2name.insert( src->id(), src->nodeId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -254,7 +254,7 @@ void
|
|||||||
SourceList::latchedOff( const source_ptr& to )
|
SourceList::latchedOff( const source_ptr& to )
|
||||||
{
|
{
|
||||||
Source* s = qobject_cast< Source* >( sender() );
|
Source* s = qobject_cast< Source* >( sender() );
|
||||||
const source_ptr source = m_sources[ s->userName() ];
|
const source_ptr source = m_sources[ s->nodeId() ];
|
||||||
|
|
||||||
emit sourceLatchedOff( source, to );
|
emit sourceLatchedOff( source, to );
|
||||||
}
|
}
|
||||||
@@ -264,7 +264,7 @@ SourceList::latchedOn( const source_ptr& to )
|
|||||||
{
|
{
|
||||||
|
|
||||||
Source* s = qobject_cast< Source* >( sender() );
|
Source* s = qobject_cast< Source* >( sender() );
|
||||||
const source_ptr source = m_sources[ s->userName() ];
|
const source_ptr source = m_sources[ s->nodeId() ];
|
||||||
|
|
||||||
emit sourceLatchedOn( source, to );
|
emit sourceLatchedOn( source, to );
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ using namespace Tomahawk;
|
|||||||
|
|
||||||
|
|
||||||
DatabaseCollection::DatabaseCollection( const source_ptr& src, QObject* parent )
|
DatabaseCollection::DatabaseCollection( const source_ptr& src, QObject* parent )
|
||||||
: Collection( src, QString( "dbcollection:%1" ).arg( src->userName() ), parent )
|
: Collection( src, QString( "dbcollection:%1" ).arg( src->nodeId() ), parent )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -112,7 +112,7 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
|
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString artist, track, album, composer;
|
QString artist, track, album, composer;
|
||||||
|
@@ -140,7 +140,7 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
|
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cached = Tomahawk::Result::isCached( url );
|
bool cached = Tomahawk::Result::isCached( url );
|
||||||
@@ -279,7 +279,7 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
|
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cached = Tomahawk::Result::isCached( url );
|
bool cached = Tomahawk::Result::isCached( url );
|
||||||
|
@@ -293,7 +293,7 @@ DatabaseImpl::file( int fid )
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
|
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
r = Tomahawk::Result::get( url );
|
r = Tomahawk::Result::get( url );
|
||||||
@@ -691,7 +691,7 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
|
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
res = Tomahawk::Result::get( url );
|
res = Tomahawk::Result::get( url );
|
||||||
|
@@ -82,7 +82,7 @@ LatchedStatusManager::latchedOn( const Tomahawk::source_ptr& from, const Tomahaw
|
|||||||
{
|
{
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
LatchedStatusItem* item = new LatchedStatusItem( from, to, this );
|
LatchedStatusItem* item = new LatchedStatusItem( from, to, this );
|
||||||
m_jobs[ from->userName() ] = item;
|
m_jobs[ from->nodeId() ] = item;
|
||||||
JobStatusView::instance()->model()->addJob( item );
|
JobStatusView::instance()->model()->addJob( item );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -96,9 +96,9 @@ LatchedStatusManager::sourceOffline()
|
|||||||
Tomahawk::Source* s = qobject_cast< Tomahawk::Source* >( sender() );
|
Tomahawk::Source* s = qobject_cast< Tomahawk::Source* >( sender() );
|
||||||
Q_ASSERT( s );
|
Q_ASSERT( s );
|
||||||
|
|
||||||
if ( m_jobs.contains( s->userName() ) )
|
if ( m_jobs.contains( s->nodeId() ) )
|
||||||
{
|
{
|
||||||
QPointer< LatchedStatusItem> job = m_jobs.take( s->userName() ).data();
|
QPointer< LatchedStatusItem> job = m_jobs.take( s->nodeId() ).data();
|
||||||
if ( !job.isNull() )
|
if ( !job.isNull() )
|
||||||
job.data()->stop();
|
job.data()->stop();
|
||||||
}
|
}
|
||||||
@@ -111,9 +111,9 @@ LatchedStatusManager::latchedOff( const Tomahawk::source_ptr& from, const Tomaha
|
|||||||
if ( from.isNull() || to.isNull() )
|
if ( from.isNull() || to.isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( to->isLocal() && m_jobs.contains( from->userName() ) )
|
if ( to->isLocal() && m_jobs.contains( from->nodeId() ) )
|
||||||
{
|
{
|
||||||
QPointer< LatchedStatusItem > item = m_jobs.take( from->userName() );
|
QPointer< LatchedStatusItem > item = m_jobs.take( from->nodeId() );
|
||||||
if ( !item.isNull() )
|
if ( !item.isNull() )
|
||||||
item.data()->stop();
|
item.data()->stop();
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,7 @@ AlbumModel::addCollection( const collection_ptr& collection, bool overwrite )
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << collection->name()
|
qDebug() << Q_FUNC_INFO << collection->name()
|
||||||
<< collection->source()->id()
|
<< collection->source()->id()
|
||||||
<< collection->source()->userName();
|
<< collection->source()->nodeId();
|
||||||
|
|
||||||
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection );
|
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection );
|
||||||
m_overwriteOnAdd = overwrite;
|
m_overwriteOnAdd = overwrite;
|
||||||
@@ -88,7 +88,7 @@ AlbumModel::addFilteredCollection( const collection_ptr& collection, unsigned in
|
|||||||
{
|
{
|
||||||
/* qDebug() << Q_FUNC_INFO << collection->name()
|
/* qDebug() << Q_FUNC_INFO << collection->name()
|
||||||
<< collection->source()->id()
|
<< collection->source()->id()
|
||||||
<< collection->source()->userName()
|
<< collection->source()->nodeId()
|
||||||
<< amount << order;*/
|
<< amount << order;*/
|
||||||
|
|
||||||
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection );
|
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection );
|
||||||
|
@@ -246,7 +246,7 @@ TreeModel::addCollection( const collection_ptr& collection )
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << collection->name()
|
qDebug() << Q_FUNC_INFO << collection->name()
|
||||||
<< collection->source()->id()
|
<< collection->source()->id()
|
||||||
<< collection->source()->userName();
|
<< collection->source()->nodeId();
|
||||||
|
|
||||||
startLoading();
|
startLoading();
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ TreeModel::addFilteredCollection( const collection_ptr& collection, unsigned int
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << collection->name()
|
qDebug() << Q_FUNC_INFO << collection->name()
|
||||||
<< collection->source()->id()
|
<< collection->source()->id()
|
||||||
<< collection->source()->userName()
|
<< collection->source()->nodeId()
|
||||||
<< amount << order;
|
<< amount << order;
|
||||||
|
|
||||||
DatabaseCommand_AllArtists* cmd = new DatabaseCommand_AllArtists( collection );
|
DatabaseCommand_AllArtists* cmd = new DatabaseCommand_AllArtists( collection );
|
||||||
|
@@ -95,7 +95,7 @@ LovedTracksItem::activate()
|
|||||||
else
|
else
|
||||||
raModel->setDescription( tr( "All of %1's loved tracks" ).arg( par->source()->friendlyName() ) );
|
raModel->setDescription( tr( "All of %1's loved tracks" ).arg( par->source()->friendlyName() ) );
|
||||||
|
|
||||||
pv->setGuid( QString( "lovedtracks/%1" ).arg( par->source()->userName() ) );
|
pv->setGuid( QString( "lovedtracks/%1" ).arg( par->source()->nodeId() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
pv->setPlayableModel( raModel );
|
pv->setPlayableModel( raModel );
|
||||||
|
@@ -555,7 +555,7 @@ SourceItem::latestAdditionsClicked()
|
|||||||
pv->setEmptyTip( tr( "Sorry, we could not find any recent additions!" ) );
|
pv->setEmptyTip( tr( "Sorry, we could not find any recent additions!" ) );
|
||||||
raModel->setSource( m_source );
|
raModel->setSource( m_source );
|
||||||
|
|
||||||
pv->setGuid( QString( "latestadditions/%1" ).arg( m_source->userName() ) );
|
pv->setGuid( QString( "latestadditions/%1" ).arg( m_source->nodeId() ) );
|
||||||
|
|
||||||
m_latestAdditionsPage = pv;
|
m_latestAdditionsPage = pv;
|
||||||
}
|
}
|
||||||
@@ -596,7 +596,7 @@ SourceItem::recentPlaysClicked()
|
|||||||
pv->setEmptyTip( tr( "Sorry, we could not find any recent plays!" ) );
|
pv->setEmptyTip( tr( "Sorry, we could not find any recent plays!" ) );
|
||||||
raModel->setSource( m_source );
|
raModel->setSource( m_source );
|
||||||
|
|
||||||
pv->setGuid( QString( "recentplays/%1" ).arg( m_source->userName() ) );
|
pv->setGuid( QString( "recentplays/%1" ).arg( m_source->nodeId() ) );
|
||||||
|
|
||||||
m_recentPlaysPage = pv;
|
m_recentPlaysPage = pv;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user