* the Time preflet now writes timezone info required by the POSIX layer into
a specific file (/boot/common/settings/libroot_timezone_info) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37934 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e4da3d6691
commit
85b54438f7
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef _LOCALTIME_H
|
||||||
|
#define _LOCALTIME_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
|
static const char* skPosixTimeZoneInfoFile = "libroot_timezone_info";
|
||||||
|
static const int skTimeZoneInfoNameMax = 32;
|
||||||
|
|
||||||
|
// holds persistent info set by Time preflet
|
||||||
|
struct time_zone_info {
|
||||||
|
char short_std_name[skTimeZoneInfoNameMax];
|
||||||
|
char short_dst_name[skTimeZoneInfoNameMax];
|
||||||
|
uint32 offset_from_gmt;
|
||||||
|
bool uses_daylight_saving;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _LOCALTIME_H
|
|
@ -2,7 +2,7 @@ SubDir HAIKU_TOP src preferences time ;
|
||||||
|
|
||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
UsePrivateHeaders locale shared ;
|
UsePrivateHeaders locale shared [ FDirName libroot time ] ;
|
||||||
UsePrivateSystemHeaders ;
|
UsePrivateSystemHeaders ;
|
||||||
|
|
||||||
local sources =
|
local sources =
|
||||||
|
|
|
@ -22,11 +22,13 @@
|
||||||
#include <Collator.h>
|
#include <Collator.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <ListItem.h>
|
#include <ListItem.h>
|
||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
#include <MutableLocaleRoster.h>
|
#include <MutableLocaleRoster.h>
|
||||||
#include <OutlineListView.h>
|
#include <OutlineListView.h>
|
||||||
|
#include <Path.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
#include <StorageDefs.h>
|
#include <StorageDefs.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
@ -34,6 +36,7 @@
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
#include <localtime.h>
|
||||||
#include <syscalls.h>
|
#include <syscalls.h>
|
||||||
|
|
||||||
#include <unicode/datefmt.h>
|
#include <unicode/datefmt.h>
|
||||||
|
@ -345,7 +348,8 @@ TimeZoneView::_SetSystemTimeZone()
|
||||||
{
|
{
|
||||||
/* Set sytem timezone for all different API levels. How to do this?
|
/* Set sytem timezone for all different API levels. How to do this?
|
||||||
* 1) tell locale-roster about new default timezone
|
* 1) tell locale-roster about new default timezone
|
||||||
* 2) write new POSIX-timezone file
|
* 2) tell kernel about new timezone offset
|
||||||
|
* 3) write new POSIX-timezone-info file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int32 selection = fZoneList->CurrentSelection();
|
int32 selection = fZoneList->CurrentSelection();
|
||||||
|
@ -359,6 +363,27 @@ TimeZoneView::_SetSystemTimeZone()
|
||||||
|
|
||||||
_kern_set_timezone(timeZone.OffsetFromGMT());
|
_kern_set_timezone(timeZone.OffsetFromGMT());
|
||||||
|
|
||||||
|
BPath path;
|
||||||
|
status_t status = find_directory(B_COMMON_SETTINGS_DIRECTORY, &path, true);
|
||||||
|
BFile file;
|
||||||
|
if (status == B_OK) {
|
||||||
|
path.Append(BPrivate::skPosixTimeZoneInfoFile);
|
||||||
|
status = file.SetTo(path.Path(),
|
||||||
|
B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
|
||||||
|
}
|
||||||
|
if (status == B_OK) {
|
||||||
|
BPrivate::time_zone_info tzInfo;
|
||||||
|
tzInfo.offset_from_gmt = timeZone.OffsetFromGMT();
|
||||||
|
tzInfo.uses_daylight_saving = timeZone.SupportsDaylightSaving();
|
||||||
|
strlcpy(tzInfo.short_std_name, timeZone.ShortName().String(),
|
||||||
|
BPrivate::skTimeZoneInfoNameMax);
|
||||||
|
strlcpy(tzInfo.short_dst_name,
|
||||||
|
timeZone.ShortDaylightSavingName().String(),
|
||||||
|
BPrivate::skTimeZoneInfoNameMax);
|
||||||
|
file.Write(&tzInfo, sizeof(tzInfo));
|
||||||
|
file.Sync();
|
||||||
|
}
|
||||||
|
|
||||||
fSetZone->SetEnabled(false);
|
fSetZone->SetEnabled(false);
|
||||||
fLastUpdateMinute = -1;
|
fLastUpdateMinute = -1;
|
||||||
// just to trigger updating immediately
|
// just to trigger updating immediately
|
||||||
|
|
Loading…
Reference in New Issue