import { Client, Tunnel } from '@raytecvision/guacamole-common-js'; import { BehaviorSubject, ReplaySubject, Subject, Observable } from 'rxjs'; import { File as ManagedFile, ManagedFilesystem } from './managed-filesystem'; import { ManagedFilesystemService } from './managed-filesystem.service'; import { ManagedFileUpload } from './managed-file-upload'; import { TunnelRestApiService } from './tunnel-rest-api.service'; import * as i0 from "@angular/core"; /** * Manages the connection to the remote desktop */ export declare class RemoteDesktopService { private filesystemService; private tunnelRestApiService; static STATE: { /** * The machine connection has not yet been attempted. */ IDLE: string; /** * The machine connection is being established. */ CONNECTING: string; /** * The machine connection has been successfully established, and the * client is now waiting for receipt of initial graphical data. */ WAITING: string; /** * The Guacamole connection has been successfully established, and * initial graphical data has been received. */ CONNECTED: string; /** * The machine connection has terminated successfully. No errors are * indicated. */ DISCONNECTED: string; /** * The machine connection has terminated due to an error reported by * the client. The associated error code is stored in statusCode. * */ CLIENT_ERROR: string; /** * The machine connection has terminated due to an error reported by * the tunnel. The associated error code is stored in statusCode. */ TUNNEL_ERROR: string; }; /** * Remote desktop connection state observable * Subscribe to this if you want to be notified when the connection state changes */ onStateChange: BehaviorSubject; /** * Remote desktop clipboard observable. * Subscribe to this if you want to be notified if text has been cut/copied within * the remote desktop. */ onRemoteClipboardData: ReplaySubject; onKeyboardReset: BehaviorSubject; onFocused: BehaviorSubject; onFullScreen: BehaviorSubject; onReconnect: Subject; /** * When an instruction is received from the tunnel */ onTunnelInstruction: BehaviorSubject<{ opcode: string; parameters: any; }>; /** * The actual underlying remote desktop client */ private client; /** * The tunnel being used by the underlying remote desktop client */ private tunnel; /** * All currently-exposed filesystems. When the Guacamole server exposes * a filesystem object, that object will be made available as a * ManagedFilesystem within this array. */ private filesystems; private subjectFilesystems; /** * All uploaded files. As files are uploaded, their progress can be * observed through the elements of this array. It is intended that * this array be manipulated externally as needed. */ private uploads; constructor(filesystemService: ManagedFilesystemService, tunnelRestApiService: TunnelRestApiService); /** * Set up the manager * @param t WebsocketTunnel, HTTPTunnel or ChainedTunnel */ initialize(t: Tunnel): void; /** * Get the guacamole connection state */ getState(): string; /** * Check to see if the given state equals the current state * @param state */ isState(state: string): boolean; /** * Set the display focus * @param newFocused */ setFocused(newFocused: boolean): void; /** * Set full screen * @param newFullScreen */ setFullScreen(newFullScreen: boolean): void; /** * Is the display full screen? */ isFullScreen(): boolean; /** * Is the tunnel connected? */ isConnected(): boolean; /** * Get the guacamole client */ getClient(): Client; /** * Get the guacamole tunnel */ getTunnel(): Tunnel; /** * Get the filesystems published by guacamole */ getFilesystems(): Observable; /** * Generate a thumbnail * @param {number} width The width of the thumbnail * @param {number} height The height of the thumbnail * @returns {string} An image data url */ createThumbnail(width?: number, height?: number): string; /** * Generate a screenshot * @param {blob} done Callback with the screenshot blob data */ createScreenshot(done: any): void; /** * Send text to the remote clipboard * @param {string} text Clipboard text to send */ sendRemoteClipboardData(text: string): void; /** * Reset the keyboard * This will release all keys */ resetKeyboard(): void; /** * Disconnect from the remote desktop */ disconnect(): void; /** * Connect to the remote desktop */ connect(parameters?: {}): void; /** * Uploads the given file to the server through this client. * The file transfer can be monitored through the corresponding entry in * the uploads array of the given managedClient. * * @param file * The file to upload. * * @param [fs] * The filesystem to upload the file to, if any. If not specified, the * file will be sent as a generic Guacamole file stream. * * @param [directory=fs.currentDirectory] * The directory within the given filesystem to upload the file to. If * not specified, but a filesystem is given, the current directory of * that filesystem will be used. */ uploadFile(file: File, fs: ManagedFilesystem, directory: ManagedFile): ManagedFileUpload; /** * Returns the current uploads. */ getUploads(): ManagedFileUpload[]; /** * Removes completed or failed uploads from the list. */ clearCompletedUploads(): void; /** * Creates a new ManagedFileUpload which uploads the given file to the * server through the given Guacamole client. * * @param file * The file to upload. * * @param [object] * The object to upload the file to, if any, such as a filesystem * object. * * @param [streamName] * The name of the stream to upload the file to. If an object is given, * this must be specified. * * @return * A new ManagedFileUpload object which can be used to track the * progress of the upload. */ private createUploadInstance; /** * Set the connection state and emit the new state to any subscribers * @param state Connection state */ private setState; /** * Receive clipboard data from the remote desktop and emit an event to the client * @param stream * @param mimetype */ private handleClipboard; /** * Receive published filesystems and store them * @param object * @param name * @private */ private handleFilesystem; /** * Handle any received file * @param stream * @param mimetype * @param filename * @private */ private handleFileReceived; /** * Build the URL query parameters to send to the tunnel connection */ private buildParameters; /** * Bind the client and tunnel event handlers */ private bindEventHandlers; /** * Handle any client errors by disconnecting and updating the connection state * @param state State received from the client */ private handleClientError; /** * Update the connection state when the client state changes * @param state State received from the client */ private handleClientStateChange; /** * Handle any tunnel errors by disconnecting and updating the connection state * @param status Status received from the tunnel * See https://guacamole.apache.org/doc/gug/protocol-reference.html for error reference */ private handleTunnelError; /** * Update the connection state when the tunnel state changes * @param state State received from the tunnel */ private handleTunnelStateChange; /** * Determines whether the given file transfer state indicates an * in-progress transfer. * * @param transferState * The file transfer state to check. */ private static isTransferInProgress; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }