diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2004-03-25 08:42:05 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2004-03-25 08:42:05 +0800 |
commit | 2e125b7af652bb9be0dfc262c0cbe207f83211bf (patch) | |
tree | 476e647880da150c9ac58bfc735ef19141ec54ff /camel/providers/imap4/camel-imap-engine.c | |
parent | 69b905b91592bb4b704682a0e57af838f621e9f6 (diff) | |
download | gsoc2013-evolution-2e125b7af652bb9be0dfc262c0cbe207f83211bf.tar gsoc2013-evolution-2e125b7af652bb9be0dfc262c0cbe207f83211bf.tar.gz gsoc2013-evolution-2e125b7af652bb9be0dfc262c0cbe207f83211bf.tar.bz2 gsoc2013-evolution-2e125b7af652bb9be0dfc262c0cbe207f83211bf.tar.lz gsoc2013-evolution-2e125b7af652bb9be0dfc262c0cbe207f83211bf.tar.xz gsoc2013-evolution-2e125b7af652bb9be0dfc262c0cbe207f83211bf.tar.zst gsoc2013-evolution-2e125b7af652bb9be0dfc262c0cbe207f83211bf.zip |
New convenience wrapper function. (engine_parse_status): Fixed to handle
2004-03-24 Jeffrey Stedfast <fejj@ximian.com>
* providers/imap4/camel-imap-engine.c (camel_imap_engine_literal):
New convenience wrapper function.
(engine_parse_status): Fixed to handle literal mailbox strings.
* providers/imap4/camel-imap-command.c (camel_imap_command_newv):
Changed how %L works - create the CamelIMAPLiteral for our caller
instead of expecting them to create it for us. We can autodetect
what type of object (stream vs data-wrapper) the literal is, so
it's trivial to do.
svn path=/trunk/; revision=25179
Diffstat (limited to 'camel/providers/imap4/camel-imap-engine.c')
-rw-r--r-- | camel/providers/imap4/camel-imap-engine.c | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/camel/providers/imap4/camel-imap-engine.c b/camel/providers/imap4/camel-imap-engine.c index 36d2e42f9e..e7d6ce5899 100644 --- a/camel/providers/imap4/camel-imap-engine.c +++ b/camel/providers/imap4/camel-imap-engine.c @@ -579,6 +579,7 @@ engine_parse_status (CamelIMAPEngine *engine, CamelException *ex) { camel_imap_token_t token; char *mailbox; + size_t len; int type; if (camel_imap_engine_next_token (engine, &token, ex) == -1) @@ -592,7 +593,9 @@ engine_parse_status (CamelIMAPEngine *engine, CamelException *ex) mailbox = g_strdup (token.v.qstring); break; case CAMEL_IMAP_TOKEN_LITERAL: - /* FIXME: can this happen? if so implement it */ + if (camel_imap_engine_literal (engine, (unsigned char **) &mailbox, &len, err) == -1) + return -1; + break; default: fprintf (stderr, "Unexpected token in IMAP untagged STATUS response: %s%c\n", token.token == CAMEL_IMAP_TOKEN_NIL ? "NIL" : "", @@ -1582,7 +1585,7 @@ camel_imap_engine_eat_line (CamelIMAPEngine *engine, CamelException *ex) int camel_imap_engine_line (CamelIMAPEngine *engine, unsigned char **line, size_t *len, CamelException *ex) { - GByteArray *linebuf; + GByteArray *linebuf = NULL; unsigned char *buf; size_t buflen; int retval; @@ -1591,7 +1594,7 @@ camel_imap_engine_line (CamelIMAPEngine *engine, unsigned char **line, size_t *l linebuf = g_byte_array_new (); while ((retval = camel_imap_stream_line (engine->istream, &buf, &buflen)) > 0) { - if (line != NULL) + if (linebuf != NULL) g_byte_array_append (linebuf, buf, buflen); } @@ -1600,13 +1603,13 @@ camel_imap_engine_line (CamelIMAPEngine *engine, unsigned char **line, size_t *l _("IMAP server %s unexpectedly disconnected: %s"), engine->url->host, errno ? g_strerror (errno) : _("Unknown")); - if (line != NULL) + if (linebuf != NULL) g_byte_array_free (linebuf, TRUE); return -1; } - if (line != NULL) { + if (linebuf != NULL) { g_byte_array_append (linebuf, buf, buflen); *line = linebuf->data; @@ -1619,6 +1622,47 @@ camel_imap_engine_line (CamelIMAPEngine *engine, unsigned char **line, size_t *l } +int +camel_imap_engine_literal (CamelIMAPEngine *engine, unsigned char **literal, size_t *len, CamelException *ex) +{ + GByteArray *literalbuf = NULL; + unsigned char *buf; + size_t buflen; + int retval; + + if (literal != NULL) + literalbuf = g_byte_array_new (); + + while ((retval = camel_imap_stream_literal (engine->istream, &buf, &buflen)) > 0) { + if (literalbuf != NULL) + g_byte_array_append (literalbuf, buf, buflen); + } + + if (retval == -1) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("IMAP server %s unexpectedly disconnected: %s"), + engine->url->host, errno ? g_strerror (errno) : _("Unknown")); + + if (literalbuf != NULL) + g_byte_array_free (literalbuf, TRUE); + + return -1; + } + + if (literalbuf != NULL) { + g_byte_array_append (literalbuf, buf, buflen); + g_byte_array_append (literalbuf, "", 1); + + *literal = literalbuf->data; + *len = literalbuf->len - 1; + + g_byte_array_free (literalbuf, FALSE); + } + + return 0; +} + + void camel_imap_resp_code_free (CamelIMAPRespCode *rcode) { |