2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@ixonos.com
6 Sami Rämö - sami.ramo@ixonos.com
8 Situare is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 Situare is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Situare; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
28 #include "networkcookiejar.h"
30 const QString COOKIES_SETTING = "cookies";
32 NetworkCookieJar::NetworkCookieJar(QObject *parent)
33 : QNetworkCookieJar(parent)
35 qDebug() << __PRETTY_FUNCTION__;
40 NetworkCookieJar::~NetworkCookieJar()
42 qDebug() << __PRETTY_FUNCTION__;
47 void NetworkCookieJar::clearCookiesSetting()
49 qDebug() << __PRETTY_FUNCTION__;
51 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
52 settings.remove(COOKIES_SETTING);
55 void NetworkCookieJar::loadCookies()
57 qDebug() << __PRETTY_FUNCTION__;
59 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
61 QStringList list = settings.value(COOKIES_SETTING).toStringList();
64 QList<QNetworkCookie> cookieList;
65 for(int i = 0; i < list.count(); i++) {
66 cookieList.append(QNetworkCookie::parseCookies(list.at(i).toAscii()));
69 setAllCookies(cookieList);
73 void NetworkCookieJar::saveCookies()
75 qDebug() << __PRETTY_FUNCTION__;
77 QList<QNetworkCookie> cookieList = allCookies();
80 for(int i = 0; i < cookieList.count(); i++) {
81 QNetworkCookie cookie = cookieList.at(i);
82 QByteArray byteArray = cookie.toRawForm(QNetworkCookie::Full);
83 list.append(QString(byteArray));
85 list.removeDuplicates();
87 QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
88 settings.setValue(COOKIES_SETTING, list);