#include <string.h>
#include "modest-ui-dimming-rules.h"
#include "modest-ui-actions.h"
+#include "modest-account-mgr-helpers.h"
#include "modest-dimming-rule.h"
#include "modest-debug.h"
#include "modest-tny-folder.h"
#include <widgets/modest-attachments-view.h>
#include <modest-runtime.h>
#include <tny-simple-list.h>
+#include <tny-merge-folder.h>
#include <widgets/modest-recpt-editor.h>
#include <gtkhtml/gtkhtml.h>
#include <modest-runtime.h>
static void fill_list_of_caches (gpointer key, gpointer value, gpointer userdata);
static gboolean _send_receive_in_progress (ModestWindow *win);
static gboolean _msgs_send_in_progress (void);
-static gboolean _all_msgs_in_sending_status (ModestHeaderView *header_view);
+static gboolean _all_msgs_in_sending_status (ModestHeaderView *header_view) G_GNUC_UNUSED;
+static gboolean _forbid_outgoing_xfers (ModestWindow *window);
static DimmedState *
_define_main_window_dimming_state (ModestMainWindow *window)
header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (win)));
folder = modest_header_view_get_folder (MODEST_HEADER_VIEW (header_view));
if (folder) {
- dimmed = (tny_folder_get_all_count (TNY_FOLDER (folder)) == 0);
+ dimmed = (tny_folder_get_all_count (TNY_FOLDER (folder)) == 0) ||
+ modest_header_view_is_empty (MODEST_HEADER_VIEW (header_view));
if (!dimmed &&
(tny_folder_get_folder_type (TNY_FOLDER (folder)) == TNY_FOLDER_TYPE_OUTBOX)) {
if (dimmed)
modest_dimming_rule_set_notification (rule, "");
}
- if (!dimmed) {
- dimmed = _transfer_mode_enabled (win);
- if (dimmed)
- modest_dimming_rule_set_notification (rule, "");
- }
return dimmed;
}
if (MODEST_IS_MSG_VIEW_WINDOW (win))
dimmed = _msg_download_in_progress (win);
if (dimmed)
- modest_dimming_rule_set_notification (rule, "");
- if (!dimmed && MODEST_IS_MSG_VIEW_WINDOW (win)) {
- if (!modest_msg_view_window_is_search_result (MODEST_MSG_VIEW_WINDOW(win))) {
- dimmed = !modest_msg_view_window_has_headers_model (MODEST_MSG_VIEW_WINDOW (win));
- }
- if (dimmed)
- modest_dimming_rule_set_notification (rule, "");
- }
+ modest_dimming_rule_set_notification (rule, "");
}
return dimmed;
}
+gboolean
+modest_ui_dimming_rules_on_fetch_images (ModestWindow *win, gpointer user_data)
+{
+ gboolean dimmed = FALSE;
+
+ g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (win), FALSE);
+
+ dimmed = !modest_msg_view_window_has_blocked_external_images (MODEST_MSG_VIEW_WINDOW (win));
+
+ return dimmed;
+}
+
gboolean
modest_ui_dimming_rules_on_mark_as_read_msg_in_view (ModestWindow *win, gpointer user_data)
folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(win),
MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-
+ if (folder_view) {
+ TnyFolderStore *selected = modest_folder_view_get_selected ((ModestFolderView *)folder_view);
+ if (selected) {
+ TnyAccount *account = NULL;
+
+ if (TNY_IS_ACCOUNT (selected)) {
+ account = g_object_ref (selected);
+ } else if (!TNY_IS_MERGE_FOLDER (selected)){
+ account = tny_folder_get_account (TNY_FOLDER (selected));
+ }
+ if (account) {
+ ModestProtocolType protocol_type;
+
+ protocol_type = modest_tny_account_get_protocol_type (account);
+ dimmed = modest_protocol_registry_protocol_type_has_tag
+ (modest_runtime_get_protocol_registry (),
+ protocol_type,
+ MODEST_PROTOCOL_REGISTRY_STORE_FORBID_OUTGOING_XFERS);
+
+ g_object_unref (account);
+ }
+ g_object_unref (selected);
+ }
+ }
+
/* Check diming rules for folders transfer */
- if (folder_view && gtk_widget_is_focus (folder_view)) {
+ if (!dimmed && folder_view && gtk_widget_is_focus (folder_view)) {
TnyFolderType types[5];
-
+
types[0] = TNY_FOLDER_TYPE_DRAFTS;
types[1] = TNY_FOLDER_TYPE_OUTBOX;
types[2] = TNY_FOLDER_TYPE_SENT;
if (!dimmed) {
if (!(folder_view && gtk_widget_is_focus (folder_view)))
dimmed = _invalid_msg_selected (MODEST_MAIN_WINDOW(win), FALSE, user_data);
-
+
}
if (!dimmed) {
dimmed = _selected_msg_sent_in_progress (win);
if (dimmed)
modest_dimming_rule_set_notification (rule, _("sfil_ib_unable_to_move_selected_items"));
}
-
+
+ return dimmed;
+}
+
+static gboolean
+_forbid_outgoing_xfers (ModestWindow *window)
+{
+ const gchar *account_name;
+ TnyAccount *account;
+ gboolean dimmed = FALSE;
+
+ account_name = modest_window_get_active_account (window);
+ account = modest_tny_account_store_get_server_account (modest_runtime_get_account_store (),
+ account_name,
+ TNY_ACCOUNT_TYPE_STORE);
+
+ if (account) {
+ ModestProtocolType protocol_type;
+
+ protocol_type = modest_tny_account_get_protocol_type (account);
+ dimmed = modest_protocol_registry_protocol_type_has_tag
+ (modest_runtime_get_protocol_registry (),
+ protocol_type,
+ MODEST_PROTOCOL_REGISTRY_STORE_FORBID_OUTGOING_XFERS);
+
+ g_object_unref (account);
+ }
return dimmed;
}
}
/* Check dimmed rule */
-
dimmed = _transfer_mode_enabled (win);
if (dimmed)
- modest_dimming_rule_set_notification (rule, _("mail_ib_notavailable_downloading"));
+ modest_dimming_rule_set_notification (rule, _("mail_ib_notavailable_downloading"));
+
+ if (!dimmed)
+ dimmed = _forbid_outgoing_xfers (win);
+
if (!dimmed) {
- dimmed = modest_window_get_dimming_state (win)->any_marked_as_deleted;
- if (dimmed) {
- gchar *msg = modest_ui_actions_get_msg_already_deleted_error_msg (win);
- modest_dimming_rule_set_notification (rule, msg);
- g_free (msg);
+ const DimmedState *state = modest_window_get_dimming_state (win);
+ if (state) {
+ dimmed = state->any_marked_as_deleted;
+ if (dimmed) {
+ gchar *msg = modest_ui_actions_get_msg_already_deleted_error_msg (win);
+ modest_dimming_rule_set_notification (rule, msg);
+ g_free (msg);
+ }
}
}
-
+
if (!dimmed) {
dimmed = _selected_msg_sent_in_progress (win);
if (dimmed)
dimmed = !modest_msg_view_window_has_headers_model (MODEST_MSG_VIEW_WINDOW (win));
}
}
-
if (dimmed)
modest_dimming_rule_set_notification (rule, _("emev_nc_unabletomove_item"));
}
return dimmed;
}
-#ifdef MODEST_TOOLKIT_HILDON2
-#endif
-
gboolean
-modest_ui_dimming_rules_on_find_msg (ModestWindow *win, gpointer user_data)
+modest_ui_dimming_rules_on_find_in_msg (ModestWindow *win, gpointer user_data)
{
ModestDimmingRule *rule = NULL;
gboolean dimmed = FALSE;
dimmed = _invalid_attach_selected (win, FALSE, FALSE, FALSE, rule);
if (!dimmed) {
- dimmed = _purged_attach_selected (win, TRUE);
+ dimmed = _purged_attach_selected (win, TRUE, NULL);
if (dimmed) {
modest_dimming_rule_set_notification (rule, _("mail_ib_attach_not_local"));
}
dimmed = _invalid_attach_selected (win, FALSE, FALSE, TRUE, NULL);
if (dimmed)
modest_dimming_rule_set_notification (rule, _("FIXME:no attachment selected"));
-
- if (!dimmed) {
- TnyList *attachments;
- TnyIterator *iter;
- attachments = modest_msg_view_window_get_attachments (MODEST_MSG_VIEW_WINDOW (win));
- if (attachments) {
- iter = tny_list_create_iterator (attachments);
- while (!tny_iterator_is_done (iter) && !dimmed) {
- TnyMimePart *mime_part = (TnyMimePart *)
- tny_iterator_get_current (iter);
- if (modest_tny_mime_part_is_msg (mime_part))
- dimmed = TRUE;
- g_object_unref (mime_part);
- tny_iterator_next (iter);
- }
- g_object_unref (iter);
- g_object_unref (attachments);
- }
- }
}
if (!dimmed) {
if (!dimmed) {
dimmed = modest_msg_view_window_last_message_selected (MODEST_MSG_VIEW_WINDOW (win));
modest_dimming_rule_set_notification (rule, NULL);
- }
+ }
return dimmed;
}
-gboolean
+gboolean
modest_ui_dimming_rules_on_tools_smtp_servers (ModestWindow *win, gpointer user_data)
{
- return !modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(),
- TRUE);
+ gboolean dimmed;
+ ModestAccountMgr *mgr;
+
+ mgr = modest_runtime_get_account_mgr();
+ dimmed = !modest_account_mgr_has_accounts(mgr, TRUE);
+
+ /* Dimm it if we only have metaaccounts */
+ if (!dimmed) {
+ ModestProtocolRegistry *reg = modest_runtime_get_protocol_registry ();
+ GSList *account_names = modest_account_mgr_account_names (mgr, TRUE);
+
+ if (account_names) {
+ ModestProtocolType store_protocol;
+ gboolean found = FALSE;
+ GSList *iter = account_names;
+ const gchar *tag = MODEST_PROTOCOL_REGISTRY_MULTI_MAILBOX_PROVIDER_PROTOCOLS;
+
+ while (iter && !found) {
+ gchar* account_name;
+
+ account_name = (gchar *) iter->data;
+ store_protocol = modest_account_mgr_get_store_protocol (mgr, account_name);
+
+ if (!modest_protocol_registry_protocol_type_has_tag (reg, store_protocol, tag))
+ found = TRUE;
+ else
+ iter = g_slist_next (iter);
+ }
+ modest_account_mgr_free_account_names (account_names);
+ dimmed = !found;
+ }
+ }
+
+ return dimmed;
}
-gboolean
+gboolean
modest_ui_dimming_rules_on_cancel_sending (ModestWindow *win, gpointer user_data)
{
ModestDimmingRule *rule = NULL;
result = !has_selection;
} else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
if (focused) {
- MODEST_DEBUG_BLOCK (g_message ("FOCUSED %s", g_type_name (G_TYPE_FROM_INSTANCE (focused))););
+ MODEST_DEBUG_BLOCK (g_debug ("FOCUSED %s", g_type_name (G_TYPE_FROM_INSTANCE (focused))););
if (GTK_IS_LABEL (focused) &&
!gtk_label_get_selection_bounds (GTK_LABEL (focused), NULL, NULL)) {
result = TRUE;
if (dimmed)
modest_dimming_rule_set_notification (rule, _("mail_ib_notavailable_downloading"));
+ if (!dimmed)
+ dimmed = _forbid_outgoing_xfers (win);
+
if (!dimmed) {
GtkWidget *header_view;
TnyFolder *folder;
header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (win)));
folder = modest_header_view_get_folder (MODEST_HEADER_VIEW (header_view));
if (folder) {
- dimmed = (tny_folder_get_all_count (TNY_FOLDER (folder)) == 0);
+ dimmed = (tny_folder_get_all_count (TNY_FOLDER (folder)) == 0) ||
+ modest_header_view_is_empty (MODEST_HEADER_VIEW (header_view));
if (!dimmed &&
(tny_folder_get_folder_type (TNY_FOLDER (folder)) == TNY_FOLDER_TYPE_OUTBOX)) {
if (dimmed)
modest_dimming_rule_set_notification (rule, _("mail_ib_notavailable_downloading"));
+ if (!dimmed)
+ dimmed = _forbid_outgoing_xfers (win);
+
if (MODEST_IS_FOLDER_WINDOW (win)) {
ModestFolderView *folder_view;
folder_view = modest_folder_window_get_folder_view (MODEST_FOLDER_WINDOW (win));
MODEST_FOLDER_RULES_FOLDER_NON_MOVEABLE);
}
+ if (!dimmed) {
+ dimmed = _transfer_mode_enabled (win);
+ if (dimmed)
+ modest_dimming_rule_set_notification (rule, "");
+ }
+
return dimmed;
}
MODEST_FOLDER_RULES_FOLDER_NON_DELETABLE);
}
+ if (!dimmed) {
+ dimmed = _transfer_mode_enabled (win);
+ if (dimmed)
+ modest_dimming_rule_set_notification (rule, "");
+ }
+
return dimmed;
}