|
| 1 | +package exec |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + |
| 6 | + execsdk "github.com/omniviewdev/plugin-sdk/pkg/v1/exec" |
| 7 | + "github.com/wailsapp/wails/v3/pkg/application" |
| 8 | +) |
| 9 | + |
| 10 | +// ServiceWrapper is an explicit delegation wrapper around exec.Controller. |
| 11 | +// Excluded: OnPluginInit, OnPluginStart, OnPluginStop, OnPluginShutdown, |
| 12 | +// |
| 13 | +// OnPluginDestroy |
| 14 | +type ServiceWrapper struct { |
| 15 | + Ctrl Controller |
| 16 | +} |
| 17 | + |
| 18 | +func (s *ServiceWrapper) ServiceStartup(ctx context.Context, options application.ServiceOptions) error { |
| 19 | + if ss, ok := s.Ctrl.(interface { |
| 20 | + ServiceStartup(context.Context, application.ServiceOptions) error |
| 21 | + }); ok { |
| 22 | + return ss.ServiceStartup(ctx, options) |
| 23 | + } |
| 24 | + return nil |
| 25 | +} |
| 26 | +func (s *ServiceWrapper) ServiceShutdown() error { |
| 27 | + if ss, ok := s.Ctrl.(interface{ ServiceShutdown() error }); ok { |
| 28 | + return ss.ServiceShutdown() |
| 29 | + } |
| 30 | + return nil |
| 31 | +} |
| 32 | +func (s *ServiceWrapper) CreateSession(plugin, connectionID string, opts execsdk.SessionOptions) (*execsdk.Session, error) { |
| 33 | + return s.Ctrl.CreateSession(plugin, connectionID, opts) |
| 34 | +} |
| 35 | +func (s *ServiceWrapper) CreateTerminal(opts execsdk.SessionOptions) (*execsdk.Session, error) { |
| 36 | + return s.Ctrl.CreateTerminal(opts) |
| 37 | +} |
| 38 | +func (s *ServiceWrapper) ListSessions() ([]*execsdk.Session, error) { |
| 39 | + return s.Ctrl.ListSessions() |
| 40 | +} |
| 41 | +func (s *ServiceWrapper) GetSession(sessionID string) (*execsdk.Session, error) { |
| 42 | + return s.Ctrl.GetSession(sessionID) |
| 43 | +} |
| 44 | +func (s *ServiceWrapper) AttachSession(sessionID string) (*execsdk.Session, []byte, error) { |
| 45 | + return s.Ctrl.AttachSession(sessionID) |
| 46 | +} |
| 47 | +func (s *ServiceWrapper) DetachSession(sessionID string) (*execsdk.Session, error) { |
| 48 | + return s.Ctrl.DetachSession(sessionID) |
| 49 | +} |
| 50 | +func (s *ServiceWrapper) WriteSession(sessionID string, data []byte) error { |
| 51 | + return s.Ctrl.WriteSession(sessionID, data) |
| 52 | +} |
| 53 | +func (s *ServiceWrapper) CloseSession(sessionID string) error { |
| 54 | + return s.Ctrl.CloseSession(sessionID) |
| 55 | +} |
| 56 | +func (s *ServiceWrapper) ResizeSession(sessionID string, rows, cols uint16) error { |
| 57 | + return s.Ctrl.ResizeSession(sessionID, rows, cols) |
| 58 | +} |
| 59 | +func (s *ServiceWrapper) GetHandler(plugin, resource string) *execsdk.Handler { |
| 60 | + return s.Ctrl.GetHandler(plugin, resource) |
| 61 | +} |
| 62 | +func (s *ServiceWrapper) GetHandlers() map[string]map[string]execsdk.Handler { |
| 63 | + return s.Ctrl.GetHandlers() |
| 64 | +} |
| 65 | +func (s *ServiceWrapper) GetPluginHandlers(plugin string) map[string]execsdk.Handler { |
| 66 | + return s.Ctrl.GetPluginHandlers(plugin) |
| 67 | +} |
| 68 | +func (s *ServiceWrapper) ListPlugins() ([]string, error) { |
| 69 | + return s.Ctrl.ListPlugins() |
| 70 | +} |
| 71 | +func (s *ServiceWrapper) HasPlugin(pluginID string) bool { |
| 72 | + return s.Ctrl.HasPlugin(pluginID) |
| 73 | +} |
0 commit comments