#![allow(dead_code)]
#![allow(unused_variables)]
include!("debug.rs");
include!("rsnotify.rs");
include!("sendcmd.rs");
include!("linuxalert.rs");
#[cfg(target_os = "windows")]
include!("winalert.rs");
#[cfg(target_os = "windows")]
include!("win32send.rs");
pub struct RNotify<'a> {
pub title: & 'a str,
pub app_name: & 'a str,
pub body: & 'a str,
pub icon: & 'a str,
pub action: & 'a str,
pub urgency: & 'a str,
pub category: & 'a str,
pub id: & 'a u32,
pub timeout: & 'a i32,
}
impl <'a>RNotify<'a> {
pub fn new() -> RNotify<'a> {
RNotify { title: "", app_name: "", body: "",
action: "", urgency: "", category: "",
icon: "", id: &0, timeout: &0,}
}
#[cfg(target_os = "linux")]
#[cfg(not(windows))]
pub fn notify(&self, title: & 'a str, app_name: & 'a str, body: & 'a str,
icon: & 'a str, id: & 'a u32,
timeout: & 'a i32) -> RNotify<'a>
{
SendDbus::dbus_notify_send(title, app_name, body, icon, id, timeout);
RNotify {title, app_name, body, icon
, action: "", urgency: "", category: ""
, id, timeout,}
}
#[cfg(not(windows))]
pub fn cmdnotify(app_name: & 'a str, icon: & 'a str,
urgency: & 'a str, body: & 'a str, action: & 'a str,
category: & 'a str, timeout: i32,) -> RNotify<'a>
{
SendCommand::send_notify_command(app_name, icon, urgency, body, action, category, timeout);
RNotify {title: "", app_name, body, icon
, action, urgency, category
, id: &0, timeout: &0,}
}
#[cfg(not(windows))]
pub fn dbus_notify(title: & 'a str, app_name: & 'a str, body: & 'a str,
icon: & 'a str, id: & 'a u32,
timeout: & 'a i32) -> RNotify<'a>
{
SendDbus::dbus_notify_send(title, app_name, body, icon, id, timeout);
RNotify {title, app_name, body, icon
, action: "", urgency: "", category: ""
, id, timeout,}
}
#[cfg(not(windows))]
pub fn cmd_notify(app_name: & 'a str, icon: & 'a str,
urgency: & 'a str, body: & 'a str, action: & 'a str,
category: & 'a str, timeout: i32,) -> RNotify<'a>
{
SendCommand::send_notify_command(app_name, icon, urgency, body, action, category, timeout);
RNotify {title: "", app_name, body, icon
, action, urgency, category
, id: &0, timeout: &0,}
}
#[cfg(target_os = "windows")]
pub fn win32notify(action: & 'a str, app_name: & 'a str,
title: & 'a str, body: & 'a str, icon: & 'a str,
category: & 'a str, timeout: & 'a i64) -> RNotify <'a>
{
WinSend::wintoast_send(action, app_name, title, body, icon, category, timeout);
RNotify { title: "", app_name: "", body: body
, icon: "", action: "", urgency: ""
, category: "", id: &0, timeout: &0,}
}
pub fn alert(mode: & 'a str, body: & 'a str) -> RNotify<'a>
{
#[cfg(target_os = "linux")]
{
let err = Debug::new();
if mode == "INFO" || mode == "info" {
LinuxAlert::dialog_info(body);
}
else if mode == "Error" || mode == "err" || mode == "ERROR" {
LinuxAlert::dialog_error(body);
} else { err.error("Invalid message window");}
}
#[cfg(target_os = "windows")]
{
let err = Debug::new();
if mode == "INFO" || mode == "info" {
WinAlert::alert_info(body);
} else if mode == "Error" || mode == "err"
|| mode == "ERROR" {
WinAlert::alert_err(body);
} else { err.error("Invalid message window");}
}
RNotify { title: "", app_name: "", body: body
, icon: "", action: "", urgency: ""
, category: ""
, id: &0, timeout: &0,}
}
}