diff options
-rw-r--r-- | src/event/server_events.c | 5 | ||||
-rw-r--r-- | src/ui/mucwin.c | 15 | ||||
-rw-r--r-- | src/ui/ui.h | 2 | ||||
-rw-r--r-- | tests/unittests/ui/stub_ui.c | 3 |
4 files changed, 11 insertions, 14 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c index 84bc407a..b05dc22c 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -165,7 +165,10 @@ void sv_ev_room_message(const char *const room_jid, const char *const nick, const char *const message) { - mucwin_message(room_jid, nick, message); + ProfMucWin *mucwin = wins_get_muc(room_jid); + if (mucwin) { + mucwin_message(mucwin, nick, message); + } if (prefs_get_boolean(PREF_GRLOG)) { Jid *jid = jid_create(jabber_get_fulljid()); diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index b0990cd8..95908875 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -355,18 +355,13 @@ mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, } void -mucwin_message(const char *const roomjid, const char *const nick, - const char *const message) +mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message) { - ProfMucWin *mucwin = wins_get_muc(roomjid); - if (mucwin == NULL) { - log_error("Room message received from %s, but no window open for %s", nick, roomjid); - return; - } + assert(mucwin != NULL); - ProfWin *window = (ProfWin*) mucwin; + ProfWin *window = (ProfWin*)mucwin; int num = wins_get_num(window); - char *my_nick = muc_nick(roomjid); + char *my_nick = muc_nick(mucwin->roomjid); if (g_strcmp0(nick, my_nick) != 0) { if (g_strrstr(message, my_nick)) { @@ -427,7 +422,7 @@ mucwin_message(const char *const roomjid, const char *const nick, if (notify) { gboolean is_current = wins_is_current(window); if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_ROOM_CURRENT)) ) { - Jid *jidp = jid_create(roomjid); + Jid *jidp = jid_create(mucwin->roomjid); if (prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT)) { notify_room_message(nick, jidp->localpart, ui_index, message); } else { diff --git a/src/ui/ui.h b/src/ui/ui.h index 9784c569..db22a3ed 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -174,7 +174,7 @@ void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char const char *const role, const char *const affiliation, const char *const actor, const char *const reason); void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char *const presence); void mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, const char *const message); -void mucwin_message(const char *const roomjid, const char *const nick, const char *const message); +void mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message); void mucwin_subject(const char *const roomjid, const char *const nick, const char *const subject); void mucwin_requires_config(const char *const roomjid); void mucwin_info(ProfMucWin *mucwin); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index b37e8e67..d1812d9d 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -205,8 +205,7 @@ void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char const char * const affiliation, const char * const actor, const char * const reason) {} void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char * const presence) {} void mucwin_history(ProfMucWin *mucwin, const char * const nick, GDateTime *timestamp, const char * const message) {} -void mucwin_message(const char * const roomjid, const char * const nick, - const char * const message) {} +void mucwin_message(ProfMucWin *mucwin, const char * const nick, const char * const message) {} void mucwin_subject(const char * const roomjid, const char * const nick, const char * const subject) {} void mucwin_requires_config(const char * const roomjid) {} void ui_room_destroy(const char * const roomjid) {} |