-/**
+/**
code to fetch ticket info...
public string project_id;
public string description;
public string shortname;
+
+}
+
+public class RooOption : Object
+{
+
+ public string id; // not really important that they are numbers..
+ public string name;
+ public string display_name;
+
+ public RooOption (string id, string name, string display_name)
+ {
+ this.id = id;
+ this.display_name = name;
+ }
}
+
public class RooProject : Object
{
public string id; // not really important that they are numbers..
public class RooTicket : Object
{
-
+ public enum NotMe {
+ TRUE,
+ FALSE
+ }
+ public enum Closed {
+ TRUE,
+ FALSE
+ }
+
//const string baseurl = "https://roojs.com/admin.php/Ro/mtrack_ticket";
const string roourl = "https://roojs.com/admin.php/Roo";
public static RooTicket singleton()
public Gee.ArrayList<RooTicket> tickets; // only available for singletonn.
public Gee.ArrayList<RooProject> projects; // only available for singletonn.
public Gee.ArrayList<RooRepo> repos; // only available for singletonn.
+
+ public Gee.ArrayList<RooOption> milestones;
+ public Gee.ArrayList<RooOption> priorities;
+ public Gee.ArrayList<RooOption> serverities;
+ public Gee.ArrayList<RooOption> classifications;
+ public Gee.ArrayList<RooOption> developers;
+
+
public string username = ""; // only available for singletonn.
public string password = ""; // only available for singletonn.
}
+ public Gee.ArrayList<RooOption> readJsonArray(Json.Array a)
+ {
+ var ret = new Gee.ArrayList<RooOption>();
+ for(var i = 0; i < a.get_length(); i++) {
+ var t = a.get_object_element(i);
+ ret.add(new RooOption(
+ t.get_string_member("id"),
+ t.get_string_member("display_name")
+ ));
+ }
+ return ret;
+
+ }
public RooTicket addTicket(Json.Object t)
{
public RooProject? getProjectByRepo(GitRepo repo)
{
+ var rt = RooTicket.singleton();
+
+ if (rt.repos.size < 1) {
+ rt.loadRepos();
+ }
+ if (rt.projects.size < 1) {
+ rt.loadProjects();
+ }
+
var pid = "";
- for(var roo_repo in this.repos.values) {
+ foreach(var roo_repo in rt.repos) {
if (roo_repo.shortname == repo.name) {
pid = roo_repo.project_id;
break;
}
}
if (pid == "") {
+ GLib.debug("getProjectByRepo: repo has no project");
return null;
}
+ // get project by id...
+ foreach(var roo_project in rt.projects) {
+ if (roo_project.id == pid) {
+ GLib.debug("getProjectByRepo: project_id = %s", pid);
+ return roo_project;
+ }
+ }
+ GLib.debug("getProjectByRepo: can not find project");
+ return null;
}
}
}
- public void loadTickets()
+ public void loadTickets(string project_id, NotMe not_me, Closed closed)
{
RooTicket.singleton().tickets = new Gee.ArrayList<RooTicket>();
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);
+ }
+
var params = Soup.Form.encode_hash(table);
session.send_message (message);
var data = (string) message.response_body.flatten().data;
- GLib.debug("got %s", data);
+ //GLib.debug("got %s", data);
try {
var parser = new Json.Parser ();
parser.load_from_data (data, -1);
session.send_message (message);
var data = (string) message.response_body.flatten().data;
- GLib.debug("got %s", data);
+ //GLib.debug("got %s", data);
try {
var parser = new Json.Parser ();
parser.load_from_data (data, -1);
session.send_message (message);
var data = (string) message.response_body.flatten().data;
- GLib.debug("got %s", data);
+ //GLib.debug("got %s", data);
try {
var parser = new Json.Parser ();
parser.load_from_data (data, -1);
}
}
-
+ public void loadProjectOptions(string pid)
+ {
+
+ var rt = RooTicket.singleton();
+
+ 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_object_member ("data");
+
+ rt.milestones = this.readJsonArray( rd.get_array_member("milestone"));
+ rt.priorities = this.readJsonArray( rd.get_array_member("priority"));
+ rt.serverities = this.readJsonArray( rd.get_array_member("severity"));
+ rt.classifications = this.readJsonArray( rd.get_array_member("classification"));
+ rt.developers = this.readJsonArray( rd.get_array_member("developer"));
+
+
+
+
+ // got a valid result...
+
+
+ } catch (Error e) {
+ GLib.error(e.message);
+ return;
+ }
+
+ }
public static void setAuth(Soup.Message message)
{