mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +02:00
neutrino: improve timezone handling
* only offer timezones which are actually installed in the system
* symlink the timezone file to /etc/localtime instead of copying
Origin commit data
------------------
Branch: ni/coolstream
Commit: f130d20b64
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2012-03-29 (Thu, 29 Mar 2012)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -128,11 +128,16 @@ CMenuOptionStringChooser* COsdLangSetup::getTzItems()
|
|||||||
if (!strcmp(xmlGetName(search), "zone"))
|
if (!strcmp(xmlGetName(search), "zone"))
|
||||||
{
|
{
|
||||||
std::string name = xmlGetAttribute(search, "name");
|
std::string name = xmlGetAttribute(search, "name");
|
||||||
// std::string zone = xmlGetAttribute(search, "zone");
|
std::string zone = xmlGetAttribute(search, "zone");
|
||||||
//printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str());
|
//printf("Timezone: %s -> %s\n", name.c_str(), zone.c_str());
|
||||||
|
if (access(("/usr/share/zoneinfo/" + zone).c_str(), R_OK))
|
||||||
|
printf("[neutrino] timezone file '%s' not installed\n", zone.c_str());
|
||||||
|
else
|
||||||
|
{
|
||||||
tzSelect->addOption(name.c_str());
|
tzSelect->addOption(name.c_str());
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
search = search->xmlNextNode;
|
search = search->xmlNextNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -875,6 +875,7 @@ bool CTZChangeNotifier::changeNotify(const neutrino_locale_t, void * Data)
|
|||||||
name = xmlGetAttribute(search, "name");
|
name = xmlGetAttribute(search, "name");
|
||||||
if(!strcmp(g_settings.timezone, name.c_str())) {
|
if(!strcmp(g_settings.timezone, name.c_str())) {
|
||||||
zone = xmlGetAttribute(search, "zone");
|
zone = xmlGetAttribute(search, "zone");
|
||||||
|
if (!access(("/usr/share/zoneinfo/" + zone).c_str(), R_OK))
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -885,9 +886,12 @@ 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 = "cp /usr/share/zoneinfo/" + zone + " /etc/localtime";
|
std::string cmd = "/usr/share/zoneinfo/" + zone;
|
||||||
printf("exec %s\n", cmd.c_str());
|
printf("symlink %s to /etc/localtime\n", cmd.c_str());
|
||||||
system(cmd.c_str());
|
if (unlink("/etc/localtime"))
|
||||||
|
perror("unlink failed");
|
||||||
|
if (symlink(cmd.c_str(), "/etc/localtime"))
|
||||||
|
perror("symlink failed");
|
||||||
cmd = ":" + zone;
|
cmd = ":" + zone;
|
||||||
setenv("TZ", cmd.c_str(), 1);
|
setenv("TZ", cmd.c_str(), 1);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user