about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/muc.c10
-rw-r--r--src/muc.h1
-rw-r--r--src/profanity.c1
-rw-r--r--src/server_events.c14
4 files changed, 19 insertions, 7 deletions
diff --git a/src/muc.c b/src/muc.c
index 1dcc457f..3cc410bf 100644
--- a/src/muc.c
+++ b/src/muc.c
@@ -55,6 +55,16 @@ muc_init(void)
 }
 
 void
+muc_close(void)
+{
+    autocomplete_free(invite_ac);
+    if (rooms != NULL) {
+        g_hash_table_destroy(rooms);
+        rooms = NULL;
+    }
+}
+
+void
 muc_add_invite(char *room)
 {
     autocomplete_add(invite_ac, room);
diff --git a/src/muc.h b/src/muc.h
index 3d12452e..ce5602c4 100644
--- a/src/muc.h
+++ b/src/muc.h
@@ -30,6 +30,7 @@
 #include "tools/autocomplete.h"
 
 void muc_init(void);
+void muc_close(void);
 void muc_join_room(const char * const room, const char * const nick);
 void muc_leave_room(const char * const room);
 gboolean muc_room_is_active(Jid *jid);
diff --git a/src/profanity.c b/src/profanity.c
index 166a78c0..ea3e35b9 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -318,6 +318,7 @@ _shutdown(void)
     jabber_disconnect();
     jabber_shutdown();
     roster_free();
+    muc_close();
     caps_close();
     ui_close();
     chat_log_close();
diff --git a/src/server_events.c b/src/server_events.c
index b9917f52..f0ec4975 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -43,7 +43,7 @@ handle_presence_error(const char *from, const char * const type,
     const char *err_msg)
 {
     // handle nickname conflict on entering room
-    if (g_strcmp0(err_msg, "conflict") == 0) {
+    if ((from != NULL) && g_strcmp0(err_msg, "conflict") == 0) {
         // remove the room from muc
         Jid *room_jid = jid_create(from);
         if (!muc_get_roster_received(room_jid->barejid)) {
@@ -67,20 +67,20 @@ void
 handle_message_error(const char * const from, const char * const type,
     const char * const err_msg)
 {
+    // handle errors from no recipient
+    if (from == NULL) {
+        ui_handle_error(err_msg);
+
     // handle recipient not found ('from' contains a value and type is 'cancel')
-    if ((from != NULL) && ((type != NULL && (strcmp(type, "cancel") == 0)))) {
+    } else if (type != NULL && (strcmp(type, "cancel") == 0)) {
         ui_handle_recipient_not_found(from, err_msg);
         if (prefs_get_boolean(PREF_STATES) && chat_session_exists(from)) {
             chat_session_set_recipient_supports(from, FALSE);
         }
 
     // handle any other error from recipient
-    } else if (from != NULL) {
-        ui_handle_recipient_error(from, err_msg);
-
-    // handle errors from no recipient
     } else {
-        ui_handle_error(err_msg);
+        ui_handle_recipient_error(from, err_msg);
     }
 }