1 // Copyright 2026 Splitfire AB (Onde Inference). All rights reserved.
2 // SPDX-License-Identifier: MIT OR Apache-2.0
3 //
4 // onde_inference_plugin.cc
5 //
6 // Minimal Linux Flutter plugin registration entry point for the
7 // onde_inference package.
8 //
9 // All real inference logic lives inside the Rust shared library
10 // (libonde_inference_dart.so) which is loaded at runtime by the
11 // flutter_rust_bridge Dart package. This C++ file exists solely to satisfy
12 // the Flutter tooling's requirement that every Linux plugin provides a
13 // GObject-based plugin class registered via FlPluginRegistrar.
14
15 #include "include/onde_inference/onde_inference_plugin.h"
16
17 #include <flutter_linux/flutter_linux.h>
18 #include <gtk/gtk.h>
19
20 #define ONDE_INFERENCE_PLUGIN(obj) \
21 (G_TYPE_CHECK_INSTANCE_CAST((obj), onde_inference_plugin_get_type(), \
22 OndeInferencePlugin))
23
24 struct _OndeInferencePlugin {
25 GObject parent_instance;
26 };
27
28 G_DEFINE_TYPE(OndeInferencePlugin, onde_inference_plugin, G_TYPE_OBJECT)
29
30 // Called when the plugin object is being finalised.
31 static void onde_inference_plugin_dispose(GObject* object) {
32 G_OBJECT_CLASS(onde_inference_plugin_parent_class)->dispose(object);
33 }
34
35 // Class initialiser.
36 static void onde_inference_plugin_class_init(
37 OndeInferencePluginClass* klass) {
38 G_OBJECT_CLASS(klass)->dispose = onde_inference_plugin_dispose;
39 }
40
41 // Instance initialiser.
42 static void onde_inference_plugin_init(OndeInferencePlugin* self) {}
43
44 // ---------------------------------------------------------------------------
45 // Registration
46 // ---------------------------------------------------------------------------
47
48 // Called by the Flutter engine when the plugin is registered with a
49 // FlPluginRegistrar. Because all Flutter ↔ Rust communication is handled
50 // through the flutter_rust_bridge FFI layer (not through Flutter platform
51 // channels), no MethodChannel is registered here.
52 void onde_inference_plugin_register_with_registrar(
53 FlPluginRegistrar* registrar) {
54 OndeInferencePlugin* plugin = ONDE_INFERENCE_PLUGIN(
55 g_object_new(onde_inference_plugin_get_type(), nullptr));
56
57 g_object_unref(plugin);
58 }