public class Contact : Object { public enum Show { ONLINE, AWAY, CHAT, DND, XA, UNDEFINED } public enum Subscription { BOTH } public Contact(string jid0, string? name0) { Object(jid: jid0, name: name0); update_display_string(); } public class Resource : Object { public Resource(int prio0, Show show0, string? status0) { Object(priority: prio0, show: show0, status: status0); } public int priority {get; construct;} public Show show {get; construct;} public string? status {get; construct;} } public string jid {get; construct;} public string? name {get; construct;} public Subscription subscription {get; set;} public Gdk.Pixbuf? avatar {get; set; default = null;} public Gee.TreeSet groups = new Gee.TreeSet(); public string display_string {get; private set;} private Gee.HashMap resources = new Gee.HashMap(); private void update_display_string() { if (name != null) display_string = name; else display_string = jid; } public Gee.Map.Entry? get_resource_with_highest_priority() { int max_prio = int.MIN; Gee.Map.Entry ret = null; foreach(Gee.Map.Entry res in resources) { if(res.value.priority > max_prio) { max_prio = res.value.priority; ret = res; } } return ret; } public void update_resource(string resource_name, Resource resource) { resources[resource_name] = resource; update_display_string(); } }