Skip to content

IToolbarContext

Interface in Oadm.Sdk.Client · Oadm.Sdk.Client.dll

What a toolbar plugin can see and do: the devices and the selection (with change events), the task plugins, the host pages and dialogs, and the same server access as a task plugin dialog. All members are called and raise their events on the UI thread.

public interface IToolbarContext

Guide: Core plugins and pages

IReadOnlyList<IDeviceInfo> Devices { get; }

All managed devices.

bool HasAllDevices { get; }

Default implementation

Whether the user may reach every device (SDK 0.4.0); false for a user limited to a device group: hide or disable what only users with all devices may do (the server refuses it anyway). Changes come with PermissionsChanged. Default (older hosts): true.

Window? Owner { get; }

The main window, as owner for the plugin’s own dialogs; null before it is shown.

int SelectedCount { get; }

Default implementation

How many devices are selected, without a copy of the selection (enable a button with it).

IReadOnlyList<IDeviceInfo> SelectedDevices { get; }

Selected devices of the grid, in selection order (a new list per call: read it once per change).

IReadOnlyList<ToolbarTaskPlugin> TaskPlugins { get; }

Task plugins of the server.

bool CanRunTask(string pluginId)

True when the task plugin can run on every selected device (and something is selected).

string? CannotRunTaskReason(string pluginId)

Default implementation

Why the task plugin cannot run on the selection, in plain language (the context menu tooltip of the greyed entry, e.g. “Needs AXIS OS 11.11 or later: 3 of 5 selected devices”); null when it can or nothing is selected. Default (older hosts): null.

Task<bool> ConfirmAsync(string title, string message, string confirmText)

The host’s confirmation dialog; true when confirmed.

ICorePluginClientContext? CorePluginContext(string pluginId)

Default implementation

SDK 0.15.0: the context a page of the core plugin pluginId would get (its server calls, live events, dialogs, the host’s reveal of a stored password), for a toolbar entry of a core plugin without a page (Provisioning) that opens dialogs of that plugin. A new context per call: keep it as long as the entry lives. Default (older hosts): null.

bool Has(string permission)

Default implementation

Whether the user’s role allows permission (“devices.refresh”). Default (older hosts): true.

Task<string?> InvokePluginAsync(string pluginId, string method, string? payloadJson, CancellationToken ct)

Default implementation

Calls a core plugin’s server part (ICorePlugin.InvokeAsync through gRPC PluginService.Invoke), e.g. the backend of a toolbar-only core plugin (ICorePlugin.HasPage false). Failures are Grpc.Core.RpcException (Status.Detail is the message). Hosts without it throw NotSupportedException.

Task OpenAsync(string hostPage)

Opens a host page, see HostPages. Completes when a dialog page closes.

Task<string?> QueryAsync(string pluginId, Guid deviceId, string method, string? payloadJson, CancellationToken ct)

Calls a task plugin’s server-side ITaskPluginQuery.QueryAsync for one device (read-only).

Task RefreshDevicesAsync(IReadOnlyCollection<Guid> deviceIds, CancellationToken ct)

Default implementation

Reads devices again now (full refresh on the server: status, firmware, network settings, API list, certificate); returns when the refresh is queued, the grid updates as the results arrive. Read-only for the devices.

Task RemoveDevicesAsync(IReadOnlyCollection<Guid> deviceIds, CancellationToken ct)

Removes devices from OADM (the devices themselves are not changed). No confirmation.

Task<IReadOnlyList<string>?> RunTaskAsync(string pluginId, CancellationToken ct)

Runs a task plugin on the selection like the context menu does: its dialog first when it has one, then one task per device. Returns the task ids, or null when nothing was started.

Task ShowMessageAsync(string title, string message)

The host’s message dialog.

Task<UploadedFile> UploadAsync(string localPath, IProgress<double>? progress, CancellationToken ct)

Uploads a local file to the server; progress receives 0.0 to 1.0.

event EventHandler? DevicesChanged

A device was added, removed or changed.

event EventHandler? PermissionsChanged

Default implementation

Raised on the UI thread after the user’s role or its permissions changed.

event EventHandler? SelectionChanged

The grid selection changed.

event EventHandler? TaskPluginsChanged

IToolbarContext.TaskPlugins or what they can run on changed.