mirror of
https://github.com/rustdesk/qemu-display.git
synced 2025-07-01 15:25:29 +00:00
demo: teach to connect to a different bus
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
cbe0cf891c
commit
5f0279eb1f
@ -25,6 +25,7 @@ struct App {
|
|||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct AppOptions {
|
struct AppOptions {
|
||||||
vm_name: Option<String>,
|
vm_name: Option<String>,
|
||||||
|
address: Option<String>,
|
||||||
list: bool,
|
list: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,6 +40,14 @@ impl App {
|
|||||||
"VM name",
|
"VM name",
|
||||||
Some("VM-NAME"),
|
Some("VM-NAME"),
|
||||||
);
|
);
|
||||||
|
app.add_main_option(
|
||||||
|
"address",
|
||||||
|
glib::Char(b'a' as _),
|
||||||
|
glib::OptionFlags::NONE,
|
||||||
|
glib::OptionArg::String,
|
||||||
|
"D-Bus bus address",
|
||||||
|
None,
|
||||||
|
);
|
||||||
app.add_main_option(
|
app.add_main_option(
|
||||||
"list",
|
"list",
|
||||||
glib::Char(0),
|
glib::Char(0),
|
||||||
@ -64,6 +73,9 @@ impl App {
|
|||||||
println!("Version: {}", env!("CARGO_PKG_VERSION"));
|
println!("Version: {}", env!("CARGO_PKG_VERSION"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if let Some(arg) = opt.lookup_value("address", None) {
|
||||||
|
app_opt.address = arg.get::<String>();
|
||||||
|
}
|
||||||
if opt.lookup_value("list", None).is_some() {
|
if opt.lookup_value("list", None).is_some() {
|
||||||
app_opt.list = true;
|
app_opt.list = true;
|
||||||
}
|
}
|
||||||
@ -96,7 +108,12 @@ impl App {
|
|||||||
let app_clone = app_clone.clone();
|
let app_clone = app_clone.clone();
|
||||||
let opt_clone = opt.clone();
|
let opt_clone = opt.clone();
|
||||||
MainContext::default().spawn_local(async move {
|
MainContext::default().spawn_local(async move {
|
||||||
let conn = zbus::ConnectionBuilder::session()
|
let builder = if let Some(addr) = &opt_clone.borrow().address {
|
||||||
|
zbus::ConnectionBuilder::address(addr.as_str())
|
||||||
|
} else {
|
||||||
|
zbus::ConnectionBuilder::session()
|
||||||
|
};
|
||||||
|
let conn = builder
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.internal_executor(false)
|
.internal_executor(false)
|
||||||
.build()
|
.build()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user