aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/pop3/camel-pop3-store.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-03-23 00:55:28 +0800
committerDan Winship <danw@src.gnome.org>2000-03-23 00:55:28 +0800
commit07baaeb9c606395a98853be164b04b56560f547a (patch)
tree89e381f6da58cc9d497fff7e99b0522290dac3e0 /camel/providers/pop3/camel-pop3-store.c
parentaf50786d6f38bccab9b4ec69a5268668cb440191 (diff)
downloadgsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.tar
gsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.tar.gz
gsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.tar.bz2
gsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.tar.lz
gsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.tar.xz
gsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.tar.zst
gsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.zip
fill this in partially make camel_pop3_command return the text after
* providers/pop3/camel-pop3-folder.c: fill this in partially * providers/pop3/camel-pop3-store.c: make camel_pop3_command return the text after "+OK"/"-ERR" and add a separate camel_pop3_get_additional_data to get the message body or whatever. Also make them take a CamelPop3Store rather than a CamelStreamBuffer. svn path=/trunk/; revision=2143
Diffstat (limited to 'camel/providers/pop3/camel-pop3-store.c')
-rw-r--r--camel/providers/pop3/camel-pop3-store.c74
1 files changed, 56 insertions, 18 deletions
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index 5e5e9fe4e9..ece5171c2b 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -45,7 +45,9 @@
-static gboolean _connect (CamelService *service, CamelException *ex);
+static gboolean connect (CamelService *service, CamelException *ex);
+static CamelFolder *get_folder (CamelStore *store, const gchar *folder_name,
+ CamelException *ex);
static void
@@ -53,9 +55,15 @@ camel_pop3_store_class_init (CamelPop3StoreClass *camel_pop3_store_class)
{
CamelServiceClass *camel_service_class =
CAMEL_SERVICE_CLASS (camel_pop3_store_class);
+ CamelStoreClass *camel_store_class =
+ CAMEL_STORE_CLASS (camel_pop3_store_class);
/* virtual method overload */
- camel_service_class->connect = _connect;
+ camel_service_class->connect = connect;
+
+ camel_store_class->get_root_folder = camel_pop3_folder_new;
+ camel_store_class->get_default_folder = camel_pop3_folder_new;
+ camel_store_class->get_folder = get_folder;
}
@@ -171,16 +179,16 @@ _connect (CamelService *service, CamelException *ex)
for (s = md5sum, d = md5asc; d < md5asc + 32; s++, d += 2)
sprintf(d, "%.2x", *s);
- status = camel_pop3_command(store->stream, NULL, "APOP %s %s",
+ status = camel_pop3_command(store, NULL, "APOP %s %s",
service->url->user, md5asc);
}
g_free(buf);
if (status != CAMEL_POP3_OK ) {
- status = camel_pop3_command(store->stream, NULL, "USER %s",
+ status = camel_pop3_command(store, NULL, "USER %s",
service->url->user);
if (status == CAMEL_POP3_OK) {
- status = camel_pop3_command(store->stream, NULL,
+ status = camel_pop3_command(store, NULL,
"PASS %s", pass);
}
}
@@ -195,9 +203,22 @@ _connect (CamelService *service, CamelException *ex)
return TRUE;
}
+static CamelFolder *get_folder (CamelStore *store, const gchar *folder_name,
+ CamelException *ex)
+{
+ if (!strcasecmp (folder_name, "inbox"))
+ return camel_pop3_folder_new (store, ex);
+ else {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
+ "No such folder `%s'.", folder_name);
+ return NULL;
+ }
+}
+
int
-camel_pop3_command (CamelStreamBuffer *stream, char **ret, char *fmt, ...)
+camel_pop3_command (CamelPop3Store *store, char **ret, char *fmt, ...)
{
+ CamelStreamBuffer *stream = store->stream;
char *cmdbuf, *respbuf;
va_list ap;
int status, i;
@@ -220,35 +241,52 @@ camel_pop3_command (CamelStreamBuffer *stream, char **ret, char *fmt, ...)
status = CAMEL_POP3_ERR;
else
status = CAMEL_POP3_FAIL;
+
+ if (ret) {
+ if (status != CAMEL_POP3_FAIL) {
+ *ret = strchr (respbuf, ' ');
+ if (*ret)
+ *ret = g_strdup (ret + 1);
+ } else
+ *ret = NULL;
+ }
g_free (respbuf);
- if (status != CAMEL_POP3_OK || !ret)
- return status;
+ return status;
+}
+
+char *
+camel_pop3_command_get_additional_data (CamelPop3Store *store)
+{
+ CamelStreamBuffer *stream = store->stream;
+ GPtrArray *data;
+ char *buf;
+ int i, status = CAMEL_POP3_OK;
- /* Read the additional data. */
data = g_ptr_array_new ();
while (1) {
- respbuf = camel_stream_buffer_read_line (stream);
- if (!respbuf) {
+ buf = camel_stream_buffer_read_line (stream);
+ if (!buf) {
status = CAMEL_POP3_FAIL;
break;
}
- if (!strcmp (respbuf, "."))
+ if (!strcmp (buf, "."))
break;
- if (*respbuf == '.')
- memmove (respbuf, respbuf + 1, strlen (respbuf));
- g_ptr_array_add (data, respbuf);
+ if (*buf == '.')
+ memmove (buf, buf + 1, strlen (buf));
+ g_ptr_array_add (data, buf);
}
if (status == CAMEL_POP3_OK) {
g_ptr_array_add (data, NULL);
- *ret = g_strjoinv ("\n", (char **)data->pdata);
- }
+ buf = g_strjoinv ("\n", (char **)data->pdata);
+ } else
+ buf = NULL;
for (i = 0; i < data->len; i++)
g_free (data->pdata[i]);
g_ptr_array_free (data, TRUE);
- return status;
+ return buf;
}