From ad56d57251f67ac416ff7ad71a76f30836d2ccb3 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 26 Jun 2010 00:11:08 +0200 Subject: Added groups to roster --- src/gui/Contact.vala | 62 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 20 deletions(-) (limited to 'src/gui/Contact.vala') diff --git a/src/gui/Contact.vala b/src/gui/Contact.vala index 0e27b07..4ced825 100644 --- a/src/gui/Contact.vala +++ b/src/gui/Contact.vala @@ -1,10 +1,20 @@ public class Contact : Object { - public enum Show { - ONLINE, AWAY, CHAT, DND, XA, UNDEFINED + 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()); } - public enum Subscription { - BOTH + private static string get_default_group() { + return "Allgemein"; } public Contact(string jid0, string? name0) { @@ -13,25 +23,18 @@ public class Contact : Object { update_display_string(); } - public class Resource : Object { - public Resource(int prio0, Show show0, string? status0) { - Object(priority: prio0, show: show0, status: status0); + public Gee.Set get_groups() { + if(groups.is_empty) { + return defaultGroups.read_only_view; + } + else { + return groups.read_only_view; } - - 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(); + public void add_group(string group) { + groups.add(group); + } private void update_display_string() { if (name != null) @@ -58,4 +61,23 @@ public class Contact : Object { 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;} + } } -- cgit v1.2.3