mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-10 07:01:21 +00:00
GUAC-586: Use data source when connecting to connections or groups. Remove deprecated getUserContext() from GuacamoleSession and related classes. Use identifiers which embed the data source for client URLs.
This commit is contained in:
@@ -158,7 +158,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
var RECONNECT_ACTION = {
|
||||
name : "CLIENT.ACTION_RECONNECT",
|
||||
callback : function reconnectCallback() {
|
||||
$scope.client = guacClientManager.replaceManagedClient(uniqueId, $routeParams.params);
|
||||
$scope.client = guacClientManager.replaceManagedClient($routeParams.id, $routeParams.params);
|
||||
guacNotification.showStatus(false);
|
||||
}
|
||||
};
|
||||
@@ -219,13 +219,13 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
$scope.$on('guacClientClipboard', function clientClipboardListener(event, client, mimetype, clipboardData) {
|
||||
$scope.clipboardData = clipboardData;
|
||||
});
|
||||
|
||||
/*
|
||||
* Parse the type, name, and id out of the url paramteres,
|
||||
* as well as any extra parameters if set.
|
||||
|
||||
/**
|
||||
* The client which should be attached to the client UI.
|
||||
*
|
||||
* @type ManagedClient
|
||||
*/
|
||||
var uniqueId = $routeParams.type + '/' + $routeParams.id;
|
||||
$scope.client = guacClientManager.getManagedClient(uniqueId, $routeParams.params);
|
||||
$scope.client = guacClientManager.getManagedClient($routeParams.id, $routeParams.params);
|
||||
|
||||
var keysCurrentlyPressed = {};
|
||||
|
||||
|
@@ -28,6 +28,7 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
||||
|
||||
// Required types
|
||||
var ClientProperties = $injector.get('ClientProperties');
|
||||
var ClientIdentifier = $injector.get('ClientIdentifier');
|
||||
var ManagedClientState = $injector.get('ManagedClientState');
|
||||
var ManagedDisplay = $injector.get('ManagedDisplay');
|
||||
var ManagedFileDownload = $injector.get('ManagedFileDownload');
|
||||
@@ -153,8 +154,8 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
||||
* desired connection ID, display resolution, and supported audio/video
|
||||
* codecs.
|
||||
*
|
||||
* @param {String} id
|
||||
* The ID of the connection or group to connect to.
|
||||
* @param {ClientIdentifier} identifier
|
||||
* The identifier representing the connection or group to connect to.
|
||||
*
|
||||
* @param {String} [connectionParameters]
|
||||
* Any additional HTTP parameters to pass while connecting.
|
||||
@@ -163,7 +164,7 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
||||
* The string of connection parameters to be passed to the Guacamole
|
||||
* client.
|
||||
*/
|
||||
var getConnectString = function getConnectString(id, connectionParameters) {
|
||||
var getConnectString = function getConnectString(identifier, connectionParameters) {
|
||||
|
||||
// Calculate optimal width/height for display
|
||||
var pixel_density = $window.devicePixelRatio || 1;
|
||||
@@ -173,21 +174,23 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
||||
|
||||
// Build base connect string
|
||||
var connectString =
|
||||
"id=" + encodeURIComponent(id)
|
||||
+ "&authToken=" + encodeURIComponent(authenticationService.getCurrentToken())
|
||||
+ "&width=" + Math.floor(optimal_width)
|
||||
+ "&height=" + Math.floor(optimal_height)
|
||||
+ "&dpi=" + Math.floor(optimal_dpi)
|
||||
"token=" + encodeURIComponent(authenticationService.getCurrentToken())
|
||||
+ "&GUAC_DATA_SOURCE=" + encodeURIComponent(identifier.dataSource)
|
||||
+ "&GUAC_ID=" + encodeURIComponent(identifier.id)
|
||||
+ "&GUAC_TYPE=" + encodeURIComponent(identifier.type)
|
||||
+ "&GUAC_WIDTH=" + Math.floor(optimal_width)
|
||||
+ "&GUAC_HEIGHT=" + Math.floor(optimal_height)
|
||||
+ "&GUAC_DPI=" + Math.floor(optimal_dpi)
|
||||
+ (connectionParameters ? '&' + connectionParameters : '');
|
||||
|
||||
// Add audio mimetypes to connect_string
|
||||
guacAudio.supported.forEach(function(mimetype) {
|
||||
connectString += "&audio=" + encodeURIComponent(mimetype);
|
||||
connectString += "&GUAC_AUDIO=" + encodeURIComponent(mimetype);
|
||||
});
|
||||
|
||||
// Add video mimetypes to connect_string
|
||||
guacVideo.supported.forEach(function(mimetype) {
|
||||
connectString += "&video=" + encodeURIComponent(mimetype);
|
||||
connectString += "&GUAC_VIDEO=" + encodeURIComponent(mimetype);
|
||||
});
|
||||
|
||||
return connectString;
|
||||
@@ -238,7 +241,9 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
||||
* or group.
|
||||
*
|
||||
* @param {String} id
|
||||
* The ID of the connection or group to connect to.
|
||||
* The ID of the connection or group to connect to. This String must be
|
||||
* a valid ClientIdentifier string, as would be generated by
|
||||
* ClientIdentifier.toString().
|
||||
*
|
||||
* @param {String} [connectionParameters]
|
||||
* Any additional HTTP parameters to pass while connecting.
|
||||
@@ -402,23 +407,23 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
||||
// Manage the client display
|
||||
managedClient.managedDisplay = ManagedDisplay.getInstance(client.getDisplay());
|
||||
|
||||
// Connect the Guacamole client
|
||||
client.connect(getConnectString(id, connectionParameters));
|
||||
// Parse connection details from ID
|
||||
var clientIdentifier = ClientIdentifier.fromString(id);
|
||||
|
||||
// Determine type of connection
|
||||
var typePrefix = id.substring(0, 2);
|
||||
// Connect the Guacamole client
|
||||
client.connect(getConnectString(clientIdentifier, connectionParameters));
|
||||
|
||||
// If using a connection, pull connection name
|
||||
if (typePrefix === 'c/') {
|
||||
connectionService.getConnection(id.substring(2))
|
||||
if (clientIdentifier.type === ClientIdentifier.Types.CONNECTION) {
|
||||
connectionService.getConnection(clientIdentifier.dataSource, clientIdentifier.id)
|
||||
.success(function connectionRetrieved(connection) {
|
||||
managedClient.name = connection.name;
|
||||
});
|
||||
}
|
||||
|
||||
// If using a connection group, pull connection name
|
||||
else if (typePrefix === 'g/') {
|
||||
connectionGroupService.getConnectionGroup(id.substring(2))
|
||||
else if (clientIdentifier.type === ClientIdentifier.Types.CONNECTION_GROUP) {
|
||||
connectionGroupService.getConnectionGroup(clientIdentifier.dataSource, clientIdentifier.id)
|
||||
.success(function connectionGroupRetrieved(group) {
|
||||
managedClient.name = group.name;
|
||||
});
|
||||
|
Reference in New Issue
Block a user