diff --git a/src/libtomahawk/sip/SipPlugin.h b/src/libtomahawk/sip/SipPlugin.h
index 6b4f5cb5c..52daa67eb 100644
--- a/src/libtomahawk/sip/SipPlugin.h
+++ b/src/libtomahawk/sip/SipPlugin.h
@@ -14,6 +14,8 @@ public:
enum SipErrorCode { AuthError, ConnectionError }; // Placeholder for errors, to be defined
virtual ~SipPlugin() {}
+
+ virtual bool isValid() = 0;
public slots:
virtual bool connect( bool startup = false ) = 0;
diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp
index 22ca85469..9f0ae3560 100644
--- a/src/settingsdialog.cpp
+++ b/src/settingsdialog.cpp
@@ -349,7 +349,8 @@ SettingsDialog::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user )
twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() );
QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( twitAuth, this );
connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postGotTomahawkStatusUpdateReply(const QTweetStatus &) ) );
- statUpdate->post( QString( "Got Tomahawk?" ) );
+ QString uuid = QUuid::createUuid();
+ statUpdate->post( QString( "Got Tomahawk? (" ) + uuid.mid( 1, 8 ) + ")" );
}
void
diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui
index 30701062e..c0c29c599 100644
--- a/src/settingsdialog.ui
+++ b/src/settingsdialog.ui
@@ -29,7 +29,7 @@
- 2
+ 0
diff --git a/src/sip/jabber/jabber.h b/src/sip/jabber/jabber.h
index 65ccaca3a..19cc5d1de 100644
--- a/src/sip/jabber/jabber.h
+++ b/src/sip/jabber/jabber.h
@@ -18,6 +18,9 @@ public:
virtual ~JabberPlugin() { delete p; }
+ //FIXME: Make this more correct
+ virtual bool isValid() { return true; }
+
void setProxy( QNetworkProxy* proxy );
public slots:
diff --git a/src/sip/twitter/CMakeLists.txt b/src/sip/twitter/CMakeLists.txt
index 6fd91e9d6..7ca0f93c8 100644
--- a/src/sip/twitter/CMakeLists.txt
+++ b/src/sip/twitter/CMakeLists.txt
@@ -4,14 +4,15 @@ include( ${QT_USE_FILE} )
add_definitions( ${QT_DEFINITIONS} )
add_definitions( -DQT_PLUGIN )
add_definitions( -DQT_SHARED )
+add_definitions( -DSIPDLLEXPORT_PRO )
set( twitterSources
- # twitter.cpp
+ twitter.cpp
tomahawkoauthtwitter.cpp
)
set( twitterHeaders
- # twitter.h
+ twitter.h
tomahawkoauthtwitter.h
)
diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp
index 20dd60057..99d3d4e4b 100644
--- a/src/sip/twitter/twitter.cpp
+++ b/src/sip/twitter/twitter.cpp
@@ -2,27 +2,44 @@
#include
+#include
+#include
+
#include
+#include
+
+TwitterPlugin::TwitterPlugin()
+ : m_twitterAuth( 0 )
+ , m_isAuthed( false )
+{
+}
+
+bool
+TwitterPlugin::isValid()
+{
+ return m_isAuthed;
+}
bool
TwitterPlugin::connect( bool /*startup*/ )
-{
- delete m_twitterAuth;
- m_twitterAuth = new OAuthTwitter( this );
-
+{
TomahawkSettings *settings = TomahawkSettings::instance();
- QString oauthtoken = settings->twitterOAuthToken();
- QString oauthtokensecret = settings->twitterOAuthTokenSecret();
- if ( oauthtoken.isEmpty() || oauthtokensecret.isEmpty() )
+ if ( settings->twitterOAuthToken().isEmpty() || settings->twitterOAuthTokenSecret().isEmpty() )
{
qDebug() << "Empty Twitter credentials; not connecting";
return false;
}
+
+ delete m_twitterAuth;
+ m_twitterAuth = new TomahawkOAuthTwitter( this );
+ m_twitterAuth->setNetworkAccessManager( TomahawkUtils::nam() );
+ m_twitterAuth->setOAuthToken( settings->twitterOAuthToken().toLatin1() );
+ m_twitterAuth->setOAuthTokenSecret( settings->twitterOAuthTokenSecret().toLatin1() );
- m_twitterAuth->setOAuthToken( oauthtoken );
- m_twitterAuth->setOAuthTokenSecret( oauthtokensecret );
-
+ QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth, this );
+ QObject::connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) );
+ credVerifier->verify();
/*
QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ),
SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) );
@@ -31,6 +48,20 @@ TwitterPlugin::connect( bool /*startup*/ )
return true;
}
+void
+TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user )
+{
+ if ( user.id() == 0 )
+ {
+ qDebug() << "Could not authenticate to Twitter";
+ m_isAuthed = false;
+ }
+ else
+ {
+ qDebug() << "Successfully authenticated to Twitter as user " << user.screenName();
+ m_isAuthed = true;
+ }
+}
void
TwitterPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid )
diff --git a/src/sip/twitter/twitter.h b/src/sip/twitter/twitter.h
index bede2e4e3..fd64c1e94 100644
--- a/src/sip/twitter/twitter.h
+++ b/src/sip/twitter/twitter.h
@@ -3,6 +3,8 @@
#include "sip/SipPlugin.h"
#include "tomahawkoauthtwitter.h"
+#include
+#include
#include "../sipdllmacro.h"
@@ -12,11 +14,11 @@ class SIPDLLEXPORT TwitterPlugin : public SipPlugin
Q_INTERFACES( SipPlugin )
public:
- TwitterPlugin()
- : m_twitterAuth( 0 )
- {}
+ TwitterPlugin();
virtual ~TwitterPlugin() {}
+
+ virtual bool isValid();
public slots:
virtual bool connect( bool startup );
@@ -39,9 +41,12 @@ public slots:
private slots:
void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid );
+ void connectAuthVerifyReply( const QTweetUser &user );
+ void connectAuthVerifyError( QTweetNetBase::ErrorCode errorCode, const QString& errorMsg );
private:
- OAuthTwitter *m_twitterAuth;
+ TomahawkOAuthTwitter *m_twitterAuth;
+ bool m_isAuthed;
};
#endif
diff --git a/src/sip/zeroconf/zeroconf.h b/src/sip/zeroconf/zeroconf.h
index c347608ad..233160589 100644
--- a/src/sip/zeroconf/zeroconf.h
+++ b/src/sip/zeroconf/zeroconf.h
@@ -17,6 +17,8 @@ public:
{}
virtual ~ZeroconfPlugin() {}
+
+ virtual bool isValid() { return true; }
public slots:
virtual bool connect( bool startup );