signals[AUTHENTICATE] =
g_signal_new ("authenticate",
G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_BOOLEAN);
+ 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
signals[CONNECTED] =
g_signal_new ("connected",
soup_session_abort(s->session);
g_object_unref(s->session);
g_object_unref(s->connection);
+ g_free(s);
}
static void fail(struct signin *state, GError *error)
amazon_prepare_signin_form(state, dom, msg);
if (state->form) {
if (state->form->email_name && state->form->password_name)
- g_signal_emit_by_name(state->connection, "authenticate", state, FALSE);
+ g_signal_emit_by_name(state->connection, "authenticate", FALSE);
else
fail_bad_response(state, _("Unexpected Amazon sign-in form during retry"));
} else {
SoupMessage *msg;
if (!(password && *password)) {
- g_signal_emit_by_name(state->connection, "authenticate", state, FALSE);
+ g_signal_emit_by_name(state->connection, "authenticate", FALSE);
return;
}
if (!(state->form && state->form->email_name && state->form->password_name))
fail_bad_response(state, _("Could not find Amazon sign in form"));
else
- g_signal_emit_by_name(state->connection, "authenticate", state, FALSE);
+ g_signal_emit_by_name(state->connection, "authenticate", FALSE);
free_dom(dom);
}
}
if (!ok) {
if (count > 3 && !g_strcmp0(response[3], "AuthenticationFailedException"))
- g_signal_emit_by_name(state->connection, "authenticate", state, TRUE);
+ g_signal_emit_by_name(state->connection, "authenticate", TRUE);
else
fail_bad_response(state, _("Unexpected corporate authentication failure"));
goto out;
goto out;
}
- g_signal_emit_by_name(state->connection, "authenticate", state, TRUE);
+ g_signal_emit_by_name(state->connection, "authenticate", TRUE);
out:
g_strfreev(response);
}
"libchime " PACKAGE_VERSION " ",
NULL);
+ g_object_set_data(G_OBJECT(state->connection), "signin-state", state);
+
g_object_get(self, "account-email", &state->email, NULL);
if (!(state->email && *state->email)) {
chime_debug("The ChimeConnection object does not indicate an account name\n");
* If the credentials are NULL, it is interpreted as an error and the sign-in
* procedure is canceled.
*/
-void chime_connection_authenticate(gpointer opaque, const gchar *user, const gchar *password)
+void chime_connection_authenticate(ChimeConnection *self, const gchar *user, const gchar *password)
{
- struct signin *state = opaque;
- g_assert(opaque != NULL);
+ struct signin *state = g_object_get_data(G_OBJECT(self), "signin-state");
+ g_assert(state != NULL);
if (state->region && user && *user && password && *password)
wd_send_credentials(state, user, password);
struct auth_data {
PurpleConnection *conn;
- gpointer state;
+ ChimeConnection *cxn;
gboolean user_required;
gchar *username;
gchar *password;
static void send_credentials(struct auth_data *data)
{
- chime_connection_authenticate(data->state, data->username, data->password);
+ chime_connection_authenticate(data->cxn, data->username, data->password);
g_free(data->username);
g_free(data->password);
g_free(data);
request_password_with_input(data, NULL);
}
-void purple_request_credentials(PurpleConnection *conn, gpointer state, gboolean user_required)
+void purple_request_credentials(PurpleConnection *conn, ChimeConnection *cxn, gboolean user_required)
{
struct auth_data *data = g_new0(struct auth_data, 1);
data->conn = conn;
- data->state = state;
+ data->cxn = cxn;
data->user_required = user_required;
if (purple_request_get_ui_ops()->request_fields)
request_credentials_with_fields(data);
NULL);
}
-static void on_chime_authenticate(ChimeConnection *cxn, gpointer state, gboolean user_required, PurpleConnection *conn)
+static void on_chime_authenticate(ChimeConnection *cxn, gboolean user_required, PurpleConnection *conn)
{
- purple_request_credentials(conn, state, user_required);
+ purple_request_credentials(conn, cxn, user_required);
}
static void on_chime_connected(ChimeConnection *cxn, const gchar *display_name, PurpleConnection *conn)