diff --git a/README.md b/README.md
index 8d210fbb11..1dde91cd16 100644
--- a/README.md
+++ b/README.md
@@ -63,7 +63,7 @@ Agama consists on a set of D-Bus services and a web client (an experimental CLI
* Agama service: it is the main service which manages and controls the installation process.
* Software service: configures the product and software to install.
* Users service: manages first user creation and configuration for root.
-* Language service: allows to configure the language and keyboard settings.
+* Localization service: allows to configure the language and keyboard settings.
* Storage service: analyzes and prepares the storage devices in order to perform the installation.
* Questions service: helper service used for requesting information from clients.
@@ -138,10 +138,10 @@ $ busctl --address=unix:path=/run/agama/bus \
$ busctl --address=unix:path=/run/agama/bus \
call \
- org.opensuse.Agama.Language1 \
- /org/opensuse/Agama/Language1 \
+ org.opensuse.Agama.Locale1 \
+ /org/opensuse/Agama/Locale1 \
org.freedesktop.DBus.Properties \
- GetAll s org.opensuse.Agama.Language1
+ GetAll s org.opensuse.Agama.Locale1
```
## How to Contribute
diff --git a/doc/dbus/bus/org.opensuse.Agama.Language1.bus.xml b/doc/dbus/bus/org.opensuse.Agama.Language1.bus.xml
deleted file mode 100644
index 1ab8363dd8..0000000000
--- a/doc/dbus/bus/org.opensuse.Agama.Language1.bus.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/doc/dbus/bus/org.opensuse.Agama.Locale1.bus.xml b/doc/dbus/bus/org.opensuse.Agama.Locale1.bus.xml
new file mode 100644
index 0000000000..b3b346f936
--- /dev/null
+++ b/doc/dbus/bus/org.opensuse.Agama.Locale1.bus.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/dbus/bus/seed.sh b/doc/dbus/bus/seed.sh
index 32a0f15fb5..570d248502 100755
--- a/doc/dbus/bus/seed.sh
+++ b/doc/dbus/bus/seed.sh
@@ -15,7 +15,7 @@ look() {
> $DD.$1.bus.xml
}
-look Language1
+look Locale1
look Questions1
look Software1
look Software1.Proposal
diff --git a/doc/dbus/org.opensuse.Agama.Language1.doc.xml b/doc/dbus/org.opensuse.Agama.Language1.doc.xml
deleted file mode 100644
index f5c295055c..0000000000
--- a/doc/dbus/org.opensuse.Agama.Language1.doc.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/doc/dbus/org.opensuse.Agama.Locale1.doc.xml b/doc/dbus/org.opensuse.Agama.Locale1.doc.xml
new file mode 100644
index 0000000000..19abfbf81f
--- /dev/null
+++ b/doc/dbus/org.opensuse.Agama.Locale1.doc.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/dbus_api.md b/doc/dbus_api.md
index 08ef92174c..531f6936d8 100644
--- a/doc/dbus_api.md
+++ b/doc/dbus_api.md
@@ -19,7 +19,7 @@ should be prevented and instead use for that struct or dictionary object.
### Localization
-We also discuss aproach how to solve localization of some strings like language human names,
+We also discuss approach how to solve localization of some strings like language human names,
error messages from some scripts or strings from libraries.
Setting locale for whole service is basically discouraged as there can be multiple clients
working with given service, e.g. some log collector beside user doing setup.
@@ -44,12 +44,12 @@ We use these resources to get more familiar with D-Bus API designing.
## Language
-Iface: o.o.Agama.Language1
+Iface: o.o.Agama.Locale1
See the new-style [reference][lang-ref] ([source][lang-src]).
-[lang-ref]: https://opensuse.github.io/agama/dbus/ref-org.opensuse.Agama.Language1.html
-[lang-src]: dbus/org.opensuse.Agama.Language1.doc.xml
+[lang-ref]: https://opensuse.github.io/agama/dbus/ref-org.opensuse.Agama.Locale1.html
+[lang-src]: dbus/org.opensuse.Agama.Locale1.doc.xml
## Base Product
diff --git a/rust/agama-dbus-server/src/locale.rs b/rust/agama-dbus-server/src/locale.rs
index ec0bcef66e..12caf0ff2e 100644
--- a/rust/agama-dbus-server/src/locale.rs
+++ b/rust/agama-dbus-server/src/locale.rs
@@ -13,11 +13,11 @@ pub struct LocaleService {
#[dbus_interface(name = "org.opensuse.Agama.Locale1")]
impl LocaleService {
- // Can be `async` as well.
- /// get labels for given locale. The first pair is english language and territory
+ /// Get labels for locales. The first pair is english language and territory
/// and second one is localized one to target language from locale.
///
- /// Note: check how often it is used and if often, it can be easily cached
+ // Can be `async` as well.
+ // NOTE: check how often it is used and if often, it can be easily cached
fn labels_for_locales(&self) -> Result, Error> {
const DEFAULT_LANG: &str = "en";
let mut res = Vec::with_capacity(self.supported_locales.len());
diff --git a/rust/agama-lib/src/proxies.rs b/rust/agama-lib/src/proxies.rs
index 17301cb1fe..4cd58408f3 100644
--- a/rust/agama-lib/src/proxies.rs
+++ b/rust/agama-lib/src/proxies.rs
@@ -75,33 +75,40 @@ trait Manager {
) -> zbus::Result>>;
}
-#[dbus_proxy(
- interface = "org.opensuse.Agama.Language1",
- default_service = "org.opensuse.Agama.Language1",
- default_path = "/org/opensuse/Agama/Language1"
-)]
-trait Language1 {
- /// Finish method
- fn finish(&self) -> zbus::Result<()>;
+#[dbus_proxy(interface = "org.opensuse.Agama.Locale1", assume_defaults = true)]
+trait Locale1 {
+ /// Commit method
+ fn commit(&self) -> zbus::Result<()>;
+
+ /// LabelsForLocales method
+ fn labels_for_locales(&self) -> zbus::Result>;
+
+ /// ListTimezones method
+ fn list_timezones(&self, locale: &str) -> zbus::Result>;
- /// ToInstall method
- fn to_install(&self, lang_ids: &[&str]) -> zbus::Result<()>;
+ /// ListVConsoleKeyboards method
+ #[dbus_proxy(name = "ListVConsoleKeyboards")]
+ fn list_vconsole_keyboards(&self) -> zbus::Result>;
- /// AvailableLanguages property
+ /// Locales property
#[dbus_proxy(property)]
- fn available_languages(
- &self,
- ) -> zbus::Result<
- Vec<(
- String,
- String,
- std::collections::HashMap,
- )>,
- >;
+ fn locales(&self) -> zbus::Result>;
+ fn set_locales(&self, value: &[&str]) -> zbus::Result<()>;
+
+ /// SupportedLocales property
+ #[dbus_proxy(property)]
+ fn supported_locales(&self) -> zbus::Result>;
+ fn set_supported_locales(&self, value: &[&str]) -> zbus::Result<()>;
- /// MarkedForInstall property
+ /// Timezone property
#[dbus_proxy(property)]
- fn marked_for_install(&self) -> zbus::Result>;
+ fn timezone(&self) -> zbus::Result;
+ fn set_timezone(&self, value: &str) -> zbus::Result<()>;
+
+ /// VConsoleKeyboard property
+ #[dbus_proxy(property, name = "VConsoleKeyboard")]
+ fn vconsole_keyboard(&self) -> zbus::Result;
+ fn set_vconsole_keyboard(&self, value: &str) -> zbus::Result<()>;
}
#[dbus_proxy(
diff --git a/service/lib/agama/dbus/language.rb b/service/lib/agama/dbus/language.rb
deleted file mode 100644
index 2ebed065df..0000000000
--- a/service/lib/agama/dbus/language.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-# 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"
-require "agama/language"
-require "agama/errors"
-
-module Agama
- module DBus
- # YaST D-Bus object (/org/opensuse/Agama/Language1)
- #
- # @see https://rubygems.org/gems/ruby-dbus
- class Language < ::DBus::Object
- PATH = "/org/opensuse/Agama/Language1"
- private_constant :PATH
-
- LANGUAGE_INTERFACE = "org.opensuse.Agama.Language1"
- private_constant :LANGUAGE_INTERFACE
-
- # @param backend [Agama::Language]
- # @param logger [Logger]
- def initialize(backend, logger)
- @backend = backend
- @logger = logger
-
- super(PATH)
- end
-
- dbus_interface LANGUAGE_INTERFACE do
- attr_accessor :available_languages
-
- dbus_reader :available_languages, "a(ssa{sv})"
-
- dbus_reader :marked_for_install, "as"
-
- dbus_method :ToInstall, "in LangIDs:as" do |lang_ids|
- logger.info "ToInstall #{lang_ids.inspect}"
- result = select_to_install(lang_ids)
-
- dbus_properties_changed(LANGUAGE_INTERFACE, { "MarkedForInstall" => lang_ids }, [])
- result ? 0 : 1
- end
-
- dbus_method(:Finish) { finish }
- end
-
- def available_languages
- @available_languages ||= backend.languages.map { |k, v| [k, v.first, {}] }
- end
-
- def marked_for_install
- # TODO: change when installer support multiple target languages
- result = [backend.language]
- logger.info "MarkedForInstall #{result}"
- result
- end
-
- def select_to_install(lang_ids)
- backend.language = lang_ids.first
- true
- rescue Errors::InvalidValue
- false
- end
-
- def finish
- backend.finish
- end
-
- private
-
- attr_reader :logger
- attr_reader :backend
- end
- end
-end
diff --git a/service/lib/agama/dbus/language_service.rb b/service/lib/agama/dbus/language_service.rb
deleted file mode 100644
index 94729e7e5f..0000000000
--- a/service/lib/agama/dbus/language_service.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-# 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"
-require "agama/dbus/bus"
-require "agama/dbus/language"
-require "agama/language"
-
-module Agama
- module DBus
- # D-Bus service (org.opensuse.Agama.Language1)
- #
- # It connects to the system D-Bus and answers requests on objects below
- # `/org/opensuse/Agama/Language1`.
- class LanguageService
- # Service name
- #
- # @return [String]
- SERVICE_NAME = "org.opensuse.Agama.Language1"
- private_constant :SERVICE_NAME
-
- # System D-Bus
- #
- # @return [::DBus::Connection]
- attr_reader :bus
-
- # @param _config [Config] Configuration object
- # @param logger [Logger]
- def initialize(_config, logger = nil)
- @logger = logger || Logger.new($stdout)
- @bus = Bus.current
- end
-
- # Exports the installer object through the D-Bus service
- def export
- dbus_objects.each { |o| service.export(o) }
-
- paths = dbus_objects.map(&:path).join(", ")
- logger.info "Exported #{paths} objects"
- end
-
- # Call this from some main loop to dispatch the D-Bus messages
- def dispatch
- bus.dispatch_message_queue
- end
-
- private
-
- # @return [Logger]
- attr_reader :logger
-
- # @return [::DBus::Service]
- def service
- @service ||= bus.request_service(SERVICE_NAME)
- end
-
- # @return [Array<::DBus::Object>]
- def dbus_objects
- @dbus_objects ||= [
- language_dbus
- ]
- end
-
- # @return [Agama::DBus::Language]
- def language_dbus
- @language_dbus ||= Agama::DBus::Language.new(language_backend(logger), logger)
- end
-
- # @return [Agama::Language]
- def language_backend(logger)
- @language_backend ||= Agama::Language.new(logger).tap(&:probe)
- end
- end
- end
-end
diff --git a/service/lib/agama/language.rb b/service/lib/agama/language.rb
deleted file mode 100644
index 5c5becf857..0000000000
--- a/service/lib/agama/language.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-# 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 "yast"
-require "agama/errors"
-
-Yast.import "Language"
-
-module Agama
- # Backend for handling language settings
- class Language
- # @return [Hash>>] Known languages, where the key
- # is the language code and value is an array containing the translated name,
- # the english name, etc.
- attr_reader :languages
-
- def initialize(logger)
- @logger = logger
- @languages = []
- end
-
- # Probes the available system languages
- def probe
- logger.info "Probing languages"
- @languages = Yast::Language.GetLanguagesMap(true)
- end
-
- # Writes the language settings
- def finish
- Yast::Language.Save
- end
-
- # Sets the language
- #
- # @param name [String] Language code
- # @raise Errors::InvalidValue
- def language=(name)
- raise Errors::InvalidValue unless languages.include?(name)
-
- Yast::Language.Set(name)
- Yast::Language.languages = Yast::Language.RemoveSuffix(name)
- end
-
- # Returns the selected language
- #
- # @return [String] Language code
- def language
- Yast::Language.language
- end
-
- private
-
- attr_reader :logger
- end
-end
diff --git a/service/package/rubygem-agama.changes b/service/package/rubygem-agama.changes
index 06fbfabea2..301948090d 100644
--- a/service/package/rubygem-agama.changes
+++ b/service/package/rubygem-agama.changes
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Wed Jun 7 05:33:27 UTC 2023 - Imobach Gonzalez Sosa
+
+- Drop the old `org.opensuse.Agama.Language1` which was replaced
+ with `org.opensuse.Agama.Locale1` (gh#openSUSE/agama#608).
+
-------------------------------------------------------------------
Wed May 24 15:43:41 UTC 2023 - Ancor Gonzalez Sosa
diff --git a/service/share/org.opensuse.Agama.Language1.service b/service/share/org.opensuse.Agama.Language1.service
deleted file mode 100644
index 6b3c34b193..0000000000
--- a/service/share/org.opensuse.Agama.Language1.service
+++ /dev/null
@@ -1,4 +0,0 @@
-[D-BUS Service]
-Name=org.opensuse.Agama.Language1
-Exec=/usr/bin/agamactl language
-User=root
diff --git a/service/test/agama/dbus/language_test.rb b/service/test/agama/dbus/language_test.rb
deleted file mode 100644
index 3338142fc5..0000000000
--- a/service/test/agama/dbus/language_test.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-# 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_relative "../../test_helper"
-require "agama/dbus/language"
-require "agama/errors"
-require "agama/language"
-require "agama/progress"
-
-describe Agama::DBus::Language do
- subject { described_class.new(backend, logger) }
-
- let(:backend) do
- instance_double(Agama::Language, languages: languages, language: "de_DE")
- end
-
- let(:logger) { Logger.new($stdout) }
-
- let(:languages) do
- {
- "en_US" => ["English (US)", "English (US)", ".UTF-8", "", "English (US)"],
- "de_DE" => ["Deutsch", "Deutsch", ".UTF-8", "@euro", "German"]
- }
- end
-
- describe "#available_languages" do
- it "returns the list of available languages" do
- expect(subject.available_languages).to eq(
- [["en_US", "English (US)", {}], ["de_DE", "Deutsch", {}]]
- )
- end
- end
-
- describe "#marked_for_install" do
- it "returns the languages that are selected for installation" do
- expect(subject.marked_for_install).to eq(["de_DE"])
- end
- end
-
- describe "#select_to_install" do
- before do
- allow(backend).to receive(:language=)
- end
-
- it "selects the first given language for installation" do
- expect(backend).to receive(:language=).with("de_DE")
- subject.select_to_install(["de_DE", "en_US"])
- end
-
- it "returns true" do
- expect(subject.select_to_install(["de_DE"])).to eq(true)
- end
-
- context "when the language does not exists" do
- before do
- allow(backend).to receive(:language=).and_raise(Agama::Errors::InvalidValue)
- end
-
- it "returns false" do
- expect(subject.select_to_install(["unknown"])).to eq(false)
- end
- end
- end
-
- describe "#finish" do
- it "finishes the language installation" do
- expect(backend).to receive(:finish)
- subject.finish
- end
- end
-end
diff --git a/service/test/agama/language_test.rb b/service/test/agama/language_test.rb
deleted file mode 100644
index 41530b97a4..0000000000
--- a/service/test/agama/language_test.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-# 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_relative "../test_helper"
-require "agama/language"
-
-Yast.import "Language"
-
-describe Agama::Language do
- subject { described_class.new(logger) }
-
- let(:logger) { Logger.new($stdout, level: :warn) }
-
- describe "#probe" do
- let(:languages) do
- {
- "en_US" => ["English (US)", "English (US)", ".UTF-8", "", "English (US)"],
- "de_DE" => ["Deutsch", "Deutsch", ".UTF-8", "@euro", "German"]
- }
- end
-
- before do
- allow(Yast::Language).to receive(:GetLanguagesMap).with(true).and_return(languages)
- end
-
- it "reads the list of languages" do
- expect(subject.languages).to be_empty
- subject.probe
- expect(subject.languages).to eq(languages)
- end
- end
-
- describe "#finish" do
- it "writes language settings" do
- expect(Yast::Language).to receive(:Save)
- subject.finish
- end
- end
-
- describe "#language=" do
- before do
- subject.probe
- end
-
- it "sets the language and selects the related packages" do
- expect(Yast::Language).to receive(:Set).with("de_DE")
- subject.language = "de_DE"
- end
-
- context "if the language is unknown" do
- it "raise an InvalidValue exception" do
- expect { subject.language = "unknown" }.to raise_error(Agama::Errors::InvalidValue)
- end
- end
- end
-end