USA.
*/
-#include "parser.h"
+#include <qjson/parser.h>
#include <QtDebug>
#include <QDateTime>
#include "common.h"
#include "error.h"
#include "facebookcommon.h"
+#include "ui/facebookloginbrowser.h"
#include "facebookauthentication.h"
const QString REDIRECT_URI = "http://www.facebook.com/connect/login_success.html";
FacebookAuthentication::FacebookAuthentication(QObject *parent)
- : QObject(parent)
+ : QObject(parent),
+ m_browser(0)
{
qDebug() << __PRETTY_FUNCTION__;
}
+void FacebookAuthentication::browserDestroyed()
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ ///< @todo (HIGH) Is newer called!
+
+ m_browser = 0;
+}
+
void FacebookAuthentication::clearAccountInformation(bool keepUsername)
{
qDebug() << __PRETTY_FUNCTION__;
///< @todo show browsed window if url != redirect url
}
+void FacebookAuthentication::login()
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ emit buildLoginBrowser();
+}
+
QString FacebookAuthentication::parseSession(const QUrl &url)
{
qWarning() << __PRETTY_FUNCTION__;
int end = urlString.indexOf(END, begin);
if ((begin > -1) && (end > -1))
- return urlString.mid(begin, end - begin +1);
+ return urlString.mid(begin, end - begin + 1);
else
return QString();
}
+void FacebookAuthentication::setBrowser(FacebookLoginBrowser *browser)
+{
+ qWarning() << __PRETTY_FUNCTION__;
+
+ m_browser = browser;
+
+ if (m_browser) {
+ connect(m_browser, SIGNAL(loadFinished(bool)),
+ this, SLOT(loadFinished(bool)));
+
+ connect(m_browser, SIGNAL(urlChanged(QUrl)),
+ this, SLOT(urlChanged(QUrl)));
+
+ connect(m_browser, SIGNAL(destroyed()),
+ this, SLOT(browserDestroyed()));
+
+ // browser->load(QUrl("https://graph.facebook.com/oauth/authorize?client_id=4197c64da2fb6b927236feaea32d7d81&redirect_uri=http://www.facebook.com/connect/login_success.html&display=touch&type=user_agent"));
+
+ QString url = "https://www.facebook.com/login.php?";
+ url.append("api_key=cf77865a5070f2c2ba3b52cbf3371579&"); ///< @todo hard coded test server api key
+ url.append("cancel_url=http://www.facebook.com/connect/login_failure.html&");
+ url.append("display=popup&");
+ url.append("fbconnect=1&");
+ url.append("next=http://www.facebook.com/connect/login_success.html&");
+ url.append("return_session=1&");
+ url.append("session_version=3&");
+ url.append("v=1.0&");
+ url.append("req_perms=publish_stream");
+
+ m_browser->load(QUrl(url));
+ }
+}
+
void FacebookAuthentication::urlChanged(const QUrl &url)
{
qWarning() << __PRETTY_FUNCTION__ << url.toString();