banging on the 'dos print' kludge. There was a 1.2 regression involving a file path...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 6 Dec 2007 23:06:33 +0000 (23:06 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 6 Dec 2007 23:06:33 +0000 (23:06 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2_1@8167 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/chrome/content/util/file.js
Open-ILS/xul/staff_client/chrome/content/util/print.js

index 98168fb..52b21ec 100644 (file)
@@ -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 */
index ca57ff8..0cdf367 100644 (file)
@@ -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;
                        }
 
index b4d6f9b..89e47b5 100644 (file)
@@ -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);