aboutsummaryrefslogtreecommitdiffstats
path: root/libmatrix.c
diff options
context:
space:
mode:
authorEion Robb <eion@robbmob.com>2017-03-12 22:16:00 +1300
committerEion Robb <eion@robbmob.com>2017-03-12 22:16:00 +1300
commit61ee52f3230724b5c1e8f81caeb16ce7887d183c (patch)
treee7a5f5a66ce2cda993dcb8c4c007e8e14c360fe7 /libmatrix.c
parentccf49582556edc17c75df1073d61d8bebfede744 (diff)
downloadpurple-matrix-61ee52f3230724b5c1e8f81caeb16ce7887d183c.tar.gz
Send/receive typing notifications
using the "Group Typing Notifications" plugin
Diffstat (limited to 'libmatrix.c')
-rw-r--r--libmatrix.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libmatrix.c b/libmatrix.c
index 5b3118c..2307494 100644
--- a/libmatrix.c
+++ b/libmatrix.c
@@ -76,6 +76,26 @@ static GList *matrixprpl_status_types(PurpleAccount *acct)
}
/**
+ * handle sending typing notifications in a chat
+ */
+static guint matrixprpl_conv_send_typing(PurpleConversation *conv,
+ PurpleTypingState state, PurpleConnection *pc)
+{
+ if (pc == NULL)
+ pc = purple_conversation_get_gc(conv);
+
+ if (!PURPLE_CONNECTION_IS_CONNECTED(pc))
+ return 0;
+
+ if (g_strcmp0(purple_plugin_get_id(purple_connection_get_prpl(pc)), PRPL_ID))
+ return 0;
+
+ matrix_room_send_typing(conv, (state == PURPLE_TYPING));
+
+ return 20;
+}
+
+/**
* Start the connection to a matrix account
*/
void matrixprpl_login(PurpleAccount *acct)
@@ -83,6 +103,9 @@ void matrixprpl_login(PurpleAccount *acct)
PurpleConnection *pc = purple_account_get_connection(acct);
matrix_connection_new(pc);
matrix_connection_start_login(pc);
+
+ purple_signal_connect(purple_conversations_get_handle(), "chat-conversation-typing",
+ acct, PURPLE_CALLBACK(matrixprpl_conv_send_typing), pc);
}