Emit dbus signal on changing SEEN flag.
authorJosé Dapena Paz <jdapena@igalia.com>
Sat, 23 Jan 2010 20:07:14 +0000 (21:07 +0100)
committerJosé Dapena Paz <jdapena@igalia.com>
Tue, 26 Jan 2010 10:19:14 +0000 (11:19 +0100)
src/dbus_api/modest-dbus-callbacks.c
src/gnome/modest-platform.c
src/hildon2/modest-header-window.c
src/hildon2/modest-msg-view-window.c
src/hildon2/modest-platform.c
src/maemo/modest-msg-view-window.c
src/maemo/modest-platform.c
src/modest-platform.h
src/modest-tny-send-queue.c
src/modest-ui-actions.c

index 93a6932..11769ef 100644 (file)
@@ -537,6 +537,7 @@ find_msg_async_cb (TnyFolder *folder,
                                ModestMailOperation *mail_op;
                                
                                 tny_header_set_flag (header, TNY_HEADER_FLAG_SEEN);
+                               modest_platform_emit_msg_read_changed_signal (msg_uid, TRUE);
                                /* Sync folder, we need this to save the seen flag */
                                mail_op = modest_mail_operation_new (NULL);
                                modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
index 8923c7e..c39064d 100644 (file)
@@ -677,3 +677,10 @@ modest_platform_emit_account_removed_signal (const gchar *account_id)
 {
        return;
 }
+
+void
+modest_platform_emit_msg_read_changed_signal (const gchar *msg_uid,
+                                             gboolean is_read)
+{
+       return;
+}
index 6c3d6a4..b44f12e 100644 (file)
@@ -581,7 +581,11 @@ on_mark_read_csm_activated (GtkMenuItem *item,
                                                       priv->x_coord, priv->y_coord);
 
        if (header) {
+               gchar *uid;
                tny_header_set_flag (header, TNY_HEADER_FLAG_SEEN);
+               uid = modest_tny_folder_get_header_unique_id (header);
+               modest_platform_emit_msg_read_changed_signal (uid, TRUE);
+               g_free (uid);
                g_object_unref (header);
        }
 }
@@ -601,7 +605,11 @@ on_mark_unread_csm_activated (GtkMenuItem *item,
                                                       priv->x_coord, priv->y_coord);
 
        if (header) {
+               gchar *uid;
                tny_header_unset_flag (header, TNY_HEADER_FLAG_SEEN);
+               uid = modest_tny_folder_get_header_unique_id (header);
+               modest_platform_emit_msg_read_changed_signal (uid, FALSE);
+               g_free (uid);
                g_object_unref (header);
        }
 }
index 1ad8d2f..f3ff4f0 100644 (file)
@@ -2310,8 +2310,14 @@ view_msg_cb (ModestMailOperation *mail_op,
        }
 
        /* Mark header as read */
-       if (!(tny_header_get_flags (header) & TNY_HEADER_FLAG_SEEN))
+       if (!(tny_header_get_flags (header) & TNY_HEADER_FLAG_SEEN)) {
+               gchar *uid;
+
                tny_header_set_flag (header, TNY_HEADER_FLAG_SEEN);
+               uid = modest_tny_folder_get_header_unique_id (header);
+               modest_platform_emit_msg_read_changed_signal (uid, TRUE);
+               g_free (uid);
+       }
 
        /* Set new message */
        if (priv->msg_view != NULL && TNY_IS_MSG_VIEW (priv->msg_view)) {
index ff3934e..885427b 100644 (file)
@@ -3208,3 +3208,14 @@ modest_platform_emit_account_removed_signal (const gchar *account_id)
 
        modest_dbus_emit_account_removed_signal (con, account_id);
 }
+void
+modest_platform_emit_msg_read_changed_signal (const gchar *msg_uid,
+                                             gboolean is_read)
+{
+       DBusConnection *con;
+
+       con = modest_platform_get_dbus_connection ();
+       if (!con) return;
+
+       modest_dbus_emit_msg_read_changed_signal (con, msg_uid, is_read);
+}
index 54f69fc..a5fc2d6 100644 (file)
@@ -2192,8 +2192,14 @@ view_msg_cb (ModestMailOperation *mail_op,
        }
 
        /* Mark header as read */
-       if (!(tny_header_get_flags (header) & TNY_HEADER_FLAG_SEEN))
+       if (!(tny_header_get_flags (header) & TNY_HEADER_FLAG_SEEN)) {
+               gchar *uid;
+
                tny_header_set_flag (header, TNY_HEADER_FLAG_SEEN);
+               uid = modest_tny_folder_get_header_unique_id (header);
+               modest_platform_emit_msg_read_changed_signal (uid, TRUE);
+               g_free (uid);
+       }
 
        /* Set new message */
        if (priv->msg_view != NULL && TNY_IS_MSG_VIEW (priv->msg_view)) {
index 52f7206..ca67fa5 100644 (file)
@@ -2302,3 +2302,15 @@ modest_platform_emit_account_removed_signal (const gchar *account_id)
 
        modest_dbus_emit_account_removed_signal (con, account_id);
 }
+
+void
+modest_platform_emit_msg_read_changed_signal (const gchar *msg_uid,
+                                             gboolean is_read)
+{
+       DBusConnection *con;
+
+       con = modest_platform_get_dbus_connection ();
+       if (!con) return;
+
+       modest_dbus_emit_msg_read_changed_signal (con, msg_uid, is_read);
+}
index b029780..4fab91f 100644 (file)
@@ -567,6 +567,7 @@ DBusConnection* modest_platform_get_dbus_connection (void);
 void modest_platform_emit_folder_updated_signal (const gchar *account_id, const gchar *folder_id);
 void modest_platform_emit_account_created_signal (const gchar *account_id);
 void modest_platform_emit_account_removed_signal (const gchar *account_id);
+void modest_platform_emit_msg_read_changed_signal (const gchar *msg_uid, gboolean is_read);
 
 G_END_DECLS
 
index 9e9586b..b3bd3b1 100644 (file)
@@ -679,6 +679,8 @@ _on_msg_has_been_sent (TnySendQueue *self,
 
        tny_header_set_flag (header, TNY_HEADER_FLAG_SEEN);
 
+       modest_platform_emit_msg_read_changed_signal (msg_id, TRUE);
+
        tny_folder_sync_async (priv->sentbox, FALSE, NULL, NULL, NULL);
 
        /* Get status info */
index 523d260..3b2ab68 100644 (file)
@@ -398,12 +398,16 @@ headers_action_mark_as_read (TnyHeader *header,
                             gpointer user_data)
 {
        TnyHeaderFlags flags;
+       gchar *uid;
 
        g_return_if_fail (TNY_IS_HEADER(header));
 
        flags = tny_header_get_flags (header);
        if (flags & TNY_HEADER_FLAG_SEEN) return;
        tny_header_set_flag (header, TNY_HEADER_FLAG_SEEN);
+       uid = modest_tny_folder_get_header_unique_id (header);
+       modest_platform_emit_msg_read_changed_signal (uid, TRUE);
+       g_free (uid);
 }
 
 static void
@@ -417,7 +421,10 @@ headers_action_mark_as_unread (TnyHeader *header,
 
        flags = tny_header_get_flags (header);
        if (flags & TNY_HEADER_FLAG_SEEN)  {
+               gchar *uid;
+               uid = modest_tny_folder_get_header_unique_id (header);
                tny_header_unset_flag (header, TNY_HEADER_FLAG_SEEN);
+               modest_platform_emit_msg_read_changed_signal (uid, FALSE);
        }
 }