aboutsummaryrefslogtreecommitdiffstats
path: root/libmatrix.c
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2015-10-19 18:03:21 +0100
committerRichard van der Hoff <richard@matrix.org>2015-10-19 18:03:21 +0100
commite8c15ca56f5a2951d97aa49ac0e8aea8c93b1320 (patch)
treef7574fea030b48b4eeb6df6ae3ba5019c75db9c5 /libmatrix.c
parent9b1f0aa4805f62355423522a07d04bb089829bfa (diff)
downloadpurple-matrix-e8c15ca56f5a2951d97aa49ac0e8aea8c93b1320.tar.gz
Fix the memory handling for rooms
Make sure that we delete the room state structures when they are thrown away.
Diffstat (limited to 'libmatrix.c')
-rw-r--r--libmatrix.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/libmatrix.c b/libmatrix.c
index 83fdd51..6399454 100644
--- a/libmatrix.c
+++ b/libmatrix.c
@@ -94,6 +94,19 @@ static void matrixprpl_join_chat(PurpleConnection *gc, GHashTable *components)
}
+/**
+ * handle leaving a chat: notify the server that we are leaving, and
+ * (ultimately) free the memory structures associated with it
+ */
+static void matrixprpl_chat_leave(PurpleConnection *gc, int id) {
+ PurpleConversation *conv = purple_find_chat(gc, id);
+ purple_debug_info("matrixprpl", "%s is leaving chat room %s\n",
+ gc->account->username, conv->name);
+
+ matrix_room_leave_chat(conv);
+}
+
+
/******************************************************************************
* The following comes from the 'nullprpl' dummy protocol. TODO: clear this out
* and keep only what we need.
@@ -613,27 +626,6 @@ static void matrixprpl_chat_invite(PurpleConnection *gc, int id,
}
}
-static void left_chat_room(PurpleConvChat *from, PurpleConvChat *to,
- int id, const char *room, gpointer userdata) {
- if (from != to) {
- /* tell their chat window that we left */
- purple_debug_info("matrixprpl", "%s sees that %s left chat room %s\n",
- to->nick, from->nick, room);
- purple_conv_chat_remove_user(to,
- from->nick,
- NULL); /* user-provided message, IRC style */
- }
-}
-
-static void matrixprpl_chat_leave(PurpleConnection *gc, int id) {
- PurpleConversation *conv = purple_find_chat(gc, id);
- purple_debug_info("matrixprpl", "%s is leaving chat room %s\n",
- gc->account->username, conv->name);
-
- /* tell everyone that we left */
- foreach_gc_in_chat(left_chat_room, gc, id, NULL);
-}
-
#if 0
static PurpleCmdRet send_whisper(PurpleConversation *conv, const gchar *cmd,
gchar **args, gchar **error, void *userdata) {