about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command/commands.c6
-rw-r--r--src/roster_list.c42
-rw-r--r--src/roster_list.h4
3 files changed, 22 insertions, 30 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index a301efd4..57a6b151 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1009,7 +1009,8 @@ cmd_group(gchar **args, struct cmd_help_t help)
             return TRUE;
         }
 
-        roster_add_to_group(group, barejid);
+        roster_add_to_group(group, pcontact);
+        roster_send_add_to_group(group, pcontact);
 
         return TRUE;
     }
@@ -1035,7 +1036,8 @@ cmd_group(gchar **args, struct cmd_help_t help)
             return TRUE;
         }
 
-        roster_remove_from_group(group, barejid);
+        roster_remove_from_group(group, pcontact);
+        roster_send_remove_from_group(group, pcontact);
 
         return TRUE;
     }
diff --git a/src/roster_list.c b/src/roster_list.c
index c4329a3b..62d99323 100644
--- a/src/roster_list.c
+++ b/src/roster_list.c
@@ -31,7 +31,6 @@
 #include "jid.h"
 #include "tools/autocomplete.h"
 #include "profanity.h"
-#include "xmpp/xmpp.h"
 
 // nicknames
 static Autocomplete name_ac;
@@ -336,41 +335,32 @@ roster_get_group(const char * const group)
 }
 
 void
-roster_add_to_group(const char * const group, const char * const barejid)
+roster_add_to_group(const char * const group, PContact contact)
 {
-    PContact contact = g_hash_table_lookup(contacts, barejid);
+    assert(contact != NULL);
 
-    if (contact != NULL) {
-        if (p_contact_in_group(contact, group)) {
-            if (p_contact_name(contact) != NULL) {
-                prof_handle_already_in_group(p_contact_name(contact), group);
-            } else {
-                prof_handle_already_in_group(p_contact_barejid(contact), group);
-            }
-            return;
+    if (p_contact_in_group(contact, group)) {
+        if (p_contact_name(contact) != NULL) {
+            prof_handle_already_in_group(p_contact_name(contact), group);
+        } else {
+            prof_handle_already_in_group(p_contact_barejid(contact), group);
         }
-
-        roster_send_add_to_group(group, contact);
-
+        return;
     }
 }
 
 void
-roster_remove_from_group(const char * const group, const char * const barejid)
+roster_remove_from_group(const char * const group, PContact contact)
 {
-    PContact contact = g_hash_table_lookup(contacts, barejid);
+    assert(contact != NULL);
 
-    if (contact != NULL) {
-        if (!p_contact_in_group(contact, group)) {
-            if (p_contact_name(contact) != NULL) {
-                prof_handle_not_in_group(p_contact_name(contact), group);
-            } else {
-                prof_handle_not_in_group(p_contact_barejid(contact), group);
-            }
-            return;
+    if (!p_contact_in_group(contact, group)) {
+        if (p_contact_name(contact) != NULL) {
+            prof_handle_not_in_group(p_contact_name(contact), group);
+        } else {
+            prof_handle_not_in_group(p_contact_barejid(contact), group);
         }
-
-        roster_send_remove_from_group(group, contact);
+        return;
     }
 }
 
diff --git a/src/roster_list.h b/src/roster_list.h
index 85a4cffc..8fe2b5bd 100644
--- a/src/roster_list.h
+++ b/src/roster_list.h
@@ -50,8 +50,8 @@ char * roster_find_contact(char *search_str);
 char * roster_find_resource(char *search_str);
 GSList * roster_get_group(const char * const group);
 GSList * roster_get_groups(void);
-void roster_add_to_group(const char * const group, const char * const barejid);
-void roster_remove_from_group(const char * const group, const char * const barejid);
+void roster_add_to_group(const char * const group, PContact contact);
+void roster_remove_from_group(const char * const group, PContact contact);
 char * roster_find_group(char *search_str);
 char * roster_find_jid(char *search_str);