From 265fff8f40ad521d09bf56e8f2e8fad89ef63865 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 23 Jun 2013 16:29:42 +0100 Subject: Show message when contact already in group --- src/profanity.c | 8 ++++++++ src/profanity.h | 1 + src/ui/core.c | 6 ++++++ src/ui/ui.h | 1 + src/xmpp/roster.c | 5 +++++ 5 files changed, 21 insertions(+) (limited to 'src') diff --git a/src/profanity.c b/src/profanity.c index 732cbf5c..7042b7b5 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -148,6 +148,14 @@ prof_handle_duck_result(const char * const result) ui_current_page_off(); } +void +prof_handle_already_in_group(const char * const barejid, + const char * const group) +{ + ui_contact_already_in_group(barejid, group); + ui_current_page_off(); +} + void prof_handle_error_message(const char *from, const char *err_msg) { diff --git a/src/profanity.h b/src/profanity.h index ebf7d044..7254c2de 100644 --- a/src/profanity.h +++ b/src/profanity.h @@ -82,5 +82,6 @@ void prof_handle_duck_help(const char * const result); void prof_handle_duck_result(const char * const result); void prof_handle_roster_add(const char * const barejid, const char * const name); void prof_handle_roster_remove(const char * const barejid); +void prof_handle_already_in_group(const char * const barejid, const char * const group); #endif diff --git a/src/ui/core.c b/src/ui/core.c index 3b08e593..86518bf7 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -455,6 +455,12 @@ ui_roster_remove(const char * const barejid) cons_show("Roster item removed: %s", barejid); } +void +ui_contact_already_in_group(const char * const barejid, const char * const group) +{ + cons_show("%s already in group %s", barejid, group); +} + void ui_contact_online(const char * const barejid, const char * const resource, const char * const show, const char * const status, GDateTime *last_activity) diff --git a/src/ui/ui.h b/src/ui/ui.h index a41a8cff..f8a6ff2d 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -114,6 +114,7 @@ void ui_room_member_presence(const char * const room, const char * const nick, const char * const show, const char * const status); void ui_roster_add(const char * const barejid, const char * const name); void ui_roster_remove(const char * const barejid); +void ui_contact_already_in_group(const char * const barejid, const char * const group); // contact status functions void ui_status_room(const char * const contact); diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index 8e8dc328..f29ac09b 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -293,6 +293,11 @@ roster_add_to_group(const char * const group, const char * const barejid) 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; } -- cgit 1.4.1-2-gfad0