+/**
+
+code to fetch ticket info...
+
+
+*/
+static RooTicket _RooTicket;
+
+
+
+class RooTicket : Object
+{
+
+
+ public static RooTicket singleton()
+ {
+ if (_RooTicket == null) {
+ _RooTicket = new RooTicket();
+ _RooTicket.tickets = new Gee.ArrayList<RooTicket>();
+ }
+ return _RooTicket;
+ }
+ public Gee.ArrayList<RooTicket> tickets; // only available for singletonn.
+
+ public int id;
+ public string summary;
+ public string description;
+ public string project_id_name;
+
+
+ public void loadTickets()
+ {
+ var url = "https://roojs.com/admin.php/Roo/mtrack_ticket");
+
+ var table = new GLib.HashTable<string, string>(str_hash, str_equal);
+
+ table.insert("query[viewtype]","active");
+ table.insert("developer_id","494");
+ table.insert("limit","999");
+ table.insert("sort","summary");
+ table.insert("dir","ASC");
+
+
+ var params = Soup.Form.encode_hash(table);
+
+ url = "%s?%s" . printf(url, params);
+
+ GLib.debug("request %s", url);
+
+ var session = new Soup.Session ();
+ session.timeout = 0;
+ var message = new Soup.Message ("GET", url);
+
+
+ this.setAuth(message);
+
+ session.send_message (message);
+
+ var data = (string) message.response_body.flatten().data;
+ GLib.debug("got %s", data);
+
+
+ }
+
+ public void setAuth(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...
+ var bits = Regex.split_simple ("[ \t]+", line[i].strip());
+ if (bits.length < 7 || bits[0] != "machine" || bits[1] != "git.roojs.com") {
+ continue;
+ }
+ // we are gussing....
+ username = bits[3];
+ password = bits[5];
+
+ }
+ var authCode = Base64.encode ("%s:%s".printf(username), password)).data);
+ message.request_headers.append("Authorization", "Basic %s".printf(authCode));
+
+
+ }
+
+
+
+
\ No newline at end of file