Skip to content

Commit

Permalink
*-login: Add client_vfuncs.send_raw_data()
Browse files Browse the repository at this point in the history
This allows login plugins to hook into seeing all the data that is sent to
the imap/pop3 client.
  • Loading branch information
sirainen committed Apr 21, 2017
1 parent f231cd7 commit ae797f3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/imap-login/imap-login-client.c
Expand Up @@ -775,6 +775,7 @@ static struct client_vfuncs imap_client_vfuncs = {
imap_proxy_parse_line,
imap_proxy_error,
imap_proxy_get_state,
client_common_send_raw_data,
};

static const struct login_binary imap_login_binary = {
Expand Down
1 change: 1 addition & 0 deletions src/imap-urlauth/imap-urlauth-login.c
Expand Up @@ -174,6 +174,7 @@ static struct client_vfuncs imap_urlauth_vfuncs = {
NULL,
NULL,
NULL,
client_common_send_raw_data,
};

static const struct login_binary imap_urlauth_login_binary = {
Expand Down
12 changes: 11 additions & 1 deletion src/login-common/client-common.c
Expand Up @@ -883,7 +883,8 @@ void client_notify_status(struct client *client, bool bad, const char *text)
client->v.notify_status(client, bad, text);
}

void client_send_raw_data(struct client *client, const void *data, size_t size)
void client_common_send_raw_data(struct client *client,
const void *data, size_t size)
{
ssize_t ret;

Expand All @@ -897,6 +898,15 @@ void client_send_raw_data(struct client *client, const void *data, size_t size)
}
}

void client_send_raw_data(struct client *client, const void *data, size_t size)
{
/* FIXME: NULL check is only for backwards compatibility - remove */
if (client->v.send_raw_data != NULL)
client->v.send_raw_data(client, data, size);
else
client_common_send_raw_data(client, data, size);
}

void client_send_raw(struct client *client, const char *data)
{
client_send_raw_data(client, data, strlen(data));
Expand Down
4 changes: 4 additions & 0 deletions src/login-common/client-common.h
Expand Up @@ -120,6 +120,8 @@ struct client_vfuncs {
int (*proxy_parse_line)(struct client *client, const char *line);
void (*proxy_error)(struct client *client, const char *text);
const char *(*proxy_get_state)(struct client *client);
void (*send_raw_data)(struct client *client,
const void *data, size_t size);
};

struct client {
Expand Down Expand Up @@ -268,6 +270,8 @@ void client_notify_disconnect(struct client *client,

void client_send_raw_data(struct client *client, const void *data, size_t size);
void client_send_raw(struct client *client, const char *data);
void client_common_send_raw_data(struct client *client,
const void *data, size_t size);

void client_set_auth_waiting(struct client *client);
void client_auth_send_challenge(struct client *client, const char *data);
Expand Down
1 change: 1 addition & 0 deletions src/pop3-login/client.c
Expand Up @@ -323,6 +323,7 @@ static struct client_vfuncs pop3_client_vfuncs = {
pop3_proxy_parse_line,
pop3_proxy_error,
pop3_proxy_get_state,
client_common_send_raw_data,
};

static const struct login_binary pop3_login_binary = {
Expand Down

0 comments on commit ae797f3

Please sign in to comment.