mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 05:37:29 +02:00
Enable collaboratives
This commit is contained in:
@@ -66,7 +66,8 @@ static QString s_resolverId = "spotify-unknown";
|
|||||||
namespace {
|
namespace {
|
||||||
enum ActionType {
|
enum ActionType {
|
||||||
Sync = 0,
|
Sync = 0,
|
||||||
Subscribe
|
Subscribe = 1,
|
||||||
|
Collaborate
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,6 +446,9 @@ SpotifyAccount::aboutToShow( QAction* action, const playlist_ptr& playlist )
|
|||||||
bool isSubscribed = false;
|
bool isSubscribed = false;
|
||||||
bool manuallyDisabled = false;
|
bool manuallyDisabled = false;
|
||||||
bool sync = false;
|
bool sync = false;
|
||||||
|
bool owner = false;
|
||||||
|
bool collaborative = false;
|
||||||
|
|
||||||
action->setVisible( true );
|
action->setVisible( true );
|
||||||
|
|
||||||
QList<PlaylistUpdaterInterface*> updaters = playlist->updaters();
|
QList<PlaylistUpdaterInterface*> updaters = playlist->updaters();
|
||||||
@@ -456,6 +460,8 @@ SpotifyAccount::aboutToShow( QAction* action, const playlist_ptr& playlist )
|
|||||||
|
|
||||||
canSubscribe = spotifyUpdater->canSubscribe();
|
canSubscribe = spotifyUpdater->canSubscribe();
|
||||||
isSubscribed = spotifyUpdater->subscribed();
|
isSubscribed = spotifyUpdater->subscribed();
|
||||||
|
owner = spotifyUpdater->owner();
|
||||||
|
collaborative = spotifyUpdater->collaborative();
|
||||||
|
|
||||||
if ( !canSubscribe && !spotifyUpdater->sync() )
|
if ( !canSubscribe && !spotifyUpdater->sync() )
|
||||||
manuallyDisabled = true;
|
manuallyDisabled = true;
|
||||||
@@ -521,9 +527,38 @@ SpotifyAccount::aboutToShow( QAction* action, const playlist_ptr& playlist )
|
|||||||
action->setVisible( false );
|
action->setVisible( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the user is owner of current playlist, enable collaboration options
|
||||||
|
if ( actionType == Collaborate )
|
||||||
|
{
|
||||||
|
if( found && owner && !manuallyDisabled )
|
||||||
|
{
|
||||||
|
if( !collaborative )
|
||||||
|
action->setText( tr( "Enable Spotify collaborations" ) );
|
||||||
|
else
|
||||||
|
action->setText( tr( "Disable Spotify collaborations" ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
action->setVisible( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SpotifyPlaylistUpdater*
|
||||||
|
SpotifyAccount::getPlaylistUpdater( const playlist_ptr plptr ){
|
||||||
|
|
||||||
|
SpotifyPlaylistUpdater* updater = 0;
|
||||||
|
QList<PlaylistUpdaterInterface*> updaters = plptr->updaters();
|
||||||
|
foreach ( PlaylistUpdaterInterface* u, updaters )
|
||||||
|
{
|
||||||
|
if ( SpotifyPlaylistUpdater* spotifyUpdater = qobject_cast< SpotifyPlaylistUpdater* >( u ) )
|
||||||
|
{
|
||||||
|
updater = spotifyUpdater;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return updater;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccount::subscribeActionTriggered( bool )
|
SpotifyAccount::subscribeActionTriggered( bool )
|
||||||
{
|
{
|
||||||
@@ -531,21 +566,12 @@ SpotifyAccount::subscribeActionTriggered( bool )
|
|||||||
|
|
||||||
if ( playlist.isNull() )
|
if ( playlist.isNull() )
|
||||||
{
|
{
|
||||||
qWarning() << "Got context menu spotify sync action triggered, but invalid playlist payload!";
|
qWarning() << "Got context menu spotify subscribe action triggered, but invalid playlist payload!";
|
||||||
Q_ASSERT( false );
|
Q_ASSERT( false );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpotifyPlaylistUpdater* updater = 0;
|
SpotifyPlaylistUpdater *updater = getPlaylistUpdater( playlist );
|
||||||
QList<PlaylistUpdaterInterface*> updaters = playlist->updaters();
|
|
||||||
foreach ( PlaylistUpdaterInterface* u, updaters )
|
|
||||||
{
|
|
||||||
if ( SpotifyPlaylistUpdater* spotifyUpdater = qobject_cast< SpotifyPlaylistUpdater* >( u ) )
|
|
||||||
{
|
|
||||||
updater = spotifyUpdater;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_ASSERT( updater );
|
Q_ASSERT( updater );
|
||||||
if ( !updater )
|
if ( !updater )
|
||||||
@@ -556,6 +582,49 @@ SpotifyAccount::subscribeActionTriggered( bool )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SpotifyAccount::collaborateActionTriggered( bool )
|
||||||
|
{
|
||||||
|
const playlist_ptr playlist = playlistFromAction( qobject_cast< QAction* >( sender() ) );
|
||||||
|
|
||||||
|
if ( playlist.isNull() )
|
||||||
|
{
|
||||||
|
qWarning() << "Got context menu spotify collaboration action triggered, but invalid playlist payload!";
|
||||||
|
Q_ASSERT( false );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SpotifyPlaylistUpdater *updater = getPlaylistUpdater( playlist );
|
||||||
|
|
||||||
|
if ( !updater )
|
||||||
|
{
|
||||||
|
tLog() << "No SpotifyPlaylistUpdater in payload slot of triggered action! Uh oh!!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SpotifyPlaylistInfo* info = m_allSpotifyPlaylists.value( updater->spotifyId(), 0 );
|
||||||
|
Q_ASSERT( info );
|
||||||
|
|
||||||
|
if( info->isOwner )
|
||||||
|
{
|
||||||
|
tLog() << info->name << info->isOwner << info->plid << updater->owner() << updater->collaborative();
|
||||||
|
QVariantMap msg;
|
||||||
|
msg[ "_msgtype" ] = "setCollaborative";
|
||||||
|
msg[ "collaborative" ] = !updater->collaborative();
|
||||||
|
msg[ "playlistid" ] = info->plid;
|
||||||
|
|
||||||
|
sendMessage( msg, this );
|
||||||
|
updater->setCollaborative( !updater->collaborative() );
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tLog() << "cant set collab for this pl, not owner!?" << info->name << info->plid;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccount::syncActionTriggered( bool )
|
SpotifyAccount::syncActionTriggered( bool )
|
||||||
{
|
{
|
||||||
@@ -568,15 +637,7 @@ SpotifyAccount::syncActionTriggered( bool )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpotifyPlaylistUpdater* updater = 0;
|
SpotifyPlaylistUpdater *updater = getPlaylistUpdater( playlist );
|
||||||
QList<PlaylistUpdaterInterface*> updaters = playlist->updaters();
|
|
||||||
foreach ( PlaylistUpdaterInterface* u, updaters )
|
|
||||||
{
|
|
||||||
if ( SpotifyPlaylistUpdater* spotifyUpdater = qobject_cast< SpotifyPlaylistUpdater* >( u ) )
|
|
||||||
{
|
|
||||||
updater = spotifyUpdater;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !updater || updater->canSubscribe() )
|
if ( !updater || updater->canSubscribe() )
|
||||||
{
|
{
|
||||||
@@ -629,16 +690,7 @@ SpotifyAccount::syncActionTriggered( bool )
|
|||||||
void
|
void
|
||||||
SpotifyAccount::setSubscribedForPlaylist( const playlist_ptr& playlist, bool subscribed )
|
SpotifyAccount::setSubscribedForPlaylist( const playlist_ptr& playlist, bool subscribed )
|
||||||
{
|
{
|
||||||
SpotifyPlaylistUpdater* updater = 0;
|
SpotifyPlaylistUpdater *updater = getPlaylistUpdater( playlist );
|
||||||
QList<PlaylistUpdaterInterface*> updaters = playlist->updaters();
|
|
||||||
foreach ( PlaylistUpdaterInterface* u, updaters )
|
|
||||||
{
|
|
||||||
if ( SpotifyPlaylistUpdater* spotifyUpdater = qobject_cast< SpotifyPlaylistUpdater* >( u ) )
|
|
||||||
{
|
|
||||||
updater = spotifyUpdater;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !updater )
|
if ( !updater )
|
||||||
{
|
{
|
||||||
@@ -752,6 +804,7 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
|
|||||||
const QString name = plMap.value( "name" ).toString();
|
const QString name = plMap.value( "name" ).toString();
|
||||||
const QString plid = plMap.value( "id" ).toString();
|
const QString plid = plMap.value( "id" ).toString();
|
||||||
const QString revid = plMap.value( "revid" ).toString();
|
const QString revid = plMap.value( "revid" ).toString();
|
||||||
|
const bool isOwner = plMap.value( "owner" ).toBool();
|
||||||
const bool sync = plMap.value( "sync" ).toBool();
|
const bool sync = plMap.value( "sync" ).toBool();
|
||||||
const bool subscribed = plMap.value( "subscribed" ).toBool();
|
const bool subscribed = plMap.value( "subscribed" ).toBool();
|
||||||
|
|
||||||
@@ -761,7 +814,7 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
registerPlaylistInfo( new SpotifyPlaylistInfo( name, plid, revid, sync, subscribed ) );
|
registerPlaylistInfo( new SpotifyPlaylistInfo( name, plid, revid, sync, subscribed, isOwner ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_configWidget.isNull() )
|
if ( !m_configWidget.isNull() )
|
||||||
@@ -1095,10 +1148,12 @@ void
|
|||||||
SpotifyAccount::startPlaylistSyncWithPlaylist( const QString& msgType, const QVariantMap& msg, const QVariant& )
|
SpotifyAccount::startPlaylistSyncWithPlaylist( const QString& msgType, const QVariantMap& msg, const QVariant& )
|
||||||
{
|
{
|
||||||
Q_UNUSED( msgType );
|
Q_UNUSED( msgType );
|
||||||
qDebug() << Q_FUNC_INFO << "Got full spotify playlist body, creating a tomahawk playlist and enabling sync!!";
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Got full spotify playlist body, creating a tomahawk playlist and enabling sync!!";
|
||||||
const QString id = msg.value( "id" ).toString();
|
const QString id = msg.value( "id" ).toString();
|
||||||
const QString name = msg.value( "name" ).toString();
|
const QString name = msg.value( "name" ).toString();
|
||||||
const QString revid = msg.value( "revid" ).toString();
|
const QString revid = msg.value( "revid" ).toString();
|
||||||
|
const bool collaborative = msg.value( "collaborative" ).toBool();
|
||||||
|
const bool owner = msg.value( "owner" ).toBool();
|
||||||
|
|
||||||
qDebug() << "Starting sync with pl:" << id << name;
|
qDebug() << "Starting sync with pl:" << id << name;
|
||||||
QVariantList tracks = msg.value( "tracks" ).toList();
|
QVariantList tracks = msg.value( "tracks" ).toList();
|
||||||
@@ -1134,6 +1189,8 @@ SpotifyAccount::startPlaylistSyncWithPlaylist( const QString& msgType, const QVa
|
|||||||
|
|
||||||
SpotifyPlaylistUpdater* updater = new SpotifyPlaylistUpdater( this, revid, id, plPtr );
|
SpotifyPlaylistUpdater* updater = new SpotifyPlaylistUpdater( this, revid, id, plPtr );
|
||||||
updater->setSync( true );
|
updater->setSync( true );
|
||||||
|
updater->setOwner( owner );
|
||||||
|
updater->setCollaborative( collaborative );
|
||||||
m_updaters[ id ] = updater;
|
m_updaters[ id ] = updater;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1228,9 +1285,9 @@ SpotifyAccount::registerUpdaterForPlaylist( const QString& plId, SpotifyPlaylist
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccount::registerPlaylistInfo( const QString& name, const QString& plid, const QString &revid, const bool sync, const bool subscribed )
|
SpotifyAccount::registerPlaylistInfo( const QString& name, const QString& plid, const QString &revid, const bool sync, const bool subscribed, const bool owner )
|
||||||
{
|
{
|
||||||
m_allSpotifyPlaylists[ plid ] = new SpotifyPlaylistInfo( name, plid, revid, sync, subscribed );
|
m_allSpotifyPlaylists[ plid ] = new SpotifyPlaylistInfo( name, plid, revid, sync, subscribed, owner );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1339,6 +1396,13 @@ SpotifyAccount::createActions()
|
|||||||
subscribeAction->setData( Subscribe );
|
subscribeAction->setData( Subscribe );
|
||||||
m_customActions.append( subscribeAction );
|
m_customActions.append( subscribeAction );
|
||||||
|
|
||||||
|
QAction* collaborateAction = new QAction( 0 );
|
||||||
|
collaborateAction->setIcon( QIcon( RESPATH "images/spotify-logo.png" ) );
|
||||||
|
connect( collaborateAction, SIGNAL( triggered( bool ) ), this, SLOT( collaborateActionTriggered( bool ) ) );
|
||||||
|
ActionCollection::instance()->addAction( ActionCollection::LocalPlaylists, collaborateAction, this );
|
||||||
|
collaborateAction->setData( Collaborate );
|
||||||
|
m_customActions.append( collaborateAction );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -50,11 +50,11 @@ class SpotifyAccountConfig;
|
|||||||
// metadata for a playlist
|
// metadata for a playlist
|
||||||
struct SpotifyPlaylistInfo {
|
struct SpotifyPlaylistInfo {
|
||||||
QString name, plid, revid;
|
QString name, plid, revid;
|
||||||
bool sync, subscribed, changed;
|
bool sync, subscribed, changed, isOwner;
|
||||||
|
|
||||||
|
|
||||||
SpotifyPlaylistInfo( const QString& nname, const QString& pid, const QString& rrevid, bool ssync, bool ssubscribed )
|
SpotifyPlaylistInfo( const QString& nname, const QString& pid, const QString& rrevid, bool ssync, bool ssubscribed, bool isowner = false )
|
||||||
: name( nname ), plid( pid ), revid( rrevid ), sync( ssync ), subscribed( ssubscribed ), changed( false ) {}
|
: name( nname ), plid( pid ), revid( rrevid ), sync( ssync ), subscribed( ssubscribed ), isOwner( isowner ), changed( false ) {}
|
||||||
|
|
||||||
SpotifyPlaylistInfo() : sync( false ), changed( false ) {}
|
SpotifyPlaylistInfo() : sync( false ), changed( false ) {}
|
||||||
};
|
};
|
||||||
@@ -103,7 +103,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
void registerUpdaterForPlaylist( const QString& plId, SpotifyPlaylistUpdater* updater );
|
void registerUpdaterForPlaylist( const QString& plId, SpotifyPlaylistUpdater* updater );
|
||||||
void registerPlaylistInfo( const QString& name, const QString& plid, const QString &revid, const bool sync, const bool subscribed );
|
void registerPlaylistInfo(const QString& name, const QString& plid, const QString &revid, const bool sync, const bool subscribed , const bool owner = false);
|
||||||
void registerPlaylistInfo( SpotifyPlaylistInfo* info );
|
void registerPlaylistInfo( SpotifyPlaylistInfo* info );
|
||||||
void unregisterUpdater( const QString& plid );
|
void unregisterUpdater( const QString& plid );
|
||||||
|
|
||||||
@@ -120,6 +120,7 @@ public slots:
|
|||||||
void syncActionTriggered( bool );
|
void syncActionTriggered( bool );
|
||||||
void subscribeActionTriggered( bool );
|
void subscribeActionTriggered( bool );
|
||||||
void atticaLoaded(Attica::Content::List);
|
void atticaLoaded(Attica::Content::List);
|
||||||
|
void collaborateActionTriggered( bool );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void resolverChanged();
|
void resolverChanged();
|
||||||
@@ -157,7 +158,7 @@ private:
|
|||||||
void createActions();
|
void createActions();
|
||||||
void removeActions();
|
void removeActions();
|
||||||
playlist_ptr playlistFromAction( QAction* action ) const;
|
playlist_ptr playlistFromAction( QAction* action ) const;
|
||||||
|
SpotifyPlaylistUpdater* getPlaylistUpdater( const playlist_ptr plptr);
|
||||||
static SpotifyAccount* s_instance;
|
static SpotifyAccount* s_instance;
|
||||||
|
|
||||||
QWeakPointer<SpotifyAccountConfig> m_configWidget;
|
QWeakPointer<SpotifyAccountConfig> m_configWidget;
|
||||||
|
@@ -60,12 +60,15 @@ SpotifyUpdaterFactory::create( const Tomahawk::playlist_ptr& pl, const QVariantH
|
|||||||
const bool sync = settings.value( "sync" ).toBool();
|
const bool sync = settings.value( "sync" ).toBool();
|
||||||
const bool canSubscribe = settings.value( "canSubscribe" ).toBool();
|
const bool canSubscribe = settings.value( "canSubscribe" ).toBool();
|
||||||
const bool isSubscribed = settings.value( "subscribed" ).toBool();
|
const bool isSubscribed = settings.value( "subscribed" ).toBool();
|
||||||
|
const bool isOwner = settings.value( "isOwner" ).toBool();
|
||||||
|
const bool isCollaborative = settings.value( "collaborative" ).toBool();
|
||||||
Q_ASSERT( !spotifyId.isEmpty() );
|
Q_ASSERT( !spotifyId.isEmpty() );
|
||||||
SpotifyPlaylistUpdater* updater = new SpotifyPlaylistUpdater( m_account.data(), latestRev, spotifyId, pl );
|
SpotifyPlaylistUpdater* updater = new SpotifyPlaylistUpdater( m_account.data(), latestRev, spotifyId, pl );
|
||||||
updater->setSync( sync );
|
updater->setSync( sync );
|
||||||
updater->setCanSubscribe( canSubscribe );
|
updater->setCanSubscribe( canSubscribe );
|
||||||
updater->setSubscribedStatus( isSubscribed );
|
updater->setSubscribedStatus( isSubscribed );
|
||||||
|
updater->setOwner( isOwner );
|
||||||
|
updater->setCollaborative( isCollaborative );
|
||||||
m_account.data()->registerUpdaterForPlaylist( spotifyId, updater );
|
m_account.data()->registerUpdaterForPlaylist( spotifyId, updater );
|
||||||
|
|
||||||
return updater;
|
return updater;
|
||||||
@@ -81,6 +84,8 @@ SpotifyPlaylistUpdater::SpotifyPlaylistUpdater( SpotifyAccount* acct, const QStr
|
|||||||
, m_sync( false )
|
, m_sync( false )
|
||||||
, m_canSubscribe( false )
|
, m_canSubscribe( false )
|
||||||
, m_subscribed( false )
|
, m_subscribed( false )
|
||||||
|
, m_isOwner( false )
|
||||||
|
, m_collaborative( false )
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -177,7 +182,8 @@ SpotifyPlaylistUpdater::saveToSettings()
|
|||||||
s[ "canSubscribe" ] = m_canSubscribe;
|
s[ "canSubscribe" ] = m_canSubscribe;
|
||||||
s[ "subscribed" ] = m_subscribed;
|
s[ "subscribed" ] = m_subscribed;
|
||||||
s[ "spotifyId" ] = m_spotifyId;
|
s[ "spotifyId" ] = m_spotifyId;
|
||||||
|
s[ "isOwner" ] = m_isOwner;
|
||||||
|
s[ "collaborative" ] = m_collaborative;
|
||||||
saveSettings( s );
|
saveSettings( s );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,6 +232,41 @@ SpotifyPlaylistUpdater::sync() const
|
|||||||
return m_sync;
|
return m_sync;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SpotifyPlaylistUpdater::setOwner( bool owner )
|
||||||
|
{
|
||||||
|
if ( m_isOwner == owner )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_isOwner = owner;
|
||||||
|
|
||||||
|
saveToSettings();
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SpotifyPlaylistUpdater::owner() const
|
||||||
|
{
|
||||||
|
return m_isOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SpotifyPlaylistUpdater::setCollaborative( bool collab )
|
||||||
|
{
|
||||||
|
if ( m_collaborative == collab )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_collaborative = collab;
|
||||||
|
|
||||||
|
saveToSettings();
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SpotifyPlaylistUpdater::collaborative() const
|
||||||
|
{
|
||||||
|
return m_collaborative;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyPlaylistUpdater::setSubscribedStatus( bool subscribed )
|
SpotifyPlaylistUpdater::setSubscribedStatus( bool subscribed )
|
||||||
|
@@ -62,6 +62,12 @@ public:
|
|||||||
void setSubscribedStatus( bool subscribed );
|
void setSubscribedStatus( bool subscribed );
|
||||||
bool canSubscribe() const;
|
bool canSubscribe() const;
|
||||||
void setCanSubscribe( bool canSub );
|
void setCanSubscribe( bool canSub );
|
||||||
|
// Collaborative actions
|
||||||
|
void setOwner( bool owner );
|
||||||
|
bool owner() const;
|
||||||
|
bool collaborative() const;
|
||||||
|
void setCollaborative( bool collaborative );
|
||||||
|
|
||||||
QString spotifyId() const { return m_spotifyId; }
|
QString spotifyId() const { return m_spotifyId; }
|
||||||
|
|
||||||
virtual bool hasCustomDeleter() const { return true; }
|
virtual bool hasCustomDeleter() const { return true; }
|
||||||
@@ -110,6 +116,9 @@ private:
|
|||||||
bool m_sync;
|
bool m_sync;
|
||||||
bool m_subscribed;
|
bool m_subscribed;
|
||||||
bool m_canSubscribe;
|
bool m_canSubscribe;
|
||||||
|
bool m_isOwner;
|
||||||
|
bool m_collaborative;
|
||||||
|
|
||||||
QQueue<_detail::Closure*> m_queuedOps;
|
QQueue<_detail::Closure*> m_queuedOps;
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
static QPixmap* s_typePixmap;
|
static QPixmap* s_typePixmap;
|
||||||
|
@@ -45,6 +45,7 @@ SpotifyParser::SpotifyParser( const QStringList& Urls, bool createNewPlaylist, Q
|
|||||||
, m_limit ( 40 )
|
, m_limit ( 40 )
|
||||||
, m_single( false )
|
, m_single( false )
|
||||||
, m_trackMode( true )
|
, m_trackMode( true )
|
||||||
|
, m_collaborative( false )
|
||||||
, m_createNewPlaylist( createNewPlaylist )
|
, m_createNewPlaylist( createNewPlaylist )
|
||||||
, m_browseJob( 0 )
|
, m_browseJob( 0 )
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ SpotifyParser::SpotifyParser( const QString& Url, bool createNewPlaylist, QObjec
|
|||||||
, m_limit ( 40 )
|
, m_limit ( 40 )
|
||||||
, m_single( true )
|
, m_single( true )
|
||||||
, m_trackMode( true )
|
, m_trackMode( true )
|
||||||
|
, m_collaborative( false )
|
||||||
, m_createNewPlaylist( createNewPlaylist )
|
, m_createNewPlaylist( createNewPlaylist )
|
||||||
, m_browseJob( 0 )
|
, m_browseJob( 0 )
|
||||||
{
|
{
|
||||||
@@ -328,6 +330,7 @@ SpotifyParser::playlistListingResult( const QString& msgType, const QVariantMap&
|
|||||||
m_title = msg.value( "name" ).toString();
|
m_title = msg.value( "name" ).toString();
|
||||||
m_single = false;
|
m_single = false;
|
||||||
m_creator = msg.value( "creator" ).toString();
|
m_creator = msg.value( "creator" ).toString();
|
||||||
|
m_collaborative = msg.value( "collaborative" ).toBool();
|
||||||
|
|
||||||
const QVariantList tracks = msg.value( "tracks" ).toList();
|
const QVariantList tracks = msg.value( "tracks" ).toList();
|
||||||
foreach ( const QVariant& blob, tracks )
|
foreach ( const QVariant& blob, tracks )
|
||||||
@@ -390,12 +393,16 @@ SpotifyParser::checkBrowseFinished()
|
|||||||
// If the user isnt dropping a playlist the he owns, its subscribeable
|
// If the user isnt dropping a playlist the he owns, its subscribeable
|
||||||
if ( !m_browseUri.contains( spotifyUsername ) )
|
if ( !m_browseUri.contains( spotifyUsername ) )
|
||||||
updater->setCanSubscribe( true );
|
updater->setCanSubscribe( true );
|
||||||
|
else
|
||||||
|
updater->setOwner( true );
|
||||||
|
|
||||||
|
updater->setCollaborative( m_collaborative );
|
||||||
|
|
||||||
// Just register the infos
|
// Just register the infos
|
||||||
Accounts::SpotifyAccount::instance()->registerPlaylistInfo( m_title, m_browseUri, m_browseUri, false, false );
|
Accounts::SpotifyAccount::instance()->registerPlaylistInfo( m_title, m_browseUri, m_browseUri, false, false, updater->owner() );
|
||||||
Accounts::SpotifyAccount::instance()->registerUpdaterForPlaylist( m_browseUri, updater );
|
Accounts::SpotifyAccount::instance()->registerUpdaterForPlaylist( m_browseUri, updater );
|
||||||
|
// On default, set the playlist as subscribed
|
||||||
|
if( !updater->owner() )
|
||||||
Accounts::SpotifyAccount::instance()->setSubscribedForPlaylist( m_playlist, true );
|
Accounts::SpotifyAccount::instance()->setSubscribedForPlaylist( m_playlist, true );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -85,6 +85,7 @@ private:
|
|||||||
bool m_single;
|
bool m_single;
|
||||||
bool m_trackMode;
|
bool m_trackMode;
|
||||||
bool m_createNewPlaylist;
|
bool m_createNewPlaylist;
|
||||||
|
bool m_collaborative;
|
||||||
QList< query_ptr > m_tracks;
|
QList< query_ptr > m_tracks;
|
||||||
QSet< QNetworkReply* > m_queries;
|
QSet< QNetworkReply* > m_queries;
|
||||||
QString m_title, m_info, m_creator;
|
QString m_title, m_info, m_creator;
|
||||||
|
Reference in New Issue
Block a user