KIO

sessiondata.cpp
1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2000 Dawit Alemayehu <adawit@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "sessiondata_p.h"
9
10#include <QDir>
11#include <QStandardPaths>
12
13#include <KConfigGroup>
14#include <KLocalizedString>
15#include <KSharedConfig>
16#include <kprotocolmanager_p.h>
17
18namespace KIO
19{
20/********************************* SessionData ****************************/
21
22class SessionData::SessionDataPrivate
23{
24public:
25 SessionDataPrivate()
26 {
27 initDone = false;
28 }
29
30 bool initDone;
31 QString charsets;
32};
33
34SessionData::SessionData()
35 : d(new SessionDataPrivate)
36{
37}
38
39SessionData::~SessionData() = default;
40
41void SessionData::configDataFor(MetaData &configData, const QString &proto, const QString &)
42{
43 if ((proto.startsWith(QLatin1String("http"), Qt::CaseInsensitive)) || (proto.startsWith(QLatin1String("webdav"), Qt::CaseInsensitive))) {
44 if (!d->initDone) {
45 reset();
46 }
47
48 // These might have already been set so check first
49 // to make sure that we do not trumpt settings sent
50 // by apps or end-user.
51 if (configData[QStringLiteral("Charsets")].isEmpty()) {
52 configData[QStringLiteral("Charsets")] = d->charsets;
53 }
54 if (configData[QStringLiteral("CacheDir")].isEmpty()) {
56 QDir().mkpath(httpCacheDir);
57 configData[QStringLiteral("CacheDir")] = httpCacheDir;
58 }
59 if (configData[QStringLiteral("UserAgent")].isEmpty()) {
60 configData[QStringLiteral("UserAgent")] = KProtocolManagerPrivate::defaultUserAgent(QString());
61 }
62 }
63}
64
65void SessionData::reset()
66{
67 d->initDone = true;
68
69 d->charsets = QStringLiteral("utf-8");
71}
72
73}
74
75#include "moc_sessiondata_p.cpp"
static void reparseConfiguration()
Force a reload of the general config file of KIO workers ( kioslaverc).
A namespace for KIO globals.
KGuiItem reset()
bool mkpath(const QString &dirPath) const const
QString writableLocation(StandardLocation type)
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
CaseInsensitive
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:51 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.