changeset 1092:1ef7572c3096

Sort the resources again when a priority changes
author Mikael Berthe <mikael@lilotux.net>
date Fri, 08 Dec 2006 22:32:26 +0100
parents 10f9d6fcfeab
children 6ca9a65df21f
files mcabber/src/roster.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/roster.c	Fri Dec 08 22:08:05 2006 +0100
+++ b/mcabber/src/roster.c	Fri Dec 08 22:32:26 2006 +0100
@@ -188,8 +188,14 @@
 
   for (p = rost->resource; p; p = g_slist_next(p)) {
     res *r = p->data;
-    if (!strcmp(r->name, resname))
+    if (!strcmp(r->name, resname)) {
+      if (prio != r->prio) {
+        r->prio = prio;
+        rost->resource = g_slist_sort(rost->resource,
+                                      (GCompareFunc)&resource_compare_prio);
+      }
       return r;
+    }
   }
 
   // Resource not found
@@ -496,7 +502,6 @@
 
   // New or updated resource
   p_res = get_or_add_resource(roster_usr, resname, prio);
-  p_res->prio = prio;
   p_res->status = bstat;
   if (p_res->status_msg) {
     g_free((gchar*)p_res->status_msg);