aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-08-12 11:42:42 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-08-12 11:42:42 +0800
commit4430ec83ec3ae4770c08d74bd9434b694e7ee628 (patch)
tree30ca38f428619d52649150e90cad2ef64ad2f835 /camel/providers
parent2a447586b3f32fc42c3032ec489a8660426c7eac (diff)
downloadgsoc2013-evolution-4430ec83ec3ae4770c08d74bd9434b694e7ee628.tar.gz
gsoc2013-evolution-4430ec83ec3ae4770c08d74bd9434b694e7ee628.tar.zst
gsoc2013-evolution-4430ec83ec3ae4770c08d74bd9434b694e7ee628.zip
Changed param order a bit and fixed some logic
2000-08-11 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-store.c (camel_imap_command_continuation): Changed param order a bit and fixed some logic * providers/imap/camel-imap-folder.c (imap_append_message): Use the new multi-transactional convenience functions svn path=/trunk/; revision=4766
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/imap/camel-imap-folder.c60
-rw-r--r--camel/providers/imap/camel-imap-store.c19
-rw-r--r--camel/providers/imap/camel-imap-store.h2
3 files changed, 53 insertions, 28 deletions
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 894b7a0865..5a157a037c 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -548,18 +548,15 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message, const Camel
{
CamelStore *store = CAMEL_STORE (folder->parent_store);
CamelURL *url = CAMEL_SERVICE (store)->url;
- CamelStreamMem *mem;
- gchar *result, *folder_path, *dir_sep, *flagstr = NULL;
+ CamelStream *memstream;
+ GByteArray *ba;
+ gchar *result, *cmdid, *dir_sep;
+ gchar *folder_path, *flagstr = NULL;
gint status;
g_return_if_fail (folder != NULL);
g_return_if_fail (message != NULL);
-
- /* write the message to a CamelStreamMem so we can get it's size */
- mem = CAMEL_STREAM_MEM (CAMEL_DATA_WRAPPER (message)->stream);
-
- mem->buffer = g_byte_array_append (mem->buffer, g_strdup ("\r\n"), 3);
-
+
dir_sep = CAMEL_IMAP_STORE (folder->parent_store)->dir_sep;
if (url && url->path && *(url->path + 1) && strcmp (folder->full_name, "INBOX"))
@@ -577,31 +574,52 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message, const Camel
*(flagstr + strlen (flagstr) - 1) = ')';
}
- /* FIXME: len isn't really correct I don't think, we need to crlf/dot filter */
- /* FIXME: Dont copy the message ANOTHER TIME, its already in memory entirely
- copied, thats bad enough */
- status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store),
- folder, &result, "APPEND %s%s {%d}\r\n%s",
- folder_path, flagstr ? flagstr : "",
- mem->buffer->len - 1, mem->buffer->data);
+ ba = g_byte_array_new ();
+ memstream = camel_stream_mem_new_with_byte_array (ba);
+ /* FIXME: we need to crlf/dot filter */
+ camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), memstream);
+ camel_stream_write_string (memstream, "\r\n");
+ camel_stream_reset (memstream);
- if (status != CAMEL_IMAP_OK) {
+ status = camel_imap_command_preliminary (CAMEL_IMAP_STORE (folder->parent_store),
+ &result, &cmdid, "APPEND %s%s {%d}",
+ folder_path, flagstr ? flagstr : "", ba->len - 2);
+
+ if (status != CAMEL_IMAP_PLUS) {
CamelService *service = CAMEL_SERVICE (folder->parent_store);
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
"Could not APPEND message to IMAP server %s: %s.",
- service->url->host,
- status != CAMEL_IMAP_FAIL && result ? result :
- "Unknown error");
+ service->url->host, result ? result : "Unknown error");
+
g_free (result);
+ g_free (cmdid);
g_free (folder_path);
return;
}
- /* FIXME: we should close/free the mem stream */
-
g_free (result);
g_free (folder_path);
+ /* send the rest of our data - the mime message */
+ status = camel_imap_command_continuation (CAMEL_IMAP_STORE (folder->parent_store),
+ &result, cmdid, memstream);
+
+ if (status != CAMEL_IMAP_OK) {
+ CamelService *service = CAMEL_SERVICE (folder->parent_store);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ "Could not APPEND message to IMAP server %s: %s.",
+ service->url->host, result ? result : "Unknown error");
+
+ camel_object_unref (CAMEL_OBJECT (memstream));
+ g_free (result);
+ g_free (cmdid);
+ return;
+ }
+
+ camel_object_unref (CAMEL_OBJECT (memstream));
+ g_free (cmdid);
+ g_free (result);
+
camel_imap_folder_changed (folder, 1, ex);
}
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 6eb03e9db4..d5985bb9ea 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -1023,6 +1023,7 @@ camel_imap_command_preliminary (CamelImapStore *store, char **ret, char **cmdid,
if (respbuf) {
switch (*respbuf) {
case '+':
+ /* continuation request */
status = CAMEL_IMAP_PLUS;
break;
default:
@@ -1050,6 +1051,9 @@ camel_imap_command_preliminary (CamelImapStore *store, char **ret, char **cmdid,
*
* This method is for sending continuing responses to the IMAP server. Meant
* to be used as a followup to camel_imap_command_preliminary.
+ * camel_imap_command_continuation will set @ret to point to a buffer
+ * containing the rest of the response from the IMAP server. The
+ * caller function is responsible for freeing @ret.
*
* Return value: one of CAMEL_IMAP_PLUS (command requires additional data),
* CAMEL_IMAP_OK (command executed successfully),
@@ -1059,7 +1063,7 @@ camel_imap_command_preliminary (CamelImapStore *store, char **ret, char **cmdid,
* of the result of the command.)
**/
gint
-camel_imap_command_continuation (CamelImapStore *store, char *cmdid, char **ret, CamelStream *cstream)
+camel_imap_command_continuation (CamelImapStore *store, char **ret, char *cmdid, CamelStream *cstream)
{
gint len = 0, status = CAMEL_IMAP_OK;
gchar *respbuf;
@@ -1069,19 +1073,22 @@ camel_imap_command_continuation (CamelImapStore *store, char *cmdid, char **ret,
d(fprintf (stderr, "sending continuation stream\r\n"));
if (camel_stream_write_to_stream (cstream, store->ostream) == -1) {
+ d(fprintf (stderr, "failed to send continuation stream\r\n"));
+
*ret = g_strdup (strerror (errno));
return CAMEL_IMAP_FAIL;
}
+ d(fprintf (stderr, "okie dokie...\r\n"));
data = g_ptr_array_new ();
- while (TRUE) {
+ while (1) {
CamelStreamBuffer *stream = CAMEL_STREAM_BUFFER (store->istream);
respbuf = camel_stream_buffer_read_line (stream);
if (!respbuf || *respbuf == '+' || !strncmp (respbuf, cmdid, strlen (cmdid))) {
- /* IMAP's last response starts with our command id */
+ /* IMAP's last response starts with our command id or a continuation request */
d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)"));
break;
@@ -1094,14 +1101,14 @@ camel_imap_command_continuation (CamelImapStore *store, char *cmdid, char **ret,
}
if (respbuf) {
+ g_ptr_array_add (data, respbuf);
+ len += strlen (respbuf) + 1;
+
switch (*respbuf) {
case '+':
status = CAMEL_IMAP_PLUS;
break;
default:
- g_ptr_array_add (data, respbuf);
- len += strlen (respbuf) + 1;
-
status = camel_imap_status (cmdid, respbuf);
}
} else {
diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h
index ce572ff45d..678cf83a1d 100644
--- a/camel/providers/imap/camel-imap-store.h
+++ b/camel/providers/imap/camel-imap-store.h
@@ -88,7 +88,7 @@ gint camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, ch
/* multi-transactional commands... */
gint camel_imap_command_preliminary (CamelImapStore *store, char **ret, char **cmdid, char *fmt, ...);
-gint camel_imap_command_continuation (CamelImapStore *store, char *cmdid, char **ret, CamelStream *cstream);
+gint camel_imap_command_continuation (CamelImapStore *store, char **ret, char *cmdid, CamelStream *cstream);
/* Standard Camel function */
CamelType camel_imap_store_get_type (void);
s'>-1/+1 * As announced on Aug 7, remove the broken hlatex-mffonts-wansung andkris2003-11-0810-974/+0 * rename openoffice to openoffice-1.0 after repocopymaho2003-11-082-16/+1 * Use the new Apache bits from bsd.port.mk.marcus2003-11-071-4/+1 * Respect CC and CFLAGSkris2003-10-191-0/+28 * Update to 0.9.perky2003-10-152-16/+3 * Update to 0.8perky2003-10-132-2/+2 * - Fix MASTER_SITESkrion2003-10-011-3/+3 * sysutis/cd9660, japanese/msdosfs and korean/msdosfs is nowperky2003-09-281-1/+4 * Update to 0.7perky2003-09-283-23/+16 * Add ko-unfonts-ttf 20030907,perky2003-09-285-0/+57 * Update to 0.7perky2003-09-282-2/+2 * Update to 0.6perky2003-09-252-3/+2 * Add a workaround to avoid a fatal confliction with qt32.perky2003-09-192-0/+21 * Remove ko-qt31. We are happy with mainstream qt 3.2.1 now.perky2003-09-195-75/+0 * Point to the QT 3.2 Makefile instead of the 3.1 Makefile. This directorymarcus2003-09-191-1/+1 * Upgrade to Qt 3.2.1 / KDE 3.1.4. See x11/kde3/Makefile rev 1.64 for details.will2003-09-182-2/+0 * Add missing \erwin2003-09-091-1/+1 * Fix distfiles/www locations and one maintainer.cjh2003-09-099-18/+10 * Fix distfiles location.cjh2003-09-097-8/+7 * Fix non-i386 builds proposed by the submitter.cjh2003-09-091-2/+2 * * Support CFLAGStaoka2003-09-021-0/+1 * Update to 0.6.4perky2003-09-012-2/+2 * Update to 0.4perky2003-08-283-31/+24 * Bump the PORTREVISION for the ports directly affected by the gettext upgrade.marcus2003-08-271-1/+1 * Chase the libintl.so shared lib version.marcus2003-08-251-1/+1 * Add two knobs that changes default keyboard layout:perky2003-08-251-0/+5 * Update to 0.6.3perky2003-08-232-2/+2 * Update to 0.6.2perky2003-08-213-23/+19 * Add a missing dependency on py-cjkcodecsperky2003-08-201-1/+2 * Add port for GDick 0.6.1, a English<->Korean Dictionary for GTK2/GNOME2perky2003-08-206-0/+69 * Fix build on -STABLEperky2003-08-201-1/+6 * Remove dependency on libpanel.marcus2003-08-122-19/+0 * Update to 0.3perky2003-08-122-2/+2 * - Update to 0.2perky2003-08-113-7/+4 * BROKEN: Does not fetchkris2003-08-071-0/+2 * Fix mis-sorting in r1.85kris2003-08-071-1/+1 * As announced on May 6, remove the broken htexp portkris2003-08-076-104/+0 * As announced on May 6, remove the broken ghostscript55httf portkris2003-08-0711-963/+0 * As announced on May 6, remove the broken ftghostscript5 portkris2003-08-0710-661/+0 * - Pass correct CPPFLAGS and LDFLAGS to configure for libiconv and libintl.perky2003-08-061-4/+4 * Remove korean/netdic. It never worked at all and is marked BROKENperky2003-08-055-40/+0 * Add nabi 0.1, a Shiny New Hangul X Input Method.perky2003-08-055-0/+77 * BROKEN: Broken dependencykris2003-08-051-0/+2 * Update KDE to the latest official release, KDE 3.1.3lofi2003-07-292-0/+2 * Remove acroread-*font ports after removal of acroread.kuriyama2003-07-244-25/+0 * Remove ko-pycodec. It's replaced by converters/py-cjkcodecs now.perky2003-07-205-117/+0 * Unhook acroread-*font before actual deletion of each ports.kuriyama2003-07-081-1/+0 * libtool uber-patchade2003-06-271-26/+0 * Fix issues with the PGPLIB change made some time ago (broken alpha build,will2003-06-252-11/+11 * Activate korean/imhangul_status_applet, GNOME2 panel applet of imhangulcjh2003-06-036-0/+91 * Active korean/imhangul, gtk+ 2.0 Korean input method extension.cjh2003-06-035-0/+36 * Add a port for unzip with localized patches.perky2003-05-215-0/+64 * Update to KDE 3.1.2lioux2003-05-202-6/+6 * BROKEN: Does not compilekris2003-05-073-0/+6 * As announced on 27 March 2003 in <20030328052350.GA18971@rot13.obsecurity.org>,kris2003-05-061-1/+0 * As announced on 27 March 2003 in <20030328052350.GA18971@rot13.obsecurity.org>,kris2003-05-064-53/+0 * Convert to new GNOME infrastructure.marcus2003-05-051-1/+1 * Convert to new GNOME infrastructure.marcus2003-05-051-1/+1 * Add a port for ko-qt31, Localized Qt 3.1 for Korean Usersperky2003-04-255-0/+75 * Remove gnome knobarved2003-04-241-6/+2 * gdk-pixbuf is installed at ${X11BASE}.cjh2003-04-201-1/+1 * Back out my last commit to pkg-plist.arved2003-04-142-6/+0 * Activate mod_url.cjh2003-04-136-0/+53 * Convert to new GNOME infrastructure.marcus2003-04-081-7/+4 * - Nuke obsolete PREV_I18N_VER from Makefile.kdearved2003-04-086-8/+12 * Rejoice, for the long awaited upgrade to kde 3.1.1 is here!alane2003-04-064-2/+20 * o Fix build on 5 [1]perky2003-03-243-4/+25 * Clear moonlight beckons.ade2003-03-0794-47/+47 * Remove pkg-comment where COMMENT is already defined in the Makefileade2003-03-071-1/+0 * Remove pkg-comment from the remaining special cases.ade2003-03-073-1/+2 * Remove pkg-comment from remaining master/slave port sets.ade2003-03-0714-7/+8 * Destroy pkg-comment for some of the stranger uses in the tree,ade2003-03-072-1/+2 * Make BROKEN: doesn't working at all due to update of the site.perky2003-02-281-0/+2 * Release the maintainershipperky2003-02-281-1/+1 * De-pkg-comment for my ports.perky2003-02-256-3/+3 * Remove RESTRICTED tag for crypto stuff.nork2003-02-232-3/+0 * De-pkg-comment.knu2003-02-218-4/+4 * De-pkg-comment.knu2003-02-214-4/+2 * Update to 2.0.5-173.cjh2003-02-192-3/+3 * Update to 1.2.2cjh2003-02-193-6/+4 * build fix for 5-current.cjh2003-02-181-0/+11 * Update 2.0.4-172 (based on xterm-172)cjh2003-02-186-33/+28 * Upgrade to 1.2.1.perky2003-02-185-25/+60 * Convert COMMENT to COMMENTFILE until these ports can be converted.kris2003-02-102-2/+2 * add Acrobat Reader 5 CJK font packsijliao2003-02-066-7/+7 * Upgrade kde-i18n to 3.1. Note that the following modules did not get awill2003-01-294-2/+4 * New port: korean/netdicedwin2003-01-206-0/+38 * After repo copy from graphics category, update all appropriatelioux2002-11-291-1/+1 * Update to 4.8. Back from hell!cjh2002-11-27