Skip to content

Plugin Architechture Draft #117

Closed
Closed
@TTWNO

Description

@TTWNO

We could have a dedicated communication thread between the SR and plugins—which is running on a blocking task.

Basically:
Plugin <-> Comm. Thread <-> SR

The comm thread will also be how we run each plugins' functions.

So let's say we had a event(ev: Event) for each plugin, so they could, in theory, do something based on an event, we would write the following:

In the plugin, beep-on-blank-line

fn pre_event(comms: Pipe, ev: Event) {
   if Some(caret_moved) = TextCaretMoved::try_from(ev) {
     comms.send(OdiliaEvent::Sound("beep.wav"));
  }
}
fn post_event(ev: Event) {}

The comms thread passes events to the main Odilia even loop (it'll have a Sender<OdiliaEvent>).
It will also have a Received<AtspiEvent> to send events to each plugin:

// Vec<wasmer::Instance> 
for instance in instances {
  let func = instant.get_function(func_name)?;
  func(&event);
}

Finally, there is our atspi even loop:

comms_pipe.send("pre_event", &event);
// dispatch event
comms_pipe.send("post_event", &event);

I'm on mobile, so excuse the mess, but I think this is a good start. We need pre_* and post_* hooks for atspi events, Odilia events, SSIP commands, and module loading itself (basically init and cleanup).

Init should probably return a ModuleOptions

enum HookSystem {
  OdiliaEvents,
  AtspiEvents,
  SsipCommands,
  ModuleLoading
}
enum HookSide {
  Pre,
  Post,
  Core, // implement/override core functionality
}
struct Hook {
  side: HookSide,
  system: HookSystem,
}
struct ModuleOptions {
  hooks: Vec<Hook>,
  core_mod: bool, // is a core module that overrides standard behaviour. Without it, a Hook which uses rhe HookSide::Core value will be rejected. Also nore that only one core mod per system is permitted.
  id: String, // a unique string to identify your module. If not unique, Odilia will remove the module with the same name, and load this one. This should not change wirh versions.
  version: String, // the version of the plugin being used
}

Any comments? I realixe it'll be annoying to pass all those messages around, but I can't think of a better way.

EDIT: Tired and on mobile, will fix up grammsr/spelling later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions