Hello community,

here is the log from the commit of package yast2-ntp-client for 
openSUSE:Factory checked in at 2018-11-18 22:59:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-ntp-client (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-ntp-client.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-ntp-client"

Sun Nov 18 22:59:52 2018 rev:108 rq:649233 version:4.1.5

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-ntp-client/yast2-ntp-client.changes        
2018-11-01 18:55:38.289969172 +0100
+++ /work/SRC/openSUSE:Factory/.yast2-ntp-client.new/yast2-ntp-client.changes   
2018-11-18 23:00:49.195625713 +0100
@@ -1,0 +2,20 @@
+Thu Nov  8 19:20:26 UTC 2018 - [email protected]
+
+- fate#323454
+  - Bring back the menu button for choosing an NTP address from a
+    public NTP servers list or from the ones returned by DHCP.
+  - When no configuration is proposed by default, then use the DHCP
+    offered servers as fallback.
+- Do not synchronize if chronyd service is running (bsc#1087048)
+- Use the title style capitalization in "Synchronize Now" button
+  (bsc#1039987)
+- 4.1.5
+
+-------------------------------------------------------------------
+Thu Nov  8 15:20:26 UTC 2018 - [email protected]
+
+- Only write the configuration once, and do not save changes when
+  we are only synchronizing the date. (bsc#1108497)
+- 4.1.4
+
+-------------------------------------------------------------------

Old:
----
  yast2-ntp-client-4.1.3.tar.bz2

New:
----
  yast2-ntp-client-4.1.5.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-ntp-client.spec ++++++
--- /var/tmp/diff_new_pack.vOuXaP/_old  2018-11-18 23:00:49.967624849 +0100
+++ /var/tmp/diff_new_pack.vOuXaP/_new  2018-11-18 23:00:49.971624844 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-ntp-client
-Version:        4.1.3
+Version:        4.1.5
 Release:        0
 Summary:        YaST2 - NTP Client Configuration
 License:        GPL-2.0-or-later
@@ -40,7 +40,8 @@
 Requires:       yast2 >= 3.2.21
 Requires:       yast2-country-data
 # needed for network/config agent
-Requires:       yast2-network
+# Yast::Lan.dhcp_ntp_servers
+Requires:       yast2-network >= 4.1.17
 Requires:       yast2-ruby-bindings >= 1.0.0
 Requires:       rubygem(%rb_default_ruby_abi:cfa) >= 0.6.0
 BuildArch:      noarch

++++++ yast2-ntp-client-4.1.3.tar.bz2 -> yast2-ntp-client-4.1.5.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ntp-client-4.1.3/package/yast2-ntp-client.changes 
new/yast2-ntp-client-4.1.5/package/yast2-ntp-client.changes
--- old/yast2-ntp-client-4.1.3/package/yast2-ntp-client.changes 2018-10-16 
11:03:32.000000000 +0200
+++ new/yast2-ntp-client-4.1.5/package/yast2-ntp-client.changes 2018-11-15 
12:08:24.000000000 +0100
@@ -1,4 +1,24 @@
 -------------------------------------------------------------------
+Thu Nov  8 19:20:26 UTC 2018 - [email protected]
+
+- fate#323454
+  - Bring back the menu button for choosing an NTP address from a
+    public NTP servers list or from the ones returned by DHCP.
+  - When no configuration is proposed by default, then use the DHCP
+    offered servers as fallback.
+- Do not synchronize if chronyd service is running (bsc#1087048)
+- Use the title style capitalization in "Synchronize Now" button
+  (bsc#1039987)
+- 4.1.5
+
+-------------------------------------------------------------------
+Thu Nov  8 15:20:26 UTC 2018 - [email protected]
+
+- Only write the configuration once, and do not save changes when
+  we are only synchronizing the date. (bsc#1108497)
+- 4.1.4
+
+-------------------------------------------------------------------
 Tue Oct 16 10:28:35 CEST 2018 - [email protected]
 
 - Fixed license path. Build error for bsc#1110598.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ntp-client-4.1.3/package/yast2-ntp-client.spec 
new/yast2-ntp-client-4.1.5/package/yast2-ntp-client.spec
--- old/yast2-ntp-client-4.1.3/package/yast2-ntp-client.spec    2018-10-16 
11:03:32.000000000 +0200
+++ new/yast2-ntp-client-4.1.5/package/yast2-ntp-client.spec    2018-11-15 
12:08:24.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-ntp-client
-Version:        4.1.3
+Version:        4.1.5
 Release:        0
 Summary:        YaST2 - NTP Client Configuration
 License:        GPL-2.0-or-later
@@ -40,7 +40,8 @@
 Requires:       yast2 >= 3.2.21
 Requires:       yast2-country-data
 # needed for network/config agent
-Requires:       yast2-network
+# Yast::Lan.dhcp_ntp_servers
+Requires:       yast2-network >= 4.1.17
 Requires:       yast2-ruby-bindings >= 1.0.0
 Requires:       rubygem(%rb_default_ruby_abi:cfa) >= 0.6.0
 BuildArch:      noarch
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ntp-client-4.1.3/src/clients/ntp-client_proposal.rb 
new/yast2-ntp-client-4.1.5/src/clients/ntp-client_proposal.rb
--- old/yast2-ntp-client-4.1.3/src/clients/ntp-client_proposal.rb       
2018-10-16 11:03:32.000000000 +0200
+++ new/yast2-ntp-client-4.1.5/src/clients/ntp-client_proposal.rb       
2018-11-15 12:08:24.000000000 +0100
@@ -61,6 +61,8 @@
       when "SetUseNTP"
         NtpClient.ntp_selected = Ops.get_boolean(@param, "ntp_used", false)
         @ret = true
+      when "dhcp_ntp_servers"
+        @ret = NtpClient.dhcp_ntp_servers
       when "MakeProposal"
         @ret = MakeProposal()
       when "Write"
@@ -128,7 +130,10 @@
     def ui_enable_disable_widgets(enabled)
       UI.ChangeWidget(Id(:ntp_address), :Enabled, enabled)
       UI.ChangeWidget(Id(:run_service), :Enabled, enabled)
-      if !NetworkService.isNetworkRunning
+      # FIXME: With chronyd, we cannot synchronize if the service is already
+      # running, we could force a makestep in this case, but then the button
+      # should be reworded and maybe the user should confirm it (bsc#1087048)
+      if !NetworkService.isNetworkRunning || 
Service.Active(NtpClient.service_name)
         UI.ChangeWidget(Id(:ntp_now), :Enabled, false)
       else
         UI.ChangeWidget(Id(:ntp_now), :Enabled, enabled)
@@ -184,24 +189,16 @@
       end
 
       if NtpClient.config_has_been_read || NtpClient.ntp_selected
-        Builtins.y2milestone("ntp_items will be filled from /etc/chrony.conf")
+        log.info("ntp_items will be filled from /etc/chrony.conf")
         # grr, GUNS means all of them are used and here we just pick one
-        ntp_items = Builtins.maplist(NtpClient.GetUsedNtpServers) do |server|
-          Item(Id(server), server)
-        end
-        # avoid calling Read again (bnc #427712)
-        NtpClient.config_has_been_read = true
-      end
-      if ntp_items == []
-        Builtins.y2milestone(
-          "Nothing found in /etc/chrony.conf, proposing current timezone-based 
NTP server list"
-        )
-        time_zone_country = Timezone.GetCountryForTimezone(Timezone.timezone)
-        ntp_items = NtpClient.GetNtpServersByCountry(time_zone_country, true)
-        NtpClient.config_has_been_read = true
+        ntp_items = configured_ntp_items
       end
-      ntp_items = Builtins.add(ntp_items, "")
-      Builtins.y2milestone("ntp_items :%1", ntp_items)
+
+      ntp_items = fallback_ntp_items if ntp_items.empty?
+      # Once read or proposed any config we consider it as read (bnc#427712)
+      NtpClient.config_has_been_read = true
+
+      log.info "ntp_items :#{ntp_items}"
       UI.ChangeWidget(Id(:ntp_address), :Items, ntp_items)
 
       nil
@@ -223,14 +220,14 @@
                 ComboBox(
                   Id(:ntp_address),
                   Opt(:editable, :hstretch),
-                  # combo box label
+                  # TRANSLATORS: combo box label
                   _("&NTP Server Address")
                 )
               ),
               VSpacing(0.3),
               HBox(
                 HSpacing(0.5),
-                # check box label
+                # TRANSLATORS: check box label
                 Left(
                   CheckBox(
                     Id(:run_service),
@@ -241,7 +238,7 @@
               ),
               HBox(
                 HSpacing(0.5),
-                # check box label
+                # TRANSLATORS: check box label
                 Left(
                   CheckBox(Id(:ntp_save), _("&Save NTP Configuration"), true)
                 )
@@ -252,10 +249,10 @@
             1,
             VBox(
               Label(""),
-              # push button label
-              Left(PushButton(Id(:ntp_now), _("S&ynchronize now"))),
+              # TRANSLATORS: push button label
+              Left(PushButton(Id(:ntp_now), _("S&ynchronize Now"))),
               VSpacing(0.3),
-              # push button label
+              # TRANSLATORS: push button label
               # bnc#449615: only simple config for inst-sys
               Stage.initial ? Label("") : Left(PushButton(Id(:ntp_configure), 
_("&Configure..."))),
               Label("")
@@ -356,14 +353,14 @@
 
       return :invalid_hostname unless ValidateSingleServer(ntp_server)
 
-      WriteNtpSettings(ntp_servers, ntp_server, run_service)
+      add_or_install_required_package unless params["write_only"]
 
-      return :success if params["write_only"]
+      WriteNtpSettings(ntp_servers, ntp_server, run_service) unless 
params["ntpdate_only"]
 
-      add_or_install_required_package
+      return :success if params["write_only"]
 
       # Only if network is running try to synchronize the ntp server
-      if NetworkService.isNetworkRunning
+      if NetworkService.isNetworkRunning && 
!Service.Active(NtpClient.service_name)
         Popup.ShowFeedback("", _("Synchronizing with NTP server..."))
         exit_code = NtpClient.sync_once(ntp_server)
         Popup.ClearFeedback
@@ -371,9 +368,6 @@
         return :ntpdate_failed unless exit_code.zero?
       end
 
-      # User wants more than running one time sync (synchronize on boot)
-      WriteNtpSettings(ntp_servers, ntp_server, run_service) unless 
params["ntpdate_only"]
-
       :success
     end
 
@@ -480,6 +474,46 @@
         )
       end
     end
+
+    # Configured ntp servers Yast::Term items with the ntp address ID and label
+    #
+    # @return [Yast::Term] ntp address table Item
+    def configured_ntp_items
+      NtpClient.GetUsedNtpServers.map { |s| Item(Id(s), s) }
+    end
+
+    # Public list of ntp servers Yast::Term items with the ntp address ID and
+    # label
+    #
+    # @return [Array<Yast::Term>] ntp address Item
+    def timezone_ntp_items
+      timezone_country = Timezone.GetCountryForTimezone(Timezone.timezone)
+      NtpClient.GetNtpServersByCountry(timezone_country, true)
+    end
+
+    # List of dhcp ntp servers Yast::Term items with the ntp address ID and
+    # label
+    #
+    # @return [Array<Yast::Term>] ntp address table Item
+    def dhcp_ntp_items
+      NtpClient.dhcp_ntp_servers.map { |s| Item(Id(s), s) }
+    end
+
+    # List of ntp servers Yast::Term items with the ntp address ID and label
+    #
+    # @return [Array<Yast::Term>] ntp address table Item
+    def fallback_ntp_items
+      dhcp_items = dhcp_ntp_items
+
+      log.info("Nothing found in /etc/chrony.conf")
+      if dhcp_items.empty?
+        log.info("Proposing current timezone-based NTP server list")
+        return timezone_ntp_items
+      end
+
+      log.info("Proposing NTP server list provided by DHCP")
+      dhcp_items
+    end
   end
 end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ntp-client-4.1.3/src/lib/y2ntp_client/dialog/add_pool.rb 
new/yast2-ntp-client-4.1.5/src/lib/y2ntp_client/dialog/add_pool.rb
--- old/yast2-ntp-client-4.1.3/src/lib/y2ntp_client/dialog/add_pool.rb  
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-ntp-client-4.1.5/src/lib/y2ntp_client/dialog/add_pool.rb  
2018-11-15 12:08:24.000000000 +0100
@@ -0,0 +1,96 @@
+require "yast"
+
+require "cwm/popup"
+
+Yast.import "Label"
+Yast.import "NtpClient"
+Yast.import "Stage"
+Yast.import "Popup"
+
+# Work around YARD inability to link across repos/gems:
+
+# @!macro [new] seeAbstractWidget
+#   @see http://www.rubydoc.info/github/yast/yast-yast2/CWM/AbstractWidget:${0}
+# @!macro [new] seeCustomWidget
+#   @see http://www.rubydoc.info/github/yast/yast-yast2/CWM/CustomWidget:${0}
+# @!macro [new] seeItemsSelection
+#   @see http://www.rubydoc.info/github/yast/yast-yast2/CWM/ItemsSelection:${0}
+# @!macro [new] seeDialog
+#   @see http://www.rubydoc.info/github/yast/yast-yast2/CWM/Dialog:${0}
+# @!macro [new] seePopup
+#   @see http://www.rubydoc.info/github/yast/yast-yast2/CWM/Popup:${0}
+
+module Y2NtpClient
+  module Dialog
+    # Dialog to add/edit ntp pool server
+    class AddPool < ::CWM::Popup
+      # Constructor
+      #
+      # @param address_widget [CWM::InputField]
+      # @param pool_type [Symbol]
+      def initialize(address_widget, pool_type)
+        textdomain "ntp-client"
+
+        @address_widget = address_widget
+        @address = @address_widget.value
+        @pool_chooser = pool_for(pool_type)
+      end
+
+      # @macro seeDialog
+      def title
+        # TRANSLATORS: title for choosing a ntp server dialog
+        _("Available NTP servers")
+      end
+
+      # @macro seeDialog
+      def contents
+        VBox(
+          @pool_chooser
+        )
+      end
+
+      def next_handler
+        return :cancel if @pool_chooser.value.to_s.empty?
+        @address = @pool_chooser.value
+
+        :next
+      end
+
+      # @macro seeDialog
+      def next_button
+        ok_button_label
+      end
+
+      # @macro seeDialog
+      def run
+        result = super
+        @address_widget.value = @address if result == :next
+
+        result
+      end
+
+    private
+
+      # @macro seeDialog
+      def ok_button
+        PushButton(Id(:next), Opt(:default), ok_button_label)
+      end
+
+      def available_pools
+        { local:  Widgets::LocalList, public: Widgets::PublicList }
+      end
+
+      def pool_for(type)
+        available_pools.fetch(type, 
Widgets::LocalList).new(@address_widget.value)
+      end
+
+      def min_height
+        8
+      end
+
+      def buttons
+        [ok_button, cancel_button]
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ntp-client-4.1.3/src/lib/y2ntp_client/dialog/pool.rb 
new/yast2-ntp-client-4.1.5/src/lib/y2ntp_client/dialog/pool.rb
--- old/yast2-ntp-client-4.1.3/src/lib/y2ntp_client/dialog/pool.rb      
2018-10-16 11:03:32.000000000 +0200
+++ new/yast2-ntp-client-4.1.5/src/lib/y2ntp_client/dialog/pool.rb      
2018-11-15 12:08:24.000000000 +0100
@@ -32,10 +32,19 @@
           HBox(
             @address_widget,
             HSpacing(),
-            Widgets::TestButton.new(@address_widget)
+            VBox(
+              VSpacing(1),
+              Widgets::SelectFrom.new(@address_widget)
+            ),
+            HSpacing(),
+            VBox(
+              VSpacing(1),
+              Widgets::TestButton.new(@address_widget)
+            )
           ),
           VSpacing(),
           HBox(
+            HSpacing(),
             Widgets::Iburst.new(@options),
             HSpacing(),
             Widgets::Offline.new(@options)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ntp-client-4.1.3/src/lib/y2ntp_client/widgets/main_widgets.rb 
new/yast2-ntp-client-4.1.5/src/lib/y2ntp_client/widgets/main_widgets.rb
--- old/yast2-ntp-client-4.1.3/src/lib/y2ntp_client/widgets/main_widgets.rb     
2018-10-16 11:03:32.000000000 +0200
+++ new/yast2-ntp-client-4.1.5/src/lib/y2ntp_client/widgets/main_widgets.rb     
2018-11-15 12:08:24.000000000 +0100
@@ -24,13 +24,12 @@
       end
 
       def help
-        # TRANSLATORS: 'man 8 netconfig' is a command, do not translate that
-        _(
-          "The NTP configuration may be provided by the local network over 
DHCP. " \
+        # TRANSLATORS: configuration source combo box help, %{manual} is a
+        # manual page reference, e.g. "man 8 netconfig"
+        _("<p>The NTP configuration may be provided by the local network over 
DHCP. " \
           "<b>Configuration Source</b> can simply enable or disable using that 
configuration. " \
           "In cases where there may be multiple DHCP sources, it can 
prioritize them: " \
-          "see 'man 8 netconfig'."
-        )
+          "see '%{manual}'.</p>") % { manual: "man 8 netconfig" }
       end
 
       def opt
@@ -39,9 +38,9 @@
 
       def items
         items = [
-          # combo box item
+          # TRANSLATORS: combo box item
           ["", _("Static")],
-          # combo box item
+          # TRANSLATORS: combo box item
           ["auto", _("Dynamic")]
         ]
         current_policy = Yast::NtpClient.ntp_policy
@@ -127,7 +126,7 @@
           "Select whether to start the NTP daemon now and on every system 
boot. \n"            \
           "Selecting <b>Synchronize without Daemon</b> the NTP daemon will not 
be activated\n" \
           "and the system time will be set periodically by a <i>cron</i> 
script. \n"           \
-          "The interval is configurable, by default it is %d minutes."
+          "The interval is configurable, by default it is %d minutes.</p>"
         ) % Yast::NtpClientClass::DEFAULT_SYNC_INTERVAL
       end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ntp-client-4.1.3/src/lib/y2ntp_client/widgets/pool_widgets.rb 
new/yast2-ntp-client-4.1.5/src/lib/y2ntp_client/widgets/pool_widgets.rb
--- old/yast2-ntp-client-4.1.3/src/lib/y2ntp_client/widgets/pool_widgets.rb     
2018-10-16 11:03:32.000000000 +0200
+++ new/yast2-ntp-client-4.1.5/src/lib/y2ntp_client/widgets/pool_widgets.rb     
2018-11-15 12:08:24.000000000 +0100
@@ -1,6 +1,7 @@
 require "yast"
 
 require "cwm/widget"
+require "y2ntp_client/dialog/add_pool"
 
 Yast.import "Address"
 Yast.import "NtpClient"
@@ -12,19 +13,25 @@
     class PoolAddress < CWM::InputField
       attr_reader :address
 
+      # @macro seeAbstractWidget
       def initialize(initial_value)
         textdomain "ntp-client"
+
         @address = initial_value
       end
 
+      # @macro seeAbstractWidget
       def label
+        # TRANSLATORS: input field label
         _("A&ddress")
       end
 
+      # @macro seeAbstractWidget
       def init
         self.value = @address
       end
 
+      # @macro seeAbstractWidget
       def validate
         return true if Yast::Address.Check(value)
 
@@ -33,6 +40,7 @@
         false
       end
 
+      # @macro seeAbstractWidget
       def store
         @address = value
       end
@@ -42,11 +50,13 @@
     class TestButton < CWM::PushButton
       def initialize(address_widget)
         textdomain "ntp-client"
+
         @address_widget = address_widget
       end
 
       def label
-        _("Test")
+        # TRANSLATORS: push button label
+        _("&Test")
       end
 
       def handle
@@ -60,10 +70,12 @@
     class Iburst < CWM::CheckBox
       def initialize(options)
         textdomain "ntp-client"
+
         @options = options
       end
 
       def label
+        # TRANSLATORS: checkbox label
         _("Quick Initial Sync")
       end
 
@@ -80,27 +92,34 @@
       end
 
       def help
-        _("<b>Quick Initial Sync</b> specifies whether the 'iburst' option is 
used. This option " \
-        "sends 4 poll requests in 2 second intervals during the 
initialization. It is useful for " \
-        "a quick synchronization during the start of the machine.")
+        # TRANSLATORS: checkbox help for enabling quick synchronization
+        _("<p><b>Quick Initial Sync</b> is useful for a quick synchronization" 
\
+          "during the start of the machine.</p>")
       end
     end
 
     # Enable offline option
     class Offline < CWM::CheckBox
+      # Constructor
+      #
+      # @param options [Hash] current ntp server address options
       def initialize(options)
         textdomain "ntp-client"
         @options = options
       end
 
+      # @macro seeAbstractWidget
       def label
+        # TRANSLATORS: check box label
         _("Start Offline")
       end
 
+      # @macro seeAbstractWidget
       def init
         self.value = @options.key?("offline")
       end
 
+      # @macro seeAbstractWidget
       def store
         if value
           @options["offline"] = nil
@@ -109,12 +128,274 @@
         end
       end
 
+      # @macro seeAbstractWidget
       def help
+        "<p>#{help_text}</p>"
+      end
+
+    private
+
+      def help_text
+        # TRANSLATORS: help text for the offline check box
         _("<b>Start Offline</b> specifies whether the 'offline' option is 
used. This option " \
           "skips this server during the start-up. It is useful for a machine 
which starts " \
           "without the network, because it speeds up the boot, and 
synchronizes when the machine " \
           "gets connected to the network.")
       end
     end
+
+    # Menu Button for choosing which type of server should be added to the
+    # address input field.
+    class SelectFrom < CWM::MenuButton
+      # Constructor
+      #
+      # @param address_widget [PoolAddress] the dialog pool address widget
+      def initialize(address_widget)
+        @address_widget = address_widget
+      end
+
+      # @macro seeAbstractWidget
+      def label
+        # TRANSLATORS: menu button label
+        _("&Select")
+      end
+
+      # @macro seeAbstractWidget
+      def opt
+        [:notify]
+      end
+
+      # @macro seeItemsSelection
+      def items
+        # TRANSLATORS: Menu button entries for choosing an address from a local
+        #   servers list or from a public one
+        [[:local, _("Local Server")], [:public, _("Public Server")]]
+      end
+
+      # @macro seeAbstractWidget
+      def handle(event)
+        id = event["ID"]
+        Dialog::AddPool.new(@address_widget, id).run if [:local, 
:public].include?(id)
+
+        nil
+      end
+
+      # @macro seeAbstractWidget
+      def cwm_definition
+        additional = {}
+        # handle also the items id events
+        if !handle_all_events
+          event_ids = items.map(&:first)
+          additional["handle_events"] = event_ids
+        end
+
+        super.merge(additional)
+      end
+
+      # @macro seeAbstractWidget
+      def help
+        # TRANSLATORS: Help for the select menu button
+        _("<p><b>Select</b> permits to choose a server from the list of 
servers" \
+          "offered by DHCP or from a public list filtered by country.</p>") \
+      end
+    end
+
+    # List of NTP servers obtained from DHCP
+    class LocalList < CWM::SelectionBox
+      # Constructor
+      #
+      # @param address [String] current NTP pool address
+      def initialize(address)
+        textdomain "ntp-client"
+
+        @address = address
+        @servers = []
+      end
+
+      # @macro seeAbstractWidget
+      def init
+        read_available_servers
+        self.value = @address
+      end
+
+      # @macro seeAbstractWidget
+      def opt
+        [:hstretch]
+      end
+
+      # @macro seeAbstractWidget
+      def label
+        # TRANSLATORS: selection box label
+        _("Synchronization Server")
+      end
+
+      # @macro seeItemsSelection
+      def items
+        @servers.map { |s| [s, s] }
+      end
+
+      # @macro seeAbstractWidget
+      def help
+        # TRANSLATORS: help text for the local servers selection box
+        _("<p>List of available NTP servers provided by DHCP. " \
+          "Servers already in use are discarded.</p>")
+      end
+
+    private
+
+      # Convenience method to read and initialize the list of available servers
+      def read_available_servers
+        Yast::Popup.Feedback(_("Getting NTP sources from DHCP"), 
Yast::Message.takes_a_while) do
+          @servers = available_servers
+        end
+      end
+
+      # List of available NTP servers provided by DHCP. Servers already in use
+      # are discarded.
+      #
+      # @return [Array<String>] list of NTP servers provided by DHCP
+      def available_servers
+        Yast::NtpClient.dhcp_ntp_servers.reject { |s| 
configured_servers.include?(s) }
+      end
+
+      # List of NTP servers in use.
+      #
+      # @return [Array<String>] list of already configured NTP servers
+      def configured_servers
+        Yast::NtpClient.ntp_conf.pools.keys
+      end
+    end
+
+    # List of public NTP servers filtered by country
+    class PublicList < CWM::CustomWidget
+      # Constructor
+      #
+      # @param address [String] current NTP pool address
+      def initialize(address)
+        textdomain "ntp-client"
+
+        @country_pools = CountryPools.new
+        @country = Country.new(country_for(address), @country_pools)
+      end
+
+      # @macro seeAbstractWidget
+      def label
+        # TRANSLATORS: custom widget label, the widget permits to select a
+        # public server from a selection box, filtering the list by country
+        _("Public Servers")
+      end
+
+      # @macro seeCustomWidget
+      def contents
+        VBox(
+          @country,
+          VSpacing(),
+          @country_pools
+        )
+      end
+
+      # The value of this widget is the current country pool entry selected
+      def value
+        @country_pools.value
+      end
+
+      # @macro seeAbstractWidget
+      def help
+        # TRANSLATORS: help text for the public servers custom widget
+        _("<p>List of public NTP servers filtered by country.</p>")
+      end
+
+    private
+
+      def country_for(address)
+        Yast::NtpClient.GetNtpServers.fetch(address, {})["country"]
+      end
+    end
+
+    # Country chooser
+    class Country < CWM::ComboBox
+      def initialize(country, country_pools)
+        textdomain "ntp-client"
+
+        @country = country
+        @country_pools = country_pools
+      end
+
+      # @macro seeAbstractWidget
+      def init
+        self.value = @country
+        refresh_country_pools
+      end
+
+      # @macro seeAbstractWidget
+      def opt
+        [:notify, :hstretch]
+      end
+
+      # @macro seeAbstractWidget
+      def label
+        # TRANSLATORS: combo box label
+        _("Country")
+      end
+
+      # @macro seeItemsSelection
+      def items
+        country_names.map { |c, l| [c, l] }
+      end
+
+      # @macro seeAbstractWidget
+      def handle
+        @country = value.to_s
+        refresh_country_pools
+        nil
+      end
+
+    private
+
+      def refresh_country_pools
+        @country_pools.refresh(@country)
+      end
+
+      def country_names
+        # TRANSLATORS: Combo box entry for not filtering entries
+        { "" => _("ALL") }.merge(Yast::NtpClient.GetCountryNames)
+      end
+    end
+
+    # Ntp sources selector filtered by country
+    class CountryPools < CWM::ComboBox
+      def initialize
+        textdomain "ntp-client"
+      end
+
+      # macro seeAbstractWidget
+      def opt
+        [:hstretch]
+      end
+
+      # macro seeAbstractWidget
+      def label
+        # TRANSLATORS: combo box label
+        _("NTP Servers")
+      end
+
+      # macro seeItemsSelection
+      def items
+        ntp_servers.map { |s, v| [s, "#{s} (#{v["country"]})"] }
+      end
+
+      def refresh(country)
+        @country = country
+        change_items(items)
+      end
+
+    private
+
+      def ntp_servers
+        servers = Yast::NtpClient.GetNtpServers
+        return servers if @country.to_s.empty?
+        servers.find_all { |_s, v| v["country"] == @country }
+      end
+    end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ntp-client-4.1.3/src/modules/NtpClient.rb 
new/yast2-ntp-client-4.1.5/src/modules/NtpClient.rb
--- old/yast2-ntp-client-4.1.3/src/modules/NtpClient.rb 2018-10-16 
11:03:32.000000000 +0200
+++ new/yast2-ntp-client-4.1.5/src/modules/NtpClient.rb 2018-11-15 
12:08:24.000000000 +0100
@@ -56,6 +56,7 @@
 
       Yast.import "Directory"
       Yast.import "FileUtils"
+      Yast.import "Lan"
       Yast.import "Language"
       Yast.import "Message"
       Yast.import "Mode"
@@ -95,8 +96,8 @@
       @service_name = "chronyd"
 
       # Netconfig policy: for merging and prioritizing static and DHCP config.
-      # FIXME: get a public URL
-      # 
https://svn.suse.de/svn/sysconfig/branches/mt/dhcp6-netconfig/netconfig/doc/README
+      # https://github.com/openSUSE/sysconfig/blob/master/doc/README.netconfig
+      # 
https://github.com/openSUSE/sysconfig/blob/master/config/sysconfig.config-network
       @ntp_policy = DEFAULT_NTP_POLICY
 
       # Active Directory controller
@@ -128,7 +129,7 @@
       @ntp_selected = false
     end
 
-    # CFA instance for reading/writing /etc/ntp.conf
+    # CFA instance for reading/writing /etc/chrony.conf
     def ntp_conf
       @chrony_conf ||= CFA::ChronyConf.new
     end
@@ -154,7 +155,7 @@
     # @param server [String] to sync against
     # @return [Integer] exit code of sync command
     def sync_once(server)
-      log.info "Running ont time sync with #{server}"
+      log.info "Running one time sync with #{server}"
 
       # -q: set system time and quit
       # -t: timeout in seconds
@@ -192,7 +193,7 @@
       deep_copy(@ntp_servers)
     end
 
-    # Get the mapping between country codea and names ("CZ" -> "Czech 
Republic")
+    # Get the mapping between country codes and names ("CZ" -> "Czech 
Republic")
     # @return a map the country codes and names mapping
     def GetCountryNames
       if @country_names.nil?
@@ -580,6 +581,12 @@
       { "install" => @required_packages, "remove" => [] }
     end
 
+    # Convenience method to obtain the list of ntp servers proposed by DHCP
+    # @see https://www.rubydoc.info/github/yast/yast-network/Yast/LanClass:${0}
+    def dhcp_ntp_servers
+      Yast::Lan.dhcp_ntp_servers
+    end
+
     publish variable: :AbortFunction, type: "boolean ()"
     publish variable: :modified, type: "boolean"
     publish variable: :write_only, type: "boolean"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ntp-client-4.1.3/test/ntp_client_proposal_test.rb 
new/yast2-ntp-client-4.1.5/test/ntp_client_proposal_test.rb
--- old/yast2-ntp-client-4.1.3/test/ntp_client_proposal_test.rb 2018-10-16 
11:03:32.000000000 +0200
+++ new/yast2-ntp-client-4.1.5/test/ntp_client_proposal_test.rb 2018-11-15 
12:08:24.000000000 +0100
@@ -1,3 +1,5 @@
+#! /usr/bin/env rspec
+
 require_relative "test_helper"
 
 require_relative "../src/clients/ntp-client_proposal.rb"
@@ -14,7 +16,7 @@
   describe "#Write" do
     let(:ntp_server) { "fake.pool.ntp.org" }
     let(:write_only) { false }
-    let(:ntpdate_only) { true }
+    let(:ntpdate_only) { false }
     let(:params) do
       {
         "server"       => ntp_server,
@@ -33,6 +35,7 @@
       allow(Yast::PackageSystem).to receive(:CheckAndInstallPackages)
       allow(Yast::Report).to receive(:Error)
       allow(Yast::NetworkService).to 
receive(:isNetworkRunning).and_return(network_running)
+      allow(Yast::Service).to 
receive(:Active).with(ntp_client.service_name).and_return(false)
     end
 
     context "with a not valid hostname" do
@@ -140,26 +143,33 @@
           expect(subject.Write(params)).to eq(:ntpdate_failed)
         end
 
-        it "returns :success if syncronization was successfully" do
+        it "returns :success if synchronization was successfully" do
           allow(Yast::NtpClient).to 
receive(:sync_once).with(ntp_server).and_return(0)
 
           expect(subject.Write(params)).to eq(:success)
         end
       end
 
-      context "and user only wants to syncronize date" do
-        it "writes settings only once" do
-          expect(subject).to receive(:WriteNtpSettings).once
+      context "and user only wants to synchronize date" do
+        let(:ntpdate_only) { true }
+
+        it "does not write settings" do
+          expect(subject).to_not receive(:WriteNtpSettings)
 
           subject.Write(params)
         end
-      end
 
-      context "and user wants to syncronize on boot" do
-        let(:ntpdate_only) { false }
+        it "does not try to synchronize if the service is running" do
+          allow(Yast::Service).to 
receive(:Active).with(ntp_client.service_name).and_return(true)
+          expect(Yast::NtpClient).to_not receive(:sync_once)
+
+          subject.Write(params)
+        end
+      end
 
-        it "writes settings again?" do
-          expect(subject).to receive(:WriteNtpSettings).twice
+      context "and user wants to synchronize on boot" do
+        it "writes settings only once" do
+          expect(subject).to receive(:WriteNtpSettings).once
 
           subject.Write(params)
         end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ntp-client-4.1.3/test/test_helper.rb 
new/yast2-ntp-client-4.1.5/test/test_helper.rb
--- old/yast2-ntp-client-4.1.3/test/test_helper.rb      2018-10-16 
11:03:32.000000000 +0200
+++ new/yast2-ntp-client-4.1.5/test/test_helper.rb      2018-11-15 
12:08:24.000000000 +0100
@@ -17,6 +17,15 @@
   end
 end
 
+# stub module to prevent its Import
+# Useful for modules from different yast packages, to avoid build dependencies
+def stub_module(name)
+  Yast.const_set name.to_sym, Class.new { def self.fake_method; end }
+end
+
+# stub classes from other modules to speed up a build
+stub_module("Lan")
+
 if ENV["COVERAGE"]
   require "simplecov"
   SimpleCov.start do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ntp-client-4.1.3/test/y2ntp_client/widgets/pool_widgets_test.rb 
new/yast2-ntp-client-4.1.5/test/y2ntp_client/widgets/pool_widgets_test.rb
--- old/yast2-ntp-client-4.1.3/test/y2ntp_client/widgets/pool_widgets_test.rb   
2018-10-16 11:03:32.000000000 +0200
+++ new/yast2-ntp-client-4.1.5/test/y2ntp_client/widgets/pool_widgets_test.rb   
2018-11-15 12:08:24.000000000 +0100
@@ -1,3 +1,4 @@
+#! /usr/bin/env rspec
 require_relative "../../test_helper"
 
 require "cwm/rspec"
@@ -21,8 +22,26 @@
   include_examples "CWM::CheckBox"
 end
 
-describe Y2NtpClient::Widgets::Iburst do
+describe Y2NtpClient::Widgets::Offline do
   subject { described_class.new({}) }
 
   include_examples "CWM::CheckBox"
 end
+
+describe Y2NtpClient::Widgets::LocalList do
+  subject { described_class.new({}) }
+
+  include_examples "CWM::ComboBox"
+end
+
+describe Y2NtpClient::Widgets::PublicList do
+  subject { described_class.new({}) }
+
+  include_examples "CWM::CustomWidget"
+end
+
+describe Y2NtpClient::Widgets::SelectFrom do
+  subject { described_class.new({}) }
+
+  include_examples "CWM::AbstractWidget"
+end


Reply via email to