--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Henri Lampela - henri.lampela@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#include <QDebug>
+#include <QStringList>
+#include "cookiehandler.h"
+
+CookieHandler::CookieHandler()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+}
+
+CookieHandler::~CookieHandler()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+}
+
+QString CookieHandler::formCookie(const QString &apiKeyValue, QString expiresValue,
+ QString userValue, QString sessionKeyValue,
+ QString sessionSecretValue, const QString &signatureValue,
+ const QString &localeValue)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QString cookie;
+ QString apiKey;
+ QString user;
+ QString expires;
+ QString sessionKey;
+ QString sessionSecret;
+ QString locale;
+ QString variable;
+ QString signature = EQUAL_MARK;
+ QStringList variableList;
+
+ signature.append(signatureValue);
+ apiKey.append(apiKeyValue);
+ apiKey.append(UNDERLINE_MARK);
+
+ user.append(USER);
+ user.append(EQUAL_MARK);
+ expires.append(EXPIRES);
+ expires.append(EQUAL_MARK);
+ sessionKey.append(SESSION_KEY);
+ sessionKey.append(EQUAL_MARK);
+ sessionSecret.append(SESSION_SECRET);
+ sessionSecret.append(EQUAL_MARK);
+ locale.append(LOCALE);
+ locale.append(EQUAL_MARK);
+ locale.append(localeValue);
+
+ variableList.append(expires.append(expiresValue.append(BREAK_MARK)));
+ variableList.append(sessionKey.append(sessionKeyValue.append(BREAK_MARK)));
+ variableList.append(user.append(userValue).append(BREAK_MARK));
+ variableList.append(sessionSecret.append(sessionSecretValue.append(BREAK_MARK)));
+
+ cookie.append(BREAK_MARK);
+
+ foreach(variable, variableList) {
+ cookie.append(apiKey);
+ cookie.append(variable);
+ }
+ apiKey.remove(UNDERLINE_MARK);
+ cookie.append(apiKey);
+ cookie.append(signature);
+ cookie.append(BREAK_MARK);
+ cookie.append(locale);
+
+ qDebug() << cookie;
+
+ return cookie;
+}
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Henri Lampela - henri.lampela@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+#ifndef COOKIEHANDLER_H
+#define COOKIEHANDLER_H
+
+#include <QString>
+#include "../situareservice/situarecommon.h"
+
+/**
+* @brief Class for cookie cretion.
+*
+* @author Henri Lampela
+* @class CookieHandler cookiehandler.h "cookiehandler/cookiehandler.h"
+*/
+class CookieHandler
+{
+public:
+
+ /**
+ * @brief Default constructor
+ *
+ */
+ CookieHandler();
+
+ /**
+ * @brief Destructor
+ *
+ */
+ ~CookieHandler();
+
+ /**
+ * @brief Forms a http cookie
+ *
+ * @param apiKeyValue application key
+ * @param expiresValue session expire date&time from Facebook
+ * @param userValue user id from Facebook
+ * @param sessionKeyValue session key from Facebook
+ * @param sessionSecretValue session secret from Facebook
+ * @param signatureValue md5 generated signature
+ * @param localeValue used locale
+ * @return QString formed cookie
+ */
+ QString formCookie(const QString &apiKeyValue, QString expiresValue, QString userValue,
+ QString sessionKeyValue, QString sessionSecretValue,
+ const QString &signatureValue, const QString &localeValue);
+
+};
+
+#endif // COOKIEHANDLER_H
#include <QNetworkReply>
#include "situareservice.h"
#include "situarecommon.h"
+#include "../cookiehandler/cookiehandler.h"
#include "parser.h"
SituareService::SituareService(QObject *parent)
{
qDebug() << __PRETTY_FUNCTION__;
- QString cookie = formCookie(API_KEY, m_credentials.expires(),m_credentials.userID(),
- m_credentials.sessionKey(), m_credentials.sessionSecret(),
- m_credentials.sig(), EN_LOCALE);
+ CookieHandler cookieHandler;
+
+ QString cookie = cookieHandler.formCookie(API_KEY, m_credentials.expires(), m_credentials.userID(),
+ m_credentials.sessionKey(), m_credentials.sessionSecret(),
+ m_credentials.sig(), EN_LOCALE);
QUrl url = formUrl(SITUARE_URL, GET_LOCATIONS);
sendRequest(url, COOKIE, cookie);
{
qDebug() << __PRETTY_FUNCTION__;
- QString cookie = formCookie(API_KEY, m_credentials.expires(),m_credentials.userID(),
- m_credentials.sessionKey(), m_credentials.sessionSecret(),
- m_credentials.sig(), EN_LOCALE);
+ CookieHandler cookieHandler;
+
+ QString cookie = cookieHandler.formCookie(API_KEY, m_credentials.expires(), m_credentials.userID(),
+ m_credentials.sessionKey(), m_credentials.sessionSecret(),
+ m_credentials.sig(), EN_LOCALE);
QString urlParameters = formUrlParameters(coordinates);
QUrl url = formUrl(SITUARE_URL, REVERSE_GEO, urlParameters);
{
qDebug() << __PRETTY_FUNCTION__;
- QString cookie = formCookie(API_KEY, m_credentials.expires(),m_credentials.userID(),
- m_credentials.sessionKey(), m_credentials.sessionSecret(),
- m_credentials.sig(), EN_LOCALE);
+ CookieHandler cookieHandler;
+
+ QString cookie = cookieHandler.formCookie(API_KEY, m_credentials.expires(), m_credentials.userID(),
+ m_credentials.sessionKey(), m_credentials.sessionSecret(),
+ m_credentials.sig(), EN_LOCALE);
QString publishValue;
sendRequest(url, COOKIE, cookie);
}
-QString SituareService::formCookie(const QString &apiKeyValue, QString expiresValue,
- QString userValue, QString sessionKeyValue,
- QString sessionSecretValue, const QString &signatureValue,
- const QString &localeValue)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- QString cookie;
- QString apiKey;
- QString user;
- QString expires;
- QString sessionKey;
- QString sessionSecret;
- QString locale;
- QString variable;
- QString signature = EQUAL_MARK;
- QStringList variableList;
-
- signature.append(signatureValue);
- apiKey.append(apiKeyValue);
- apiKey.append(UNDERLINE_MARK);
-
- user.append(USER);
- user.append(EQUAL_MARK);
- expires.append(EXPIRES);
- expires.append(EQUAL_MARK);
- sessionKey.append(SESSION_KEY);
- sessionKey.append(EQUAL_MARK);
- sessionSecret.append(SESSION_SECRET);
- sessionSecret.append(EQUAL_MARK);
- locale.append(LOCALE);
- locale.append(EQUAL_MARK);
- locale.append(localeValue);
-
- variableList.append(expires.append(expiresValue.append(BREAK_MARK)));
- variableList.append(sessionKey.append(sessionKeyValue.append(BREAK_MARK)));
- variableList.append(user.append(userValue).append(BREAK_MARK));
- variableList.append(sessionSecret.append(sessionSecretValue.append(BREAK_MARK)));
-
- cookie.append(BREAK_MARK);
-
- foreach(variable, variableList) {
- cookie.append(apiKey);
- cookie.append(variable);
- }
- apiKey.remove(UNDERLINE_MARK);
- cookie.append(apiKey);
- cookie.append(signature);
- cookie.append(BREAK_MARK);
- cookie.append(locale);
-
- qDebug() << cookie;
-
- return cookie;
-}
-
-QUrl SituareService::formUrl(const QString &baseUrl, const QString &phpScript,
- QString urlParameters)
+QUrl SituareService::formUrl(const QString &baseUrl, const QString &phpScript, QString urlParameters)
{
qDebug() << __PRETTY_FUNCTION__;
QString urlString;
return url;
}
-QString SituareService::formUrlParameters(const QPointF &coordinates, QString status,
- QString publish)
+QString SituareService::formUrlParameters(const QPointF &coordinates, QString status, QString publish)
{
QString parameters;
parseUserData(replyArray);
}
else if(replyArray == "") {
- if(url.toString().contains(UPDATE_LOCATION.toAscii())) {
+ if(url.toString().contains(UPDATE_LOCATION.toAscii())) {
emit updateWasSuccessful();
}
else {
private:
/**
- * @brief Forms a http cookie
- *
- * @param apiKeyValue application key
- * @param expiresValue session expire date&time from Facebook
- * @param userValue user id from Facebook
- * @param sessionKeyValue session key from Facebook
- * @param sessionSecretValue session secret from Facebook
- * @param signatureValue md5 generated signature
- * @param localeValue used locale
- * @return QString formed cookie
- */
- QString formCookie(const QString &apiKeyValue, QString expiresValue, QString userValue,
- QString sessionKeyValue, QString sessionSecretValue,
- const QString &signatureValue, const QString &localeValue);
-
- /**
* @brief Forms a http url
*
* @param baseUrl Server url
ui/mapviewscreen.cpp \
situareservice/situareservice.cpp \
situareservice/imagefetcher.cpp \
+ cookiehandler/cookiehandler.cpp \
facebookservice/facebookcredentials.cpp \
facebookservice/facebookauthentication.cpp \
map/mapengine.cpp \
situareservice/situareservice.h \
situareservice/situarecommon.h \
situareservice/imagefetcher.h \
+ cookiehandler/cookiehandler.h \
facebookservice/facebookcredentials.h \
facebookservice/facebookauthentication.h \
facebookservice/facebookcommon.h \