diff options
-rw-r--r-- | matrix-api.c | 11 | ||||
-rw-r--r-- | matrix-api.h | 7 | ||||
-rw-r--r-- | matrix-room.c | 10 | ||||
-rw-r--r-- | matrix-room.h | 2 | ||||
-rw-r--r-- | matrix-sync.c | 1 |
5 files changed, 16 insertions, 15 deletions
diff --git a/matrix-api.c b/matrix-api.c index b80637a..089c446 100644 --- a/matrix-api.c +++ b/matrix-api.c @@ -790,8 +790,8 @@ MatrixApiRequestData *matrix_api_join_room(MatrixConnectionData *conn, } MatrixApiRequestData *matrix_api_typing(MatrixConnectionData *conn, - const gchar *room_id, JsonObject *content, - MatrixApiCallback callback, + const gchar *room_id, gboolean typing, + gint typing_timeout, MatrixApiCallback callback, MatrixApiErrorCallback error_callback, MatrixApiBadResponseCallback bad_response_callback, gpointer user_data) @@ -801,6 +801,7 @@ MatrixApiRequestData *matrix_api_typing(MatrixConnectionData *conn, JsonNode *body_node; JsonGenerator *generator; gchar *json; + JsonObject *content; /* purple_url_encode uses a single static buffer, so we have to build up * the url gradually @@ -814,6 +815,11 @@ MatrixApiRequestData *matrix_api_typing(MatrixConnectionData *conn, g_string_append(url, purple_url_encode(conn->access_token)); body_node = json_node_new(JSON_NODE_OBJECT); + content = json_object_new(); + json_object_set_boolean_member(content, "typing", typing); + if (typing == TRUE) { + json_object_set_int_member(content, "timeout", typing_timeout); + } json_node_set_object(body_node, content); generator = json_generator_new(); @@ -829,6 +835,7 @@ MatrixApiRequestData *matrix_api_typing(MatrixConnectionData *conn, user_data, 0); g_free(json); g_string_free(url, TRUE); + json_object_unref(content); return fetch_data; } diff --git a/matrix-api.h b/matrix-api.h index 22091d8..375e88a 100644 --- a/matrix-api.h +++ b/matrix-api.h @@ -241,7 +241,8 @@ MatrixApiRequestData *matrix_api_join_room(MatrixConnectionData *conn, * * @param conn The connection with which to make the request * @param room_id The room id to send the typing notification to - * @param content The content of the typing event + * @param typing Whether to mark the user as typing + * @param typing_timeout How long the server should mark the user as typing * @param callback Function to be called when the request completes * @param error_callback Function to be called if there is an error making * the request. If NULL, matrix_api_error will be @@ -252,8 +253,8 @@ MatrixApiRequestData *matrix_api_join_room(MatrixConnectionData *conn, * @param user_data Opaque data to be passed to the callbacks */ MatrixApiRequestData *matrix_api_typing(MatrixConnectionData *conn, - const gchar *room_id, struct _JsonObject *content, - MatrixApiCallback callback, + const gchar *room_id, gboolean typing, + gint typing_timeout, MatrixApiCallback callback, MatrixApiErrorCallback error_callback, MatrixApiBadResponseCallback bad_response_callback, gpointer user_data); diff --git a/matrix-room.c b/matrix-room.c index ea38efc..4eae41f 100644 --- a/matrix-room.c +++ b/matrix-room.c @@ -1261,23 +1261,15 @@ void matrix_room_send_image(PurpleConversation *conv, int imgstore_id, */ void matrix_room_send_typing(PurpleConversation *conv, gboolean typing) { - JsonObject *content; MatrixConnectionData *acct; PurpleConnection *pc = conv->account->gc; acct = purple_connection_get_protocol_data(pc); - content = json_object_new(); - json_object_set_boolean_member(content, "typing", typing); - if (typing == TRUE) { - json_object_set_int_member(content, "timeout", 25000); - } - // Don't check callbacks as it's inconsequential whether typing notifications go through - matrix_api_typing(acct, conv->name, content, + matrix_api_typing(acct, conv->name, typing, 25000, NULL, NULL, NULL, NULL); - json_object_unref(content); } /** diff --git a/matrix-room.h b/matrix-room.h index ca0420c..b0bd396 100644 --- a/matrix-room.h +++ b/matrix-room.h @@ -77,7 +77,7 @@ void matrix_room_handle_timeline_event(struct _PurpleConversation *conv, /** * Sends a typing notification in a room with a 25s timeout */ -void matrix_room_send_typing(PurpleConversation *conv, gboolean typing); +void matrix_room_send_typing(struct _PurpleConversation *conv, gboolean typing); /** * Send a message in a room diff --git a/matrix-sync.c b/matrix-sync.c index 89926ab..84f8be1 100644 --- a/matrix-sync.c +++ b/matrix-sync.c @@ -159,6 +159,7 @@ static void matrix_sync_room(const gchar *room_id, _parse_room_event_array(conv, timeline_array, FALSE); /* parse the ephemeral events */ + /* (uses the state table to track the state of who is typing and who isn't) */ ephemeral_object = matrix_json_object_get_object_member(room_data, "ephemeral"); ephemeral_array = matrix_json_object_get_array_member(ephemeral_object, "events"); if(ephemeral_array != NULL) |