#![warn(clippy::correctness)]
#![warn(clippy::perf)]
mod config;
mod connect_db;
mod enums;
mod error_handler;
mod log_db;
mod secret;
mod secure;
mod shell;
mod structs;
mod tasker_logic;
mod tasks_db;
mod notify;
mod root_key_request;
mod tests;
pub mod time;
pub mod taskerctl {
use random_string;
use crate::{shell, secret, root_key_request};
pub use crate::structs::{CurrentTime, Task};
pub use crate::enums::Configure;
use crate::structs::{LogEntry, LogEntryEncrypted, TaskEncrypted};
use crate::config::is_root;
pub fn execute_command_install(enable_disable: Configure){
shell::execute_for_install(enable_disable);
}
pub fn read_tasks_db() -> Vec<Task> {
TaskEncrypted::read_db(get_keys())
}
pub fn read_logs_db() -> Option<Vec<LogEntry>> {
LogEntryEncrypted::read_logs(get_keys())
}
pub(crate) fn get_keys() -> Vec<u8> {
if !is_root(){
secret::get_key_linux()
}else{
root_key_request::get_key_root()
}
}
pub fn add_task(task: Task) {
TaskEncrypted::add_task(task, get_keys());
}
pub fn rm_task(task_name: String){
TaskEncrypted::rm_task(task_name, get_keys());
}
impl Task{
pub fn new()->Task{
let az: String = "abcdefghijklmnopqrstuvwxyz".to_string();
let name_holder = random_string::generate(6, az);
let now = CurrentTime::now();
Task { name: Some(name_holder),
shell: None,
command: None,
comment: None,
month: None,
day_of_month: None,
day_of_week: None,
hour: None,
minute: None,
year_added: now.year,
month_added: now.month,
day_of_month_added: now.day_of_month,
hour_added: now.hour,
minute_added: now.min }
}
}
}
pub mod tasker_service {
use crate::{tasker_logic, taskerctl::get_keys,root_key_request::get_key_root,config::is_root};
pub fn main_service() {
if is_root(){
tasker_logic::main_execution_loop(get_key_root());
}else if !is_root(){
tasker_logic::main_execution_loop(get_keys());
}
}
}