[haiku-commits] r37934 - in haiku/trunk: headers/private/libroot/time src/preferences/time

  • From: zooey@xxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 5 Aug 2010 23:46:05 +0200 (CEST)

Author: zooey
Date: 2010-08-05 23:46:05 +0200 (Thu, 05 Aug 2010)
New Revision: 37934
Changeset: http://dev.haiku-os.org/changeset/37934

Added:
   haiku/trunk/headers/private/libroot/time/localtime.h
Modified:
   haiku/trunk/src/preferences/time/Jamfile
   haiku/trunk/src/preferences/time/ZoneView.cpp
Log:
* the Time preflet now writes timezone info required by the POSIX layer into
  a specific file (/boot/common/settings/libroot_timezone_info)


Added: haiku/trunk/headers/private/libroot/time/localtime.h
===================================================================
--- haiku/trunk/headers/private/libroot/time/localtime.h                        
        (rev 0)
+++ haiku/trunk/headers/private/libroot/time/localtime.h        2010-08-05 
21:46:05 UTC (rev 37934)
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2010, Oliver Tappe, zooey@xxxxxxxxxxxxxxxx
+ * 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

Modified: haiku/trunk/src/preferences/time/Jamfile
===================================================================
--- haiku/trunk/src/preferences/time/Jamfile    2010-08-05 21:44:38 UTC (rev 
37933)
+++ haiku/trunk/src/preferences/time/Jamfile    2010-08-05 21:46:05 UTC (rev 
37934)
@@ -2,7 +2,7 @@
 
 SetSubDirSupportedPlatformsBeOSCompatible ;
 
-UsePrivateHeaders locale shared ;
+UsePrivateHeaders locale shared [ FDirName libroot time ] ;
 UsePrivateSystemHeaders ;
 
 local sources =

Modified: haiku/trunk/src/preferences/time/ZoneView.cpp
===================================================================
--- haiku/trunk/src/preferences/time/ZoneView.cpp       2010-08-05 21:44:38 UTC 
(rev 37933)
+++ haiku/trunk/src/preferences/time/ZoneView.cpp       2010-08-05 21:46:05 UTC 
(rev 37934)
@@ -22,11 +22,13 @@
 #include <Collator.h>
 #include <Directory.h>
 #include <Entry.h>
+#include <File.h>
 #include <FindDirectory.h>
 #include <ListItem.h>
 #include <Locale.h>
 #include <MutableLocaleRoster.h>
 #include <OutlineListView.h>
+#include <Path.h>
 #include <ScrollView.h>
 #include <StorageDefs.h>
 #include <String.h>
@@ -34,6 +36,7 @@
 #include <View.h>
 #include <Window.h>
 
+#include <localtime.h>
 #include <syscalls.h>
 
 #include <unicode/datefmt.h>
@@ -345,7 +348,8 @@
 {
        /*      Set sytem timezone for all different API levels. How to do this?
         *      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();
@@ -359,6 +363,27 @@
 
        _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);
        fLastUpdateMinute = -1;
                // just to trigger updating immediately


Other related posts: