mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 07:21:43 +00:00
fix
This commit is contained in:
parent
97f68c39bb
commit
1309e2ab8f
|
@ -69,7 +69,7 @@ Router.add('/test', function(render) {
|
|||
alert("모든 메시지가 정상적으로 보였다면 테스트에 성공한 것입니다.");
|
||||
};
|
||||
|
||||
var content = FILE.readFile("data/test-oss-20231030.json", FILE.CdoCharset.CdoUTF_8);
|
||||
var content = FILE.readFile("data/test-oss-korea-2023.json", FILE.CdoCharset.CdoUTF_8);
|
||||
var data = JSON.parse(content);
|
||||
render("app/test.html", {
|
||||
"data": data
|
||||
|
|
18
lib/adb.js
18
lib/adb.js
|
@ -6,17 +6,17 @@ var SYS = require("lib/system");
|
|||
|
||||
// A common Android devices
|
||||
function ADBObject() {
|
||||
var _interface = SHELL.create();
|
||||
this._interface = SHELL.create();
|
||||
|
||||
this.setBinPath = function(binPath) {
|
||||
this.binPath = binPath;
|
||||
_interface.setPrefix(this.binPath);
|
||||
this._interface.setPrefix(this.binPath);
|
||||
return this;
|
||||
};
|
||||
|
||||
this.getDevices = function() {
|
||||
var devices = [];
|
||||
var result = _interface.exec(["devices"]);
|
||||
var result = this._interface.exec(["devices"]);
|
||||
|
||||
splitLn(result).forEach(function(line) {
|
||||
var row = line.split(/\s+/);
|
||||
|
@ -63,32 +63,32 @@ function ADBObject() {
|
|||
|
||||
// download a file from target device
|
||||
this.pull = function(id, path) {
|
||||
return _interface.exec(["-s", id, "pull", path, "data\\"]);
|
||||
return this._interface.exec(["-s", id, "pull", path, "data\\"]);
|
||||
};
|
||||
|
||||
// upload a file to target device
|
||||
this.push = function(id, filename, path) {
|
||||
return _interface.exec(["-s", id, "push", "data\\" + filename, path]);
|
||||
return this._interface.exec(["-s", id, "push", "data\\" + filename, path]);
|
||||
};
|
||||
|
||||
// install APK file
|
||||
this.install = function(id, filename) {
|
||||
return _interface.exec(["-s", id, "install", "data\\" + filename]);
|
||||
return this._interface.exec(["-s", id, "install", "data\\" + filename]);
|
||||
};
|
||||
|
||||
// Uninstall the App
|
||||
this.uninstall = function(id, appname) {
|
||||
return _interface.exec(["-s", id, "uninstall", appname]);
|
||||
return this._interface.exec(["-s", id, "uninstall", appname]);
|
||||
};
|
||||
|
||||
// reboot device
|
||||
this.reboot = function(id) {
|
||||
return _interface.exec(["-s", id, "reboot"]);
|
||||
return this._interface.exec(["-s", id, "reboot"]);
|
||||
};
|
||||
|
||||
// set the binary path
|
||||
this.binPath = "bin\\platform-tools_r33.0.0-windows\\platform-tools\\adb.exe";
|
||||
_interface.setPrefix(this.binPath);
|
||||
this._interface.setPrefix(this.binPath);
|
||||
}
|
||||
|
||||
// An Android Emulator
|
||||
|
|
53
lib/http.js
53
lib/http.js
|
@ -17,7 +17,7 @@ var PROCESS_VERSION = SYS.getProcessVersion();
|
|||
var DEFAULT_USER_AGENT = "WelsonJS/0.2.7 (" + OS_NAME + "; " + OS_ARCH + "; " + PROCESS_VERSION + "; " + DEVICE_UUID + "; abuse@catswords.net)";
|
||||
|
||||
var HTTPObject = function(engine) {
|
||||
var _interface = null;
|
||||
this._interface = null;
|
||||
|
||||
this.contentType = "application/x-www-form-urlencoded";
|
||||
this.requestBody = "";
|
||||
|
@ -82,9 +82,11 @@ var HTTPObject = function(engine) {
|
|||
switch (this.engine) {
|
||||
case "MSXML":
|
||||
if (typeof XMLHttpRequest !== "undefined") {
|
||||
_interface = new XMLHttpRequest();
|
||||
console.log("A");
|
||||
this._interface = new XMLHttpRequest();
|
||||
} else {
|
||||
_interface = CreateObject([
|
||||
console.log("B");
|
||||
this._interface = CreateObject([
|
||||
"Microsoft.XMLHTTP",
|
||||
"WinHttp.WinHttpRequest.5.1",
|
||||
"Msxml3.XMLHTTP",
|
||||
|
@ -105,13 +107,15 @@ var HTTPObject = function(engine) {
|
|||
break;
|
||||
|
||||
case "CURL":
|
||||
_interface = SHELL.create();
|
||||
_interface.setPrefix("bin\\curl.exe"); // the location of cURL binary
|
||||
console.log("C");
|
||||
this._interface = SHELL.create();
|
||||
this._interface.setPrefix("bin\\curl.exe"); // the location of cURL binary
|
||||
break;
|
||||
|
||||
case "BITS":
|
||||
_interface = SHELL.create();
|
||||
_interface.setPrefix("bitsadmin.exe"); // the location of BITS binary
|
||||
console.log("D");
|
||||
this._interface = SHELL.create();
|
||||
this._interface.setPrefix("bitsadmin.exe"); // the location of BITS binary
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -246,7 +250,7 @@ var HTTPObject = function(engine) {
|
|||
|
||||
this.getHeader = function(key) {
|
||||
try {
|
||||
return _interface.getResponseHeader(key);
|
||||
return this._interface.getResponseHeader(key);
|
||||
} catch (e) {
|
||||
console.error("HTTPObject.getHeader() -> ", e.message);
|
||||
}
|
||||
|
@ -254,7 +258,7 @@ var HTTPObject = function(engine) {
|
|||
|
||||
this.getHeaders = function() {
|
||||
try {
|
||||
var raw = _interface.getAllResponseHeaders();
|
||||
var raw = this._interface.getAllResponseHeaders();
|
||||
|
||||
return raw.split(/[\r\n]+/).filter(function(s) {
|
||||
return s.trim().length > 0;
|
||||
|
@ -385,11 +389,11 @@ var HTTPObject = function(engine) {
|
|||
// Open
|
||||
switch (this.method) {
|
||||
case "POST":
|
||||
_interface.open(method, url, this.isAsynchronous);
|
||||
this._interface.open(method, url, this.isAsynchronous);
|
||||
break;
|
||||
|
||||
case "GET":
|
||||
_interface.open(method, url, this.isAsynchronous);
|
||||
this._interface.open(method, url, this.isAsynchronous);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -439,27 +443,30 @@ var HTTPObject = function(engine) {
|
|||
this.setHeader("Content-Type", this.contentType);
|
||||
}
|
||||
|
||||
console.log("engine: ", this.engine);
|
||||
console.log("interface: ", typeof this._interface);
|
||||
|
||||
try {
|
||||
// MSXML (XHR)
|
||||
if (this.engine == "MSXML") {
|
||||
for (var key in this.headers) {
|
||||
_interface.setRequestHeader(key, this.evaluate(this.headers[key]));
|
||||
this._interface.setRequestHeader(key, this.evaluate(this.headers[key]));
|
||||
}
|
||||
|
||||
switch (this.method) {
|
||||
case "GET":
|
||||
_interface.send();
|
||||
this._interface.send();
|
||||
break;
|
||||
|
||||
default:
|
||||
_interface.send(this.serialize());
|
||||
this._interface.send(this.serialize());
|
||||
}
|
||||
|
||||
// Waiting a response
|
||||
while (_interface.readyState < 4) sleep(100);
|
||||
while (this._interface.readyState < 4) sleep(100);
|
||||
|
||||
// Get response text
|
||||
responseText = _interface.responseText;
|
||||
responseText = this._interface.responseText;
|
||||
}
|
||||
|
||||
// cURL
|
||||
|
@ -584,7 +591,7 @@ var HTTPObject = function(engine) {
|
|||
cmd.push(state.url);
|
||||
|
||||
// Get response text
|
||||
responseText = _interface.setCharset(this.charset).exec(cmd);
|
||||
responseText = this._interface.setCharset(this.charset).exec(cmd);
|
||||
|
||||
// Reload a cookie in the pipe
|
||||
if (this.isLoggingCookie) {
|
||||
|
@ -597,14 +604,14 @@ var HTTPObject = function(engine) {
|
|||
console.log("Detected charset:", detectedCharset);
|
||||
|
||||
if (detectedCharset != null && this.charset != detectedCharset) {
|
||||
var _interface = SHELL.create();
|
||||
responseText = _interface.setCharset(detectedCharset).exec(cmd);
|
||||
debuggingText = _interface.stderr.read();
|
||||
var this._interface = SHELL.create();
|
||||
responseText = this._interface.setCharset(detectedCharset).exec(cmd);
|
||||
debuggingText = this._interface.stderr.read();
|
||||
}
|
||||
}
|
||||
|
||||
// Get debuging text
|
||||
debuggingText = _interface.stderr.read();
|
||||
debuggingText = this._interface.stderr.read();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -619,11 +626,11 @@ var HTTPObject = function(engine) {
|
|||
|
||||
if (this.method == "GET") {
|
||||
cmd = cmd.concat(["/download", "/priority", job_priority, url, out.path]); // build a BITS command
|
||||
_interface.exec(cmd); // launch the download job
|
||||
this._interface.exec(cmd); // launch the download job
|
||||
out.reload(); // read the downloaded data
|
||||
responseText = out.read() // set the downloaded data to response text
|
||||
|
||||
var err = _interface.exec(["/geterror", job_name]); // get error information
|
||||
var err = this._interface.exec(["/geterror", job_name]); // get error information
|
||||
debuggingText = err.stdout.read(); // set the error information to debugging text
|
||||
|
||||
out.destroy(); // destroy the downloaded data
|
||||
|
|
26
lib/shell.js
26
lib/shell.js
|
@ -5,7 +5,7 @@ var FILE = require("lib/file");
|
|||
var PipeIPC = require("lib/pipe-ipc");
|
||||
|
||||
var ShellObject = function() {
|
||||
this.interface = null;
|
||||
this._interface = null;
|
||||
|
||||
this.currentDirectory = null;
|
||||
this.workingDirectory = null;
|
||||
|
@ -20,8 +20,8 @@ var ShellObject = function() {
|
|||
|
||||
this.create = function() {
|
||||
try {
|
||||
this.interface = CreateObject("WScript.Shell");
|
||||
this.currentDirectory = this.interface.CurrentDirectory;
|
||||
this._interface = CreateObject("WScript.Shell");
|
||||
this.currentDirectory = this._interface.CurrentDirectory;
|
||||
this.workingDirectory = this.currentDirectory;
|
||||
} catch (e) {
|
||||
console.error("ShellObject.create() ->", e.message);
|
||||
|
@ -42,7 +42,7 @@ var ShellObject = function() {
|
|||
this.setWorkingDirectory = function(dirname) {
|
||||
if (typeof(dirname) === "string") {
|
||||
this.workingDirectory = dirname;
|
||||
this.interface.CurrentDirectory = this.workingDirectory;
|
||||
this._interface.CurrentDirectory = this.workingDirectory;
|
||||
console.log("ShellObject.workingDirectory ->", this.workingDirectory);
|
||||
}
|
||||
return this;
|
||||
|
@ -79,7 +79,7 @@ var ShellObject = function() {
|
|||
try {
|
||||
var c = this.build(cmd);
|
||||
console.log("ShellObject.createProcess() ->", c);
|
||||
return this.interface.Exec(c);
|
||||
return this._interface.Exec(c);
|
||||
} catch (e) {
|
||||
console.error("ShellObject.createProcess() ->", e.message);
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ var ShellObject = function() {
|
|||
var c = "%comspec% /c (" + this.build(cmd) + ") 1> " + this.stdout.path;
|
||||
//c += " 2>&1";
|
||||
c += " 2> " + this.stderr.path;
|
||||
this.interface.Run(c, 0, true);
|
||||
this._interface.Run(c, 0, true);
|
||||
console.log("ShellObject.exec() ->", c);
|
||||
sleep(1);
|
||||
|
||||
|
@ -127,7 +127,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.isVisibleWindow ? 0 : 1), !fork);
|
||||
};
|
||||
|
||||
this.runAs = function(FN, args) {
|
||||
|
@ -142,11 +142,11 @@ var ShellObject = function() {
|
|||
};
|
||||
|
||||
this.createShoutcut = function(shoutcutName, cmd) {
|
||||
var desktopPath = this.interface.SpecialFolders("Desktop");
|
||||
var desktopPath = this._interface.SpecialFolders("Desktop");
|
||||
var path = desktopPath + "\\" + shoutcutName + ".lnk";
|
||||
|
||||
if (!FILE.fileExists(path)) {
|
||||
var link = this.interface.CreateShortcut(path);
|
||||
var link = this._interface.CreateShortcut(path);
|
||||
//link.TargetPath = "cmd";
|
||||
//link.Arguments = "/q /c " + this.build(cmd);
|
||||
link.TargetPath = "wscript";
|
||||
|
@ -161,13 +161,13 @@ var ShellObject = function() {
|
|||
};
|
||||
|
||||
this.getPathOfMyDocuments = function() {
|
||||
return this.interface.SpecialFolders("MyDocuments");
|
||||
return this._interface.SpecialFolders("MyDocuments");
|
||||
};
|
||||
|
||||
this.release = function() {
|
||||
console.log("ShellObject.release() ->", this.currentDirectory);
|
||||
this.interface.CurrentDirectory = this.currentDirectory;
|
||||
this.interface = null;
|
||||
this._interface.CurrentDirectory = this.currentDirectory;
|
||||
this._interface = null;
|
||||
};
|
||||
|
||||
this.create();
|
||||
|
@ -221,7 +221,7 @@ exports.getPathOfMyDocuments = function() {
|
|||
|
||||
exports.CdoCharset = PipeIPC.CdoCharset;
|
||||
|
||||
exports.VERSIONINFO = "Windows Shell Interface with WelsonJS Pipe-IPC module (shell.js) version 0.3.11";
|
||||
exports.VERSIONINFO = "Windows Shell Interface (shell.js) version 0.3.11";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user