about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-11-02 00:17:46 +0000
committerJames Booth <boothj5@gmail.com>2015-11-02 00:17:46 +0000
commit6ed72d8a3570ba56a0af5c5fba2fe598eeeb1b12 (patch)
treee849f4e3f68b28e6ccaf5855c4b4b198e5495aee
parent42643391a44ff745892673b0d97723f415b6376a (diff)
downloadprofani-tty-6ed72d8a3570ba56a0af5c5fba2fe598eeeb1b12.tar.gz
mucwin_nick_change takes ProfMucWin
-rw-r--r--src/event/server_events.c5
-rw-r--r--src/ui/mucwin.c12
-rw-r--r--src/ui/ui.h2
-rw-r--r--tests/unittests/ui/stub_ui.c2
4 files changed, 11 insertions, 10 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 7168828a..3e054fa9 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -548,7 +548,10 @@ sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean c
     // handle self nick change
     if (muc_nick_change_pending(room)) {
         muc_nick_change_complete(room, nick);
-        mucwin_nick_change(room, nick);
+        ProfMucWin *mucwin = wins_get_muc(room);
+        if (mucwin) {
+            mucwin_nick_change(mucwin, nick);
+        }
 
     // handle roster complete
     } else if (!muc_roster_complete(room)) {
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index 9288293e..f300abec 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -323,14 +323,12 @@ mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, cons
 }
 
 void
-mucwin_nick_change(const char *const roomjid, const char *const nick)
+mucwin_nick_change(ProfMucWin *mucwin, const char *const nick)
 {
-    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
-    if (window == NULL) {
-        log_error("Received self nick change %s, but no window open for %s.", nick, roomjid);
-    } else {
-        win_vprint(window, '!', 0, NULL, 0, THEME_ME, "", "** You are now known as %s", nick);
-    }
+    assert(mucwin != NULL);
+
+    ProfWin *window = (ProfWin*)mucwin;
+    win_vprint(window, '!', 0, NULL, 0, THEME_ME, "", "** You are now known as %s", nick);
 }
 
 void
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 80073843..df5233bc 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -192,7 +192,7 @@ void mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick);
 void mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *const roles,
     const char *const affiliation, const char *const show, const char *const status);
 void mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, const char *const nick);
-void mucwin_nick_change(const char *const roomjid, const char *const nick);
+void mucwin_nick_change(ProfMucWin *mucwin, const char *const nick);
 void mucwin_occupant_presence(ProfMucWin *mucwin, const char *const nick, const char *const show,
     const char *const status);
 void mucwin_update_occupants(const char *const roomjid);
diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c
index eec4af29..655b2ed8 100644
--- a/tests/unittests/ui/stub_ui.c
+++ b/tests/unittests/ui/stub_ui.c
@@ -231,7 +231,7 @@ void mucwin_occupant_offline(ProfMucWin *mucwin, const char * const nick) {}
 void mucwin_occupant_online(ProfMucWin *mucwin, const char * const nick, const char * const roles,
     const char * const affiliation, const char * const show, const char * const status) {}
 void mucwin_occupant_nick_change(ProfMucWin *mucwin, const char * const old_nick, const char * const nick) {}
-void mucwin_nick_change(const char * const roomjid, const char * const nick) {}
+void mucwin_nick_change(ProfMucWin *mucwin, const char * const nick) {}
 void mucwin_occupant_presence(ProfMucWin *mucwin, const char * const nick, const char * const show,
     const char * const status) {}
 void mucwin_update_occupants(const char * const roomjid) {}