Author: jsuchome Date: Fri Jul 27 11:02:00 2007 New Revision: 39733 URL: http://svn.opensuse.org/viewcvs/yast?rev=39733&view=rev Log: - timezone dialog offers synchronization with NTP (F302192) - "installation source" changed to "repository" - 2.15.13 Modified: trunk/country/VERSION trunk/country/package/yast2-country.changes trunk/country/timezone/src/dialogs.ycp Modified: trunk/country/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/country/VERSION?rev=39733&r1=39732&r2=39733&view=diff ============================================================================== --- trunk/country/VERSION (original) +++ trunk/country/VERSION Fri Jul 27 11:02:00 2007 @@ -1 +1 @@ -2.15.12 +2.15.13 Modified: trunk/country/package/yast2-country.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/country/package/yast2-country.changes?rev=39733&r1=39732&r2=39733&view=diff ============================================================================== --- trunk/country/package/yast2-country.changes (original) +++ trunk/country/package/yast2-country.changes Fri Jul 27 11:02:00 2007 @@ -1,4 +1,15 @@ ------------------------------------------------------------------- +Fri Jul 27 10:10:58 CEST 2007 - jsuchome@suse.cz + +- timezone dialog offers synchronization with NTP (F302192) +- 2.15.13 + +------------------------------------------------------------------- +Thu Jul 19 13:59:15 CEST 2007 - jsuchome@suse.cz + +- "installation source" changed to "repository" + +------------------------------------------------------------------- Mon Jul 9 09:01:23 CEST 2007 - jsuchome@suse.cz - added support for Sinhala language (si_LK) Modified: trunk/country/timezone/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/country/timezone/src/dialogs.ycp?rev=39733&r1=39732&r2=39733&view=diff ============================================================================== --- trunk/country/timezone/src/dialogs.ycp (original) +++ trunk/country/timezone/src/dialogs.ycp Fri Jul 27 11:02:00 2007 @@ -20,7 +20,9 @@ import "Label"; import "Language"; import "Mode"; + import "Package"; import "Popup"; + import "Service"; import "Stage"; import "Timezone"; import "Wizard"; @@ -55,10 +57,11 @@ */ define boolean SetTimeDialog() { - // help text - string htext = _("<p>The current system time and date are displayed. Change them to the correct values and press -<b>Apply</b>.</p> -"); + // help text for set time dialog + string htext = _("<p>The current system time and date are displayed. Change them to the correct values manually or select a NTP server to adapt your time automatically. Use <b>Configure</b> to run NTP client configuration.</p>") + + + // help text, cont. + _("<p>Changes are written after pressing <b>Accept</b>. Synchronization with NTP server can be done only when the network is configured.</p>"); map val = Timezone::GetDateTimeMap(); @@ -118,35 +121,92 @@ ); dt_widgets = true; } + list ntp_items = []; + boolean ntp_used = Service::Enabled ("ntp") && Package::Installed ("yast2-ntp-client"); - UI::OpenDialog( `opt(`decorated), - `HBox( - `HWeight(30, `RichText( htext )), - `HStretch(), - `HSpacing(1), - `HWeight(70, - `VBox ( - `HBox (`HSpacing(55)), - // heading text - `Heading( _("Change System Date and Time") ), - `VSpacing(2), - `VStretch(), - timeterm, - `VSpacing(), - `VStretch(), - dateterm, - `VSpacing(2), - `VStretch(), - `HBox( - // button text - `PushButton(`id(`apply), `opt(`default), _("&Apply")), - `PushButton(`id(`cancel), Label::CancelButton() ) + // list of servers based on the language (got from ntp-client module) + list ntp_items_proposed = nil; + list ntp_items_proposal () { + if (ntp_items_proposed == nil) + { + list servers = (list) WFM::CallFunction ("ntp-client_auto", [ + "GetNtpServersByCountry", + $[ "country" : Language::GetLanguageCountry () ] + ]); + ntp_items_proposed = (servers == nil) ? [] : servers; + } + return ntp_items_proposed; + } + + /** + * read the settings of ntp client (we only need current list of servers) + */ + boolean read_ntp_settings () { + + // busy popup + Popup::ShowFeedback ("", _("Reading NTP configuration...")); + any read = WFM::CallFunction ("ntp-client_auto", ["Read"]); + if (read == false) + { + ntp_used = false; + ntp_items = []; + } + else + { + map ex = (map)WFM::CallFunction ("ntp-client_auto", ["Export"]); + foreach (map peer, ex["peers"]:[], { + if (peer["type"]:"" == "server") + ntp_items = add (ntp_items, peer["address"]:""); + }); + } + if (ntp_used && ntp_items == []) + ntp_items = ntp_items_proposal (); + Popup::ClearFeedback (); + return ntp_used; + } + + term cont = `HBox ( + `RadioButtonGroup (`id (`rb), `HCenter (`VBox ( + `Left (`VBox ( + // radio button label (= how to setup time) + `Left (`RadioButton (`id (`manual), `opt (`notify), _("Manually"), !ntp_used)), + `VSpacing (0.5), + `HBox ( + `HSpacing (3), + `VBox ( + `Left (timeterm), + `VSpacing(), + `Left (dateterm) + ) + ) + )), + `VSpacing (1), + `Left (`VBox ( + `Left (`RadioButton (`id (`ntp), `opt (`notify), + // radio button label + _("Synchronize with NTP Server"), ntp_used) + ), + `VSpacing (0.5), + `HBox ( + `HSpacing (3), + `MinWidth (38, + `ComboBox (`id (`ntp_address), `opt (`editable), + // combo box label + _("NTP Server Address"), ntp_items + ) ), - `VSpacing() + `VBox ( + `Label (""), + // push button label + `PushButton (`id (`ntp_configure), _("Configure...")) + ) ) - ) - )); + )) + ))) + ); + Wizard::OpenAcceptDialog (); + Wizard::SetContents (_("Change Date and Time"), cont, htext, true, true); if (!dt_widgets) { @@ -156,12 +216,99 @@ widget == `year ? 4 : 2); }); } + + if (ntp_used) + { + read_ntp_settings (); + UI::ChangeWidget (`id (`ntp_address), `Items, ntp_items); + } + + void enable_disable_widgets () { + if (!dt_widgets) + { + foreach (symbol widget, [`hour, `minute, `second, `day, `month, `year],{ + UI::ChangeWidget (`id (widget), `Enabled, !ntp_used); + }); + } + else + { + UI::ChangeWidget (`id (`date), `Enabled, !ntp_used); + UI::ChangeWidget (`id (`time), `Enabled, !ntp_used); + } + UI::ChangeWidget (`id (`ntp_address), `Enabled, ntp_used); + UI::ChangeWidget (`id (`ntp_configure), `Enabled, ntp_used); + } + + enable_disable_widgets (); any ret = `cancel; + boolean ntp_installed = false; repeat { ret = UI::UserInput(); y2debug ("UserInput ret:%1", ret ); - if (ret == `apply) + if (ret == `ntp || ret == `manual) + { + ntp_used = (ret == `ntp); + if (ntp_used && !Stage::initial () && !ntp_installed) + { + ntp_installed = Package::Install ("yast2-ntp-client"); + if (!ntp_installed) + { + ntp_used = false; + UI::ChangeWidget (`id (`manual), `Value, true); + UI::ChangeWidget (`id (`ntp), `Value, false); + } + } + if (ntp_used && ntp_items == []) + { + if (!read_ntp_settings ()) + { + UI::ChangeWidget (`id (`manual), `Value, true); + UI::ChangeWidget (`id (`ntp), `Value, false); + continue; + } + UI::ChangeWidget (`id (`ntp_address), `Items, ntp_items); + } + enable_disable_widgets (); + } + if (ret == `ntp_configure) + { + if (WFM::CallFunction ("ntp-client", []) != true) + continue; + // read current settings again + if (!read_ntp_settings ()) + { + UI::ChangeWidget (`id (`manual), `Value, true); + UI::ChangeWidget (`id (`ntp), `Value, false); + continue; + } + UI::ChangeWidget (`id (`ntp_address), `Items, ntp_items); + // adapt current time after the attempt to synchronize + val = Timezone::GetDateTimeMap(); + hour = val["hour"]:""; + minute = val["minute"]:""; + second = val["second"]:""; + day = val["day"]:""; + month = val["month"]:""; + year = val["year"]:""; + if (dt_widgets) + { + UI::ChangeWidget (`id (`date), `Value, + sformat ("%1-%2-%3", year, month, day)); + UI::ChangeWidget (`id (`time), `Value, + sformat ("%1:%2:%3", hour, minute, second)); + } + else + { + UI::ChangeWidget (`id (`hour), `Value, hour); + UI::ChangeWidget (`id (`minute), `Value, minute); + UI::ChangeWidget (`id (`second), `Value, second); + UI::ChangeWidget (`id (`day), `Value, day); + UI::ChangeWidget (`id (`month), `Value, month); + UI::ChangeWidget (`id (`year), `Value, year); + } + } + if (ret == `accept && !ntp_used) { if (dt_widgets) { @@ -210,10 +357,31 @@ Timezone::SetTime( year, month, day, hour, minute, second ); } } + if (ret == `accept && ntp_used) + { + // check the address validity, call ntp-client API etc. + map ex = (map)WFM::CallFunction ("ntp-client_auto", ["Export"]); + list peers = add (ex["peers"]:[], $[ + "address" : UI::QueryWidget (`id (`ntp_address), `Value), + "comment" : "", + "options" : "", + "type" : "server", + "initial_sync" : true, + ] + ); + map import_map = $[ + "peers" : peers, + "start_at_boot" : true, + ]; + WFM::CallFunction ("ntp-client_auto", ["Import", import_map]); + WFM::CallFunction ("ntp-client_auto", ["Write", $[ + "restart_services": true + ]]); + } } - until( ret==`apply || ret==`cancel ); - UI::CloseDialog(); - return( ret==`apply ); + until( ret==`accept || ret==`cancel ); + Wizard::CloseDialog (); + return (ret == `accept); }; /** @@ -286,6 +454,14 @@ boolean textmode = Language::GetTextMode (); + boolean ntp = false; + term ntp_term = `Frame (_("NTP Synchronization"), `VBox (`HBox ( + `HSpacing (0.5), + `Label (`id(`ntp), _("NTP is not configured")), + // button label + `Right (`PushButton (`id (`ntp_configure), _("Change..."))), + `HSpacing (1) + ), `VSpacing (0.2))); term contents = `MarginBox ( `leftMargin (2), `rightMargin (2), `topMargin (0), `bottomMargin (0.2), `VBox ( -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org