Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Feb 18, 2022
1 parent b113d82 commit 364ec4e
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 21 deletions.
21 changes: 0 additions & 21 deletions yastd/lib/yast2/dbus/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,6 @@ def initialize(installer, logger)
end
end

# SOFTWARE_INTERFACE = "org.opensuse.YaST.Installer1.Software"
# dbus_interface SOFTWARE_INTERFACE do
# dbus_attr_reader :available_base_products, "a(ssa{sv})"
# attr_writer :available_base_products
# dbus_watcher :available_base_products

# def selected_base_product
# installer.product
# end

# dbus_reader :selected_base_product, "s"


# dbus_method :SelectProduct, "in ProductID:s" do |product_id|
# logger.info "SelectProduct #{product_id}"

# installer.product = product_id
# self[DBus::PROPERTY_INTERFACE].PropertiesChanged(SOFTWARE_INTERFACE, {"SelectedBaseProduct" => product_id}, [])
# end
# end

private

PATH = "/org/opensuse/YaST/Installer1".freeze
Expand Down
77 changes: 77 additions & 0 deletions yastd/lib/yast2/dbus/software.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# frozen_string_literal: true

# Copyright (c) [2022] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "dbus"

module Yast2
module DBus
# YaST D-Bus object (/org/opensuse/YaST/Installer1)
#
# @see https://rubygems.org/gems/ruby-dbus
class Software < ::DBus::Object
attr_reader :installer, :logger

# @param installer [Yast2::Installer] YaST installer instance
# @param args [Array<Object>] ::DBus::Object arguments
def initialize(installer, logger)
@installer = installer
@logger = logger

super(PATH)
end

dbus_interface SOFTWARE_INTERFACE do
dbus_reader :available_base_products, "a(ssa{sv})"
attr_writer :available_base_products
dbus_watcher :available_base_products

dbus_reader :selected_base_product, "s"

dbus_method :SelectProduct, "in ProductID:s" do |product_id|
logger.info "SelectProduct #{product_id}"

select_product(product_id)
self[DBus::PROPERTY_INTERFACE].PropertiesChanged(SOFTWARE_INTERFACE, {"SelectedBaseProduct" => product_id}, [])
end
end

private

PATH = "/org/opensuse/YaST/Software1".freeze
private_constant :PATH

YAST_SOFTWARE_INTERFACE = "org.opensuse.YaST.Software1"
private_constant :YAST_SOFTWARE_INTERFACE

def available_base_products
@available_base_products ||= installer.products
end

def selected_base_product
installer.product
end

def select_product(product_id)
installer.product = product_id
end
end
end
end

0 comments on commit 364ec4e

Please sign in to comment.