mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-25 02:09:48 +01:00
Add migration from pre-accounts to accounts, and fix twitter in various places
This commit is contained in:
parent
811b6842c5
commit
a78ef004f0
@ -59,7 +59,7 @@ TwitterSipPlugin::TwitterSipPlugin( Tomahawk::Accounts::Account* account )
|
||||
|
||||
connect( account, SIGNAL( nowAuthenticated( const QWeakPointer< TomahawkOAuthTwitter > &, const QTweetUser & ) ), SLOT( accountAuthenticated( const QWeakPointer< TomahawkOAuthTwitter > &, const QTweetUser & ) ) );
|
||||
|
||||
if ( Database::instance()->dbid() != m_configuration[ "saveddbid" ].toString() )
|
||||
if ( Database::instance()->dbid() != m_account->configuration()[ "saveddbid" ].toString() )
|
||||
{
|
||||
m_configuration[ "cachedpeers" ] = QVariantHash();
|
||||
m_configuration[ "saveddbid" ] = Database::instance()->dbid();
|
||||
@ -158,7 +158,7 @@ TwitterSipPlugin::accountAuthenticated( const QWeakPointer< TomahawkOAuthTwitter
|
||||
{
|
||||
Q_UNUSED( user );
|
||||
|
||||
if ( !isValid() )
|
||||
if ( !m_account->enabled() || !m_account->isAuthenticated() )
|
||||
return;
|
||||
|
||||
m_cachedTwitterAuth = twitterAuth;
|
||||
@ -702,3 +702,11 @@ TwitterSipPlugin::configurationChanged()
|
||||
m_account->deauthenticate();
|
||||
connectPlugin();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TwitterSipPlugin::syncConfig()
|
||||
{
|
||||
m_account->setConfiguration( m_configuration );
|
||||
m_account->sync();
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ private slots:
|
||||
void profilePicReply();
|
||||
|
||||
private:
|
||||
inline void syncConfig() { m_account->setCredentials( m_credentials ); m_account->setConfiguration( m_configuration ); m_account->sync(); }
|
||||
void syncConfig();
|
||||
bool refreshTwitterAuth();
|
||||
void parseGotTomahawk( const QRegExp ®ex, const QString &screenName, const QString &text );
|
||||
|
||||
@ -110,7 +110,6 @@ private:
|
||||
QWeakPointer< QTweetDirectMessageDestroy > m_directMessageDestroy;
|
||||
|
||||
QVariantHash m_configuration;
|
||||
QVariantHash m_credentials;
|
||||
|
||||
QTimer m_checkTimer;
|
||||
QTimer m_connectTimer;
|
||||
|
@ -47,12 +47,8 @@ TwitterAccount::TwitterAccount( const QString &accountId )
|
||||
: Account( accountId )
|
||||
, m_isAuthenticated( false )
|
||||
{
|
||||
loadFromConfig( accountId );
|
||||
|
||||
setAccountServiceName( "Twitter" );
|
||||
QSet< AccountType > types;
|
||||
types << InfoType << SipType;
|
||||
setTypes( types );
|
||||
setTypes( QSet< AccountType >() << InfoType << SipType );
|
||||
|
||||
m_configWidget = QWeakPointer< TwitterConfigWidget >( new TwitterConfigWidget( this, 0 ) );
|
||||
connect( m_configWidget.data(), SIGNAL( twitterAuthed( bool ) ), SLOT( configDialogAuthedSignalSlot( bool ) ) );
|
||||
@ -167,6 +163,10 @@ TwitterAccount::connectAuthVerifyReply( const QTweetUser &user )
|
||||
config[ "screenname" ] = user.screenName();
|
||||
setConfiguration( config );
|
||||
sync();
|
||||
|
||||
sipPlugin()->connectPlugin();
|
||||
|
||||
m_isAuthenticated = true;
|
||||
emit nowAuthenticated( m_twitterAuth, user );
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ TwitterConfigWidget::TwitterConfigWidget( TwitterAccount* account, QWidget *pare
|
||||
m_ui->twitterTweetGotTomahawkButton->setText( tr( "Tweet!" ) );
|
||||
|
||||
QVariantHash credentials = m_account->credentials();
|
||||
|
||||
|
||||
if ( credentials[ "oauthtoken" ].toString().isEmpty() ||
|
||||
credentials[ "oauthtokensecret" ].toString().isEmpty() ||
|
||||
credentials[ "username" ].toString().isEmpty() )
|
||||
@ -131,7 +131,7 @@ TwitterConfigWidget::authenticateVerifyReply( const QTweetUser &user )
|
||||
configuration[ "sipcachedfriendssinceid" ] = 0;
|
||||
configuration[ "sipcachedmentionssinceid" ] = 0;
|
||||
m_account->setConfiguration( configuration );
|
||||
|
||||
|
||||
m_ui->twitterStatusLabel->setText( tr( "Status: Credentials saved for %1" ).arg( user.screenName() ) );
|
||||
m_ui->twitterAuthenticateButton->setText( tr( "De-authenticate" ) );
|
||||
m_ui->twitterSyncGroupBox->setVisible( true );
|
||||
@ -202,7 +202,7 @@ TwitterConfigWidget::startPostGotTomahawkStatus()
|
||||
|
||||
qDebug() << "Posting Got Tomahawk status";
|
||||
QVariantHash credentials = m_account->credentials();
|
||||
|
||||
|
||||
if ( credentials[ "oauthtoken" ].toString().isEmpty() ||
|
||||
credentials[ "oauthtokensecret" ].toString().isEmpty() ||
|
||||
credentials[ "username" ].toString().isEmpty() )
|
||||
|
@ -54,7 +54,7 @@ signals:
|
||||
void twitterAuthed( bool authed );
|
||||
|
||||
void sizeHintChanged();
|
||||
|
||||
|
||||
private slots:
|
||||
void authDeauthTwitter();
|
||||
void startPostGotTomahawkStatus();
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
virtual ~GoogleWrapperFactory() {}
|
||||
|
||||
virtual QString prettyName() const { return "Google"; }
|
||||
virtual QString factoryId() const { return "sipgoogle"; }
|
||||
virtual QString factoryId() const { return "googleaccount"; }
|
||||
virtual QIcon icon() const;
|
||||
virtual Account* createAccount( const QString& pluginId );
|
||||
};
|
||||
|
@ -40,8 +40,6 @@ XmppAccountFactory::createAccount( const QString& accountId )
|
||||
XmppAccount::XmppAccount( const QString &accountId )
|
||||
: Account( accountId )
|
||||
{
|
||||
loadFromConfig( accountId );
|
||||
|
||||
setAccountServiceName( "XMPP (Jabber)" );
|
||||
QSet< AccountType > types;
|
||||
types << SipType;
|
||||
|
@ -65,6 +65,8 @@ ZeroconfAccount::ZeroconfAccount( const QString& accountId )
|
||||
{
|
||||
setAccountServiceName( "Local Network" );
|
||||
setAccountFriendlyName( "Local Network" );
|
||||
|
||||
setTypes( QSet< AccountType >() << SipType );
|
||||
}
|
||||
|
||||
ZeroconfAccount::~ZeroconfAccount()
|
||||
|
@ -33,6 +33,8 @@ Account::Account( const QString& accountId )
|
||||
{
|
||||
connect( this, SIGNAL( error( int, QString ) ), this, SLOT( onError( int,QString ) ) );
|
||||
connect( this, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) , this, SLOT( onConnectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) );
|
||||
|
||||
loadFromConfig( accountId );
|
||||
}
|
||||
|
||||
QWidget*
|
||||
@ -77,8 +79,10 @@ Account::isAuthenticated() const
|
||||
|
||||
|
||||
void
|
||||
Account::onError(int errorCode, const QString& error )
|
||||
Account::onError( int errorCode, const QString& error )
|
||||
{
|
||||
Q_UNUSED( errorCode );
|
||||
|
||||
QMutexLocker locker( &m_mutex );
|
||||
m_cachedError = error;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public slots:
|
||||
virtual void setShuffled( bool enabled ) = 0;
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011 Leo Franchi <lfranchi@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -29,7 +30,7 @@
|
||||
#include "database/databasecommand_updatesearchindex.h"
|
||||
#include "database/database.h"
|
||||
|
||||
#define VERSION 5
|
||||
#define VERSION 6
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@ -111,7 +112,7 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
|
||||
|
||||
setValue( QString( "%1_legacy/username" ).arg( sipName ), value( "jabber/username" ) );
|
||||
setValue( QString( "%1_legacy/password" ).arg( sipName ), value( "jabber/password" ) );
|
||||
setValue( QString( "%1r_legacy/autoconnect" ).arg( sipName ), value( "jabber/autoconnect" ) );
|
||||
setValue( QString( "%1_legacy/autoconnect" ).arg( sipName ), value( "jabber/autoconnect" ) );
|
||||
setValue( QString( "%1_legacy/port" ).arg( sipName ), value( "jabber/port" ) );
|
||||
setValue( QString( "%1_legacy/server" ).arg( sipName ), value( "jabber/server" ) );
|
||||
|
||||
@ -187,6 +188,75 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
|
||||
{
|
||||
// 0.3.0 contained a bug which prevent indexing local files. Force a reindex.
|
||||
QTimer::singleShot( 0, this, SLOT( updateIndex() ) );
|
||||
} else if ( oldVersion == 5 )
|
||||
{
|
||||
// Migrate to accounts from sipplugins.
|
||||
// collect old connected and enabled sip plugins
|
||||
const QStringList allSip = sipPlugins();
|
||||
const QStringList enabledSip = enabledSipPlugins();
|
||||
|
||||
QStringList accounts;
|
||||
foreach ( const QString& sipPlugin, allSip )
|
||||
{
|
||||
const QStringList parts = sipPlugin.split( "_" );
|
||||
Q_ASSERT( parts.size() == 2 );
|
||||
|
||||
const QString pluginName = parts[ 0 ];
|
||||
const QString pluginId = parts[ 1 ];
|
||||
|
||||
// new key, <plugin>account_<id>
|
||||
QString rawpluginname = pluginName;
|
||||
rawpluginname.replace( "sip", "" );
|
||||
if ( rawpluginname.contains( "jabber" ) )
|
||||
rawpluginname.replace( "jabber", "xmpp" );
|
||||
|
||||
QString accountKey = QString( "%1account_%2" ).arg( rawpluginname ).arg( pluginId );
|
||||
accounts << accountKey;
|
||||
|
||||
beginGroup( "accounts/" + accountKey );
|
||||
setValue( "enabled", enabledSip.contains( sipPlugin ) == true );
|
||||
setValue( "autoconnect", true );
|
||||
setValue( "configuration", QVariantHash() );
|
||||
setValue( "acl", QVariantMap() );
|
||||
setValue( "types", QStringList() << "SipType" );
|
||||
endGroup();
|
||||
if ( pluginName == "sipjabber" || pluginName == "sipgoogle" )
|
||||
{
|
||||
QVariantHash credentials;
|
||||
credentials[ "username" ] = value( sipPlugin + "/username" );
|
||||
credentials[ "password" ] = value( sipPlugin + "/password" );
|
||||
credentials[ "port" ] = value( sipPlugin + "/port" );
|
||||
credentials[ "server" ] = value( sipPlugin + "/server" );
|
||||
|
||||
setValue( QString( "accounts/%1/credentials" ).arg( accountKey ), credentials );
|
||||
setValue( QString( "accounts/%1/accountfriendlyname" ).arg( accountKey ), value( sipPlugin + "/username" ) );
|
||||
|
||||
}
|
||||
else if ( pluginName == "siptwitter" )
|
||||
{
|
||||
QVariantHash credentials;
|
||||
credentials[ "cachedfriendssinceid" ] = value( sipPlugin + "/cachedfriendssinceid" );
|
||||
credentials[ "cacheddirectmessagessinceid" ] = value( sipPlugin + "/cacheddirectmessagessinceid" );
|
||||
credentials[ "cachedpeers" ] = value( sipPlugin + "/cachedpeers" );
|
||||
credentials[ "oauthtoken" ] = value( sipPlugin + "/oauthtoken" );
|
||||
credentials[ "oauthtokensecret" ] = value( sipPlugin + "/oauthtokensecret" );
|
||||
credentials[ "cachedmentionssinceid" ] = value( sipPlugin + "/cachedmentionssinceid" );
|
||||
credentials[ "username" ] = value( sipPlugin + "/screenname" );
|
||||
credentials[ "saveddbid" ] = value( sipPlugin + "/saveddbid" );
|
||||
|
||||
setValue( QString( "accounts/%1/credentials" ).arg( accountKey ), credentials );
|
||||
setValue( QString( "accounts/%1/accountfriendlyname" ).arg( accountKey ), "@" + value( sipPlugin + "/screenname" ).toString() );
|
||||
}
|
||||
else if ( pluginName == "sipzeroconf" )
|
||||
{
|
||||
setValue( QString( "accounts/%1/accountfriendlyname" ).arg( accountKey ), "Local Network" );
|
||||
}
|
||||
|
||||
|
||||
remove( sipPlugin );
|
||||
}
|
||||
setValue( "accounts/allaccounts", accounts );
|
||||
remove( "sip" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011 Leo Franchi <lfranchi@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
Loading…
x
Reference in New Issue
Block a user