aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-06-18 09:56:23 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-06-18 09:56:23 +0800
commitc1c936c70a138bf853dc79e2775b4c7893722c0d (patch)
treee81339ad0d5340bcd2976c6e2f513520876c6476
parent4ffc39159b07823df1d312fadaf02a7e955e53a8 (diff)
downloadgsoc2013-evolution-c1c936c70a138bf853dc79e2775b4c7893722c0d.tar
gsoc2013-evolution-c1c936c70a138bf853dc79e2775b4c7893722c0d.tar.gz
gsoc2013-evolution-c1c936c70a138bf853dc79e2775b4c7893722c0d.tar.bz2
gsoc2013-evolution-c1c936c70a138bf853dc79e2775b4c7893722c0d.tar.lz
gsoc2013-evolution-c1c936c70a138bf853dc79e2775b4c7893722c0d.tar.xz
gsoc2013-evolution-c1c936c70a138bf853dc79e2775b4c7893722c0d.tar.zst
gsoc2013-evolution-c1c936c70a138bf853dc79e2775b4c7893722c0d.zip
We were leaking memory - but not anymore! (imap_get_summary): We now get
2000-06-17 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-folder.c (imap_free_summary): We were leaking memory - but not anymore! (imap_get_summary): We now get the UIDs and the beginnings of the code to get the message flags as well. svn path=/trunk/; revision=3625
-rw-r--r--camel/ChangeLog7
-rw-r--r--camel/providers/imap/camel-imap-folder.c107
2 files changed, 111 insertions, 3 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 7e38c2d529..d35e6babc0 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,10 @@
+2000-06-17 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * providers/imap/camel-imap-folder.c (imap_free_summary): We were
+ leaking memory - but not anymore!
+ (imap_get_summary): We now get the UIDs and the beginnings of the
+ code to get the message flags as well.
+
2000-06-17 Dan Winship <danw@helixcode.com>
* camel-mime-parser.c (folder_scan_header): Don't copy newlines
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 74148d3d92..c9af368d3c 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -666,7 +666,7 @@ imap_get_summary (CamelFolder *folder, CamelException *ex)
GPtrArray *array = NULL;
CamelMessageInfo *info;
int i, num, status;
- char *result, *datestr;
+ char *result, *datestr, *p, *q;
num = imap_get_message_count (folder, ex);
@@ -696,11 +696,110 @@ imap_get_summary (CamelFolder *folder, CamelException *ex)
datestr = get_header_field (result, "\nDate:");
info->date_sent = header_decode_date (datestr, NULL);
g_free (datestr);
+ g_free (result);
+
+ /* now to get the UID */
+ status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
+ &result, "FETCH %d UID", i);
- info->uid = NULL; /* FIXME: how can we get the UID? */
+ if (status != CAMEL_IMAP_OK) {
+ CamelService *service = CAMEL_SERVICE (folder->parent_store);
+
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ "Could not get summary for %s on IMAP server %s: %s",
+ folder->full_name, service->url->host,
+ status == CAMEL_IMAP_ERR ? result :
+ "Unknown error");
+ g_free (result);
+
+ g_free (info->subject);
+ g_free (info->to);
+ g_free (info->from);
+ g_free (info);
+
+ break;
+ }
+
+ if (!result || *result != '*') {
+ g_free (result);
+ fprintf (stderr, "Warning: UID for message %d not found\n", i);
+
+ g_free (info->subject);
+ g_free (info->to);
+ g_free (info->from);
+ g_free (info);
+
+ break;
+ }
+
+ p = strchr (result, '(') + 1;
+ if (strncasecmp (p, "UID", 3)) {
+ g_free (result);
+ fprintf (stderr, "Warning: UID for message %d not found\n", i);
+
+ g_free (info->subject);
+ g_free (info->to);
+ g_free (info->from);
+ g_free (info);
+
+ break;
+ }
+
+ for (p += 4; *p && *p != ' '; p++); /* advance to <uid> */
+ for (q = p; *q && *q != ')' && *q != ' '; q++); /* find the end of the <uid> */
+ info->uid = g_strndup (p, (gint)(q - p));
g_free (result);
- /* still need to get flags */
+ /* now to get the flags */
+ status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
+ &result, "FETCH %d FLAGS", i);
+
+ if (status != CAMEL_IMAP_OK) {
+ CamelService *service = CAMEL_SERVICE (folder->parent_store);
+
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ "Could not get summary for %s on IMAP server %s: %s",
+ folder->full_name, service->url->host,
+ status == CAMEL_IMAP_ERR ? result :
+ "Unknown error");
+ g_free (result);
+
+ g_free (info->subject);
+ g_free (info->to);
+ g_free (info->from);
+ g_free (info);
+
+ break;
+ }
+
+ if (!result || *result != '*') {
+ g_free (result);
+ fprintf (stderr, "Warning: FLAGS for message %d not found\n", i);
+
+ g_free (info->subject);
+ g_free (info->to);
+ g_free (info->from);
+ g_free (info);
+
+ break;
+ }
+
+ p = strchr (result, '(') + 1;
+ if (strncasecmp (p, "FLAGS", 5)) {
+ g_free (result);
+ fprintf (stderr, "Warning: FLAGS for message %d not found\n", i);
+
+ g_free (info->subject);
+ g_free (info->to);
+ g_free (info->from);
+ g_free (info);
+
+ break;
+ }
+
+ /* now we gotta parse for the flags */
+
+ g_free (result);
g_ptr_array_add (array, info);
}
@@ -721,6 +820,8 @@ imap_free_summary (CamelFolder *folder, GPtrArray *array)
g_free (info->to);
g_free (info->from);
g_free (info->uid);
+ g_free (info);
+ info = NULL;
}
g_ptr_array_free (array, TRUE);