Changeset View
Changeset View
Standalone View
Standalone View
src/kconf_update/kconf_update.cpp
Show All 32 Lines | |||||
33 | 33 | | |||
34 | #include <kconfig.h> | 34 | #include <kconfig.h> | ||
35 | #include <kconfiggroup.h> | 35 | #include <kconfiggroup.h> | ||
36 | 36 | | |||
37 | #include <qstandardpaths.h> | 37 | #include <qstandardpaths.h> | ||
38 | #include <qcommandlineparser.h> | 38 | #include <qcommandlineparser.h> | ||
39 | #include <qcommandlineoption.h> | 39 | #include <qcommandlineoption.h> | ||
40 | 40 | | |||
41 | #include "kconf_update_debug.h" | ||||
41 | #include "kconfigutils.h" | 42 | #include "kconfigutils.h" | ||
42 | 43 | | |||
44 | // Convenience wrapper around qCDebug to prefix the output with metadata of | ||||
45 | // the file. | ||||
46 | #define qCDebugFile(CATEGORY) \ | ||||
47 | qCDebug(CATEGORY) << m_currentFilename << ':' << m_lineCount << ":'" << m_line << "': " | ||||
48 | | ||||
43 | class KonfUpdate | 49 | class KonfUpdate | ||
44 | { | 50 | { | ||
45 | public: | 51 | public: | ||
46 | KonfUpdate(QCommandLineParser *parser); | 52 | KonfUpdate(QCommandLineParser *parser); | ||
47 | ~KonfUpdate(); | 53 | ~KonfUpdate(); | ||
48 | 54 | | |||
49 | KonfUpdate(const KonfUpdate &) = delete; | 55 | KonfUpdate(const KonfUpdate &) = delete; | ||
50 | KonfUpdate& operator=(const KonfUpdate &) = delete; | 56 | KonfUpdate& operator=(const KonfUpdate &) = delete; | ||
51 | 57 | | |||
52 | QStringList findUpdateFiles(bool dirtyOnly); | 58 | QStringList findUpdateFiles(bool dirtyOnly); | ||
53 | 59 | | |||
54 | QTextStream &log(); | | |||
55 | QTextStream &logFileError(); | | |||
56 | | ||||
57 | bool checkFile(const QString &filename); | 60 | bool checkFile(const QString &filename); | ||
58 | void checkGotFile(const QString &_file, const QString &id); | 61 | void checkGotFile(const QString &_file, const QString &id); | ||
59 | 62 | | |||
60 | bool updateFile(const QString &filename); | 63 | bool updateFile(const QString &filename); | ||
61 | 64 | | |||
62 | void gotId(const QString &_id); | 65 | void gotId(const QString &_id); | ||
63 | void gotFile(const QString &_file); | 66 | void gotFile(const QString &_file); | ||
64 | void gotGroup(const QString &_group); | 67 | void gotGroup(const QString &_group); | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 118 | { | |||
116 | bool updateAll = false; | 119 | bool updateAll = false; | ||
117 | 120 | | |||
118 | m_config = new KConfig(QStringLiteral("kconf_updaterc")); | 121 | m_config = new KConfig(QStringLiteral("kconf_updaterc")); | ||
119 | KConfigGroup cg(m_config, QString()); | 122 | KConfigGroup cg(m_config, QString()); | ||
120 | 123 | | |||
121 | QStringList updateFiles; | 124 | QStringList updateFiles; | ||
122 | 125 | | |||
123 | m_debug = parser->isSet(QStringLiteral("debug")); | 126 | m_debug = parser->isSet(QStringLiteral("debug")); | ||
127 | if (m_debug) { | ||||
128 | // The only way to enable debug reliably is through a filter rule. | ||||
129 | // The category itself is const, so we can't just go around changing | ||||
130 | // its mode. This can however be overridden by the environment, so | ||||
131 | // we'll want to have a fallback warning if debug is not enabled | ||||
132 | // after setting the filter. | ||||
133 | QLoggingCategory::setFilterRules(QStringLiteral("%1.debug=true").arg(KCONF_UPDATE_LOG().categoryName())); | ||||
134 | qDebug() << "Automatically enabled the debug logging category" << KCONF_UPDATE_LOG().categoryName(); | ||||
135 | if (!KCONF_UPDATE_LOG().isDebugEnabled()) { | ||||
136 | qWarning("The debug logging category %s needs to be enabled manually to get debug output", | ||||
137 | KCONF_UPDATE_LOG().categoryName()); | ||||
138 | } | ||||
139 | } | ||||
124 | 140 | | |||
125 | if (parser->isSet(QStringLiteral("testmode"))) { | 141 | if (parser->isSet(QStringLiteral("testmode"))) { | ||
126 | QStandardPaths::setTestModeEnabled(true); | 142 | QStandardPaths::setTestModeEnabled(true); | ||
127 | } | 143 | } | ||
128 | 144 | | |||
129 | m_bUseConfigInfo = false; | 145 | m_bUseConfigInfo = false; | ||
130 | if (parser->isSet(QStringLiteral("check"))) { | 146 | if (parser->isSet(QStringLiteral("check"))) { | ||
131 | m_bUseConfigInfo = true; | 147 | m_bUseConfigInfo = true; | ||
132 | const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kconf_update/" + parser->value(QStringLiteral("check"))); | 148 | const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kconf_update/" + parser->value(QStringLiteral("check"))); | ||
133 | if (file.isEmpty()) { | 149 | if (file.isEmpty()) { | ||
134 | qWarning("File '%s' not found.", parser->value(QStringLiteral("check")).toLocal8Bit().data()); | 150 | qWarning("File '%s' not found.", parser->value(QStringLiteral("check")).toLocal8Bit().data()); | ||
135 | log() << "File '" << parser->value(QStringLiteral("check")) << "' passed on command line not found" << endl; | 151 | qCDebug(KCONF_UPDATE_LOG) << "File" << parser->value(QStringLiteral("check")) << "passed on command line not found"; | ||
136 | return; | 152 | return; | ||
137 | } | 153 | } | ||
138 | updateFiles.append(file); | 154 | updateFiles.append(file); | ||
139 | } else if (!parser->positionalArguments().isEmpty()) { | 155 | } else if (!parser->positionalArguments().isEmpty()) { | ||
140 | updateFiles += parser->positionalArguments(); | 156 | updateFiles += parser->positionalArguments(); | ||
141 | } else { | 157 | } else { | ||
142 | if (cg.readEntry("autoUpdateDisabled", false)) { | 158 | if (cg.readEntry("autoUpdateDisabled", false)) { | ||
143 | return; | 159 | return; | ||
Show All 21 Lines | |||||
165 | 181 | | |||
166 | KonfUpdate::~KonfUpdate() | 182 | KonfUpdate::~KonfUpdate() | ||
167 | { | 183 | { | ||
168 | delete m_config; | 184 | delete m_config; | ||
169 | delete m_file; | 185 | delete m_file; | ||
170 | delete m_textStream; | 186 | delete m_textStream; | ||
171 | } | 187 | } | ||
172 | 188 | | |||
173 | static QTextStream &operator<<(QTextStream &stream, const QStringList &lst) | | |||
174 | { | | |||
175 | stream << lst.join(QStringLiteral(", ")); | | |||
176 | return stream; | | |||
177 | } | | |||
178 | | ||||
179 | QTextStream & | | |||
180 | KonfUpdate::log() | | |||
181 | { | | |||
182 | if (!m_textStream) { | | |||
183 | #if 0 | | |||
184 | QString dir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + "kconf_update/log"; | | |||
185 | QDir().mkpath(dir); | | |||
186 | QString file = dir + "/update.log"; | | |||
187 | m_file = new QFile(file); | | |||
188 | if (m_file->open(QIODevice::WriteOnly | QIODevice::Append)) { | | |||
189 | m_textStream = new QTextStream(m_file); | | |||
190 | } else { | | |||
191 | // Error | | |||
192 | m_textStream = new QTextStream(stderr, QIODevice::WriteOnly); | | |||
193 | } | | |||
194 | #endif | | |||
195 | m_textStream = new QTextStream(stderr, QIODevice::WriteOnly); | | |||
196 | } | | |||
197 | | ||||
198 | (*m_textStream) << QDateTime::currentDateTime().toString(Qt::ISODate) << " "; | | |||
199 | | ||||
200 | return *m_textStream; | | |||
201 | } | | |||
202 | | ||||
203 | QTextStream & | | |||
204 | KonfUpdate::logFileError() | | |||
205 | { | | |||
206 | return log() << m_currentFilename << ':' << m_lineCount << ":'" << m_line << "': "; | | |||
207 | } | | |||
208 | | ||||
209 | QStringList KonfUpdate::findUpdateFiles(bool dirtyOnly) | 189 | QStringList KonfUpdate::findUpdateFiles(bool dirtyOnly) | ||
210 | { | 190 | { | ||
211 | QStringList result; | 191 | QStringList result; | ||
212 | 192 | | |||
213 | const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kconf_update"), QStandardPaths::LocateDirectory); | 193 | const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kconf_update"), QStandardPaths::LocateDirectory); | ||
214 | for (const QString &d : dirs) { | 194 | for (const QString &d : dirs) { | ||
215 | const QDir dir(d); | 195 | const QDir dir(d); | ||
216 | 196 | | |||
Show All 39 Lines | 235 | if (line.startsWith(QLatin1String("Version=5"))) { | |||
256 | foundVersion = true; | 236 | foundVersion = true; | ||
257 | } | 237 | } | ||
258 | ++lineCount; | 238 | ++lineCount; | ||
259 | if (line.isEmpty() || (line[0] == '#')) { | 239 | if (line.isEmpty() || (line[0] == '#')) { | ||
260 | continue; | 240 | continue; | ||
261 | } | 241 | } | ||
262 | if (line.startsWith(QLatin1String("Id="))) { | 242 | if (line.startsWith(QLatin1String("Id="))) { | ||
263 | if (!foundVersion) { | 243 | if (!foundVersion) { | ||
264 | qDebug() << QStringLiteral("Missing \"Version=5\", file \'%1\' will be skipped.").arg(filename); | 244 | qCDebug(KCONF_UPDATE_LOG, | ||
245 | "Missing 'Version=5', file '%s' will be skipped.", | ||||
246 | qUtf8Printable(filename)); | ||||
265 | return true; | 247 | return true; | ||
266 | } | 248 | } | ||
267 | id = m_currentFilename + ':' + line.mid(3); | 249 | id = m_currentFilename + ':' + line.mid(3); | ||
268 | } else if (line.startsWith(QLatin1String("File="))) { | 250 | } else if (line.startsWith(QLatin1String("File="))) { | ||
269 | checkGotFile(line.mid(5), id); | 251 | checkGotFile(line.mid(5), id); | ||
270 | } | 252 | } | ||
271 | } | 253 | } | ||
272 | 254 | | |||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 303 | if (i != -1) { | |||
322 | m_currentFilename = m_currentFilename.mid(i + 1); | 304 | m_currentFilename = m_currentFilename.mid(i + 1); | ||
323 | } | 305 | } | ||
324 | m_skip = true; | 306 | m_skip = true; | ||
325 | QFile file(filename); | 307 | QFile file(filename); | ||
326 | if (!file.open(QIODevice::ReadOnly)) { | 308 | if (!file.open(QIODevice::ReadOnly)) { | ||
327 | return false; | 309 | return false; | ||
328 | } | 310 | } | ||
329 | 311 | | |||
330 | log() << "Checking update-file '" << filename << "' for new updates" << endl; | 312 | qCDebug(KCONF_UPDATE_LOG) << "Checking update-file" << filename << "for new updates"; | ||
331 | 313 | | |||
332 | QTextStream ts(&file); | 314 | QTextStream ts(&file); | ||
333 | ts.setCodec(QTextCodec::codecForName("ISO-8859-1")); | 315 | ts.setCodec(QTextCodec::codecForName("ISO-8859-1")); | ||
334 | m_lineCount = 0; | 316 | m_lineCount = 0; | ||
335 | resetOptions(); | 317 | resetOptions(); | ||
336 | bool foundVersion = false; | 318 | bool foundVersion = false; | ||
337 | while (!ts.atEnd()) { | 319 | while (!ts.atEnd()) { | ||
338 | m_line = ts.readLine().trimmed(); | 320 | m_line = ts.readLine().trimmed(); | ||
339 | if (m_line.startsWith(QLatin1String("Version=5"))) { | 321 | if (m_line.startsWith(QLatin1String("Version=5"))) { | ||
340 | foundVersion = true; | 322 | foundVersion = true; | ||
341 | } | 323 | } | ||
342 | m_lineCount++; | 324 | m_lineCount++; | ||
343 | if (m_line.isEmpty() || (m_line[0] == QLatin1Char('#'))) { | 325 | if (m_line.isEmpty() || (m_line[0] == QLatin1Char('#'))) { | ||
344 | continue; | 326 | continue; | ||
345 | } | 327 | } | ||
346 | if (m_line.startsWith(QLatin1String("Id="))) { | 328 | if (m_line.startsWith(QLatin1String("Id="))) { | ||
347 | if (!foundVersion) { | 329 | if (!foundVersion) { | ||
348 | qDebug() << QStringLiteral("Missing \"Version=5\", file \'%1\' will be skipped.").arg(filename); | 330 | qCDebug(KCONF_UPDATE_LOG, | ||
331 | "Missing 'Version=5', file '%s' will be skipped.", | ||||
332 | qUtf8Printable(filename)); | ||||
349 | break; | 333 | break; | ||
350 | } | 334 | } | ||
351 | gotId(m_line.mid(3)); | 335 | gotId(m_line.mid(3)); | ||
352 | } else if (m_skip) { | 336 | } else if (m_skip) { | ||
353 | continue; | 337 | continue; | ||
354 | } else if (m_line.startsWith(QLatin1String("Options="))) { | 338 | } else if (m_line.startsWith(QLatin1String("Options="))) { | ||
355 | gotOptions(m_line.mid(8)); | 339 | gotOptions(m_line.mid(8)); | ||
356 | } else if (m_line.startsWith(QLatin1String("File="))) { | 340 | } else if (m_line.startsWith(QLatin1String("File="))) { | ||
Show All 18 Lines | 357 | } else if (m_line.startsWith(QLatin1String("RemoveKey="))) { | |||
375 | resetOptions(); | 359 | resetOptions(); | ||
376 | } else if (m_line == QLatin1String("AllKeys")) { | 360 | } else if (m_line == QLatin1String("AllKeys")) { | ||
377 | gotAllKeys(); | 361 | gotAllKeys(); | ||
378 | resetOptions(); | 362 | resetOptions(); | ||
379 | } else if (m_line == QLatin1String("AllGroups")) { | 363 | } else if (m_line == QLatin1String("AllGroups")) { | ||
380 | gotAllGroups(); | 364 | gotAllGroups(); | ||
381 | resetOptions(); | 365 | resetOptions(); | ||
382 | } else { | 366 | } else { | ||
383 | logFileError() << "Parse error" << endl; | 367 | qCDebugFile(KCONF_UPDATE_LOG) << "Parse error"; | ||
384 | } | 368 | } | ||
385 | } | 369 | } | ||
386 | // Flush. | 370 | // Flush. | ||
387 | gotId(QString()); | 371 | gotId(QString()); | ||
388 | 372 | | |||
389 | QFileInfo info(filename); | 373 | QFileInfo info(filename); | ||
390 | KConfigGroup cg(m_config, m_currentFilename); | 374 | KConfigGroup cg(m_config, m_currentFilename); | ||
391 | cg.writeEntry("ctime", info.created().toTime_t()); | 375 | cg.writeEntry("ctime", info.created().toTime_t()); | ||
Show All 27 Lines | 402 | if (!m_bUseConfigInfo) { | |||
419 | m_skip = true; | 403 | m_skip = true; | ||
420 | return; | 404 | return; | ||
421 | } | 405 | } | ||
422 | } | 406 | } | ||
423 | m_skip = false; | 407 | m_skip = false; | ||
424 | m_skipFile = false; | 408 | m_skipFile = false; | ||
425 | m_id = _id; | 409 | m_id = _id; | ||
426 | if (m_bUseConfigInfo) { | 410 | if (m_bUseConfigInfo) { | ||
427 | log() << m_currentFilename << ": Checking update '" << _id << "'" << endl; | 411 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Checking update" << _id; | ||
428 | } else { | 412 | } else { | ||
429 | log() << m_currentFilename << ": Found new update '" << _id << "'" << endl; | 413 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Found new update" << _id; | ||
430 | } | 414 | } | ||
431 | } | 415 | } | ||
432 | } | 416 | } | ||
433 | 417 | | |||
434 | void KonfUpdate::gotFile(const QString &_file) | 418 | void KonfUpdate::gotFile(const QString &_file) | ||
435 | { | 419 | { | ||
436 | // Reset group | 420 | // Reset group | ||
437 | gotGroup(QString()); | 421 | gotGroup(QString()); | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
492 | if (!m_oldFile.isEmpty()) { | 476 | if (!m_oldFile.isEmpty()) { | ||
493 | m_oldConfig2 = new KConfig(m_oldFile, KConfig::NoGlobals); | 477 | m_oldConfig2 = new KConfig(m_oldFile, KConfig::NoGlobals); | ||
494 | QString cfg_id = m_currentFilename + ':' + m_id; | 478 | QString cfg_id = m_currentFilename + ':' + m_id; | ||
495 | KConfigGroup cg(m_oldConfig2, "$Version"); | 479 | KConfigGroup cg(m_oldConfig2, "$Version"); | ||
496 | QStringList ids = cg.readEntry("update_info", QStringList()); | 480 | QStringList ids = cg.readEntry("update_info", QStringList()); | ||
497 | if (ids.contains(cfg_id)) { | 481 | if (ids.contains(cfg_id)) { | ||
498 | m_skip = true; | 482 | m_skip = true; | ||
499 | m_newFile.clear(); | 483 | m_newFile.clear(); | ||
500 | log() << m_currentFilename << ": Skipping update '" << m_id << "'" << endl; | 484 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Skipping update" << m_id; | ||
501 | } | 485 | } | ||
502 | 486 | | |||
503 | if (!m_newFile.isEmpty()) { | 487 | if (!m_newFile.isEmpty()) { | ||
504 | m_newConfig = new KConfig(m_newFile, KConfig::NoGlobals); | 488 | m_newConfig = new KConfig(m_newFile, KConfig::NoGlobals); | ||
505 | KConfigGroup cg(m_newConfig, "$Version"); | 489 | KConfigGroup cg(m_newConfig, "$Version"); | ||
506 | ids = cg.readEntry("update_info", QStringList()); | 490 | ids = cg.readEntry("update_info", QStringList()); | ||
507 | if (ids.contains(cfg_id)) { | 491 | if (ids.contains(cfg_id)) { | ||
508 | m_skip = true; | 492 | m_skip = true; | ||
509 | log() << m_currentFilename << ": Skipping update '" << m_id << "'" << endl; | 493 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Skipping update" << m_id; | ||
510 | } | 494 | } | ||
511 | } else { | 495 | } else { | ||
512 | m_newConfig = m_oldConfig2; | 496 | m_newConfig = m_oldConfig2; | ||
513 | } | 497 | } | ||
514 | 498 | | |||
515 | m_oldConfig1 = new KConfig(m_oldFile, KConfig::NoGlobals); | 499 | m_oldConfig1 = new KConfig(m_oldFile, KConfig::NoGlobals); | ||
516 | } else { | 500 | } else { | ||
517 | m_newFile.clear(); | 501 | m_newFile.clear(); | ||
518 | } | 502 | } | ||
519 | m_newFileName = m_newFile; | 503 | m_newFileName = m_newFile; | ||
520 | if (m_newFileName.isEmpty()) { | 504 | if (m_newFileName.isEmpty()) { | ||
521 | m_newFileName = m_oldFile; | 505 | m_newFileName = m_oldFile; | ||
522 | } | 506 | } | ||
523 | 507 | | |||
524 | m_skipFile = false; | 508 | m_skipFile = false; | ||
525 | if (!m_oldFile.isEmpty()) { // if File= is specified, it doesn't exist, is empty or contains only kconf_update's [$Version] group, skip | 509 | if (!m_oldFile.isEmpty()) { // if File= is specified, it doesn't exist, is empty or contains only kconf_update's [$Version] group, skip | ||
526 | if (m_oldConfig1 != nullptr | 510 | if (m_oldConfig1 != nullptr | ||
527 | && (m_oldConfig1->groupList().isEmpty() | 511 | && (m_oldConfig1->groupList().isEmpty() | ||
528 | || (m_oldConfig1->groupList().count() == 1 && m_oldConfig1->groupList().at(0) == QLatin1String("$Version")))) { | 512 | || (m_oldConfig1->groupList().count() == 1 && m_oldConfig1->groupList().at(0) == QLatin1String("$Version")))) { | ||
529 | log() << m_currentFilename << ": File '" << m_oldFile << "' does not exist or empty, skipping" << endl; | 513 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": File" << m_oldFile << "does not exist or empty, skipping"; | ||
530 | m_skipFile = true; | 514 | m_skipFile = true; | ||
531 | } | 515 | } | ||
532 | } | 516 | } | ||
533 | } | 517 | } | ||
534 | 518 | | |||
535 | QStringList KonfUpdate::parseGroupString(const QString &str) | 519 | QStringList KonfUpdate::parseGroupString(const QString &str) | ||
536 | { | 520 | { | ||
537 | bool ok; | 521 | bool ok; | ||
538 | QString error; | 522 | QString error; | ||
539 | QStringList lst = KConfigUtils::parseGroupString(str, &ok, &error); | 523 | QStringList lst = KConfigUtils::parseGroupString(str, &ok, &error); | ||
540 | if (!ok) { | 524 | if (!ok) { | ||
541 | logFileError() << error; | 525 | qCDebugFile(KCONF_UPDATE_LOG) << error; | ||
542 | } | 526 | } | ||
543 | return lst; | 527 | return lst; | ||
544 | } | 528 | } | ||
545 | 529 | | |||
546 | void KonfUpdate::gotGroup(const QString &_group) | 530 | void KonfUpdate::gotGroup(const QString &_group) | ||
547 | { | 531 | { | ||
548 | QString group = _group.trimmed(); | 532 | QString group = _group.trimmed(); | ||
549 | if (group.isEmpty()) { | 533 | if (group.isEmpty()) { | ||
Show All 10 Lines | |||||
560 | } | 544 | } | ||
561 | } | 545 | } | ||
562 | 546 | | |||
563 | void KonfUpdate::gotRemoveGroup(const QString &_group) | 547 | void KonfUpdate::gotRemoveGroup(const QString &_group) | ||
564 | { | 548 | { | ||
565 | m_oldGroup = parseGroupString(_group); | 549 | m_oldGroup = parseGroupString(_group); | ||
566 | 550 | | |||
567 | if (!m_oldConfig1) { | 551 | if (!m_oldConfig1) { | ||
568 | logFileError() << "RemoveGroup without previous File specification" << endl; | 552 | qCDebugFile(KCONF_UPDATE_LOG) << "RemoveGroup without previous File specification"; | ||
569 | return; | 553 | return; | ||
570 | } | 554 | } | ||
571 | 555 | | |||
572 | KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, m_oldGroup); | 556 | KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, m_oldGroup); | ||
573 | if (!cg.exists()) { | 557 | if (!cg.exists()) { | ||
574 | return; | 558 | return; | ||
575 | } | 559 | } | ||
576 | // Delete group. | 560 | // Delete group. | ||
577 | cg.deleteGroup(); | 561 | cg.deleteGroup(); | ||
578 | log() << m_currentFilename << ": RemoveGroup removes group " << m_oldFile << ":" << m_oldGroup << endl; | 562 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": RemoveGroup removes group" << m_oldFile << ":" << m_oldGroup; | ||
579 | } | 563 | } | ||
580 | 564 | | |||
581 | void KonfUpdate::gotKey(const QString &_key) | 565 | void KonfUpdate::gotKey(const QString &_key) | ||
582 | { | 566 | { | ||
583 | QString oldKey, newKey; | 567 | QString oldKey, newKey; | ||
584 | int i = _key.indexOf(','); | 568 | int i = _key.indexOf(','); | ||
585 | if (i == -1) { | 569 | if (i == -1) { | ||
586 | oldKey = _key.trimmed(); | 570 | oldKey = _key.trimmed(); | ||
587 | newKey = oldKey; | 571 | newKey = oldKey; | ||
588 | } else { | 572 | } else { | ||
589 | oldKey = _key.left(i).trimmed(); | 573 | oldKey = _key.left(i).trimmed(); | ||
590 | newKey = _key.mid(i + 1).trimmed(); | 574 | newKey = _key.mid(i + 1).trimmed(); | ||
591 | } | 575 | } | ||
592 | 576 | | |||
593 | if (oldKey.isEmpty() || newKey.isEmpty()) { | 577 | if (oldKey.isEmpty() || newKey.isEmpty()) { | ||
594 | logFileError() << "Key specifies invalid key" << endl; | 578 | qCDebugFile(KCONF_UPDATE_LOG) << "Key specifies invalid key"; | ||
595 | return; | 579 | return; | ||
596 | } | 580 | } | ||
597 | if (!m_oldConfig1) { | 581 | if (!m_oldConfig1) { | ||
598 | logFileError() << "Key without previous File specification" << endl; | 582 | qCDebugFile(KCONF_UPDATE_LOG) << "Key without previous File specification"; | ||
599 | return; | 583 | return; | ||
600 | } | 584 | } | ||
601 | copyOrMoveKey(m_oldGroup, oldKey, m_newGroup, newKey); | 585 | copyOrMoveKey(m_oldGroup, oldKey, m_newGroup, newKey); | ||
602 | } | 586 | } | ||
603 | 587 | | |||
604 | void KonfUpdate::copyOrMoveKey(const QStringList &srcGroupPath, const QString &srcKey, const QStringList &dstGroupPath, const QString &dstKey) | 588 | void KonfUpdate::copyOrMoveKey(const QStringList &srcGroupPath, const QString &srcKey, const QStringList &dstGroupPath, const QString &dstKey) | ||
605 | { | 589 | { | ||
606 | KConfigGroup dstCg = KConfigUtils::openGroup(m_newConfig, dstGroupPath); | 590 | KConfigGroup dstCg = KConfigUtils::openGroup(m_newConfig, dstGroupPath); | ||
607 | if (!m_bOverwrite && dstCg.hasKey(dstKey)) { | 591 | if (!m_bOverwrite && dstCg.hasKey(dstKey)) { | ||
608 | log() << m_currentFilename << ": Skipping " << m_newFileName << ":" << dstCg.name() << ":" << dstKey << ", already exists." << endl; | 592 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Skipping" << m_newFileName << ":" << dstCg.name() << ":" << dstKey << ", already exists."; | ||
609 | return; | 593 | return; | ||
610 | } | 594 | } | ||
611 | 595 | | |||
612 | KConfigGroup srcCg = KConfigUtils::openGroup(m_oldConfig1, srcGroupPath); | 596 | KConfigGroup srcCg = KConfigUtils::openGroup(m_oldConfig1, srcGroupPath); | ||
613 | if (!srcCg.hasKey(srcKey)) { | 597 | if (!srcCg.hasKey(srcKey)) { | ||
614 | return; | 598 | return; | ||
615 | } | 599 | } | ||
616 | QString value = srcCg.readEntry(srcKey, QString()); | 600 | QString value = srcCg.readEntry(srcKey, QString()); | ||
617 | log() << m_currentFilename << ": Updating " << m_newFileName << ":" << dstCg.name() << ":" << dstKey << " to '" << value << "'" << endl; | 601 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Updating" << m_newFileName << ":" << dstCg.name() << ":" << dstKey << "to" << value; | ||
618 | dstCg.writeEntry(dstKey, value); | 602 | dstCg.writeEntry(dstKey, value); | ||
619 | 603 | | |||
620 | if (m_bCopy) { | 604 | if (m_bCopy) { | ||
621 | return; // Done. | 605 | return; // Done. | ||
622 | } | 606 | } | ||
623 | 607 | | |||
624 | // Delete old entry | 608 | // Delete old entry | ||
625 | if (m_oldConfig2 == m_newConfig | 609 | if (m_oldConfig2 == m_newConfig | ||
626 | && srcGroupPath == dstGroupPath | 610 | && srcGroupPath == dstGroupPath | ||
627 | && srcKey == dstKey) { | 611 | && srcKey == dstKey) { | ||
628 | return; // Don't delete! | 612 | return; // Don't delete! | ||
629 | } | 613 | } | ||
630 | KConfigGroup srcCg2 = KConfigUtils::openGroup(m_oldConfig2, srcGroupPath); | 614 | KConfigGroup srcCg2 = KConfigUtils::openGroup(m_oldConfig2, srcGroupPath); | ||
631 | srcCg2.deleteEntry(srcKey); | 615 | srcCg2.deleteEntry(srcKey); | ||
632 | log() << m_currentFilename << ": Removing " << m_oldFile << ":" << srcCg2.name() << ":" << srcKey << ", moved." << endl; | 616 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Removing" << m_oldFile << ":" << srcCg2.name() << ":" << srcKey << ", moved."; | ||
633 | } | 617 | } | ||
634 | 618 | | |||
635 | void KonfUpdate::copyOrMoveGroup(const QStringList &srcGroupPath, const QStringList &dstGroupPath) | 619 | void KonfUpdate::copyOrMoveGroup(const QStringList &srcGroupPath, const QStringList &dstGroupPath) | ||
636 | { | 620 | { | ||
637 | KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig1, srcGroupPath); | 621 | KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig1, srcGroupPath); | ||
638 | 622 | | |||
639 | // Keys | 623 | // Keys | ||
640 | const QStringList lstKeys = cg.keyList(); | 624 | const QStringList lstKeys = cg.keyList(); | ||
Show All 9 Lines | |||||
650 | } | 634 | } | ||
651 | } | 635 | } | ||
652 | 636 | | |||
653 | void KonfUpdate::gotRemoveKey(const QString &_key) | 637 | void KonfUpdate::gotRemoveKey(const QString &_key) | ||
654 | { | 638 | { | ||
655 | QString key = _key.trimmed(); | 639 | QString key = _key.trimmed(); | ||
656 | 640 | | |||
657 | if (key.isEmpty()) { | 641 | if (key.isEmpty()) { | ||
658 | logFileError() << "RemoveKey specifies invalid key" << endl; | 642 | qCDebugFile(KCONF_UPDATE_LOG) << "RemoveKey specifies invalid key"; | ||
659 | return; | 643 | return; | ||
660 | } | 644 | } | ||
661 | 645 | | |||
662 | if (!m_oldConfig1) { | 646 | if (!m_oldConfig1) { | ||
663 | logFileError() << "Key without previous File specification" << endl; | 647 | qCDebugFile(KCONF_UPDATE_LOG) << "Key without previous File specification"; | ||
664 | return; | 648 | return; | ||
665 | } | 649 | } | ||
666 | 650 | | |||
667 | KConfigGroup cg1 = KConfigUtils::openGroup(m_oldConfig1, m_oldGroup); | 651 | KConfigGroup cg1 = KConfigUtils::openGroup(m_oldConfig1, m_oldGroup); | ||
668 | if (!cg1.hasKey(key)) { | 652 | if (!cg1.hasKey(key)) { | ||
669 | return; | 653 | return; | ||
670 | } | 654 | } | ||
671 | log() << m_currentFilename << ": RemoveKey removes " << m_oldFile << ":" << m_oldGroup << ":" << key << endl; | 655 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": RemoveKey removes" << m_oldFile << ":" << m_oldGroup << ":" << key; | ||
672 | 656 | | |||
673 | // Delete old entry | 657 | // Delete old entry | ||
674 | KConfigGroup cg2 = KConfigUtils::openGroup(m_oldConfig2, m_oldGroup); | 658 | KConfigGroup cg2 = KConfigUtils::openGroup(m_oldConfig2, m_oldGroup); | ||
675 | cg2.deleteEntry(key); | 659 | cg2.deleteEntry(key); | ||
676 | /*if (m_oldConfig2->deleteGroup(m_oldGroup, KConfig::Normal)) { // Delete group if empty. | 660 | /*if (m_oldConfig2->deleteGroup(m_oldGroup, KConfig::Normal)) { // Delete group if empty. | ||
677 | log() << m_currentFilename << ": Removing empty group " << m_oldFile << ":" << m_oldGroup << endl; | 661 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Removing empty group " << m_oldFile << ":" << m_oldGroup; | ||
678 | } (this should be automatic)*/ | 662 | } (this should be automatic)*/ | ||
679 | } | 663 | } | ||
680 | 664 | | |||
681 | void KonfUpdate::gotAllKeys() | 665 | void KonfUpdate::gotAllKeys() | ||
682 | { | 666 | { | ||
683 | if (!m_oldConfig1) { | 667 | if (!m_oldConfig1) { | ||
684 | logFileError() << "AllKeys without previous File specification" << endl; | 668 | qCDebugFile(KCONF_UPDATE_LOG) << "AllKeys without previous File specification"; | ||
685 | return; | 669 | return; | ||
686 | } | 670 | } | ||
687 | 671 | | |||
688 | copyOrMoveGroup(m_oldGroup, m_newGroup); | 672 | copyOrMoveGroup(m_oldGroup, m_newGroup); | ||
689 | } | 673 | } | ||
690 | 674 | | |||
691 | void KonfUpdate::gotAllGroups() | 675 | void KonfUpdate::gotAllGroups() | ||
692 | { | 676 | { | ||
693 | if (!m_oldConfig1) { | 677 | if (!m_oldConfig1) { | ||
694 | logFileError() << "AllGroups without previous File specification" << endl; | 678 | qCDebugFile(KCONF_UPDATE_LOG) << "AllGroups without previous File specification"; | ||
695 | return; | 679 | return; | ||
696 | } | 680 | } | ||
697 | 681 | | |||
698 | const QStringList allGroups = m_oldConfig1->groupList(); | 682 | const QStringList allGroups = m_oldConfig1->groupList(); | ||
699 | for (QStringList::ConstIterator it = allGroups.begin(); | 683 | for (QStringList::ConstIterator it = allGroups.begin(); | ||
700 | it != allGroups.end(); ++it) { | 684 | it != allGroups.end(); ++it) { | ||
701 | m_oldGroup = QStringList() << *it; | 685 | m_oldGroup = QStringList() << *it; | ||
702 | m_newGroup = m_oldGroup; | 686 | m_newGroup = m_oldGroup; | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 738 | { | |||
757 | if (i == -1) { | 741 | if (i == -1) { | ||
758 | script = _script.trimmed(); | 742 | script = _script.trimmed(); | ||
759 | } else { | 743 | } else { | ||
760 | script = _script.left(i).trimmed(); | 744 | script = _script.left(i).trimmed(); | ||
761 | interpreter = _script.mid(i + 1).trimmed(); | 745 | interpreter = _script.mid(i + 1).trimmed(); | ||
762 | } | 746 | } | ||
763 | 747 | | |||
764 | if (script.isEmpty()) { | 748 | if (script.isEmpty()) { | ||
765 | logFileError() << "Script fails to specify filename"; | 749 | qCDebugFile(KCONF_UPDATE_LOG) << "Script fails to specify filename"; | ||
766 | m_skip = true; | 750 | m_skip = true; | ||
767 | return; | 751 | return; | ||
768 | } | 752 | } | ||
769 | 753 | | |||
770 | QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kconf_update/") + script); | 754 | QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kconf_update/") + script); | ||
771 | if (path.isEmpty()) { | 755 | if (path.isEmpty()) { | ||
772 | if (interpreter.isEmpty()) { | 756 | if (interpreter.isEmpty()) { | ||
773 | path = CMAKE_INSTALL_PREFIX "/" LIB_INSTALL_DIR "/kconf_update_bin/" + script; | 757 | path = CMAKE_INSTALL_PREFIX "/" LIB_INSTALL_DIR "/kconf_update_bin/" + script; | ||
774 | if (!QFile::exists(path)) { | 758 | if (!QFile::exists(path)) { | ||
775 | path = QStandardPaths::findExecutable(script); | 759 | path = QStandardPaths::findExecutable(script); | ||
776 | } | 760 | } | ||
777 | } | 761 | } | ||
778 | 762 | | |||
779 | if (path.isEmpty()) { | 763 | if (path.isEmpty()) { | ||
780 | logFileError() << "Script '" << script << "' not found" << endl; | 764 | qCDebugFile(KCONF_UPDATE_LOG) << "Script" << script << "not found"; | ||
781 | m_skip = true; | 765 | m_skip = true; | ||
782 | return; | 766 | return; | ||
783 | } | 767 | } | ||
784 | } | 768 | } | ||
785 | 769 | | |||
786 | if (!m_arguments.isNull()) { | 770 | if (!m_arguments.isNull()) { | ||
787 | log() << m_currentFilename << ": Running script '" << script << "' with arguments '" << m_arguments << "'" << endl; | 771 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Running script" << script << "with arguments" << m_arguments; | ||
788 | } else { | 772 | } else { | ||
789 | log() << m_currentFilename << ": Running script '" << script << "'" << endl; | 773 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Running script" << script; | ||
790 | } | 774 | } | ||
791 | 775 | | |||
792 | QStringList args; | 776 | QStringList args; | ||
793 | QString cmd; | 777 | QString cmd; | ||
794 | if (interpreter.isEmpty()) { | 778 | if (interpreter.isEmpty()) { | ||
795 | cmd = path; | 779 | cmd = path; | ||
796 | } else { | 780 | } else { | ||
797 | QString interpreterPath = QStandardPaths::findExecutable(interpreter); | 781 | QString interpreterPath = QStandardPaths::findExecutable(interpreter); | ||
798 | if (interpreterPath.isEmpty()) { | 782 | if (interpreterPath.isEmpty()) { | ||
799 | logFileError() << "Cannot find interpreter '" << interpreter << "'." << endl; | 783 | qCDebugFile(KCONF_UPDATE_LOG) << "Cannot find interpreter" << interpreter; | ||
800 | m_skip = true; | 784 | m_skip = true; | ||
801 | return; | 785 | return; | ||
802 | } | 786 | } | ||
803 | cmd = interpreterPath; | 787 | cmd = interpreterPath; | ||
804 | args << path; | 788 | args << path; | ||
805 | } | 789 | } | ||
806 | 790 | | |||
807 | if (!m_arguments.isNull()) { | 791 | if (!m_arguments.isNull()) { | ||
808 | args += m_arguments; | 792 | args += m_arguments; | ||
809 | } | 793 | } | ||
810 | 794 | | |||
811 | QTemporaryFile scriptIn; | 795 | QTemporaryFile scriptIn; | ||
812 | scriptIn.open(); | 796 | scriptIn.open(); | ||
813 | QTemporaryFile scriptOut; | 797 | QTemporaryFile scriptOut; | ||
814 | scriptOut.open(); | 798 | scriptOut.open(); | ||
815 | 799 | | |||
816 | int result; | 800 | int result; | ||
817 | QProcess proc; | 801 | QProcess proc; | ||
818 | proc.setProcessChannelMode(QProcess::SeparateChannels); | 802 | proc.setProcessChannelMode(QProcess::SeparateChannels); | ||
819 | proc.setStandardInputFile(scriptIn.fileName()); | 803 | proc.setStandardInputFile(scriptIn.fileName()); | ||
820 | proc.setStandardOutputFile(scriptOut.fileName()); | 804 | proc.setStandardOutputFile(scriptOut.fileName()); | ||
821 | if (m_oldConfig1) { | 805 | if (m_oldConfig1) { | ||
822 | if (m_debug) { | 806 | if (m_debug) { | ||
823 | scriptIn.setAutoRemove(false); | 807 | scriptIn.setAutoRemove(false); | ||
824 | log() << "Script input stored in " << scriptIn.fileName() << endl; | 808 | qCDebug(KCONF_UPDATE_LOG) << "Script input stored in" << scriptIn.fileName(); | ||
825 | } | 809 | } | ||
826 | KConfig cfg(scriptIn.fileName(), KConfig::SimpleConfig); | 810 | KConfig cfg(scriptIn.fileName(), KConfig::SimpleConfig); | ||
827 | 811 | | |||
828 | if (m_oldGroup.isEmpty()) { | 812 | if (m_oldGroup.isEmpty()) { | ||
829 | // Write all entries to tmpFile; | 813 | // Write all entries to tmpFile; | ||
830 | const QStringList grpList = m_oldConfig1->groupList(); | 814 | const QStringList grpList = m_oldConfig1->groupList(); | ||
831 | for (QStringList::ConstIterator it = grpList.begin(); | 815 | for (QStringList::ConstIterator it = grpList.begin(); | ||
832 | it != grpList.end(); | 816 | it != grpList.end(); | ||
833 | ++it) { | 817 | ++it) { | ||
834 | copyGroup(m_oldConfig1, *it, &cfg, *it); | 818 | copyGroup(m_oldConfig1, *it, &cfg, *it); | ||
835 | } | 819 | } | ||
836 | } else { | 820 | } else { | ||
837 | KConfigGroup cg1 = KConfigUtils::openGroup(m_oldConfig1, m_oldGroup); | 821 | KConfigGroup cg1 = KConfigUtils::openGroup(m_oldConfig1, m_oldGroup); | ||
838 | KConfigGroup cg2(&cfg, QString()); | 822 | KConfigGroup cg2(&cfg, QString()); | ||
839 | copyGroup(cg1, cg2); | 823 | copyGroup(cg1, cg2); | ||
840 | } | 824 | } | ||
841 | cfg.sync(); | 825 | cfg.sync(); | ||
842 | } | 826 | } | ||
827 | | ||||
828 | qCDebug(KCONF_UPDATE_LOG) << "About to run" << cmd; | ||||
843 | if (m_debug) { | 829 | if (m_debug) { | ||
844 | log() << "About to run " << cmd << endl; | | |||
845 | QFile scriptFile(path); | 830 | QFile scriptFile(path); | ||
846 | if (scriptFile.open(QIODevice::ReadOnly)) { | 831 | if (scriptFile.open(QIODevice::ReadOnly)) { | ||
847 | log() << "Script contents is:" << endl << scriptFile.readAll() << endl; | 832 | qCDebug(KCONF_UPDATE_LOG) << "Script contents is:" << endl << scriptFile.readAll(); | ||
848 | } | 833 | } | ||
849 | } | 834 | } | ||
850 | proc.start(cmd, args); | 835 | proc.start(cmd, args); | ||
851 | if (!proc.waitForFinished(60000)) { | 836 | if (!proc.waitForFinished(60000)) { | ||
852 | logFileError() << "update script did not terminate within 60 seconds: " << cmd << endl; | 837 | qCDebugFile(KCONF_UPDATE_LOG) << "update script did not terminate within 60 seconds:" << cmd; | ||
853 | m_skip = true; | 838 | m_skip = true; | ||
854 | return; | 839 | return; | ||
855 | } | 840 | } | ||
856 | result = proc.exitCode(); | 841 | result = proc.exitCode(); | ||
857 | 842 | | |||
858 | // Copy script stderr to log file | 843 | // Copy script stderr to log file | ||
859 | { | 844 | { | ||
860 | QTextStream ts(proc.readAllStandardError()); | 845 | QTextStream ts(proc.readAllStandardError()); | ||
861 | ts.setCodec(QTextCodec::codecForName("UTF-8")); | 846 | ts.setCodec(QTextCodec::codecForName("UTF-8")); | ||
862 | while (!ts.atEnd()) { | 847 | while (!ts.atEnd()) { | ||
863 | QString line = ts.readLine(); | 848 | QString line = ts.readLine(); | ||
864 | log() << "[Script] " << line << endl; | 849 | qCDebug(KCONF_UPDATE_LOG) << "[Script]" << line; | ||
865 | } | 850 | } | ||
866 | } | 851 | } | ||
867 | proc.close(); | 852 | proc.close(); | ||
868 | 853 | | |||
869 | if (result) { | 854 | if (result) { | ||
870 | log() << m_currentFilename << ": !! An error occurred while running '" << cmd << "'" << endl; | 855 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": !! An error occurred while running" << cmd; | ||
871 | return; | 856 | return; | ||
872 | } | 857 | } | ||
873 | 858 | | |||
874 | if (m_debug) { | 859 | qCDebug(KCONF_UPDATE_LOG) << "Successfully ran" << cmd; | ||
875 | log() << "Successfully ran " << cmd << endl; | | |||
876 | } | | |||
877 | 860 | | |||
878 | if (!m_oldConfig1) { | 861 | if (!m_oldConfig1) { | ||
879 | return; // Nothing to merge | 862 | return; // Nothing to merge | ||
880 | } | 863 | } | ||
881 | 864 | | |||
882 | if (m_debug) { | 865 | if (m_debug) { | ||
883 | scriptOut.setAutoRemove(false); | 866 | scriptOut.setAutoRemove(false); | ||
884 | log() << "Script output stored in " << scriptOut.fileName() << endl; | 867 | qCDebug(KCONF_UPDATE_LOG) << "Script output stored in" << scriptOut.fileName(); | ||
885 | QFile output(scriptOut.fileName()); | 868 | QFile output(scriptOut.fileName()); | ||
886 | if (output.open(QIODevice::ReadOnly)) { | 869 | if (output.open(QIODevice::ReadOnly)) { | ||
887 | log() << "Script output is:" << endl << output.readAll() << endl; | 870 | qCDebug(KCONF_UPDATE_LOG) << "Script output is:" << endl << output.readAll(); | ||
888 | } | 871 | } | ||
889 | } | 872 | } | ||
890 | 873 | | |||
891 | // Deleting old entries | 874 | // Deleting old entries | ||
892 | { | 875 | { | ||
893 | QStringList group = m_oldGroup; | 876 | QStringList group = m_oldGroup; | ||
894 | QFile output(scriptOut.fileName()); | 877 | QFile output(scriptOut.fileName()); | ||
895 | if (output.open(QIODevice::ReadOnly)) { | 878 | if (output.open(QIODevice::ReadOnly)) { | ||
Show All 9 Lines | 887 | if (key[0] == '[') { | |||
905 | int j = key.lastIndexOf(']') + 1; | 888 | int j = key.lastIndexOf(']') + 1; | ||
906 | if (j > 0) { | 889 | if (j > 0) { | ||
907 | group = parseGroupString(key.left(j)); | 890 | group = parseGroupString(key.left(j)); | ||
908 | key = key.mid(j); | 891 | key = key.mid(j); | ||
909 | } | 892 | } | ||
910 | } | 893 | } | ||
911 | KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, group); | 894 | KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, group); | ||
912 | cg.deleteEntry(key); | 895 | cg.deleteEntry(key); | ||
913 | log() << m_currentFilename << ": Script removes " << m_oldFile << ":" << group << ":" << key << endl; | 896 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Script removes" << m_oldFile << ":" << group << ":" << key; | ||
914 | /*if (m_oldConfig2->deleteGroup(group, KConfig::Normal)) { // Delete group if empty. | 897 | /*if (m_oldConfig2->deleteGroup(group, KConfig::Normal)) { // Delete group if empty. | ||
915 | log() << m_currentFilename << ": Removing empty group " << m_oldFile << ":" << group << endl; | 898 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Removing empty group " << m_oldFile << ":" << group; | ||
916 | } (this should be automatic)*/ | 899 | } (this should be automatic)*/ | ||
917 | } else if (line.startsWith(QLatin1String("# DELETEGROUP"))) { | 900 | } else if (line.startsWith(QLatin1String("# DELETEGROUP"))) { | ||
918 | QString str = line.mid(13).trimmed(); | 901 | QString str = line.mid(13).trimmed(); | ||
919 | if (!str.isEmpty()) { | 902 | if (!str.isEmpty()) { | ||
920 | group = parseGroupString(str); | 903 | group = parseGroupString(str); | ||
921 | } | 904 | } | ||
922 | KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, group); | 905 | KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, group); | ||
923 | cg.deleteGroup(); | 906 | cg.deleteGroup(); | ||
924 | log() << m_currentFilename << ": Script removes group " << m_oldFile << ":" << group << endl; | 907 | qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Script removes group" << m_oldFile << ":" << group; | ||
925 | } | 908 | } | ||
926 | } | 909 | } | ||
927 | } | 910 | } | ||
928 | } | 911 | } | ||
929 | 912 | | |||
930 | // Merging in new entries. | 913 | // Merging in new entries. | ||
931 | KConfig scriptOutConfig(scriptOut.fileName(), KConfig::NoGlobals); | 914 | KConfig scriptOutConfig(scriptOut.fileName(), KConfig::NoGlobals); | ||
932 | if (m_newGroup.isEmpty()) { | 915 | if (m_newGroup.isEmpty()) { | ||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |