summaryrefslogtreecommitdiffstats
path: root/src/gui/Contact.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/Contact.vala')
-rw-r--r--src/gui/Contact.vala45
1 files changed, 35 insertions, 10 deletions
diff --git a/src/gui/Contact.vala b/src/gui/Contact.vala
index 1db1e62..d79cfff 100644
--- a/src/gui/Contact.vala
+++ b/src/gui/Contact.vala
@@ -9,26 +9,51 @@ public class Contact : Object {
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? status {get; construct;}
}
public string jid {get; construct;}
public string? name {get; construct;}
public Subscription subscription {get; set;}
- public Gee.TreeSet<string> groups;
- public Gee.HashMap<string, Resource> resources {get; private set;}
-
- public string display_string {
- get {
- if (name != null)
- return name;
- else
- return jid;
+ public Gee.TreeSet<string> groups = new Gee.TreeSet<string>();
+ public string display_string {get; private set;}
+
+ private Gee.HashMap<string, Resource> resources = new Gee.HashMap<string, Resource>();
+
+ private void update_display_string() {
+ if (name != null)
+ display_string = name;
+ else
+ display_string = jid;
+ }
+
+ public Gee.Map.Entry<string, Resource>? get_resource_with_highest_priority() {
+ int max_prio = int.MIN;
+ Gee.Map.Entry<string, Resource> ret = null;
+
+ foreach(Gee.Map.Entry<string, Resource> 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();
}
}