diff options
author | Dan Winship <danw@src.gnome.org> | 2000-09-22 05:05:56 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-09-22 05:05:56 +0800 |
commit | 3af120103084dec827ae3026da10adb67fd89a79 (patch) | |
tree | 972a56ffdb6b2e7148c0c1b993093a765e415a56 /camel/providers/imap/camel-imap-utils.c | |
parent | 08a52d10bc6dd001c42ebf3303b71460e9785210 (diff) | |
download | gsoc2013-evolution-3af120103084dec827ae3026da10adb67fd89a79.tar gsoc2013-evolution-3af120103084dec827ae3026da10adb67fd89a79.tar.gz gsoc2013-evolution-3af120103084dec827ae3026da10adb67fd89a79.tar.bz2 gsoc2013-evolution-3af120103084dec827ae3026da10adb67fd89a79.tar.lz gsoc2013-evolution-3af120103084dec827ae3026da10adb67fd89a79.tar.xz gsoc2013-evolution-3af120103084dec827ae3026da10adb67fd89a79.tar.zst gsoc2013-evolution-3af120103084dec827ae3026da10adb67fd89a79.zip |
New function to convert Camel flags to an IMAP flag_list.
* providers/imap/camel-imap-utils.c (imap_create_flag_list): New
function to convert Camel flags to an IMAP flag_list.
(imap_parse_flag_list): Contrariwise.
* providers/imap/camel-imap-store.c (camel_imap_command_*): Make
the @ret arg actually optional, as (mostly) documented.
(various): Don't pass "&result" to camel_imap_command_* if we're
just going to immediately free it. Don't record status if we're
not going to look at it.
* providers/imap/camel-imap-folder.c: Likewise.
(imap_summary_free): Use camel_folder_info_free.
(imap_sync): Use imap_create_flag_list. Clear
CAMEL_MESSAGE_FOLDER_FLAGGED after syncing so we don't keep
re-syncing.
(imap_append_message): Use imap_create_flag_list. Don't leak the
memstream if the append fails.
(imap_move_message_to): Use camel_folder_delete_message rather
than doing it by hand.
(imap_get_summary_internal, imap_get_message_info_internal): Use
imap_parse_flag_list and header_raw_clear.
(camel_imap_folder_changed): Use camel_message_info_free.
svn path=/trunk/; revision=5544
Diffstat (limited to 'camel/providers/imap/camel-imap-utils.c')
-rw-r--r-- | camel/providers/imap/camel-imap-utils.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/camel/providers/imap/camel-imap-utils.c b/camel/providers/imap/camel-imap-utils.c index c32975188e..8fdc4fb5b4 100644 --- a/camel/providers/imap/camel-imap-utils.c +++ b/camel/providers/imap/camel-imap-utils.c @@ -28,6 +28,7 @@ #include "camel-imap-utils.h" #include "string-utils.h" #include <e-sexp.h> +#include "camel/camel-folder-summary.h" #define d(x) x @@ -496,3 +497,62 @@ imap_translate_sexp (const char *expression) return retval; } + +char * +imap_create_flag_list (guint32 flags) +{ + GString *gstr; + char *flag_list; + + gstr = g_string_new ("("); + + if (flags & CAMEL_MESSAGE_ANSWERED) + g_string_append (gstr, "\\Answered "); + if (flags & CAMEL_MESSAGE_DELETED) + g_string_append (gstr, "\\Deleted "); + if (flags & CAMEL_MESSAGE_DRAFT) + g_string_append (gstr, "\\Draft "); + if (flags & CAMEL_MESSAGE_FLAGGED) + g_string_append (gstr, "\\Flagged "); + if (flags & CAMEL_MESSAGE_SEEN) + g_string_append (gstr, "\\Seen "); + + if (gstr->str[gstr->len - 1] == ' ') + gstr->str[gstr->len - 1] = ')'; + else + g_string_append_c (gstr, ')'); + + flag_list = gstr->str; + g_string_free (gstr, FALSE); + return flag_list; +} + +guint32 +imap_parse_flag_list (const char *flag_list) +{ + guint32 flags = 0; + int len; + + if (*flag_list++ != '(') + return 0; + + while (*flag_list != ')') { + len = strcspn (flag_list, " )"); + if (!g_strncasecmp (flag_list, "\\Answered", len)) + flags |= CAMEL_MESSAGE_ANSWERED; + else if (!g_strncasecmp (flag_list, "\\Deleted", len)) + flags |= CAMEL_MESSAGE_DELETED; + else if (!g_strncasecmp (flag_list, "\\Draft", len)) + flags |= CAMEL_MESSAGE_DRAFT; + else if (!g_strncasecmp (flag_list, "\\Flagged", len)) + flags |= CAMEL_MESSAGE_FLAGGED; + else if (!g_strncasecmp (flag_list, "\\Seen", len)) + flags |= CAMEL_MESSAGE_SEEN; + + flag_list += len; + if (*flag_list == ' ') + flag_list++; + } + + return flags; +} |