RooTicket.vala
[gitlive] / RooTicket.vala
index 4cf57ca..cbf0030 100644 (file)
@@ -17,6 +17,16 @@ public class RooRepo : Object
 
 }
 
+public class RooOption : Object 
+{
+       
+       public string id; // not really important that they are numbers..
+       public string name;
+
+}
+
+
 public class RooProject  : Object 
 {
        public string  id; // not really important that they are numbers..
@@ -237,11 +247,21 @@ public class RooTicket : Object
         
                
                var table = new GLib.HashTable<string, string>(str_hash, str_equal);
-        
-               table.insert("query[viewtype]","me");
+               if (not_me  == NotMe.FALSE) {
+                       table.insert("query[viewtype]","me");
+               } else {
+               
+               }               
+               if (closed  == Closed.TRUE) {
+                       table.insert("query[viewtype]","me");
+               } else {
+               
+               }
+
                table.insert("limit","999");
                table.insert("sort","summary");
                table.insert("dir","ASC");
+               
                if (project_id != "") {
                        table.insert("project_id",project_id);
                }
@@ -402,7 +422,67 @@ public class RooTicket : Object
                }
                
        }
-       
+       public void loadProjectOptions(string pid)
+       {
+               RooTicket.singleton().repos = new Gee.ArrayList<RooRepo>();
+        
+               
+               var table = new GLib.HashTable<string, string>(str_hash, str_equal);
+        
+               table.insert("_options_for",pid);
+
+               var params = Soup.Form.encode_hash(table);
+               
+               var url = "%s/%s?%s" . printf(roourl, "mtrack_ticket", params);
+               
+               GLib.debug("request %s", url);
+               
+               var session = new Soup.Session ();
+               session.timeout = 0;
+               var message = new Soup.Message ("GET", url);
+               
+               
+               RooTicket.setAuth(message);
+               
+               session.send_message (message);
+               
+               var data = (string) message.response_body.flatten().data;
+               //GLib.debug("got %s", data);
+               try {
+                       var parser = new Json.Parser ();
+                       parser.load_from_data (data, -1);
+
+                       var response = parser.get_root().get_object();
+                       var status = response.get_boolean_member("success");
+               
+                       if(!status){
+                               GLib.error(response.get_string_member("errorMsg"));
+                               return;
+                       }
+                       var rd = response.get_array_member ("data");
+                       
+                       this.milestones = this.readJsonArray( rd.get_array_member("milestone"));
+                       this.priorities = this.readJsonArray( rd.get_array_member("priority"));
+                       this.serverities = this.readJsonArray( rd.get_array_member("severity"));
+                       this.classifications  = this.readJsonArray( rd.get_array_member("classification"));
+                       this.developers = this.readJsonArray( rd.get_array_member("developer"));
+                       
+                       
+                       
+                       // got a valid result...
+                       var _this = RooTicket.singleton();
+                       for(var i = 0; i < rd.get_length(); i++) {
+                               _this.addRepo(rd.get_object_element(i));
+                       }
+                        
+               
+               } catch (Error e) {
+                       GLib.error(e.message);
+                       return;
+               }
+               
+       }
        
        public  static void setAuth(Soup.Message message) 
        {