diff --git a/lib/ovftool.js b/lib/ovftool.js index ae6f8b5..8ceb564 100644 --- a/lib/ovftool.js +++ b/lib/ovftool.js @@ -13,25 +13,31 @@ function OVFObject() { this.setBinPath = function(binPath) { this.binPath = binPath; }; - - this.setHostname = function(hostname) { - this.hostname = hostname; - }; - - this.setResourceName = function(resourceName) { - this.resourceName = resourceName; - }; - + + this.setHostname = function(hostname) { + this.hostname = hostname; + }; + + this.setResourceName = function(resourceName) { + this.resourceName = resourceName; + }; + this.saveTo = function() { var cred = CRED.get("password", "ovftool"); var connectionString = "vi://" + - cred.username + ":" + - encodeURIComponent(cred.password) + "@" + - this.hostname + "/" + - this.resourceName; - - // todo + cred.username + ":" + + encodeURIComponent(cred.password) + "@" + + this.hostname + "/" + + this.resourceName + ; + var cmd = [ + this.binPath, + connectionString, + "." + ]; + // run the command synchronously + SHELL.show(cmd, false); }; } @@ -50,7 +56,7 @@ function create() { exports.setCredential = setCredential; exports.create = create; -exports.VERSIONINFO = "Broadcom/VMware OVF Tool interface (ovftool.js) version 0.1"; +exports.VERSIONINFO = "Broadcom/VMware OVF Tool interface (ovftool.js) version 0.1.1"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require; diff --git a/lib/shell.js b/lib/shell.js index 4cfd457..f0d085d 100644 --- a/lib/shell.js +++ b/lib/shell.js @@ -11,7 +11,7 @@ var ShellObject = function() { this.workingDirectory = null; this.isElevated = false; this.isFork = false; - this.isVisibleWindow = false; + this.visibility = "hidden"; this.isPreventClear = false; this.charset = PipeIPC.CdoUS_ASCII; @@ -53,12 +53,21 @@ var ShellObject = function() { } return this; }; - + + this.setVisibility = function(visibility) { + this.setVisibility = visibility; + }; + + // @deprecated this.setVisibleWindow = function(visible) { - this.isVisibleWindow = visible; + if (visible == false) { + this.setVisibility("hidden"); + } else { + this.setVisibility("visible"); + } return this; }; - + this.build = function(cmd) { var prefix = this.prefix; var wrap = function(s) { @@ -137,7 +146,7 @@ var ShellObject = function() { var fork = (typeof(fork) !== "undefined") ? fork : true; var c = "%comspec% /q /c (" + this.build(cmd) + ")"; console.log("ShellObject.run() ->", c); - this._interface.Run(c, (!this.isVisibleWindow ? 0 : 1), !fork); + this._interface.Run(c, (this.visibility === "hidden" ? 0 : 1), !fork); }; this.runAs = function(FN, args) { @@ -147,7 +156,7 @@ var ShellObject = function() { if (typeof(args) !== "undefined") { _args = args.join(' '); } - oShell.shellExecute(FN, _args, this.workingDirectory, "runas", (!this.isVisibleWindow ? 0 : 1)); + oShell.shellExecute(FN, _args, this.workingDirectory, "runas", (this.visibility === "hidden" ? 0 : 1)); return oShell; }; @@ -205,7 +214,7 @@ exports.run = function(cmd, fork) { }; exports.show = function(cmd, fork) { - return (new ShellObject()).setVisibleWindow(true).run(cmd, fork); + return (new ShellObject()).setVisibility("visible").run(cmd, fork); }; exports.runAs = function(FN, args) { @@ -213,7 +222,7 @@ exports.runAs = function(FN, args) { }; exports.showAs = function(FN, args) { - return (new ShellObject()).setVisibleWindow(true).runAs(FN, args); + return (new ShellObject()).setVisibility("visible").runAs(FN, args); }; exports.createProcess = function(cmd, workingDirectory) { @@ -236,7 +245,7 @@ exports.getPathOfMyDocuments = function() { exports.CdoCharset = PipeIPC.CdoCharset; -exports.VERSIONINFO = "Windows Shell Interface (shell.js) version 0.3.15"; +exports.VERSIONINFO = "Windows Shell Interface (shell.js) version 0.3.16"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require;