aboutsummaryrefslogtreecommitdiffstats
path: root/libmatrix.c
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2015-11-02 14:28:02 +0000
committerRichard van der Hoff <richard@matrix.org>2015-11-02 14:28:02 +0000
commitf4c6751e9b1c36a54eace8471fbd80a27ec674ac (patch)
tree5fd836e0a85fdac425184318331bae6a10ed47ff /libmatrix.c
parentf9b67d862caed52dd6494e0aa526ed65dd85c08d (diff)
downloadpurple-matrix-f4c6751e9b1c36a54eace8471fbd80a27ec674ac.tar.gz
Handle incoming room invites
Propagate received invites to the UI, and correctly handle accepting/refusing them.
Diffstat (limited to 'libmatrix.c')
-rw-r--r--libmatrix.c43
1 files changed, 17 insertions, 26 deletions
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)
{
@@ -142,6 +144,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;