Situare - A location system for Facebook
Copyright (C) 2010 Ixonos Plc. Authors:
- Firstname Lastname - ville.tiensuu@ixonos.com
+ Ville Tiensuu - ville.tiensuu@ixonos.com
+ Kaj Wallin - kaj.wallin@ixonos.com
Situare is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
#include "fbauthentication.h"
#include <QtGui>
-#include <iostream>
-using namespace std;
+#include <QtDebug>
-Fbauthentication::Fbauthentication(QWidget *parent)
+
+FacebookAuthentication::FacebookAuthentication(QWidget *parent)
: QWidget(parent)
{
- cout << "Fbauthentication constructor" << endl;
+ qDebug() << "FacebookAuthentication constructor" << endl;
}
-Fbauthentication::~Fbauthentication()
+FacebookAuthentication::~FacebookAuthentication()
{
- cout << "Fbauthentication destructor" << endl;
+ qDebug() << "FacebookAuthentication destructor" << endl;
delete webView;
}
-void Fbauthentication::start()
+void FacebookAuthentication::start()
{
- webView = new QWebView;
+ qDebug() << "FacebookAuthentication start" << endl;
+ webView = new QWebView;
+
+ if (webView == NULL){
+ qCritical() << "Failed to allocate memory for webView" << endl;
+ }
+
QHBoxLayout *mainlayout = new QHBoxLayout;
+ if (mainlayout == NULL){
+ qCritical() << "Failed to allocate memory for mainlayout" << endl;
+ }
+
+ webView->setZoomFactor(1.2);
webView->load(facebookLoginPage);
mainlayout->addWidget(webView);
setLayout(mainlayout);
}
-void Fbauthentication::updateCredentials(const QUrl & url)
+void FacebookAuthentication::updateCredentials(const QUrl & url)
{
if (url.isValid()){
- //cout << "url is valid" << endl;
+ //qDebug() << "url is valid" << endl;
- //QUrl tmpUrl(webView->url());
QString callbackUrl = url.toString(); //tmpUrl.toString();
QString urlEdit(callbackUrl);
- //cout << "callbackUrl: " << endl << callbackUrl.toStdString() << endl;
+ qDebug() << "callbackUrl: " << endl << callbackUrl.constData() << endl;
+ qDebug() << "webView zoom factor" << webView->zoomFactor() << endl;
if ( 0 == callbackUrl.indexOf("http://www.facebook.com/connect/login_success.html")){
- cout << "login success" << endl;
+ qDebug() << "login success" << endl;
// let's find out session key
int indexOfCredential = callbackUrl.indexOf("session_key");
- cout << "index: " << indexOfCredential << endl;
+ //qDebug() << "index: " << indexOfCredential << endl;
indexOfCredential += 14; //lenght of string "session_key"
int index2 = callbackUrl.indexOf("uid");
index2 -= 4;
urlEdit.remove(0,indexOfCredential);
- //cout << "urlEdit" << endl << urlEdit.toStdString() << endl;
+ //qDebug() << "urlEdit" << endl << urlEdit.toStdString() << endl;
index2 = urlEdit.indexOf("uid");
urlEdit.remove(index2, urlEdit.length());
- //cout << "urlEdit" << endl << urlEdit.toStdString() << endl;
+ //qDebug() << "urlEdit" << endl << urlEdit.toStdString() << endl;
urlEdit.remove("\",\"");
- //cout << "urlEdit" << endl << urlEdit.toStdString() << endl;
+ //qDebug() << "urlEdit" << endl << urlEdit.toStdString() << endl;
- //urlEdit;
- //cout << "session_key" << endl << sessionKey->toStdString() << endl;
+ qDebug() << "session_key" << endl << urlEdit.constData() << endl;
fbCredentials.insert("Session Key",urlEdit);
// let's find out uid
index2 = urlEdit.indexOf("expires");
urlEdit.remove(index2, urlEdit.length());
urlEdit.remove(",\"");
- //cout << "urlEdit" << endl << urlEdit.toStdString() << endl;
+ //qDebug() << "urlEdit" << endl << urlEdit.toStdString() << endl;
- //*userID = urlEdit;
- //cout << "userID" << endl << userID->toStdString() << endl;
+ qDebug() << "userID" << endl << urlEdit.constData() << endl;
fbCredentials.insert("User ID",urlEdit);
// let's find out expires
urlEdit.remove(index2, urlEdit.length());
urlEdit.remove(",\"");
- //*expires = urlEdit;
- //cout << "expires" << endl << expires->toStdString() << endl;
+ qDebug() << "expires" << endl << urlEdit.constData() << endl;
fbCredentials.insert("Expires", urlEdit);
// let's find out sessionsecret
urlEdit.remove("\",\"");
//*sessionSecret = urlEdit;
- //cout << "sessionSecret" << endl << sessionSecret->toStdString() << endl;
+ qDebug() << "sessionSecret" << endl << urlEdit.constData() << endl;
fbCredentials.insert("sessionSecret", urlEdit);
urlEdit.remove("\"}");
//QString sig = urlEdit;
- //cout << "sig" << endl << sig.toStdString() << endl;
+ qDebug() << "sig" << endl << urlEdit.constData() << endl;
fbCredentials.insert("Sig", urlEdit);
}
if (0 == callbackUrl.indexOf("https://login.facebook.com/login.php?login_attempt=")){
- cout << "login failure" << endl;
+ qWarning() << "login failure" << endl;
loginFailure();
}
}
else { // show error message that page cant be loaded in QWebView
- cout << " Loading of page failed" << endl;
+ qDebug() << " Loading of page failed" << endl;
}
}
+