diff options
author | Dan Winship <danw@src.gnome.org> | 2000-06-17 07:11:10 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-06-17 07:11:10 +0800 |
commit | 9c21067261d2af663d762c7f655eea1a7573f1e9 (patch) | |
tree | 4229c0ba1d5bda5dee9c1db0991460681521787d /mail/mail-ops.c | |
parent | 3069f4c5d1a2d0a2a8e3f6afd2a446493fab14d5 (diff) | |
download | gsoc2013-evolution-9c21067261d2af663d762c7f655eea1a7573f1e9.tar gsoc2013-evolution-9c21067261d2af663d762c7f655eea1a7573f1e9.tar.gz gsoc2013-evolution-9c21067261d2af663d762c7f655eea1a7573f1e9.tar.bz2 gsoc2013-evolution-9c21067261d2af663d762c7f655eea1a7573f1e9.tar.lz gsoc2013-evolution-9c21067261d2af663d762c7f655eea1a7573f1e9.tar.xz gsoc2013-evolution-9c21067261d2af663d762c7f655eea1a7573f1e9.tar.zst gsoc2013-evolution-9c21067261d2af663d762c7f655eea1a7573f1e9.zip |
new function to do a uid to row mapping. (mark_msg_seen, select_msg,
* message-list.c (get_message_row): new function to do a uid to
row mapping.
(mark_msg_seen, select_msg, message_changed,
message_list_set_folder): Update for Camel flag changes.
(on_cursor_change_cmd): Rename "row_to_select" to "selected_row",
and keep a "selected_uid" as well.
* mail-ops.c (composer_send_cb): Update for Camel flag changes,
and fix some memory-handling bugs. (Free the post_send_data when
the composer is destroyed, not when the user clicks "send", which
could happen never, or more than once.)
(delete_msg): Update for Camel flag changes, and fix the "holding
down the delete key skips some messages" bug.
svn path=/trunk/; revision=3600
Diffstat (limited to 'mail/mail-ops.c')
-rw-r--r-- | mail/mail-ops.c | 84 |
1 files changed, 51 insertions, 33 deletions
diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 81cb5ae139..c28c4a0de6 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -271,7 +271,8 @@ fetch_mail (GtkWidget *button, gpointer user_data) struct post_send_data { - CamelMimeMessage *message; + CamelFolder *folder; + const char *uid; guint32 flags; }; @@ -321,7 +322,7 @@ composer_send_cb (EMsgComposer *composer, gpointer data) mail_exception_dialog ("Could not load mail transport", ex, composer); camel_exception_free (ex); - goto free_psd; + return; } } @@ -340,26 +341,29 @@ composer_send_cb (EMsgComposer *composer, gpointer data) if (camel_exception_is_set (ex)) mail_exception_dialog ("Could not send message", ex, composer); else { - gtk_object_destroy (GTK_OBJECT (composer)); if (psd) { guint32 set; - set = camel_mime_message_get_flags (psd->message); - camel_mime_message_set_flags (psd->message, - psd->flags, ~set); + set = camel_folder_get_message_flags (psd->folder, + psd->uid, ex); + camel_folder_set_message_flags (psd->folder, psd->uid, + psd->flags, ~set, ex); } + gtk_object_destroy (GTK_OBJECT (composer)); } camel_exception_free (ex); gtk_object_unref (GTK_OBJECT (message)); - - free_psd: - if (psd) { - gtk_object_unref (GTK_OBJECT (psd->message)); - g_free (psd); - } } +static void +free_psd (GtkWidget *composer, gpointer user_data) +{ + struct post_send_data *psd = user_data; + + gtk_object_unref (GTK_OBJECT (psd->folder)); + g_free (psd); +} void send_msg (GtkWidget *widget, gpointer user_data) @@ -402,14 +406,18 @@ reply (FolderBrowser *fb, gboolean to_all) return; psd = g_new (struct post_send_data, 1); - psd->message = fb->mail_display->current_message; - gtk_object_ref (GTK_OBJECT (psd->message)); + psd->folder = fb->folder; + gtk_object_ref (GTK_OBJECT (psd->folder)); + psd->uid = fb->message_list->selected_uid; psd->flags = CAMEL_MESSAGE_ANSWERED; - composer = mail_generate_reply (psd->message, to_all); + composer = mail_generate_reply (fb->mail_display->current_message, + to_all); gtk_signal_connect (GTK_OBJECT (composer), "send", GTK_SIGNAL_FUNC (composer_send_cb), psd); + gtk_signal_connect (GTK_OBJECT (composer), "destroy", + GTK_SIGNAL_FUNC (free_psd), psd); gtk_widget_show (GTK_WIDGET (composer)); } @@ -450,25 +458,35 @@ void delete_msg (GtkWidget *button, gpointer user_data) { FolderBrowser *fb = user_data; - int row; - - if (fb->mail_display->current_message) { - guint32 flags; - - /* FIXME: table should watch the message with a signal and update display! */ - - flags = camel_mime_message_get_flags(fb->mail_display->current_message); - camel_mime_message_set_flags(fb->mail_display->current_message, CAMEL_MESSAGE_DELETED, ~flags); - printf("Message %s set to %s\n", fb->mail_display->current_message->message_uid, - flags&CAMEL_MESSAGE_DELETED ? "UNDELETED" : "DELETED"); - - - /* Move the cursor down a row... FIXME: should skip other - * deleted messages. - */ - row = e_table_get_selected_view_row (E_TABLE (fb->message_list->etable)); - e_table_select_row (E_TABLE (fb->message_list->etable), row + 1); + MessageList *ml = fb->message_list; + CamelException ex; + guint32 flags; + + if (!fb->mail_display->current_message) + return; + + camel_exception_init (&ex); + + flags = camel_folder_get_message_flags (fb->folder, ml->selected_uid, + &ex); + if (!camel_exception_is_set (&ex)) { + /* Toggle the deleted flag without touching other flags. */ + camel_folder_set_message_flags (fb->folder, ml->selected_uid, + CAMEL_MESSAGE_DELETED, + ~flags, &ex); } + + if (camel_exception_is_set (&ex)) { + mail_exception_dialog ("Could not toggle deleted flag", + &ex, fb); + camel_exception_clear (&ex); + return; + } + + /* Move the cursor down a row... FIXME: should skip other + * deleted messages. + */ + e_table_select_row (E_TABLE (ml->etable), ml->selected_row + 1); } void |