#include "facebookauthentication.h"
#include "facebookcommon.h"
-#include "../common.h"
+#include "common.h"
#include "parser.h"
FacebookAuthentication::FacebookAuthentication(QObject *parent)
: QObject(parent),
- m_freshLogin(false),
- m_loginAttempts(0)
-
+ m_freshLogin(false)
{
qDebug() << __PRETTY_FUNCTION__;
m_loginCredentials.clearCredentials();
QSettings settings(DIRECTORY_NAME, FILE_NAME);
- if(!keepUsername)
+ if(!keepUsername) {
settings.remove(USERNAME);
+ settings.remove(SETTINGS_AUTOMATIC_UPDATE_ENABLED);
+ settings.remove(SETTINGS_AUTOMATIC_UPDATE_INTERVAL);
+ }
settings.remove(COOKIES);
+ settings.remove(USER_UNSEND_MESSAGE);
+ settings.remove(USER_UNSEND_MESSAGE_PUBLISH);
}
const QString FacebookAuthentication::loadUsername()
bool FacebookAuthentication::updateCredentials(const QUrl &url)
{
- qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__ << url.toString();
bool found = false;
if (!ok) {
qFatal("An error occurred during parsing");
- exit (1);
+ emit error(SituareError::INVALID_JSON);
+ found = false;
}
qDebug() << "Session Key" << result[SESSION_KEY].toString();
m_loginCredentials.setSessionKey(result[SESSION_KEY].toString());
else if ( callbackUrl.indexOf(LOGIN_FAILURE_REPLY) == 0){
qWarning() << "login failure" << endl;
qDebug() << callbackUrl;
- ++m_loginAttempts;
- /* emit loginFailure for every second login attemps, since webview loads login
- error page (loadingDone() signal is emitted) and we need to avoid that because
- at this point we don't have new login parameters */
- if(m_loginAttempts % 2) {
- clearAccountInformation(true);
- if(m_freshLogin) {
- emit error(LOGIN_FAILED);
- emit loginFailure();
- }
- else {
- m_freshLogin = true;
- emit error(SESSION_EXPIRED);
- }
+ clearAccountInformation(true);
+ if(m_freshLogin) {
+ emit error(SituareError::LOGIN_FAILED);
+ emit loginFailure();
+ }
+ else {
+ m_freshLogin = true;
+ emit error(SituareError::SESSION_EXPIRED);
}
}
else if(callbackUrl.indexOf(LOGIN_PAGE) == 0) {