diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index cc6f4278c..4d625932f 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -378,6 +378,29 @@ TomahawkSettings::setLastFmUsername( const QString& username ) setValue( "lastfm/username", username ); } +QString +TomahawkSettings::twitterOAuthToken() const +{ + return value( "twitter/oauthtoken" ).toString(); +} + +void +TomahawkSettings::setTwitterOAuthToken( const QString& oauthtoken ) +{ + setValue( "twitter/username", oauthtoken ); +} + +QString +TomahawkSettings::twitterOAuthTokenSecret() const +{ + return value( "twitter/oauthtokensecret" ).toString(); +} + +void +TomahawkSettings::setTwitterOAuthTokenSecret( const QString& oauthtokensecret ) +{ + setValue( "twitter/oauthtokensecret", oauthtokensecret ); +} bool TomahawkSettings::scrobblingEnabled() const diff --git a/src/libtomahawk/tomahawksettings.h b/src/libtomahawk/tomahawksettings.h index 3959ec6e9..7e92afe5c 100644 --- a/src/libtomahawk/tomahawksettings.h +++ b/src/libtomahawk/tomahawksettings.h @@ -95,6 +95,13 @@ public: QByteArray lastFmSessionKey() const; void setLastFmSessionKey( const QByteArray& key ); + + /// Twitter settings + QString twitterOAuthToken() const; + void setTwitterOAuthToken( const QString& oauthtoken ); + + QString twitterOAuthTokenSecret() const; + void setTwitterOAuthTokenSecret( const QString& oauthtokensecret ); /// XMPP Component Settings QString xmppBotServer() const; diff --git a/src/sip/twitter/tomahawkoauthtwitter.cpp b/src/sip/twitter/tomahawkoauthtwitter.cpp index 1031f0d2f..e35445b41 100644 --- a/src/sip/twitter/tomahawkoauthtwitter.cpp +++ b/src/sip/twitter/tomahawkoauthtwitter.cpp @@ -4,7 +4,7 @@ int TomahawkOAuthTwitter::authorizationWidget() { bool ok; - int i = QInputDialog::getInt(0, QString( "Twitter PIN" ), QString( "After authenticating, enter the displayed PIN number here:" ), 0, 0, 2147483647, 1, &ok); + int i = QInputDialog::getInt(0, QString( "Twitter PIN" ), QString( "After authenticating on Twitter's web site,\nenter the displayed PIN number here:" ), 0, 0, 2147483647, 1, &ok); if (ok) return i; diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 702c7983b..6a1898769 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -1,29 +1,46 @@ -#include "zeroconf.h" +#include "twitter.h" + +#include #include - bool -ZeroconfPlugin::connect( bool /*startup*/ ) +TwitterPlugin::connect( bool /*startup*/ ) { - delete m_zeroconf; - m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this ); + delete m_twitterAuth; + m_twitterAuth = new TomahawkOAuthTwitter( this ); + + TomahawkSettings *settings = TomahawkSettings::instance(); + QString oauthtoken = settings->twitterOAuthToken(); + QString oauthtokensecret = settings->twitterOAuthTokenSecret(); + + if ( oauthtoken.isEmpty() || oauthtokensecret.isEmpty() ) + { + qDebug() << "Empty Twitter credentials; not connecting"; + return false; + } + + m_twitterAuth->setOAuthToken( oauthtoken ); + m_twitterAuth->setOAuthTokenSecret( oauthtokensecret ); + + /* QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ), SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) ); - - m_zeroconf->advertise(); - + */ + return true; } void -ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ) +TwitterPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ) { + /* qDebug() << "Found LAN host:" << host << port << nodeid; if ( !Servent::instance()->connectedToSession( nodeid ) ) Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid ); + */ } -Q_EXPORT_PLUGIN2( sip, ZeroconfPlugin ) +Q_EXPORT_PLUGIN2( sip, TwitterPlugin ) diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h index c347608ad..e44780647 100644 --- a/src/sip/twitter/twitter.h +++ b/src/sip/twitter/twitter.h @@ -2,21 +2,21 @@ #define ZEROCONF_H #include "sip/SipPlugin.h" -#include "tomahawkzeroconf.h" +#include "tomahawkoauthtwitter.h" #include "../sipdllmacro.h" -class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin +class SIPDLLEXPORT TwitterPlugin : public SipPlugin { Q_OBJECT Q_INTERFACES( SipPlugin ) public: - ZeroconfPlugin() - : m_zeroconf( 0 ) + TwitterPlugin() + : m_twitterAuth( 0 ) {} - virtual ~ZeroconfPlugin() {} + virtual ~TwitterPlugin() {} public slots: virtual bool connect( bool startup ); @@ -41,7 +41,7 @@ private slots: void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ); private: - TomahawkZeroconf* m_zeroconf; + TomahawkOAuthTwitter *m_twitterAuth; }; #endif