X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=RooTicket.vala;h=779bcfc151de00621f892ed2e171e2b139aa4a18;hb=48b3d2b4281bfa78ae11b4dfb5f91d5475aefd90;hp=232b918a75d93ba8fcd1228e9472cfcc4d3c7792;hpb=629cbba854e1d1c4e5518e4c179308f9ed8a0918;p=gitlive diff --git a/RooTicket.vala b/RooTicket.vala index 232b918a..779bcfc1 100644 --- a/RooTicket.vala +++ b/RooTicket.vala @@ -20,6 +20,9 @@ class RooTicket : Object return _RooTicket; } public Gee.ArrayList tickets; // only available for singletonn. + public string username = ""; // only available for singletonn. + public string password = ""; // only available for singletonn. + public string id; // not really important that they are numbers.. public string summary; @@ -38,6 +41,16 @@ class RooTicket : Object GLib.debug("ADD ticket %s : %s : %s", add.id, add.summary, add.project_id_name); } + public RooTicket? getById(string id) + { + foreach(var t in this.tickets) { + if (t.id == id) { + return t; + } + } + return null; + + } public void loadTickets() { @@ -97,29 +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]; + } } - var authCode = Base64.encode ("%s:%s".printf(username, password).data); + public Gee.ArrayList tickets; // only available for singletonn. + + var authCode = Base64.encode ("%s:%s".printf(rs.username, rs.password).data); message.request_headers.append("Authorization", "Basic %s".printf(authCode));