Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #932 Fixed #1

Merged
merged 32 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dec964e
Add an 'Active' property to the Connection interface
imobachgs Dec 20, 2023
45d2ba7
AddConnection returns the D-Bus path of the new connection
imobachgs Dec 20, 2023
e192989
Better name for a channel variable
imobachgs Dec 20, 2023
6aad653
Use channels in the *.Network.Connection interface
imobachgs Dec 20, 2023
c2d906e
Split interfaces.rs into smaller files
imobachgs Dec 20, 2023
932de66
Use channels in the *.Connection.Wireless D-Bus interface
imobachgs Dec 20, 2023
116aaa9
Reduce the size of the Action enum variants
imobachgs Dec 20, 2023
ba90e0e
Add some basic rustfmt configuration
imobachgs Dec 21, 2023
ac9b791
Use channels in the *.Connection.IPConfig interface
imobachgs Dec 26, 2023
3804859
Fix the ConnectionAdded signal emission
imobachgs Dec 26, 2023
16cada3
Drop an unneeded variable
imobachgs Dec 26, 2023
be094a5
Implement conversions to/from ConnectionConfig
imobachgs Dec 26, 2023
615d4a1
Reduce D-Bus network interface code by using traits
imobachgs Dec 27, 2023
3eb41cd
Documentation fixes
imobachgs Dec 27, 2023
3deeadc
Improve D-Bus network interface (#961)
imobachgs Dec 27, 2023
7b00e7e
Fix several issues detected by Clippy
imobachgs Dec 27, 2023
4a76c9e
Rename agama-dbus-server "locale" to "l10n"
imobachgs Dec 27, 2023
c7d43c8
Define some 'types' for D-Bus proxies
imobachgs Dec 27, 2023
d5860fa
Run Clippy in CI
imobachgs Dec 27, 2023
9bbf3a4
Update service PO files
yast-bot Dec 28, 2023
334f7d0
Update service PO files (#963)
imobachgs Dec 28, 2023
c8bb1fe
Adapt the code to Clippy suggestions (#962)
imobachgs Dec 28, 2023
bc6ef3a
Update service PO files
yast-bot Dec 28, 2023
51abf8d
Update service PO files (#964)
imobachgs Dec 28, 2023
96036d4
Drop the ObjectsRegistry mutex
imobachgs Dec 28, 2023
d83b01e
Use async_trait in the network Adapter trait
imobachgs Dec 28, 2023
7d84f6d
Set minimal Rust version to 1.74
imobachgs Dec 29, 2023
f652948
Improve ServiceError reporting
imobachgs Dec 28, 2023
e4ae7ed
Drop objects registry mutex (#965)
imobachgs Dec 29, 2023
1c9ec66
Avoid a deadlock updating the network D-Bus tree
imobachgs Dec 29, 2023
c40e251
Log an error when the D-Bus tree cannot be updated
imobachgs Dec 29, 2023
d9b0131
Avoid a deadlock updating the network D-Bus tree (#966)
imobachgs Dec 29, 2023
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
9 changes: 6 additions & 3 deletions .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ jobs:
- name: Install Rust toolchains
run: rustup toolchain install stable

- name: Run clippy linter
run: cargo clippy

- name: Run rustfmt
run: cargo fmt --all -- --check

- name: Install cargo-binstall
uses: taiki-e/install-action@v2
with:
Expand All @@ -89,9 +95,6 @@ jobs:
- name: Run the tests
run: cargo tarpaulin --out xml

- name: Lint formatting
run: cargo fmt --all -- --check

# send the code coverage for the Rust part to the coveralls.io
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2
Expand Down
5 changes: 3 additions & 2 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ members = [
"agama-derive",
"agama-lib",
"agama-locale-data",
"agama-settings"
"agama-settings",
]
resolver = "2"

[workspace.package]
rust-version = "1.74"
edition = "2021"
7 changes: 2 additions & 5 deletions rust/agama-cli/src/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl LogItem for LogCmd {

/// Collect existing / requested paths which should already exist in the system.
/// Turns them into list of log sources
fn paths_to_log_sources(paths: &Vec<String>, tmp_dir: &TempDir) -> Vec<Box<dyn LogItem>> {
fn paths_to_log_sources(paths: &[String], tmp_dir: &TempDir) -> Vec<Box<dyn LogItem>> {
let mut log_sources: Vec<Box<dyn LogItem>> = Vec::new();

for path in paths.iter() {
Expand All @@ -293,10 +293,7 @@ fn paths_to_log_sources(paths: &Vec<String>, tmp_dir: &TempDir) -> Vec<Box<dyn L
}

/// Some info can be collected via particular commands only, turn it into log sources
fn cmds_to_log_sources(
commands: &Vec<(String, String)>,
tmp_dir: &TempDir,
) -> Vec<Box<dyn LogItem>> {
fn cmds_to_log_sources(commands: &[(String, String)], tmp_dir: &TempDir) -> Vec<Box<dyn LogItem>> {
let mut log_sources: Vec<Box<dyn LogItem>> = Vec::new();

for cmd in commands.iter() {
Expand Down
6 changes: 4 additions & 2 deletions rust/agama-dbus-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
name = "agama-dbus-server"
version = "0.1.0"
edition = "2021"
rust-version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0"
agama-locale-data = { path="../agama-locale-data" }
agama-lib = { path="../agama-lib" }
agama-locale-data = { path = "../agama-locale-data" }
agama-lib = { path = "../agama-lib" }
log = "0.4"
simplelog = "0.12.1"
systemd-journal-logger = "1.0"
Expand All @@ -25,3 +26,4 @@ gettext-rs = { version = "0.7.0", features = ["gettext-system"] }
regex = "1.10.2"
once_cell = "1.18.0"
macaddr = "1.0"
async-trait = "0.1.75"
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ mod tests {
fn test_read_timezone_without_country() {
let mut db = TimezonesDatabase::new();
db.read("es").unwrap();
let timezone = db
.entries()
.into_iter()
.find(|tz| tz.code == "UTC")
.unwrap();
let timezone = db.entries().iter().find(|tz| tz.code == "UTC").unwrap();
assert_eq!(timezone.country, None);
}

Expand All @@ -145,7 +141,7 @@ mod tests {
db.read("en").unwrap();
let timezone = db
.entries()
.into_iter()
.iter()
.find(|tz| tz.code == "Europe/Kiev")
.unwrap();
assert_eq!(timezone.country, Some("Ukraine".to_string()));
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-dbus-server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod error;
pub mod locale;
pub mod l10n;
pub mod network;
pub mod questions;
7 changes: 5 additions & 2 deletions rust/agama-dbus-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use agama_dbus_server::{locale, locale::helpers, network, questions};
use agama_dbus_server::{
l10n::{self, helpers},
network, questions,
};

use agama_lib::connection_to;
use anyhow::Context;
Expand Down Expand Up @@ -36,7 +39,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// When adding more services here, the order might be important.
questions::export_dbus_objects(&connection).await?;
log::info!("Started questions interface");
locale::export_dbus_objects(&connection, &locale).await?;
l10n::export_dbus_objects(&connection, &locale).await?;
log::info!("Started locale interface");
network::export_dbus_objects(&connection).await?;
log::info!("Started network interface");
Expand Down
21 changes: 18 additions & 3 deletions rust/agama-dbus-server/src/network/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::network::model::Connection;
use agama_lib::network::types::DeviceType;
use tokio::sync::oneshot;
use uuid::Uuid;
use zbus::zvariant::OwnedObjectPath;

use super::error::NetworkStateError;

Expand All @@ -15,19 +16,33 @@ pub type ControllerConnection = (Connection, Vec<String>);
#[derive(Debug)]
pub enum Action {
/// Add a new connection with the given name and type.
AddConnection(String, DeviceType),
AddConnection(
String,
DeviceType,
Responder<Result<OwnedObjectPath, NetworkStateError>>,
),
/// Gets a connection
GetConnection(Uuid, Responder<Option<Connection>>),
/// Gets a connection
GetConnectionPath(String, Responder<Option<OwnedObjectPath>>),
/// Get connections paths
GetConnectionsPaths(Responder<Vec<OwnedObjectPath>>),
/// Gets a controller connection
GetController(
Uuid,
Responder<Result<ControllerConnection, NetworkStateError>>,
),
/// Get devices paths
GetDevicesPaths(Responder<Vec<OwnedObjectPath>>),
/// Sets a controller's ports. It uses the Uuid of the controller and the IDs or interface names
/// of the ports.
SetPorts(Uuid, Vec<String>, Responder<Result<(), NetworkStateError>>),
SetPorts(
Uuid,
Box<Vec<String>>,
Responder<Result<(), NetworkStateError>>,
),
/// Update a connection (replacing the old one).
UpdateConnection(Connection),
UpdateConnection(Box<Connection>),
/// Remove the connection with the given Uuid.
RemoveConnection(String),
/// Apply the current configuration.
Expand Down
6 changes: 4 additions & 2 deletions rust/agama-dbus-server/src/network/adapter.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::network::NetworkState;
use async_trait::async_trait;
use std::error::Error;

/// A trait for the ability to read/write from/to a network service
#[async_trait]
pub trait Adapter {
fn read(&self) -> Result<NetworkState, Box<dyn Error>>;
fn write(&self, network: &NetworkState) -> Result<(), Box<dyn Error>>;
async fn read(&self) -> Result<NetworkState, Box<dyn Error>>;
async fn write(&self, network: &NetworkState) -> Result<(), Box<dyn Error>>;
}
2 changes: 1 addition & 1 deletion rust/agama-dbus-server/src/network/dbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pub mod service;
mod tree;

pub use service::NetworkService;
pub(crate) use tree::{ObjectsRegistry, Tree};
pub(crate) use tree::Tree;
Loading