From 39bf8f9f6e30ac8c7a193c8bb6d127b804ccbe61 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Wed, 14 Mar 2012 19:36:35 -0400 Subject: [PATCH] Move spotify and last.fm accounts from libtomahawk to tomahawk/ --- src/CMakeLists.txt | 8 + src/accounts/CMakeLists.txt | 2 +- .../lastfm}/LastFmAccount.cpp | 2 +- .../lastfm}/LastFmAccount.h | 0 .../lastfm}/LastFmConfig.cpp | 0 .../lastfm}/LastFmConfig.h | 0 .../lastfm}/LastFmConfig.ui | 0 .../lastfm}/lastfmplugin.cpp | 2 +- .../lastfm}/lastfmplugin.h | 0 .../spotify}/SpotifyAccount.cpp | 2 +- .../spotify}/SpotifyAccount.h | 2 +- src/accounts/spotify/SpotifyAccountConfig.ui | 199 ++++++++++++++++++ src/libtomahawk/CMakeLists.txt | 6 - src/libtomahawk/accounts/AccountManager.cpp | 16 +- src/libtomahawk/accounts/AccountManager.h | 2 + .../accounts/SpotifyAccountSettings.ui | 21 ++ src/tomahawkapp.cpp | 10 + 17 files changed, 252 insertions(+), 20 deletions(-) rename src/{libtomahawk/accounts => accounts/lastfm}/LastFmAccount.cpp (99%) rename src/{libtomahawk/accounts => accounts/lastfm}/LastFmAccount.h (100%) rename src/{libtomahawk/accounts => accounts/lastfm}/LastFmConfig.cpp (100%) rename src/{libtomahawk/accounts => accounts/lastfm}/LastFmConfig.h (100%) rename src/{libtomahawk/accounts => accounts/lastfm}/LastFmConfig.ui (100%) rename src/{libtomahawk/infosystem/infoplugins/generic => accounts/lastfm}/lastfmplugin.cpp (99%) rename src/{libtomahawk/infosystem/infoplugins/generic => accounts/lastfm}/lastfmplugin.h (100%) rename src/{libtomahawk/accounts => accounts/spotify}/SpotifyAccount.cpp (98%) rename src/{libtomahawk/accounts => accounts/spotify}/SpotifyAccount.h (98%) create mode 100644 src/accounts/spotify/SpotifyAccountConfig.ui create mode 100644 src/libtomahawk/accounts/SpotifyAccountSettings.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8cc5dd1bf..669440e86 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -72,6 +72,12 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui} utils/guihelpers.cpp + accounts/lastfm/LastFmAccount.cpp + accounts/lastfm/LastFmConfig.cpp + accounts/lastfm/lastfmplugin.cpp + + accounts/spotify/SpotifyAccount.cpp + tomahawktrayicon.cpp audiocontrols.cpp settingsdialog.cpp @@ -91,6 +97,8 @@ SET( tomahawkUI ${tomahawkUI} stackedsettingsdialog.ui proxydialog.ui + accounts/lastfm/LastFmConfig.ui + audiocontrols.ui LoadXSPFDialog.ui diff --git a/src/accounts/CMakeLists.txt b/src/accounts/CMakeLists.txt index c7d709337..99fd1814b 100644 --- a/src/accounts/CMakeLists.txt +++ b/src/accounts/CMakeLists.txt @@ -7,4 +7,4 @@ IF( QTWEETLIB_FOUND AND BUILD_GUI ) ADD_SUBDIRECTORY( twitter ) ENDIF() -ADD_SUBDIRECTORY( zeroconf ) \ No newline at end of file +ADD_SUBDIRECTORY( zeroconf ) diff --git a/src/libtomahawk/accounts/LastFmAccount.cpp b/src/accounts/lastfm/LastFmAccount.cpp similarity index 99% rename from src/libtomahawk/accounts/LastFmAccount.cpp rename to src/accounts/lastfm/LastFmAccount.cpp index c2205d6b0..9ceffdce1 100644 --- a/src/libtomahawk/accounts/LastFmAccount.cpp +++ b/src/accounts/lastfm/LastFmAccount.cpp @@ -20,7 +20,7 @@ #include "LastFmConfig.h" #include "infosystem/infosystem.h" -#include "infosystem/infoplugins/generic/lastfmplugin.h" +#include "lastfmplugin.h" #include "utils/tomahawkutils.h" #include "resolvers/qtscriptresolver.h" #include "AtticaManager.h" diff --git a/src/libtomahawk/accounts/LastFmAccount.h b/src/accounts/lastfm/LastFmAccount.h similarity index 100% rename from src/libtomahawk/accounts/LastFmAccount.h rename to src/accounts/lastfm/LastFmAccount.h diff --git a/src/libtomahawk/accounts/LastFmConfig.cpp b/src/accounts/lastfm/LastFmConfig.cpp similarity index 100% rename from src/libtomahawk/accounts/LastFmConfig.cpp rename to src/accounts/lastfm/LastFmConfig.cpp diff --git a/src/libtomahawk/accounts/LastFmConfig.h b/src/accounts/lastfm/LastFmConfig.h similarity index 100% rename from src/libtomahawk/accounts/LastFmConfig.h rename to src/accounts/lastfm/LastFmConfig.h diff --git a/src/libtomahawk/accounts/LastFmConfig.ui b/src/accounts/lastfm/LastFmConfig.ui similarity index 100% rename from src/libtomahawk/accounts/LastFmConfig.ui rename to src/accounts/lastfm/LastFmConfig.ui diff --git a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp b/src/accounts/lastfm/lastfmplugin.cpp similarity index 99% rename from src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp rename to src/accounts/lastfm/lastfmplugin.cpp index 5a9ede354..992cf7a36 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp +++ b/src/accounts/lastfm/lastfmplugin.cpp @@ -28,7 +28,7 @@ #include "audio/audioengine.h" #include "utils/tomahawkutils.h" #include "utils/logger.h" -#include "accounts/LastFmAccount.h" +#include "accounts/lastfm/LastFmAccount.h" #include #include diff --git a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.h b/src/accounts/lastfm/lastfmplugin.h similarity index 100% rename from src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.h rename to src/accounts/lastfm/lastfmplugin.h diff --git a/src/libtomahawk/accounts/SpotifyAccount.cpp b/src/accounts/spotify/SpotifyAccount.cpp similarity index 98% rename from src/libtomahawk/accounts/SpotifyAccount.cpp rename to src/accounts/spotify/SpotifyAccount.cpp index 03f1ba64e..2c750e75c 100644 --- a/src/libtomahawk/accounts/SpotifyAccount.cpp +++ b/src/accounts/spotify/SpotifyAccount.cpp @@ -20,7 +20,7 @@ #include "SpotifyAccount.h" #include "playlist.h" #include "utils/tomahawkutils.h" -#include "PlaylistUpdaterInterface.h" +#include "playlist/PlaylistUpdaterInterface.h" #include "sourcelist.h" #include diff --git a/src/libtomahawk/accounts/SpotifyAccount.h b/src/accounts/spotify/SpotifyAccount.h similarity index 98% rename from src/libtomahawk/accounts/SpotifyAccount.h rename to src/accounts/spotify/SpotifyAccount.h index 723971c69..0bbb5f9b5 100644 --- a/src/libtomahawk/accounts/SpotifyAccount.h +++ b/src/accounts/spotify/SpotifyAccount.h @@ -23,7 +23,7 @@ #include "playlist.h" #include "utils/tomahawkutils.h" #include "sourcelist.h" -#include "ResolverAccount.h" +#include "accounts/ResolverAccount.h" class QTimer; diff --git a/src/accounts/spotify/SpotifyAccountConfig.ui b/src/accounts/spotify/SpotifyAccountConfig.ui new file mode 100644 index 000000000..709a96dc6 --- /dev/null +++ b/src/accounts/spotify/SpotifyAccountConfig.ui @@ -0,0 +1,199 @@ + + + SpotifyConfig + + + + 0 + 0 + 397 + 487 + + + + + 0 + 0 + + + + Form + + + + + + + + + spotify-logo.png + + + Qt::AlignCenter + + + + + + + + + + 16 + 75 + true + + + + Configure your Spotify credentials + + + Qt::PlainText + + + Qt::AlignCenter + + + + + + + + + + + Username: + + + + + + + placeholderUsername + + + + + + + Password: + + + + + + + placeholderPw + + + QLineEdit::Password + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::RightToLeft + + + High Quality Streaming + + + STREAMING_DEFAULT + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + spotifycore-logo.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 9 + + + + This product uses SPOTIFY(R) CORE but is not endorsed, certified or otherwise approved in any way by Spotify. Spotify is the registered trade mark of the Spotify Group. + + + true + + + + + + + + + + diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index e0e73ce14..52d714ad2 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -182,10 +182,6 @@ set( libSources accounts/AccountModel.cpp accounts/AccountModelFilterProxy.cpp accounts/ResolverAccount.cpp - accounts/LastFmAccount.cpp - accounts/LastFmConfig.cpp - accounts/SpotifyAccount.cpp - sip/SipPlugin.cpp sip/SipHandler.cpp sip/sipinfo.cpp @@ -250,7 +246,6 @@ set( libSources infosystem/infosystemworker.cpp infosystem/infoplugins/generic/echonestplugin.cpp - infosystem/infoplugins/generic/lastfmplugin.cpp infosystem/infoplugins/generic/chartsplugin.cpp infosystem/infoplugins/generic/spotifyPlugin.cpp infosystem/infoplugins/generic/hypemPlugin.cpp @@ -311,7 +306,6 @@ set( libUI ${libUI} playlist/queueview.ui context/ContextWidget.ui infobar/infobar.ui - accounts/LastFmConfig.ui ) include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. .. diff --git a/src/libtomahawk/accounts/AccountManager.cpp b/src/libtomahawk/accounts/AccountManager.cpp index df8177bac..1683485e7 100644 --- a/src/libtomahawk/accounts/AccountManager.cpp +++ b/src/libtomahawk/accounts/AccountManager.cpp @@ -21,8 +21,6 @@ #include "config.h" #include "sourcelist.h" #include "ResolverAccount.h" -#include "LastFmAccount.h" -#include "SpotifyAccount.h" #include #include @@ -61,13 +59,6 @@ AccountManager::AccountManager( QObject *parent ) ResolverAccountFactory* f = new ResolverAccountFactory(); m_accountFactories[ f->factoryId() ] = f; registerAccountFactoryForFilesystem( f ); - - LastFmAccountFactory* l = new LastFmAccountFactory(); - m_accountFactories[ l->factoryId() ] = l; - - SpotifyAccountFactory* s = new SpotifyAccountFactory; - m_accountFactories[ s->factoryId() ] = s; - registerAccountFactoryForFilesystem( s ); } @@ -77,6 +68,7 @@ AccountManager::~AccountManager() disconnectAll(); qDeleteAll( m_accounts ); + qDeleteAll( m_accountFactories ); } @@ -360,6 +352,12 @@ AccountManager::registerAccountFactoryForFilesystem( AccountFactory* factory ) } +void +AccountManager::addAccountFactory( AccountFactory* factory ) +{ + m_accountFactories[ factory->factoryId() ] = factory; +} + void AccountManager::hookupAccount( Account* account ) const diff --git a/src/libtomahawk/accounts/AccountManager.h b/src/libtomahawk/accounts/AccountManager.h index acec261d9..16dcf72fc 100644 --- a/src/libtomahawk/accounts/AccountManager.h +++ b/src/libtomahawk/accounts/AccountManager.h @@ -76,6 +76,8 @@ public: */ void registerAccountFactoryForFilesystem( AccountFactory* factory ); + void addAccountFactory( AccountFactory* factory ); + public slots: void connectAll(); void disconnectAll(); diff --git a/src/libtomahawk/accounts/SpotifyAccountSettings.ui b/src/libtomahawk/accounts/SpotifyAccountSettings.ui new file mode 100644 index 000000000..4b7d6a45f --- /dev/null +++ b/src/libtomahawk/accounts/SpotifyAccountSettings.ui @@ -0,0 +1,21 @@ + + + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index 1b3f9fe78..8504370b3 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -59,6 +59,8 @@ #include "utils/jspfloader.h" #include "utils/logger.h" #include "utils/tomahawkutilsgui.h" +#include "accounts/lastfm/LastFmAccount.h" +#include "accounts/spotify/SpotifyAccount.h" #include "config.h" @@ -224,6 +226,14 @@ TomahawkApp::init() tDebug() << "Init AccountManager."; m_accountManager = QWeakPointer< Tomahawk::Accounts::AccountManager >( new Tomahawk::Accounts::AccountManager( this ) ); + + Tomahawk::Accounts::LastFmAccountFactory* lastfmFactory = new Tomahawk::Accounts::LastFmAccountFactory(); + m_accountManager.data()->addAccountFactory( lastfmFactory ); + + Tomahawk::Accounts::SpotifyAccountFactory* spotifyFactory = new Tomahawk::Accounts::SpotifyAccountFactory; + m_accountManager.data()->addAccountFactory( spotifyFactory ); + m_accountManager.data()->registerAccountFactoryForFilesystem( spotifyFactory ); + Tomahawk::Accounts::AccountManager::instance()->loadFromConfig(); Echonest::Config::instance()->setNetworkAccessManager( TomahawkUtils::nam() );