diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-10-02 00:37:25 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-10-02 00:37:25 +0800 |
commit | d0bfb9478143d03baed80448f8a835009b7fc6f8 (patch) | |
tree | 9626c4ab8efeaed07b5b0937941ad1fdf8b24577 /mail | |
parent | 1fd58574ff6709cf0cb0c9ecc2d0aac32e40c0fb (diff) | |
download | gsoc2013-evolution-d0bfb9478143d03baed80448f8a835009b7fc6f8.tar gsoc2013-evolution-d0bfb9478143d03baed80448f8a835009b7fc6f8.tar.gz gsoc2013-evolution-d0bfb9478143d03baed80448f8a835009b7fc6f8.tar.bz2 gsoc2013-evolution-d0bfb9478143d03baed80448f8a835009b7fc6f8.tar.lz gsoc2013-evolution-d0bfb9478143d03baed80448f8a835009b7fc6f8.tar.xz gsoc2013-evolution-d0bfb9478143d03baed80448f8a835009b7fc6f8.tar.zst gsoc2013-evolution-d0bfb9478143d03baed80448f8a835009b7fc6f8.zip |
Use the camel_message_info_new/free functions rather than g_new0 and
2002-10-01 Jeffrey Stedfast <fejj@ximian.com>
* importers/evolution-mbox-importer.c (process_item_fn): Use the
camel_message_info_new/free functions rather than g_new0 and
g_free. Also, if we fail to parse a message make sure we don't
later try to use that message object.
(get_info_from_mozilla): Use camel_message_info_new and strtoul
instead of string_to_int.
2002-09-30 Jeffrey Stedfast <fejj@ximian.com>
* subscribe-dialog.c (fe_node_to_shell_path): Removed (useless).
svn path=/trunk/; revision=18279
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 13 | ||||
-rw-r--r-- | mail/importers/evolution-mbox-importer.c | 112 | ||||
-rw-r--r-- | mail/subscribe-dialog.c | 48 |
3 files changed, 60 insertions, 113 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index ab17fc1052..448b39e046 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,16 @@ +2002-10-01 Jeffrey Stedfast <fejj@ximian.com> + + * importers/evolution-mbox-importer.c (process_item_fn): Use the + camel_message_info_new/free functions rather than g_new0 and + g_free. Also, if we fail to parse a message make sure we don't + later try to use that message object. + (get_info_from_mozilla): Use camel_message_info_new and strtoul + instead of string_to_int. + +2002-09-30 Jeffrey Stedfast <fejj@ximian.com> + + * subscribe-dialog.c (fe_node_to_shell_path): Removed (useless). + 2002-10-01 Ettore Perazzoli <ettore@ximian.com> [Fix #24732] diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c index d088723bc9..faeadbcf34 100644 --- a/mail/importers/evolution-mbox-importer.c +++ b/mail/importers/evolution-mbox-importer.c @@ -69,64 +69,38 @@ void mail_importer_module_init (void); /* EvolutionImporter methods */ -static int -string_to_int (const char *str) -{ - int result = 0; - char *s; - - for (s = (char *) str; *s; s++) { - char c = toupper (*s); - - result *= 16; - - if (c >= '0' && c <= '9') { - result += (c - '0'); - } else if (c >= 'A' && c <= 'F') { - result += (c - 'A'); - } - } - - g_print ("%s became %d\n", str, result); - - return result; -} static CamelMessageInfo * get_info_from_mozilla (const char *mozilla_status, gboolean *deleted) { - int status; + unsigned int status; CamelMessageInfo *info; - - info = g_new0 (CamelMessageInfo, 1); - + *deleted = FALSE; - - status = string_to_int (mozilla_status); + + status = strtoul (mozilla_status, NULL, 16); if (status == 0) { - return info; + return camel_message_info_new (); } - + if (status & MSG_FLAG_EXPUNGED) { *deleted = TRUE; - g_free (info); - + return NULL; } - - if (status & MSG_FLAG_READ) { + + info = camel_message_info_new (); + + if (status & MSG_FLAG_READ) info->flags |= CAMEL_MESSAGE_SEEN; - } - - if (status & MSG_FLAG_MARKED) { + + if (status & MSG_FLAG_MARKED) info->flags |= CAMEL_MESSAGE_FLAGGED; - } - - if (status & MSG_FLAG_REPLIED) { + + if (status & MSG_FLAG_REPLIED) info->flags |= CAMEL_MESSAGE_ANSWERED; - } - + return info; } @@ -162,35 +136,36 @@ process_item_fn (EvolutionImporter *eimporter, CamelMimeMessage *msg; CamelMessageInfo *info; gboolean deleted; - + IN; msg = camel_mime_message_new (); - if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg), - mbi->mp) == -1) { + if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg), mbi->mp) == -1) { g_warning ("Failed message %d", mbi->num); camel_object_unref (CAMEL_OBJECT (msg)); done = TRUE; - } - - mozilla_status = camel_medium_get_header (CAMEL_MEDIUM (msg), "X-Mozilla-Status"); - if (mozilla_status != NULL) { - g_print ("Got Mozilla status header: %s\n", mozilla_status); - info = get_info_from_mozilla (mozilla_status, &deleted); } else { - info = g_new0 (CamelMessageInfo, 1); - deleted = FALSE; - } - - if (! deleted) { - /* Write the message. */ - camel_folder_append_message (importer->folder, msg, info, NULL, ex); - g_free (info); - } - - camel_object_unref (CAMEL_OBJECT (msg)); - if (camel_exception_is_set (ex)) { - g_warning ("Failed message %d", mbi->num); - done = TRUE; + mozilla_status = camel_medium_get_header (CAMEL_MEDIUM (msg), "X-Mozilla-Status"); + if (mozilla_status != NULL) { + g_print ("Got Mozilla status header: %s\n", mozilla_status); + info = get_info_from_mozilla (mozilla_status, &deleted); + } else { + deleted = FALSE; + info = camel_message_info_new (); + } + + if (deleted == FALSE) { + /* write the mesg */ + camel_folder_append_message (importer->folder, msg, info, NULL, ex); + } + + if (info) + camel_message_info_free (info); + + camel_object_unref (CAMEL_OBJECT (msg)); + if (camel_exception_is_set (ex)) { + g_warning ("Failed message %d", mbi->num); + done = TRUE; + } } OUT; } else { @@ -202,11 +177,10 @@ process_item_fn (EvolutionImporter *eimporter, done = TRUE; OUT; } - - if (!done) { + + if (!done) camel_mime_parser_step (mbi->mp, 0, 0); - } - + camel_exception_free (ex); GNOME_Evolution_ImporterListener_notifyResult (listener, GNOME_Evolution_ImporterListener_OK, diff --git a/mail/subscribe-dialog.c b/mail/subscribe-dialog.c index 7669833e7f..cab48a72ce 100644 --- a/mail/subscribe-dialog.c +++ b/mail/subscribe-dialog.c @@ -22,6 +22,7 @@ * */ + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -798,47 +799,6 @@ fe_get_first_child (ETreeModel *model, ETreePath path) } /* subscribing */ - -static char * -fe_node_to_shell_path (ftree_node *node) -{ - char *path = NULL; - int name_len, full_name_len; - - name_len = strlen (ftree_node_get_name (node)); - full_name_len = strlen (ftree_node_get_full_name (node)); - - if (name_len != full_name_len) { - char *full_name; - char *iter; - char sep; - - /* so, we don't know the heirarchy separator. But - * full_name = blahXblahXname, where X = separator - * and name = .... name. So we can determine it. - * (imap_store->dir_sep isn't really private, I guess, - * so we could use that if we had the store. But also - * we don't "know" that it is an IMAP store anyway.) - */ - - full_name = ftree_node_get_full_name (node); - sep = full_name[full_name_len - (name_len + 1)]; - - if (sep != '/') { - path = g_malloc (full_name_len + 2); - path[0] = '/'; - strcpy (path + 1, full_name); - while ((iter = strchr (path, sep)) != NULL) - *iter = '/'; - } - } - - if (!path) - path = g_strdup_printf ("/%s", ftree_node_get_full_name (node)); - - return path; -} - static void fe_done_subscribing (const char *full_name, const char *name, gboolean subscribe, gboolean success, gpointer user_data) { @@ -846,9 +806,9 @@ fe_done_subscribing (const char *full_name, const char *name, gboolean subscribe if (success && closure->handle != -1) { char *path; - - path = fe_node_to_shell_path (closure->data); - + + path = g_strdup_printf ("/%s", full_name); + if (subscribe) { closure->data->flags |= FTREE_NODE_SUBSCRIBED; recursive_add_folder (closure->ftree->e_storage, |