aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/imap/camel-imap-utils.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-01-15 04:14:15 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-01-15 04:14:15 +0800
commitd54a3c91c587f2d481c8c52b1674210502acbe85 (patch)
tree2e627f709b2940b71487b9516310f6479cd51628 /camel/providers/imap/camel-imap-utils.c
parent885d0b6bd7eb813ec273592ee627ff0f1bd4f065 (diff)
downloadgsoc2013-evolution-d54a3c91c587f2d481c8c52b1674210502acbe85.tar
gsoc2013-evolution-d54a3c91c587f2d481c8c52b1674210502acbe85.tar.gz
gsoc2013-evolution-d54a3c91c587f2d481c8c52b1674210502acbe85.tar.bz2
gsoc2013-evolution-d54a3c91c587f2d481c8c52b1674210502acbe85.tar.lz
gsoc2013-evolution-d54a3c91c587f2d481c8c52b1674210502acbe85.tar.xz
gsoc2013-evolution-d54a3c91c587f2d481c8c52b1674210502acbe85.tar.zst
gsoc2013-evolution-d54a3c91c587f2d481c8c52b1674210502acbe85.zip
Updated to use the new imap_uid_array_to_set() interface.
2002-01-14 Jeffrey Stedfast <fejj@ximian.com> * providers/imap/camel-imap-folder.c (imap_expunge_uids_online): Updated to use the new imap_uid_array_to_set() interface. (imap_expunge_uids_resyncing): Same. (do_copy): Here too. (imap_update_summary): Added a FIXME comment to rewrite allowing for a uid-set limitation. (get_matching): Copy some of the logic over from imap_uid_adday_to_set() to limit the length of the uid-set string. (imap_sync_online): Added a comment to explain what is going on with get_matching() since the behavior has changed slightly. * providers/imap/camel-imap-utils.c (imap_uid_array_to_set): Modify the interface so that we can limit the size of the uid set string returned. svn path=/trunk/; revision=15318
Diffstat (limited to 'camel/providers/imap/camel-imap-utils.c')
-rw-r--r--camel/providers/imap/camel-imap-utils.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/camel/providers/imap/camel-imap-utils.c b/camel/providers/imap/camel-imap-utils.c
index d5466bf9ac..7d2073142b 100644
--- a/camel/providers/imap/camel-imap-utils.c
+++ b/camel/providers/imap/camel-imap-utils.c
@@ -648,44 +648,54 @@ get_summary_uid_numeric (CamelFolderSummary *summary, int index)
return uid;
}
+/* the max number of chars that an unsigned 32-bit int can be is 10 chars plus 1 for a possible : */
+#define UID_SET_FULL(setlen, maxlen) (maxlen > 0 ? setlen + 11 >= maxlen : FALSE)
+
/**
* imap_uid_array_to_set:
* @summary: summary for the folder the UIDs come from
* @uids: a (sorted) array of UIDs
+ * @uid: uid index to start at
+ * @maxlen: max length of the set string (or -1 for infinite)
+ * @lastuid: index offset of the last uid used
+ *
+ * Creates an IMAP "set" up to @maxlen bytes long, covering the listed
+ * UIDs starting at index @uid and not covering any UIDs that are in
+ * @summary but not in @uids. It doesn't actually require that all (or
+ * any) of the UIDs be in @summary.
*
- * Creates an IMAP "set" covering the listed UIDs and not covering
- * any UIDs that are in @summary but not in @uids. It doesn't
- * actually require that all (or any) of the UIDs be in @summary.
+ * After calling, @lastuid will be set the index of the first uid
+ * *not* included in the returned set string.
*
* Return value: the set, which the caller must free with g_free()
**/
char *
-imap_uid_array_to_set (CamelFolderSummary *summary, GPtrArray *uids)
+imap_uid_array_to_set (CamelFolderSummary *summary, GPtrArray *uids, int uid, ssize_t maxlen, int *lastuid)
{
- int ui, si, scount;
unsigned long last_uid, next_summary_uid, this_uid;
gboolean range = FALSE;
+ int si, scount;
GString *gset;
char *set;
- g_return_val_if_fail (uids->len > 0, NULL);
+ g_return_val_if_fail (uids->len > uid, NULL);
- gset = g_string_new (uids->pdata[0]);
- last_uid = strtoul (uids->pdata[0], NULL, 10);
+ gset = g_string_new (uids->pdata[uid]);
+ last_uid = strtoul (uids->pdata[uid], NULL, 10);
next_summary_uid = 0;
scount = camel_folder_summary_count (summary);
- for (ui = 1, si = 0; ui < uids->len; ui++) {
+ for (uid++, si = 0; uid < uids->len && !UID_SET_FULL (gset->len, maxlen); uid++) {
/* Find the next UID in the summary after the one we
* just wrote out.
*/
- for (; last_uid >= next_summary_uid && si < scount; si++)
+ for ( ; last_uid >= next_summary_uid && si < scount; si++)
next_summary_uid = get_summary_uid_numeric (summary, si);
if (last_uid >= next_summary_uid)
next_summary_uid = (unsigned long) -1;
/* Now get the next UID from @uids */
- this_uid = strtoul (uids->pdata[ui], NULL, 10);
+ this_uid = strtoul (uids->pdata[uid], NULL, 10);
if (this_uid == next_summary_uid || this_uid == last_uid + 1)
range = TRUE;
else {
@@ -702,6 +712,8 @@ imap_uid_array_to_set (CamelFolderSummary *summary, GPtrArray *uids)
if (range)
g_string_sprintfa (gset, ":%lu", last_uid);
+ *lastuid = uid;
+
set = gset->str;
g_string_free (gset, FALSE);