From: phasefx Date: Thu, 6 Dec 2007 23:06:33 +0000 (+0000) Subject: banging on the 'dos print' kludge. There was a 1.2 regression involving a file path... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=29f99f201fd0c371d2a4cd67a1adc8e2e878b1e0;p=Evergreen.git banging on the 'dos print' kludge. There was a 1.2 regression involving a file path, which still needs to be tested with an actual windows machine and receipt printer. This changeset also adds linux lpr support for 'dos print'. I may need to use this print strategy for incremental printing, as much as it pains me. git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2_1@8167 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 98168fb9cf..52b21ecad1 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -1,5 +1,15 @@ dump('Loading constants.js\n'); +const MODE_RDONLY = 0x01; +const MODE_WRONLY = 0x02; +const MODE_CREATE = 0x08; +const MODE_APPEND = 0x10; +const MODE_TRUNCATE = 0x20; +const MODE_SYNC = 0x40; +const MODE_EXCL = 0x80; +const PERMS_FILE = 0644; +const PERMS_DIR = 0755; + const my_constants = { 'magical_statuses' : { '1' : { 'disable_in_copy_editor' : true, 'block_mark_item_action' : true }, /* | Checked out | t */ diff --git a/Open-ILS/xul/staff_client/chrome/content/util/file.js b/Open-ILS/xul/staff_client/chrome/content/util/file.js index ca57ff8f92..0cdf367d0b 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/file.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/file.js @@ -166,7 +166,7 @@ util.file.prototype = { this._f = Components.classes["@mozilla.org/network/file-input-stream;1"] .createInstance(Components.interfaces.nsIFileInputStream); - this._f.init(this._file, 0x01, 0, 0); + this._f.init(this._file, MODE_RDONLY, 0, 0); /* this._f.QueryInterface(Components.interfaces.nsILineInputStream); this._istream = this._f; @@ -188,23 +188,31 @@ util.file.prototype = { '_create_output_stream' : function(param) { try { - //dump('_create_output_stream('+param+')\n'); + //dump('_create_output_stream('+param+') for '+this._file.path+'\n'); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead"); if (!this._file) throw('Must .get() a file first.'); - if (! this._file.exists()) this._file.create( 0, 0640 ); - + if (! this._file.exists()) { + if (param == 'truncate+exec') { + this._file.create( 0, 0777 ); + } else { + this._file.create( 0, PERMS_FILE ); + } + } this._output_stream = Components.classes["@mozilla.org/network/file-output-stream;1"] .createInstance(Components.interfaces.nsIFileOutputStream); switch(param){ case 'append' : - this._output_stream.init(this._file, 0x02 | 0x08 | 0x10 | 0x40, 0644, 0); + this._output_stream.init(this._file, MODE_WRONLY | MODE_APPEND, PERMS_FILE, 0); break; + case 'truncate+exec' : + this._output_stream.init(this._file, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, 0); + break; case 'truncate' : default: - this._output_stream.init(this._file, 0x02 | 0x08 | 0x20 | 0x40, 0644, 0); + this._output_stream.init(this._file, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, 0); break; } diff --git a/Open-ILS/xul/staff_client/chrome/content/util/print.js b/Open-ILS/xul/staff_client/chrome/content/util/print.js index b4d6f9b863..89e47b57a9 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/print.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js @@ -282,21 +282,23 @@ util.print.prototype = { var text = w; var file = new util.file('receipt.txt'); - file.write_content('truncate',text); file.close(); + file.write_content('truncate',text); + var path = file._file.path; + file.close(); file = new util.file('receipt.bat'); - if (! file._file.exists()) { - file.write_content('truncate','copy chrome\\open_ils_staff_client\\content\\conf\\receipt.txt lpt1 /b\n'); - file.close(); - file = new util.file('receipt.bat'); - } + file.write_content('truncate+exec','#!/bin/sh\ncopy ' + path + ' lpt1 /b\nlpr ' + path + '\n'); + file.close(); + file = new util.file('receipt.bat'); var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess); process.init(file._file); var args = []; - process.run(true, args, args.length); + dump('process.run = ' + process.run(true, args, args.length) + '\n'); + + file.close(); } catch (e) { //alert('Probably not printing: ' + e);