• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • kio
sessiondata.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 Copyright (C) 2000 Dawit Alemayehu <adawit@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License (LGPL) as published by the Free Software Foundation;
7 either version 2 of the License, or (at your option) any
8 later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 51 Franklin Street,
18 Fifth Floor, Boston, MA 02110-1301, USA.
19*/
20
21#include "sessiondata.h"
22#include "sessiondata.moc"
23
24#include <QtCore/QList>
25#include <QtCore/QTextCodec>
26
27#include <kdebug.h>
28#include <kconfiggroup.h>
29#include <kglobal.h>
30#include <klocale.h>
31#include <kprotocolmanager.h>
32#include <ksharedconfig.h>
33#include <kstandarddirs.h>
34
35#include <kio/slaveconfig.h>
36#include <kio/http_slave_defaults.h>
37
38namespace KIO {
39
40/***************************** SessionData::AuthData ************************/
41#if 0
42struct SessionData::AuthData
43{
44
45public:
46 AuthData() {}
47
48 AuthData(const QByteArray& k, const QByteArray& g, bool p) {
49 key = k;
50 group = g;
51 persist = p;
52 }
53
54 bool isKeyMatch( const QByteArray& val ) const {
55 return (val==key);
56 }
57
58 bool isGroupMatch( const QByteArray& val ) const {
59 return (val==group);
60 }
61
62 QByteArray key;
63 QByteArray group;
64 bool persist;
65};
66#endif
67
68/********************************* SessionData ****************************/
69
70class SessionData::SessionDataPrivate
71{
72public:
73 SessionDataPrivate() {
74 useCookie = true;
75 initDone = false;
76 }
77
78 bool initDone;
79 bool useCookie;
80 QString charsets;
81 QString language;
82};
83
84SessionData::SessionData()
85 :d(new SessionDataPrivate)
86{
87// authData = 0;
88}
89
90SessionData::~SessionData()
91{
92 delete d;
93}
94
95void SessionData::configDataFor( MetaData &configData, const QString &proto,
96 const QString & )
97{
98 if ( (proto.startsWith(QLatin1String("http"), Qt::CaseInsensitive)) ||
99 (proto.startsWith(QLatin1String("webdav"), Qt::CaseInsensitive)) )
100 {
101 if (!d->initDone)
102 reset();
103
104 // These might have already been set so check first
105 // to make sure that we do not trumpt settings sent
106 // by apps or end-user.
107 if ( configData["Cookies"].isEmpty() )
108 configData["Cookies"] = d->useCookie ? "true" : "false";
109 if ( configData["Languages"].isEmpty() )
110 configData["Languages"] = d->language;
111 if ( configData["Charsets"].isEmpty() )
112 configData["Charsets"] = d->charsets;
113 if ( configData["CacheDir"].isEmpty() )
114 configData["CacheDir"] = KGlobal::dirs()->saveLocation("cache", "http");
115 if ( configData["UserAgent"].isEmpty() )
116 configData["UserAgent"] = KProtocolManager::defaultUserAgent();
117 }
118}
119
120void SessionData::reset()
121{
122 d->initDone = true;
123 // Get Cookie settings...
124 d->useCookie = KSharedConfig::openConfig("kcookiejarrc", KConfig::NoGlobals)->
125 group("Cookie Policy").
126 readEntry("Cookies", true);
127
128 d->language = KProtocolManager::acceptLanguagesHeader();
129 d->charsets = QString::fromLatin1(QTextCodec::codecForLocale()->name()).toLower();
130 KProtocolManager::reparseConfiguration();
131}
132
133}
KConfig::NoGlobals
NoGlobals
KIO::MetaData
MetaData is a simple map of key/value strings.
Definition: global.h:397
KIO::SessionData::SessionData
SessionData()
Definition: sessiondata.cpp:84
KIO::SessionData::configDataFor
virtual void configDataFor(KIO::MetaData &configData, const QString &proto, const QString &host)
Definition: sessiondata.cpp:95
KIO::SessionData::~SessionData
~SessionData()
Definition: sessiondata.cpp:90
KIO::SessionData::reset
virtual void reset()
Definition: sessiondata.cpp:120
KProtocolManager::acceptLanguagesHeader
static QString acceptLanguagesHeader()
Return Accept-Languages header built up according to user's desktop language settings.
Definition: kprotocolmanager.cpp:893
KProtocolManager::reparseConfiguration
static void reparseConfiguration()
Force a reload of the general config file of io-slaves ( kioslaverc).
Definition: kprotocolmanager.cpp:232
KProtocolManager::defaultUserAgent
static QString defaultUserAgent()
Returns the default user-agent string used for web browsing.
Definition: kprotocolmanager.cpp:631
KSharedConfig::openConfig
static KSharedConfig::Ptr openConfig(const KComponentData &componentData, const QString &fileName=QString(), OpenFlags mode=FullConfig, const char *resourceType="config")
KStandardDirs::saveLocation
QString saveLocation(const char *type, const QString &suffix=QString(), bool create=true) const
http_slave_defaults.h
readEntry
KAutostart::StartPhase readEntry(const KConfigGroup &group, const char *key, const KAutostart::StartPhase &aDefault)
kconfiggroup.h
kdebug.h
kglobal.h
klocale.h
kprotocolmanager.h
ksharedconfig.h
kstandarddirs.h
KGlobal::dirs
KStandardDirs * dirs()
charsets
KCharsets * charsets()
KIO
A namespace for KIO globals.
Definition: kbookmarkmenu.h:55
group
group
name
const char * name(StandardAction id)
sessiondata.h
slaveconfig.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal