aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--e-util/e-marshal.list1
-rw-r--r--mail/e-mail-reader-utils.c32
-rw-r--r--mail/e-mail-reader-utils.h2
-rw-r--r--mail/e-mail-reader.c92
-rw-r--r--mail/e-mail-reader.h7
5 files changed, 81 insertions, 53 deletions
diff --git a/e-util/e-marshal.list b/e-util/e-marshal.list
index c42078b2df..884886c83f 100644
--- a/e-util/e-marshal.list
+++ b/e-util/e-marshal.list
@@ -54,6 +54,7 @@ NONE:POINTER,POINTER,INT
NONE:STRING,DOUBLE
NONE:STRING,INT
NONE:STRING,INT,INT
+NONE:STRING,OBJECT
NONE:STRING,POINTER,POINTER
NONE:STRING,STRING
NONE:UINT,STRING
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 725a0c6d7c..a58eb1f441 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -282,38 +282,6 @@ e_mail_reader_delete_folder (EMailReader *reader,
gtk_widget_destroy (dialog);
}
-void
-e_mail_reader_mark_as_read (EMailReader *reader,
- const gchar *uid)
-{
- EMailBackend *backend;
- EMFormatHTML *formatter;
- CamelFolder *folder;
- guint32 mask, set;
- guint32 flags;
-
- g_return_if_fail (E_IS_MAIL_READER (reader));
- g_return_if_fail (uid != NULL);
-
- folder = e_mail_reader_get_folder (reader);
- backend = e_mail_reader_get_backend (reader);
- formatter = e_mail_reader_get_formatter (reader);
-
- flags = camel_folder_get_message_flags (folder, uid);
-
- if (!(flags & CAMEL_MESSAGE_SEEN)) {
- CamelMimeMessage *message;
-
- message = EM_FORMAT (formatter)->message;
- em_utils_handle_receipt (backend, folder, uid, message);
- }
-
- mask = CAMEL_MESSAGE_SEEN;
- set = CAMEL_MESSAGE_SEEN;
-
- camel_folder_set_message_flags (folder, uid, mask, set);
-}
-
guint
e_mail_reader_mark_selected (EMailReader *reader,
guint32 mask,
diff --git a/mail/e-mail-reader-utils.h b/mail/e-mail-reader-utils.h
index b566da16a7..bb4671ba21 100644
--- a/mail/e-mail-reader-utils.h
+++ b/mail/e-mail-reader-utils.h
@@ -39,8 +39,6 @@ struct _EMailReaderHeader {
gboolean e_mail_reader_confirm_delete (EMailReader *reader);
void e_mail_reader_delete_folder (EMailReader *reader,
CamelFolder *folder);
-void e_mail_reader_mark_as_read (EMailReader *reader,
- const gchar *uid);
guint e_mail_reader_mark_selected (EMailReader *reader,
guint32 mask,
guint32 set);
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 8b7c80349a..06fdfc4293 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -102,6 +102,7 @@ struct _EMailReaderPrivate {
enum {
CHANGED,
FOLDER_LOADED,
+ MESSAGE_SEEN,
SHOW_SEARCH_BAR,
UPDATE_ACTIONS,
SHOW_FOLDER,
@@ -1102,13 +1103,13 @@ action_mail_redirect_cb (GtkAction *action,
EMailReaderClosure *closure;
GtkWidget *message_list;
CamelFolder *folder;
- const gchar *uid;
+ const gchar *message_uid;
folder = e_mail_reader_get_folder (reader);
message_list = e_mail_reader_get_message_list (reader);
- uid = MESSAGE_LIST (message_list)->cursor_uid;
- g_return_if_fail (uid != NULL);
+ message_uid = MESSAGE_LIST (message_list)->cursor_uid;
+ g_return_if_fail (message_uid != NULL);
/* Open the message asynchronously. */
@@ -1120,7 +1121,7 @@ action_mail_redirect_cb (GtkAction *action,
closure->reader = g_object_ref (reader);
camel_folder_get_message (
- folder, uid, G_PRIORITY_DEFAULT,
+ folder, message_uid, G_PRIORITY_DEFAULT,
cancellable, (GAsyncReadyCallback)
mail_reader_redirect_cb, closure);
}
@@ -2479,21 +2480,35 @@ mail_reader_key_press_cb (EMailReader *reader,
}
static gboolean
-mail_reader_message_read_cb (EMailReaderClosure *closure)
+mail_reader_message_seen_cb (EMailReaderClosure *closure)
{
EMailReader *reader;
GtkWidget *message_list;
- const gchar *cursor_uid;
+ EMFormatHTML *formatter;
+ CamelMimeMessage *message;
+ const gchar *current_uid;
const gchar *message_uid;
+ gboolean uid_is_current = TRUE;
reader = closure->reader;
message_uid = closure->message_uid;
+ formatter = e_mail_reader_get_formatter (reader);
message_list = e_mail_reader_get_message_list (reader);
- cursor_uid = MESSAGE_LIST (message_list)->cursor_uid;
- if (g_strcmp0 (cursor_uid, message_uid) == 0)
- e_mail_reader_mark_as_read (reader, message_uid);
+ current_uid = EM_FORMAT (formatter)->uid;
+ uid_is_current &= (g_strcmp0 (current_uid, message_uid) == 0);
+
+ current_uid = MESSAGE_LIST (message_list)->cursor_uid;
+ uid_is_current &= (g_strcmp0 (current_uid, message_uid) == 0);
+
+ message = EM_FORMAT (formatter)->message;
+ g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), FALSE);
+
+ if (uid_is_current)
+ g_signal_emit (
+ reader, signals[MESSAGE_SEEN], 0,
+ message_uid, message);
return FALSE;
}
@@ -2517,7 +2532,7 @@ schedule_timeout_mark_seen (EMailReader *reader)
shell_settings = e_shell_get_shell_settings (shell);
message_uid = message_list->cursor_uid;
- if (!message_uid)
+ if (message_uid == NULL)
return FALSE;
schedule_timeout =
@@ -2542,7 +2557,7 @@ schedule_timeout_mark_seen (EMailReader *reader)
MESSAGE_LIST (message_list)->seen_id = g_timeout_add_full (
G_PRIORITY_DEFAULT, timeout_interval,
- (GSourceFunc) mail_reader_message_read_cb,
+ (GSourceFunc) mail_reader_message_seen_cb,
timeout_closure, (GDestroyNotify)
mail_reader_closure_free);
}
@@ -2736,7 +2751,7 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
static void
mail_reader_message_selected_cb (EMailReader *reader,
- const gchar *uid)
+ const gchar *message_uid)
{
EMailReaderPrivate *priv;
MessageList *message_list;
@@ -2788,7 +2803,7 @@ mail_reader_message_cursor_change_cb (EMailReader *reader)
message_list = MESSAGE_LIST (e_mail_reader_get_message_list (reader));
g_return_if_fail (message_list != NULL);
- if (!message_list->seen_id &&
+ if (message_list->seen_id == 0 &&
E_IS_MAIL_VIEW (reader) &&
e_mail_view_get_preview_visible (E_MAIL_VIEW (reader)))
schedule_timeout_mark_seen (reader);
@@ -2874,13 +2889,14 @@ mail_reader_set_folder (EMailReader *reader,
static void
mail_reader_set_message (EMailReader *reader,
- const gchar *uid)
+ const gchar *message_uid)
{
GtkWidget *message_list;
message_list = e_mail_reader_get_message_list (reader);
- message_list_select_uid (MESSAGE_LIST (message_list), uid, FALSE);
+ message_list_select_uid (
+ MESSAGE_LIST (message_list), message_uid, FALSE);
}
static void
@@ -2893,6 +2909,36 @@ mail_reader_folder_loaded (EMailReader *reader)
}
static void
+mail_reader_message_seen (EMailReader *reader,
+ const gchar *message_uid,
+ CamelMimeMessage *message)
+{
+ EMailBackend *backend;
+ EMFormatHTML *formatter;
+ CamelFolder *folder;
+ guint32 mask, set;
+ guint32 flags;
+
+ folder = e_mail_reader_get_folder (reader);
+ backend = e_mail_reader_get_backend (reader);
+ formatter = e_mail_reader_get_formatter (reader);
+
+ flags = camel_folder_get_message_flags (folder, uid);
+
+ if ((flags & CAMEL_MESSAGE_SEEN) == 0) {
+ CamelMimeMessage *message;
+
+ message = EM_FORMAT (formatter)->message;
+ em_utils_handle_receipt (backend, folder, uid, message);
+ }
+
+ mask = CAMEL_MESSAGE_SEEN;
+ set = CAMEL_MESSAGE_SEEN;
+
+ camel_folder_set_message_flags (folder, message_uid, mask, set);
+}
+
+static void
mail_reader_update_actions (EMailReader *reader,
guint32 state)
{
@@ -3325,6 +3371,7 @@ e_mail_reader_default_init (EMailReaderInterface *interface)
interface->set_message = mail_reader_set_message;
interface->open_selected_mail = e_mail_reader_open_selected;
interface->folder_loaded = mail_reader_folder_loaded;
+ interface->message_seen = mail_reader_message_seen;
interface->update_actions = mail_reader_update_actions;
g_object_interface_install_property (
@@ -3373,6 +3420,17 @@ e_mail_reader_default_init (EMailReaderInterface *interface)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ signals[MESSAGE_SEEN] = g_signal_new (
+ "message-seen",
+ G_OBJECT_CLASS_TYPE (interface),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EMailReaderInterface, message_seen),
+ NULL, NULL,
+ e_marshal_VOID__STRING_OBJECT,
+ G_TYPE_NONE, 2,
+ G_TYPE_STRING,
+ CAMEL_TYPE_MIME_MESSAGE);
+
signals[SHOW_SEARCH_BAR] = g_signal_new (
"show-search-bar",
G_OBJECT_CLASS_TYPE (interface),
@@ -4085,7 +4143,7 @@ e_mail_reader_set_folder (EMailReader *reader,
void
e_mail_reader_set_message (EMailReader *reader,
- const gchar *uid)
+ const gchar *message_uid)
{
EMailReaderInterface *interface;
@@ -4094,7 +4152,7 @@ e_mail_reader_set_message (EMailReader *reader,
interface = E_MAIL_READER_GET_INTERFACE (reader);
g_return_if_fail (interface->set_message != NULL);
- interface->set_message (reader, uid);
+ interface->set_message (reader, message_uid);
}
guint
diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h
index 331837da55..1b1cfaa1bf 100644
--- a/mail/e-mail-reader.h
+++ b/mail/e-mail-reader.h
@@ -106,12 +106,15 @@ struct _EMailReaderInterface {
void (*set_folder) (EMailReader *reader,
CamelFolder *folder);
void (*set_message) (EMailReader *reader,
- const gchar *uid);
+ const gchar *message_uid);
guint (*open_selected_mail) (EMailReader *reader);
gboolean (*enable_show_folder) (EMailReader *reader);
/* Signals */
void (*folder_loaded) (EMailReader *reader);
+ void (*message_seen) (EMailReader *reader,
+ const gchar *message_uid,
+ CamelMimeMessage *message);
void (*show_search_bar) (EMailReader *reader);
void (*update_actions) (EMailReader *reader,
guint32 state);
@@ -145,7 +148,7 @@ CamelFolder * e_mail_reader_get_folder (EMailReader *reader);
void e_mail_reader_set_folder (EMailReader *reader,
CamelFolder *folder);
void e_mail_reader_set_message (EMailReader *reader,
- const gchar *uid);
+ const gchar *message_uid);
EMailForwardStyle
e_mail_reader_get_forward_style (EMailReader *reader);
void e_mail_reader_set_forward_style (EMailReader *reader,