about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-11-01 22:42:31 +0000
committerJames Booth <boothj5@gmail.com>2015-11-01 22:42:31 +0000
commite547ae0bcc42a3fddab4f49fa6dfec4815320c10 (patch)
tree8c1e2bc1fa78926ed34eb61488743609718760a6
parent2be3b7d9a298eae3fef2829b5c51895a17b10a0e (diff)
downloadprofani-tty-e547ae0bcc42a3fddab4f49fa6dfec4815320c10.tar.gz
mucwin_role_change takes ProfMucWin
-rw-r--r--src/event/server_events.c5
-rw-r--r--src/ui/mucwin.c8
-rw-r--r--src/ui/ui.h3
-rw-r--r--tests/unittests/ui/stub_ui.c2
4 files changed, 12 insertions, 6 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 7d39267b..bda81f25 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -592,7 +592,10 @@ sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean c
 
             // role changed
             } else if (g_strcmp0(role, old_role) != 0) {
-                mucwin_role_change(room, role, actor, reason);
+                ProfMucWin *mucwin = wins_get_muc(room);
+                if (mucwin) {
+                    mucwin_role_change(mucwin, role, actor, reason);
+                }
 
             // affiliation changed
             } else if (g_strcmp0(affiliation, old_affiliation) != 0) {
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index 2e722585..8eaac733 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -32,6 +32,8 @@
  *
  */
 
+#include <assert.h>
+
 #include "ui/win_types.h"
 #include "window_list.h"
 #include "log.h"
@@ -39,10 +41,12 @@
 #include "ui/window.h"
 
 void
-mucwin_role_change(const char *const roomjid, const char *const role, const char *const actor,
+mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor,
     const char *const reason)
 {
-    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
+    assert(mucwin != NULL);
+
+    ProfWin *window = (ProfWin*)mucwin;
     win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your role has been changed to: %s", role);
     if (actor) {
         win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor);
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 226d31aa..4c312c23 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -161,8 +161,7 @@ void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, voi
 #endif
 
 // MUC window
-void mucwin_role_change(const char *const roomjid, const char *const role, const char *const actor,
-    const char *const reason);
+void mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason);
 void mucwin_affiliation_change(const char *const roomjid, const char *const affiliation, const char *const actor,
     const char *const reason);
 void mucwin_role_and_affiliation_change(const char *const roomjid, const char *const role,
diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c
index 9a3f704a..e09c8199 100644
--- a/tests/unittests/ui/stub_ui.c
+++ b/tests/unittests/ui/stub_ui.c
@@ -191,7 +191,7 @@ void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char * const message
 void ui_room_join(const char * const roomjid, gboolean focus) {}
 void ui_switch_to_room(const char * const roomjid) {}
 
-void mucwin_role_change(const char * const roomjid, const char * const role, const char * const actor,
+void mucwin_role_change(ProfMucWin *mucwin, const char * const role, const char * const actor,
     const char * const reason) {}
 void mucwin_affiliation_change(const char * const roomjid, const char * const affiliation, const char * const actor,
     const char * const reason) {}