From 626182bef55006c632db43e73e53105d451f9930 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 8 Mar 2002 23:43:43 +0000 Subject: Don't call camel_remote_store_get_authtypes since we no longer subclass 2002-03-08 Jeffrey Stedfast * providers/pop3/camel-pop3-provider.c (camel_provider_module_init): Don't call camel_remote_store_get_authtypes since we no longer subclass camel-remote-store. * providers/pop3/camel-pop3-engine.c: Added STARTTLS to the capabilities to look for. (camel_pop3_engine_reget_capabilities): New function to re-get capabilities. * providers/pop3/camel-pop3-store.c: Updated to not subclass CamelRemoteStore. (connect_to_server): Rewritten to not depend on CamelRemoteStore's connect implementation. Also added support for STLS (aka STARTTLS). svn path=/trunk/; revision=15998 --- camel/providers/pop3/camel-pop3-engine.c | 51 ++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'camel/providers/pop3/camel-pop3-engine.c') diff --git a/camel/providers/pop3/camel-pop3-engine.c b/camel/providers/pop3/camel-pop3-engine.c index 682141f975..1783520b7c 100644 --- a/camel/providers/pop3/camel-pop3-engine.c +++ b/camel/providers/pop3/camel-pop3-engine.c @@ -44,7 +44,7 @@ extern int camel_verbose_debug; #define dd(x) (camel_verbose_debug?(x):0) -static void get_capabilities(CamelPOP3Engine *pe); +static void get_capabilities(CamelPOP3Engine *pe, int read_greeting); static CamelObjectClass *parent_class = NULL; @@ -96,6 +96,7 @@ camel_pop3_engine_get_type (void) /** * camel_pop3_engine_new: + * @source: source stream * * Returns a NULL stream. A null stream is always at eof, and * always returns success for all reads and writes. @@ -112,13 +113,28 @@ camel_pop3_engine_new(CamelStream *source) pe->stream = (CamelPOP3Stream *)camel_pop3_stream_new(source); pe->state = CAMEL_POP3_ENGINE_AUTH; - get_capabilities(pe); + get_capabilities(pe, TRUE); return pe; } + +/** + * camel_pop3_engine_reget_capabilities: + * @engine: pop3 engine + * + * Regets server capabilities (needed after a STLS command is issued for example). + **/ +void +camel_pop3_engine_reget_capabilities (CamelPOP3Engine *engine) +{ + g_return_if_fail (CAMEL_IS_POP3_ENGINE (engine)); + + get_capabilities (engine, FALSE); +} + + /* TODO: read implementation too? - STARTLS? etc? */ struct { char *cap; @@ -128,6 +144,7 @@ struct { { "TOP" , CAMEL_POP3_CAP_TOP }, { "UIDL", CAMEL_POP3_CAP_UIDL }, { "PIPELINING", CAMEL_POP3_CAP_PIPE }, + { "STLS", CAMEL_POP3_CAP_STLS }, /* STARTTLS */ }; static void @@ -171,25 +188,27 @@ cmd_capa(CamelPOP3Engine *pe, CamelPOP3Stream *stream, void *data) } static void -get_capabilities(CamelPOP3Engine *pe) +get_capabilities(CamelPOP3Engine *pe, int read_greeting) { CamelPOP3Command *pc; unsigned char *line, *apop, *apopend; unsigned int len; extern CamelServiceAuthType camel_pop3_password_authtype; extern CamelServiceAuthType camel_pop3_apop_authtype; - - /* first, read the greeting */ - if (camel_pop3_stream_line(pe->stream, &line, &len) == -1 - || strncmp(line, "+OK", 3) != 0) - return; - - if ((apop = strchr(line+3, '<')) - && (apopend = strchr(apop, '>'))) { - apopend[1] = 0; - pe->apop = g_strdup(apop); - pe->capa = CAMEL_POP3_CAP_APOP; - pe->auth = g_list_append(pe->auth, &camel_pop3_apop_authtype); + + if (read_greeting) { + /* first, read the greeting */ + if (camel_pop3_stream_line(pe->stream, &line, &len) == -1 + || strncmp(line, "+OK", 3) != 0) + return; + + if ((apop = strchr(line+3, '<')) + && (apopend = strchr(apop, '>'))) { + apopend[1] = 0; + pe->apop = g_strdup(apop); + pe->capa = CAMEL_POP3_CAP_APOP; + pe->auth = g_list_append(pe->auth, &camel_pop3_apop_authtype); + } } pe->auth = g_list_prepend(pe->auth, &camel_pop3_password_authtype); -- cgit v1.2.3