2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Ville Tiensuu - ville.tiensuu@ixonos.com
6 Kaj Wallin - kaj.wallin@ixonos.com
7 Henri Lampela - henri.lampela@ixonos.com
9 Situare is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 version 2 as published by the Free Software Foundation.
13 Situare is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Situare; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
29 #include <QStringList>
30 #include <QVariantMap>
33 #include <QMaemo5InformationBox>
34 #endif // Q_WS_MAEMO_5
38 #include "facebookcommon.h"
40 #include "facebookauthentication.h"
42 const QString REDIRECT_URI = "http://www.facebook.com/connect/login_success.html";
44 FacebookAuthentication::FacebookAuthentication(QObject *parent)
47 qDebug() << __PRETTY_FUNCTION__;
51 void FacebookAuthentication::clearAccountInformation(bool keepUsername)
53 qDebug() << __PRETTY_FUNCTION__;
55 ///< @todo (HIGH) clear session from SituareService
56 QSettings settings(DIRECTORY_NAME, FILE_NAME);
59 settings.remove(SETTINGS_AUTOMATIC_UPDATE_ENABLED);
60 settings.remove(SETTINGS_AUTOMATIC_UPDATE_INTERVAL);
63 settings.remove(COOKIES);
64 settings.remove(USER_UNSEND_MESSAGE);
65 settings.remove(USER_UNSEND_MESSAGE_PUBLISH);
68 void FacebookAuthentication::loadFinished(bool ok)
70 qWarning() << __PRETTY_FUNCTION__ << ok;
72 ///< @todo show browsed window if url != redirect url
75 QString FacebookAuthentication::parseSession(const QUrl &url)
77 qWarning() << __PRETTY_FUNCTION__;
79 const QString BEGIN("session={");
80 const QString END("}");
82 QString urlString = url.toString();
84 int begin = urlString.indexOf(BEGIN);
85 int end = urlString.indexOf(END, begin);
87 if ((begin > -1) && (end > -1))
88 return urlString.mid(begin, end - begin +1);
93 void FacebookAuthentication::urlChanged(const QUrl &url)
95 qWarning() << __PRETTY_FUNCTION__ << url.toString();
98 if (url.toString().startsWith(REDIRECT_URI)) {
99 const QString session = parseSession(url);
100 qWarning() << __PRETTY_FUNCTION__ << "parsed session:" << session;
101 if (!session.isEmpty())
102 emit loggedIn(session);