Author: kmachalkova Date: Thu Sep 6 18:13:28 2007 New Revision: 40792 URL: http://svn.opensuse.org/viewcvs/yast?rev=40792&view=rev Log: Accept IP as a valid NTP server address Modified: trunk/ntp-client/src/ntp-client_proposal.ycp Modified: trunk/ntp-client/src/ntp-client_proposal.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ntp-client/src/ntp-client_proposal.ycp?rev=40792&r1=40791&r2=40792&view=diff ============================================================================== --- trunk/ntp-client/src/ntp-client_proposal.ycp (original) +++ trunk/ntp-client/src/ntp-client_proposal.ycp Thu Sep 6 18:13:28 2007 @@ -8,7 +8,7 @@ { textdomain "ntp-client"; -import "Hostname"; +import "Address"; import "NetworkService"; import "NtpClient"; import "Service"; @@ -47,6 +47,7 @@ ntp_items = NtpClient::GetNtpServersByCountry( cc, true ); NtpClient::config_has_been_read = true; } + ntp_items = add(ntp_items, ""); UI::ChangeWidget(`id(`ntp_address), `Items, ntp_items); } @@ -68,6 +69,17 @@ NtpClient::storeSyncRecord(); } +boolean ValidateSingleServer( string ntp_server ) +{ + if (!Address::Check(ntp_server) ) + { + UI::SetFocus(`id(`ntp_address)); + return false; + } + + return true; +} + if (func == "CreateUI") { term cont = @@ -123,11 +135,8 @@ else if (func == "Write") { string ntp_server = (string) UI::QueryWidget(`id(`ntp_address), `Value); - if (!Hostname::CheckFQ(ntp_server)) - { - UI::SetFocus(`id(`ntp_address)); + if ( !ValidateSingleServer( ntp_server ) ) ret = `invalid_hostname; - } else { y2milestone("Running ntpdate to sync with %1", ntp_server); @@ -141,7 +150,7 @@ status = Service::Status (service_name); //Stop service temporarily (otherwise ntpdate won't work) //0 means service is running - if ( status == 0); + if ( status == 0) Service::Stop (service_name); } @@ -170,9 +179,15 @@ else if (func == "AskUser") { string ntp_server = (string) UI::QueryWidget(`id(`ntp_address), `Value); - AddSingleServer(ntp_server); - ret = (symbol) WFM::CallFunction("ntp-client"); - ProposeSomething(); + if ( !ValidateSingleServer( ntp_server ) ) + ret = `invalid_hostname; + else + { + string ntp_server = (string) UI::QueryWidget(`id(`ntp_address), `Value); + AddSingleServer(ntp_server); + ret = (symbol) WFM::CallFunction("ntp-client"); + ProposeSomething(); + } } y2milestone("Ntp client proposal finished"); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org