Documentation
¶
Index ¶
- func RunCommandAsync(logger *zap.Logger, name string, args ...string)
- func RunCommandSync(ctx context.Context, name string, args ...string) ([]byte, error)
- type Plugin
- type Registry
- func (r *Registry) All() []Plugin
- func (r *Registry) Capabilities() (incoming []string, outgoing []string)
- func (r *Registry) Dispatch(ctx context.Context, dev device.Sender, pkt *protocol.Packet) bool
- func (r *Registry) GetByName(name string) (Plugin, bool)
- func (r *Registry) OnConnect(dev device.Sender)
- func (r *Registry) OnDisconnect(dev device.Sender)
- func (r *Registry) Register(p Plugin)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunCommandAsync ¶
RunCommandAsync executes a system command in a goroutine so it doesn't block the plugin handler. It logs a warning if the command fails, aiding in debugging missing dependencies (like notify-send, xclip).
Types ¶
type Plugin ¶
type Plugin interface {
// Name returns the unique human-readable name of the plugin (e.g. "Battery").
Name() string
// IncomingTypes returns a list of packet type strings this plugin handles.
IncomingTypes() []string
// OutgoingTypes returns a list of packet type strings this plugin may send.
OutgoingTypes() []string
// Timeout returns the maximum duration allowed for this plugin's Handle execution.
// Return 0 for no timeout (or a global default).
Timeout() time.Duration
// OnConnect is called when the device connects.
OnConnect(dev device.Sender)
// OnDisconnect is called when the device disconnects.
OnDisconnect(dev device.Sender)
Handle(ctx context.Context, dev device.Sender, pkt *protocol.Packet) error
}
Plugin represents a KDE Connect functionality module. Implementations must not import other plugins, and must not block in Handle.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages the set of active plugins and routes packets to them.
func NewRegistry ¶
NewRegistry creates a new plugin registry.
func (*Registry) Capabilities ¶
Capabilities returns the aggregated incoming and outgoing capabilities of all registered plugins, suitable for sending in an Identity packet.
func (*Registry) Dispatch ¶
Dispatch routes an incoming packet to the appropriate plugin. Returns true if the packet was processed within the timeout and may be safely returned to the packet pool. Returns false if the plugin timed out — the caller must NOT recycle the packet because the background goroutine may still hold a reference to it.
func (*Registry) OnConnect ¶
OnConnect is called when a device connects. It calls OnConnect on all registered plugins.
func (*Registry) OnDisconnect ¶
OnDisconnect is called when a device disconnects. It calls OnDisconnect on all registered plugins.