aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/pop3/camel-pop3-engine.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@novell.com>2004-06-25 05:49:41 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-06-25 05:49:41 +0800
commit0ef312f45de342d9eb91bda74503497974c39084 (patch)
tree51c26409cfcfbc0e92d3e0cd626ec97c142245e0 /camel/providers/pop3/camel-pop3-engine.c
parent4110b183b7326182ef014516be7c4a53a8c1bb76 (diff)
downloadgsoc2013-evolution-0ef312f45de342d9eb91bda74503497974c39084.tar
gsoc2013-evolution-0ef312f45de342d9eb91bda74503497974c39084.tar.gz
gsoc2013-evolution-0ef312f45de342d9eb91bda74503497974c39084.tar.bz2
gsoc2013-evolution-0ef312f45de342d9eb91bda74503497974c39084.tar.lz
gsoc2013-evolution-0ef312f45de342d9eb91bda74503497974c39084.tar.xz
gsoc2013-evolution-0ef312f45de342d9eb91bda74503497974c39084.tar.zst
gsoc2013-evolution-0ef312f45de342d9eb91bda74503497974c39084.zip
Error out and set an exception if camel_pop3_engine_new() returns NULL
2004-06-24 Jeffrey Stedfast <fejj@novell.com> * providers/pop3/camel-pop3-store.c (connect_to_server): Error out and set an exception if camel_pop3_engine_new() returns NULL (which it can do now). * providers/pop3/camel-pop3-engine.c (get_capabilities): No longer reads the greeting. (camel_pop3_engine_new): Reads the greeting itself and returns NULL if an error occurs (like stupid braindamaged piece of shit POP servers that spew debug prinfs). svn path=/trunk/; revision=26504
Diffstat (limited to 'camel/providers/pop3/camel-pop3-engine.c')
-rw-r--r--camel/providers/pop3/camel-pop3-engine.c64
1 files changed, 38 insertions, 26 deletions
diff --git a/camel/providers/pop3/camel-pop3-engine.c b/camel/providers/pop3/camel-pop3-engine.c
index 2186136f95..391d5bd31b 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, int read_greeting);
+static void get_capabilities(CamelPOP3Engine *pe);
static CamelObjectClass *parent_class = NULL;
@@ -72,7 +72,7 @@ camel_pop3_engine_finalise(CamelPOP3Engine *pe)
/* FIXME: Also flush/free any outstanding requests, etc */
if (pe->stream)
- camel_object_unref((CamelObject *)pe->stream);
+ camel_object_unref(pe->stream);
}
CamelType
@@ -94,6 +94,32 @@ camel_pop3_engine_get_type (void)
return camel_pop3_engine_type;
}
+static int
+read_greeting (CamelPOP3Engine *pe)
+{
+ extern CamelServiceAuthType camel_pop3_password_authtype;
+ extern CamelServiceAuthType camel_pop3_apop_authtype;
+ unsigned char *line, *apop, *apopend;
+ unsigned int len;
+
+ /* first, read the greeting */
+ if (camel_pop3_stream_line (pe->stream, &line, &len) == -1
+ || strncmp (line, "+OK", 3) != 0)
+ return -1;
+
+ 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);
+
+ return 0;
+}
+
/**
* camel_pop3_engine_new:
* @source: source stream
@@ -115,8 +141,13 @@ camel_pop3_engine_new(CamelStream *source, guint32 flags)
pe->state = CAMEL_POP3_ENGINE_AUTH;
pe->flags = flags;
- get_capabilities(pe, TRUE);
-
+ if (read_greeting (pe) == -1) {
+ camel_object_unref (pe);
+ return NULL;
+ }
+
+ get_capabilities (pe);
+
return pe;
}
@@ -132,7 +163,7 @@ camel_pop3_engine_reget_capabilities (CamelPOP3Engine *engine)
{
g_return_if_fail (CAMEL_IS_POP3_ENGINE (engine));
- get_capabilities (engine, FALSE);
+ get_capabilities (engine);
}
@@ -190,30 +221,11 @@ cmd_capa(CamelPOP3Engine *pe, CamelPOP3Stream *stream, void *data)
}
static void
-get_capabilities(CamelPOP3Engine *pe, int read_greeting)
+get_capabilities(CamelPOP3Engine *pe)
{
CamelPOP3Command *pc;
- unsigned char *line, *apop, *apopend;
+ unsigned char *line;
unsigned int len;
- extern CamelServiceAuthType camel_pop3_password_authtype;
- extern CamelServiceAuthType 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);
- }
if (!(pe->flags & CAMEL_POP3_ENGINE_DISABLE_EXTENSIONS)) {
pc = camel_pop3_engine_command_new(pe, CAMEL_POP3_COMMAND_MULTI, cmd_capa, NULL, "CAPA\r\n");