fix date calc
[gitlive] / Spawn.js
index 2246391..8ed7bc4 100644 (file)
--- a/Spawn.js
+++ b/Spawn.js
@@ -31,7 +31,7 @@ var GLib      = imports.gi.GLib;
 *
 *
 *  CRITICAL - needs this change to gir in GLib-2.0.gir g_spawn_async_with_pipes
-*
+*  Fixed in Ubuntu 12.10
     <parameter name="argv" transfer-ownership="none">
          <array c:type="gchar**">
             <type name="utf8"/>
@@ -43,8 +43,9 @@ var GLib      = imports.gi.GLib;
           </array>
         </parameter>
 *
-*
-*<method name="read_line"
+*  ALSO in GLib-2.0.gir
+
+<method name="read_line"
               c:identifier="g_io_channel_read_line"
               throws="1">
         <return-value transfer-ownership="none">
@@ -63,7 +64,7 @@ var GLib      = imports.gi.GLib;
         </parameters>
       </method>
 *
-*
+* run g-ir-compile -o /usr/lib/girepostitory-1.0/GLib-2.0.typelib GLib-2.0.gir
 *
 * 
 */
@@ -108,7 +109,7 @@ Spawn.prototype = {
     cwd: false,
     args: false,
     exceptions : false,
-    debug : true,
+    debug : false,
     /**
      * @property output {String} resulting output
      */
@@ -212,9 +213,9 @@ Spawn.prototype = {
         }
         
         
-        this.in_ch = GLib.io_channel_unix_new(ret.standard_input);
-        this.out_ch = GLib.io_channel_unix_new(ret.standard_output);
-        this.err_ch = GLib.io_channel_unix_new(ret.standard_error);
+        this.in_ch = new GLib.IOChannel.unix_new(ret.standard_input);
+        this.out_ch = new GLib.IOChannel.unix_new(ret.standard_output);
+        this.err_ch = new GLib.IOChannel.unix_new(ret.standard_error);
         
         // make everything non-blocking!
         
@@ -251,8 +252,18 @@ Spawn.prototype = {
         if (this.pid !== false) {
             // child can exit before we get this far..
             if (this.listeners.input) {
+               print("Trying to call listeners");
                 try {
                     this.write(this.listeners.input.call(this));
+                    // this probably needs to be a bit smarter...
+                   //but... let's close input now..
+                   this.in_ch.close();
+                   _this.in_ch = false;
+                  
+                   
+                   
+                   
+                   
                 } catch (e) {
                     tidyup();
                     throw e;
@@ -302,12 +313,19 @@ Spawn.prototype = {
         if (!this.in_ch) {
             return 0; // input is closed
         }
-        var ret = {};
-        var res = this.in_ch.write_chars(str, str.length);
+       //print("write: " + str);
+       // NEEDS GIR FIX! for return value.. let's ignore for the time being..
+       //var ret = {};
+        //var res = this.in_ch.write_chars(str, str.length, ret);
+       var res = this.in_ch.write_chars(str, str.length);
+       
+       //print("write_char retunred:" + JSON.stringify(res) +  ' ' +JSON.stringify(ret)  );
+       
         if (res != GLib.IOStatus.NORMAL) {
             throw "Write failed";
         }
-        return ret.bytes_written;
+        //return ret.value;
+        return str.length;
         
     },