1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-07 06:36:55 +02:00

fixes for linux binary ghns

This commit is contained in:
Leo Franchi
2012-05-17 20:56:36 -04:00
parent b4dda21704
commit 841b151acc
5 changed files with 42 additions and 11 deletions

View File

@@ -40,6 +40,7 @@
#include <QAction> #include <QAction>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel> #include <QLabel>
#include <QMessageBox>
using namespace Tomahawk; using namespace Tomahawk;
using namespace Accounts; using namespace Accounts;
@@ -52,7 +53,7 @@ static QString s_resolverId = "spotify-osx";
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
static QString s_resolverId = "spotify-win"; static QString s_resolverId = "spotify-win";
#else #else
static QString s_resolverId = "spotify-linux" static QString s_resolverId = "spotify-linux";
#endif #endif
Account* Account*
@@ -74,6 +75,7 @@ SpotifyAccountFactory::icon() const
SpotifyAccount::SpotifyAccount( const QString& accountId ) SpotifyAccount::SpotifyAccount( const QString& accountId )
: CustomAtticaAccount( accountId ) : CustomAtticaAccount( accountId )
, m_preventEnabling( false )
{ {
init(); init();
} }
@@ -204,6 +206,22 @@ SpotifyAccount::authenticate()
qDebug() << "Got null resolver but asked to authenticate, so installing if we have one from attica:" << res.isValid() << res.id(); qDebug() << "Got null resolver but asked to authenticate, so installing if we have one from attica:" << res.isValid() << res.id();
if ( res.isValid() && !res.id().isEmpty() ) if ( res.isValid() && !res.id().isEmpty() )
AtticaManager::instance()->installResolver( res, false ); AtticaManager::instance()->installResolver( res, false );
else
{
#ifdef Q_OS_LINUX
// Can't install from attica yet on linux, so show a warning if the user tries to turn it on.
// TODO make a prettier display
QMessageBox box;
box.setWindowTitle( tr( "Manual Install Required" ) );
box.setTextFormat( Qt::RichText );
box.setIcon( QMessageBox::Information );
box.setText( tr( "Unfortunately, automatic installation of the Spotify resolver is not yet available on Linux.<br /><br />"
"Please use \"Install from file\" above, by fetching it from your distribution or compiling it yourself. Further instructions can be found here:<br /><br />http://www.tomahawk-player.org/resolvers/spotify" ) );
box.setStandardButtons( QMessageBox::Ok );
box.exec();
#endif
m_preventEnabling = true;
}
} }
else if ( !m_spotifyResolver.data()->running() ) else if ( !m_spotifyResolver.data()->running() )
{ {
@@ -263,11 +281,13 @@ SpotifyAccount::setManualResolverPath( const QString &resolverPath )
{ {
Q_ASSERT( !resolverPath.isEmpty() ); Q_ASSERT( !resolverPath.isEmpty() );
QVariantHash configuration; QVariantHash conf = configuration();
configuration[ "resolverPath" ] = resolverPath; conf[ "resolverPath" ] = resolverPath;
setConfiguration( configuration ); setConfiguration( conf );
sync(); sync();
m_preventEnabling = false;
if ( !m_spotifyResolver.isNull() ) if ( !m_spotifyResolver.isNull() )
{ {
// replace // replace
@@ -278,17 +298,17 @@ SpotifyAccount::setManualResolverPath( const QString &resolverPath )
else else
{ {
hookupResolver(); hookupResolver();
authenticate(); AccountManager::instance()->enableAccount( this );
} }
} }
void void
SpotifyAccount::hookupAfterDeletion( bool autostart ) SpotifyAccount::hookupAfterDeletion( bool autoEnable )
{ {
hookupResolver(); hookupResolver();
if ( autostart ) if ( autoEnable )
authenticate(); AccountManager::instance()->enableAccount( this );
} }

View File

@@ -90,6 +90,7 @@ public:
virtual QWidget* aclWidget() { return 0; } virtual QWidget* aclWidget() { return 0; }
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); } virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() { return Tomahawk::InfoSystem::InfoPluginPtr(); }
virtual SipPlugin* sipPlugin() { return 0; } virtual SipPlugin* sipPlugin() { return 0; }
virtual bool preventEnabling() const { return m_preventEnabling; }
QString sendMessage( const QVariantMap& msg, QObject* receiver = 0, const QString& slot = QString() ); QString sendMessage( const QVariantMap& msg, QObject* receiver = 0, const QString& slot = QString() );
@@ -118,7 +119,7 @@ private slots:
void playlistCreated( const QString& msgType, const QVariantMap& msg ); void playlistCreated( const QString& msgType, const QVariantMap& msg );
void init(); void init();
void hookupAfterDeletion( bool autostart ); void hookupAfterDeletion( bool autoEnable );
private: private:
bool checkForResolver(); bool checkForResolver();
@@ -148,6 +149,8 @@ private:
QHash< QString, playlist_ptr > m_waitingForCreateReply; QHash< QString, playlist_ptr > m_waitingForCreateReply;
bool m_preventEnabling;
SmartPointerList< QAction > m_customActions; SmartPointerList< QAction > m_customActions;
friend class ::SpotifyPlaylistUpdater; friend class ::SpotifyPlaylistUpdater;
}; };

View File

@@ -102,6 +102,10 @@ public:
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() = 0; virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() = 0;
virtual SipPlugin* sipPlugin() = 0; virtual SipPlugin* sipPlugin() = 0;
// Some accounts cannot be enabled if authentication fails. Return true after failing to authenticate
// if this is the case, and the account will not be enabled
virtual bool preventEnabling() const { return false; }
AccountTypes types() const; AccountTypes types() const;
void setAccountServiceName( const QString &serviceName ) { QMutexLocker locker( &m_mutex ); m_accountServiceName = serviceName; } void setAccountServiceName( const QString &serviceName ) { QMutexLocker locker( &m_mutex ); m_accountServiceName = serviceName; }

View File

@@ -202,6 +202,9 @@ AccountManager::enableAccount( Account* account )
account->authenticate(); account->authenticate();
if ( account->preventEnabling() )
return;
account->setEnabled( true ); account->setEnabled( true );
m_enabledAccounts << account; m_enabledAccounts << account;

View File

@@ -616,7 +616,8 @@ AccountModel::accountStateChanged( Account* account , Account::ConnectionState )
// For each type that this node could be, check the corresponding data // For each type that this node could be, check the corresponding data
if ( ( n->type == AccountModelNode::UniqueFactoryType && n->accounts.size() && n->accounts.first() == account ) || if ( ( n->type == AccountModelNode::UniqueFactoryType && n->accounts.size() && n->accounts.first() == account ) ||
( n->type == AccountModelNode::AtticaType && n->atticaAccount && n->atticaAccount == account ) || ( n->type == AccountModelNode::AtticaType && n->atticaAccount && n->atticaAccount == account ) ||
( n->type == AccountModelNode::ManualResolverType && n->resolverAccount && n->resolverAccount == account ) ) ( n->type == AccountModelNode::ManualResolverType && n->resolverAccount && n->resolverAccount == account ) ||
( n->type == AccountModelNode::CustomAccountType && n->customAccount && n->customAccount == account ) )
{ {
const QModelIndex idx = index( i, 0, QModelIndex() ); const QModelIndex idx = index( i, 0, QModelIndex() );
emit dataChanged( idx, idx ); emit dataChanged( idx, idx );