Skip to content

Commit

Permalink
Fix the ConnectionAdded signal emission
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Dec 26, 2023
1 parent ac9b791 commit ee7270f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,16 @@ impl Connections {
&mut self,
id: String,
ty: u8,
#[zbus(signal_context)] ctxt: SignalContext<'_>,
) -> zbus::fdo::Result<OwnedObjectPath> {
let actions = self.actions.lock().await;
let (tx, rx) = oneshot::channel();
actions
.send(Action::AddConnection(id.clone(), ty.try_into()?, tx))
.unwrap();
let result = rx.await.unwrap()?;
Ok(result)
let path = rx.await.unwrap()?;
Self::connection_added(&ctxt, &id, &path).await?;
Ok(path)
}

/// Returns the D-Bus path of the network connection.
Expand Down
17 changes: 0 additions & 17 deletions rust/agama-dbus-server/src/network/dbus/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ impl Tree {
.await?;
}

if notify {
self.notify_connection_added(&orig_id, &path).await?;
}

Ok(path.into())
}

Expand Down Expand Up @@ -202,19 +198,6 @@ impl Tree {
let object_server = self.connection.object_server();
Ok(object_server.at(path, iface).await?)
}

/// Notify that a new connection has been added
async fn notify_connection_added(
&self,
id: &str,
path: &ObjectPath<'_>,
) -> Result<(), ServiceError> {
let object_server = self.connection.object_server();
let iface_ref = object_server
.interface::<_, interfaces::Connections>(CONNECTIONS_PATH)
.await?;
Ok(interfaces::Connections::connection_added(iface_ref.signal_context(), id, path).await?)
}
}

/// Objects paths for known devices and connections
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-lib/src/network/proxies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ trait Connections {
///
/// `name`: connection name.
/// `ty`: connection type.
fn add_connection(&self, name: &str, ty: u8) -> zbus::Result<()>;
fn add_connection(&self, name: &str, ty: u8) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;

/// Apply method
fn apply(&self) -> zbus::Result<()>;
Expand Down

0 comments on commit ee7270f

Please sign in to comment.