summaryrefslogtreecommitdiffstats
path: root/xbmc/settings/lib/SettingUpdate.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/settings/lib/SettingUpdate.cpp
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/settings/lib/SettingUpdate.cpp')
-rw-r--r--xbmc/settings/lib/SettingUpdate.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/xbmc/settings/lib/SettingUpdate.cpp b/xbmc/settings/lib/SettingUpdate.cpp
new file mode 100644
index 0000000..0201aab
--- /dev/null
+++ b/xbmc/settings/lib/SettingUpdate.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2013-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "SettingUpdate.h"
+
+#include "ServiceBroker.h"
+#include "SettingDefinitions.h"
+#include "utils/StringUtils.h"
+#include "utils/XBMCTinyXML.h"
+#include "utils/log.h"
+
+Logger CSettingUpdate::s_logger;
+
+CSettingUpdate::CSettingUpdate()
+{
+ if (s_logger == nullptr)
+ s_logger = CServiceBroker::GetLogging().GetLogger("CSettingUpdate");
+}
+
+bool CSettingUpdate::Deserialize(const TiXmlNode *node)
+{
+ if (node == nullptr)
+ return false;
+
+ auto elem = node->ToElement();
+ if (elem == nullptr)
+ return false;
+
+ auto strType = elem->Attribute(SETTING_XML_ATTR_TYPE);
+ if (strType == nullptr || strlen(strType) <= 0 || !setType(strType))
+ {
+ s_logger->warn("missing or unknown update type definition");
+ return false;
+ }
+
+ if (m_type == SettingUpdateType::Rename)
+ {
+ if (node->FirstChild() == nullptr || node->FirstChild()->Type() != TiXmlNode::TINYXML_TEXT)
+ {
+ s_logger->warn("missing or invalid setting id for rename update definition");
+ return false;
+ }
+
+ m_value = node->FirstChild()->ValueStr();
+ }
+
+ return true;
+}
+
+bool CSettingUpdate::setType(const std::string &type)
+{
+ if (StringUtils::EqualsNoCase(type, "change"))
+ m_type = SettingUpdateType::Change;
+ else if (StringUtils::EqualsNoCase(type, "rename"))
+ m_type = SettingUpdateType::Rename;
+ else
+ return false;
+
+ return true;
+}