diff options
author | Srinivasa Ragavan <sragavan@src.gnome.org> | 2007-05-03 15:45:12 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@src.gnome.org> | 2007-05-03 15:45:12 +0800 |
commit | c12711e656c8658402a084e2d0099c702ea1064d (patch) | |
tree | 7e64e6704817b060c71e44f915669fcc7dc775fb /mail | |
parent | 2cbfce7757da1bf0ead6af738c425796f37a6293 (diff) | |
download | gsoc2013-evolution-c12711e656c8658402a084e2d0099c702ea1064d.tar.gz gsoc2013-evolution-c12711e656c8658402a084e2d0099c702ea1064d.tar.zst gsoc2013-evolution-c12711e656c8658402a084e2d0099c702ea1064d.zip |
Improvements to the new mail hook.
svn path=/trunk/; revision=33470
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 11 | ||||
-rw-r--r-- | mail/em-event.c | 4 | ||||
-rw-r--r-- | mail/em-event.h | 2 | ||||
-rw-r--r-- | mail/em-folder-tree-model.c | 41 | ||||
-rw-r--r-- | mail/em-folder-tree-model.h | 1 | ||||
-rw-r--r-- | mail/mail-folder-cache.c | 9 |
6 files changed, 63 insertions, 5 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 833daa6384..9123609abc 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,14 @@ +2007-05-03 Srinivasa Ragavan <sragavan@novell.com> + + ** Added code to improve the new mail hook to provide the number of + new mails received and if the folder is an INBOX. + + * em-event.c: (em_event_target_new_folder): + * em-event.h: + * em-folder-tree-model.c: (em_folder_tree_model_is_type_inbox): + * em-folder-tree-model.h: + * mail-folder-cache.c: (real_flush_updates), (update_1folder): + 2007-04-20 Matthew Barnes <mbarnes@redhat.com> ** Fixes part of bug #426812 diff --git a/mail/em-event.c b/mail/em-event.c index 0fae713277..2e7673a62c 100644 --- a/mail/em-event.c +++ b/mail/em-event.c @@ -136,12 +136,14 @@ EMEvent *em_event_peek(void) } EMEventTargetFolder * -em_event_target_new_folder (EMEvent *eme, const char *uri, guint32 flags) +em_event_target_new_folder (EMEvent *eme, const char *uri, unsigned int new) { EMEventTargetFolder *t = e_event_target_new(&eme->popup, EM_EVENT_TARGET_FOLDER, sizeof(*t)); + guint32 flags = new ? EM_EVENT_FOLDER_NEWMAIL : 0; t->uri = g_strdup(uri); t->target.mask = ~flags; + t->new = new; return t; } diff --git a/mail/em-event.h b/mail/em-event.h index 34ad09b6fd..90bb23dca4 100644 --- a/mail/em-event.h +++ b/mail/em-event.h @@ -66,6 +66,8 @@ typedef struct _EMEventTargetFolder EMEventTargetFolder; struct _EMEventTargetFolder { EEventTarget target; char *uri; + guint new; + gboolean is_inbox; }; typedef struct _EMEventTargetMessage EMEventTargetMessage; diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index aced299122..45dd17a7e1 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -1108,6 +1108,47 @@ em_folder_tree_model_expand_foreach (EMFolderTreeModel *model, EMFTModelExpandFu expand_foreach_r (model, root, NULL, func, user_data); } +gboolean +em_folder_tree_model_is_type_inbox (EMFolderTreeModel *model, CamelStore *store, const char *full) +{ + struct _EMFolderTreeModelStoreInfo *si; + GtkTreeRowReference *row; + GtkTreePath *tree_path; + GtkTreeIter iter; + guint32 flags; + + g_return_if_fail (EM_IS_FOLDER_TREE_MODEL (model)); + g_return_if_fail (CAMEL_IS_STORE (store)); + g_return_if_fail (full != NULL); + + u(printf("Checking if the folder is an INBOX type %p '%s' %d\n", store, full, unread)); + + if (!(si = g_hash_table_lookup (model->store_hash, store))) { + u(printf(" can't find store\n")); + return; + } + + if (!(row = g_hash_table_lookup (si->full_hash, full))) { + u(printf(" can't find row\n")); + return; + } + + tree_path = gtk_tree_row_reference_get_path (row); + if (!gtk_tree_model_get_iter ((GtkTreeModel *) model, &iter, tree_path)) { + gtk_tree_path_free (tree_path); + return; + } + + gtk_tree_path_free (tree_path); + + gtk_tree_model_get (model, &iter, COL_UINT_FLAGS, &flags, -1); + + if ((flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_INBOX) + return TRUE; + + return FALSE; +} + void em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *store, const char *full, int unread) { diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h index 1938e84095..bcdf6b4331 100644 --- a/mail/em-folder-tree-model.h +++ b/mail/em-folder-tree-model.h @@ -143,6 +143,7 @@ typedef void (* EMFTModelExpandFunc) (EMFolderTreeModel *model, const char *path void em_folder_tree_model_expand_foreach (EMFolderTreeModel *model, EMFTModelExpandFunc func, void *user_data); void em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *store, const char *path, int unread); +gboolean em_folder_tree_model_is_type_inbox (EMFolderTreeModel *model, CamelStore *store, const char *full); #ifdef __cplusplus } diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 4b83b960b2..67d2858205 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -95,7 +95,7 @@ struct _folder_update { unsigned int delete:1; /* deleting as well? */ unsigned int add:1; /* add to vfolder */ unsigned int unsub:1; /* unsubcribing? */ - unsigned int new:1; /* new mail arrived? */ + unsigned int new; /* new mail arrived? */ char *full_name; char *uri; @@ -230,7 +230,6 @@ real_flush_updates(void *o, void *event_data, void *data) /* update unread counts */ em_folder_tree_model_set_unread_count (model, up->store, up->full_name, up->unread); - /* new mail notification */ if (notify_type == -1) { /* need to track the user's new-mail-notification settings... */ @@ -250,13 +249,15 @@ real_flush_updates(void *o, void *event_data, void *data) if (up->uri) { EMEvent *e = em_event_peek(); - EMEventTargetFolder *t = em_event_target_new_folder(e, up->uri, up->new?EM_EVENT_FOLDER_NEWMAIL:0); + EMEventTargetFolder *t = em_event_target_new_folder(e, up->uri, up->new); + t->is_inbox = em_folder_tree_model_is_type_inbox (model, up->store, up->full_name); /** @Event: folder.changed * @Title: Folder changed * @Target: EMEventTargetFolder * * folder.changed is emitted whenever a folder changes. There is no detail on how the folder has changed. + * UPDATE: We tell the number of new UIDs added rather than the new mails received */ e_event_emit((EEvent *)e, "folder.changed", (EEventTarget *)t); } @@ -377,7 +378,7 @@ update_1folder(struct _folder_info *mfi, int new, CamelFolderInfo *info) up = g_malloc0(sizeof(*up)); up->full_name = g_strdup(mfi->full_name); up->unread = unread; - up->new = new ? 1 : 0; + up->new = new; up->store = mfi->store_info->store; up->uri = g_strdup(mfi->uri); camel_object_ref(up->store); |