From: David Woodhouse Date: Sat, 11 Nov 2023 19:37:21 +0000 (+0000) Subject: Add meeting_authz support X-Git-Tag: v1.5~14 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2ac006b054a070ba71708fe23dd435f0ecfb2fdd;p=pidgin-chime.git Add meeting_authz support Signed-off-by: David Woodhouse --- diff --git a/chime/chime-meeting.c b/chime/chime-meeting.c index fba2c88..9945e6a 100644 --- a/chime/chime-meeting.c +++ b/chime/chime-meeting.c @@ -778,6 +778,74 @@ ChimeMeeting *chime_connection_lookup_meeting_by_pin_finish(ChimeConnection *sel return g_task_propagate_pointer(G_TASK(result), error); } +static void meet_authz_cb(ChimeConnection *cxn, SoupMessage *msg, + JsonNode *node, gpointer user_data) +{ + GTask *task = G_TASK(user_data); + + if (SOUP_STATUS_IS_SUCCESSFUL(msg->status_code) && node) { + const gchar *access_req_id = NULL; + + if (parse_string(node, "AccessRequestId", &access_req_id)) { + g_task_return_pointer(task, g_strdup(access_req_id), + g_free); + } else { + g_task_return_new_error(task, CHIME_ERROR, + CHIME_ERROR_BAD_RESPONSE, + _("Meeting authorisation response had no AccessRequstId")); + } + } else { + const gchar *reason; + eparse: + reason = msg->reason_phrase; + + if (node) + parse_string(node, "Message", &reason); + + g_task_return_new_error(task, CHIME_ERROR, + CHIME_ERROR_NETWORK, + _("Failed to obtain meeting authorisation: %s"), + reason); + } + + g_object_unref(task); +} + +void chime_connection_meeting_authz_by_pin_async(ChimeConnection *cxn, + const gchar *pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_return_if_fail(CHIME_IS_CONNECTION(cxn)); + ChimeConnectionPrivate *priv = chime_connection_get_private (cxn); + + GTask *task = g_task_new(cxn, cancellable, callback, user_data); + + JsonBuilder *jb = json_builder_new(); + jb = json_builder_begin_object(jb); + jb = json_builder_set_member_name(jb, "Passcode"); + jb = json_builder_add_string_value(jb, pin); + jb = json_builder_end_object(jb); + + JsonNode *node = json_builder_get_root(jb); + SoupURI *uri = soup_uri_new_printf(priv->express_url, "/meetings/v3/meeting_authz"); + chime_connection_queue_http_request(cxn, node, uri, "POST", meet_authz_cb, task); + json_node_unref(node); + g_object_unref(jb); + +} + +char *chime_connection_meeting_authz_by_pin_finish(ChimeConnection *self, + GAsyncResult *result, + GError **error) +{ + g_return_val_if_fail(CHIME_IS_CONNECTION(self), FALSE); + g_return_val_if_fail(g_task_is_valid(result, self), FALSE); + + return g_task_propagate_pointer(G_TASK(result), error); +} + static void chime_connection_open_meeting(ChimeConnection *cxn, ChimeMeeting *meeting, GTask *task) { diff --git a/chime/chime-meeting.h b/chime/chime-meeting.h index c2a4ae3..eb54caf 100644 --- a/chime/chime-meeting.h +++ b/chime/chime-meeting.h @@ -130,6 +130,16 @@ ChimeMeeting *chime_connection_lookup_meeting_by_pin_finish(ChimeConnection *sel GAsyncResult *result, GError **error); +void chime_connection_meeting_authz_by_pin_async(ChimeConnection *cxn, + const gchar *pin, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + +char *chime_connection_meeting_authz_by_pin_finish(ChimeConnection *self, + GAsyncResult *result, + GError **error); + void chime_connection_join_meeting_async(ChimeConnection *cxn, ChimeMeeting *meeting, gboolean audio,