about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/event/server_events.c9
-rw-r--r--src/ui/mucwin.c28
-rw-r--r--src/ui/ui.h2
3 files changed, 20 insertions, 19 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 8ceb9f22..a56a54b0 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -136,7 +136,10 @@ void
 sv_ev_room_broadcast(const char *const room_jid, const char *const message)
 {
     if (muc_roster_complete(room_jid)) {
-        mucwin_broadcast(room_jid, message);
+        ProfMucWin *mucwin = wins_get_muc(room_jid);
+        if (mucwin) {
+            mucwin_broadcast(mucwin, message);
+        }
     } else {
         muc_pending_broadcasts_add(room_jid, message);
     }
@@ -587,10 +590,10 @@ sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean c
         }
 
         GList *pending_broadcasts = muc_pending_broadcasts(room);
-        if (pending_broadcasts) {
+        if (mucwin && pending_broadcasts) {
             GList *curr = pending_broadcasts;
             while (curr) {
-                mucwin_broadcast(room, curr->data);
+                mucwin_broadcast(mucwin, curr->data);
                 curr = g_list_next(curr);
             }
         }
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index f4e104ca..a7668479 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -506,25 +506,23 @@ mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const
 }
 
 void
-mucwin_broadcast(const char *const roomjid, const char *const message)
+mucwin_broadcast(ProfMucWin *mucwin, const char *const message)
 {
-    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
-    if (window == NULL) {
-        log_error("Received room broadcast, but no window open for %s.", roomjid);
-    } else {
-        int num = wins_get_num(window);
+    assert(mucwin != NULL);
 
-        win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room message: ");
-        win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", message);
+    ProfWin *window = (ProfWin*)mucwin;
+    int num = wins_get_num(window);
 
-        // currently in groupchat window
-        if (wins_is_current(window)) {
-            status_bar_active(num);
+    win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room message: ");
+    win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", message);
 
-        // not currently on groupchat window
-        } else {
-            status_bar_new(num);
-        }
+    // currently in groupchat window
+    if (wins_is_current(window)) {
+        status_bar_active(num);
+
+    // not currently on groupchat window
+    } else {
+        status_bar_new(num);
     }
 }
 
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 5cfa3c8e..38c66a05 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -186,7 +186,7 @@ void mucwin_occupant_kicked(ProfMucWin *mucwin, const char *const nick, const ch
     const char *const reason);
 void mucwin_occupant_banned(ProfMucWin *mucwin, const char *const nick, const char *const actor,
     const char *const reason);
-void mucwin_broadcast(const char *const roomjid, const char *const message);
+void mucwin_broadcast(ProfMucWin *mucwin, const char *const message);
 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);