Class: DInstaller::DBus::SoftwareService

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

Overview

D-Bus service (org.opensuse.DInstaller.Software)

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, logger = nil) ⇒ SoftwareService

Returns a new instance of SoftwareService.

Parameters:

  • Configuration object

  • (defaults to: nil)


43
44
45
46
47
48
# File 'lib/dinstaller/dbus/software_service.rb', line 43

def initialize(config, logger = nil)
  @logger = logger || Logger.new($stdout)
  @bus = ::DBus::SystemBus.instance
  @backend = DInstaller::Software.new(config, logger)
  @backend.on_progress_change { dispatch }
end

Instance Attribute Details

#bus::DBus::Connection (readonly)

D-Bus connection

Returns:



39
40
41
# File 'lib/dinstaller/dbus/software_service.rb', line 39

def bus
  @bus
end

Instance Method Details

#dispatchObject

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



58
59
60
# File 'lib/dinstaller/dbus/software_service.rb', line 58

def dispatch
  bus.dispatch_message_queue
end

#exportObject

Exports the software object through the D-Bus service



51
52
53
54
55
# File 'lib/dinstaller/dbus/software_service.rb', line 51

def export
  dbus_objects.each { |o| service.export(o) }
  paths = dbus_objects.map(&:path).join(", ")
  logger.info "Exported #{paths} objects"
end