Skip to content

Commit

Permalink
lib-imap-client: invoke state change callback on "authentication succ…
Browse files Browse the repository at this point in the history
…ess"
  • Loading branch information
Josef 'Jeff' Sipek authored and sirainen committed Feb 17, 2017
1 parent 4231957 commit b9838d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/lib-imap-client/imapc-client.h
Expand Up @@ -147,6 +147,7 @@ struct imapc_untagged_reply {
};

enum imapc_state_change_event {
IMAPC_STATE_CHANGE_AUTH_OK,
IMAPC_STATE_CHANGE_AUTH_FAILED,
};

Expand Down
16 changes: 14 additions & 2 deletions src/lib-imap-client/imapc-connection.c
Expand Up @@ -141,6 +141,19 @@ static int imapc_connection_ssl_init(struct imapc_connection *conn);
static void imapc_command_free(struct imapc_command *cmd);
static void imapc_command_send_more(struct imapc_connection *conn);

static void
imapc_auth_ok(struct imapc_connection *conn)
{
if (conn->client->set.debug)
i_debug("imapc(%s): Authenticated successfully", conn->name);

if (conn->client->state_change_callback == NULL)
return;

conn->client->state_change_callback(conn->client->state_change_context,
IMAPC_STATE_CHANGE_AUTH_OK, NULL);
}

static void
imapc_auth_failed(struct imapc_connection *conn,
const char *error)
Expand Down Expand Up @@ -785,8 +798,7 @@ imapc_connection_auth_finish(struct imapc_connection *conn,
return;
}

if (conn->client->set.debug)
i_debug("imapc(%s): Authenticated successfully", conn->name);
imapc_auth_ok(conn);

timeout_remove(&conn->to);
imapc_connection_set_state(conn, IMAPC_CONNECTION_STATE_DONE);
Expand Down

0 comments on commit b9838d5

Please sign in to comment.