mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 00:24:12 +02:00
More work on oauth implementation
This commit is contained in:
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -1,29 +1,46 @@
|
||||
#include "zeroconf.h"
|
||||
#include "twitter.h"
|
||||
|
||||
#include <tomahawksettings.h>
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
|
||||
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 )
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user