From c4ea707ae24deb22c9ce73b5cd223a79d103ba3d Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sat, 5 Apr 2014 18:03:07 +0100 Subject: [PATCH] Drop QTweetLib and deprecated TwitterSIP --- .gitignore | 1 - CMakeLists.txt | 3 - CMakeModules/FindQTweetLib.cmake | 28 - CMakeModules/NSIS.template.in | 1 - README.md | 1 - admin/mac/macdeploy.py | 1 - src/accounts/CMakeLists.txt | 3 +- src/accounts/twitter/CMakeLists.txt | 19 - src/accounts/twitter/TomahawkOAuthTwitter.cpp | 52 -- src/accounts/twitter/TomahawkOAuthTwitter.h | 45 -- src/accounts/twitter/TwitterAccount.cpp | 247 ------ src/accounts/twitter/TwitterAccount.h | 111 --- src/accounts/twitter/TwitterConfigWidget.cpp | 298 -------- src/accounts/twitter/TwitterConfigWidget.h | 83 -- src/accounts/twitter/TwitterConfigWidget.ui | 381 --------- src/accounts/twitter/TwitterInfoPlugin.cpp | 202 ----- src/accounts/twitter/TwitterInfoPlugin.h | 80 -- src/accounts/twitter/resources.qrc | 6 - src/accounts/twitter/sip/TwitterSip.cpp | 723 ------------------ src/accounts/twitter/sip/TwitterSip.h | 132 ---- src/accounts/twitter/twitter-icon.png | Bin 2970 -> 0 bytes src/accounts/twitter/twitter-offline-icon.png | Bin 3705 -> 0 bytes src/accounts/xmpp/XmppConfigWidget.h | 2 +- src/libtomahawk/accounts/AccountDelegate.cpp | 4 +- .../widgets/AccountModelFactoryProxy.cpp | 2 - src/tomahawk/widgets/AccountWidget.cpp | 5 - 26 files changed, 3 insertions(+), 2427 deletions(-) delete mode 100644 CMakeModules/FindQTweetLib.cmake delete mode 100644 src/accounts/twitter/CMakeLists.txt delete mode 100644 src/accounts/twitter/TomahawkOAuthTwitter.cpp delete mode 100644 src/accounts/twitter/TomahawkOAuthTwitter.h delete mode 100644 src/accounts/twitter/TwitterAccount.cpp delete mode 100644 src/accounts/twitter/TwitterAccount.h delete mode 100644 src/accounts/twitter/TwitterConfigWidget.cpp delete mode 100644 src/accounts/twitter/TwitterConfigWidget.h delete mode 100644 src/accounts/twitter/TwitterConfigWidget.ui delete mode 100644 src/accounts/twitter/TwitterInfoPlugin.cpp delete mode 100644 src/accounts/twitter/TwitterInfoPlugin.h delete mode 100644 src/accounts/twitter/resources.qrc delete mode 100644 src/accounts/twitter/sip/TwitterSip.cpp delete mode 100644 src/accounts/twitter/sip/TwitterSip.h delete mode 100644 src/accounts/twitter/twitter-icon.png delete mode 100644 src/accounts/twitter/twitter-offline-icon.png diff --git a/.gitignore b/.gitignore index 4c5f44487..6be6119fc 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,6 @@ Makefile* moc_* *~ /tomahawk -thirdparty/qtweetlib/WARNING-twitter-api-keys .kdev4 *.kdev4 *.kate-swp diff --git a/CMakeLists.txt b/CMakeLists.txt index 16daac05f..cde2a61c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -269,9 +269,6 @@ if( PC_JREEN_VERSION STREQUAL "1.1.0" ) message(FATAL_ERROR "Jreen 1.1.0 has a very annoying bug that breaks accepting auth requests in Tomahawk. Please upgrade to 1.1.1 or downgrade to 1.0.5.") endif() -macro_optional_find_package(QTweetLib) -macro_log_feature(QTWEETLIB_FOUND "QTweetLib" "Qt Twitter Library" "https://github.com/minimoog/QTweetLib" FALSE "" "QTweetLib is needed for the Twitter SIP plugin.\n") - macro_optional_find_package(LibLastFm 1.0.0) macro_log_feature(LIBLASTFM_FOUND "liblastfm" "Qt library for the Last.fm webservices" "https://github.com/lastfm/liblastfm" TRUE "" "liblastfm is needed for scrobbling tracks to Last.fm and fetching cover artwork") diff --git a/CMakeModules/FindQTweetLib.cmake b/CMakeModules/FindQTweetLib.cmake deleted file mode 100644 index 536b09733..000000000 --- a/CMakeModules/FindQTweetLib.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# - Try to find QTweetLib -# -# QTWEETLIB_FOUND - system has QTweetLib -# QTWEETLIB_INCLUDE_DIRS - the QTweetLib include directories -# QTWEETLIB_LIBRARIES - link these to use QTweetLib -# -# (c) Dominik Schmidt -# - -# Include dir -find_path(QTWEETLIB_INCLUDE_DIR - NAMES QTweetLib/qtweetlib_global.h - PATHS ${KDE4_INCLUDE_DIR} -) - -# Finally the library itself -find_library(QTWEETLIB_LIBRARY - NAMES QTweetLib - PATHS ${KDE4_LIB_DIR} -) - -SET( QTWEETLIB_LIBRARIES ${QTWEETLIB_LIBRARY} ${QJSON_LIBRARIES} ) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(QTweetLib DEFAULT_MSG QTWEETLIB_LIBRARY QTWEETLIB_INCLUDE_DIR) - -MARK_AS_ADVANCED(QTWEETLIB_LIBRARIES QTWEETLIB_INCLUDE_DIR) - diff --git a/CMakeModules/NSIS.template.in b/CMakeModules/NSIS.template.in index fea469c93..7cede5970 100644 --- a/CMakeModules/NSIS.template.in +++ b/CMakeModules/NSIS.template.in @@ -352,7 +352,6 @@ Section "Tomahawk Player" SEC_TOMAHAWK_PLAYER File "${MING_BIN}\libechonest.dll" File "${MING_BIN}\liblastfm.dll" - File "${MING_BIN}\libQTweetLib.dll" File "${MING_BIN}\libquazip.dll" File "${MING_BIN}\libqtkeychain.dll" diff --git a/README.md b/README.md index 8bf3c9952..63952edaf 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,6 @@ Required dependencies: The following dependencies are optional, but recommended: * Jreen 1.0.5 (1.1.0 will fail, 1.1.1 is fine) - http://qutim.org/jreen/ -* QTweetLib 0.5.0 - https://github.com/minimoog/QTweetLib/ Third party libraries that we ship with our source: diff --git a/admin/mac/macdeploy.py b/admin/mac/macdeploy.py index 00d3e46eb..309819128 100755 --- a/admin/mac/macdeploy.py +++ b/admin/mac/macdeploy.py @@ -202,7 +202,6 @@ QT_PLUGINS = [ TOMAHAWK_PLUGINS = [ 'libtomahawk_account_xmpp.dylib', 'libtomahawk_account_google.so', - #'libtomahawk_account_twitter.so', 'libtomahawk_account_zeroconf.so', 'libtomahawk_infoplugin_adium.so', 'libtomahawk_infoplugin_charts.so', diff --git a/src/accounts/CMakeLists.txt b/src/accounts/CMakeLists.txt index 1493daa15..27f98725e 100644 --- a/src/accounts/CMakeLists.txt +++ b/src/accounts/CMakeLists.txt @@ -2,8 +2,7 @@ file(GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*") foreach(SUBDIRECTORY ${SUBDIRECTORIES}) if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt") - if(SUBDIRECTORY STREQUAL "twitter") - elseif((SUBDIRECTORY STREQUAL "xmpp") OR (SUBDIRECTORY STREQUAL "google")) + if((SUBDIRECTORY STREQUAL "xmpp") OR (SUBDIRECTORY STREQUAL "google")) if( JREEN_FOUND ) add_subdirectory(${SUBDIRECTORY}) endif() diff --git a/src/accounts/twitter/CMakeLists.txt b/src/accounts/twitter/CMakeLists.txt deleted file mode 100644 index b1de573e4..000000000 --- a/src/accounts/twitter/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ - -include_directories(${QTWEETLIB_INCLUDE_DIR}) - -tomahawk_add_plugin(twitter - TYPE account - EXPORT_MACRO ACCOUNTDLLEXPORT_PRO - SOURCES - TwitterAccount.cpp - TwitterInfoPlugin.cpp - TwitterConfigWidget.cpp - TomahawkOAuthTwitter.cpp -# sip/TwitterSip.cpp - UI - TwitterConfigWidget.ui - LINK_LIBRARIES - ${TOMAHAWK_LIBRARIES} - ${QTWEETLIB_LIBRARIES} -) - diff --git a/src/accounts/twitter/TomahawkOAuthTwitter.cpp b/src/accounts/twitter/TomahawkOAuthTwitter.cpp deleted file mode 100644 index 243129fd7..000000000 --- a/src/accounts/twitter/TomahawkOAuthTwitter.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2012, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - - - -#include "TomahawkOAuthTwitter.h" - -#include "utils/Logger.h" - -#include - - -TomahawkOAuthTwitter::TomahawkOAuthTwitter( QNetworkAccessManager *nam, QObject* parent ) - : OAuthTwitter( QByteArray::fromBase64( "QzR2NFdmYTIxcmZJRGNrNEhNUjNB" ), QByteArray::fromBase64( "elhTalU2Ympydmc2VVZNSlg0SnVmcUh5amozaWV4dFkxNFNSOXVCRUFv" ), parent ) -{ - setNetworkAccessManager( nam ); -} - - -const QString -TomahawkOAuthTwitter::authorizationWidget() -{ - bool ok; - const QString str = QInputDialog::getText(0, tr( "Twitter PIN" ), tr( "After authenticating on Twitter's web site,\nenter the displayed PIN number here:" ), QLineEdit::Normal, QString(), &ok); - if ( ok && !str.isEmpty() ) - return str; - - return QString(); -} - -void -TomahawkOAuthTwitter::error() -{ - qDebug() << Q_FUNC_INFO; - setOAuthToken( QString().toLatin1() ); - setOAuthTokenSecret( QString().toLatin1() ); -} diff --git a/src/accounts/twitter/TomahawkOAuthTwitter.h b/src/accounts/twitter/TomahawkOAuthTwitter.h deleted file mode 100644 index 4270a89a2..000000000 --- a/src/accounts/twitter/TomahawkOAuthTwitter.h +++ /dev/null @@ -1,45 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2012, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - - -#ifndef TOMAHAWKOAUTHTWITTERACCOUNT -#define TOMAHAWKOAUTHTWITTERACCOUNT - -#include "accounts/AccountDllMacro.h" -#include "utils/TomahawkUtils.h" - -#include -#include - -class ACCOUNTDLLEXPORT TomahawkOAuthTwitter : public OAuthTwitter -{ - Q_OBJECT - -public: - TomahawkOAuthTwitter( QNetworkAccessManager *nam = TomahawkUtils::nam() , QObject *parent = 0 ); - - ~TomahawkOAuthTwitter() {} - -protected: - virtual const QString authorizationWidget(); - -private slots: - void error(); -}; - -#endif diff --git a/src/accounts/twitter/TwitterAccount.cpp b/src/accounts/twitter/TwitterAccount.cpp deleted file mode 100644 index 4dd95d601..000000000 --- a/src/accounts/twitter/TwitterAccount.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2011, Leo Franchi - * Copyright 2010-2011, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#include "TwitterAccount.h" -#include "TwitterConfigWidget.h" -#include "TomahawkOAuthTwitter.h" -#include "infosystem/InfoSystem.h" -#include "utils/Logger.h" -#include "sip/SipPlugin.h" - -#include -#include -#include -#include - -#include -#include - -namespace Tomahawk -{ - -namespace Accounts -{ - -Account* -TwitterAccountFactory::createAccount( const QString& accountId ) -{ - return new TwitterAccount( accountId.isEmpty() ? Tomahawk::Accounts::generateId( factoryId() ) : accountId ); -} - - -TwitterAccount::TwitterAccount( const QString &accountId ) - : Account( accountId ) - , m_isAuthenticated( false ) - , m_isAuthenticating( false ) -{ - setAccountServiceName( "Twitter" ); - setTypes( AccountTypes( StatusPushType ) ); - - qDebug() << "Got cached peers:" << configuration() << configuration()[ "cachedpeers" ]; - - m_configWidget = QPointer< TwitterConfigWidget >( new TwitterConfigWidget( this, 0 ) ); - connect( m_configWidget.data(), SIGNAL( twitterAuthed( bool ) ), SLOT( configDialogAuthedSignalSlot( bool ) ) ); - - m_twitterAuth = QPointer< TomahawkOAuthTwitter >( new TomahawkOAuthTwitter( TomahawkUtils::nam(), this ) ); - - m_onlinePixmap = QPixmap( ":/twitter-account/twitter-icon.png" ); - m_offlinePixmap = QPixmap( ":/twitter-account/twitter-offline-icon.png" ); -} - - -TwitterAccount::~TwitterAccount() -{ - -} - - -void -TwitterAccount::configDialogAuthedSignalSlot( bool authed ) -{ - tDebug() << Q_FUNC_INFO; - m_isAuthenticated = authed; - if ( !credentials()[ "username" ].toString().isEmpty() ) - setAccountFriendlyName( QString( "@%1" ).arg( credentials()[ "username" ].toString() ) ); - syncConfig(); - emit configurationChanged(); -} - - -Account::ConnectionState -TwitterAccount::connectionState() const -{ -// if ( m_twitterSipPlugin.isNull() ) - return Account::Disconnected; - -// return m_twitterSipPlugin.data()->connectionState(); -} - -SipPlugin* -TwitterAccount::sipPlugin() -{ -// 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(); - return 0; -} - - -Tomahawk::InfoSystem::InfoPluginPtr -TwitterAccount::infoPlugin() -{ - if ( m_twitterInfoPlugin.isNull() ) - m_twitterInfoPlugin = QPointer< Tomahawk::InfoSystem::TwitterInfoPlugin >( new Tomahawk::InfoSystem::TwitterInfoPlugin( this ) ); - - return Tomahawk::InfoSystem::InfoPluginPtr( m_twitterInfoPlugin.data() ); -} - - -void -TwitterAccount::authenticate() -{ - // Since we need to have a chance for deletion (via the infosystem) to work on the info plugin, we put this on the event loop - tDebug() << Q_FUNC_INFO; - QTimer::singleShot( 0, this, SLOT( authenticateSlot() ) ); -} - - -void -TwitterAccount::authenticateSlot() -{ - tDebug() << Q_FUNC_INFO; - if ( m_twitterInfoPlugin.isNull() ) - { - if ( infoPlugin() && Tomahawk::InfoSystem::InfoSystem::instance()->workerThread() ) - { - infoPlugin().data()->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() ); - Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin() ); - } - } - - if ( m_isAuthenticating ) - { - tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Already authenticating"; - return; - } - - tDebug() << Q_FUNC_INFO << "credentials: " << credentials().keys(); - - if ( credentials()[ "oauthtoken" ].toString().isEmpty() || credentials()[ "oauthtokensecret" ].toString().isEmpty() ) - { - tDebug() << Q_FUNC_INFO << "TwitterSipPlugin has empty Twitter credentials; not connecting"; - return; - } - - if ( refreshTwitterAuth() ) - { - m_isAuthenticating = true; - tDebug() << Q_FUNC_INFO << "Verifying credentials"; - QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this ); - connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( connectAuthVerifyReply( const QTweetUser & ) ) ); - credVerifier->verify(); - } -} - - -void -TwitterAccount::deauthenticate() -{ - tDebug() << Q_FUNC_INFO; - -// if ( m_twitterSipPlugin ) -// sipPlugin()->disconnectPlugin(); - - if ( m_twitterInfoPlugin ) - Tomahawk::InfoSystem::InfoSystem::instance()->removeInfoPlugin( m_twitterInfoPlugin.data() ); - - m_isAuthenticated = false; - m_isAuthenticating = false; - - emit nowDeauthenticated(); -} - - - -bool -TwitterAccount::refreshTwitterAuth() -{ - qDebug() << Q_FUNC_INFO << " begin"; - if( !m_twitterAuth.isNull() ) - delete m_twitterAuth.data(); - - Q_ASSERT( TomahawkUtils::nam() != 0 ); - tDebug() << Q_FUNC_INFO << " with nam " << TomahawkUtils::nam(); - m_twitterAuth = QPointer< TomahawkOAuthTwitter >( new TomahawkOAuthTwitter( TomahawkUtils::nam(), this ) ); - - if( m_twitterAuth.isNull() ) - return false; - - m_twitterAuth.data()->setOAuthToken( credentials()[ "oauthtoken" ].toString().toLatin1() ); - m_twitterAuth.data()->setOAuthTokenSecret( credentials()[ "oauthtokensecret" ].toString().toLatin1() ); - - return true; -} - - -void -TwitterAccount::connectAuthVerifyReply( const QTweetUser &user ) -{ - m_isAuthenticating = false; - if ( user.id() == 0 ) - { - qDebug() << "TwitterAccount could not authenticate to Twitter"; - deauthenticate(); - } - else - { - tDebug() << "TwitterAccount successfully authenticated to Twitter as user " << user.screenName(); - QVariantHash config = configuration(); - config[ "screenname" ] = user.screenName(); - setConfiguration( config ); - sync(); - -// sipPlugin()->connectPlugin(); - - m_isAuthenticated = true; - emit nowAuthenticated( m_twitterAuth, user ); - } -} - - -QPixmap -TwitterAccount::icon() const -{ - if ( connectionState() == Connected ) - return m_onlinePixmap; - return m_offlinePixmap; -} - - -} - -} - -Q_EXPORT_PLUGIN2( Tomahawk::Accounts::AccountFactory, Tomahawk::Accounts::TwitterAccountFactory ) diff --git a/src/accounts/twitter/TwitterAccount.h b/src/accounts/twitter/TwitterAccount.h deleted file mode 100644 index 8d070e275..000000000 --- a/src/accounts/twitter/TwitterAccount.h +++ /dev/null @@ -1,111 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2011, Leo Franchi - * Copyright 2010-2011, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef TWITTERACCOUNT_H -#define TWITTERACCOUNT_H - -#include "TwitterConfigWidget.h" -#include "TomahawkOAuthTwitter.h" - -//#include "sip/TwitterSip.h" -#include "TwitterInfoPlugin.h" -#include "accounts/AccountDllMacro.h" -#include "accounts/Account.h" - -#define MYNAME "ACCOUNTTWITTER" - -namespace Tomahawk -{ - -namespace Accounts -{ - -class ACCOUNTDLLEXPORT TwitterAccountFactory : public AccountFactory -{ - Q_OBJECT - Q_INTERFACES( Tomahawk::Accounts::AccountFactory ) - -public: - TwitterAccountFactory() {} - virtual ~TwitterAccountFactory() {} - - QString prettyName() const { return "Twitter"; } - QString factoryId() const { return "twitteraccount"; } - QString description() const { return tr( "Send tweets from Tomahawk." ); } - QPixmap icon() const { return QPixmap( ":/twitter-account/twitter-icon.png" ); } - AccountTypes types() const { return AccountTypes( StatusPushType ); }; - Account* createAccount( const QString& pluginId = QString() ); -}; - -class ACCOUNTDLLEXPORT TwitterAccount : public Account -{ - Q_OBJECT - -public: - TwitterAccount( const QString &accountId ); - virtual ~TwitterAccount(); - - QPixmap icon() const; - - void authenticate(); - void deauthenticate(); - bool isAuthenticated() const { return m_isAuthenticated; } - - ConnectionState connectionState() const; - - Tomahawk::InfoSystem::InfoPluginPtr infoPlugin(); - SipPlugin* sipPlugin(); - - AccountConfigWidget* configurationWidget() { return m_configWidget.data(); } - QWidget* aclWidget() { return 0; } - - bool refreshTwitterAuth(); - TomahawkOAuthTwitter* twitterAuth() const { return m_twitterAuth.data(); } - -signals: - void nowAuthenticated( const QPointer< TomahawkOAuthTwitter >&, const QTweetUser &user ); - void nowDeauthenticated(); - -private slots: - void authenticateSlot(); - void configDialogAuthedSignalSlot( bool authed ); - void connectAuthVerifyReply( const QTweetUser &user ); - -private: - QIcon m_icon; - bool m_isAuthenticated; - bool m_isAuthenticating; - QPointer< TomahawkOAuthTwitter > m_twitterAuth; - QPointer< TwitterConfigWidget > m_configWidget; -// QPointer< TwitterSipPlugin > m_twitterSipPlugin; - QPointer< Tomahawk::InfoSystem::TwitterInfoPlugin > m_twitterInfoPlugin; - - // for settings access - friend class TwitterConfigWidget; - - QPixmap m_onlinePixmap; - QPixmap m_offlinePixmap; -}; - -}; - -}; - -#endif diff --git a/src/accounts/twitter/TwitterConfigWidget.cpp b/src/accounts/twitter/TwitterConfigWidget.cpp deleted file mode 100644 index e016ea0b2..000000000 --- a/src/accounts/twitter/TwitterConfigWidget.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2010-2011, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#include "TwitterConfigWidget.h" -#include "TwitterAccount.h" -#include "ui_TwitterConfigWidget.h" - -#include "TomahawkSettings.h" -#include "utils/TomahawkUtils.h" -#include "database/Database.h" -#include "database/DatabaseImpl.h" -#include "Source.h" -#include "TomahawkOAuthTwitter.h" - -#include -#include -#include - -#include - -#include "utils/Logger.h" - -namespace Tomahawk -{ - -namespace Accounts -{ - -TwitterConfigWidget::TwitterConfigWidget( TwitterAccount* account, QWidget *parent ) : - AccountConfigWidget( parent ), - m_ui( new Ui::TwitterConfigWidget ), - m_account( account ) -{ - m_ui->setupUi( this ); - - connect( m_ui->twitterAuthenticateButton, SIGNAL( pressed() ), - this, SLOT( authDeauthTwitter() ) ); - connect( m_ui->twitterTweetGotTomahawkButton, SIGNAL( pressed() ), - this, SLOT( startPostGotTomahawkStatus() ) ); - connect( m_ui->twitterTweetComboBox, SIGNAL( currentIndexChanged( int ) ), - this, SLOT( tweetComboBoxIndexChanged( int ) ) ); - - m_ui->twitterTweetComboBox->setCurrentIndex( 0 ); - m_ui->twitterTweetGotTomahawkButton->setText( tr( "Tweet!" ) ); - - QVariantHash credentials = m_account->credentials(); - - if ( credentials[ "oauthtoken" ].toString().isEmpty() || - credentials[ "oauthtokensecret" ].toString().isEmpty() || - credentials[ "username" ].toString().isEmpty() ) - { - m_ui->twitterStatusLabel->setText( tr( "Status: No saved credentials" ) ); - m_ui->twitterAuthenticateButton->setText( tr( "Authenticate" ) ); - m_ui->twitterSyncGroupBox->setVisible( false ); - - emit twitterAuthed( false ); - } - else - { - m_ui->twitterStatusLabel->setText( tr( "Status: Credentials saved for %1" ).arg( m_account->credentials()[ "username" ].toString() ) ); - m_ui->twitterAuthenticateButton->setText( tr( "De-authenticate" ) ); - //m_ui->twitterSyncGroupBox->setVisible( true ); - m_ui->twitterUserTweetLineEdit->setVisible( false ); - - emit twitterAuthed( true ); - } - - m_ui->twitterSyncGroupBox->hide(); -} - -TwitterConfigWidget::~TwitterConfigWidget() -{ - delete m_ui; -} - -void -TwitterConfigWidget::authDeauthTwitter() -{ - if ( m_ui->twitterAuthenticateButton->text() == tr( "Authenticate" ) ) //FIXME: don't rely on UI strings here! - authenticateTwitter(); - else - deauthenticateTwitter(); -} - -void -TwitterConfigWidget::authenticateTwitter() -{ - qDebug() << Q_FUNC_INFO; - TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( TomahawkUtils::nam(), this ); - twitAuth->authorizePin(); - - QVariantHash credentials = m_account->credentials(); - credentials[ "oauthtoken" ] = twitAuth->oauthToken(); - credentials[ "oauthtokensecret" ] = twitAuth->oauthTokenSecret(); - m_account->setCredentials( credentials ); - - QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this ); - connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( authenticateVerifyReply( const QTweetUser & ) ) ); - connect( credVerifier, SIGNAL( error( QTweetNetBase::ErrorCode, QString ) ), SLOT( authenticateVerifyError( QTweetNetBase::ErrorCode, QString ) ) ); - credVerifier->verify(); -} - -void -TwitterConfigWidget::authenticateVerifyReply( const QTweetUser &user ) -{ - qDebug() << Q_FUNC_INFO; - if ( user.id() == 0 ) - { - QMessageBox::critical( this, tr("Tweetin' Error"), tr("The credentials could not be verified.\nYou may wish to try re-authenticating.") ); - emit twitterAuthed( false ); - return; - } - - QVariantHash credentials = m_account->credentials(); - credentials[ "username" ] = user.screenName(); - m_account->setCredentials( credentials ); - - QVariantHash configuration = m_account->configuration(); - 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 ); - m_ui->twitterTweetComboBox->setCurrentIndex( 0 ); - m_ui->twitterUserTweetLineEdit->setVisible( false ); - m_ui->twitterTweetGotTomahawkButton->setText( tr( "Tweet!" ) ); - - emit twitterAuthed( true ); - emit sizeHintChanged(); -} - -void -TwitterConfigWidget::authenticateVerifyError( QTweetNetBase::ErrorCode code, const QString &errorMsg ) -{ - qDebug() << Q_FUNC_INFO; - qDebug() << "Error validating credentials, error code is " << code << ", error message is " << errorMsg; - m_ui->twitterStatusLabel->setText(tr("Status: Error validating credentials")); - emit twitterAuthed( false ); - return; -} - -void -TwitterConfigWidget::deauthenticateTwitter() -{ - qDebug() << Q_FUNC_INFO; - QVariantHash credentials = m_account->credentials(); - credentials[ "oauthtoken" ] = QString(); - credentials[ "oauthtokensecret" ] = QString(); - credentials[ "username" ] = QString(); - m_account->setCredentials( credentials ); - - m_ui->twitterStatusLabel->setText(tr("Status: No saved credentials")); - m_ui->twitterAuthenticateButton->setText( tr( "Authenticate" ) ); - m_ui->twitterSyncGroupBox->setVisible( false ); - - emit twitterAuthed( false ); - emit sizeHintChanged(); -} - -void -TwitterConfigWidget::tweetComboBoxIndexChanged( int index ) -{ - Q_UNUSED( index ); - if ( m_ui->twitterTweetComboBox->currentText() == tr( "Global Tweet" ) ) //FIXME: use data! - m_ui->twitterUserTweetLineEdit->setVisible( false ); - else - m_ui->twitterUserTweetLineEdit->setVisible( true ); - - if ( m_ui->twitterTweetComboBox->currentText() == tr( "Direct Message" ) ) //FIXME: use data! - m_ui->twitterTweetGotTomahawkButton->setText( tr( "Send Message!" ) ); - else if ( m_ui->twitterTweetComboBox->currentText() == tr( "@Mention" ) ) - m_ui->twitterTweetGotTomahawkButton->setText( tr( "Send Mention!" ) ); - else - m_ui->twitterTweetGotTomahawkButton->setText( tr( "Tweet!" ) ); -} - -void -TwitterConfigWidget::startPostGotTomahawkStatus() -{ - qDebug() << Q_FUNC_INFO; - m_postGTtype = m_ui->twitterTweetComboBox->currentText(); - - if ( m_postGTtype != "Global Tweet" && ( m_ui->twitterUserTweetLineEdit->text().isEmpty() || m_ui->twitterUserTweetLineEdit->text() == "@" ) ) - { - QMessageBox::critical( this, tr("Tweetin' Error"), tr("You must enter a user name for this type of tweet.") ); - return; - } - - qDebug() << "Posting Got Tomahawk status"; - QVariantHash credentials = m_account->credentials(); - - if ( credentials[ "oauthtoken" ].toString().isEmpty() || - credentials[ "oauthtokensecret" ].toString().isEmpty() || - credentials[ "username" ].toString().isEmpty() ) - { - QMessageBox::critical( this, tr("Tweetin' Error"), tr("Your saved credentials could not be loaded.\nYou may wish to try re-authenticating.") ); - emit twitterAuthed( false ); - return; - } - TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( TomahawkUtils::nam(), this ); - twitAuth->setOAuthToken( credentials[ "oauthtoken" ].toString().toLatin1() ); - twitAuth->setOAuthTokenSecret( credentials[ "oauthtokensecret" ].toString().toLatin1() ); - QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this ); - connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( postGotTomahawkStatusAuthVerifyReply(const QTweetUser &) ) ); - credVerifier->verify(); -} - -void -TwitterConfigWidget::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user ) -{ - qDebug() << Q_FUNC_INFO; - if ( user.id() == 0 ) - { - QMessageBox::critical( this, tr("Tweetin' Error"), tr("Your saved credentials could not be verified.\nYou may wish to try re-authenticating.") ); - emit twitterAuthed( false ); - return; - } - TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( TomahawkUtils::nam(), this ); - QVariantHash credentials = m_account->credentials(); - twitAuth->setOAuthToken( credentials[ "oauthtoken" ].toString().toLatin1() ); - twitAuth->setOAuthTokenSecret( credentials[ "oauthtokensecret" ].toString().toLatin1() ); - if ( m_postGTtype != "Direct Message" ) - { - QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( twitAuth, this ); - connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postGotTomahawkStatusUpdateReply(const QTweetStatus &) ) ); - connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) ); - QString uuid = QUuid::createUuid(); - QString message = QString( "Got Tomahawk? {" ) + Database::instance()->impl()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) + QString( " http://gettomahawk.com" ); - if ( m_postGTtype == "@Mention" ) - { - QString user = m_ui->twitterUserTweetLineEdit->text(); - if ( user.startsWith( "@" ) ) - user.remove( 0, 1 ); - message = QString( "@" ) + user + QString( " " ) + message; - } - statUpdate->post( message ); - } - else - { - QTweetDirectMessageNew *statUpdate = new QTweetDirectMessageNew( twitAuth, this ); - connect( statUpdate, SIGNAL( parsedDirectMessage(const QTweetDMStatus &)), SLOT( postGotTomahawkDirectMessageReply(const QTweetDMStatus &) ) ); - connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) ); - QString uuid = QUuid::createUuid(); - QString message = QString( "Got Tomahawk? {" ) + Database::instance()->impl()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) + QString( " http://gettomahawk.com" ); - QString user = m_ui->twitterUserTweetLineEdit->text(); - if ( user.startsWith( "@" ) ) - user.remove( 0, 1 ); - statUpdate->post( user, message ); - } -} - -void -TwitterConfigWidget::postGotTomahawkStatusUpdateReply( const QTweetStatus& status ) -{ - if ( status.id() == 0 ) - QMessageBox::critical( this, tr("Tweetin' Error"), tr("There was an error posting your status -- sorry!") ); - else - QMessageBox::information( this, tr("Tweeted!"), tr("Your tweet has been posted!") ); -} - -void -TwitterConfigWidget::postGotTomahawkDirectMessageReply( const QTweetDMStatus& status ) -{ - if ( status.id() == 0 ) - QMessageBox::critical( this, tr("Tweetin' Error"), tr("There was an error posting your direct message -- sorry!") ); - else - QMessageBox::information( this, tr("Tweeted!"), tr("Your message has been posted!") ); -} - -void -TwitterConfigWidget::postGotTomahawkStatusUpdateError( QTweetNetBase::ErrorCode code, const QString& errorMsg ) -{ - qDebug() << Q_FUNC_INFO; - qDebug() << "Error posting Got Tomahawk message, error code is " << code << ", error message is " << errorMsg; - QMessageBox::critical( this, tr("Tweetin' Error"), tr("There was an error posting your status -- sorry!") ); -} - -} - -} diff --git a/src/accounts/twitter/TwitterConfigWidget.h b/src/accounts/twitter/TwitterConfigWidget.h deleted file mode 100644 index df0e0be44..000000000 --- a/src/accounts/twitter/TwitterConfigWidget.h +++ /dev/null @@ -1,83 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2010-2011, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef TWITTERACCOUNTCONFIGWIDGET_H -#define TWITTERACCOUNTCONFIGWIDGET_H - -#include "accounts/AccountDllMacro.h" - -#include -#include -#include -#include - -#include "accounts/AccountConfigWidget.h" - -namespace Ui -{ - class TwitterConfigWidget; -} - -namespace Tomahawk -{ - -namespace Accounts -{ - -class TwitterAccount; - - -class ACCOUNTDLLEXPORT TwitterConfigWidget : public AccountConfigWidget -{ - Q_OBJECT - -public: - explicit TwitterConfigWidget( TwitterAccount* account = 0, QWidget *parent = 0 ); - virtual ~TwitterConfigWidget(); - -signals: - void twitterAuthed( bool authed ); - - void sizeHintChanged(); - -private slots: - void authDeauthTwitter(); - void startPostGotTomahawkStatus(); - void authenticateVerifyReply( const QTweetUser &user ); - void authenticateVerifyError( QTweetNetBase::ErrorCode code, const QString &errorMsg ); - void postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user ); - void postGotTomahawkStatusUpdateReply( const QTweetStatus &status ); - void postGotTomahawkDirectMessageReply( const QTweetDMStatus &status ); - void postGotTomahawkStatusUpdateError( QTweetNetBase::ErrorCode, const QString &errorMsg ); - void tweetComboBoxIndexChanged( int index ); - -private: - void authenticateTwitter(); - void deauthenticateTwitter(); - - Ui::TwitterConfigWidget *m_ui; - TwitterAccount *m_account; - QString m_postGTtype; -}; - -} - -} - -#endif // TWITTERCONFIGWIDGET_H diff --git a/src/accounts/twitter/TwitterConfigWidget.ui b/src/accounts/twitter/TwitterConfigWidget.ui deleted file mode 100644 index 596e83116..000000000 --- a/src/accounts/twitter/TwitterConfigWidget.ui +++ /dev/null @@ -1,381 +0,0 @@ - - - TwitterConfigWidget - - - - 0 - 0 - 380 - 180 - - - - - 0 - 0 - - - - - 380 - 180 - - - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - - 0 - 0 - - - - - - - :/twitter-account/twitter-icon.png - - - - - - - - 0 - 0 - - - - - 11 - 75 - true - - - - Configure this Twitter account - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 40 - 0 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - 0 - 0 - - - - The Twitter plugin allows you to post messages to your Twitter account. - - - true - - - - - - - - - - 0 - 0 - - - - Status: No saved credentials - - - Qt::AutoText - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Authenticate with Twitter - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - Twitter Connections - - - - - - -If you only want to post tweets, you're done. - -If you want to connect Tomahawk to your friends using Twitter, select the type of tweet and press the button below to send a sync message. You must both be following each other as Direct Messages are used. Then be (very) patient -- it can take several minutes! - -You can re-send a sync message at any time simply by sending another tweet using the button. - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - - - - QLayout::SetFixedSize - - - - - - 0 - 0 - - - - Select the kind of tweet you would like, then press the button to post it: - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - - - - 0 - 0 - - - - - Global Tweet - - - - - @Mention - - - - - Direct Message - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - - 250 - 0 - - - - e.g. @tomahawk - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - Send Message - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - - diff --git a/src/accounts/twitter/TwitterInfoPlugin.cpp b/src/accounts/twitter/TwitterInfoPlugin.cpp deleted file mode 100644 index f6342dc3a..000000000 --- a/src/accounts/twitter/TwitterInfoPlugin.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2012, Dominik Schmidt - * Copyright 2012, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - - -#include "TwitterInfoPlugin.h" - -#include "TwitterAccount.h" - -#include "GlobalActionManager.h" -#include "utils/Logger.h" -#include "Source.h" - -#include -#include - -namespace Tomahawk -{ - -namespace InfoSystem -{ - -TwitterInfoPlugin::TwitterInfoPlugin( Tomahawk::Accounts::TwitterAccount* account ) - : m_account( account ) -{ - m_supportedPushTypes << InfoShareTrack << InfoLove; -} - - -void -TwitterInfoPlugin::init() -{ - if ( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread() && thread() != Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() ) - { - tDebug() << "Failure: move to the worker thread before running init"; - return; - } - - QVariantHash credentials = m_account->credentials(); - if ( credentials[ "oauthtoken" ].toString().isEmpty() || credentials[ "oauthtokensecret" ].toString().isEmpty() ) - { - tDebug() << "TwitterInfoPlugin has empty Twitter credentials; not connecting"; - return; - } - - if ( refreshTwitterAuth() ) - { - QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this ); - connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( connectAuthVerifyReply( const QTweetUser & ) ) ); - credVerifier->verify(); - } -} - - -TwitterInfoPlugin::~TwitterInfoPlugin() -{ - tDebug() << Q_FUNC_INFO; -} - - -bool -TwitterInfoPlugin::refreshTwitterAuth() -{ - tDebug() << Q_FUNC_INFO << "begin" << this; - if ( !m_twitterAuth.isNull() ) - delete m_twitterAuth.data(); - - Q_ASSERT( TomahawkUtils::nam() != 0 ); - tDebug() << Q_FUNC_INFO << "with nam" << TomahawkUtils::nam() << this; - m_twitterAuth = QPointer< TomahawkOAuthTwitter >( new TomahawkOAuthTwitter( TomahawkUtils::nam(), this ) ); - - if ( m_twitterAuth.isNull() ) - return false; - - m_twitterAuth.data()->setOAuthToken( m_account->credentials()[ "oauthtoken" ].toString().toLatin1() ); - m_twitterAuth.data()->setOAuthTokenSecret( m_account->credentials()[ "oauthtokensecret" ].toString().toLatin1() ); - - return true; -} - - -void -TwitterInfoPlugin::connectAuthVerifyReply( const QTweetUser &user ) -{ - if ( user.id() == 0 ) - { - tDebug() << "TwitterInfoPlugin could not authenticate to Twitter" << this; - deleteLater(); - return; - } - else - { - tDebug() << "TwitterInfoPlugin successfully authenticated to Twitter" << this; - return; - } -} - - -void -TwitterInfoPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ) -{ - tDebug() << Q_FUNC_INFO; - if ( !isValid() ) - { - tDebug() << Q_FUNC_INFO << "Plugin not valid, deleting and returning"; - deleteLater(); - return; - } - - Tomahawk::InfoSystem::PushInfoPair pushInfoPair = pushData.infoPair; - - if ( !pushInfoPair.second.canConvert< QVariantMap >() ) - { - tLog() << Q_FUNC_INFO << "Failed to find QVariantMap!"; - return; - } - - QVariantMap map = pushInfoPair.second.toMap(); - - if ( !map.contains( "accountlist" ) || !map[ "accountlist" ].canConvert< QStringList >() ) - { - tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Cowardly failing to send out a message without an account list present"; - return; - } - - const QStringList accountList = map[ "accountlist" ].toStringList(); - if ( !accountList.contains( "all" ) && !accountList.contains( m_account->accountId() ) ) - { - tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Our account not in the list, not tweeting out"; - return; - } - - if ( !map.contains( "message" ) && ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() ) ) - { - tLog() << Q_FUNC_INFO << "Failed to find message or trackinfo"; - return; - } - - Tomahawk::InfoSystem::InfoStringHash info; - QString msg; - if ( !map.contains( "message" ) ) - { - info = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >(); - msg = tr( "Listening to \"%1\" by %2 and loving it! %3" ) - .arg( info[ "title" ] ) - .arg( info[ "artist" ] ) - .arg( pushInfoPair.first.contains( "shorturl" ) ? - pushInfoPair.first[ "shorturl" ].toUrl().toString() : - GlobalActionManager::instance()->openLink( info[ "title" ], info[ "artist" ], info[ "album" ] ).toString() ); - } - else - msg = map[ "message" ].toString(); - - QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( m_twitterAuth.data(), this ); - connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postLovedStatusUpdateReply(const QTweetStatus &) ) ); - connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postLovedStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) ); - tDebug() << Q_FUNC_INFO << "Posting message:" << msg; - statUpdate->post( msg ); -} - - -void -TwitterInfoPlugin::postLovedStatusUpdateReply( const QTweetStatus& status ) -{ - if ( status.id() == 0 ) - tDebug() << Q_FUNC_INFO << "Failed to post loved status"; - else - tDebug() << Q_FUNC_INFO << "Successfully posted loved status"; -} - - -void -TwitterInfoPlugin::postLovedStatusUpdateError( QTweetNetBase::ErrorCode code, const QString& errorMsg ) -{ - tDebug() << Q_FUNC_INFO << "Error posting love message, error code is " << code << ", error message is " << errorMsg; -} - - -bool -TwitterInfoPlugin::isValid() const -{ - return !m_twitterAuth.isNull(); -} - -} - -} diff --git a/src/accounts/twitter/TwitterInfoPlugin.h b/src/accounts/twitter/TwitterInfoPlugin.h deleted file mode 100644 index 187df4c6c..000000000 --- a/src/accounts/twitter/TwitterInfoPlugin.h +++ /dev/null @@ -1,80 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2012, Dominik Schmidt - * Copyright 2012, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef TWITTERINFOPLUGIN_H -#define TWITTERINFOPLUGIN_H - -#include "infosystem/InfoSystem.h" -#include "TomahawkOAuthTwitter.h" - -#include -#include -#include - -namespace Tomahawk { - - namespace Accounts { - class TwitterAccount; - } - - namespace InfoSystem { - - class TwitterInfoPlugin : public InfoPlugin - { - Q_OBJECT - - public: - TwitterInfoPlugin( Tomahawk::Accounts::TwitterAccount* account ); - virtual ~TwitterInfoPlugin(); - - public slots: - void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) - { - Q_UNUSED( criteria ); - Q_UNUSED( requestData ); - } - - protected slots: - void init(); - void pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ); - void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) - { - Q_UNUSED( requestData ); - } - - private slots: - void connectAuthVerifyReply( const QTweetUser &user ); - void postLovedStatusUpdateReply( const QTweetStatus& status ); - void postLovedStatusUpdateError( QTweetNetBase::ErrorCode code, const QString& errorMsg ); - - private: - bool refreshTwitterAuth(); - bool isValid() const; - - Tomahawk::Accounts::TwitterAccount* m_account; - QPointer< TomahawkOAuthTwitter > m_twitterAuth; - }; - - } - -} - -#endif // TWITTERINFOPLUGIN_H - -struct A; diff --git a/src/accounts/twitter/resources.qrc b/src/accounts/twitter/resources.qrc deleted file mode 100644 index bc05cfdb3..000000000 --- a/src/accounts/twitter/resources.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - twitter-icon.png - twitter-offline-icon.png - - diff --git a/src/accounts/twitter/sip/TwitterSip.cpp b/src/accounts/twitter/sip/TwitterSip.cpp deleted file mode 100644 index 527a9705b..000000000 --- a/src/accounts/twitter/sip/TwitterSip.cpp +++ /dev/null @@ -1,723 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2011, Leo Franchi - * Copyright 2010-2011, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#include "TwitterSip.h" - -#include "utils/TomahawkUtils.h" -#include "TomahawkSettings.h" -#include "database/Database.h" -#include "database/DatabaseImpl.h" -#include "network/Servent.h" -#include "Source.h" - -#include "utils/Logger.h" -#include "accounts/twitter/TomahawkOAuthTwitter.h" -#include "accounts/twitter/TwitterAccount.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -static QString s_gotTomahawkRegex = QString( "^(@[a-zA-Z0-9]+ )?(Got Tomahawk\\?) (\\{[a-fA-F0-9\\-]+\\}) (.*)$" ); - -TwitterSipPlugin::TwitterSipPlugin( Tomahawk::Accounts::Account* account ) - : SipPlugin( account ) - , m_checkTimer( this ) - , m_connectTimer( this ) - , m_dmPollTimer( this ) - , m_cachedFriendsSinceId( 0 ) - , m_cachedMentionsSinceId( 0 ) - , m_cachedDirectMessagesSinceId( 0 ) - , m_cachedPeers() - , m_keyCache() - , m_state( Tomahawk::Accounts::Account::Disconnected ) -{ - qDebug() << Q_FUNC_INFO; - - connect( account, SIGNAL( nowAuthenticated( const QPointer< TomahawkOAuthTwitter > &, const QTweetUser & ) ), SLOT( accountAuthenticated( const QPointer< TomahawkOAuthTwitter > &, const QTweetUser & ) ) ); - - m_configuration = account->configuration(); - qDebug() << "SIP configuration:" << m_configuration << m_configuration[ "cachedpeers" ]; - if ( Database::instance()->impl()->dbid() != m_account->configuration()[ "saveddbid" ].toString() ) - { - m_configuration[ "cachedpeers" ] = QVariantHash(); - m_configuration[ "saveddbid" ] = Database::instance()->impl()->dbid(); - syncConfig(); - } - - m_checkTimer.setInterval( 180000 ); - m_checkTimer.setSingleShot( false ); - connect( &m_checkTimer, SIGNAL( timeout() ), SLOT( checkTimerFired() ) ); - - m_dmPollTimer.setInterval( 60000 ); - m_dmPollTimer.setSingleShot( false ); - connect( &m_dmPollTimer, SIGNAL( timeout() ), SLOT( pollDirectMessages() ) ); - - m_connectTimer.setInterval( 180000 ); - m_connectTimer.setSingleShot( false ); - connect( &m_connectTimer, SIGNAL( timeout() ), SLOT( connectTimerFired() ) ); -} - - -bool -TwitterSipPlugin::isValid() const -{ - return m_account->enabled() && m_account->isAuthenticated() && !m_cachedTwitterAuth.isNull(); -} - - -Tomahawk::Accounts::Account::ConnectionState -TwitterSipPlugin::connectionState() const -{ - return m_state; -} - -QString -TwitterSipPlugin::inviteString() const -{ - return tr( "Enter Twitter username" ); -} - - -void -TwitterSipPlugin::checkSettings() -{ - configurationChanged(); -} - - -void -TwitterSipPlugin::connectPlugin() -{ - tDebug() << Q_FUNC_INFO; - if ( !m_account->enabled() ) - { - tDebug() << Q_FUNC_INFO << "account isn't enabled"; - return; - } - - m_cachedPeers = m_configuration[ "cachedpeers" ].toHash(); - QStringList peerList = m_cachedPeers.keys(); - qStableSort( peerList.begin(), peerList.end() ); - - if ( !m_account->isAuthenticated() ) - { - tDebug() << Q_FUNC_INFO << "account isn't authenticated, attempting"; - m_account->authenticate(); - } - - m_state = Tomahawk::Accounts::Account::Connecting; - emit stateChanged( m_state ); -} - - -void -TwitterSipPlugin::disconnectPlugin() -{ - tDebug() << Q_FUNC_INFO; - m_checkTimer.stop(); - m_connectTimer.stop(); - m_dmPollTimer.stop(); - if( !m_friendsTimeline.isNull() ) - delete m_friendsTimeline.data(); - if( !m_mentions.isNull() ) - delete m_mentions.data(); - if( !m_directMessages.isNull() ) - delete m_directMessages.data(); - if( !m_directMessageNew.isNull() ) - delete m_directMessageNew.data(); - if( !m_directMessageDestroy.isNull() ) - delete m_directMessageDestroy.data(); - - m_cachedTwitterAuth = 0; - - m_configuration[ "cachedpeers" ] = m_cachedPeers; - syncConfig(); - m_cachedPeers.empty(); - m_state = Tomahawk::Accounts::Account::Disconnected; - emit stateChanged( m_state ); -} - -void -TwitterSipPlugin::accountAuthenticated( const QPointer< TomahawkOAuthTwitter > &twitterAuth, const QTweetUser &user ) -{ - Q_UNUSED( user ); - - if ( !m_account->enabled() || !m_account->isAuthenticated() ) - return; - - m_cachedTwitterAuth = twitterAuth; - - m_friendsTimeline = QPointer( new QTweetFriendsTimeline( m_cachedTwitterAuth.data(), this ) ); - m_mentions = QPointer( new QTweetMentions( m_cachedTwitterAuth.data(), this ) ); - m_directMessages = QPointer( new QTweetDirectMessages( m_cachedTwitterAuth.data(), this ) ); - m_directMessageNew = QPointer( new QTweetDirectMessageNew( m_cachedTwitterAuth.data(), this ) ); - m_directMessageDestroy = QPointer( new QTweetDirectMessageDestroy( m_cachedTwitterAuth.data(), this ) ); - connect( m_friendsTimeline.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( friendsTimelineStatuses(const QList &) ) ); - connect( m_mentions.data(), SIGNAL( parsedStatuses(const QList< QTweetStatus > &) ), SLOT( mentionsStatuses(const QList &) ) ); - connect( m_directMessages.data(), SIGNAL( parsedDirectMessages(const QList &)), SLOT( directMessages(const QList &) ) ); - connect( m_directMessageNew.data(), SIGNAL( parsedDirectMessage(const QTweetDMStatus &)), SLOT( directMessagePosted(const QTweetDMStatus &) ) ); - connect( m_directMessageNew.data(), SIGNAL( error(QTweetNetBase::ErrorCode, const QString &) ), SLOT( directMessagePostError(QTweetNetBase::ErrorCode, const QString &) ) ); - connect( m_directMessageDestroy.data(), SIGNAL( parsedDirectMessage(const QTweetDMStatus &) ), SLOT( directMessageDestroyed(const QTweetDMStatus &) ) ); - m_state = Tomahawk::Accounts::Account::Connected; - emit stateChanged( m_state ); - QStringList peerList = m_cachedPeers.keys(); - qStableSort( peerList.begin(), peerList.end() ); - registerOffers( peerList ); - m_connectTimer.start(); - m_checkTimer.start(); - m_dmPollTimer.start(); - - QMetaObject::invokeMethod( this, "checkTimerFired", Qt::AutoConnection ); - QTimer::singleShot( 20000, this, SLOT( connectTimerFired() ) ); -} - - -void -TwitterSipPlugin::checkTimerFired() -{ - if ( !isValid() ) - return; - - if ( m_cachedFriendsSinceId == 0 ) - m_cachedFriendsSinceId = m_configuration[ "cachedfriendssinceid" ].toLongLong(); - - qDebug() << "TwitterSipPlugin looking at friends timeline since id " << m_cachedFriendsSinceId; - - if ( !m_friendsTimeline.isNull() ) - m_friendsTimeline.data()->fetch( m_cachedFriendsSinceId, 0, 800 ); - - if ( m_cachedMentionsSinceId == 0 ) - m_cachedMentionsSinceId = m_configuration[ "cachedmentionssinceid" ].toLongLong(); - - qDebug() << "TwitterSipPlugin looking at mentions timeline since id " << m_cachedMentionsSinceId; - - if ( !m_mentions.isNull() ) - m_mentions.data()->fetch( m_cachedMentionsSinceId, 0, 800 ); -} - - -void -TwitterSipPlugin::registerOffers( const QStringList &peerList ) -{ - if ( !isValid() ) - return; - - foreach( QString screenName, peerList ) - { - QVariantHash peerData = m_cachedPeers[screenName].toHash(); - - if ( peerData.contains( "onod" ) && peerData["onod"] != Database::instance()->impl()->dbid() ) - { - m_cachedPeers.remove( screenName ); - m_configuration[ "cachedpeers" ] = m_cachedPeers; - syncConfig(); - } - - if ( Servent::instance()->connectedToSession( peerData["node"].toString() ) ) - { - peerData["lastseen"] = QDateTime::currentMSecsSinceEpoch(); - m_cachedPeers[screenName] = peerData; - m_configuration[ "cachedpeers" ] = m_cachedPeers; - syncConfig(); - qDebug() << Q_FUNC_INFO << " already connected"; - continue; - } - else if ( QDateTime::currentMSecsSinceEpoch() - peerData["lastseen"].toLongLong() > 1209600000 ) // 2 weeks - { - qDebug() << Q_FUNC_INFO << " aging peer " << screenName << " out of cache"; - m_cachedPeers.remove( screenName ); - m_configuration[ "cachedpeers" ] = m_cachedPeers; - syncConfig(); - m_cachedAvatars.remove( screenName ); - continue; - } - - if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) ) - { - qDebug() << "TwitterSipPlugin does not have host, port and/or pkey values for " << screenName << " (this is usually *not* a bug or problem but a normal part of the process)"; - continue; - } - - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), Q_ARG( QVariantHash, peerData ) ); - } -} - - -void -TwitterSipPlugin::connectTimerFired() -{ - tDebug() << Q_FUNC_INFO << " beginning"; - if ( !isValid() || m_cachedPeers.isEmpty() ) - { - if ( !isValid() ) - tDebug() << Q_FUNC_INFO << " is not valid"; - if ( m_cachedPeers.isEmpty() ) - tDebug() << Q_FUNC_INFO << " has empty cached peers"; - return; - } - - tDebug() << Q_FUNC_INFO << " continuing"; - QString myScreenName = m_configuration[ "screenname" ].toString(); - QStringList peerList = m_cachedPeers.keys(); - qStableSort( peerList.begin(), peerList.end() ); - registerOffers( peerList ); -} - -void -TwitterSipPlugin::parseGotTomahawk( const QRegExp ®ex, const QString &screenName, const QString &text ) -{ - QString myScreenName = m_configuration[ "screenname" ].toString(); - qDebug() << "TwitterSipPlugin found an exact matching Got Tomahawk? mention or direct message from user " << screenName << ", now parsing"; - regex.exactMatch( text ); - if ( text.startsWith( '@' ) && regex.captureCount() >= 2 && regex.cap( 1 ) != QString( '@' + myScreenName ) ) - { - qDebug() << "TwitterSipPlugin skipping mention because it's directed @someone that isn't us"; - return; - } - - QString node; - for ( int i = 0; i < regex.captureCount(); ++i ) - { - if ( regex.cap( i ) == QString( "Got Tomahawk?" ) ) - { - QString nodeCap = regex.cap( i + 1 ); - nodeCap.chop( 1 ); - node = nodeCap.mid( 1 ); - } - } - if ( node.isEmpty() ) - { - qDebug() << "TwitterSipPlugin could not parse node out of the tweet"; - return; - } - else - qDebug() << "TwitterSipPlugin parsed node " << node << " out of the tweet"; - - if ( node == Database::instance()->impl()->dbid() ) - { - qDebug() << "My dbid found; ignoring"; - return; - } - - QVariantHash peerData; - if( m_cachedPeers.contains( screenName ) ) - { - peerData = m_cachedPeers[screenName].toHash(); - //force a re-send of info but no need to re-register - peerData["resend"] = QVariant::fromValue< bool >( true ); - if ( peerData["node"].toString() != node ) - peerData["rekey"] = QVariant::fromValue< bool >( true ); - } - peerData["node"] = QVariant::fromValue< QString >( node ); - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, screenName ), Q_ARG( QVariantHash, peerData ) ); -} - -void -TwitterSipPlugin::friendsTimelineStatuses( const QList< QTweetStatus > &statuses ) -{ - tDebug() << Q_FUNC_INFO; - QRegExp regex( s_gotTomahawkRegex, Qt::CaseSensitive, QRegExp::RegExp2 ); - - QHash< QString, QTweetStatus > latestHash; - foreach ( QTweetStatus status, statuses ) - { - if ( !regex.exactMatch( status.text() ) ) - continue; - - if ( !latestHash.contains( status.user().screenName() ) ) - latestHash[status.user().screenName()] = status; - else - { - if ( status.id() > latestHash[status.user().screenName()].id() ) - latestHash[status.user().screenName()] = status; - } - } - - foreach( QTweetStatus status, latestHash.values() ) - { - if ( status.id() > m_cachedFriendsSinceId ) - m_cachedFriendsSinceId = status.id(); - - tDebug() << "TwitterSipPlugin checking mention from " << status.user().screenName() << " with content " << status.text(); - parseGotTomahawk( regex, status.user().screenName(), status.text() ); - } - - m_configuration[ "cachedfriendssinceid" ] = m_cachedFriendsSinceId; - syncConfig(); -} - -void -TwitterSipPlugin::mentionsStatuses( const QList< QTweetStatus > &statuses ) -{ - tDebug() << Q_FUNC_INFO; - QRegExp regex( s_gotTomahawkRegex, Qt::CaseSensitive, QRegExp::RegExp2 ); - - QHash< QString, QTweetStatus > latestHash; - foreach ( QTweetStatus status, statuses ) - { - if ( !regex.exactMatch( status.text() ) ) - continue; - - if ( !latestHash.contains( status.user().screenName() ) ) - latestHash[status.user().screenName()] = status; - else - { - if ( status.id() > latestHash[status.user().screenName()].id() ) - latestHash[status.user().screenName()] = status; - } - } - - foreach( QTweetStatus status, latestHash.values() ) - { - if ( status.id() > m_cachedMentionsSinceId ) - m_cachedMentionsSinceId = status.id(); - - tDebug() << "TwitterSipPlugin checking mention from " << status.user().screenName() << " with content " << status.text(); - parseGotTomahawk( regex, status.user().screenName(), status.text() ); - } - - m_configuration[ "cachedmentionssinceid" ] = m_cachedMentionsSinceId; - syncConfig(); -} - -void -TwitterSipPlugin::pollDirectMessages() -{ - if ( !isValid() ) - return; - - if ( m_cachedDirectMessagesSinceId == 0 ) - m_cachedDirectMessagesSinceId = m_configuration[ "cacheddirectmessagessinceid" ].toLongLong(); - - tDebug() << "TwitterSipPlugin looking for direct messages since id " << m_cachedDirectMessagesSinceId; - - if ( !m_directMessages.isNull() ) - m_directMessages.data()->fetch( m_cachedDirectMessagesSinceId, 0, 800 ); -} - -void -TwitterSipPlugin::directMessages( const QList< QTweetDMStatus > &messages ) -{ - tDebug() << Q_FUNC_INFO; - - QRegExp regex( s_gotTomahawkRegex, Qt::CaseSensitive, QRegExp::RegExp2 ); - QString myScreenName = m_configuration[ "screenname" ].toString(); - - QHash< QString, QTweetDMStatus > latestHash; - foreach ( QTweetDMStatus status, messages ) - { - if ( !regex.exactMatch( status.text() ) ) - { - QStringList splitList = status.text().split(':'); - if ( splitList.length() != 5 ) - continue; - if ( splitList[0] != "TOMAHAWKPEER" ) - continue; - if ( !splitList[1].startsWith( "Host=" ) || !splitList[2].startsWith( "Port=" ) || !splitList[3].startsWith( "Node=" ) || !splitList[4].startsWith( "PKey=" ) ) - continue; - int port = splitList[2].mid( 5 ).toInt(); - if ( port == 0 ) - continue; - } - - if ( !latestHash.contains( status.senderScreenName() ) ) - latestHash[status.senderScreenName()] = status; - else - { - if ( status.id() > latestHash[status.senderScreenName()].id() ) - latestHash[status.senderScreenName()] = status; - } - } - - foreach( QTweetDMStatus status, latestHash.values() ) - { - qDebug() << "TwitterSipPlugin checking direct message from " << status.senderScreenName() << " with content " << status.text(); - if ( status.id() > m_cachedDirectMessagesSinceId ) - m_cachedDirectMessagesSinceId = status.id(); - - if ( regex.exactMatch( status.text() ) ) - parseGotTomahawk( regex, status.sender().screenName(), status.text() ); - else - { - QStringList splitList = status.text().split(':'); - qDebug() << "TwitterSipPlugin found " << splitList.length() << " parts to the message; the parts are:"; - foreach( QString part, splitList ) - qDebug() << part; - //validity is checked above - int port = splitList[2].mid( 5 ).toInt(); - QString host = splitList[1].mid( 5 ); - QString node = splitList[3].mid( 5 ); - QString pkey = splitList[4].mid( 5 ); - QStringList splitNode = node.split('*'); - if ( splitNode.length() != 2 ) - { - qDebug() << "Old-style node info found, ignoring"; - continue; - } - qDebug() << "TwitterSipPlugin found a peerstart message from " << status.senderScreenName() << " with host " << host << " and port " << port << " and pkey " << pkey << " and node " << splitNode[0] << " destined for node " << splitNode[1]; - - - QVariantHash peerData = ( m_cachedPeers.contains( status.senderScreenName() ) ) ? - m_cachedPeers[status.senderScreenName()].toHash() : - QVariantHash(); - - peerData["host"] = QVariant::fromValue< QString >( host ); - peerData["port"] = QVariant::fromValue< int >( port ); - peerData["pkey"] = QVariant::fromValue< QString >( pkey ); - peerData["node"] = QVariant::fromValue< QString >( splitNode[0] ); - peerData["dirty"] = QVariant::fromValue< bool >( true ); - - QMetaObject::invokeMethod( this, "registerOffer", Q_ARG( QString, status.senderScreenName() ), Q_ARG( QVariantHash, peerData ) ); - - if ( Database::instance()->impl()->dbid().startsWith( splitNode[1] ) ) - { - qDebug() << "TwitterSipPlugin found message destined for this node; destroying it"; - if ( !m_directMessageDestroy.isNull() ) - m_directMessageDestroy.data()->destroyMessage( status.id() ); - } - } - } - - m_configuration[ "cacheddirectmessagessinceid" ] = m_cachedDirectMessagesSinceId; - syncConfig(); -} - -void -TwitterSipPlugin::registerOffer( const QString &screenName, const QVariantHash &peerData ) -{ - qDebug() << Q_FUNC_INFO; - - bool peersChanged = false; - bool needToSend = false; - bool needToAddToCache = false; - - QString friendlyName = QString( '@' + screenName ); - - if ( !m_cachedAvatars.contains( screenName ) ) - QMetaObject::invokeMethod( this, "fetchAvatar", Q_ARG( QString, screenName ) ); - - QVariantHash _peerData( peerData ); - - if ( _peerData.contains( "dirty" ) ) - { - peersChanged = true; - _peerData.remove( "dirty" ); - } - - if ( _peerData.contains( "resend" ) ) - { - needToSend = true; - peersChanged = true; - _peerData.remove( "resend" ); - } - - if ( !_peerData.contains( "okey" ) || - !_peerData.contains( "onod" ) || - ( _peerData.contains( "onod" ) && _peerData["onod"] != Database::instance()->impl()->dbid() ) ) - { - QString okey = QUuid::createUuid().toString().split( '-' ).last(); - okey.chop( 1 ); - _peerData["okey"] = QVariant::fromValue< QString >( okey ); - _peerData["onod"] = QVariant::fromValue< QString >( Database::instance()->impl()->dbid() ); - peersChanged = true; - needToAddToCache = true; - needToSend = true; - } - - if ( _peerData.contains( "rekey" ) || !m_keyCache.contains( _peerData["okey"].toString() ) ) - { - _peerData.remove( "rekey" ); - needToAddToCache = true; - } - - if ( !_peerData.contains( "ohst" ) || !_peerData.contains( "oprt" ) || - _peerData["ohst"].toString() != Servent::instance()->externalAddress() || - _peerData["oprt"].toInt() != Servent::instance()->externalPort() - ) - needToSend = true; - - if( needToAddToCache && _peerData.contains( "node" ) ) - { - qDebug() << "TwitterSipPlugin registering offer to " << friendlyName << " with node " << _peerData["node"].toString() << " and offeredkey " << _peerData["okey"].toString(); - m_keyCache << Servent::instance()->createConnectionKey( friendlyName, _peerData["node"].toString(), _peerData["okey"].toString(), false ); - } - - if( needToSend && _peerData.contains( "node") ) - { - qDebug() << "TwitterSipPlugin needs to send and has node"; - _peerData["ohst"] = QVariant::fromValue< QString >( Servent::instance()->externalAddress() ); - _peerData["oprt"] = QVariant::fromValue< int >( Servent::instance()->externalPort() ); - peersChanged = true; - if( !Servent::instance()->externalAddress().isEmpty() && !Servent::instance()->externalPort() == 0 ) - QMetaObject::invokeMethod( this, "sendOffer", Q_ARG( QString, screenName ), Q_ARG( QVariantHash, _peerData ) ); - else - qDebug() << "TwitterSipPlugin did not send offer because external address is " << Servent::instance()->externalAddress() << " and external port is " << Servent::instance()->externalPort(); - } - - if ( peersChanged ) - { - _peerData["lastseen"] = QString::number( QDateTime::currentMSecsSinceEpoch() ); - m_cachedPeers[screenName] = QVariant::fromValue< QVariantHash >( _peerData ); - m_configuration[ "cachedpeers" ] = m_cachedPeers; - syncConfig(); - } - - if ( m_state == Tomahawk::Accounts::Account::Connected && _peerData.contains( "host" ) && _peerData.contains( "port" ) && _peerData.contains( "pkey" ) ) - QMetaObject::invokeMethod( this, "makeConnection", Q_ARG( QString, screenName ), Q_ARG( QVariantHash, _peerData ) ); - -} - -void -TwitterSipPlugin::sendOffer( const QString &screenName, const QVariantHash &peerData ) -{ - qDebug() << Q_FUNC_INFO; - QString offerString = QString( "TOMAHAWKPEER:Host=%1:Port=%2:Node=%3*%4:PKey=%5" ).arg( peerData["ohst"].toString() ) - .arg( peerData["oprt"].toString() ) - .arg( Database::instance()->impl()->dbid() ) - .arg( peerData["node"].toString().left( 8 ) ) - .arg( peerData["okey"].toString() ); - qDebug() << "TwitterSipPlugin sending message to " << screenName << ": " << offerString; - if( !m_directMessageNew.isNull() ) - m_directMessageNew.data()->post( screenName, offerString ); -} - -void -TwitterSipPlugin::makeConnection( const QString &screenName, const QVariantHash &peerData ) -{ - qDebug() << Q_FUNC_INFO; - if ( !peerData.contains( "host" ) || !peerData.contains( "port" ) || !peerData.contains( "pkey" ) || !peerData.contains( "node" ) || - peerData["host"].toString().isEmpty() || peerData["port"].toString().isEmpty() || peerData["pkey"].toString().isEmpty() || peerData["node"].toString().isEmpty() ) - { - qDebug() << "TwitterSipPlugin could not find host and/or port and/or pkey and/or node for peer " << screenName; - return; - } - - if ( peerData["host"].toString() == Servent::instance()->externalAddress() && - peerData["port"].toInt() == Servent::instance()->externalPort() ) - { - qDebug() << "TwitterSipPlugin asked to make connection to our own host and port, ignoring " << screenName; - return; - } - - QString friendlyName = QString( '@' + screenName ); - if ( !Servent::instance()->connectedToSession( peerData["node"].toString() ) ) - Servent::instance()->connectToPeer( peerData["host"].toString(), - peerData["port"].toString().toInt(), - peerData["pkey"].toString(), - friendlyName, - peerData["node"].toString() ); -} - -void -TwitterSipPlugin::directMessagePosted( const QTweetDMStatus& message ) -{ - qDebug() << Q_FUNC_INFO; - qDebug() << "TwitterSipPlugin sent message to " << message.recipientScreenName() << " containing: " << message.text(); - -} - -void -TwitterSipPlugin::directMessagePostError( QTweetNetBase::ErrorCode errorCode, const QString &message ) -{ - Q_UNUSED( errorCode ); - Q_UNUSED( message ); - qDebug() << Q_FUNC_INFO; - qDebug() << "TwitterSipPlugin received an error posting direct message: " << m_directMessageNew.data()->lastErrorMessage(); -} - -void -TwitterSipPlugin::directMessageDestroyed( const QTweetDMStatus& message ) -{ - qDebug() << Q_FUNC_INFO; - qDebug() << "TwitterSipPlugin destroyed message " << message.text(); -} - -void -TwitterSipPlugin::fetchAvatar( const QString& screenName ) -{ - qDebug() << Q_FUNC_INFO; - if ( !isValid() ) - return; - - QTweetUserShow *userShowFetch = new QTweetUserShow( m_cachedTwitterAuth.data(), this ); - connect( userShowFetch, SIGNAL( parsedUserInfo( QTweetUser ) ), SLOT( avatarUserDataSlot( QTweetUser ) ) ); - userShowFetch->fetch( screenName ); -} - -void -TwitterSipPlugin::avatarUserDataSlot( const QTweetUser &user ) -{ - tDebug() << Q_FUNC_INFO; - if ( !isValid() || user.profileImageUrl().isEmpty()) - return; - - QNetworkRequest request( user.profileImageUrl() ); - QNetworkReply *reply = m_cachedTwitterAuth.data()->networkAccessManager()->get( request ); - reply->setProperty( "screenname", user.screenName() ); - connect( reply, SIGNAL( finished() ), this, SLOT( profilePicReply() ) ); -} - - -void -TwitterSipPlugin::profilePicReply() -{ - tDebug() << Q_FUNC_INFO; - QNetworkReply *reply = qobject_cast< QNetworkReply* >( sender() ); - if ( !reply || reply->error() != QNetworkReply::NoError || !reply->property( "screenname" ).isValid() ) - { - tDebug() << Q_FUNC_INFO << " reply not valid or came back with error"; - return; - } - QString screenName = reply->property( "screenname" ).toString(); - QString friendlyName = '@' + screenName; - QByteArray rawData = reply->readAll(); - QImage image; - image.loadFromData( rawData, "PNG" ); - QPixmap pixmap = QPixmap::fromImage( image ); - m_cachedAvatars[screenName] = pixmap; - emit avatarReceived( friendlyName, QPixmap::fromImage( image ) ); -} - -void -TwitterSipPlugin::configurationChanged() -{ - tDebug() << Q_FUNC_INFO; - if ( m_state != Tomahawk::Accounts::Account::Disconnected ) - m_account->deauthenticate(); - connectPlugin(); -} - - -void -TwitterSipPlugin::syncConfig() -{ - m_account->setConfiguration( m_configuration ); - m_account->sync(); -} diff --git a/src/accounts/twitter/sip/TwitterSip.h b/src/accounts/twitter/sip/TwitterSip.h deleted file mode 100644 index 89ac5d26e..000000000 --- a/src/accounts/twitter/sip/TwitterSip.h +++ /dev/null @@ -1,132 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2011, Leo Franchi - * Copyright 2010-2011, Jeff Mitchell - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef TWITTER_H -#define TWITTER_H - -#include "accounts/AccountDllMacro.h" -#include "sip/SipPlugin.h" -#include "accounts/Account.h" -#include "accounts/twitter/TomahawkOAuthTwitter.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -class ACCOUNTDLLEXPORT TwitterSipPlugin : public SipPlugin -{ - Q_OBJECT - -public: - TwitterSipPlugin( Tomahawk::Accounts::Account *account ); - - virtual ~TwitterSipPlugin() {} - - virtual bool isValid() const; - virtual Tomahawk::Accounts::Account::ConnectionState connectionState() const; - virtual QString inviteString() const; - -signals: - void stateChanged( Tomahawk::Accounts::Account::ConnectionState ); - -public slots: - virtual void connectPlugin(); - void disconnectPlugin(); - void configurationChanged(); - - void sendMsg( const QString& peerId, const SipInfo& info ) - { - Q_UNUSED( peerId ); - Q_UNUSED( info ); - } - - void broadcastMsg( const QString &msg ) - { - Q_UNUSED( msg ); - } - - bool addContact( const QString &peerId, AddContactOptions options, const QString& msg = QString() ) - { - Q_UNUSED( peerId ); - Q_UNUSED( msg ); - Q_UNUSED( options ); - - return false; - } - - void checkSettings(); - -private slots: - void accountAuthenticated( const QPointer< TomahawkOAuthTwitter > &twitterAuth, const QTweetUser &user ); - void checkTimerFired(); - void connectTimerFired(); - void friendsTimelineStatuses( const QList< QTweetStatus > &statuses ); - void mentionsStatuses( const QList< QTweetStatus > &statuses ); - void pollDirectMessages(); - void directMessages( const QList< QTweetDMStatus > &messages ); - void directMessagePosted( const QTweetDMStatus &message ); - void directMessagePostError( QTweetNetBase::ErrorCode errorCode, const QString &message ); - void directMessageDestroyed( const QTweetDMStatus &message ); - void registerOffers( const QStringList &peerList ); - void registerOffer( const QString &screenName, const QVariantHash &peerdata ); - void sendOffer( const QString &screenName, const QVariantHash &peerdata ); - void makeConnection( const QString &screenName, const QVariantHash &peerdata ); - void fetchAvatar( const QString &screenName ); - void avatarUserDataSlot( const QTweetUser &user ); - void profilePicReply(); - -private: - void syncConfig(); - bool refreshTwitterAuth(); - void parseGotTomahawk( const QRegExp ®ex, const QString &screenName, const QString &text ); - - QPointer< TomahawkOAuthTwitter > m_cachedTwitterAuth; - - QPointer< QTweetFriendsTimeline > m_friendsTimeline; - QPointer< QTweetMentions > m_mentions; - QPointer< QTweetDirectMessages > m_directMessages; - QPointer< QTweetDirectMessageNew > m_directMessageNew; - QPointer< QTweetDirectMessageDestroy > m_directMessageDestroy; - - QVariantHash m_configuration; - - QTimer m_checkTimer; - QTimer m_connectTimer; - QTimer m_dmPollTimer; - qint64 m_cachedFriendsSinceId; - qint64 m_cachedMentionsSinceId; - qint64 m_cachedDirectMessagesSinceId; - QVariantHash m_cachedPeers; - QHash< QString, QPixmap > m_cachedAvatars; - QSet m_keyCache; - Tomahawk::Accounts::Account::ConnectionState m_state; -}; - -#endif diff --git a/src/accounts/twitter/twitter-icon.png b/src/accounts/twitter/twitter-icon.png deleted file mode 100644 index aab1fca8755c0cc5b051bde0d373d5c8bf825c3f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2970 zcmV;L3uW|)P)|0rI6xS8K-7`J=rd>h^jSUiD2nZ)}Y*z&fmBZp6WXI(=KSnqp6Q?THhf}Gt zVQ?vb);s6j<=xj$0AI=%Tew`l{LRxBtMO2eYEC$s7kR8NuHDneXLfJ3er^bO z^VG%NcxWWRDy3l7Yt>*hXrZXU0D@c&CW9{N^LD2Q!B7Y$rkvn#y20i4g3lkECgjvJ zjayGII|8~+UZ9a~BGqeE=F0LSs3J3CP>Y!S|gH9y_J*o_eafxo|xjg`*6AlQ4BSb`7QwBsxBH+Zk7mRplLEtT`Doadj zsw+XER5HL*Vi5eHXiof9Dd(U-Con<+em{I_9fUiBV|FB>9dEbqec};E&Ix$q-R{lg zizS6d^M;yLpwsDK${k`Fi9{hE!t+RkR?buuMYz#>2gW8HlfEqq?d1r53y!>tz}r&?PkFq$SOvv;0pzk6&!KP> z#$7?Mj{DfWAQv)>eI$3FK1Z+h)QybWDMRc{+X8;~_W4$=M%lLYflc5Ja%q95G*wrv zn*lyshzN^SWN9;JmVhK^g(zJ7*Hv(P{B6%Ywe3*K1pM~xbDQNdndPDT*Mp$a!N8<1 zt&#uwy#@x}fkCpP#{-u}W8^(ts(|KN4Hz+K5eXmOcIM0yNLCiAAm|g}gO6_F-wW3r zc&gz_N-ls|t#jS#m7vw>;j>XMMAJxfW;FY0@QNv4^D0?WF%1A zn?s(Q5ip1YcTcGv2+Oq|E6p0W%t@uQFTDQNxfcvtb=}Gp<;?6U+7kh(YOz6x1yCIM zMDWu>*XSMzwN2;U=_>V|Fc22PMA#N3faccs)tbQ@jLqkxF^fo91zGHs(`G-POy8rn z>ApW*B@BdR?dnwwTT&PJ%^%P0G3m7?qrm`u<9=jO`V^1MeIdDS56+xFy0Kuvc0nA% zF=r5N*}NIWiebAS-OU7qjWGV;>4vU(EdcShR92K=zK>u{9+hNvsfaU}T0^ps6*#$h zu*SeLi&R%2EQE=$5ypA5z_0&su39O``?fx~3C6|P15#w?rb2csdut?VyN62@i@qx{ zYmhZu>T#kuOY4_T$wRS@gNy&T3jSco{KM}ySnqa$C^Q;$YT$SQ{l*8mmSirnP}W#o zriN?%Zb^TS3bzu23JBxaq>EOpj^5=0Xz=v~CIfi<6!@h7WLpxmMwwB_sBeUgFcQ`| zK@huc)@d~?*hH78yiF-lP_-2&13)?{ZEEH8TBoaVCD0>K$!fW%Zm%xzEhrZTLS<0 z9tXJnk&NR9vx51i!ZZGn#gWWZ0tlQIIR1kbV>Z?w6EV)23L`HTyVD6ufy>G~AeEV3 z${o+r4`CyWgmu1JpwH#Pj}X%yJfv`Eq0ubvQ7x?j> zZ&^d(h-GYI3QJF3a*m~M1|%B`gsjAY#9ClQfkJY>2oqr=jD&Um^#FkO!C@O-jG(!2 zl2%{_kN|Q6k|SI6S*-=ggr)R}un;D~Mi>`d5__p>dzZ%-wA)5UkukaCVDryg&KWB> z`hYR(wLrQ`SO^ngBaBJc1hIYFz>p2NND$M8G{$Wh2WZwt^7K7wMgq<5GOYyy@me4q zB@BdxFh%EC6P!c9%X_yUMW!tM1A}0|)Wb<+{c@iOw@1A*Bv2re5)%?@fq_YXT796t z69&RUml1AE=G+U?2{9KSQw_XK8+oIcBTMj-ucl47I5GUb;UZZNNsi}bw8jCZ- zZ+TUPN~UE7MM`84@P0J=tNmhHi?jxOw;X%i+uI8+kFOKKr~h$uS`PjG{f~7TRb5TZ z8hoX|J~S+6(KGNt1pg_B9-pQ4d)v1pYtN_f&U%-}Yw1BY!vS~9w6a#7WbcRiM17+^ z_OOxnvb_O|flE0zwH`lvLXh!I)vKz&SWv{=AsAjBb+dp)4w=1UY67fx`so`&=b?Q& zva>}dQ4StI`vT8FdueeYlvS*RFvK=NF6AaED!lk;7;M7>FgiX-eQ7zoZ^zM8-;wt0 ziilY&ktoz^T);4}t1?C#JcPkrD9v161NR9^StrciZF= z<&|S+TQPvN=yV!WX;}qm^akbr~RGtKOjSQCg&2aMW=!RhkY5k>ov{W}gx zB~!Az(s8yL15g{sL6b_UfTE&e79V(-oRL8q%FsXLXy@ePq>*rl`T4}eIQaauLJXZ8 zaBWALcjR}g>}>f-#~CBSq_3_`a-KJ9bz0CHaN>hjAt;n=Juj4Iz@*h1+W!{}_(60z z!G$C47Tri_giIZQL;FvgcRI4+PFaH{`Fe!gDC0P@Uay17>eY;dRE>dx8-X9R z-U63Pgm5(4hnHv(=XQ2QqLI$Q0gO{vm-8Gf z2%p`$+9)xqc+rb_Ewh9H37dku*-q?nnbtT zJ~1{N`}Qzv{OKCqqc+r*p83BafaI44c3q)SofsPh52iIfVWo-A=^EXmHqhq6X`9cst^5X07?Sa_;|FH$j*Pef@Ybp9Mhk(DH z>!y`rU0k&^F-thA6I2yfWr8Z=O79TjDvSRvi@V&ka{uo4vE{0-RjEEsNC-4t49Ab5 z_<1mXPRBrk`s3=0t2aSC2}+v_=|iRXXhXgKu9{;hS8@=z1-_J}mH!Gb01kfaHA8_hmj`V2+HTua96b%^h%N<5Mw&3Su|C!+0cvKx$c7v9(&LxftMrWU+oIV= z&tylb!*t+DO=RE5!5h_dR7o<`Xh^Xd8_PyOB6ktX%@l#&wK5yO;7Y~=nV~gFBr@N4 z`45C{cXWGnm^3o%;~XUmrKDXf@fE!|nXEM@2iV;2MlVEZ48UT302KhGdo4#htwE08 zk*DigB5HvZxK-hm!4tTuUBb4wS?d?n!$*bYur0&FgLbvLyWQD=XKU&z|3j2x)4LL_ZkS$>DL z-)Dxd$k$Jk&G$pNsHmuBK6r7mJN(bAc3h63uu^?G@IS&4jhmRJ5k@rSnb75Iq0bw{ zSVWwsLTW++wMx_(`=t939D7($Q$yM6PM}*$&yRd?$+|rZSO26wlc;i^E&btxo}Qjx zdwbeA%Y+J1Ll$bBrI);*Ub@wu{tPuLEmoQ)vp>GHl;`mHxO;<$LZg|8M4}GXn7VJ~ zwP;EX=cWLGdHK%~;cRtvmB7`1?x4c6x6~GV`z-1{xVrp;0;BqAb(ovAnwT58DF;}u z54{{0+xM}+CqN5aIt72lJedbis#?zohII}CjmbSvIg zYIg-^GCtk#NFYGxcH}tJ~opPd#y$&D0+WhLVrH#3dvGS=3!c)NbXqvL|aAbeycFT0D93 zP_@kG<|ocjBNnFAUIaX8%`lp|= zRG;s17et6TIj7oWiyxTY?P}9{WMI(20fSOD2eJgyS4M^h<_`5C!!8;yaHmV7DWMn* zept662VETSIG+igR4#f&6f0rVE%_Qb&Jfh54pYY(LjZb4M!`H??mJIHbF?Es^+diA>`wocp;={!H|v+bI93=G{DD`i61Y2 z@XYBt&XU14>eT69i8lGbrWUItO^;8J|C6hCmAld-^-M>I#niOZf2BJiDX6aa9ssED zjCF#}Nhjw~jxyK#Rd=SA@cSY0XW@J8Ngy^9){lbs7JJEiotehfP!RF1a&y@<{pbvd z;gP8KMX1UNH}K292A)=gj3j%c0y#N3O9f7+C*$J?Ha0e{jqM-{S$I+p5ThyZ%{9f$ zmZ`hlgB6#l>e)+7K9j=S-6eBS;7) zre3=5CL&4^-=#vFn}Xx6iy)271)pBs^zJk=WlgED8!NpB_yG9;GVn=TTTSoz@{yzysFBD^xuE~k^1`j zq8$3n$|kSgDo>1JKQ7# z9B%LJz5DC%FyQCm=7e&WKujH>Um)u#45+D57&%m+n(|&w)F_VuliVR7fTdAfkS!Ir zQ@CR{*JLLpy6)HF08pr0cP}LgW<7niMo~a<%WISy>YZ6y+F*^X^Mklo=%GPeex|oyR>3J(NPq(NC-!M}#WxyR8x$ zJEj=K_r3iPj)#3-TE|`>xTq}Nel}S1O_A*huu1C2L--wwuJ_N{2KebI-*CO=+O$j} zqfdULfUbjsMvu_egmatEJe%upq>@U4M$@XOHDF=k;Y^wRf9DJ|((6w=dn8P}C?k=+jX<^gmGjo=yDXt9vQP?G65`uE}ZeM!j zT9~-D<|LFenCR7*JLOi2 zk44BgQUt!P$pFJeC@l+t_dV`xR zD=S+k(c8fmvfHxZyD?glkD5z<)4si4FNCbLC6dx3ICNp%BlZmz_0t6XA6*it=1LdI z_@u-{>p?3caW?MTZM4X2p)Yu}Il)IFHHWW4wBkwqD+}?hIKBl>rsct{U(O0e@-BK3 zn0Y3}o!;-?Ya(ZH9@jp2%_pXJx3WnE7rhOg|AC*9u^QSWk+VjeKeM;F)j^A(A=xvN zCby_F`>8VU*5o`Z2}9j-QQcRppUw`3IN1Q#Cv*Wa5eB$1qKXO+qj5EhQU=+@!#W25 z*Fa9MsktZ`bVR_Qh0JJ9rtOtn-dyADnFgvPIQJZIWTv#Xf1Krx&LYn!QAN|} z%PZ|nHP~tLy`B8@tjznAklmAgd=f(s`&>t4xK+Pv+eTg<>u;6Jjt*5YKws>o#U&-{ zW|#hgZ}rRN5EUMAadErQ&{?$Yxb9+#oz&C%P6~&Zn3y8S5afxBOF&nHLqDa>@@*!*(fzVib>Z>6k%!-| z^=I-Hn46iwy_Pz-G0zgKW`+ka6H&499cH!sIfHx!L!i*{<)T$b-1);@J9!J-GiMi< zayLt>?x}EOHXrO#$Db`R*TSIF?b)V+g@a!oi$QMvB#Hb!=u#HRmis+FfBC)B+WQr^ zYhV8?cd45N!`Q9hsp^H3sXw*AA`wcayShwZ8;%q zLb?25g`|z0gl|#w4E`Puqo$Fj%!@CptMH|YT-d`%WH!9dUK-S7 zV9qEqKvjW0OL-~)<)N8koL)#b8x|<<< z2-rgbCJ;G542oU94tLZgG(uDfi3< zKRG-sYZGWL*Tj5rMzC(EiV zk1rFmdmom+=82I-vC%#3;Ry&oDRz1Rw$v7bP{@YxZ6tH{pb#jF*d3zzFcAajg=h+r zry#gz-lvlrue93~8yo8?%CZ$Uug{{za)la9m)AG3OZTEF5sgH1LQmyxY}x&2RX6rN z*E=P3wKa3U`ggjBDsuV{?vzYj=6_X$z|aI2 z*>vb%0|3?Y!--~h+?>z9)g}|4k$0i$pz_jqYu2W$q;xW6mg}Vl{fNdVs>4ppD?~S~ zB{x1^`KbhNv4*Eqyas&`PKiBX?{0v(dU6udCzbZiQ^CsI6z5d)#*L$K_KgATIyWz` z?GisW&~69{bTrV?(a}lNwt&p$Y1G+luSX4-?Wnguxp*5&d5(w!X73-&z`&%tsW1i# zRsT%|Gt@oLH7*lPQPr)^M66&6p_oJDCWQ2fBpGul^7G8;|wy6G+S!AY)Lz)Q2 zH%&SNp^-iKvk8Nshr<^g(xf$DPHEpnI%xo^7`U1U=D+I>ff_mtYTPl-Eha<(jEN}L zw9mqnrMIz;z^b7$E0t#4U?E;|C$Prt&fGDtU{Sh-`0-@(i;FVIa%QU6^H`W~&pYt! O2q3i#H0w0%;{FdAQUUn@ diff --git a/src/accounts/xmpp/XmppConfigWidget.h b/src/accounts/xmpp/XmppConfigWidget.h index bfdaa5da8..ec3739735 100644 --- a/src/accounts/xmpp/XmppConfigWidget.h +++ b/src/accounts/xmpp/XmppConfigWidget.h @@ -72,4 +72,4 @@ private: } -#endif // TWITTERCONFIGWIDGET_H +#endif // JABBERACCOUNTCONFIGWIDGET_H diff --git a/src/libtomahawk/accounts/AccountDelegate.cpp b/src/libtomahawk/accounts/AccountDelegate.cpp index f5c5a52bf..d69371b05 100644 --- a/src/libtomahawk/accounts/AccountDelegate.cpp +++ b/src/libtomahawk/accounts/AccountDelegate.cpp @@ -420,10 +420,8 @@ AccountDelegate::drawAccountList( QPainter* painter, QStyleOptionViewItemV4& opt for ( int i = 0; i < accts.size(); i++ ) { - //FIXME: special case for twitter, remove for 0.8.0 - if ( accts.at( i )->accountServiceName() != "Twitter" ) // draw lightbulb and text - runningRightEdge = drawStatus( painter, QPointF( rightEdge - PADDING, current), accts.at( i ) ); + runningRightEdge = drawStatus( painter, QPointF( rightEdge - PADDING, current), accts.at( i ) ); const QString label = accts.at( i )->accountFriendlyName(); const QPoint textTopLeft( runningRightEdge - PADDING - painter->fontMetrics().width( label ), current); diff --git a/src/tomahawk/widgets/AccountModelFactoryProxy.cpp b/src/tomahawk/widgets/AccountModelFactoryProxy.cpp index 2f2dd70a3..4056c48cd 100644 --- a/src/tomahawk/widgets/AccountModelFactoryProxy.cpp +++ b/src/tomahawk/widgets/AccountModelFactoryProxy.cpp @@ -49,8 +49,6 @@ AccountModelFactoryProxy::filterAcceptsRow( int sourceRow, const QModelIndex& so 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/tomahawk/widgets/AccountWidget.cpp b/src/tomahawk/widgets/AccountWidget.cpp index 35ac1c41f..2a707834e 100644 --- a/src/tomahawk/widgets/AccountWidget.cpp +++ b/src/tomahawk/widgets/AccountWidget.cpp @@ -175,11 +175,6 @@ AccountWidget::update( const QPersistentModelIndex& idx, int accountIdx ) qobject_cast< Tomahawk::Accounts::AccountFactory* >( idx.data( Tomahawk::Accounts::AccountModel::AccountData ) .value< QObject* >() ); - if ( fac->factoryId() == "twitteraccount" ) - { - m_inviteContainer->setVisible( false ); - m_inviteButton->setVisible( false ); - } switch ( account->connectionState() ) {