mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
1b8169036f
commit
1a5cd0e155
2 changed files with 21 additions and 2 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ slots:
|
|||
void gfhighChanged(int gf);
|
||||
void proxyType_changed(int idx);
|
||||
void on_btnUseDefaultFile_toggled(bool toggle);
|
||||
|
||||
void facebookLoginResponse(const QUrl& url);
|
||||
private:
|
||||
explicit PreferencesDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
void setUiFromPrefs();
|
||||
|
|
Loading…
Add table
Reference in a new issue