Revert "setting_helpers: reduce dub code parts"

This reverts commit 34070f9c24 because zone was uninitialized while zoneinfo was initialized.


Origin commit data
------------------
Branch: ni/coolstream
Commit: 5e44b0a1a8
Author: vanhofen <vanhofen@gmx.de>
Date: 2023-05-01 (Mon, 01 May 2023)



------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2023-05-01 22:54:02 +02:00
parent 34070f9c24
commit 7e78f2196d

View File

@@ -64,7 +64,7 @@
#include <driver/display.h> #include <driver/display.h>
#include <driver/volume.h> #include <driver/volume.h>
#include <system/helpers.h> #include <system/helpers.h>
#include <system/debug.h>
#include <gui/widget/msgbox.h> #include <gui/widget/msgbox.h>
#include <gui/widget/hintbox.h> #include <gui/widget/hintbox.h>
@@ -619,7 +619,6 @@ bool CTZChangeNotifier::changeNotify(const neutrino_locale_t, void *Data)
bool found = false; bool found = false;
std::string name, zone; std::string name, zone;
printf("CTZChangeNotifier::changeNotify: %s\n", (char *) Data); printf("CTZChangeNotifier::changeNotify: %s\n", (char *) Data);
std::string zoneinfo = TARGET_PREFIX "/share/zoneinfo/" + zone;
xmlDocPtr parser = parseXmlFile("/etc/timezone.xml"); xmlDocPtr parser = parseXmlFile("/etc/timezone.xml");
if (parser != NULL) if (parser != NULL)
@@ -639,10 +638,8 @@ bool CTZChangeNotifier::changeNotify(const neutrino_locale_t, void *Data)
const char *zptr = xmlGetAttribute(search, "zone"); const char *zptr = xmlGetAttribute(search, "zone");
if (zptr) if (zptr)
zone = zptr; zone = zptr;
if (!access(zoneinfo.c_str(), R_OK)) if (!access(TARGET_PREFIX "/share/zoneinfo/" + zone, R_OK))
found = true; found = true;
else
dprintf(DEBUG_NORMAL, "[CTZChangeNotifier] [%s - %d] %s not found\n", __func__, __LINE__, zoneinfo.c_str());
break; break;
} }
} }
@@ -653,7 +650,7 @@ bool CTZChangeNotifier::changeNotify(const neutrino_locale_t, void *Data)
if (found) if (found)
{ {
printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str()); printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str());
std::string cmd = zoneinfo; std::string cmd = TARGET_PREFIX "/share/zoneinfo/" + zone;
printf("symlink %s to /etc/localtime\n", cmd.c_str()); printf("symlink %s to /etc/localtime\n", cmd.c_str());
if (unlink("/etc/localtime")) if (unlink("/etc/localtime"))
perror("unlink failed"); perror("unlink failed");