2 #include "kconfigunibackend.h"
3 #include "uniconfroot.h"
6 //static UniConfRoot root();
7 static UniConfRoot root
;
17 KUniPriv(KConfigBase
*_config
, WvStringParm _filename
,
18 WvStringParm _restype
, bool usekdeglobals
);
25 KUniPriv::KUniPriv(KConfigBase
*_config
, WvStringParm _filename
,
26 WvStringParm _restype
, bool usekdeglobals
)
27 : log(WvString("KU:%s:%s", _restype
, _filename
)), cfg(root
)
31 log("Creating. (globals=%s)\n", usekdeglobals
);
33 static bool init
= false;
37 // root["kde/config"].mount("fast-reget:unix:/tmp/uniwrap");
38 // root["kde/config"].mount("fstree:/home/apenwarr/.kde/share/config");
42 // FIXME: do something with usekdeglobals
43 WvString
restype(!!_restype
? _restype
: WvString("NOTHING"));
44 WvString
filename(!!_filename
? _filename
: WvString("NOTHING"));
45 cfg
= root
["kde"][restype
][filename
];
46 if (!cfg
.ismountpoint())
47 cfg
.mount(WvString("ini:/home/apenwarr/.kde/share/%s/%s",
48 restype
, filename
), true);
50 // UniConf cfgx(cfg["KUniPriv wuz heer"]);
51 // cfgx.setmeint(cfgx.getmeint() + 1);
66 return; // UniConf doesn't need to reread more than once
72 UniConf::Iter
group(cfg
);
73 for (group
.rewind(); group
.next(); )
75 UniConf::RecursiveIter
entry(*group
);
76 for (entry
.rewind(); entry
.next(); )
78 QCString
groupkey(group
->key().printable().cstr());
79 QCString
entkey(entry
->fullkey(*group
).printable().cstr());
81 KEntryKey
key(groupkey
, entkey
);
83 val
.mValue
= entry
._value();
85 config
->putData(key
, val
);
95 void KUniPriv::write()
98 KEntryMap kmap
= config
->internalEntryMap();
100 for (KEntryMapIterator i
= kmap
.begin(); i
!= kmap
.end(); ++i
)
102 const KEntry
&ent
= *i
;
104 if (ent
.bGlobal
!= bGlobal
)
106 // wrong "globality" - might have to be saved later
112 WvString
group(i
.key().mGroup
), key(i
.key().mKey
), val(ent
.mValue
);
114 val
= ""; // never accidentally *delete* keys
115 if (!!group
&& !!key
)
117 if (cfg
[group
].xget(key
) != val
)
119 log("'[%s]%s' = '%s'\n", group
, key
, val
);
120 cfg
[group
].xset(key
, val
);
134 KConfigUniBackEnd::KConfigUniBackEnd(KConfigBase
*_config
,
135 const QString
&_fileName
, const char * _resType
,
137 : KConfigBackEnd(_config
, _fileName
, _resType
, _useKDEGlobals
)
139 priv
= new KUniPriv(_config
, _fileName
, _resType
, _useKDEGlobals
);
143 KConfigUniBackEnd::~KConfigUniBackEnd()
145 if (priv
) delete priv
;
149 bool KConfigUniBackEnd::parseConfigFiles()
156 void KConfigUniBackEnd::sync(bool merge
)