{
qDebug() << __PRETTY_FUNCTION__;
- webView = new QWebView;
- mainlayout = new QHBoxLayout;
+ m_webView = new QWebView;
+ m_mainlayout = new QHBoxLayout;
QString facebookLoginBase = "http://www.facebook.com/login.php?";
QString situarePublicFacebookApiKey = "api_key=4197c64da2fb6b927236feaea32d7d81";
QString situareLoginFailure = "http://www.facebook.com/connect/login_failure.html";
QString facebookLoginEnding = "&fbconnect=true&return_session=true&";
- facebookLoginPage.append(facebookLoginBase);
- facebookLoginPage.append(situarePublicFacebookApiKey);
- facebookLoginPage.append(interval1);
- facebookLoginPage.append(situareLoginSuccess);
- facebookLoginPage.append(interval2);
- facebookLoginPage.append(situareLoginFailure);
- facebookLoginPage.append(facebookLoginEnding);
+ m_facebookLoginPage.append(facebookLoginBase);
+ m_facebookLoginPage.append(situarePublicFacebookApiKey);
+ m_facebookLoginPage.append(interval1);
+ m_facebookLoginPage.append(situareLoginSuccess);
+ m_facebookLoginPage.append(interval2);
+ m_facebookLoginPage.append(situareLoginFailure);
+ m_facebookLoginPage.append(facebookLoginEnding);
- connect(webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(updateCredentials(const QUrl &)));
+ connect(m_webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(updateCredentials(const QUrl &)));
- readCredentials(loginCredentials);
+ readCredentials(m_loginCredentials);
- if (!verifyCredentials(loginCredentials))
+ if (!verifyCredentials(m_loginCredentials))
start();
else
emit credentialsReady();
FacebookAuthentication::~FacebookAuthentication()
{
qDebug() << __PRETTY_FUNCTION__;
- delete webView;
- delete mainlayout;
+ delete m_webView;
+ delete m_mainlayout;
}
void FacebookAuthentication::start()
const double fontSize = 1.2;
- webView->setZoomFactor(fontSize);
- webView->load(facebookLoginPage);
- setCentralWidget(webView);
+ m_webView->setZoomFactor(fontSize);
+ m_webView->load(m_facebookLoginPage);
+ setCentralWidget(m_webView);
}
urlEdit.remove("\",\"");
qDebug() << "session_key" << endl << urlEdit.toAscii() << endl;
- loginCredentials.setSessionKey(urlEdit);
+ m_loginCredentials.setSessionKey(urlEdit);
}
// let's find out uid
urlEdit.remove(",\"");
qDebug() << "userID" << endl << urlEdit.toAscii() << endl;
- loginCredentials.setUserID(urlEdit);
+ m_loginCredentials.setUserID(urlEdit);
}
// let's find out expires
urlEdit.remove(",\"");
qDebug() << "expires" << endl << urlEdit.toAscii() << endl;
- loginCredentials.setExpires(urlEdit);
+ m_loginCredentials.setExpires(urlEdit);
}
// let's find out sessionsecret
urlEdit.remove("\",\"");
qDebug() << "sessionSecret" << endl << urlEdit.toAscii() << endl;
- loginCredentials.setSessionSecret(urlEdit);
+ m_loginCredentials.setSessionSecret(urlEdit);
}
// let's find out sig
urlEdit.remove("\"}");
qDebug() << "sig" << endl << urlEdit.toAscii() << endl;
- loginCredentials.setSig(urlEdit);
+ m_loginCredentials.setSig(urlEdit);
}
- webView->hide();
+ m_webView->hide();
emit credentialsReady();
- writeCredentials(loginCredentials);
+ writeCredentials(m_loginCredentials);
}
else if ( callbackUrl.indexOf("https://login.facebook.com/login.php?login_attempt=") == 0){
FacebookCredentials FacebookAuthentication::getLoginCredentials() const
{
qDebug() << __PRETTY_FUNCTION__;
- return loginCredentials;
+ return m_loginCredentials;
}
bool FacebookAuthentication::verifyCredentials(const FacebookCredentials &credentials) const
#include <QtGui>
#include <QtWebKit>
-#include <QHash>
#include <QString>
#include <QLayout>
#include "facebookcredentials.h"
/**
* @brief FacebookAuthentication class takes care of transmitting username and password to facebook. And it also receives credentials from Facebook. Other components of Situare application needs credentials to communicate with facebook.
*
+* @author Ville Tiensuu
* @class FacebookAuthentication facebookauthentication.h "facebookauthentication.h"
*/
class FacebookAuthentication : public QMainWindow
*
* -Composes Loginpage from pieces of strings.
* -Checks if there is valid credentials stored on the file. If there is emits signal. If not it calls start method.
- * -Connects signal from webview to UpdateCredentials() method. With this feature it is verified that class tries always update credentials when web page changes.
- * -Allocates memory for webView and mainlayout
+ * -Connects signal from m_webView to UpdateCredentials() method. With this feature it is verified that class tries always update credentials when web page changes.
+ * -Allocates memory for m_webView and m_mainlayout
*
* @fn FacebookAuthentication
* @param parent
FacebookAuthentication(QWidget *parent = 0);
/**
- * @brief Releases allocated memory for webView and mainLayout
+ * @brief Releases allocated memory for m_webView and m_mainlayout
*
- * @fn ~FacebookAuthentication
*/
~FacebookAuthentication();
/**
- * @brief Getter for loginCredentials
+ * @brief Getter for m_loginCredentials
+ *
*
- * @fn getLoginCredentials
* @return FacebookCredentials
*/
- FacebookCredentials getLoginCredentials() const;
+ FacebookCredentials loginCredentials() const;
public slots:
/**
- * @brief shows the webView and loads page that is specified in the facebookLoginPage variable. Specifies font size for the page.
- *
- * @fn start
+ * @brief shows the m_webView and loads page that is specified in the m_facebookLoginPage variable. Specifies font size for the page.
+ *
*/
void start();
/**
* @brief search credentials from URL that is given parameter. If credentials are found thay are stored to loginCredentials variable.
*
- * @fn updateCredentials
* @param url, URL where this method tries to find credentials.
* @return bool, if credentials are found return true, if credentials are not found return false.
*/
/**
* @brief this signal is emitted if user exits logging in by pressing X
*
- * @fn userExit
*/
void userExit();
/**
- * @brief this signal is emitted updateCredentials method finds credentials from URL. signal is also emitted at the beginning of the program if there is valid credentials in the file.
+ * @brief this signal is emitted if updateCredentials method finds credentials from URL. signal is also emitted at the beginning of the program if there is valid credentials in the file.
*
- * @fn credentialsReady
*/
void credentialsReady();
/**
* @brief this signal is emitted if updateCredentials method can't find credentials from URL
*
- * @fn loginFailure
*/
void loginFailure();
/**
* @brief Program cames to this method when user closes login screen by pressing X.
- * method send userExit() signal in this function
+ * method sends userExit() signal in this function
*
- * @fn closeEvent
* @param event, without parameter programs does not come to this function when user exits by pressing X.
*/
void closeEvent(QCloseEvent *event);
/**
* @brief checks expiration time of credentials and compares it to current time.
*
- * @fn verifyCredentials
* @param credentials, this parameter represents credentials that will be verified.
* @return bool, returns true if expiration time is after current time. in other cases returns false.
*/
/**
* @brief Reads previous stored credentials from file.
*
- * @fn readCredentials
- * @param credentialsFromFile, This dataclass is the place where method stores credentials. Corrent parameter here is loginCredentials (private member of FacebookAuthentication class)
+ * @param credentialsFromFile, This dataclass is the place where method stores credentials. Corrent parameter here is m_loginCredentials (private member of FacebookAuthentication class)
*/
void readCredentials(FacebookCredentials &credentialsFromFile);
/**
* @brief Writes credentials to File
*
- * @fn writeCredentials
* @param credentials, Contents of this dataclass is stored to file
*/
void writeCredentials(const FacebookCredentials &credentials);
/**
* @brief, shows facebook login page.
*
- * @var webView
+ * @var m_webView
*/
- QWebView *webView;
+ QWebView *m_webView;
/**
- * @brief, lays out webview in window.
+ * @brief, lays out m_webView in window.
*
- * @var mainlayout
+ * @var m_mainlayout
*/
- QHBoxLayout *mainlayout;
+ QHBoxLayout *m_mainlayout;
/**
* @brief string that contantains URL of facebook loginpage.
*
- * @var facebookLoginPage
+ * @var m_facebookLoginPage
*/
- QString facebookLoginPage;
+ QString m_facebookLoginPage;
/**
* @brief Dataclass that contains authorization to use facebook. Dataclass is composed of five QStrings and setters and getters.
*
- * @var loginCredentials
+ * @var m_loginCredentials
*/
- FacebookCredentials loginCredentials;
+ FacebookCredentials m_loginCredentials;
};
#endif // FACEBOOKAUTHENTICATION_H
void FacebookCredentials::setSessionKey(const QString sessionKeyParameter)
{
- sessionKey = sessionKeyParameter;
+ m_sessionKey = sessionKeyParameter;
}
void FacebookCredentials::setSessionSecret(const QString sessionSecretParameter)
{
- sessionSecret = sessionSecretParameter;
+ m_sessionSecret = sessionSecretParameter;
}
void FacebookCredentials::setExpires (const QString expiresParameter)
{
- expires = expiresParameter;
+ m_expires = expiresParameter;
}
void FacebookCredentials::setUserID (const QString userIDParameter)
{
- userID = userIDParameter;
+ m_userID = userIDParameter;
}
void FacebookCredentials::setSig(const QString sigParameter)
{
- sig = sigParameter;
+ m_sig = sigParameter;
}
-QString FacebookCredentials::getSessionKey() const
+QString FacebookCredentials::sessionKey() const
{
- return sessionKey;
+ return m_sessionKey;
}
-QString FacebookCredentials::getSessionSecret() const
+QString FacebookCredentials::sessionSecret() const
{
- return sessionSecret;
+ return m_sessionSecret;
}
-QString FacebookCredentials::getExpires() const
+QString FacebookCredentials::expires() const
{
- return expires;
+ return m_expires;
}
-QString FacebookCredentials::getUserID() const
+QString FacebookCredentials::userID() const
{
- return userID;
+ return m_userID;
}
-QString FacebookCredentials::getSig() const
+QString FacebookCredentials::sig() const
{
- return sig;
+ return m_sig;
}
bool FacebookCredentials::operator==(const FacebookCredentials &credentials)
{
- bool expireBool = (expires == credentials.getExpires());
- bool sessionKeyBool = (sessionKey == credentials.getSessionKey());
- bool sessionSecretBool = (sessionSecret == credentials.getSessionSecret());
- bool sigBool = (sig == credentials.getSig());
- bool userIdBool = (userID == credentials.getUserID());
+ bool expireBool = (m_expires == credentials.expires());
+ bool sessionKeyBool = (m_sessionKey == credentials.sessionKey());
+ bool sessionSecretBool = (m_sessionSecret == credentials.sessionSecret());
+ bool sigBool = (m_sig == credentials.sig());
+ bool userIdBool = (m_userID == credentials.userID());
return expireBool && sessionKeyBool && sessionSecretBool && sigBool && userIdBool;
}
#include <QObject>
#include <QString>
+/**
+* @brief class is used to integrate facebook credentials together.
+*
+* @author Ville Tiensuu
+* @class FacebookCredentials facebookcredentials.h situare/src/facebookservice/facebookcredentials.h"
+*/
class FacebookCredentials// : public QObject
{
public:
+ /**
+ * @brief constructor is empty
+ *
+ */
FacebookCredentials();
+
+ /**
+ * @brief set function for m_sessionKey member
+ *
+ * @param sessionKeyParameter, value of parameter is set to sessionKey member
+ */
void setSessionKey(const QString sessionKeyParameter);
+
+ /**
+ * @brief set function for m_sessionSecret member
+ *
+ * @param sessionSecretParameter, value of parameter is set to sessionSecret member
+ */
void setSessionSecret(const QString sessionSecretParameter);
+
+ /**
+ * @brief set funtion for m_expires member
+ *
+ * @param expiresParameter, value of parameter is set to expires member
+ */
void setExpires (const QString expiresParameter);
+
+ /**
+ * @brief set function for m_userID member
+ *
+ * @param userIDParameter, value of parameter is set to userID member
+ */
void setUserID(const QString userIDParameter);
+
+ /**
+ * @brief set funtionc for m_sig member
+ *
+ * @param sigParameter, value of parameter is set to sig member
+ */
void setSig(const QString sigParameter);
- QString getSessionKey() const;
- QString getSessionSecret() const;
- QString getExpires() const;
- QString getUserID() const;
- QString getSig() const;
+
+ /**
+ * @brief get function for m_sessionKey member
+ *
+ * @return QString
+ */
+ QString sessionKey() const;
+
+ /**
+ * @brief get funtion for m_sessionSecret member
+ *
+ * @return QString
+ */
+ QString sessionSecret() const;
+
+ /**
+ * @brief get function for m_expires member
+ *
+ * @return QString
+ */
+ QString expires() const;
+
+ /**
+ * @brief get function for m_userID member
+ *
+ * @return QString
+ */
+ QString userID() const;
+
+ /**
+ * @brief get function for m_sig member
+ *
+ * @return QString
+ */
+ QString sig() const;
+
+ /**
+ * @brief overloaded operator == is used to compare two FacebookCredentials.
+ *
+ * @param credentials
+ * @return bool operator, returns true if all members are same, else returns false
+ */
bool operator==(const FacebookCredentials& credentials);
private:
- QString sessionKey;
- QString sessionSecret;
- QString expires;
- QString userID;
- QString sig;
+ /**
+ * @brief string for storing sessionKey
+ *
+ * @var m_sessionKey
+ */
+ QString m_sessionKey;
+
+ /**
+ * @brief string for storing sessionSecret
+ *
+ * @var m_sessionSecret
+ */
+ QString m_sessionSecret;
+
+ /**
+ * @brief string for storing expires
+ *
+ * @var m_expires
+ */
+ QString m_expires;
+
+ /**
+ * @brief string for storing userID
+ *
+ * @var m_userID
+ */
+ QString m_userID;
+
+ /**
+ * @brief string for storing sig
+ *
+ * @var m_sig
+ */
+ QString m_sig;
};
#endif // FACEBOOKCREDENTIALS_H