From f134be44b1899d11d6a8fafa4d45d5ce1dc2debc Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Mon, 1 Apr 2013 20:15:52 +0200 Subject: [PATCH] Bring back Twitter, but only for social actions. SIP is disabled. --- src/accounts/CMakeLists.txt | 2 +- src/accounts/twitter/CMakeLists.txt | 2 +- src/accounts/twitter/TwitterAccount.cpp | 31 ++++++++++---------- src/accounts/twitter/TwitterAccount.h | 6 ++-- src/accounts/twitter/TwitterConfigWidget.cpp | 4 +-- src/accounts/twitter/TwitterConfigWidget.h | 4 +-- src/widgets/AccountListWidget.cpp | 1 + src/widgets/AccountModelFactoryProxy.cpp | 4 +++ src/widgets/AccountWidget.cpp | 9 ++++-- 9 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/accounts/CMakeLists.txt b/src/accounts/CMakeLists.txt index 2dc81966a..a6604bef3 100644 --- a/src/accounts/CMakeLists.txt +++ b/src/accounts/CMakeLists.txt @@ -9,7 +9,7 @@ foreach(SUBDIRECTORY ${SUBDIRECTORIES}) endif() elseif(SUBDIRECTORY STREQUAL "twitter") if(QTWEETLIB_FOUND AND BUILD_GUI) -# add_subdirectory( twitter ) + add_subdirectory( twitter ) endif() else() add_subdirectory( ${SUBDIRECTORY} ) diff --git a/src/accounts/twitter/CMakeLists.txt b/src/accounts/twitter/CMakeLists.txt index a6d83984f..b1de573e4 100644 --- a/src/accounts/twitter/CMakeLists.txt +++ b/src/accounts/twitter/CMakeLists.txt @@ -9,7 +9,7 @@ tomahawk_add_plugin(twitter TwitterInfoPlugin.cpp TwitterConfigWidget.cpp TomahawkOAuthTwitter.cpp - sip/TwitterSip.cpp +# sip/TwitterSip.cpp UI TwitterConfigWidget.ui LINK_LIBRARIES diff --git a/src/accounts/twitter/TwitterAccount.cpp b/src/accounts/twitter/TwitterAccount.cpp index 750a3e3e9..b5c40461d 100644 --- a/src/accounts/twitter/TwitterAccount.cpp +++ b/src/accounts/twitter/TwitterAccount.cpp @@ -23,7 +23,7 @@ #include "accounts/twitter/TomahawkOAuthTwitter.h" #include "libtomahawk/infosystem/InfoSystem.h" #include "utils/Logger.h" -#include "sip/SipPlugin.h" +//#include "sip/SipPlugin.h" #include #include @@ -51,7 +51,7 @@ TwitterAccount::TwitterAccount( const QString &accountId ) , m_isAuthenticating( false ) { setAccountServiceName( "Twitter" ); - setTypes( AccountTypes( StatusPushType | SipType ) ); + setTypes( AccountTypes( StatusPushType ) ); qDebug() << "Got cached peers:" << configuration() << configuration()[ "cachedpeers" ]; @@ -86,24 +86,25 @@ TwitterAccount::configDialogAuthedSignalSlot( bool authed ) Account::ConnectionState TwitterAccount::connectionState() const { - if ( m_twitterSipPlugin.isNull() ) +// if ( m_twitterSipPlugin.isNull() ) return Account::Disconnected; - return m_twitterSipPlugin.data()->connectionState(); +// return m_twitterSipPlugin.data()->connectionState(); } SipPlugin* TwitterAccount::sipPlugin() { - if ( m_twitterSipPlugin.isNull() ) - { - qDebug() << "CHECKING:" << configuration() << configuration()[ "cachedpeers" ]; - m_twitterSipPlugin = QPointer< TwitterSipPlugin >( new TwitterSipPlugin( this ) ); +// if ( m_twitterSipPlugin.isNull() ) +// { +// qDebug() << "CHECKING:" << configuration() << configuration()[ "cachedpeers" ]; +// m_twitterSipPlugin = QPointer< TwitterSipPlugin >( new TwitterSipPlugin( this ) ); - connect( m_twitterSipPlugin.data(), SIGNAL( stateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), this, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) ); - return m_twitterSipPlugin.data(); - } - return m_twitterSipPlugin.data(); +// connect( m_twitterSipPlugin.data(), SIGNAL( stateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), this, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ) ); +// return m_twitterSipPlugin.data(); +// } +// return m_twitterSipPlugin.data(); + return 0; } @@ -169,8 +170,8 @@ TwitterAccount::deauthenticate() { tDebug() << Q_FUNC_INFO; - if ( m_twitterSipPlugin ) - sipPlugin()->disconnectPlugin(); +// if ( m_twitterSipPlugin ) +// sipPlugin()->disconnectPlugin(); if ( m_twitterInfoPlugin ) Tomahawk::InfoSystem::InfoSystem::instance()->removeInfoPlugin( m_twitterInfoPlugin.data() ); @@ -221,7 +222,7 @@ TwitterAccount::connectAuthVerifyReply( const QTweetUser &user ) setConfiguration( config ); sync(); - sipPlugin()->connectPlugin(); +// sipPlugin()->connectPlugin(); m_isAuthenticated = true; emit nowAuthenticated( m_twitterAuth, user ); diff --git a/src/accounts/twitter/TwitterAccount.h b/src/accounts/twitter/TwitterAccount.h index 6557a4721..23d66eeb5 100644 --- a/src/accounts/twitter/TwitterAccount.h +++ b/src/accounts/twitter/TwitterAccount.h @@ -50,7 +50,7 @@ public: QString factoryId() const { return "twitteraccount"; } QString description() const { return tr( "Connect to your Twitter followers." ); } QPixmap icon() const { return QPixmap( ":/twitter-account/twitter-icon.png" ); } - AccountTypes types() const { return AccountTypes( SipType | StatusPushType ); }; + AccountTypes types() const { return AccountTypes( StatusPushType ); }; Account* createAccount( const QString& pluginId = QString() ); }; @@ -73,7 +73,7 @@ public: Tomahawk::InfoSystem::InfoPluginPtr infoPlugin(); SipPlugin* sipPlugin(); - QWidget* configurationWidget() { return m_configWidget.data(); } + AccountConfigWidget* configurationWidget() { return m_configWidget.data(); } QWidget* aclWidget() { return 0; } bool refreshTwitterAuth(); @@ -94,7 +94,7 @@ private: bool m_isAuthenticating; QPointer< TomahawkOAuthTwitter > m_twitterAuth; QPointer< TwitterConfigWidget > m_configWidget; - QPointer< TwitterSipPlugin > m_twitterSipPlugin; +// QPointer< TwitterSipPlugin > m_twitterSipPlugin; QPointer< Tomahawk::InfoSystem::TwitterInfoPlugin > m_twitterInfoPlugin; // for settings access diff --git a/src/accounts/twitter/TwitterConfigWidget.cpp b/src/accounts/twitter/TwitterConfigWidget.cpp index d6e025f11..e96fa6db9 100644 --- a/src/accounts/twitter/TwitterConfigWidget.cpp +++ b/src/accounts/twitter/TwitterConfigWidget.cpp @@ -43,7 +43,7 @@ namespace Accounts { TwitterConfigWidget::TwitterConfigWidget( TwitterAccount* account, QWidget *parent ) : - QWidget( parent ), + AccountConfigWidget( parent ), m_ui( new Ui::TwitterConfigWidget ), m_account( account ) { @@ -294,4 +294,4 @@ TwitterConfigWidget::postGotTomahawkStatusUpdateError( QTweetNetBase::ErrorCode } -} \ No newline at end of file +} diff --git a/src/accounts/twitter/TwitterConfigWidget.h b/src/accounts/twitter/TwitterConfigWidget.h index 52f4279e8..df0e0be44 100644 --- a/src/accounts/twitter/TwitterConfigWidget.h +++ b/src/accounts/twitter/TwitterConfigWidget.h @@ -27,7 +27,7 @@ #include #include -#include +#include "accounts/AccountConfigWidget.h" namespace Ui { @@ -43,7 +43,7 @@ namespace Accounts class TwitterAccount; -class ACCOUNTDLLEXPORT TwitterConfigWidget : public QWidget +class ACCOUNTDLLEXPORT TwitterConfigWidget : public AccountConfigWidget { Q_OBJECT diff --git a/src/widgets/AccountListWidget.cpp b/src/widgets/AccountListWidget.cpp index f6df9b4b5..a00be77f0 100644 --- a/src/widgets/AccountListWidget.cpp +++ b/src/widgets/AccountListWidget.cpp @@ -138,6 +138,7 @@ AccountListWidget::insertEntries( const QModelIndex& parent, int start, int end QPersistentModelIndex idx( m_model->index( i, 0, parent ) ); int count = idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().count(); + QList< AccountWidget* > entryAccounts; for ( int j = 0; j < count; ++j ) { diff --git a/src/widgets/AccountModelFactoryProxy.cpp b/src/widgets/AccountModelFactoryProxy.cpp index 67a014a7d..2f2dd70a3 100644 --- a/src/widgets/AccountModelFactoryProxy.cpp +++ b/src/widgets/AccountModelFactoryProxy.cpp @@ -47,6 +47,10 @@ AccountModelFactoryProxy::filterAcceptsRow( int sourceRow, const QModelIndex& so if ( idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().isEmpty() ) return false; + + Tomahawk::Accounts::AccountFactory* factory = qobject_cast< Tomahawk::Accounts::AccountFactory* >( idx.data( Tomahawk::Accounts::AccountModel::AccountData ).value< QObject* >() ); + if ( factory && factory->factoryId() == "twitteraccount" ) + return false; } return rowType == m_filterRowType; diff --git a/src/widgets/AccountWidget.cpp b/src/widgets/AccountWidget.cpp index 8a9bfcff4..d7dc8fc15 100644 --- a/src/widgets/AccountWidget.cpp +++ b/src/widgets/AccountWidget.cpp @@ -314,9 +314,12 @@ AccountWidget::setupConnections( const QPersistentModelIndex& idx, int accountId connect( m_inviteEdit, SIGNAL( returnPressed() ), this, SLOT( sendInvite() ) ); - m_inviteEdit->setPlaceholderText( account->sipPlugin()->inviteString() ); - connect( account->sipPlugin(), SIGNAL( inviteSentSuccess( QString ) ), SLOT( onInviteSentSuccess( QString ) ) ); - connect( account->sipPlugin(), SIGNAL( inviteSentFailure( QString ) ), SLOT( onInviteSentFailure( QString ) ) ); + if ( account->sipPlugin() ) + { + m_inviteEdit->setPlaceholderText( account->sipPlugin()->inviteString() ); + connect( account->sipPlugin(), SIGNAL( inviteSentSuccess( QString ) ), SLOT( onInviteSentSuccess( QString ) ) ); + connect( account->sipPlugin(), SIGNAL( inviteSentFailure( QString ) ), SLOT( onInviteSentFailure( QString ) ) ); + } } }