From f4c6751e9b1c36a54eace8471fbd80a27ec674ac Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Mon, 2 Nov 2015 14:28:02 +0000 Subject: Handle incoming room invites Propagate received invites to the UI, and correctly handle accepting/refusing them. --- libmatrix.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) (limited to 'libmatrix.c') diff --git a/libmatrix.c b/libmatrix.c index 0c38941..db82661 100644 --- a/libmatrix.c +++ b/libmatrix.c @@ -121,8 +121,10 @@ static char *matrixprpl_get_chat_name(GHashTable *components) return g_strdup(room); } -/* Handle a double-click on a chat in the buddy list: it is expected that we - * join the chat. + +/** + * Handle a double-click on a chat in the buddy list, or acceptance of a chat + * invite: it is expected that we join the chat. */ static void matrixprpl_join_chat(PurpleConnection *gc, GHashTable *components) { @@ -141,6 +143,19 @@ static void matrixprpl_join_chat(PurpleConnection *gc, GHashTable *components) } +/** + * Handle refusing a chat invite. + */ +static void matrixprpl_reject_chat(PurpleConnection *gc, GHashTable *components) +{ + const char *room_id = g_hash_table_lookup(components, + PRPL_CHAT_INFO_ROOM_ID); + + matrix_connection_reject_invite(gc, room_id); +} + + + /** * handle leaving a chat: notify the server that we are leaving, and * (ultimately) free the memory structures associated with it @@ -628,30 +643,6 @@ static void matrixprpl_rem_deny(PurpleConnection *gc, const char *name) { static void matrixprpl_set_permit_deny(PurpleConnection *gc) { } - -static void matrixprpl_reject_chat(PurpleConnection *gc, GHashTable *components) { - const char *invited_by = g_hash_table_lookup(components, "invited_by"); - const char *room = g_hash_table_lookup(components, "room"); - const char *username = gc->account->username; - PurpleConnection *invited_by_gc = get_matrixprpl_gc(invited_by); - char *message = g_strdup_printf( - "%s %s %s.", - username, - _("has rejected your invitation to join the chat room"), - room); - - purple_debug_info("matrixprpl", - "%s has rejected %s's invitation to join chat room %s\n", - username, invited_by, room); - - purple_notify_info(invited_by_gc, - _("Chat invitation rejected"), - _("Chat invitation rejected"), - message); - g_free(message); -} - - static void matrixprpl_chat_invite(PurpleConnection *gc, int id, const char *message, const char *who) { const char *username = gc->account->username; -- cgit