1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 07:49:42 +01:00

Revert "Enable Subscribing on SpotifyPlaylists"

Looks fine but holding off until post-0.5.0 is tagged as I would like to test it quite thoroughly :)

This reverts commit 8401befe6b30674721518ef18cc17cc03cd2908d.
This commit is contained in:
Leo Franchi 2012-06-12 23:26:13 +02:00
parent 8401befe6b
commit d18439b4ae
6 changed files with 24 additions and 180 deletions

View File

@ -47,7 +47,6 @@ using namespace Accounts;
static QPixmap* s_icon = 0;
SpotifyAccount* SpotifyAccount::s_instance = 0;
#ifdef Q_OS_MAC
static QString s_resolverId = "spotify-osx";
@ -82,10 +81,10 @@ SpotifyAccount::SpotifyAccount( const QString& accountId )
: CustomAtticaAccount( accountId )
, m_preventEnabling( false )
{
s_instance = this;
init();
}
SpotifyAccount::~SpotifyAccount()
{
clearUser();
@ -347,12 +346,9 @@ SpotifyAccount::aboutToShow( QAction* action, const playlist_ptr& playlist )
if ( !m_customActions.contains( action ) )
return;
// If it's not being synced, allow the option to sync
bool found = false;
bool manuallyDisabled = false;
bool canSubscribe = false;
bool isSubscribed = false;
QList<PlaylistUpdaterInterface*> updaters = playlist->updaters();
foreach ( PlaylistUpdaterInterface* updater, updaters )
{
@ -362,42 +358,21 @@ SpotifyAccount::aboutToShow( QAction* action, const playlist_ptr& playlist )
if ( !spotifyUpdater->sync() )
manuallyDisabled = true;
canSubscribe = spotifyUpdater->canSubscribe();
isSubscribed = spotifyUpdater->subscribed();
qDebug() << "canSub " << canSubscribe << " is Sub " << isSubscribed << "isSibb " << spotifyUpdater->subscribed();
}
}
if ( !found )
{
action->setText( tr( "Sync with Spotify" ) );
action->setProperty( "type", Sync );
}
else if ( manuallyDisabled && !canSubscribe )
else if ( manuallyDisabled )
{
action->setText( tr( "Re-enable syncing with Spotify" ) );
action->setProperty( "type", Sync );
}
else if ( canSubscribe && !isSubscribed )
{
action->setText( tr( "Subscribe with Spotify" ) );
action->setProperty( "type", Subscribe );
}
else
{
if ( canSubscribe )
{
action->setText( tr( "Stop Subscribing with Spotify" ) );
action->setProperty( "type", UnSubscribe);
}
else
{
action->setText( tr( "Stop syncing with Spotify" ) );
action->setProperty( "type", UnSync);
}
action->setText( tr( "Stop syncing with Spotify" ) );
}
}
@ -456,95 +431,21 @@ SpotifyAccount::syncActionTriggered( bool checked )
}
}
if ( info )
{
qDebug() << "Found info!";
info->sync = !updater->sync();
info->subscribe = !updater->sync();
}
else if( action->property("type").toInt() == Subscribe | UnSubscribe )
{
qDebug() << "ADDING PLAYLIST INFO!";
info = new SpotifyPlaylistInfo( playlist->title(), updater->spotifyId(), updater->spotifyId(), true, false );
}
Q_ASSERT( info );
if ( info )
info->sync = !updater->sync();
if ( m_configWidget.data() )
m_configWidget.data()->setPlaylists( m_allSpotifyPlaylists );
switch( action->property("type").toInt() )
if ( !updater->sync() )
{
case Sync:
startPlaylistSync( info );
break;
case UnSync:
stopPlaylistSync( info, true );
break;
case Subscribe:
qDebug() << "Got subscribe!";
startPlaylistSubscribe( info );
break;
case UnSubscribe:
qDebug() << "Got UNsubscribe!";
stopPlaylistSubscribe( info );
break;
default:
qDebug() << "I DONNO WHAT TO DO";
break;
startPlaylistSync( info );
}
else
{
stopPlaylistSync( info, true );
}
}
}
void
SpotifyAccount::stopPlaylistSubscribe( SpotifyPlaylistInfo* playlist )
{
qDebug() << Q_FUNC_INFO;
if ( !playlist )
return;
QVariantMap msg;
msg[ "_msgtype" ] = "setSubscription";
msg[ "playlistid" ] = playlist->plid;
msg[ "subscribed" ] = false;
sendMessage( msg, 0, "setSubscription" );
if ( m_updaters.contains( playlist->plid ) )
{
SpotifyPlaylistUpdater* updater = m_updaters[ playlist->plid ];
updater->setSubscribe( false );
updater->save();
}
}
void
SpotifyAccount::startPlaylistSubscribe( SpotifyPlaylistInfo* playlist )
{
qDebug() << Q_FUNC_INFO;
if ( !playlist )
return;
QVariantMap msg;
msg[ "_msgtype" ] = "setSubscription";
msg[ "playlistid" ] = playlist->plid;
msg[ "subscribed" ] = true;
sendMessage( msg, 0, "setSubscription" );
if ( m_updaters.contains( playlist->plid ) )
{
SpotifyPlaylistUpdater* updater = m_updaters[ playlist->plid ];
updater->setSubscribe( true );
updater->save();
}
}
@ -594,13 +495,13 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
const QString plid = plMap.value( "id" ).toString();
const QString revid = plMap.value( "revid" ).toString();
const bool sync = plMap.value( "sync" ).toBool();
const bool subscribe = plMap.value( "subscribe" ).toBool();
if ( name.isNull() || plid.isNull() || revid.isNull() )
{
qDebug() << "Did not get name and plid and revid for spotify playlist:" << name << plid << revid << plMap;
continue;
}
m_allSpotifyPlaylists << new SpotifyPlaylistInfo( name, plid, revid, sync, subscribe );
m_allSpotifyPlaylists << new SpotifyPlaylistInfo( name, plid, revid, sync );
}
if ( !m_configWidget.isNull() )
@ -895,6 +796,7 @@ SpotifyAccount::startPlaylistSync( SpotifyPlaylistInfo* playlist )
sendMessage( msg, this, "startPlaylistSyncWithPlaylist" );
}
void
SpotifyAccount::startPlaylistSyncWithPlaylist( const QString& msgType, const QVariantMap& msg )
{

View File

@ -42,13 +42,13 @@ class SpotifyAccountConfig;
// metadata for a playlist
struct SpotifyPlaylistInfo {
QString name, plid, revid;
bool sync, changed, subscribe;
bool sync, changed;
SpotifyPlaylistInfo( const QString& nname, const QString& pid, const QString& rrevid, bool ssync, bool ssubscribe )
: name( nname ), plid( pid ), revid( rrevid ), sync( ssync ), changed( false ), subscribe( ssubscribe ) {}
SpotifyPlaylistInfo( const QString& nname, const QString& pid, const QString& rrevid, bool ssync )
: name( nname ), plid( pid ), revid( rrevid ), sync( ssync ), changed( false ) {}
SpotifyPlaylistInfo() : sync( false ), changed( false ), subscribe( false ) {}
SpotifyPlaylistInfo() : sync( false ), changed( false ) {}
};
@ -78,10 +78,6 @@ public:
SpotifyAccount( const QString& accountId, const QString& path );
virtual ~SpotifyAccount();
static SpotifyAccount* instance() {
return s_instance;
}
virtual QPixmap icon() const;
virtual QWidget* configurationWidget();
virtual QWidget* aboutWidget();
@ -98,9 +94,12 @@ public:
virtual bool preventEnabling() const { return m_preventEnabling; }
QString sendMessage( const QVariantMap& msg, QObject* receiver = 0, const QString& slot = QString() );
void registerUpdaterForPlaylist( const QString& plId, SpotifyPlaylistUpdater* updater );
void unregisterUpdater( const QString& plid );
bool deleteOnUnsync() const;
void setManualResolverPath( const QString& resolverPath );
public slots:
@ -134,21 +133,9 @@ private:
void startPlaylistSync( SpotifyPlaylistInfo* playlist );
void stopPlaylistSync( SpotifyPlaylistInfo* playlist, bool forceDontDelete = false );
void fetchFullPlaylist( SpotifyPlaylistInfo* playlist );
void setSyncForPlaylist( const QString& spotifyPlaylistId, bool sync );
void stopPlaylistSubscribe( SpotifyPlaylistInfo* playlist );
void startPlaylistSubscribe( SpotifyPlaylistInfo* playlist );
enum Actions{
None = 0x01,
Subscribe = 0x02,
Sync = 0x04,
UnSubscribe = 0x06,
UnSync = 0x08
};
Actions m_action;
void createActions();
void removeActions();
@ -168,8 +155,6 @@ private:
SmartPointerList< QAction > m_customActions;
friend class ::SpotifyPlaylistUpdater;
static SpotifyAccount* s_instance;
};
}

View File

@ -74,7 +74,6 @@ SpotifyPlaylistUpdater::SpotifyPlaylistUpdater( SpotifyAccount* acct, const QStr
, m_spotifyId( spotifyId )
, m_blockUpdatesForNextRevision( false )
, m_sync( false )
, m_subscribe( false )
{
init();
}
@ -195,14 +194,13 @@ SpotifyPlaylistUpdater::type() const
QPixmap
SpotifyPlaylistUpdater::typeIcon() const
{
if ( !s_typePixmap )
{
QPixmap pm( RESPATH "images/spotify-logo.png" );
s_typePixmap = new QPixmap( pm.scaled( 32, 32, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
}
if( !m_sync )
if ( !m_sync )
return QPixmap();
return *s_typePixmap;
@ -222,17 +220,6 @@ SpotifyPlaylistUpdater::setSync( bool sync )
emit changed();
}
void
SpotifyPlaylistUpdater::setSubscribe( bool sub )
{
if ( m_subscribe == sub )
return;
m_subscribe = sub;
saveToSettings();
emit changed();
}
bool
SpotifyPlaylistUpdater::sync() const
@ -240,14 +227,6 @@ SpotifyPlaylistUpdater::sync() const
return m_sync;
}
bool
SpotifyPlaylistUpdater::canSubscribe()
{
qDebug() << " canSubscribe " << m_spotify.data()->credentials().value( "username" ).toString() << m_spotifyId;
return !m_spotifyId.contains( m_spotify.data()->credentials().value( "username" ).toString() );
}
void
SpotifyPlaylistUpdater::spotifyTracksAdded( const QVariantList& tracks, const QString& startPosId, const QString& newRev, const QString& oldRev )

View File

@ -53,9 +53,6 @@ public:
bool sync() const;
void setSync( bool sync );
bool canSubscribe();
void setSubscribe( bool sub );
bool subscribed() { return m_subscribe; }
QString spotifyId() const { return m_spotifyId; }
@ -102,8 +99,6 @@ private:
bool m_blockUpdatesForNextRevision;
bool m_sync;
bool m_subscribe;
bool m_canSubscribe;
QQueue<_detail::Closure*> m_queuedOps;
#ifndef ENABLE_HEADLESS

View File

@ -116,7 +116,6 @@ SpotifyParser::lookupSpotifyBrowse( const QString& linkRaw )
type = DropJob::Track;
QUrl url;
m_browseId = browseUri;
if( type != DropJob::Artist )
url = QUrl( QString( SPOTIFY_PLAYLIST_API_URL "/browse/%1" ).arg( browseUri ) );
@ -303,8 +302,6 @@ SpotifyParser::checkBrowseFinished()
if( m_createNewPlaylist && !m_tracks.isEmpty() )
{
m_playlist = Playlist::create( SourceList::instance()->getLocal(),
uuid(),
m_title,
@ -312,18 +309,6 @@ SpotifyParser::checkBrowseFinished()
m_creator,
false,
m_tracks );
if( Tomahawk::Accounts::SpotifyAccount::instance() != 0 )
{
qDebug() << "FOUND SPOTIFY ACCOUNT!!" << Tomahawk::Accounts::SpotifyAccount::instance()->credentials().value("username") << Tomahawk::Accounts::SpotifyAccount::instance()->isAuthenticated();
SpotifyPlaylistUpdater* updater = new SpotifyPlaylistUpdater( Tomahawk::Accounts::SpotifyAccount::instance(), m_browseId, m_browseId, m_playlist );
updater->setSync( true );
updater->setSubscribe( false );
Tomahawk::Accounts::SpotifyAccount::instance()->registerUpdaterForPlaylist( m_browseId, updater);
}
connect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( playlistCreated() ) );
return;
}

View File

@ -28,8 +28,6 @@
#include <QObject>
#include <QSet>
#include <QtCore/QStringList>
#include "accounts/spotify/SpotifyAccount.h"
#include "accounts/spotify/SpotifyPlaylistUpdater.h"
#define SPOTIFY_PLAYLIST_API_URL "http://spotikea.tomahawk-player.org"
@ -86,7 +84,7 @@ private:
QString m_title, m_info, m_creator;
Tomahawk::playlist_ptr m_playlist;
DropJobNotifier* m_browseJob;
QString m_browseId;
static QPixmap* s_pixmap;
};