Class: DInstaller::DBus::ManagerService

Inherits:
Object
  • Object
show all
Defined in:
lib/dinstaller/dbus/manager_service.rb

Overview

D-Bus service (org.opensuse.DInstaller)

It connects to the system D-Bus and answers requests on objects below ‘/org/opensuse/DInstaller`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, logger = nil) ⇒ ManagerService

Returns a new instance of ManagerService.

Parameters:

  • config (Config)

    Configuration

  • logger (Logger) (defaults to: nil)


55
56
57
58
59
60
# File 'lib/dinstaller/dbus/manager_service.rb', line 55

def initialize(config, logger = nil)
  @config = config
  @manager = DInstaller::Manager.new(config, logger)
  @logger = logger || Logger.new($stdout)
  @bus = ::DBus::SystemBus.instance
end

Instance Attribute Details

#bus::DBus::Connection (readonly)

System D-Bus

Returns:

  • (::DBus::Connection)


46
47
48
# File 'lib/dinstaller/dbus/manager_service.rb', line 46

def bus
  @bus
end

#managerDInstaller::Manager (readonly)

Installation manager

Returns:



51
52
53
# File 'lib/dinstaller/dbus/manager_service.rb', line 51

def manager
  @manager
end

Instance Method Details

#dispatchObject

Call this from some main loop to dispatch the D-Bus messages



81
82
83
# File 'lib/dinstaller/dbus/manager_service.rb', line 81

def dispatch
  bus.dispatch_message_queue
end

#exportObject

Exports the installer object through the D-Bus service



73
74
75
76
77
78
# File 'lib/dinstaller/dbus/manager_service.rb', line 73

def export
  dbus_objects.each { |o| service.export(o) }

  paths = dbus_objects.map(&:path).join(", ")
  logger.info "Exported #{paths} objects"
end

#startObject

Note:

The service runs its startup phase

Initializes and exports the D-Bus API



65
66
67
68
69
70
# File 'lib/dinstaller/dbus/manager_service.rb', line 65

def start
  setup_cockpit
  export
  manager.on_progress_change { dispatch } # make single thread more responsive
  manager.startup_phase
end