static gboolean _selected_folder_not_deletable (ModestMainWindow *win);
static gboolean _selected_folder_is_any_of_type (ModestWindow *win, TnyFolderType types[], guint ntypes);
static gboolean _selected_folder_is_root_or_inbox (ModestMainWindow *win);
-static gboolean _selected_folder_is_MMC_or_POP_root (ModestMainWindow *win);
static gboolean _selected_folder_is_root (ModestMainWindow *win);
static gboolean _header_view_is_all_selected (ModestMainWindow *win);
static gboolean _selected_folder_is_empty (ModestMainWindow *win);
static gboolean _msg_download_in_progress (ModestWindow *win);
static gboolean _msg_download_completed (ModestMainWindow *win);
static gboolean _selected_msg_sent_in_progress (ModestWindow *win);
-static gboolean _sending_in_progress (ModestWindow *win);
static gboolean _invalid_folder_for_purge (ModestWindow *win, ModestDimmingRule *rule);
static gboolean _transfer_mode_enabled (ModestWindow *win);
static gboolean _selected_folder_has_subfolder_with_same_name (ModestWindow *win);
if (modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (parent_folder))) {
dimmed = FALSE;
} else {
- const gchar *proto_str = tny_account_get_proto (TNY_ACCOUNT (parent_folder));
- if (proto_str != NULL) {
- /* If it's POP then dim */
- dimmed = (modest_protocol_info_get_transport_store_protocol (proto_str) ==
- MODEST_PROTOCOL_STORE_POP) ? TRUE : FALSE;
+ ModestProtocolType protocol_type = modest_tny_account_get_protocol_type (TNY_ACCOUNT (parent_folder));
+ if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
+ ModestProtocolRegistry *protocol_registry;
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ /* If account does not support folders (pop) then dim */
+ dimmed = (!modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type,
+ MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS));
if (dimmed)
modest_dimming_rule_set_notification (rule, _("mail_in_ui_folder_create_error"));
}
modest_dimming_rule_set_notification (rule, _("mail_in_ui_folder_delete_error"));
}
if (!dimmed) {
- dimmed = _selected_folder_is_MMC_or_POP_root (MODEST_MAIN_WINDOW(win));
- if (dimmed)
- modest_dimming_rule_set_notification (rule, _("mail_in_ui_folder_delete_error"));
- }
- if (!dimmed) {
dimmed = _transfer_mode_enabled (win);
if (dimmed)
modest_dimming_rule_set_notification (rule, _CS("ckct_ib_unable_to_delete"));
return dimmed;
}
+static gboolean
+_message_already_sent (ModestMsgViewWindow *view_window)
+{
+ TnyHeader *header;
+ TnyFolder *folder;
+ gboolean already_sent = FALSE;
+
+ header = modest_msg_view_window_get_header (view_window);
+ if (header) {
+ folder = tny_header_get_folder (header);
+ if (folder) {
+ if (modest_tny_folder_guess_folder_type (folder) ==
+ TNY_FOLDER_TYPE_OUTBOX) {
+ ModestTnySendQueueStatus status =
+ modest_tny_all_send_queues_get_msg_status (header);
+ if (status == MODEST_TNY_SEND_QUEUE_UNKNOWN ||
+ status == MODEST_TNY_SEND_QUEUE_SENDING)
+ already_sent = TRUE;
+ }
+ g_object_unref (folder);
+ }
+ g_object_unref (header);
+ }
+ return already_sent;
+}
+
+
gboolean
modest_ui_dimming_rules_on_delete_msg (ModestWindow *win, gpointer user_data)
{
/* This could happen if we're viewing a message of the
outbox that has been already sent */
- if (!dimmed) {
- ModestMsgViewWindow *view_window = MODEST_MSG_VIEW_WINDOW (win);
- if (modest_msg_view_window_last_message_selected (view_window) &&
- modest_msg_view_window_first_message_selected (view_window))
- dimmed = TRUE;
- }
+ if (!dimmed)
+ dimmed = _message_already_sent (MODEST_MSG_VIEW_WINDOW(win));
/* The delete button should be dimmed when viewing an attachment,
* but should be enabled when viewing a message from the list,
modest_dimming_rule_set_notification (rule, "");
}
+ } else {
+ return TRUE;
}
-
}
/* msg view window dimming rules */
/* This could happen if we're viewing a message of the outbox
that has been already sent */
- if (!dimmed) {
- ModestMsgViewWindow *view_window = MODEST_MSG_VIEW_WINDOW (win);
- if (modest_msg_view_window_last_message_selected (view_window) &&
- modest_msg_view_window_first_message_selected (view_window))
- dimmed = TRUE;
- }
+ if (!dimmed)
+ dimmed = _message_already_sent (MODEST_MSG_VIEW_WINDOW(win));
if (!dimmed) {
if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
modest_dimming_rule_set_notification (rule, "");
}
if (!dimmed) {
- dimmed = !_sending_in_progress (win);
- if (dimmed)
- modest_dimming_rule_set_notification (rule, "");
- }
-
- return dimmed;
-}
-
-gboolean
-modest_ui_dimming_rules_on_csm_cancel_sending (ModestWindow *win, gpointer user_data)
-{
- ModestDimmingRule *rule = NULL;
- TnyFolderType types[1];
- const DimmedState *state = NULL;
- gboolean dimmed = FALSE;
-
- g_return_val_if_fail (MODEST_IS_MAIN_WINDOW(win), FALSE);
- g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
- rule = MODEST_DIMMING_RULE (user_data);
- state = modest_window_get_dimming_state (win);
-
- types[0] = TNY_FOLDER_TYPE_OUTBOX;
-
- /* Check dimmed rules */
- if (!dimmed) {
- dimmed = !_selected_folder_is_any_of_type (win, types, 1);
- if (dimmed)
- modest_dimming_rule_set_notification (rule, "");
- }
- if (!dimmed) {
- dimmed = !_sending_in_progress (win);
+ dimmed = !state->sent_in_progress;
if (dimmed)
modest_dimming_rule_set_notification (rule, "");
}
} else if (MODEST_IS_ATTACHMENTS_VIEW (focused)) {
do_check = FALSE;
}
- g_warning ("FOCUSED %s", focused?G_OBJECT_TYPE_NAME (focused):"NULL");
if (do_check) {
clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
selection = gtk_clipboard_wait_for_text (clipboard);
/* Check pop and MMC accounts */
if (!result) {
- result = _selected_folder_is_MMC_or_POP_root (win);
+ result = _selected_folder_is_root (win);
}
return result;
modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
if (folder_store) {
is_account = TNY_IS_ACCOUNT (folder_store);
+
g_object_unref (folder_store);
folder_store = NULL;
}
/* Check folder type */
result = _selected_folder_is_any_of_type (MODEST_WINDOW(win), types, 1);
- /* Check pop and MMC accounts */
- if (!result) {
- result = _selected_folder_is_MMC_or_POP_root (win);
- }
-
- return result;
-}
-
-static gboolean
-_selected_folder_is_MMC_or_POP_root (ModestMainWindow *win)
-{
- GtkWidget *folder_view = NULL;
- TnyFolderStore *parent_folder = NULL;
- gboolean result = FALSE;
-
- folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(win),
- MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
- if (!folder_view)
- return FALSE;
-
- /* Get selected folder as parent of new folder to create */
- parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
- if (!parent_folder)
- return TRUE;
-
- if (TNY_IS_ACCOUNT (parent_folder)) {
- /* If it's the local account then do not dim */
- if (modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (parent_folder))) {
- result = FALSE;
- } else {
- /* If it's the MMC root folder then dim it */
- if (!strcmp (tny_account_get_id (TNY_ACCOUNT (parent_folder)), MODEST_MMC_ACCOUNT_ID)) {
- result = TRUE;
- } else {
- const gchar *proto_str = tny_account_get_proto (TNY_ACCOUNT (parent_folder));
- /* If it's POP then dim */
- result = (modest_protocol_info_get_transport_store_protocol (proto_str) ==
- MODEST_PROTOCOL_STORE_POP) ? TRUE : FALSE;
- }
- }
- }
- g_object_unref (parent_folder);
-
return result;
}
static gboolean
-_sending_in_progress (ModestWindow *win)
-{
- GHashTable *send_queue_cache = NULL;
- ModestCacheMgr *cache_mgr = NULL;
- ModestTnySendQueue *send_queue = NULL;
- GSList *send_queues = NULL, *node = NULL;
- gboolean result = FALSE;
-
- g_return_val_if_fail (MODEST_IS_MAIN_WINDOW (win), FALSE);
-
- /* Get send queue */
- cache_mgr = modest_runtime_get_cache_mgr ();
- send_queue_cache = modest_cache_mgr_get_cache (cache_mgr,
- MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE);
-
- g_hash_table_foreach (send_queue_cache, (GHFunc) fill_list_of_caches, &send_queues);
-
- for (node = send_queues; node != NULL && !result; node = g_slist_next (node)) {
- send_queue = MODEST_TNY_SEND_QUEUE (node->data);
-
- /* Check if send operation is in progress */
- result = modest_tny_send_queue_sending_in_progress (send_queue);
- }
-
- return result;
-}
-
-static gboolean
_invalid_folder_for_purge (ModestWindow *win,
ModestDimmingRule *rule)
{
result = TRUE;
}
} else {
- const gchar *proto_str = tny_account_get_proto (TNY_ACCOUNT (account));
- ModestTransportStoreProtocol proto;
- proto = modest_protocol_info_get_transport_store_protocol (proto_str);
+ ModestProtocolType protocol_type = modest_tny_account_get_protocol_type (TNY_ACCOUNT (account));
/* If it's a remote folder then dim */
- if (proto == MODEST_PROTOCOL_STORE_POP || proto == MODEST_PROTOCOL_STORE_IMAP) {
+ if (modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
+ protocol_type,
+ MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS)) {
result = TRUE;
}
}