aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-08-31 00:24:36 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-08-31 00:24:36 +0800
commite8df3eea83688f5656c076952dfcffb297c08ad1 (patch)
tree5c38f2f8aabf4c4b0d2bbe2d67e967c2717fe52d
parentccda437a9ab19df7be5a3d5608cc4ca7c93c4e69 (diff)
downloadgsoc2013-evolution-e8df3eea83688f5656c076952dfcffb297c08ad1.tar
gsoc2013-evolution-e8df3eea83688f5656c076952dfcffb297c08ad1.tar.gz
gsoc2013-evolution-e8df3eea83688f5656c076952dfcffb297c08ad1.tar.bz2
gsoc2013-evolution-e8df3eea83688f5656c076952dfcffb297c08ad1.tar.lz
gsoc2013-evolution-e8df3eea83688f5656c076952dfcffb297c08ad1.tar.xz
gsoc2013-evolution-e8df3eea83688f5656c076952dfcffb297c08ad1.tar.zst
gsoc2013-evolution-e8df3eea83688f5656c076952dfcffb297c08ad1.zip
General cleanup / moving stuff around to make things easier to follow.
2000-08-30 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-store.c: General cleanup / moving stuff around to make things easier to follow. svn path=/trunk/; revision=5115
-rw-r--r--camel/ChangeLog5
-rw-r--r--camel/providers/imap/camel-imap-store.c97
2 files changed, 61 insertions, 41 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index a7c662a67b..4c74dff873 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,10 @@
2000-08-30 Jeffrey Stedfast <fejj@helixcode.com>
+ * providers/imap/camel-imap-store.c: General cleanup / moving
+ stuff around to make things easier to follow.
+
+2000-08-30 Jeffrey Stedfast <fejj@helixcode.com>
+
* camel-remote-store.c: Prevent exceptions from being overwritten
* providers/imap/camel-imap-folder.c (imap_expunge): Beautified
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index fc11631209..31b0019688 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -699,41 +699,6 @@ slurp_response (CamelImapStore *store, CamelFolder *folder, char *cmdid, char **
return status;
}
-/* frees cmdid! */
-static gint
-parse_single_line (CamelImapStore *store, char *cmdid, CamelException *ex)
-{
- char *respbuf;
- gint status;
- char *word;
-
- if (camel_remote_store_recv_line (CAMEL_REMOTE_STORE (store), &respbuf, ex) < 0)
- return CAMEL_IMAP_FAIL;
-
- /* Assume that buf indeed starts with cmdid; then
- * it can only start with a plus when the slurper
- * found a valid plus. So no need to check for
- * stop_on_plus.
- */
-
- if (*respbuf == '+') {
- g_free (cmdid);
- return CAMEL_IMAP_PLUS;
- }
-
- status = camel_imap_status (cmdid, respbuf);
- g_free (cmdid);
-
- if (status == CAMEL_IMAP_OK)
- return status;
-
- word = imap_next_word (respbuf); /* points to status */
- word = imap_next_word (word); /* points to fail message, if there is one */
-
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "IMAP command failed: %s", word);
- return status;
-}
/**
* camel_imap_command: Send a command to a IMAP server.
@@ -760,9 +725,9 @@ parse_single_line (CamelImapStore *store, char *cmdid, CamelException *ex)
gint
camel_imap_command (CamelImapStore *store, CamelFolder *folder, CamelException *ex, char *fmt, ...)
{
- gchar *cmdid;
- va_list ap;
+ char *cmdid, *respbuf, *word;
gint status = CAMEL_IMAP_OK;
+ va_list ap;
/* check for current folder */
status = check_current_folder (store, folder, fmt, ex);
@@ -773,11 +738,36 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder, CamelException *
va_start (ap, fmt);
if (!send_command (store, &cmdid, fmt, ap, ex)) {
va_end (ap);
+ g_free (cmdid);
return CAMEL_IMAP_FAIL;
}
va_end (ap);
- return parse_single_line (store, cmdid, ex);
+ /* read single line response */
+ if (camel_remote_store_recv_line (CAMEL_REMOTE_STORE (store), &respbuf, ex) < 0) {
+ g_free (cmdid);
+ return CAMEL_IMAP_FAIL;
+ }
+
+ status = camel_imap_status (cmdid, respbuf);
+ g_free (cmdid);
+
+ if (status == CAMEL_IMAP_OK)
+ return status;
+
+ if (respbuf) {
+ /* get error response and set exception accordingly */
+ word = imap_next_word (respbuf); /* points to status */
+ word = imap_next_word (word); /* points to fail message, if there is one */
+
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ "IMAP command failed: %s", word);
+ } else {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ "IMAP command failed: %s", "Unknown");
+ }
+
+ return status;
}
/**
@@ -819,7 +809,7 @@ camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **
status = check_current_folder (store, folder, fmt, ex);
if (status != CAMEL_IMAP_OK)
return status;
-
+
/* send the command */
va_start (ap, fmt);
if (!send_command (store, &cmdid, fmt, ap, ex)) {
@@ -858,6 +848,7 @@ camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **
gint
camel_imap_command_preliminary (CamelImapStore *store, char **cmdid, CamelException *ex, char *fmt, ...)
{
+ char *respbuf, *word;
gint status = CAMEL_IMAP_OK;
va_list ap;
@@ -869,8 +860,32 @@ camel_imap_command_preliminary (CamelImapStore *store, char **cmdid, CamelExcept
}
va_end (ap);
- /* Read the response */
- return parse_single_line (store, g_strdup (*cmdid), ex);
+ /* read single line response */
+ if (camel_remote_store_recv_line (CAMEL_REMOTE_STORE (store), &respbuf, ex) < 0)
+ return CAMEL_IMAP_FAIL;
+
+ /* Check for '+' which indicates server is ready for command continuation */
+ if (*respbuf == '+') {
+ g_free (cmdid);
+ return CAMEL_IMAP_PLUS;
+ }
+
+ status = camel_imap_status (*cmdid, respbuf);
+ g_free (cmdid);
+
+ if (respbuf) {
+ /* get error response and set exception accordingly */
+ word = imap_next_word (respbuf); /* points to status */
+ word = imap_next_word (word); /* points to fail message, if there is one */
+
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ "IMAP command failed: %s", word);
+ } else {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ "IMAP command failed: %s", "Unknown");
+ }
+
+ return status;
}
/**