/* * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ /** * Main Guacamole web service namespace. * @namespace */ var GuacamoleService = GuacamoleService || {}; /** * An arbitary Guacamole connection group, having the given type, ID and name. * * @constructor * @param {Number} type The type of this connection group - either ORGANIZATIONAL * or BALANCING. * @param {String} id An arbitrary ID, likely assigned by the auth provider. * @param {String} name The human-readable name of this group. */ GuacamoleService.ConnectionGroup = function(type, id, name) { /** * The type of this connection group. * @type Number */ this.type = type; /** * The unique ID of this connection group. * @type String */ this.id = id; /** * The human-readable name associated with this connection group. * @type String */ this.name = name; /** * The parent connection group of this group. If this group is the root * group, this will be null. * * @type GuacamoleService.ConnectionGroup */ this.parent = null; /** * All connection groups contained within this group. * @type GuacamoleService.ConnectionGroup[] */ this.groups = []; /** * All connections contained within this group. * @type GuacamoleService.Connection[] */ this.connections = []; }; /** * Set of all possible types for ConnectionGroups. */ GuacamoleService.ConnectionGroup.Type = { /** * Organizational groups exist solely to hold connections or other groups, * and provide no other semantics. * * @type Number */ "ORGANIZATIONAL" : 0, /** * Balancing groups act as connections. Users that have READ permission on * balancing groups can use the group as if it were a connection, and that * group will choose an appropriate connection within itself for that user * to use. * * @type Number */ "BALANCING" : 1 }; /** * An arbitrary Guacamole connection, consisting of an ID/protocol pair. * * @constructor * @param {String} protocol The protocol used by this connection. * @param {String} id The ID associated with this connection. * @param {String} name The human-readable name associated with this connection. */ GuacamoleService.Connection = function(protocol, id, name) { /** * Reference to this connection. */ var guac_connection = this; /** * The parent connection group of this connection. * @type GuacamoleService.ConnectionGroup */ this.parent = null; /** * The protocol associated with this connection. */ this.protocol = protocol; /** * The ID associated with this connection. */ this.id = id; /** * All parameters associated with this connection, if available. */ this.parameters = {}; /** * The name of this connection. This name is arbitrary and local to the * group containing the connection. * * @type String */ this.name = name; /** * An array of GuacamoleService.Connection.Record listing the usage * history of this connection. */ this.history = []; /** * Returns the number of active users of this connection (which may be * multiple instances under the same user) by walking the history records. * * @return {Number} The number of active users of this connection. */ this.currentUsage = function() { // Number of users of this connection var usage = 0; // Walk history counting active entries for (var i=0; i