Skip to content

ICorePluginClientContext

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

What a core plugin page can see and do. Members are called and raise their events on the UI thread. Everything except ICorePluginClientContext.InvokeAsync has a default so older hosts keep working.

public interface ICorePluginClientContext

Guide: Core plugins and pages

IDeviceWebAccess? DeviceWeb { get; }

Default implementation

The web interface of managed devices for an embedded browser, relayed by the server with the stored login (Web View plugin). Null when the host has none (older hosts).

IReadOnlyList<IDeviceInfo> Devices { get; }

Default implementation

All managed devices (client mirror of the device table), see ICorePluginClientContext.DevicesChanged.

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.

bool IsAdministrator { get; }

Default implementation

Whether the user is an administrator (SDK 0.4.0), e.g. to offer Start 30-day trial (ICorePluginClientContext.StartProTrialAsync); others see who can. Changes come with PermissionsChanged. Default (older hosts): false.

ILiveVideoAccess? LiveVideo { get; }

Default implementation

The host’s live video component for the page (Live View plugin): the server streams the camera with the stored login. Null when the host has none (older hosts). The role needs “Live view” (devices.liveView) to see a picture.

Window? Owner { get; }

Default implementation

Main window, owner for the plugin’s own dialogs and file pickers.

string OwnerName { get; }

Default implementation

“user@machine” of this client, the owner shown for tasks the page starts on the server.

IReadOnlyList<IDeviceInfo> SelectedDevices { get; }

Default implementation

Devices selected in the grid of the Devices page, in selection order.

IServerFolders? ServerFolders { get; }

Default implementation

The folders of the server’s computer (SDK 0.17.0, IServerFolders) for a setting such as “Folder on the server”: give it to ServerFolderPicker.Folders. Administrators only (offer it while ICorePluginClientContext.IsAdministrator). Null when the host has none (older hosts).

IReadOnlyList<CorePluginTab> Tabs { get; }

Default implementation

The pages of other core plugins shown as tabs of this page (SDK 0.4.0, ICorePluginPage.TabOf), in the server’s order, only those the user’s role may show; see ICorePluginClientContext.TabsChanged. Default (older hosts): none.

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

Default implementation

The host’s confirmation dialog; true when confirmed. Without a host dialog nothing is confirmed.

string? GetLocalSetting(string key)

Default implementation

A short text this plugin keeps on this computer (the client settings file), e.g. a page’s last device choice; null when none. Not shared with other computers or users of them. Default (older hosts): nothing is kept.

bool Has(string permission)

Default implementation

Whether the user’s role allows permission, e.g. “oadm.dhcp-server:manage”: the page hides or disables what the role lacks (the server refuses the call anyway). Default (older hosts): true.

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

Calls ICorePlugin.InvokeAsync on the server. Errors arrive as Grpc.Core.RpcException (Status.Detail is the message).

bool? IsPluginOn(string packageId)

Default implementation

Whether the plugin package packageId is turned on (Plugins page); null when the host cannot tell.

PluginLicenseInfo? LicenseOf(string packageId)

Default implementation

The license of the plugin package packageId as the server checked it (status, reason, what it allows), e.g. for “No license” on the page; read it again when the page is shown. Null when the host cannot tell. The server checks again on every call.

Task OpenAsync(string hostPage)

Default implementation

Opens a host page (HostPages), e.g. Devices to watch the tasks pane, or another plugin’s page (“plugin:” + its id) while that plugin is on.

bool OpenDevicePage(Guid deviceId, string path)

Default implementation

Opens path of a device’s web interface (“/local/objectanalytics/index.html”) in the Web View page (SDK 0.7.0): the host shows that page and raises ICorePluginClientContext.OpenDevicePageRequested on it. False when nothing opens: Web View is off or not allowed for the role, the device is not in the client’s device list, or the path does not stay on the device (it must start with one “/”, without “", “..”, spaces or control characters). Default (older hosts): false.

Task<PluginDownload> OpenDownloadAsync(string method, string? payloadJson, CancellationToken ct)

Default implementation

A file the server part sends (ICorePluginDownloads, gRPC PluginService.Download): the suggested name, the length when known and the bytes as a stream. Read PluginDownload.Content with your own token and dispose the download (that ends the call). Errors arrive as RpcException like ICorePluginClientContext.InvokeAsync. Default (older hosts): NotSupportedException.

Task<string> RevealCredentialAsync(Guid credentialId, CancellationToken ct)

Default implementation

SDK 0.15.0: the stored password of one credential list entry (an id of IDeviceAutoAdd.ListCredentialsAsync), for an eye button like the one of the Credentials page. The same call and rules as that page: administrators only (offer it only while ICorePluginClientContext.IsAdministrator), every reveal in the audit log without the password, refused while no user exists. Show it masked first (CredentialTexts.Masked), only while the user asked for it, and forget it when hidden again; never send it to the server part or log it. Errors arrive as RpcException like ICorePluginClientContext.InvokeAsync (NOT_FOUND for an entry that is gone). Default (older hosts): NotSupportedException.

Parameters

  • credentialId: The entry’s id.
  • ct: Cancels the call.
Task<IReadOnlyList<string>?> RunTaskAsync(string pluginId, IReadOnlyList<Guid> deviceIds, CancellationToken ct)

Default implementation

Runs a task plugin on deviceIds like the context menu does: its dialog first when it has one (with every check of that dialog), then one task per device. Returns the task ids, or null when nothing was started (closed, the role lacks the task, devices outside the user’s group left out). SDK 0.7.0; older hosts throw NotSupportedException.

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

Default implementation

ICorePluginClientContext.RunTaskAsync with the dialog opened on startView (SDK 0.7.0, ITaskDialogContext.StartView), e.g. “license” for the license keys of the Applications dialog. Default: the run without a start view (the dialog’s usual start).

void SetLocalSetting(string key, string? value)

Default implementation

Keeps value (at most 64 KB) under key on this computer; null removes it.

Task ShowMessageAsync(string title, string message)

Default implementation

The host’s message dialog.

Task<ProLicenseInfo> StartProTrialAsync(CancellationToken ct)

Default implementation

Starts the server’s 30-day OADM PRO trial (SDK 0.4.0; administrators, once per server, docs/spec/licensing.md) and returns the new state; the host refreshes its plugin list and Settings card, the server raises IProLicense.Changed for the server parts. Offer it only while ProLicenseInfo.TrialAvailable. Throws with the server’s reason (“The trial was already used on this server.”). Default (older hosts): NotSupportedException.

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

Default implementation

Uploads a local file to the server (256 KB chunks) like ITaskDialogContext.UploadAsync: a page that starts tasks through its server part puts the returned id into their payload, the task reads it by id (IUploadedFiles). progress receives the fraction sent, from 0.0 to 1.0. SDK 0.7.0; older hosts throw NotSupportedException.

IAsyncEnumerable<PluginEvent> WatchEventsAsync(CancellationToken ct)

Default implementation

Live events the server part publishes (ICorePluginContext.Events, gRPC PluginService.Watch), from now until ct is cancelled; items arrive on the caller’s synchronization context. The sequence ends or throws RpcException when the connection drops: re-read the state with ICorePluginClientContext.InvokeAsync and watch again after a short delay. Default (older hosts, fake mode): an empty sequence, so the page polls.

event EventHandler? DevicesChanged

Default implementation

A device was added, removed or changed.

event EventHandler<DevicePageRequest>? OpenDevicePageRequested

Default implementation

The host asks the page to open a page of a device’s web interface (SDK 0.7.0, raised on the Web View page by ICorePluginClientContext.OpenDevicePage of another page). Default (older hosts): never raised.

event EventHandler<string>? OpenDeviceRequested

Default implementation

The host asks the page to open a device; the argument is the device’s id. Web View uses it: the address link and “Open web interface” of a device at a site open the device there (the user’s computer usually cannot reach the site). Default (older hosts): never raised.

event EventHandler<string>? OpenTabRequested

Default implementation

The host asks the page to show a tab (SDK 0.4.0): the plugin id of one of ICorePluginClientContext.Tabs, or this page’s own id for its own first tab (OpenAsync("plugin:" + id) of that page). Default (older hosts): never raised.

event EventHandler? PermissionsChanged

Default implementation

Raised on the UI thread after the user’s role or its permissions changed (ask ICorePluginClientContext.Has again).

event EventHandler? TabsChanged

Default implementation

Raised on the UI thread after ICorePluginClientContext.Tabs changed (a role change, a plugin turned on or off).