Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions rust/agama-bootloader/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,20 @@ impl SetKernelArg {
Self { id, value }
}
}

#[derive(Clone)]
pub struct SetLocale {
pub locale: String,
}

impl SetLocale {
pub fn new(locale: &str) -> Self {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it already on few places, but in general I am not big fan of those &str param, then it used just to construct string..as there is no way if you already have String and want to just drop to method to simply avoid unnecessary clone.

Self {
locale: locale.to_string(),
}
}
}

impl Message for SetLocale {
type Reply = ();
}
7 changes: 7 additions & 0 deletions rust/agama-bootloader/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,10 @@ impl MessageHandler<message::SetKernelArg> for Service {
Ok(())
}
}

#[async_trait]
impl MessageHandler<message::SetLocale> for Service {
async fn handle(&mut self, _message: message::SetLocale) -> Result<(), Error> {
Ok(())
}
}
17 changes: 17 additions & 0 deletions rust/agama-files/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,20 @@ pub struct WriteFiles;
impl Message for WriteFiles {
type Reply = ();
}

#[derive(Clone)]
pub struct SetLocale {
pub locale: String,
}

impl SetLocale {
pub fn new(locale: &str) -> Self {
Self {
locale: locale.to_string(),
}
}
}

impl Message for SetLocale {
type Reply = ();
}
7 changes: 7 additions & 0 deletions rust/agama-files/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,10 @@ impl MessageHandler<message::WriteFiles> for Service {
Ok(())
}
}

#[async_trait]
impl MessageHandler<message::SetLocale> for Service {
async fn handle(&mut self, _message: message::SetLocale) -> Result<(), Error> {
Ok(())
}
}
17 changes: 17 additions & 0 deletions rust/agama-hostname/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,20 @@ pub struct Install;
impl Message for Install {
type Reply = ();
}

#[derive(Clone)]
pub struct SetLocale {
pub locale: String,
}

impl SetLocale {
pub fn new(locale: &str) -> Self {
Self {
locale: locale.to_string(),
}
}
}

impl Message for SetLocale {
type Reply = ();
}
7 changes: 7 additions & 0 deletions rust/agama-hostname/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,10 @@ impl MessageHandler<message::Install> for Service {
self.model.install()
}
}

#[async_trait]
impl MessageHandler<message::SetLocale> for Service {
async fn handle(&mut self, _message: message::SetLocale) -> Result<(), Error> {
Ok(())
}
}
17 changes: 17 additions & 0 deletions rust/agama-iscsi/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,20 @@ impl SetConfig {
impl Message for SetConfig {
type Reply = ();
}

#[derive(Clone)]
pub struct SetLocale {
pub locale: String,
}

impl SetLocale {
pub fn new(locale: &str) -> Self {
Self {
locale: locale.to_string(),
}
}
}

impl Message for SetLocale {
type Reply = ();
}
7 changes: 7 additions & 0 deletions rust/agama-iscsi/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,10 @@ impl MessageHandler<message::SetConfig> for Service {
Ok(())
}
}

#[async_trait]
impl MessageHandler<message::SetLocale> for Service {
async fn handle(&mut self, _message: message::SetLocale) -> Result<(), Error> {
Ok(())
}
}
7 changes: 7 additions & 0 deletions rust/agama-manager/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,15 @@ impl Service {
.call(l10n::message::SetSystem::new(config.clone()))
.await?;
if let Some(locale) = config.locale {
self.software
.cast(software::message::SetLocale::new(locale.as_str()))?;
self.storage
.cast(storage::message::SetLocale::new(locale.as_str()))?;
self.users
.cast(users::message::SetLocale::new(locale.as_str()))?;
if let Some(s390) = &self.s390 {
s390.cast(s390::message::SetLocale::new(locale.as_str()))?;
}
}
Ok(())
}
Expand Down
2 changes: 2 additions & 0 deletions rust/agama-network/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,6 @@ pub enum Action {
RemoveConnection(String, Responder<Result<(), NetworkStateError>>),
/// Apply the current configuration.
Apply(Responder<Result<(), NetworkAdapterError>>),
/// Sets the locale
SetLocale(String),
}
11 changes: 10 additions & 1 deletion rust/agama-network/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,22 @@ impl NetworkSystemClient {
Ok(result?)
}

/// Proposes the default network configuration.
/// Propose the default network configuration.
pub async fn propose_default(&self) -> Result<(), NetworkSystemError> {
let (tx, rx) = oneshot::channel();
self.actions.send(Action::ProposeDefault(tx))?;
let result = rx.await?;
Ok(result?)
}

/// Sets the locale.
pub fn set_locale(&self, locale: String) -> Result<(), NetworkSystemError> {
self.actions.send(Action::SetLocale(locale))?;
Ok(())
}

/// Copies the persistent network connections to the target system.

pub async fn install(&self) -> Result<(), NetworkSystemError> {
let (tx, rx) = oneshot::channel();
self.actions.send(Action::Install(tx))?;
Expand Down Expand Up @@ -458,6 +466,7 @@ impl Service {
let result = self.state.install().await;
tx.send(result).unwrap();
}
Action::SetLocale(_) => {}
}

Ok(None)
Expand Down
17 changes: 17 additions & 0 deletions rust/agama-proxy/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,20 @@ pub struct Finish;
impl Message for Finish {
type Reply = ();
}

#[derive(Clone)]
pub struct SetLocale {
pub locale: String,
}

impl SetLocale {
pub fn new(locale: &str) -> Self {
Self {
locale: locale.to_string(),
}
}
}

impl Message for SetLocale {
type Reply = ();
}
7 changes: 7 additions & 0 deletions rust/agama-proxy/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ impl MessageHandler<message::Finish> for Service {
}
}

#[async_trait]
impl MessageHandler<message::SetLocale> for Service {
async fn handle(&mut self, _message: message::SetLocale) -> Result<(), Error> {
Ok(())
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
17 changes: 17 additions & 0 deletions rust/agama-s390/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,20 @@ impl SetConfig {
impl Message for SetConfig {
type Reply = ();
}

#[derive(Clone)]
pub struct SetLocale {
pub locale: String,
}

impl SetLocale {
pub fn new(locale: &str) -> Self {
Self {
locale: locale.to_string(),
}
}
}

impl Message for SetLocale {
type Reply = ();
}
8 changes: 8 additions & 0 deletions rust/agama-s390/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,11 @@ impl MessageHandler<message::SetConfig> for Service {
Ok(())
}
}

#[async_trait]
impl MessageHandler<message::SetLocale> for Service {
async fn handle(&mut self, _message: message::SetLocale) -> Result<(), Error> {
self.zfcp.probe().await?;
Ok(())
}
}
17 changes: 17 additions & 0 deletions rust/agama-security/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,20 @@ pub struct Finish;
impl Message for Finish {
type Reply = ();
}

#[derive(Clone)]
pub struct SetLocale {
pub locale: String,
}

impl SetLocale {
pub fn new(locale: &str) -> Self {
Self {
locale: locale.to_string(),
}
}
}

impl Message for SetLocale {
type Reply = ();
}
7 changes: 7 additions & 0 deletions rust/agama-security/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,10 @@ impl MessageHandler<message::Finish> for Service {
Ok(())
}
}

#[async_trait]
impl MessageHandler<message::SetLocale> for Service {
async fn handle(&mut self, _message: message::SetLocale) -> Result<(), Error> {
Ok(())
}
}
17 changes: 17 additions & 0 deletions rust/agama-software/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,20 @@ impl SetResolvables {
impl Message for SetResolvables {
type Reply = ();
}

#[derive(Clone)]
pub struct SetLocale {
pub locale: String,
}

impl SetLocale {
pub fn new(locale: &str) -> Self {
Self {
locale: locale.to_string(),
}
}
}

impl Message for SetLocale {
type Reply = ();
}
8 changes: 4 additions & 4 deletions rust/agama-software/src/model/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct RepoKey {
///
/// The SoftwareState is built by the [SoftwareStateBuilder] using different
/// sources (the product specification, the user configuration, etc.).
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct SoftwareState {
pub product: String,
pub repositories: Vec<Repository>,
Expand Down Expand Up @@ -449,7 +449,7 @@ impl SoftwareState {
}

/// Defines a repository.
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct Repository {
pub alias: String,
pub name: String,
Expand Down Expand Up @@ -482,7 +482,7 @@ impl From<&agama_utils::api::software::Repository> for Repository {
/// Holds states for resolvables.
///
/// Check the [ResolvableSelection] enum for possible states.
#[derive(Debug, Default)]
#[derive(Clone, Debug, Default)]
pub struct ResolvablesState(HashMap<(String, ResolvableType), ResolvableSelection>);

impl ResolvablesState {
Expand Down Expand Up @@ -595,7 +595,7 @@ impl From<ResolvableSelection> for zypp_agama::ResolvableSelected {
}

/// Software system options.
#[derive(Default, Debug)]
#[derive(Clone, Default, Debug)]
pub struct SoftwareOptions {
/// Install only required packages (not recommended ones).
pub only_required: bool,
Expand Down
Loading
Loading