[open-ils-commits] r8166 - in
trunk/Open-ILS/xul/staff_client/chrome/content: main util
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Dec 6 18:22:55 EST 2007
Author: phasefx
Date: 2007-12-06 18:03:06 -0500 (Thu, 06 Dec 2007)
New Revision: 8166
Modified:
trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
trunk/Open-ILS/xul/staff_client/chrome/content/util/file.js
trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js
Log:
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.
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js 2007-12-06 22:57:45 UTC (rev 8165)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js 2007-12-06 23:03:06 UTC (rev 8166)
@@ -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 */
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/file.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/file.js 2007-12-06 22:57:45 UTC (rev 8165)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/file.js 2007-12-06 23:03:06 UTC (rev 8166)
@@ -166,7 +166,7 @@
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 @@
'_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;
}
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js 2007-12-06 22:57:45 UTC (rev 8165)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js 2007-12-06 23:03:06 UTC (rev 8166)
@@ -282,22 +282,24 @@
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);
this.error.sdump('D_ERROR','_NSPrint_dos_print PRINT EXCEPTION: ' + js2JSON(e) + '\n');
More information about the open-ils-commits
mailing list