1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-14 01:54:07 +02:00

More work on oauth implementation

This commit is contained in:
Jeff Mitchell
2011-02-11 23:01:08 -05:00
parent 31ce7a5a2d
commit c7b99d44a0
5 changed files with 64 additions and 17 deletions

View File

@@ -378,6 +378,29 @@ TomahawkSettings::setLastFmUsername( const QString& username )
setValue( "lastfm/username", 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 bool
TomahawkSettings::scrobblingEnabled() const TomahawkSettings::scrobblingEnabled() const

View File

@@ -96,6 +96,13 @@ public:
QByteArray lastFmSessionKey() const; QByteArray lastFmSessionKey() const;
void setLastFmSessionKey( const QByteArray& key ); 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 /// XMPP Component Settings
QString xmppBotServer() const; QString xmppBotServer() const;
void setXmppBotServer( const QString &server ); void setXmppBotServer( const QString &server );

View File

@@ -4,7 +4,7 @@
int TomahawkOAuthTwitter::authorizationWidget() int TomahawkOAuthTwitter::authorizationWidget()
{ {
bool ok; 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) if (ok)
return i; return i;

View File

@@ -1,29 +1,46 @@
#include "zeroconf.h" #include "twitter.h"
#include <tomahawksettings.h>
#include <QtPlugin> #include <QtPlugin>
bool bool
ZeroconfPlugin::connect( bool /*startup*/ ) TwitterPlugin::connect( bool /*startup*/ )
{ {
delete m_zeroconf; delete m_twitterAuth;
m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this ); 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& ) ), QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ),
SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) ); SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) );
*/
m_zeroconf->advertise();
return true; return true;
} }
void 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; qDebug() << "Found LAN host:" << host << port << nodeid;
if ( !Servent::instance()->connectedToSession( nodeid ) ) if ( !Servent::instance()->connectedToSession( nodeid ) )
Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid ); Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid );
*/
} }
Q_EXPORT_PLUGIN2( sip, ZeroconfPlugin ) Q_EXPORT_PLUGIN2( sip, TwitterPlugin )

View File

@@ -2,21 +2,21 @@
#define ZEROCONF_H #define ZEROCONF_H
#include "sip/SipPlugin.h" #include "sip/SipPlugin.h"
#include "tomahawkzeroconf.h" #include "tomahawkoauthtwitter.h"
#include "../sipdllmacro.h" #include "../sipdllmacro.h"
class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin class SIPDLLEXPORT TwitterPlugin : public SipPlugin
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES( SipPlugin ) Q_INTERFACES( SipPlugin )
public: public:
ZeroconfPlugin() TwitterPlugin()
: m_zeroconf( 0 ) : m_twitterAuth( 0 )
{} {}
virtual ~ZeroconfPlugin() {} virtual ~TwitterPlugin() {}
public slots: public slots:
virtual bool connect( bool startup ); virtual bool connect( bool startup );
@@ -41,7 +41,7 @@ private slots:
void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid ); void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid );
private: private:
TomahawkZeroconf* m_zeroconf; TomahawkOAuthTwitter *m_twitterAuth;
}; };
#endif #endif