Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin Architechture Draft #117

Open
TTWNO opened this issue May 1, 2023 · 1 comment
Open

Plugin Architechture Draft #117

TTWNO opened this issue May 1, 2023 · 1 comment

Comments

@TTWNO
Copy link
Member

TTWNO commented May 1, 2023

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.

@TTWNO
Copy link
Member Author

TTWNO commented May 1, 2023

Another thing to consider: threre is a reasonable chance that plugins may want to communicate with one another. I'm not sure how to cover this case easily.

@TTWNO TTWNO linked a pull request Jun 23, 2023 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant