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
6 changes: 3 additions & 3 deletions rust/agama-dbus-server/src/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::error::Error;
use agama_lib::connection_to;
use anyhow::Context;
use std::process::Command;
use zbus::dbus_interface;
use zbus::{dbus_interface, Connection};

pub struct Locale {
locales: Vec<String>,
Expand Down Expand Up @@ -187,7 +187,7 @@ impl Locale {
}
}

pub async fn start_service(address: &str) -> Result<(), Box<dyn std::error::Error>> {
pub async fn start_service(address: &str) -> Result<Connection, Box<dyn std::error::Error>> {
const SERVICE_NAME: &str = "org.opensuse.Agama.Locale1";
const SERVICE_PATH: &str = "/org/opensuse/Agama/Locale1";

Expand All @@ -203,5 +203,5 @@ pub async fn start_service(address: &str) -> Result<(), Box<dyn std::error::Erro
.await
.context(format!("Requesting name {SERVICE_NAME}"))?;

Ok(())
Ok(connection)
}
2 changes: 1 addition & 1 deletion rust/agama-dbus-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const ADDRESS: &str = "unix:path=/run/agama/bus";
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// When adding more services here, the order might be important.
crate::questions::start_service(ADDRESS).await?;
crate::locale::start_service(ADDRESS).await?;
let _conn = crate::locale::start_service(ADDRESS).await?;

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.

btw we should document that we need to store connection, otherwise it will drop whole dbus object. So next time we do not remove it :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, we should document it. Additionally, trying the approach I proposed in the description might help.

NetworkService::start(ADDRESS).await?;

// Do other things or go to wait forever
Expand Down