Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37490585
en ru br
ALT Linux repositórios
S:4.8.1-alt1
5.0: 2.1-alt2
4.1: 0.8-alt3.M41.6
4.0: 0.3-alt1.M40.3

Group :: Sistema/Configurações/Rede
RPM: alterator-datetime

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

alterator-datetime-2.5/000075500000000000000000000000001212310616000151355ustar00rootroot00000000000000alterator-datetime-2.5/Makefile000064400000000000000000000006121212310616000165740ustar00rootroot00000000000000NAME=datetime

all:
clean:
install: install-module install-data install-bin

include /usr/share/alterator/build/module.mak

install-data:
install -d $(datadir)/install2
cp -a postinstall.d $(datadir)/install2
install -d $(sysconfdir)/alterator/datetime/
cp -a etc/* $(sysconfdir)/alterator/datetime/

install-bin:
for i in bin/*; do \
install -Dpm755 $$i $(bindir)/$${i##*/}; \
done
alterator-datetime-2.5/applications/000075500000000000000000000000001212310616000176235ustar00rootroot00000000000000alterator-datetime-2.5/applications/datetime.desktop000064400000000000000000000004161212310616000230130ustar00rootroot00000000000000[Desktop Entry]
Type=Application
Categories=X-Alterator-System
Icon=datetime
Terminal=false
Name=Date/Time
X-Alterator-URI=/datetime/system
X-Alterator-Weight=20
X-Alterator-Help=datetime
Name[ru]=Дата и время
Name[uk]=Дата й час
Name[pt_BR]=Data/Hora
alterator-datetime-2.5/backend3/000075500000000000000000000000001212310616000166075ustar00rootroot00000000000000alterator-datetime-2.5/backend3/datetime-installer000075500000000000000000000060531212310616000223300ustar00rootroot00000000000000#!/bin/sh

alterator_api_version=1
po_domain="alterator-datetime"

alteratordhcp_file=/var/lib/alterator/alterator-dhcp-general

. alterator-datetime-functions

read_ctime()
{
local domain="${2:-$po_domain}"
local langlist="$(write_language "$in_language")"
local firstlang="${langlist%%:*}"
local flags=

if test_ntp_status; then
_ "set automatically"
return
fi

if test_bool "$1"; then
flags='--utc'
else
flags='--localtime'
fi

(export LC_ALL="$firstlang"; export LANGUAGE="$langlist"; export TZ="$2"; /sbin/hwclock $flags --show|
sed 's/[[:space:]]\+[0-9.-]\+[[:space:]]\+[[:alpha:]]\+$//')
}

# Try to load rpc module
[ -c /dev/rtc ] || modprobe rtc

on_message()
{
case "$in_action" in
type)
write_type_item ntp_pool hostname
write_type_item date date
write_type_item time time
;;
list)

case "$in__objects" in
avail_country)
list_country
;;
avail_zone)
local country="$in_name"
[ -n "$country" -a -z "$in_reset" ] || country="$(read_country $(read_zone))"
list_zone "$country" ;;
esac
;;
ctime)
write_string_param ctime "$(read_ctime "$in_utc" "$in_zone")"
;;
read)
case "$in__objects" in
/)
## timezone
local country="$in_name"
local zone="$in_zone"

local default_zone="$(read_zone)"
local default_country="$(read_country "$default_zone")"

if [ -z "$country" -o -n "$in_reset" ];then
zone="$default_zone"
country="$default_country"
elif [ "$country" = "$default_country" ];then
zone="$default_zone"
fi

write_string_param zone "$zone"
write_string_param name "$country"

## datetime
local utc="$(read_utc)"
write_bool_param utc "$utc"
write_string_param ctime "$(read_ctime "$(write_bool $utc)" "$zone")" #"
;;
edit)
#date&time
write_string_param 'date' "$(date +%F)"
write_string_param 'time' "$(date +%T)"

#ntp
write_string_param ntp_pool "$(read_pool)"

! [ "$(/usr/sbin/control ntpd)" = "server" ]
write_bool_param ntp_accept "$?"

! test_ntp_status
write_bool_param ntp_status "$?"
;;
esac
;;
write)
case "$in__objects" in
/)
write_utc "$in_utc"

if [ -n "$in_zone" ] && ! write_zone "$in_zone"; then
write_error "`_ "Unable to setup time zone"`"
return
fi

/sbin/service clock start >&2
;;
edit)
write_ntp_status "$in_ntp_status"

#ntp vs date&time
if test_bool "$in_ntp_status";then
write_pool "$in_ntp_pool"
write_ntp_accept "$in_ntp_accept"
else
if [ -n "$in_date" -a -n "$in_time" ] &&
! date --set="$in_date $in_time" 2>/dev/null >/dev/null; then
write_error "`_ "unable to setup time"`"
return
fi
fi

## alterator-dhcp
if test_bool "$in_ntp_status" && test_bool "$in_ntp_accept";then
shell_config_set "$alteratordhcp_file" client_ntp "*"
else
shell_config_del "$alteratordhcp_file" client_ntp
fi

/sbin/service clock sync >&2
;;
esac


;;
esac
}

message_loop
alterator-datetime-2.5/backend3/datetime-system000075500000000000000000000057571212310616000216710ustar00rootroot00000000000000#!/bin/sh

alterator_api_version=1
po_domain="alterator-datetime"

alteratordhcp_file=/etc/alterator/dhcp/general
alteratordhcp_cmd=/usr/bin/alterator-dhcp-reset

. alterator-datetime-functions

### timezone

on_message()
{
case "$in_action" in
type)
write_type_item ntp_pool hostname
write_type_item date date
write_type_item time time
;;
list)
case "$in__objects" in
avail_country)
list_country
;;
avail_zone)
local country="$in_name"
[ -n "$country" ] || country="$(read_country $(read_zone))"
list_zone "$country"
;;
esac
;;
read)
case "$in__objects" in
/)
## date&time
write_string_param 'date' "$(date +%F)"
write_string_param 'time' "$(date +%T)"
write_string_param 'date_string' "$(run_localized date)"

## ntp
write_string_param ntp_pool "$(read_pool)"

! test_ntp_accept
write_bool_param ntp_accept "$?"

! test_ntp_status
write_bool_param ntp_status "$?"

write_bool_param utc "$(read_utc)"

## timezone
# We need the real zone from config file here,
# not the guess according to current language.
# So call read_zone with empty in_language variable.
local zone="$(in_language= read_zone)"
local tr_zone="$(translate_zone "$zone")"
local country="$(read_country "$zone")"
local tr_country="$(country_name "$country")"

write_string_param timezone "$tr_country/${tr_zone#*/}"
;;
timezone)
local country="$in_name"
local zone="$in_zone"

local default_zone="$(read_zone)"
local default_country="$(read_country "$default_zone")"

if [ -z "$country" ];then
zone="$default_zone"
country="$default_country"
elif [ "$country" = "$default_country" ];then
zone="$default_zone"
fi

write_string_param zone "$zone"
write_string_param name "$country"
;;
esac
;;
write)
case "$in__objects" in
/)

write_utc "$in_utc"
write_ntp_status "$in_ntp_status"

# ntp vs. date&time
if test_bool "$in_ntp_status";then
write_pool "$in_ntp_pool"
write_ntp_accept "$in_ntp_accept"
else
if [ -n "$in_date" -a -n "$in_time" ] &&
! date --set="$in_date $in_time" 2>/dev/null >/dev/null; then
write_error "`_ "unable to setup time"`"
return
fi
fi

## alterator-dhcp
if [ -f "$alteratordhcp_file" -a -x "$alteratordhcp_cmd" ]; then
if test_bool "$in_ntp_status" && test_bool "$in_ntp_accept";then
shell_config_set "$alteratordhcp_file" client_ntp "*"
else
shell_config_del "$alteratordhcp_file" client_ntp
fi
"$alteratordhcp_cmd"
service_control dhcpd condreload
fi
;;
timezone)
if [ -n "$in_zone" ] && ! write_zone "$in_zone"; then
write_error "`_ "Unable to setup time zone"`"
return
fi
;;
esac

/etc/init.d/clock sync >/dev/null 2>/dev/null
;;
esac
}

message_loop
alterator-datetime-2.5/bin/000075500000000000000000000000001212310616000157055ustar00rootroot00000000000000alterator-datetime-2.5/bin/alterator-datetime-functions000064400000000000000000000066741212310616000234420ustar00rootroot00000000000000#!/bin/sh

openntpd_file=/etc/ntpd.conf
ntp_file=/etc/ntp.conf

sysconfigclock_file=/etc/sysconfig/clock
zonetab_file=/usr/share/zoneinfo/zone.tab
zoneinfo_dir=/usr/share/zoneinfo

. alterator-sh-functions
. alterator-service-functions
. shell-config

### ntp

ntpd_rdelim='[[:space:]]\+'
ntpd_wdelim=' '

read_pool()
{
if [ -f "$openntpd_file" ];then
shell_config_get "$openntpd_file" "servers" "$ntpd_rdelim"|head -n1
elif [ -f "$ntp_file" ];then
local v="$(shell_config_get "$ntp_file" "server" "$ntpd_rdelim"|head -n1)"
v="${v%% *}"
[ "$v" = "127.127.1.0" ] || echo "$v"
fi
}

write_pool()
{
if [ -f "$openntpd_file" ];then
shell_config_del "$openntpd_file" "server" "$ntpd_rdelim"
shell_config_del "$openntpd_file" "servers" "$ntpd_rdelim"
[ -z "$1" ] || shell_config_set "$openntpd_file" "servers" "$1" "$ntpd_rdelim" "$ntpd_wdelim"
elif [ -f "$ntp_file" ];then
cat>"$ntp_file"<<EOF
#generated by alterator-datetime

driftfile /etc/ntp/drift

$([ -z "$1" ] || printf "server %s iburst burst prefer\n" "$1")
server 127.127.1.0 iburst
fudge 127.127.1.0 stratum 10

restrict default noquery nomodify
restrict 127.0.0.1
EOF
fi
service_control ntpd condrestart
}

test_ntp_status()
{
service_control ntpd is-enabled
}

write_ntp_status()
{
if test_bool "$1"; then
service_control ntpd on
service_control ntpd start
else
service_control ntpd off
service_control ntpd condstop
fi
}

test_ntp_accept()
{
local result=
if result="$(/usr/sbin/control ntpd 2>/dev/null)";then
[ "$result" = "server" ]
else
true
fi
}

write_ntp_accept()
{
if /usr/sbin/control ntpd >/dev/null 2>/dev/null;then
if test_bool "$1";then
/usr/sbin/control ntpd server >/dev/null 2>/dev/null
else
/usr/sbin/control ntpd client >/dev/null 2>/dev/null
fi
else
true
fi
}

### timezone

cat_isotab_file()
{
local domain="${2:-$po_domain}"
local langlist="$(write_language "$in_language")"
local firstlang="${langlist%%:*}"

LC_ALL="$firstlang" LANGUAGE="$langlist" dumpisotab 2>/dev/null|
LC_ALL="$firstlang" LANGUAGE="$langlist" sort -k2,2 2>/dev/null
}


read_zone()
{
local ZONE=
local language="${in_language%%;*}"

. "$sysconfigclock_file"

if [ -z "$ZONE" ]; then
local region="$(printf %s "$language" |
sed -r -e 's,[a-z]+_([^\.]+)(\..*)?,\1,' |
tr '[:lower:]' '[:upper:]')"

[ -z "$region" ] ||
ZONE="$(grep "^$region[[:space:]]" "/etc/alterator/datetime/defaultzones" |cut -f2)"

[ -n "$ZONE" ] ||
ZONE="Europe/London"
fi

printf %s\\n "$ZONE"
}

write_zone()
{
[ -f "$zoneinfo_dir/$1" ] || return 1

shell_config_set "$sysconfigclock_file" "ZONE" "$in_zone"
rm -f /etc/localtime && cp -pf -- "$zoneinfo_dir/$in_zone" /etc/localtime
}

read_country()
{
cut -f1,3 "$zonetab_file" |grep "[[:space:]]$1" |cut -f1
}

translate_zone()
{
_ "$1" alterator-tzone-tz|tr '_' ' '
}

country_name()
{
cat_isotab_file|sed -n "s/^$1[[:space:]]\+//p"
}

list_zone() {
local IFS=" "
local code coordinates zone comments

grep "^$1[[:space:]]" "$zonetab_file" |
while read code coordinates zone comments; do
tr_zone="$(translate_zone "$zone")"
write_enum_item "$zone" "${tr_zone#*/}"
done
}

list_country() {
cat_isotab_file|write_enum
}

### utc

read_utc()
{
shell_config_get "$sysconfigclock_file" UTC
}

write_utc()
{
if test_bool "$1";then
shell_config_set "$sysconfigclock_file" UTC "true"
else
shell_config_set "$sysconfigclock_file" UTC "false"
fi
}
alterator-datetime-2.5/bin/dumpisotab000075500000000000000000000010631212310616000200020ustar00rootroot00000000000000#!/usr/bin/guile -s
!#

(use-modules (ice-9 rdelim))

(define (comment? line)
(or (string-null? line)
(char=? #\# (string-ref line 0))))

(define (out line)
(let ((idx (string-index line #\ht)))
(format #t "~A\t~A~%" (substring line 0 idx) (gettext (substring line (+ 1 idx)) "alterator-tzone-co"))))

(setlocale LC_ALL "")

(with-input-from-file
"/usr/share/zoneinfo/iso3166.tab"
(lambda()
(let loop ((line (read-line)))
(or (eof-object? line)
(begin (or (comment? line) (out line))
(loop (read-line)))))))
alterator-datetime-2.5/etc/000075500000000000000000000000001212310616000157105ustar00rootroot00000000000000alterator-datetime-2.5/etc/defaultzones000064400000000000000000000003301212310616000203320ustar00rootroot00000000000000POSIX Europe/London
BY Europe/Minsk
GB Europe/London
RU Europe/Moscow
UA Europe/Kiev
US America/New_York
ES Europe/Madrid
BR America/Sao_Paulo
AR America/Argentina/Buenos_Aires
CL America/Santiago
VE America/Caracas
alterator-datetime-2.5/postinstall.d/000075500000000000000000000000001212310616000177335ustar00rootroot00000000000000alterator-datetime-2.5/postinstall.d/20-datetime.sh000075500000000000000000000031461212310616000223110ustar00rootroot00000000000000#!/bin/sh -efu
# ***** BEGIN LICENSE BLOCK *****
# * Copyright (C) 2007 Alexey Gladkov <legion@altlinux.org>
# *
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 2 of the License, or
# * (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# * GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License
# * along with this program; if not, write to the Free Software
# * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
# ***** END LICENSE BLOCK *****

. install2-init-functions
. shell-config

copy_ntpd_conf()
{
[ -f "$1" ] || return 0

cp "$1" "$destdir/etc/"
# Remove all dynamically added entries
sed -i '/^# Generated by/,/^# End of/d' "$destdir/$1"
}

[ ! -f '/etc/localtime' ] ||
cp -af '/etc/localtime' "$destdir/etc/"

[ ! -f '/etc/sysconfig/clock' ] ||
cp -af '/etc/sysconfig/clock' "$destdir/etc/sysconfig/"

copy_ntpd_conf /etc/ntpd.conf
copy_ntpd_conf /etc/ntp.conf

! chkconfig --list ntpd |grep -qs '[0-9]:on' || run_chroot chkconfig ntpd on || :

if [ -d "$destdir/etc/alterator/dhcp" ]; then
client_ntp="$(shell_config_get /var/lib/alterator/alterator-dhcp-general client_ntp)"
[ -z "$client_ntp" ] ||
shell_config_set "$destdir/etc/alterator/dhcp/general" client_ntp "$client_ntp"
fi
alterator-datetime-2.5/ui/000075500000000000000000000000001212310616000155525ustar00rootroot00000000000000alterator-datetime-2.5/ui/datetime/000075500000000000000000000000001212310616000173465ustar00rootroot00000000000000alterator-datetime-2.5/ui/datetime/installer/000075500000000000000000000000001212310616000213435ustar00rootroot00000000000000alterator-datetime-2.5/ui/datetime/installer/edit/000075500000000000000000000000001212310616000222705ustar00rootroot00000000000000alterator-datetime-2.5/ui/datetime/installer/edit/index.scm000064400000000000000000000030071212310616000241030ustar00rootroot00000000000000(document:surround "/std/frame")

(define (ui-commit)
(catch/message
(lambda()
(apply woo-write "/datetime-installer/edit" (form-value-list)))))

(define (ok)
(and (ui-commit) (document:end)))

(define (cancel)
(document:end))

width "550"
height "420"

(gridbox columns "50;50"
margin 20
(gridbox
columns "50;50"
colspan 2
align "left"
(checkbox text (_ "Get time from NTP server:") name "ntp_status")
(hbox (label name "ntp_pool" text (_ "NTP server:") visibility #f)
(edit name "ntp_pool")))

(checkbox text (_ "Work as NTP server") widget-name "ntp_accept" name "ntp_accept")
(spacer)

(separator colspan 2)

(label text (_ "Current date:") align "center" name "date")
(label text (_ "Current time:") align "center" name "time")

(dateedit expanded #t name "date")
(timeedit expanded #t name "time")

(label colspan 2)

(hbox
align "left"
(button name "ok" text (_ "OK"))
(button name "cancel" text (_ "Cancel")))
(spacer))

(effect-disable "ntp_pool" "ntp_status" #f)
(effect-disable "ntp_accept" "ntp_status" #f)
(effect-disable "date" "ntp_status" #t)
(effect-disable "time" "ntp_status" #t)

(document:root
(when loaded
(catch/message
(lambda()
(form-update-value-list '("date" "time" "ntp_status" "ntp_pool" "ntp_accept")
(woo-read-first "/datetime-installer/edit"))
(form-bind "ok" "click" ok)
(form-bind "cancel" "click" cancel)
(init-effect)))))
alterator-datetime-2.5/ui/datetime/installer/index.scm000064400000000000000000000042771212310616000231700ustar00rootroot00000000000000(document:surround "/std/frame")

;;; Logic (qt and html)

(define (default-zone cmd cmdlist)
(let ((zone (woo-get-option cmd 'zone)))
(if (and (string-null? zone) (pair? cmdlist))
(woo-get-option (car cmdlist) 'name)
zone)))

(define (update-ctime-value utc zone)
(form-update-value-list '("ctime") (woo-first-command (woo "ctime" "/datetime-installer" 'utc utc 'zone zone))))

(define (update-zonelist)
(let* ((name (form-value "name"))
(zone-list (woo-list "/datetime-installer/avail_zone"
'name name))
(zone (default-zone (woo-read-first "/datetime-installer" 'name name) zone-list)))
(form-update-enum "zone" zone-list)
(form-update-value "zone" zone)
(update-ctime-value (form-value "utc") zone)))

(define (update-ctime)
(update-ctime-value (form-value "utc") (form-value "zone")))

;;; Logic (qt specific)

;;TODO: optimize it
(define (ui-init)
(catch/message
(lambda()
(form-update-enum "name" (woo-list "/datetime-installer/avail_country"))
(form-update-enum "zone" (woo-list "/datetime-installer/avail_zone"))
(form-update-value-list '("name" "zone" "utc" "ctime") (woo-read-first "/datetime-installer")))))

(define (ui-commit)
(catch/message
(lambda()
(apply woo-write "/datetime-installer" (cons* 'commit #t (form-value-list))))))

(define (ui-edit)
(ui-commit)
(form-popup "/datetime/installer/edit")
(update-ctime))

(define (form-init)
(ui-init)
(form-bind "name" "change" update-zonelist)
(form-bind "zone" "change" update-ctime)
(form-bind "utc" "change" update-ctime)
(form-bind "edit" "click" ui-edit))

;;; UI

(gridbox
margin 50

(label name "name" text (_ "Please, select country:") align "left")
(combobox name "name")
(label)

(label name "zone" text (_ "Please, select time zone:") align "left")
(listbox name "zone")
(checkbox name "utc" text (_ "Hardware time set to GMT"))
(label)

(hbox
align "left"
(label text (_ "Current time:"))
(label name "ctime")
(button name "edit" text (_ "Change...")))

(label))

;;; initialization

(document:root (when loaded (form-init)))

(frame:on-next (thunk (or (ui-commit) 'cancel)))
(frame:on-back (thunk (or (ui-commit) 'cancel)))

alterator-datetime-2.5/ui/datetime/system/000075500000000000000000000000001212310616000206725ustar00rootroot00000000000000alterator-datetime-2.5/ui/datetime/system/ajax.scm000064400000000000000000000023211212310616000223170ustar00rootroot00000000000000(define-module (ui datetime system ajax)
:use-module (alterator ajax)
:use-module (alterator woo)
:use-module (alterator effect)
:export (init))

(define (ui-timezone)
(form-replace "/datetime/system/timezone"))

(define (ui-timeedit)
(catch/message
(lambda()
(form-update-value-list
'("time")
(woo-read-first "/datetime-system")))))

(define (ui-write)
(catch/message
(lambda()
(apply woo-write "/datetime-system"
'language (form-value "language")
(form-value-list))
(ui-read))))

(define (ui-read)
(catch/message
(lambda()
(form-update-value-list
'("date" "time" "ntp_status" "ntp_pool" "ntp_accept" "utc" "timezone")
(woo-read-first "/datetime-system" 'language (form-value "language")))
(update-effect))))

(define (init)
;; effects
(effect-disable "ntp_pool" "ntp_status" #f)
(effect-disable "ntp_accept" "ntp_status" #f)
(effect-disable "date" "ntp_status" #t)
(effect-disable "time" "ntp_status" #t)
(init-effect)
;; form
(ui-read)
;; events
(form-bind "apply" "click" ui-write)
(form-bind "reset" "click" ui-read)
(form-bind "change-zone" "click" ui-timezone)
(form-bind-timeedit "time" ui-timeedit))
alterator-datetime-2.5/ui/datetime/system/index.html000064400000000000000000000034221212310616000226700ustar00rootroot00000000000000<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<!-- date/time module -->
<html wf="none">
<body>
<form method="POST">
<table>
<tr>
<td colspan="2">
<input type="checkbox" name="ntp_status" value="#t"/>
<span name="ntp_status" translate="_">Get time from NTP server:</span>
<span name="ntp_pool" style="display:none" translate="_">NTP server:</span>
<input type="text" class="text" name="ntp_pool"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="checkbox" name="ntp_accept" value="#t"/>
<span name="ntp_accept" translate="_">Work as NTP server</span>
</td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td align="center"><span translate="_" name="date">Current date:</span></td>
<td align="center"><span translate="_" name="time">Current time:</span></td>
</tr>
<tr>
<td align="center" valign="bottom">
<input type="text" class="text alterator-dateedit" name="date"/>
</td>
<td align="center" valign="bottom">
<input type="text" class="text alterator-timeedit" name="time"/>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">
<input type="checkbox" name="utc" value="#t"/>
<span translate="_">Hardware time set to GMT</span>
</td>
</tr>
<tr>
<td colspan="2">
<span translate="_">Time zone:</span>
&nbsp;
<span class="alterator-label" name="timezone"/>
&nbsp;
<input type="button" class="btn" name="change-zone" value="Change..."/>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>
<input type="button" class="btn" name="apply" value="Apply"/>
<input type="button" class="btn" name="reset" value="Reset"/>
</td>
</tr>
</table>
</form>
</body>
</html>
alterator-datetime-2.5/ui/datetime/system/index.scm000064400000000000000000000035051212310616000225100ustar00rootroot00000000000000(document:surround "/std/frame")

(define (ui-write)
(catch/message
(lambda()
(apply woo-write "/datetime-system" (form-value-list))
(ui-read))))

(define (ui-read)
(form-update-value-list '("date" "time" "ntp_status" "ntp_pool" "ntp_accept" "utc" "timezone")
(woo-read-first "/datetime-system")))

(define (ui-timezone)
(form-popup "/datetime/system/timezone")
(ui-read))

(gridbox columns "50;50"
margin 20
(gridbox
columns "50;50"
colspan 2
align "left"
(checkbox text (_ "Get time from NTP server:") name "ntp_status")
(hbox (label name "ntp_pool" text (_ "NTP server:") visibility #f)
(edit name "ntp_pool")))

(checkbox text (_ "Work as NTP server") widget-name "ntp_accept" name "ntp_accept")
(spacer)

(separator colspan 2)

(label text (_ "Current date:") align "center" name "date")
(label text (_ "Current time:") align "center" name "time")

(dateedit expanded #t name "date")
(timeedit expanded #t name "time")

(label colspan 2)

(checkbox name "utc" text (_ "Hardware time set to GMT"))
(spacer)

(hbox
align "left"
(label text (_ "Time zone:"))
(label text " ")
(label name "timezone")
(label text " ")
(button name "change-zone" text (_ "Change...")))
(spacer)

(label colspan 2)

(button name "apply" text (_ "Apply") align "left")
(spacer))

(effect-disable "ntp_pool" "ntp_status" #f)
(effect-disable "ntp_accept" "ntp_status" #f)
(effect-disable "date" "ntp_status" #t)
(effect-disable "time" "ntp_status" #t)

(document:root
(when loaded
(ui-read)
(form-bind "apply" "click" ui-write)
(form-bind "change-zone" "click" ui-timezone)
(init-effect)))
alterator-datetime-2.5/ui/datetime/system/timezone/000075500000000000000000000000001212310616000225245ustar00rootroot00000000000000alterator-datetime-2.5/ui/datetime/system/timezone/ajax.scm000064400000000000000000000026171212310616000241610ustar00rootroot00000000000000(define-module (ui datetime system timezone ajax)
:use-module (alterator ajax)
:use-module (alterator woo)
:export (init))

(define (default-zone cmd cmdlist)
(let ((zone (woo-get-option cmd 'zone)))
(if (and (string-null? zone) (pair? cmdlist))
(woo-get-option (car cmdlist) 'name)
zone)))

(define (update-zonelist)
(let* ((name (form-value "name"))
(zone-list (woo-list "/datetime-system/avail_zone"
'name name
'language (form-value "language"))))
(form-update-enum "zone" zone-list)
(form-update-value "zone" (default-zone (woo-read-first "/datetime-system/timezone" 'name name)
zone-list))))

(define (ui-read)
(form-update-enum "name"
(woo-list "/datetime-system/avail_country" 'language (form-value "language")))
(form-update-enum "zone"
(woo-list "/datetime-system/avail_zone" 'language (form-value "language")))
(form-update-value-list
'("name" "zone")
(woo-read-first "/datetime-system/timezone" 'language (form-value "language"))))

(define (ui-write)
(catch/message
(lambda()
(apply woo-write "/datetime-system/timezone"
'language (form-value "language")
(form-value-list)))))

(define (ui-return)
(form-replace "/datetime/system"))

(define (init)
(ui-read)
(form-bind "name" "change" update-zonelist)
(form-bind "ok" "click" (lambda() (and (ui-write) (ui-return)))))
alterator-datetime-2.5/ui/datetime/system/timezone/index.html000064400000000000000000000010631212310616000245210ustar00rootroot00000000000000<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<!-- time zones module -->
<html wf="none">
<body>
<form method="POST" id="ajax-select">
<span translate="_">Please, select country:</span>
<br/>
<select name="name"/>
<br/>
<span translate="_">Please, select time zone:</span>
<br/>
<select class="zone-list" size="15" name="zone" style="width:50%"/>
<br/>
<br/>
<input type="button" class="btn" name="ok" value="Apply"/>
</form>
</body>
</html>
alterator-datetime-2.5/ui/datetime/system/timezone/index.scm000064400000000000000000000033341212310616000243420ustar00rootroot00000000000000(document:surround "/std/frame")

;;; Logic

(define (default-zone cmd cmdlist)
(let ((zone (woo-get-option cmd 'zone)))
(if (and (string-null? zone) (pair? cmdlist))
(woo-get-option (car cmdlist) 'name)
zone)))

(define (update-zonelist)
(let* ((name (form-value "name"))
(zone-list (woo-list "/datetime-system/avail_zone" 'name name)))
(form-update-enum "zone" zone-list)
(form-update-value "zone" (default-zone (woo-read-first "/datetime-system/timezone" 'name name)
zone-list))))

(define (ui-read)
(form-update-enum "name"
(woo-list "/datetime-system/avail_country" 'language (form-value "language")))
(form-update-enum "zone"
(woo-list "/datetime-system/avail_zone" 'language (form-value "language")))
(form-update-value-list
'("name" "zone")
(woo-read-first "/datetime-system/timezone" 'language (form-value "language"))))

(define (ui-write)
(catch/message
(lambda()
(apply woo-write "/datetime-system/timezone"
'language (form-value "language")
(form-value-list)))))

(define (ui-return)
(document:end))

(define (ui-init)
(ui-read)
(form-bind "name" "change" update-zonelist)
(form-bind "ok" "click" (lambda() (and (ui-write) (ui-return))))
(form-bind "cancel" "click" ui-return))

;;; UI

(gridbox
margin "50"

;;
(label name "name" text (_ "Please, select country:") align "left")
(combobox name "name")
(label)

;;
(label text (_ "Please, select time zone:") align "left")
(listbox name "zone")
(label)

;;
(if (global 'frame:next-button)
(label)
(hbox align "left"
(button name "ok" text (_ "OK"))
(button name "cancel" text (_ "Cancel")))))

;;; initialization

(document:root (when loaded (ui-init)))
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009