static gboolean vee_info_set_user_flag (CamelMessageInfo *mi, const gchar *name, gboolean value) { gint res = FALSE; CamelVeeFolder *vf = (CamelVeeFolder *) camel_folder_summary_get_folder (mi->summary); if (camel_debug("vfolderexp")) printf ( "Expression for vfolder '%s' is '%s'\n", camel_folder_get_full_name (camel_folder_summary_get_folder (mi->summary)), g_strescape (vf->expression, "")); if (mi->uid) { CamelMessageInfo *rmi = camel_folder_summary_get (((CamelVeeMessageInfo *) mi)->orig_summary, mi->uid + 8); HANDLE_NULL_INFO (FALSE); /* ignore changes done in the folder itself, * unless it's a vTrash or vJunk folder */ if (!CAMEL_IS_VTRASH_FOLDER (vf)) camel_vee_folder_ignore_next_changed_event (vf, camel_folder_summary_get_folder (rmi->summary)); res = camel_message_info_set_user_flag (rmi, name, value); camel_message_info_free (rmi); } return res; }
static gboolean vee_info_set_flags (CamelMessageInfo *mi, guint32 flags, guint32 set) { gint res = FALSE; CamelVeeFolder *vf = CAMEL_VEE_FOLDER (camel_folder_summary_get_folder (mi->summary)); if (camel_debug("vfolderexp")) printf ( "Expression for vfolder '%s' is '%s'\n", camel_folder_get_full_name (CAMEL_FOLDER (vf)), g_strescape (vf->expression, "")); /* first update original message info... */ if (mi->uid) { CamelMessageInfo *rmi = camel_folder_summary_get (((CamelVeeMessageInfo *) mi)->orig_summary, mi->uid + 8); HANDLE_NULL_INFO (FALSE); /* ignore changes done in the folder itself, * unless it's a vTrash or vJunk folder */ if (!CAMEL_IS_VTRASH_FOLDER (vf)) camel_vee_folder_ignore_next_changed_event (vf, camel_folder_summary_get_folder (rmi->summary)); camel_folder_freeze (camel_folder_summary_get_folder (rmi->summary)); res = camel_message_info_set_flags (rmi, flags, set); ((CamelVeeMessageInfo *) mi)->old_flags = camel_message_info_flags (rmi); camel_folder_thaw (camel_folder_summary_get_folder (rmi->summary)); camel_message_info_free (rmi); } if (res) CAMEL_FOLDER_SUMMARY_CLASS (camel_vee_summary_parent_class)->info_set_flags (mi, flags, set); return res; }
static gboolean vee_info_set_user_tag (CamelMessageInfo *mi, const gchar *name, const gchar *value) { gint res = FALSE; if (mi->uid) { CamelMessageInfo *rmi = camel_folder_summary_get (((CamelVeeMessageInfo *) mi)->orig_summary, mi->uid + 8); CamelFolder *folder = camel_folder_summary_get_folder (mi->summary); HANDLE_NULL_INFO (FALSE); /* ignore changes done in the folder itself, * unless it's a vTrash or vJunk folder */ if (!CAMEL_IS_VTRASH_FOLDER (folder)) camel_vee_folder_ignore_next_changed_event ((CamelVeeFolder *) folder, camel_folder_summary_get_folder (rmi->summary)); res = camel_message_info_set_user_tag (rmi, name, value); camel_message_info_free (rmi); } return res; }
void e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view) { EMailShellContent *mail_shell_content; EShellBackend *shell_backend; EShellSidebar *shell_sidebar; EShellView *shell_view; EShell *shell; EMailReader *reader; EMailView *mail_view; ESourceRegistry *registry; CamelStore *parent_store; CamelFolder *folder; CamelFolderInfoFlags flags = 0; CamelFolderSummary *folder_summary; MailFolderCache *folder_cache; MessageList *message_list; guint selected_count; GString *buffer, *title_short = NULL; gboolean store_is_local, is_inbox; const gchar *display_name; const gchar *folder_name; const gchar *uid; gchar *title; guint32 num_deleted; guint32 num_junked; guint32 num_junked_not_deleted; guint32 num_unread; guint32 num_visible; g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view)); mail_shell_content = mail_shell_view->priv->mail_shell_content; mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); shell_view = E_SHELL_VIEW (mail_shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); shell = e_shell_backend_get_shell (shell_backend); registry = e_shell_get_registry (shell); reader = E_MAIL_READER (mail_view); folder = e_mail_reader_ref_folder (reader); /* If no folder is selected, reset the sidebar banners * to their default values and stop. */ if (folder == NULL) { GtkAction *action; gchar *label; action = e_shell_view_get_action (shell_view); g_object_get (action, "label", &label, NULL); e_shell_sidebar_set_secondary_text (shell_sidebar, NULL); e_shell_view_set_title (shell_view, label); g_free (label); return; } folder_name = camel_folder_get_display_name (folder); parent_store = camel_folder_get_parent_store (folder); folder_summary = camel_folder_get_folder_summary (folder); folder_cache = e_mail_session_get_folder_cache ( e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend))); mail_folder_cache_get_folder_info_flags (folder_cache, parent_store, folder_name, &flags); is_inbox = (flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_INBOX; num_deleted = camel_folder_summary_get_deleted_count (folder_summary); num_junked = camel_folder_summary_get_junk_count (folder_summary); num_junked_not_deleted = camel_folder_summary_get_junk_not_deleted_count (folder_summary); num_unread = camel_folder_summary_get_unread_count (folder_summary); num_visible = camel_folder_summary_get_visible_count (folder_summary); buffer = g_string_sized_new (256); message_list = MESSAGE_LIST (e_mail_reader_get_message_list (reader)); selected_count = message_list_selected_count (message_list); if (selected_count > 1) g_string_append_printf ( buffer, ngettext ("%d selected, ", "%d selected, ", selected_count), selected_count); /* "Trash" folder (virtual or real) */ if (camel_folder_get_flags (folder) & CAMEL_FOLDER_IS_TRASH) { if (CAMEL_IS_VTRASH_FOLDER (folder)) { /* For a virtual Trash folder, count * the messages marked for deletion. */ g_string_append_printf ( buffer, ngettext ("%d deleted", "%d deleted", num_deleted), num_deleted); } else { /* For a regular Trash folder, just * count the visible messages. * * XXX Open question: what to do about messages * marked for deletion in Trash? Probably * this is the wrong question to be asking * anyway. Deleting a message in a real * Trash should permanently expunge the * message (if the server supports that), * which would eliminate this corner case. */ if (!e_mail_reader_get_hide_deleted (reader)) num_visible += num_deleted; g_string_append_printf ( buffer, ngettext ("%d deleted", "%d deleted", num_visible), num_visible); } /* "Junk" folder (virtual or real) */ } else if (camel_folder_get_flags (folder) & CAMEL_FOLDER_IS_JUNK) { if (e_mail_reader_get_hide_deleted (reader)) { /* Junk folder with deleted messages hidden. */ g_string_append_printf ( buffer, ngettext ("%d junk", "%d junk", num_junked_not_deleted), num_junked_not_deleted); } else { /* Junk folder with deleted messages visible. */ g_string_append_printf ( buffer, ngettext ("%d junk", "%d junk", num_junked), num_junked); } /* "Drafts" folder */ } else if (!is_inbox && em_utils_folder_is_drafts (registry, folder)) { g_string_append_printf ( buffer, ngettext ("%d draft", "%d drafts", num_visible), num_visible); /* "Outbox" folder */ } else if (!is_inbox && em_utils_folder_is_outbox (registry, folder)) { g_string_append_printf ( buffer, ngettext ("%d unsent", "%d unsent", num_visible), num_visible); /* "Sent" folder */ } else if (!is_inbox && em_utils_folder_is_sent (registry, folder)) { g_string_append_printf ( buffer, ngettext ("%d sent", "%d sent", num_visible), num_visible); /* Normal folder */ } else { if (!e_mail_reader_get_hide_deleted (reader)) num_visible += num_deleted - num_junked + num_junked_not_deleted; if (num_unread > 0 && selected_count <= 1) { g_string_append_printf ( buffer, ngettext ("%d unread, ", "%d unread, ", num_unread), num_unread); title_short = g_string_sized_new (64); g_string_append_printf ( title_short, ngettext ("%d unread", "%d unread", num_unread), num_unread); } g_string_append_printf ( buffer, ngettext ("%d total", "%d total", num_visible), num_visible); } uid = camel_service_get_uid (CAMEL_SERVICE (parent_store)); store_is_local = (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0); /* Choose a suitable folder name for displaying. */ display_name = folder_name; if (store_is_local) { if (strcmp (folder_name, "Drafts") == 0) display_name = _("Drafts"); else if (strcmp (folder_name, "Inbox") == 0) display_name = _("Inbox"); else if (strcmp (folder_name, "Outbox") == 0) display_name = _("Outbox"); else if (strcmp (folder_name, "Sent") == 0) display_name = _("Sent"); else if (strcmp (folder_name, "Templates") == 0) display_name = _("Templates"); else if (strcmp (folder_name, "Trash") == 0) display_name = _("Trash"); } if (strcmp (folder_name, "INBOX") == 0) display_name = _("Inbox"); if (title_short && title_short->len > 0) title = g_strdup_printf ("%s (%s)", display_name, title_short->str); else title = g_strdup (display_name); e_shell_sidebar_set_secondary_text (shell_sidebar, buffer->str); e_shell_view_set_title (shell_view, title); g_free (title); g_string_free (buffer, TRUE); if (title_short) g_string_free (title_short, TRUE); g_clear_object (&folder); }
static void view_changed(EMFolderView *emfv, EComponentView *component_view) { EInfoLabel *el = g_object_get_data((GObject *)component_view, "info-label"); CORBA_Environment ev; CORBA_exception_init(&ev); if (emfv->folder) { char *name, *title; const char *use_name; /* will contain localized name, if necessary */ guint32 visible, unread, deleted, junked, junked_not_deleted; GPtrArray *selected; GString *tmp = g_string_new(""); camel_object_get(emfv->folder, NULL, CAMEL_FOLDER_NAME, &name, CAMEL_FOLDER_DELETED, &deleted, CAMEL_FOLDER_VISIBLE, &visible, CAMEL_FOLDER_JUNKED, &junked, CAMEL_FOLDER_JUNKED_NOT_DELETED, &junked_not_deleted, CAMEL_FOLDER_UNREAD, &unread, NULL); selected = message_list_get_selected(emfv->list); /* This is so that if any of these are * shared/reused, we fallback to the standard * display behaviour */ if (selected->len > 1) g_string_append_printf(tmp, ngettext ("%d selected, ", "%d selected, ", selected->len), selected->len); if (CAMEL_IS_VTRASH_FOLDER(emfv->folder)) { if (((CamelVTrashFolder *)emfv->folder)->type == CAMEL_VTRASH_FOLDER_TRASH) { g_string_append_printf(tmp, ngettext ("%d deleted", "%d deleted", deleted), deleted); } else { guint32 num = junked_not_deleted; if (!emfv->hide_deleted) num = junked; g_string_append_printf (tmp, ngettext ("%d junk", "%d junk", num), num); } } else if (em_utils_folder_is_drafts(emfv->folder, emfv->folder_uri)) { g_string_append_printf(tmp, ngettext ("%d draft", "%d drafts", visible), visible); } else if (em_utils_folder_is_sent(emfv->folder, emfv->folder_uri)) { g_string_append_printf(tmp, ngettext ("%d sent", "%d sent", visible), visible); } else if (em_utils_folder_is_outbox(emfv->folder, emfv->folder_uri)) { g_string_append_printf(tmp, ngettext ("%d unsent", "%d unsent", visible), visible); /* HACK: hardcoded inbox or maildir '.' folder */ } else { if (!emfv->hide_deleted) visible += deleted - junked + junked_not_deleted; if (unread && selected->len <= 1) g_string_append_printf(tmp, ngettext ("%d unread, ", "%d unread, ", unread), unread); g_string_append_printf(tmp, ngettext ("%d total", "%d total", visible), visible); } message_list_free_uids(emfv->list, selected); if (emfv->folder->parent_store == mail_component_peek_local_store(NULL) && (!strcmp (name, "Drafts") || !strcmp (name, "Inbox") || !strcmp (name, "Outbox") || !strcmp (name, "Sent"))) use_name = _(name); else use_name = name; e_info_label_set_info (el, use_name, tmp->str); title = g_strdup_printf ("%s (%s)", use_name, tmp->str); e_component_view_set_title(component_view, title); g_free(title); g_string_free(tmp, TRUE); camel_object_free(emfv->folder, CAMEL_FOLDER_NAME, name); } else { e_info_label_set_info(el, _("Mail"), ""); e_component_view_set_title(component_view, _("Mail")); } }