mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUAC-1305: Send supported image formats within Guacamole protocol handshake.
This commit is contained in:
@@ -92,6 +92,13 @@ public abstract class TunnelRequest {
|
|||||||
*/
|
*/
|
||||||
public static final String VIDEO_PARAMETER = "GUAC_VIDEO";
|
public static final String VIDEO_PARAMETER = "GUAC_VIDEO";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the parameter specifying one supported image mimetype. This
|
||||||
|
* will normally appear multiple times within a single tunnel request -
|
||||||
|
* once for each mimetype.
|
||||||
|
*/
|
||||||
|
public static final String IMAGE_PARAMETER = "GUAC_IMAGE";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All supported object types that can be used as the destination of a
|
* All supported object types that can be used as the destination of a
|
||||||
* tunnel.
|
* tunnel.
|
||||||
@@ -350,4 +357,16 @@ public abstract class TunnelRequest {
|
|||||||
return getParameterValues(VIDEO_PARAMETER);
|
return getParameterValues(VIDEO_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all image mimetypes declared as supported within the
|
||||||
|
* tunnel request.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* A list of all image mimetypes declared as supported within the
|
||||||
|
* tunnel request, or null if no mimetypes were specified.
|
||||||
|
*/
|
||||||
|
public List<String> getImageMimetypes() {
|
||||||
|
return getParameterValues(IMAGE_PARAMETER);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -114,6 +114,11 @@ public class TunnelRequestService {
|
|||||||
if (videoMimetypes != null)
|
if (videoMimetypes != null)
|
||||||
info.getVideoMimetypes().addAll(videoMimetypes);
|
info.getVideoMimetypes().addAll(videoMimetypes);
|
||||||
|
|
||||||
|
// Add image mimetypes
|
||||||
|
List<String> imageMimetypes = request.getImageMimetypes();
|
||||||
|
if (imageMimetypes != null)
|
||||||
|
info.getImageMimetypes().addAll(imageMimetypes);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,13 +36,15 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
|||||||
var ManagedFileUpload = $injector.get('ManagedFileUpload');
|
var ManagedFileUpload = $injector.get('ManagedFileUpload');
|
||||||
|
|
||||||
// Required services
|
// Required services
|
||||||
var $window = $injector.get('$window');
|
|
||||||
var $document = $injector.get('$document');
|
var $document = $injector.get('$document');
|
||||||
|
var $q = $injector.get('$q');
|
||||||
|
var $window = $injector.get('$window');
|
||||||
var authenticationService = $injector.get('authenticationService');
|
var authenticationService = $injector.get('authenticationService');
|
||||||
var connectionGroupService = $injector.get('connectionGroupService');
|
var connectionGroupService = $injector.get('connectionGroupService');
|
||||||
var connectionService = $injector.get('connectionService');
|
var connectionService = $injector.get('connectionService');
|
||||||
var guacAudio = $injector.get('guacAudio');
|
var guacAudio = $injector.get('guacAudio');
|
||||||
var guacHistory = $injector.get('guacHistory');
|
var guacHistory = $injector.get('guacHistory');
|
||||||
|
var guacImage = $injector.get('guacImage');
|
||||||
var guacVideo = $injector.get('guacVideo');
|
var guacVideo = $injector.get('guacVideo');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,10 +151,11 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string of connection parameters to be passed to the
|
* Returns a promise which resolves with the string of connection
|
||||||
* Guacamole client during connection. This string generally contains the
|
* parameters to be passed to the Guacamole client during connection. This
|
||||||
* desired connection ID, display resolution, and supported audio/video
|
* string generally contains the desired connection ID, display resolution,
|
||||||
* codecs.
|
* and supported audio/video/image formats. The returned promise is
|
||||||
|
* guaranteed to resolve successfully.
|
||||||
*
|
*
|
||||||
* @param {ClientIdentifier} identifier
|
* @param {ClientIdentifier} identifier
|
||||||
* The identifier representing the connection or group to connect to.
|
* The identifier representing the connection or group to connect to.
|
||||||
@@ -160,12 +163,14 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
|||||||
* @param {String} [connectionParameters]
|
* @param {String} [connectionParameters]
|
||||||
* Any additional HTTP parameters to pass while connecting.
|
* Any additional HTTP parameters to pass while connecting.
|
||||||
*
|
*
|
||||||
* @returns {String}
|
* @returns {Promise.<String>}
|
||||||
* The string of connection parameters to be passed to the Guacamole
|
* A promise which resolves with the string of connection parameters to
|
||||||
* client.
|
* be passed to the Guacamole client, once the string is ready.
|
||||||
*/
|
*/
|
||||||
var getConnectString = function getConnectString(identifier, connectionParameters) {
|
var getConnectString = function getConnectString(identifier, connectionParameters) {
|
||||||
|
|
||||||
|
var deferred = $q.defer();
|
||||||
|
|
||||||
// Calculate optimal width/height for display
|
// Calculate optimal width/height for display
|
||||||
var pixel_density = $window.devicePixelRatio || 1;
|
var pixel_density = $window.devicePixelRatio || 1;
|
||||||
var optimal_dpi = pixel_density * 96;
|
var optimal_dpi = pixel_density * 96;
|
||||||
@@ -183,17 +188,30 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
|||||||
+ "&GUAC_DPI=" + Math.floor(optimal_dpi)
|
+ "&GUAC_DPI=" + Math.floor(optimal_dpi)
|
||||||
+ (connectionParameters ? '&' + connectionParameters : '');
|
+ (connectionParameters ? '&' + connectionParameters : '');
|
||||||
|
|
||||||
// Add audio mimetypes to connect_string
|
// Add audio mimetypes to connect string
|
||||||
guacAudio.supported.forEach(function(mimetype) {
|
guacAudio.supported.forEach(function(mimetype) {
|
||||||
connectString += "&GUAC_AUDIO=" + encodeURIComponent(mimetype);
|
connectString += "&GUAC_AUDIO=" + encodeURIComponent(mimetype);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add video mimetypes to connect_string
|
// Add video mimetypes to connect string
|
||||||
guacVideo.supported.forEach(function(mimetype) {
|
guacVideo.supported.forEach(function(mimetype) {
|
||||||
connectString += "&GUAC_VIDEO=" + encodeURIComponent(mimetype);
|
connectString += "&GUAC_VIDEO=" + encodeURIComponent(mimetype);
|
||||||
});
|
});
|
||||||
|
|
||||||
return connectString;
|
// Add image mimetypes to connect string
|
||||||
|
guacImage.getSupportedMimetypes().then(function supportedMimetypesKnown(mimetypes) {
|
||||||
|
|
||||||
|
// Add each image mimetype
|
||||||
|
angular.forEach(mimetypes, function addImageMimetype(mimetype) {
|
||||||
|
connectString += "&GUAC_IMAGE=" + encodeURIComponent(mimetype);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Connect string is now ready - nothing else is deferred
|
||||||
|
deferred.resolve(connectString);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -411,7 +429,10 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
|||||||
var clientIdentifier = ClientIdentifier.fromString(id);
|
var clientIdentifier = ClientIdentifier.fromString(id);
|
||||||
|
|
||||||
// Connect the Guacamole client
|
// Connect the Guacamole client
|
||||||
client.connect(getConnectString(clientIdentifier, connectionParameters));
|
getConnectString(clientIdentifier, connectionParameters)
|
||||||
|
.then(function connectClient(connectString) {
|
||||||
|
client.connect(connectString);
|
||||||
|
});
|
||||||
|
|
||||||
// If using a connection, pull connection name
|
// If using a connection, pull connection name
|
||||||
if (clientIdentifier.type === ClientIdentifier.Types.CONNECTION) {
|
if (clientIdentifier.type === ClientIdentifier.Types.CONNECTION) {
|
||||||
|
Reference in New Issue
Block a user