CHIME_DEFINE_ENUM_TYPE(ChimeMeetingType, chime_meeting_type, \
CHIME_ENUM_VALUE(CHIME_MEETING_TYPE_ADHOC, "AdHocMeeting") \
CHIME_ENUM_VALUE(CHIME_MEETING_TYPE_GOOGLE_CALENDAR, "GoogleCalendarMeeting")\
- CHIME_ENUM_VALUE(CHIME_MEETING_TYPE_CONFERENCE_BRIDGE, "ConferenceBridge") \
+ CHIME_ENUM_VALUE(CHIME_MEETING_TYPE_CONFERENCE_BRIDGE, "ConferenceBridgeMeeting") \
CHIME_ENUM_VALUE(CHIME_MEETING_TYPE_WEBINAR, "Webinar"))
static void close_meeting(gpointer key, gpointer val, gpointer data);
meeting_jugg_cb, NULL);
chime_jugg_subscribe(cxn, priv->device_channel, "AdHocMeeting",
meeting_jugg_cb, NULL);
- chime_jugg_subscribe(cxn, priv->device_channel, "ConferenceBridge",
+ chime_jugg_subscribe(cxn, priv->device_channel, "ConferenceBridgeMeeting",
meeting_jugg_cb, NULL);
chime_jugg_subscribe(cxn, priv->device_channel, "Webinar",
meeting_jugg_cb, NULL);
meeting_jugg_cb, NULL);
chime_jugg_unsubscribe(cxn, priv->device_channel, "AdHocMeeting",
meeting_jugg_cb, NULL);
- chime_jugg_unsubscribe(cxn, priv->device_channel, "ConferenceBridge",
+ chime_jugg_unsubscribe(cxn, priv->device_channel, "ConferenceBridgeMeeting",
meeting_jugg_cb, NULL);
chime_jugg_unsubscribe(cxn, priv->device_channel, "Webinar",
meeting_jugg_cb, NULL);
return g_task_propagate_pointer(G_TASK(result), error);
}
+static void pin_join_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) {
+ GError *error = NULL;
+ JsonObject *obj = json_node_get_object(node);
+ node = json_object_get_member(obj, "meeting");
+ if (!node)
+ goto eparse;
+
+ ChimeMeeting *mtg = chime_connection_parse_meeting(cxn, node, &error);
+ if (mtg)
+ g_task_return_pointer(task, mtg, (GDestroyNotify)g_object_unref);
+ else
+ g_task_return_error(task, error);
+ return;
+ } 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 details: %s"),
+ reason);
+ }
+
+ g_object_unref(task);
+}
+
+void chime_connection_lookup_meeting_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, "pin");
+ 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->conference_url, "/pin_joins");
+ chime_connection_queue_http_request(cxn, node, uri, "POST", pin_join_cb, task);
+ json_node_unref(node);
+ g_object_unref(jb);
+
+}
+
+ChimeMeeting *chime_connection_lookup_meeting_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);
+}
GError **error);
+void chime_connection_lookup_meeting_by_pin_async(ChimeConnection *cxn,
+ const gchar *pin,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ChimeMeeting *chime_connection_lookup_meeting_by_pin_finish(ChimeConnection *self,
+ GAsyncResult *result,
+ GError **error);
+
+
G_END_DECLS
#endif /* __CHIME_MEETING_H__ */
purple_connection_set_protocol_data(conn, pc);
purple_chime_init_conversations(pc);
purple_chime_init_chats(pc);
+
pc->cxn = chime_connection_new(conn, server, devtoken, token);
g_signal_connect(pc->cxn, "notify::session-token",
G_CALLBACK(on_chime_progress), conn);
g_signal_connect(pc->cxn, "new-conversation",
G_CALLBACK(on_chime_new_conversation), conn);
+ g_signal_connect(pc->cxn, "new-meeting",
+ G_CALLBACK(on_chime_new_meeting), conn);
/* We don't use 'conn' for this one as we don't want it disconnected
on close, and it doesn't use it anyway. */
g_signal_connect(pc->cxn, "log-message",
chime_purple_schedule_onetime);
acts = g_list_append(acts, act);
+ act = purple_plugin_action_new(_("Join meeting by PIN..."),
+ chime_purple_pin_join);
+ acts = g_list_append(acts, act);
+
return acts;
}
#include "chime-contact.h"
#include "chime-conversation.h"
#include "chime-room.h"
+#include "chime-meeting.h"
struct purple_chime {
ChimeConnection *cxn;
/* meeting.c */
void chime_purple_schedule_onetime(PurplePluginAction *action);
void chime_purple_schedule_personal(PurplePluginAction *action);
+void chime_purple_pin_join(PurplePluginAction *action);
+void on_chime_new_meeting(ChimeConnection *cxn, ChimeMeeting *mtg, PurpleConnection *conn);
/* rooms.c */
PurpleRoomlist *chime_purple_roomlist_get_list(PurpleConnection *conn);
#include <glib/glist.h>
#include <prpl.h>
+#include <request.h>
#include "chime.h"
#include "chime-meeting.h"
return;
}
- /* XXX: Choose the best one (not that chime does) */
- ChimeDialin *d = mtg->international_dialin_info->data;
-
gchar *secondary = g_strdup_printf(_("Remember to include Chime in the invites:\n%s"), mtg->delegate_scheduling_email);
GString *invite_str = g_string_new("");
void chime_purple_schedule_personal(PurplePluginAction *action)
{
do_schedule_meeting(action, FALSE);
+}
+
+static void pin_join_done(GObject *source, GAsyncResult *result, gpointer _conn)
+{
+ PurpleConnection *conn = _conn;
+ GError *error = NULL;
+ ChimeMeeting *mtg = chime_connection_lookup_meeting_by_pin_finish(CHIME_CONNECTION(source), result, &error);
+
+ if (!mtg) {
+ purple_notify_error(conn, NULL,
+ _("Unable to join meeting"),
+ error->message);
+ return;
+ }
+ /* Actually we'll handle it in the NEW_MEETING signal handler */
+}
+static void pin_join_begin(PurpleConnection *conn, const char *query)
+{
+ ChimeConnection *cxn = PURPLE_CHIME_CXN(conn);
+
+ chime_connection_lookup_meeting_by_pin_async(cxn, query, NULL,
+ pin_join_done, conn);
+}
+
+void chime_purple_pin_join(PurplePluginAction *action)
+{
+ PurpleConnection *conn = (PurpleConnection *) action->context;
+
+ purple_request_input(conn, _("Chime PIN join meeting"),
+ _("Enter the meeting PIN"), NULL, NULL,
+ FALSE, FALSE, NULL,
+ _("Search"), PURPLE_CALLBACK(pin_join_begin),
+ _("Cancel"), NULL,
+ NULL, NULL, NULL, conn);
+}
+
+void on_chime_new_meeting(ChimeConnection *cxn, ChimeMeeting *mtg, PurpleConnection *conn)
+{
+ gchar *secondary = g_strdup_printf(_("Meeting PIN: %s"),
+ chime_meeting_get_passcode(mtg));
+
+ gchar *text = g_strdup_printf(_("Web join URL: %s"),
+ chime_meeting_get_passcode(mtg));
+
+ purple_notify_formatted(conn, _("Amazon Chime Meeting"),
+ chime_meeting_get_name(mtg), secondary,
+ text, NULL, NULL);
+ g_free(text);
+ g_free(secondary);
+ g_object_unref(mtg);
}