/** @constructor */
remoting.HostController = function() {
/** @return {remoting.HostPlugin} */
- var createNpapiPlugin = function() {
- var plugin = remoting.HostSession.createPlugin();
+ var createPluginForMe2Me = function() {
/** @type {HTMLElement} @private */
var container = document.getElementById('daemon-plugin-container');
- container.appendChild(plugin);
- return plugin;
+ return remoting.createNpapiPlugin(container);
};
/** @type {remoting.HostDispatcher} @private */
- this.hostDispatcher_ = new remoting.HostDispatcher(createNpapiPlugin);
+ this.hostDispatcher_ = new remoting.HostDispatcher(createPluginForMe2Me);
/** @param {string} version */
var printVersion = function(version) {
UNKNOWN: 6
};
+/**
+ * @param {string} state The host controller state name.
+ * @return {remoting.HostController.State} The state enum value.
+ */
+remoting.HostController.State.fromString = function(state) {
+ if (!remoting.HostController.State.hasOwnProperty(state)) {
+ throw "Invalid HostController.State: " + state;
+ }
+ return remoting.HostController.State[state];
+}
+
/** @enum {number} */
remoting.HostController.AsyncResult = {
OK: 0,
};
/**
+ * @param {string} result The async result name.
+ * @return {remoting.HostController.AsyncResult} The result enum value.
+ */
+remoting.HostController.AsyncResult.fromString = function(result) {
+ if (!remoting.HostController.AsyncResult.hasOwnProperty(result)) {
+ throw "Invalid HostController.AsyncResult: " + result;
+ }
+ return remoting.HostController.AsyncResult[result];
+}
+
+/**
* Set of features for which hasFeature() can be used to test.
*
* @enum {string}
newHostId, hostPin, startHostWithHash.bind(
null, hostName, publicKey, privateKey,
remoting.identity.getCachedEmail(),
- remoting.oauth2.exportRefreshToken()),
+ remoting.oauth2.getRefreshToken()),
onError);
}
} else {
* callback.
*/
remoting.HostController.prototype.getLocalHostState = function(onDone) {
- this.hostDispatcher_.getDaemonState(onDone, function() {
- onDone(remoting.HostController.State.NOT_IMPLEMENTED);
+ this.hostDispatcher_.getDaemonState(onDone, function(error) {
+ onDone(remoting.HostController.State.UNKNOWN);
});
};
this.hostDispatcher_.clearPairedClients(onDone, onError);
};
+/**
+ * Returns true if the NPAPI plugin is being used.
+ * @return {boolean}
+ */
+remoting.HostController.prototype.usingNpapiPlugin = function() {
+ return this.hostDispatcher_.usingNpapiPlugin();
+}
+
/** @type {remoting.HostController} */
remoting.hostController = null;