refactor: introduce plugin_ids constants, replace hardcoded plugin ID strings
This commit is contained in:
@@ -244,7 +244,7 @@ impl Plugin for HttpPlugin {
|
||||
}
|
||||
|
||||
fn dependencies(&self) -> Vec<String> {
|
||||
vec!["video".to_string()]
|
||||
vec![crate::core::plugin_ids::VIDEO.to_string()]
|
||||
}
|
||||
|
||||
fn init(&mut self, ctx: PluginContext) -> Result<()> {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
use crate::core::{
|
||||
message::{Destination, DeviceCommand, Envelope, Message},
|
||||
plugin::*,
|
||||
plugin_ids,
|
||||
};
|
||||
use anyhow::Result;
|
||||
|
||||
@@ -25,7 +26,7 @@ impl ScreenPlugin {
|
||||
if let Some(ctx) = &self.ctx {
|
||||
let envelope = Envelope {
|
||||
from: self.id().to_string(),
|
||||
to: Destination::Plugin("device".to_string()),
|
||||
to: Destination::Plugin(plugin_ids::DEVICE.to_string()),
|
||||
message: Message::DeviceCommand(DeviceCommand::SetSleepInhibit(true)),
|
||||
};
|
||||
let _ = ctx.tx.send(envelope);
|
||||
@@ -36,7 +37,7 @@ impl ScreenPlugin {
|
||||
if let Some(ctx) = &self.ctx {
|
||||
let envelope = Envelope {
|
||||
from: self.id().to_string(),
|
||||
to: Destination::Plugin("device".to_string()),
|
||||
to: Destination::Plugin(plugin_ids::DEVICE.to_string()),
|
||||
message: Message::DeviceCommand(DeviceCommand::SetSleepInhibit(false)),
|
||||
};
|
||||
let _ = ctx.tx.send(envelope);
|
||||
@@ -47,7 +48,7 @@ impl ScreenPlugin {
|
||||
if let Some(ctx) = &self.ctx {
|
||||
let envelope = Envelope {
|
||||
from: self.id().to_string(),
|
||||
to: Destination::Plugin("device".to_string()),
|
||||
to: Destination::Plugin(plugin_ids::DEVICE.to_string()),
|
||||
message: Message::DeviceCommand(DeviceCommand::SetCursorVisible(!hidden)),
|
||||
};
|
||||
let _ = ctx.tx.send(envelope);
|
||||
@@ -76,7 +77,7 @@ impl Plugin for ScreenPlugin {
|
||||
}
|
||||
|
||||
fn dependencies(&self) -> Vec<String> {
|
||||
vec!["device".to_string()]
|
||||
vec![plugin_ids::DEVICE.to_string()]
|
||||
}
|
||||
|
||||
fn init(&mut self, ctx: PluginContext) -> Result<()> {
|
||||
|
||||
@@ -7,6 +7,7 @@ pub mod state_machine;
|
||||
|
||||
use crate::core::message::{Destination, Envelope, Message, PlayerCommand, PlayerStatusData};
|
||||
use crate::core::plugin::{Platform, Plugin, PluginContext, PluginInfo};
|
||||
use crate::core::plugin_ids;
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use opencv::highgui;
|
||||
use processor::VideoProcessor;
|
||||
@@ -151,7 +152,7 @@ impl Plugin for VideoPlugin {
|
||||
if let Some(ctx) = &self.ctx {
|
||||
let _ = ctx.tx.send(Envelope {
|
||||
from: self.id().to_string(),
|
||||
to: Destination::Plugin("screen".to_string()),
|
||||
to: Destination::Plugin(plugin_ids::SCREEN.to_string()),
|
||||
message: Message::ScreenLockRequest(true),
|
||||
});
|
||||
}
|
||||
@@ -162,7 +163,7 @@ impl Plugin for VideoPlugin {
|
||||
if let Some(ctx) = &self.ctx {
|
||||
let _ = ctx.tx.send(Envelope {
|
||||
from: self.id().to_string(),
|
||||
to: Destination::Plugin("screen".to_string()),
|
||||
to: Destination::Plugin(plugin_ids::SCREEN.to_string()),
|
||||
message: Message::ScreenLockRequest(false),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user