diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bb90964cd..80630f77b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -28,6 +28,7 @@ SET( TOMAHAWK_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../include/" )
SET( tomahawkSources ${tomahawkSources}
sip/SipHandler.cpp
+ sip/twitter/tomahawkoauthtwitter.cpp
infosystem/infosystem.cpp
infosystem/infoplugins/echonestplugin.cpp
@@ -62,6 +63,7 @@ SET( tomahawkHeaders ${tomahawkHeaders}
"${TOMAHAWK_INC_DIR}/tomahawk/infosystem.h"
sip/SipHandler.h
+ sip/twitter/tomahawkoauthtwitter.h
infosystem/infoplugins/echonestplugin.h
infosystem/infoplugins/musixmatchplugin.h
@@ -113,6 +115,7 @@ INCLUDE_DIRECTORIES(
../alsa-playback
../rtaudio
../qxt/qxtweb-standalone/qxtweb
+ ../thirdparty/qtweetlib/src
/usr/include/taglib
/usr/local/include/taglib
@@ -168,6 +171,7 @@ TARGET_LINK_LIBRARIES( tomahawk
qjson
tag
+ tomahawk_qtweetlib
)
INCLUDE( "CPack.txt" )
diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt
index ec1bdefc4..b741fd1c4 100644
--- a/src/libtomahawk/CMakeLists.txt
+++ b/src/libtomahawk/CMakeLists.txt
@@ -366,6 +366,7 @@ target_link_libraries( tomahawklib
ogg
FLAC++
tomahawk_jdns
+ tomahawk_qtweetlib
${CLUCENE_LIBRARY}
)
diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp
index 4d625932f..e961b4871 100644
--- a/src/libtomahawk/tomahawksettings.cpp
+++ b/src/libtomahawk/tomahawksettings.cpp
@@ -387,7 +387,7 @@ TomahawkSettings::twitterOAuthToken() const
void
TomahawkSettings::setTwitterOAuthToken( const QString& oauthtoken )
{
- setValue( "twitter/username", oauthtoken );
+ setValue( "twitter/oauthtoken", oauthtoken );
}
QString
diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp
index 1e9bb042a..a6c3225ff 100644
--- a/src/settingsdialog.cpp
+++ b/src/settingsdialog.cpp
@@ -18,6 +18,7 @@
#include "musicscanner.h"
#include "tomahawksettings.h"
#include "sip/SipHandler.h"
+#include "sip/twitter/tomahawkoauthtwitter.h"
static QString
@@ -62,6 +63,17 @@ SettingsDialog::SettingsDialog( QWidget *parent )
ui->groupBoxNetworkAdvanced->setVisible( false );
}
+ if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() )
+ {
+ ui->twitterStatusLabel->setText("Status: No saved credentials");
+ ui->twitterAuthenticateButton->setText( "Authenticate" );
+ }
+ else
+ {
+ ui->twitterStatusLabel->setText("Status: Credentials saved");
+ ui->twitterAuthenticateButton->setText( "Re-authenticate" );
+ }
+
// MUSIC SCANNER
ui->lineEditMusicPath->setText( s->scannerPath() );
@@ -273,6 +285,29 @@ SettingsDialog::onLastFmFinished()
#endif
}
+void
+SettingsDialog::authenticateTwitter()
+{
+ TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
+ twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
+ twitAuth->authorizePin();
+ if ( !twitAuth->oauthToken().isEmpty() && !twitAuth->oauthTokenSecret().isEmpty() )
+ {
+ TomahawkSettings* s = TomahawkSettings::instance();
+ s->setTwitterOAuthToken( twitAuth->oauthToken() );
+ s->setTwitterOAuthTokenSecret( twitAuth->oauthTokenSecret() );
+ ui->twitterStatusLabel->setText("Status: Credentials saved");
+ ui->twitterAuthenticateButton->setText( "Re-authenticate" );
+ }
+ else
+ {
+ TomahawkSettings* s = TomahawkSettings::instance();
+ s->setTwitterOAuthToken( QString() );
+ s->setTwitterOAuthTokenSecret( QString() );
+ ui->twitterStatusLabel->setText("Status: No saved credentials");
+ ui->twitterAuthenticateButton->setText( "Authenticate" );
+ }
+}
ProxyDialog::ProxyDialog( QWidget *parent )
: QDialog( parent )
diff --git a/src/settingsdialog.h b/src/settingsdialog.h
index f02fcd5df..dc82f03be 100644
--- a/src/settingsdialog.h
+++ b/src/settingsdialog.h
@@ -50,6 +50,8 @@ private slots:
void testLastFmLogin();
void onLastFmFinished();
+
+ void authenticateTwitter();
void addScriptResolver();
void scriptSelectionChanged();
diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui
index f9f93c32e..4009156eb 100644
--- a/src/settingsdialog.ui
+++ b/src/settingsdialog.ui
@@ -412,6 +412,71 @@
+
+
+ Twitter
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Authenticating with Twitter allows you to discover and play music from your Twitter friends running Tomahawk.
+
+This feature works best when you have set a static host name in the "Jabber" settings tab under Advanced Settings, but may work even if you do not. Please note: this discovery uses Direct Messages and will only work when both Twitter users have followed each other. Tomahawk will attempt to "clean up" after itself to keep your Direct Message inbox tidy, but may miss some.
+
+When you press the button your web browser will launch and take you to Twitter.com to authenticate. You must copy and paste the PIN number into the dialog box that appears.
+
+
+ true
+
+
+
+ -
+
+
-
+
+
+ Status: No saved credentials
+
+
+ Qt::AutoText
+
+
+
+ -
+
+
+ Authenticate with Twitter
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
Last.fm
@@ -688,5 +753,21 @@
+
+ twitterAuthenticateButton
+ pressed()
+ SettingsDialog
+ authenticateTwitter()
+
+
+ 459
+ 205
+
+
+ 310
+ 216
+
+
+
diff --git a/src/sip/twitter/tomahawkoauthtwitter.cpp b/src/sip/twitter/tomahawkoauthtwitter.cpp
index e35445b41..580ba6daf 100644
--- a/src/sip/twitter/tomahawkoauthtwitter.cpp
+++ b/src/sip/twitter/tomahawkoauthtwitter.cpp
@@ -1,6 +1,12 @@
#include "tomahawkoauthtwitter.h"
#include
+TomahawkOAuthTwitter::TomahawkOAuthTwitter( QObject* parent )
+ : OAuthTwitter( parent )
+{
+}
+
+
int TomahawkOAuthTwitter::authorizationWidget()
{
bool ok;
diff --git a/src/sip/twitter/tomahawkoauthtwitter.h b/src/sip/twitter/tomahawkoauthtwitter.h
index b40e2b87d..bef823c36 100644
--- a/src/sip/twitter/tomahawkoauthtwitter.h
+++ b/src/sip/twitter/tomahawkoauthtwitter.h
@@ -3,14 +3,14 @@
#include
-class TomahawkOAuthTwitter : public OAuthTwitter
+#include "../sipdllmacro.h"
+
+class SIPDLLEXPORT TomahawkOAuthTwitter : public OAuthTwitter
{
Q_OBJECT
public:
- TomahawkOAuthTwitter(QObject *parent = 0)
- : OAuthTwitter( parent )
- {}
+ TomahawkOAuthTwitter( QObject *parent = 0 );
~TomahawkOAuthTwitter() {}
diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp
index 6a1898769..20dd60057 100644
--- a/src/sip/twitter/twitter.cpp
+++ b/src/sip/twitter/twitter.cpp
@@ -8,7 +8,7 @@ bool
TwitterPlugin::connect( bool /*startup*/ )
{
delete m_twitterAuth;
- m_twitterAuth = new TomahawkOAuthTwitter( this );
+ m_twitterAuth = new OAuthTwitter( this );
TomahawkSettings *settings = TomahawkSettings::instance();
QString oauthtoken = settings->twitterOAuthToken();
diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h
index e44780647..bede2e4e3 100644
--- a/src/sip/twitter/twitter.h
+++ b/src/sip/twitter/twitter.h
@@ -41,7 +41,7 @@ private slots:
void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid );
private:
- TomahawkOAuthTwitter *m_twitterAuth;
+ OAuthTwitter *m_twitterAuth;
};
#endif