RooTicket.vala
authorAlan Knowles <alan@roojs.com>
Wed, 31 Oct 2018 05:19:41 +0000 (13:19 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 31 Oct 2018 05:19:41 +0000 (13:19 +0800)
RooTicket.vala

index b1dc975..779bcfc 100644 (file)
@@ -110,30 +110,33 @@ class RooTicket : Object
                
        }
        
-       public  static void setAuth(Soup.Message message) {
-       
-               string str;
-               var username = "";
-               var password = "";
-               GLib.FileUtils.get_contents(GLib.Environment.get_home_dir() + "/.netrc", out str);
-               var lines = str.split("\n");
-               for(var i=0; i< lines.length; i++) {
-               // assumes one line per entry.. if not we are buggered...
-                               GLib.debug("got %s" , lines[i]);
-               
-                       var bits =  Regex.split_simple ("[ \t]+", lines[i].strip());
-                       if (bits.length < 6 || bits[0] != "machine" || bits[1] != "git.roojs.com") {
-                               continue;
-                       }
-                               GLib.debug("found password?");
-                       // we are gussing.... 
-                       username = bits[3];
-                       password = bits[5];
+       public  static void setAuth(Soup.Message message) 
+       {
+               var rs =  RooTicket.singleton();                
+               if (rs.username.length < 1) {
+                       string str;
+                       GLib.FileUtils.get_contents(GLib.Environment.get_home_dir() + "/.netrc", out str);
+                       var lines = str.split("\n");
+                       for(var i=0; i< lines.length; i++) {
+                       // assumes one line per entry.. if not we are buggered...
+                                       GLib.debug("got %s" , lines[i]);
                        
+                               var bits =  Regex.split_simple ("[ \t]+", lines[i].strip());
+                               if (bits.length < 6 || bits[0] != "machine" || bits[1] != "git.roojs.com") {
+                                       continue;
+                               }
+                                       GLib.debug("found password?");
+                               // we are gussing.... 
+                               username = bits[3];
+                               password = bits[5];
+                               RooTicket.singleton().username  = bits[3];
+                               RooTicket.singleton().password  = bits[5];              
+                       }
                }
-               RooTicket.singleton().user = 
+
+               public Gee.ArrayList<RooTicket> tickets; // only available for singletonn.              
        
-               var authCode = Base64.encode ("%s:%s".printf(username, password).data);
+               var authCode = Base64.encode ("%s:%s".printf(rs.username, rs.password).data);
                message.request_headers.append("Authorization", "Basic %s".printf(authCode));