Professional Documents
Culture Documents
Tuytuyt
Tuytuyt
js" />
// Version 3.5.2
//
// for documentation on the query strings and functions used to build queries.
//debugger;
var i = 0;
if (args.length >=3) {
if (args.length >= 4) {
params = args.slice(3);
if (requestProcessor.ValidGetFunctions.indexOf(procFunc) != -1) {
}
return 0;
};
//debugger;
try {
value = value.replace(/</g,"<").replace(/>/g,">");
printerBidiSchemaElement.value = response;
} catch (err) {
return 0;
};
return 2;
};
var retVal = 2;
pageCache.statusRead = true;
var statusContent = pageCache.GetContent("/DevMgmt/ProductStatusDyn.xml", false);
if (statusMsg.toUpperCase() == "DoorOpen".toUpperCase())
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason', 'DoorOpen');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason',
'closeDoorOrCover');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason', 'MediaEmpty');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason', 'toner-empty-
error');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason', 'MediaJam');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason', 'jamInPrinter');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason', 'output-area-
full');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason', 'toner-empty-
warning');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason', 'toner-low-
report');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason',
'trayEmptyOrOpen');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason', 'paused');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason', 'cartridgeLow');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason',
'replaceCartridgeOut');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason',
'cartridgeVeryLow');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason',
'cartridgeCounterfeitQuestion');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason',
'cartridgeFailure');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason',
'incompatibleConsumable');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason',
'insertSETUPCartridge');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason',
'upgradableSupply');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason',
'nonHPSupplyDetected');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason', 'genuineHP');
else if (statusMsg.toUpperCase() == "startupRoutineFailed".toUpperCase())
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason',
'startupRoutineFailed');
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason',
'inReserveMode');
else
printerBidiSchemaResponses.AddString('\\Printer.Status.Summary:StateReason', 'None');
retVal = 0;
return retVal;
};
this.responses = printerBidiSchemaResponses;
this.pageCache = pageCache;
this.Context = scriptContext;
this.content = "";
this.ValidGetFunctions =
"FindIndexXmlStr,TagContainsBool,TagAnyContainsBool,FindIndexXmlConvertStr,AllContentStr," +
"FindIndexXmlInt,
InnerXmlInt,InnerXmlStr,InnerXmlMapStr,GetQueuePropStr,QueueRequestStr,StrCmpBool,MultiTagCon
tainsBool";
// ,ElementListStr,NthElementStr
this.ValidSetFunctions = "SetRequest";
};
if (content)
if (queryArray.length > 0)
this.responses.AddInt32(bidiQueryStr,result);
return true;
return false;
};
this.content = "";
if (content)
if (queryArray.length > 0)
this.responses.AddString(bidiQueryStr, result);
return true;
return false;
};
this.content = "";
if (content)
if (queryArray.length > 2)
this.responses.AddString(bidiQueryStr, result);
}
}
return true;
return false;
};
var MIN_SIZE=5;
if (null != result) {
if(typeof minSize=='undefined')
minSize=MIN_SIZE;
var i = minSize;
i = i + 2;
return result;
};
{
this.content = "";
if (content)
if (null != value)
result = queryPattern.test(value);
if (null != this.responses)
this.responses.AddBool(bidiQueryStr, result);
return true;
return false;
return false;
};
this.content = "";
if (content)
if (null != value)
if (value == queryArray[1])
result = true;
if (null != this.responses)
this.responses.AddBool(bidiQueryStr, result);
return true;
return false;
return false;
};
//example usage:
//bidiQueryStr - \Printer.Configuration.DuplexUnit:Installed
//contentName - /DevMgmt/ProductConfigDyn.xml
//queryArray - dd:DuplexUnit,dd:DuplexBindingOption;Installed;longEdge;shortEdge
if (content)
if (-1 != content.indexOf(args[i]))
if (option != null)
if (result == true)
break;
}
}
this.responses.AddBool(bidiQueryStr, result);
return true;
return false;
};
if (option == queryArray.pop())
return true;
return false;
};
this.content = "";
if (content)
do
result = true;
content = this.content;
if (null != this.responses)
this.responses.AddBool(bidiQueryStr, result);
return true;
return false;
return false;
};
this.content = "";
this.responses.AddInt32(bidiQueryStr, content);
if (content)
return true;
return false;
};
if (null != queryArray)
this.content = "";
this.responses.AddString(bidiQueryStr, content);
}
if (content)
return true;
return false;
};
RequestProcessor.prototype.AllContentStr = function(bidiQueryStr,contentName,queryArray) {
if (null != queryArray)
cacheContent = truePattern.test(queryArray[0]);
if (xmlTagRe.test(content))
content = content.substring(xmlTagRe.lastIndex);
this.responses.AddString(bidiQueryStr, content);
return true;
return false;
};
var mapIndex = 0;
if (mapRe.test(queryArray[mapIndex]))
break;
this.content = "";
if (null != content)
this.responses.AddString(bidiQueryStr, value);
return;
if (name.indexOf("default") === 0)
defaultValue = value;
if (null != this.responses)
this.responses.AddString(bidiQueryStr,defaultValue);
return true;
return false;
};
if (null != xml) {
this.content = xml;
do {
var innerXml = this.InnerXmlMultiple(parent, this.content);
return innerXml;
return null;
};
// If there is an attribute in the opening tag then we failed until I split the openRe in half and
this.content = xml.substring(closeRe.lastIndex);
return inner;
return null;
};
RequestProcessor.prototype.InnerXmlMultiple = function(tagArray, xml) {
var index=0;
// Save the context for the parent so that this.content is correct when we leave
for (index=0;index<tagArray.length;index++)
if (null != content)
content = this.InnerXml(tagArray[index],content);
parentContext = this.content;
else
break;
if (null != parentContext)
this.content = parentContext;
}
return content;
return null;
};
this.Context = scriptContext;
this.printerStream = printerStream;
this.ContentArray = [];
this.readContent = "";
this.ToMatch = "";
this.lastHeader = null;
this.readAttempts = 0;
this.statusRead = false;
};
if (saveInCache)
content = this.ContentArray[contentName];
content = this.FetchLedmContent(contentName);
this.SetContent(contentName, content);
}
}
return content;
};
if (null != contentName)
this.ContentArray[contentName] = content;
};
// Break out RawRequest (it is common for all gets and sets) and simplify FetchLedmContent and
SetLedmContent
PageCache.prototype.FetchLedmContent = function(path) {
if (null != path)
if (this.VerifyChannel())
return this.RawRequest(requestStr);
return null;
};
PageCache.prototype.VerifyChannel = function () {
if (this.ChannelVerified === undefined) {
//var pjlcommand = [0x40, 0x50, 0x4A, 0x4C, 0x20, 0x43, 0x4F, 0x4D, 0x4D, 0x45, 0x4E, 0x54, 0x20,
0x22, 0x22, 0x0D, 0x0A, 0x0D, 0x0A];
var pjlcommand = [0x1B, 0x25, 0x2D, 0x31, 0x32, 0x33, 0x34, 0x35, 0x58, 0x40, 0x50, 0x4A, 0x4C,
0x20, 0x43, 0x4F, 0x4D, 0x4D, 0x45, 0x4E, 0x54, 0x20, 0x22, 0x22, 0x0D, 0x0A, 0x1B, 0x25, 0x2D, 0x31,
0x32, 0x33, 0x34, 0x35, 0x58];
if (this.IsWebServerConnected(500)) {
this.ChannelVerified = true;
} else {
this.ChannelVerified = false;
return this.ChannelVerified;
};
if (null != path) {
if (null == content)
requestStr = requestStr.concat("\r\n");
} else
return this.RawRequest(requestStr);
return null;
};
if (writtenStrLen > 0)
return response;
return null;
};
PageCache.prototype.GetHttpResponse = function () {
if (httpHeader.ReadHeaderNow()) {
if (httpHeader.ContentLength > 0)
ledmResponse = this.ReadResponse(httpHeader.ContentLength);
else if (httpHeader.IsChunked)
{
ledmResponse = this.ReadChunkedResponse();
return ledmResponse;
return null;
};
return null;
if (bytes[i] != undefined)
result += String.fromCharCode(bytes[i]);
return result;
};
PageCache.prototype.BytesFromString = function(content) {
return null;
}
var bytes = new Array(content.length);
bytes[i] = content.charCodeAt(i);
return bytes;
};
var totalLength = 0;
do
try
// Delay the Read after handling huge data packets, this will make further responses from
the device better
if(this.statusRead == false)
sleep(1000);
this.readAttempts = 0;
catch (err)
return -1;
this.readAttempts++;
if (tempBytes.length > 0)
totalLength += actLen;
requestLength -= actLen;
zeroCount = 60;
this.ToMatch = "";
break;
else
sleep(3);
zeroCount--;
return totalLength;
};
PageCache.prototype.ReadResponse = function(len) {
if (len != NaN)
do
this.readContent = "";
return temp;
return null;
};
PageCache.prototype.ReadChunkedResponse = function() {
do {
temp = this.ReadChunk();
break;
if (null != temp) {
results = results.concat(temp);
}
else {
this.ReadBlock(2);
return results;
};
PageCache.prototype.ReadChunkHeader = function() {
var i = this.readContent.indexOf("\r\n");
if (i > 0) {
this.readContent = this.readContent.substr(i+2);
return len;
return -1;
};
PageCache.prototype.ReadChunk = function() {
if (chunkLength < 0) {
this.ReadBlock(8);
chunkLength = this.ReadChunkHeader();
if (chunkLength != 0)
do {
i = this.ReadBlock(remLen);
this.readContent = this.readContent.substring(chunkLength+2);
return temp;
else
return null;
};
do {
receivedData = true;
this.FlushChannel(100);
return receivedData;
};
do {
} while (((tempBytes != null) && (tempBytes.length > 0)) && (curDate - date < timeout));
this.readContent = "";
};
HttpHeader = function(pageCache) {
this.StatusCode = 0;
this.IsChunked = false;
this.ContentLength = 0;
this.Content = "";
this.pageCache = pageCache;
};
HttpHeader.prototype.ReadHeaderNow = function () {
try {
if (this.ReadHeader() == true) {
this.pageCache.lastHeader = this;
} else {
return false;
} catch (err) {
return false;
return true;
};
HttpHeader.prototype.ReadHeader = function() {
if (index > 0) {
this.pageCache.readContent = this.pageCache.readContent.substring(index);
if (index >= 0) {
index = this.ReadUntil("\r\n\r\n");
if (index >= 0)
this.pageCache.readContent = this.pageCache.readContent.substring(index+4);
this.StatusCode = parseInt(this.Content.substring(8));
if (ContentLengthPattern.test(this.Content))
this.ContentLength =
parseInt(this.Content.substring(ContentLengthPattern.lastIndex));
else if (ChunkedPattern.test(this.Content))
this.IsChunked = true;
else {
this.ContentLength = -1;
this.IsChunked = false;
else
return false;
return true;
};
HttpHeader.prototype.ReadUntil = function(match){
return index;
this.pageCache.ToMatch = match;
do {
index = this.pageCache.readContent.indexOf(match);
return index;
};
function sleep(milliSeconds) {