use xor_name::XorName;
use maidsafe_utilities::event_sender::EventSender;
pub type Observer<EventSubset> = EventSender<LauncherEventCategoy, EventSubset>;
pub type IpcObserver = Observer<IpcEvent>;
pub type AppHandlerObserver = Observer<AppHandlingEvent>;
#[derive(Debug, Clone)]
pub enum LauncherEventCategoy {
IpcEvent,
AppHandlingEvent,
OwnerCategory,
}
#[derive(Debug)]
pub enum IpcEvent {
VerifiedSessionUpdate(event_data::VerifiedSession),
UnverifiedSessionUpdate(event_data::UnverifiedSession),
PendingVerificationUpdate(event_data::PendingVerification),
}
impl From<event_data::VerifiedSession> for IpcEvent {
fn from(data: event_data::VerifiedSession) -> IpcEvent {
IpcEvent::VerifiedSessionUpdate(data)
}
}
impl From<event_data::UnverifiedSession> for IpcEvent {
fn from(data: event_data::UnverifiedSession) -> IpcEvent {
IpcEvent::UnverifiedSessionUpdate(data)
}
}
impl From<event_data::PendingVerification> for IpcEvent {
fn from(data: event_data::PendingVerification) -> IpcEvent {
IpcEvent::PendingVerificationUpdate(data)
}
}
#[derive(Debug)]
pub enum AppHandlingEvent {
AppAddition(event_data::AppAddition),
AppRemoval(event_data::AppRemoval),
AppActivation(Result<XorName, ::errors::LauncherError>),
AppModification(event_data::AppModification),
}
impl From<event_data::AppAddition> for AppHandlingEvent {
fn from(data: event_data::AppAddition) -> AppHandlingEvent {
AppHandlingEvent::AppAddition(data)
}
}
impl From<event_data::AppRemoval> for AppHandlingEvent {
fn from(data: event_data::AppRemoval) -> AppHandlingEvent {
AppHandlingEvent::AppRemoval(data)
}
}
impl From<event_data::AppModification> for AppHandlingEvent {
fn from(data: event_data::AppModification) -> AppHandlingEvent {
AppHandlingEvent::AppModification(data)
}
}
pub mod event_data {
use xor_name::XorName;
#[derive(Debug)]
pub enum Action {
Added,
Removed(Option<::errors::LauncherError>),
}
#[derive(Debug)]
pub struct PendingVerification {
pub nonce : String,
pub action: Action,
}
#[derive(Debug)]
pub struct UnverifiedSession {
pub id : u32,
pub action: Action,
}
#[derive(Debug)]
pub struct VerifiedSession {
pub id : XorName,
pub action: Action,
}
#[derive(Debug)]
pub struct AppAddition {
pub result : Result<AppAdditionData, ::errors::LauncherError>,
pub local_path: String,
}
#[derive(Debug)]
pub struct AppAdditionData {
pub id : XorName,
pub name: String
}
#[derive(Debug)]
pub struct AppRemoval {
pub id : XorName,
pub result: Option<::errors::LauncherError>,
}
#[derive(Debug)]
pub struct AppModification {
pub id : XorName,
pub result: Result<ModificationDetail, ::errors::LauncherError>,
}
#[derive(Debug)]
pub struct ModificationDetail {
pub name : Option<String>,
pub local_path : Option<String>,
pub safe_drive_access: Option<bool>,
}
}