consts
This commit is contained in:
parent
ff213fdd70
commit
d4f2140f55
11
src/main.rs
11
src/main.rs
@ -4,6 +4,11 @@ use notification::{print_notif, to_notif};
|
||||
use futures_util::stream::TryStreamExt;
|
||||
use zbus::{Connection, Result};
|
||||
|
||||
const SERVER_NAME: &str = "SNot";
|
||||
const VENDOR: &str = "candifloss.cc";
|
||||
const VERSION: &str = "0.1.0";
|
||||
const SPEC_VERSION: &str = "0.1.0";
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let connection = Connection::session().await?;
|
||||
@ -20,9 +25,9 @@ async fn main() -> Result<()> {
|
||||
match member_name {
|
||||
"GetServerInformation" => {
|
||||
// Respond with server information
|
||||
let response = ("SNot", "candifloss.cc", "0.1.0", "0.1.0"); // (name, vendor, version, spec_version)
|
||||
let response = (SERVER_NAME, VENDOR, VERSION, SPEC_VERSION); // (name, vendor, version, spec_version)
|
||||
connection.reply(&msg, &response).await?;
|
||||
println!("Request received: {member}\n\tName: SNot\n\tVendor: candifloss.cc\n\tVersion: 0.1.0\n\tSpec_version: 0.1.0");
|
||||
println!("Request received: {member}\n\tName: {SERVER_NAME}\n\tVendor: {VENDOR}\n\tVersion: {VERSION}\n\tSpec_version: {SPEC_VERSION}");
|
||||
}
|
||||
"GetCapabilities" => {
|
||||
// Respond with supported capabilities
|
||||
@ -38,7 +43,7 @@ async fn main() -> Result<()> {
|
||||
let notif = to_notif(&msg_body)?;
|
||||
// Print the notif
|
||||
print_notif(¬if);
|
||||
println!("{}", notif.urgency());
|
||||
println!("{}\n", notif.urgency());
|
||||
// Done. Respond to the client with a notification ID
|
||||
let notification_id: u32 = 1; // This could be incremented or generated. Do it l8r
|
||||
connection.reply(&msg, ¬ification_id).await?; // The client will disconnect when it gets this response
|
||||
|
@ -56,5 +56,5 @@ pub fn print_notif(notif: &Notification) {
|
||||
for (key, value) in ¬if.hints {
|
||||
println!(" {key}: {value:?}");
|
||||
}
|
||||
println!("Expiration Timeout: {0} seconds\n", notif.expir_timeout);
|
||||
println!("Expiration Timeout: {0} seconds", notif.expir_timeout);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user