summaryrefslogtreecommitdiffstats
path: root/qt-ui/preferences.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-12-23 18:39:47 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-12-24 06:36:53 -0800
commit1a5cd0e155f8ae6c9adde0555c8117ac7aa710e5 (patch)
tree5a9e7189d4a0e52e37671fc941c4b87b38f29a31 /qt-ui/preferences.cpp
parent1b8169036fcafc7d7d72548adebfafeb7f65e3de (diff)
downloadsubsurface-1a5cd0e155f8ae6c9adde0555c8117ac7aa710e5.tar.gz
Connect to facebook, save the tokens for future use.
We can now correctly connect to facebook endpoint. Nothing really fancy at the moment. =/ Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/preferences.cpp')
-rw-r--r--qt-ui/preferences.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 7f288ab1f..2378a1fd6 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -30,10 +30,13 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial
// Facebook stuff:
QUrl urlLogin("https://www.facebook.com/dialog/oauth?"
"client_id=427722490709000"
- "&redirect_uri=http://www.facebook.com/connect/login_success.html");
+ "&redirect_uri=http://www.facebook.com/connect/login_success.html"
+ "&response_type=token");
ui.facebookWebView->setUrl(urlLogin);
+ connect(ui.facebookWebView, &QWebView::urlChanged, this, &PreferencesDialog::facebookLoginResponse);
+
connect(ui.proxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(proxyType_changed(int)));
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
connect(ui.gflow, SIGNAL(valueChanged(int)), this, SLOT(gflowChanged(int)));
@@ -47,6 +50,22 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial
rememberPrefs();
}
+void PreferencesDialog::facebookLoginResponse(const QUrl &url)
+{
+ QString result = url.toString();
+ if (result.contains("access_token")){ // Login Successfull.
+ int from = result.indexOf("access_token=") + strlen("access_token=");
+ int to = result.indexOf("&expires_in");
+ QString securityToken = result.mid(from, to-from);
+
+ QSettings settings;
+ settings.beginGroup("WebApps");
+ settings.beginGroup("Facebook");
+ settings.setValue("ConnectToken", securityToken);
+ ui.facebookWebView->setHtml("We need a better 'you re connected' page. but, YEY. ");
+ }
+}
+
#define DANGER_GF (gf > 100) ? "* { color: red; }" : ""
void PreferencesDialog::gflowChanged(int gf)
{