public class Contact : Object { private static Gee.TreeSet defaultGroups = new Gee.TreeSet(); private Gee.TreeSet groups = new Gee.TreeSet(); private Gee.HashMap resources = new Gee.HashMap(); public string jid {get; construct;} public string? name {get; construct;} public Subscription subscription {get; set;} public Gdk.Pixbuf? avatar {get; set; default = null;} public string display_string {get; private set;} static construct { defaultGroups.add(get_default_group()); } private static string get_default_group() { return "Allgemein"; } public Contact(string jid0, string? name0) { Object(jid: jid0, name: name0); update_display_string(); } public Gee.Set get_groups() { if(groups.is_empty) { return defaultGroups.read_only_view; } else { return groups.read_only_view; } } public void add_group(string group) { groups.add(group); } 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(); } public enum Show { ONLINE, AWAY, CHAT, DND, XA, UNDEFINED } public enum Subscription { BOTH } 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;} } }