Module: DInstaller::DBus::Interfaces::ServiceStatus

Included in:
Manager, Software::Manager, Storage::Proposal, Users
Defined in:
lib/dinstaller/dbus/interfaces/service_status.rb

Overview

Note:

This mixin is expected to be included in a class inherited from DBus::Object and it requires a #service_status method that returns a ServiceStatus object.

Mixin to define the ServiceStatus D-Bus interface

Examples:

class Demo < ::DBus::Object
  include DInstaller::DBus::Interfaces::ServiceStatus

  def initialize
    super("org.test.Demo")
    register_service_status_callbacks
  end

  def service_status
    @service_status ||= DInstaller::DBus::ServiceStatus.new
end

Constant Summary collapse

SERVICE_STATUS_INTERFACE =
"org.opensuse.DInstaller.ServiceStatus1"
SERVICE_STATUS_IDLE =
0
SERVICE_STATUS_BUSY =
1

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



78
79
80
81
82
83
84
85
# File 'lib/dinstaller/dbus/interfaces/service_status.rb', line 78

def self.included(base)
  base.class_eval do
    dbus_interface SERVICE_STATUS_INTERFACE do
      dbus_reader :service_status_all, "aa{sv}", dbus_name: "All"
      dbus_reader :service_status_current, "u", dbus_name: "Current"
    end
  end
end

Instance Method Details

#register_service_status_callbacksObject

Note:

This method is expected to be called in the constructor.

Registers callbacks to be called when the value of the service status changes



71
72
73
74
75
76
# File 'lib/dinstaller/dbus/interfaces/service_status.rb', line 71

def register_service_status_callbacks
  service_status.on_change do
    dbus_properties_changed(SERVICE_STATUS_INTERFACE,
      { "Current" => service_status_current }, [])
  end
end

#service_status_allArray<Hash>

Description of all possible service status values

Returns:

  • (Array<Hash>)


54
55
56
57
58
59
# File 'lib/dinstaller/dbus/interfaces/service_status.rb', line 54

def service_status_all
  [
    { "id" => SERVICE_STATUS_IDLE, "label" => "idle" },
    { "id" => SERVICE_STATUS_BUSY, "label" => "busy" }
  ]
end

#service_status_currentInteger

Current value of the service status

Returns:

  • (Integer)


64
65
66
# File 'lib/dinstaller/dbus/interfaces/service_status.rb', line 64

def service_status_current
  service_status.busy? ? SERVICE_STATUS_BUSY : SERVICE_STATUS_IDLE
end