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

KIO

  • sources
  • kde-4.14
  • kdelibs
  • 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 
38 namespace KIO {
39 
40 /***************************** SessionData::AuthData ************************/
41 #if 0
42 struct SessionData::AuthData
43 {
44 
45 public:
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 
70 class SessionData::SessionDataPrivate
71 {
72 public:
73  SessionDataPrivate() {
74  useCookie = true;
75  initDone = false;
76  }
77 
78  bool initDone;
79  bool useCookie;
80  QString charsets;
81  QString language;
82 };
83 
84 SessionData::SessionData()
85  :d(new SessionDataPrivate)
86 {
87 // authData = 0;
88 }
89 
90 SessionData::~SessionData()
91 {
92  delete d;
93 }
94 
95 void 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 
120 void 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 }
KStandardDirs::saveLocation
QString saveLocation(const char *type, const QString &suffix=QString(), bool create=true) const
http_slave_defaults.h
KProtocolManager::reparseConfiguration
static void reparseConfiguration()
Force a reload of the general config file of io-slaves ( kioslaverc).
Definition: kprotocolmanager.cpp:232
kdebug.h
QByteArray
group
KIO::SessionData::reset
virtual void reset()
Definition: sessiondata.cpp:120
KGlobal::dirs
KStandardDirs * dirs()
readEntry
KFileShare::ShareMode readEntry(const KConfigGroup &cg, const char *key, const KFileShare::ShareMode &aDefault)
Definition: kfileshare.cpp:91
klocale.h
KIO::MetaData
MetaData is a simple map of key/value strings.
Definition: global.h:396
QTextCodec::codecForLocale
QTextCodec * codecForLocale()
KIO::SessionData::~SessionData
~SessionData()
Definition: sessiondata.cpp:90
kprotocolmanager.h
KIO::SessionData::SessionData
SessionData()
Definition: sessiondata.cpp:84
QObject::name
const char * name() const
kglobal.h
sessiondata.h
KConfig::NoGlobals
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
charsets
KCharsets * charsets()
ksharedconfig.h
QString
KProtocolManager::defaultUserAgent
static QString defaultUserAgent()
Returns the default user-agent string used for web browsing.
Definition: kprotocolmanager.cpp:631
QString::toLower
QString toLower() const
KIO::SessionData::configDataFor
virtual void configDataFor(KIO::MetaData &configData, const QString &proto, const QString &host)
Definition: sessiondata.cpp:95
QLatin1String
kstandarddirs.h
QString::fromLatin1
QString fromLatin1(const char *str, int size)
slaveconfig.h
KProtocolManager::acceptLanguagesHeader
static QString acceptLanguagesHeader()
Return Accept-Languages header built up according to user's desktop language settings.
Definition: kprotocolmanager.cpp:892
KSharedConfig::openConfig
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, const char *resourceType="config")
kconfiggroup.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:53 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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

Search



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