From 29eb8b28b311fe1cc672265a954fbb23cc8be461 Mon Sep 17 00:00:00 2001 From: Ville Tiensuu Date: Wed, 7 Apr 2010 08:39:19 +0300 Subject: [PATCH] Changed class names less cryptic --- .../fbauthentication/fbauthentication.cpp | 68 +++++++++++--------- .../fbauthentication/fbauthentication.h | 12 ++-- src/facebook_service/fbauthentication/main.cpp | 2 +- 3 files changed, 46 insertions(+), 36 deletions(-) diff --git a/src/facebook_service/fbauthentication/fbauthentication.cpp b/src/facebook_service/fbauthentication/fbauthentication.cpp index 92c6859..ce61ad9 100644 --- a/src/facebook_service/fbauthentication/fbauthentication.cpp +++ b/src/facebook_service/fbauthentication/fbauthentication.cpp @@ -2,7 +2,8 @@ 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 @@ -22,26 +23,37 @@ #include "fbauthentication.h" #include -#include -using namespace std; +#include -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); @@ -51,38 +63,37 @@ void Fbauthentication::start() } -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 @@ -94,10 +105,9 @@ void Fbauthentication::updateCredentials(const QUrl & url) 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 @@ -110,8 +120,7 @@ void Fbauthentication::updateCredentials(const QUrl & url) 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 @@ -125,7 +134,7 @@ void Fbauthentication::updateCredentials(const QUrl & url) urlEdit.remove("\",\""); //*sessionSecret = urlEdit; - //cout << "sessionSecret" << endl << sessionSecret->toStdString() << endl; + qDebug() << "sessionSecret" << endl << urlEdit.constData() << endl; fbCredentials.insert("sessionSecret", urlEdit); @@ -138,7 +147,7 @@ void Fbauthentication::updateCredentials(const QUrl & url) urlEdit.remove("\"}"); //QString sig = urlEdit; - //cout << "sig" << endl << sig.toStdString() << endl; + qDebug() << "sig" << endl << urlEdit.constData() << endl; fbCredentials.insert("Sig", urlEdit); @@ -147,13 +156,14 @@ void Fbauthentication::updateCredentials(const QUrl & url) } 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; } } + diff --git a/src/facebook_service/fbauthentication/fbauthentication.h b/src/facebook_service/fbauthentication/fbauthentication.h index 1ca8ab9..252dafe 100644 --- a/src/facebook_service/fbauthentication/fbauthentication.h +++ b/src/facebook_service/fbauthentication/fbauthentication.h @@ -20,8 +20,8 @@ */ -#ifndef FBAUTHENTICATION_H -#define FBAUTHENTICATION_H +#ifndef FACEBOOKAUTHENTICATION_H +#define FACEBOOKAUTHENTICATION_H #include #include @@ -31,13 +31,13 @@ const QString facebookLoginPage = "http://www.facebook.com/login.php?api_key=4197c64da2fb6b927236feaea32d7d81&connect_display=popup&v=1.0&next=http://www.facebook.com/connect/login_success.html&cancel_url=http://www.facebook.com/connect/login_failure.html&fbconnect=true&return_session=true&"; -class Fbauthentication : public QWidget +class FacebookAuthentication : public QWidget { Q_OBJECT public: - Fbauthentication(QWidget *parent = 0); - ~Fbauthentication(); + FacebookAuthentication(QWidget *parent = 0); + ~FacebookAuthentication(); QHash credentials() const {return fbCredentials;} private slots: @@ -60,4 +60,4 @@ private: }; -#endif // FBAUTHENTICATION_H +#endif // FacebookAuthentication_H diff --git a/src/facebook_service/fbauthentication/main.cpp b/src/facebook_service/fbauthentication/main.cpp index 6c093dd..53b082d 100644 --- a/src/facebook_service/fbauthentication/main.cpp +++ b/src/facebook_service/fbauthentication/main.cpp @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - Fbauthentication w; + FacebookAuthentication w; w.show(); w.start(); -- 1.7.9.5