[neon/neon-packaging/debconf-kde/Neon/stable] debian/patches: refresh patch
Carlos De Maine
null at kde.org
Wed Apr 2 06:24:45 BST 2025
Git commit 6fbbecc1bf1cd0c464f3b4b4e1e3f714b8c4610b by Carlos De Maine.
Committed on 02/04/2025 at 05:24.
Pushed by carlosdem into branch 'Neon/stable'.
refresh patch
M +190 -662 debian/patches/kf6_more.diff
https://invent.kde.org/neon/neon-packaging/debconf-kde/-/commit/6fbbecc1bf1cd0c464f3b4b4e1e3f714b8c4610b
diff --git a/debian/patches/kf6_more.diff b/debian/patches/kf6_more.diff
index 8580eda..c7654e7 100644
--- a/debian/patches/kf6_more.diff
+++ b/debian/patches/kf6_more.diff
@@ -1,718 +1,246 @@
-diff --git a/.clang-format b/.clang-format
-new file mode 100644
-index 0000000000000000000000000000000000000000..977a49ee993d1f5ed56d853b8f1b3af5391474eb
---- /dev/null
-+++ b/.clang-format
-@@ -0,0 +1,86 @@
-+---
-+---
-+# SPDX-FileCopyrightText: 2019 Christoph Cullmann <cullmann at kde.org>
-+# SPDX-FileCopyrightText: 2019 Gernot Gebhard <gebhard at absint.com>
-+#
-+# SPDX-License-Identifier: MIT
-+
-+---
-+Language: JavaScript
-+DisableFormat: true
-+---
-+
-+# Style for C++
-+Language: Cpp
-+Standard: c++20
-+
-+# base is WebKit coding style: https://webkit.org/code-style-guidelines/
-+# below are only things set that diverge from this style!
-+BasedOnStyle: WebKit
-+
-+# 4 spaces indent
-+TabWidth: 4
-+
-+# No line limit
-+ColumnLimit: 0
-+
-+# sort includes inside line separated groups
-+SortIncludes: true
-+
-+# Braces are usually attached, but not after functions or class declarations.
-+BreakBeforeBraces: Custom
-+BraceWrapping:
-+ AfterClass: true
-+ AfterControlStatement: false
-+ AfterEnum: false
-+ AfterFunction: true
-+ AfterNamespace: true
-+ AfterObjCDeclaration: false
-+ AfterStruct: true
-+ AfterUnion: false
-+ BeforeCatch: false
-+ BeforeElse: false
-+ IndentBraces: false
-+
-+# CrlInstruction *a;
-+PointerAlignment: Right
-+
-+# horizontally aligns arguments after an open bracket.
-+AlignAfterOpenBracket: Align
-+
-+# don't move all parameters to new line
-+AllowAllParametersOfDeclarationOnNextLine: false
-+
-+# no single line functions
-+AllowShortFunctionsOnASingleLine: None
-+
-+# In case we have an if statement with multiple lines the operator should be at the beginning of the line
-+# but we do not want to break assignments
-+BreakBeforeBinaryOperators: NonAssignment
-+
-+# format C++11 braced lists like function calls
-+Cpp11BracedListStyle: true
-+
-+# do not put a space before C++11 braced lists
-+SpaceBeforeCpp11BracedList: false
-+
-+# no namespace indentation to keep indent level low
-+NamespaceIndentation: None
-+
-+# we use template< without space.
-+SpaceAfterTemplateKeyword: false
-+
-+# Always break after template declaration
-+AlwaysBreakTemplateDeclarations: true
-+
-+# macros for which the opening brace stays attached.
-+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE , wl_resource_for_each, wl_resource_for_each_safe ]
-+
-+# keep lambda formatting multi-line if not empty
-+AllowShortLambdasOnASingleLine: Empty
-+
-+# We do not want clang-format to put all arguments on a new line
-+AllowAllArgumentsOnNextLine: false
-+
-+# Indent lambdas to the start of the line, not to the start of the lambda
-+LambdaBodyIndentation: OuterScope
-diff --git a/.gitignore b/.gitignore
-new file mode 100644
-index 0000000000000000000000000000000000000000..ec37b93b4e26b127e845d53707df41c5e6615ac5
---- /dev/null
-+++ b/.gitignore
-@@ -0,0 +1,28 @@
-+# Ignore the following files
-+.vscode
-+*~
-+*.[oa]
-+*.diff
-+*.kate-swp
-+*.kdev4
-+.kdev_include_paths
-+*.kdevelop.pcs
-+*.moc
-+*.moc.cpp
-+*.orig
-+*.user
-+.*.swp
-+.swp.*
-+Doxyfile
-+Makefile
-+avail
-+random_seed
-+/build*/
-+CMakeLists.txt.user*
-+*.unc-backup*
-+/compile_commands.json
-+.clangd
-+.idea
-+/cmake-build*
-+.cache
-+.directory
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index e865211e53b00123811ce7451172f119e82be778..665bb33756e4504e39dc13955e57e8a5e3dd742a 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -12,13 +12,13 @@ project(libdebconf-kde VERSION 1.1.1)
-
- set(QT_MIN_VERSION "5.8.0")
- set(KF_MIN_VERSION "5.96.0")
-+set(KDE_COMPILERSETTINGS_LEVEL "5.85.0")
-
--find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
-+find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE)
- set(CMAKE_MODULE_PATH
- ${ECM_MODULE_PATH}
- ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
-
--include(ECMPackageConfigHelpers)
- include(ECMSetupVersion)
- include(FeatureSummary)
- include(GenerateExportHeader)
-@@ -26,8 +26,6 @@ include(KDEInstallDirs)
- include(KDECMakeSettings)
- include(KDECompilerSettings)
-
--set(REQUIRED_QT_VERSION 5.2.0) # Used in CMakeConfig to check deps
--
- if (QT_MAJOR_VERSION STREQUAL "6")
- set(QT_REQUIRED_VERSION "6.4.0")
- set(QT_MIN_VERSION "${QT_REQUIRED_VERSION}")
-@@ -37,6 +35,8 @@ else()
- set(KF_MAJOR_VERSION "5")
- endif()
-
-+set(REQUIRED_QT_VERSION "${QT_MIN_VERSION}") # Used in CMakeConfig to check deps
+diff --git a/src/debconf.cpp b/src/debconf.cpp
+index 7e7a0a0c6d1b0803966cf1c4f0edf126ca86ca1b..1b03eceb267a9de69829c8c8da34439761b67a0a 100644
+--- a/src/debconf.cpp
++++ b/src/debconf.cpp
+@@ -68,7 +68,7 @@ const DebconfFrontend::Cmd DebconfFrontend::commands[] = {{"SET", &DebconfFronte
+ {"SETTITLE", &DebconfFrontend::cmd_title, 1},
+ {"DATA", &DebconfFrontend::cmd_data, 3},
+ {"SUBST", &DebconfFrontend::cmd_subst, 3},
+- {"INPUT", &DebconfFrontend::cmd_input, 1},
++ {"INPUT", &DebconfFrontend::cmd_input, 2},
+ {"GET", &DebconfFrontend::cmd_get, 1},
+ {"CAPB", &DebconfFrontend::cmd_capb, 1},
+ {"PROGRESS", &DebconfFrontend::cmd_progress, 1},
+@@ -84,8 +84,58 @@ const DebconfFrontend::Cmd DebconfFrontend::commands[] = {{"SET", &DebconfFronte
+ {"REGISTER", &DebconfFrontend::cmd_register, 2},
+ {"UNREGISTER", &DebconfFrontend::cmd_unregister, 1},
+ {"EXIST", &DebconfFrontend::cmd_exist, 1},
++ {"CLEAR", &DebconfFrontend::cmd_clear, 0},
++ {"RESET", &DebconfFrontend::cmd_reset, 1},
++ {"PURGE", &DebconfFrontend::cmd_purge, 0},
+ {nullptr, nullptr, 0}};
+
++static inline QString escape_data(const QString &str)
++{
++ QString result{};
++ result.reserve(str.size());
++ for (auto it = str.constBegin(); it != str.constEnd(); ++it) {
++ if (*it == QLatin1Char('\n')) {
++ result += QLatin1String("\\n");
++ } else if (*it == QLatin1Char('\\')) {
++ result += QLatin1String("\\\\");
++ } else {
++ result += *it;
++ }
++ }
+
- find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED
- COMPONENTS
- Widgets
-@@ -67,13 +67,6 @@ ecm_setup_version(${PROJECT_VERSION}
-
- add_definitions(-DPROJECT_VERSION=\"${PROJECT_VERSION}\")
- add_definitions(
-- -DQT_NO_KEYWORDS
-- -DQT_NO_CAST_TO_ASCII
-- -DQT_NO_CAST_FROM_ASCII
-- -DQT_STRICT_ITERATORS
-- -DQT_NO_URL_CAST_FROM_STRING
-- -DQT_NO_CAST_FROM_BYTEARRAY
-- -DQT_USE_QSTRINGBUILDER
- -DQT_DISABLE_DEPRECATED_BEFORE=0x050900
- )
-
-@@ -86,7 +79,7 @@ include_directories(
- # create a Config.cmake and a ConfigVersion.cmake file and install them
- set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/DebconfKDE")
-
--ecm_configure_package_config_file(
-+configure_package_config_file(
- "${CMAKE_CURRENT_SOURCE_DIR}/DebconfKDEConfig.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/DebconfKDEConfig.cmake"
- INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR})
-@@ -103,4 +96,6 @@ install(EXPORT DebconfKDETargets
- add_subdirectory(src)
- add_subdirectory(tools)
-
-+ki18n_install(po)
++ return result;
++}
+
- feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
-diff --git a/TODO b/TODO
-index ae4aba26216426578321e567134d9470a265a714..7e2affc6469e7338918ed463d99ec4e0587c1216 100644
---- a/TODO
-+++ b/TODO
-@@ -1,17 +1,11 @@
- Commands to review/fix:
- * Dummy commands, right now they just reply with a "O ok", but probably they
- should do something:
-- - INFO
- - FSET (actually it stores the flags as specified by the client, so they
- could be retrieved later by FGET, but we don't do things with them).
-- - BEGINBLOCK
-- - ENDBLOCK
- * Not yet implemented commands:
- - CLEAR
- - RESET
-- - METAGET
-- - REGISTER
-- - UNREGISTER
- - PURGE
- - PREVIOUS_MODULE
- (this one is not documented in the debconf protocol specs, as well as DATA
-diff --git a/src/DebconfGui.cpp b/src/DebconfGui.cpp
-index c63dcb23558795f4a4587a37bf97c850f1853717..4226f3530a11420c83ef8416e26d2b661c3e8a4e 100644
---- a/src/DebconfGui.cpp
-+++ b/src/DebconfGui.cpp
-@@ -68,6 +68,7 @@
- #include <QtCore/QFile>
- #include <QtWidgets/QLabel>
- #include <QHostInfo>
-+#include <QFrame>
-
- #include <KGuiItem>
- #include <KIconLoader>
-@@ -247,11 +248,15 @@ void DebconfGui::cmd_go(const QString &title, const QStringList &input)
- bool needStretch = true;
- if (input.size() == 1) {
- const QString key = input.first();
-- if (d->frontend->type(key) == DebconfFrontend::Text &&
-- d->frontend->type(key) == DebconfFrontend::Note &&
-- d->frontend->type(key) == DebconfFrontend::Error &&
-- d->frontend->type(key) == DebconfFrontend::Multiselect) {
-- needStretch = false;
-+ switch (d->frontend->type(key)) {
-+ case DebconfFrontend::Text:
-+ case DebconfFrontend::Note:
-+ case DebconfFrontend::Error:
-+ case DebconfFrontend::Multiselect:
-+ needStretch = false;
-+ break;
-+ default:
++static inline QString unescape_data(const QString &str)
++{
++ QString result{};
++ result.reserve(str.size());
++ // the logic here is slightly different from the Perl version but it should behave the same
++ // we also can not throw any errors and should just roll with the bad escape sequences
++ for (auto it = str.constBegin(); it != str.constEnd(); ++it) {
++ if (*it == QLatin1Char('\\')) {
++ // unescape the next character
++ if ((++it) == str.constEnd()) {
++ // invalid escape sequence (premature EOI)
+ break;
- }
- }
-
-@@ -259,7 +264,20 @@ void DebconfGui::cmd_go(const QString &title, const QStringList &input)
- layout->addStretch();
- }
-
-+ const QString side_info = d->frontend->getSideInfo();
-+ if (!side_info.isEmpty()) {
-+ QLabel *label = new QLabel(side_info);
-+ layout->addWidget(label);
-+ }
-+
- for (const QString &elementName : input) {
-+ if (elementName == QLatin1String("div")) {
-+ QFrame *divider = new QFrame(d->parentWidget);
-+ divider->setFrameShape(QFrame::HLine);
-+ divider->setFrameShadow(QFrame::Sunken);
-+ layout->addWidget(divider);
++ }
++ const QChar next_char = *it;
++ if (next_char == QLatin1Char('n')) {
++ result += QLatin1Char('\n');
++ } else if (next_char == QLatin1Char('\\')) {
++ result += QLatin1Char('\\');
++ } else {
++ // invalid escape sequence (we still append the next character like the Perl version)
++ result += next_char;
++ }
+ continue;
+ }
- DebconfElement *element = d->createElement(elementName);
- d->elements.append(element);
- layout->addWidget(element);
-diff --git a/src/debconf.cpp b/src/debconf.cpp
-index 85db705a65ec52686b9a91b1dffcf3b91c014367..5b78b0cb1c36d5ff724f2df2526e6396f1fb572b 100644
---- a/src/debconf.cpp
-+++ b/src/debconf.cpp
-@@ -62,26 +62,29 @@
- namespace DebconfKde {
-
- const DebconfFrontend::Cmd DebconfFrontend::commands[] = {
-- { "SET", &DebconfFrontend::cmd_set },
-- { "GO", &DebconfFrontend::cmd_go },
-- { "TITLE", &DebconfFrontend::cmd_title },
-- { "SETTITLE", &DebconfFrontend::cmd_title },
-- { "DATA", &DebconfFrontend::cmd_data },
-- { "SUBST", &DebconfFrontend::cmd_subst },
-- { "INPUT", &DebconfFrontend::cmd_input },
-- { "GET", &DebconfFrontend::cmd_get },
-- { "CAPB", &DebconfFrontend::cmd_capb },
-- { "PROGRESS", &DebconfFrontend::cmd_progress },
-- { "X_PING", &DebconfFrontend::cmd_x_ping },
-- { "VERSION", &DebconfFrontend::cmd_version },
-- { "X_LOADTEMPLATEFILE", &DebconfFrontend::cmd_x_loadtemplatefile },
-- { "INFO", &DebconfFrontend::cmd_info },
-- { "FGET", &DebconfFrontend::cmd_fget },
-- { "FSET", &DebconfFrontend::cmd_fset },
-- { "BEGINBLOCK", &DebconfFrontend::cmd_beginblock },
-- { "ENDBLOCK", &DebconfFrontend::cmd_endblock },
-- { "STOP", &DebconfFrontend::cmd_stop },
-- { nullptr, nullptr } };
-+ { "SET", &DebconfFrontend::cmd_set, 2 },
-+ { "GO", &DebconfFrontend::cmd_go, 0 },
-+ { "TITLE", &DebconfFrontend::cmd_title, 1 },
-+ { "SETTITLE", &DebconfFrontend::cmd_title, 1 },
-+ { "DATA", &DebconfFrontend::cmd_data, 3 },
-+ { "SUBST", &DebconfFrontend::cmd_subst, 3 },
-+ { "INPUT", &DebconfFrontend::cmd_input, 1 },
-+ { "GET", &DebconfFrontend::cmd_get, 1 },
-+ { "CAPB", &DebconfFrontend::cmd_capb, 1 },
-+ { "PROGRESS", &DebconfFrontend::cmd_progress, 1 },
-+ { "X_PING", &DebconfFrontend::cmd_x_ping, 0 },
-+ { "VERSION", &DebconfFrontend::cmd_version, 0 },
-+ { "X_LOADTEMPLATEFILE", &DebconfFrontend::cmd_x_loadtemplatefile, 1 },
-+ { "INFO", &DebconfFrontend::cmd_info, 0 },
-+ { "FGET", &DebconfFrontend::cmd_fget, 2 },
-+ { "FSET", &DebconfFrontend::cmd_fset, 3 },
-+ { "BEGINBLOCK", &DebconfFrontend::cmd_beginblock, 0 },
-+ { "ENDBLOCK", &DebconfFrontend::cmd_endblock, 0 },
-+ { "STOP", &DebconfFrontend::cmd_stop, 0 },
-+ { "REGISTER", &DebconfFrontend::cmd_register, 2 },
-+ { "UNREGISTER", &DebconfFrontend::cmd_unregister, 1 },
-+ { "EXIST", &DebconfFrontend::cmd_exist, 1 },
-+ { nullptr, nullptr, 0 } };
-
++ result += *it;
++ }
++
++ return result;
++}
++
DebconfFrontend::DebconfFrontend(QObject *parent)
- : QObject(parent)
-@@ -190,33 +193,34 @@ QString DebconfFrontend::property(const QString &key, PropertyKey p) const
- return r;
- }
-
--void DebconfFrontend::cmd_capb(const QString &caps)
-+void DebconfFrontend::cmd_capb(const QStringList &args)
+ : QObject(parent)
{
-+ const QString caps = args[0];
- Q_EMIT backup(caps.split(QLatin1String(", ")).contains(QLatin1String("backup")));
- say(QLatin1String("0 backup"));
+@@ -154,6 +204,7 @@ void DebconfFrontend::reset()
+ m_subst.clear();
+ m_values.clear();
+ m_flags.clear();
++ m_making_block = false;
}
--void DebconfFrontend::cmd_set(const QString ¶m)
-+void DebconfFrontend::cmd_set(const QStringList &args)
+ void DebconfFrontend::say(const QString &string)
+@@ -197,9 +248,11 @@ QString DebconfFrontend::property(const QString &key, PropertyKey p) const
+
+ void DebconfFrontend::cmd_capb(const QStringList &args)
{
-- const QString item = param.section(QLatin1Char(' '), 0, 0);
-- const QString value = param.section(QLatin1Char(' '), 1);
-+ const QString item = args[0];
-+ const QString value = args[1];
- m_values[item] = value;
- qCDebug(DEBCONF) << "# SET: [" << item << "] " << value;
- say(QLatin1String("0 ok"));
+- const QString caps = args[0];
+- Q_EMIT backup(caps.split(QLatin1String(", ")).contains(QLatin1String("backup")));
+- say(QLatin1String("0 backup"));
++ Q_EMIT backup(args.contains(QLatin1String("backup")));
++ if (args.contains(QLatin1String("escape"))) {
++ m_should_escape = true;
++ }
++ say(QLatin1String("0 multiselect escape backup"));
}
--void DebconfFrontend::cmd_get(const QString ¶m)
-+void DebconfFrontend::cmd_get(const QStringList &args)
+ void DebconfFrontend::cmd_set(const QStringList &args)
+@@ -213,12 +266,22 @@ void DebconfFrontend::cmd_set(const QStringList &args)
+
+ void DebconfFrontend::cmd_get(const QStringList &args)
{
-- say(QLatin1String("0 ") + m_values.value(param));
-+ say(QLatin1String("0 ") + m_values.value(args[0]));
+- say(QLatin1String("0 ") + m_values.value(args[0]));
++ const QString result = m_values.value(args[0]);
++ if (m_should_escape) {
++ say(QLatin1String("1 ") + escape_data(result));
++ } else {
++ say(QLatin1String("0 ") + result);
++ }
}
--void DebconfFrontend::cmd_input(const QString ¶m)
-+void DebconfFrontend::cmd_input(const QStringList &args)
+ void DebconfFrontend::cmd_input(const QStringList &args)
{
-- m_input.append(param.section(QLatin1Char(' '), 1));
-+ m_input.append(args[0]);
- say(QLatin1String("0 will ask" ));
+- m_input.append(args[0]);
++ const QString item = args[1];
++ if (!m_data.contains(item)) {
++ say(QLatin1String("10 \"%1\" doesn't exist").arg(item));
++ return;
++ }
++ m_input.append(item);
+ say(QLatin1String("0 will ask"));
}
--void DebconfFrontend::cmd_go(const QString &)
-+void DebconfFrontend::cmd_go(const QStringList &)
+@@ -226,6 +289,11 @@ void DebconfFrontend::cmd_go(const QStringList &)
{
qCDebug(DEBCONF) << "# GO";
m_input.removeDuplicates();
-@@ -224,12 +228,65 @@ void DebconfFrontend::cmd_go(const QString &)
++ if (m_input.isEmpty()) {
++ // if there is no question to ask, we are done here
++ say(QLatin1String("0 ok"));
++ return;
++ }
+ Q_EMIT go(m_title, m_input);
m_input.clear();
}
+@@ -280,7 +348,11 @@ void DebconfFrontend::cmd_metaget(const QStringList &args)
+ return;
+ }
+ const QString data = properties[key];
+- say(QLatin1String("0 ") + data);
++ if (m_should_escape) {
++ say(QLatin1String("1 ") + escape_data(data));
++ } else {
++ say(QLatin1String("0 ") + data);
++ }
+ }
--void DebconfFrontend::cmd_progress(const QString ¶m)
-+void DebconfFrontend::cmd_progress(const QStringList &args)
- {
-+ const QString param = args[0];
- qCDebug(DEBCONF) << "DEBCONF: PROGRESS " << param;
- Q_EMIT progress(param);
+ void DebconfFrontend::cmd_exist(const QStringList &args)
+@@ -399,6 +471,11 @@ void DebconfFrontend::cmd_x_loadtemplatefile(const QStringList &args)
+ m_data[item][DebconfFrontend::Description] = short_description;
+ m_data[item][DebconfFrontend::ExtendedDescription] = long_description;
+
++ // read the optional default value if exists.
++ if (field_short_value.contains(QLatin1String("default"))) {
++ m_data[item][DebconfFrontend::Default] = field_short_value[QLatin1String("default")];
++ }
++
+ // Clear data.
+ field_short_value.clear();
+ field_long_value.clear();
+@@ -494,6 +571,37 @@ void DebconfFrontend::cmd_endblock(const QStringList &args)
+ say(QLatin1String("0 ok"));
}
-+void DebconfFrontend::cmd_register(const QStringList &args)
++void DebconfFrontend::cmd_clear(const QStringList &args)
+{
-+ const QString templateName = args[0];
-+ const QString question = args[1];
-+
-+ if (!m_data.contains(templateName)) {
-+ say(QLatin1String("20 No such template, \"%1\"").arg(templateName));
-+ return;
-+ }
-+ m_data[question] = m_data[templateName];
++ Q_UNUSED(args)
++ m_input.clear();
++ m_making_block = false;
+ say(QLatin1String("0 ok"));
+}
+
-+void DebconfFrontend::cmd_unregister(const QStringList &args)
++void DebconfFrontend::cmd_reset(const QStringList &args)
+{
+ const QString question = args[0];
+ if (!m_data.contains(question)) {
-+ say(QLatin1String("20 %1 doesn't exist").arg(question));
++ say(QLatin1String("20 question doesn't exist"));
+ return;
+ }
-+ if (m_input.contains(question)) {
-+ say(QLatin1String("20 %1 is busy, cannot unregister right now").arg(question));
-+ return;
++ m_flags[question][QStringLiteral("seen")] = false;
++ if (m_data[question].contains(DebconfFrontend::Default)) {
++ m_values[question] = m_data[question][DebconfFrontend::Default];
++ } else {
++ m_values[question].clear();
+ }
-+ m_data.remove(question);
+ say(QLatin1String("0 ok"));
+}
+
-+void DebconfFrontend::cmd_metaget(const QStringList &args)
++void DebconfFrontend::cmd_purge(const QStringList &args)
+{
-+ const QString question = args[0];
-+ const QString fieldName = args[1];
-+ if (!m_data.contains(question)) {
-+ say(QLatin1String("20 %1 doesn't exist").arg(question));
-+ return;
-+ }
-+ const auto properties = m_data[question];
-+ const auto key = propertyKeyFromString(fieldName);
-+ if (!properties.contains(key)) {
-+ say(QLatin1String("20 %1 does not exist").arg(fieldName));
-+ return;
-+ }
-+ const QString data = properties[key];
-+ say(QLatin1String("0 ") + data);
-+}
-+
-+void DebconfFrontend::cmd_exist(const QStringList &args)
-+{
-+ const QString question = args[0];
-+ say(QLatin1String("0 ") + (m_data.contains(question) ? QLatin1String("true") : QLatin1String("false")));
++ Q_UNUSED(args)
++ // stubbed: we don't have the "ownership" system implemented
++ say(QLatin1String("0 ok"));
+}
+
- void DebconfFrontend::next()
- {
- m_input.clear();
-@@ -247,8 +304,9 @@ void DebconfFrontend::cancel()
- reset();
- }
-
--void DebconfFrontend::cmd_title(const QString ¶m)
-+void DebconfFrontend::cmd_title(const QStringList &args)
- {
-+ const QString param = args[0];
- if (!property(param, Description).isEmpty()) {
- m_title = property(param, Description);
- } else {
-@@ -258,46 +316,47 @@ void DebconfFrontend::cmd_title(const QString ¶m)
- say(QLatin1String("0 ok"));
- }
-
--void DebconfFrontend::cmd_data(const QString ¶m)
-+void DebconfFrontend::cmd_data(const QStringList &args)
+ void DebconfFrontend::cmd_stop(const QStringList &args)
{
- // We get strings like
- // aiccu/brokername description Tunnel broker:
- // item = "aiccu/brokername"
- // type = "description"
- // rest = "Tunnel broker:"
-- const QString item = param.section(QLatin1Char(' '), 0, 0);
-- const QString type = param.section(QLatin1Char(' '), 1, 1);
-- const QString value = param.section(QLatin1Char(' '), 2);
-+ const QString item = args[0];
-+ const QString type = args[1];
-+ const QString value = args[2];
-
- m_data[item][propertyKeyFromString(type)] = value;
- qCDebug(DEBCONF) << "# NOTED: [" << item << "] [" << type << "] " << value;
- say(QStringLiteral( "0 ok" ));
- }
-
--void DebconfFrontend::cmd_subst(const QString ¶m)
-+void DebconfFrontend::cmd_subst(const QStringList &args)
- {
- // We get strings like
- // aiccu/brokername brokers AARNet, Hexago / Freenet6, SixXS, Wanadoo France
- // item = "aiccu/brokername"
- // type = "brokers"
- // value = "AARNet, Hexago / Freenet6, SixXS, Wanadoo France"
-- const QString item = param.section(QLatin1Char(' '), 0, 0);
-- const QString type = param.section(QLatin1Char(' '), 1, 1);
-- const QString value = param.section(QLatin1Char(' '), 2);
-+ const QString item = args[0];
-+ const QString type = args[1];
-+ const QString value = args[2];
-
- m_subst[item][type] = value;
- qCDebug(DEBCONF) << "# SUBST: [" << item << "] [" << type << "] " << value;
- say(QLatin1String("0 ok"));
- }
-
--void DebconfFrontend::cmd_x_ping(const QString ¶m)
-+void DebconfFrontend::cmd_x_ping(const QStringList &args)
- {
-- Q_UNUSED(param);
-+ Q_UNUSED(args);
- say(QLatin1String("0 pong"));
- }
-
--void DebconfFrontend::cmd_version(const QString ¶m)
-+void DebconfFrontend::cmd_version(const QStringList &args)
- {
-+ const QString param = args[0];
- if ( !param.isEmpty() ) {
- const QString major_version_str = param.section(QLatin1Char('.'), 0, 0);
- bool ok = false;
-@@ -311,9 +370,9 @@ void DebconfFrontend::cmd_version(const QString ¶m)
- say(QLatin1String("0 2.1"));
- }
-
--void DebconfFrontend::cmd_x_loadtemplatefile(const QString ¶m)
-+void DebconfFrontend::cmd_x_loadtemplatefile(const QStringList &args)
- {
-- QFile template_file(param);
-+ QFile template_file(args[0]);
- if (template_file.open(QFile::ReadOnly)) {
- QTextStream template_stream(&template_file);
- QString line = QLatin1String("");
-@@ -366,22 +425,30 @@ void DebconfFrontend::cmd_x_loadtemplatefile(const QString ¶m)
- say(QLatin1String("0 ok"));
- }
-
--void DebconfFrontend::cmd_info(const QString ¶m)
-+void DebconfFrontend::cmd_info(const QStringList &args)
- {
-- Q_UNUSED(param)
-- //FIXME: this is a dummy command, we should actually do something
-- //with param.
-+ const QString &key = args[0];
-+ if (key.isEmpty()) {
-+ // this is the Perl debconf behaviour
-+ say(QLatin1String("0 ok"));
-+ return;
-+ }
-+ if (!m_data.contains(key)) {
-+ say(QLatin1String("20 question doesn't exist"));
-+ return;
-+ }
-+ m_side_info = m_data[key][PropertyKey::Description];
- say(QLatin1String("0 ok"));
- }
-
--void DebconfFrontend::cmd_fget(const QString ¶m)
-+void DebconfFrontend::cmd_fget(const QStringList &args)
- {
- // We get strings like
- // foo/bar seen false
- // question = "foo/bar"
- // flag = "seen"
-- const QString question = param.section(QLatin1Char(' '), 0, 0);
-- const QString flag = param.section(QLatin1Char(' '), 1, 1);
-+ const QString question = args[0];
-+ const QString flag = args[1];
-
- if (m_flags[question][flag]) {
- say(QLatin1String("0 true"));
-@@ -390,16 +457,16 @@ void DebconfFrontend::cmd_fget(const QString ¶m)
+ Q_UNUSED(args)
+@@ -509,6 +617,11 @@ bool DebconfFrontend::process()
+ return false;
}
- }
--void DebconfFrontend::cmd_fset(const QString ¶m)
-+void DebconfFrontend::cmd_fset(const QStringList &args)
- {
- // We get strings like
- // foo/bar seen false
- // question = "foo/bar"
- // flag = "seen"
- // value = "false"
-- const QString question = param.section(QLatin1Char(' '), 0, 0);
-- const QString flag = param.section(QLatin1Char(' '), 1, 1);
-- const QString value = param.section(QLatin1Char(' '), 2, 2);
-+ const QString question = args[0];
-+ const QString flag = args[1];
-+ const QString value = args[2];
-
- if ( value == QLatin1String("false") ) {
- m_flags[question][flag] = false;
-@@ -409,25 +476,25 @@ void DebconfFrontend::cmd_fset(const QString ¶m)
- say(QLatin1String("0 ok"));
- }
-
--void DebconfFrontend::cmd_beginblock(const QString ¶m)
-+void DebconfFrontend::cmd_beginblock(const QStringList &args)
- {
-- Q_UNUSED(param)
-- //FIXME: this is a dummy command, we should actually do something
-- //with param.
-+ Q_UNUSED(args)
-+ m_making_block = true;
- say(QLatin1String("0 ok"));
- }
-
--void DebconfFrontend::cmd_endblock(const QString ¶m)
-+void DebconfFrontend::cmd_endblock(const QStringList &args)
- {
-- Q_UNUSED(param)
-- //FIXME: this is a dummy command, we should actually do something
-- //with param.
-+ Q_UNUSED(args)
-+ if (m_making_block)
-+ m_input.append(QStringLiteral("div"));
-+ m_making_block = false;
- say(QLatin1String("0 ok"));
- }
-
--void DebconfFrontend::cmd_stop(const QString ¶m)
-+void DebconfFrontend::cmd_stop(const QStringList &args)
- {
-- Q_UNUSED(param)
-+ Q_UNUSED(args)
- //Do nothing.
- }
-
-@@ -447,11 +514,29 @@ bool DebconfFrontend::process()
- const Cmd *c = commands;
- while (c->cmd != nullptr) {
- if (command == QLatin1String(c->cmd)) {
-- (this->*(c->run))(value);
-+ QStringList args{};
-+ if (c->num_args_min > 0) {
-+ int args_scanned = 0;
-+ for (int i = 0; i < c->num_args_min; i++) {
-+ const int end_index = (i < (c->num_args_min - 1)) ? i : -1;
-+ const QString arg = value.section(QLatin1Char(' '), i, end_index);
-+ if (!arg.isEmpty()) args_scanned++;
-+ args.append(arg);
-+ }
++ if (m_should_escape) {
++ qDebug(DEBCONF) << "DEBCONF escaped data detected, unescaping data";
++ line = unescape_data(line);
++ }
+
-+ if (args_scanned < c->num_args_min) {
-+ say(QLatin1String("20 Incorrect number of arguments"));
-+ return false;
-+ }
-+ } else {
-+ args.append(value);
-+ }
-+ (this->*(c->run))(args);
- return true;
- }
- ++ c;
- }
-+ say(QLatin1String("20 Unsupported command \"%1\" received").arg(command.toLower()));
- return false;
- }
+ const QString command = line.section(QLatin1Char(' '), 0, 0);
+ const QString value = line.section(QLatin1Char(' '), 1);
+@@ -604,7 +717,7 @@ DebconfFrontendFifo::DebconfFrontendFifo(int readfd, int writefd, QObject *paren
+ m_writef = new QFile(this);
+ m_writef->open(writefd, QIODevice::WriteOnly);
+ // QIODevice::readyReady() does not work with QFile
+- // http://bugreports.qt.nokia.com/browse/QTBUG-16089
++ // https://bugreports.qt.io/browse/QTBUG-16089
+ m_readnotifier = new QSocketNotifier(readfd, QSocketNotifier::Read, this);
+ connect(m_readnotifier, &QSocketNotifier::activated, this, &DebconfFrontendFifo::process);
+ }
diff --git a/src/debconf.h b/src/debconf.h
-index 71431f68547309487f4d17fa19cf78610d75178e..87a8e5278a8e6daf7135db3a9cc6da2ddbf6d1ce 100644
+index 5338ed16f8d2ff43c1909706878bcbca9f93f3ae..e251bbbc545f8d635321fd2c151b23bdb92150f3 100644
--- a/src/debconf.h
+++ b/src/debconf.h
-@@ -123,6 +123,8 @@ public:
- */
- virtual void cancel();
-
-+ inline QString getSideInfo() const { return m_side_info; }
-+
- Q_SIGNALS:
- void go(const QString &title, const QStringList &input);
- void progress(const QString ¶m);
-@@ -161,27 +163,32 @@ protected:
- virtual void reset();
-
- private:
-- void cmd_capb(const QString &caps);
-- void cmd_set(const QString ¶m);
-- void cmd_get(const QString ¶m);
-- void cmd_input(const QString ¶m);
-- void cmd_go(const QString &);
-- void cmd_title(const QString ¶m);
-- void cmd_data(const QString ¶m);
-- void cmd_subst(const QString ¶m);
-- void cmd_progress(const QString ¶m);
-- void cmd_x_ping(const QString ¶m);
-- void cmd_version(const QString ¶m);
-- void cmd_x_loadtemplatefile(const QString ¶m);
-- void cmd_info(const QString ¶m);
-- void cmd_fget(const QString ¶m);
-- void cmd_fset(const QString ¶m);
-- void cmd_beginblock(const QString ¶m);
-- void cmd_endblock(const QString ¶m);
-- void cmd_stop(const QString ¶m);
-+ void cmd_capb(const QStringList &args);
-+ void cmd_set(const QStringList &args);
-+ void cmd_get(const QStringList &args);
-+ void cmd_input(const QStringList &args);
-+ void cmd_go(const QStringList &);
-+ void cmd_title(const QStringList &args);
-+ void cmd_data(const QStringList &args);
-+ void cmd_subst(const QStringList &args);
-+ void cmd_progress(const QStringList &args);
-+ void cmd_x_ping(const QStringList &args);
-+ void cmd_version(const QStringList &args);
-+ void cmd_x_loadtemplatefile(const QStringList &args);
-+ void cmd_info(const QStringList &args);
-+ void cmd_fget(const QStringList &args);
-+ void cmd_fset(const QStringList &args);
-+ void cmd_beginblock(const QStringList &args);
-+ void cmd_endblock(const QStringList &args);
-+ void cmd_stop(const QStringList &args);
-+ void cmd_register(const QStringList &args);
-+ void cmd_unregister(const QStringList &args);
-+ void cmd_metaget(const QStringList &args);
-+ void cmd_exist(const QStringList &args);
+@@ -80,6 +80,7 @@ public:
+ Description,
+ ExtendedDescription,
+ Type,
++ Default,
+ UnknownPropertyKey = -1
+ } PropertyKey;
+
+@@ -190,6 +191,9 @@ private:
+ void cmd_unregister(const QStringList &args);
+ void cmd_metaget(const QStringList &args);
+ void cmd_exist(const QStringList &args);
++ void cmd_clear(const QStringList &args);
++ void cmd_reset(const QStringList &args);
++ void cmd_purge(const QStringList &args);
struct Cmd {
const char *cmd;
-- void (DebconfFrontend::*run)(const QString &);
-+ void (DebconfFrontend::*run)(const QStringList &);
-+ int num_args_min;
- };
- static const Cmd commands[];
-
-@@ -202,7 +209,9 @@ private:
- QHash<QString, QString> m_values;
- QHash<QString, Flags> m_flags;
- QString m_title;
-+ QString m_side_info;
+ void (DebconfFrontend::*run)(const QStringList &);
+@@ -218,6 +222,7 @@ private:
+ QString m_side_info;
QStringList m_input;
-+ bool m_making_block;
+ bool m_making_block;
++ bool m_should_escape;
};
/**
More information about the Neon-commits
mailing list