00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifndef _KCONFIGBACKEND_H
00023
#define _KCONFIGBACKEND_H
00024
00025
#include "kconfigdata.h"
00026
#include <kconfigbase.h>
00027
#include <klockfile.h>
00028
#include "kdelibs_export.h"
00029
00030
class QFile;
00031
class KConfigBackEndPrivate;
00032
00047 class KDECORE_EXPORT KConfigBackEnd
00048 {
00049
friend class KConfig;
00050
friend class KSharedConfig;
00051
public:
00067 KConfigBackEnd(
KConfigBase *_config,
const QString &_fileName,
00068
const char * _resType,
bool _useKDEGlobals);
00069
00073
virtual ~KConfigBackEnd();
00074
00081
virtual bool parseConfigFiles() = 0;
00082
00092
virtual void sync(
bool bMerge =
true) = 0;
00093
00104
void changeFileName(
const QString &_fileName,
const char * _resType,
00105
bool _useKDEGlobals);
00106
00112 virtual KConfigBase::ConfigState getConfigState()
const
00113
{
return mConfigState; }
00114
00119 QString fileName()
const {
return mfileName; }
00120
00125 const char * resource()
const {
return resType; }
00126
00132 void setLocaleString(
const QCString &_localeString) { localeString = _localeString; }
00133
00138
void setFileWriteMode(
int mode);
00139
00146
bool checkConfigFilesWritable(
bool warnUser);
00147
00153 KLockFile::Ptr lockFile(
bool bGlobal =
false );
00154
00155
#ifdef KDE_NO_COMPAT
00156
private:
00157
#endif
00158
00161 KDE_DEPRECATED
QString filename()
const {
return mfileName; }
00162
00163
protected:
00164
KConfigBase *pConfig;
00165
00166
QString mfileName;
00167
QCString resType;
00168
bool useKDEGlobals : 1;
00169
bool bFileImmutable : 1;
00170
QCString localeString;
00171
QString mLocalFileName;
00172
QString mGlobalFileName;
00173 KConfigBase::ConfigState mConfigState;
00174
int mFileMode;
00175
00176
protected:
00177
virtual void virtual_hook(
int id,
void* data );
00178
protected:
00179
class KConfigBackEndPrivate;
00180 KConfigBackEndPrivate *d;
00181 };
00182
00183
00190 class KDECORE_EXPORT KConfigINIBackEnd :
public KConfigBackEnd
00191 {
00192
00193
public:
00209 KConfigINIBackEnd(
KConfigBase *_config,
const QString &_fileName,
00210
const char * _resType,
bool _useKDEGlobals =
true)
00211 : KConfigBackEnd(_config, _fileName, _resType, _useKDEGlobals) {}
00212
00216 virtual ~KConfigINIBackEnd() {};
00217
00223
bool parseConfigFiles();
00224
00232
virtual void sync(
bool bMerge =
true);
00233
00234
protected:
00250
void parseSingleConfigFile(
QFile& rFile,
KEntryMap *pWriteBackMap = 0L,
00251
bool bGlobal =
false,
bool bDefault =
false);
00252
00267
bool writeConfigFile(
QString filename,
bool bGlobal =
false,
bool bMerge =
true);
00268
00281
bool getEntryMap(
KEntryMap &map,
bool bGlobal,
QFile *mergeFile);
00282
00284
void writeEntries(FILE *pStream,
const KEntryMap &aTempMap);
00285
00286
protected:
00287
virtual void virtual_hook(
int id,
void* data );
00288
private:
00289
class KConfigINIBackEndPrivate;
00290 KConfigINIBackEndPrivate *not_d;
00291 };
00292
00293
#endif