+ if (MODEST_IS_MAIN_WINDOW (win)) {
+ flags = TNY_HEADER_FLAG_ATTACHMENTS;
+ if (!result)
+ result = _selected_msg_marked_as (win, flags, TRUE);
+ }
+ else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
+
+ /* Get selected atachments */
+ attachments = modest_msg_view_window_get_attachments (MODEST_MSG_VIEW_WINDOW(win));
+ n_selected = g_list_length (attachments);
+
+ /* Check unique */
+ if (!result) {
+ if (unique)
+ result = n_selected != 1;
+ else
+
+ result = n_selected < 1;
+ }
+
+ /* Check attached type (view operation not required) */
+ if (!result && !for_view) {
+ for (node = attachments; node != NULL && !result; node = g_list_next (node)) {
+ TnyMimePart *mime_part = TNY_MIME_PART (node->data);
+ TnyList *nested_list = tny_simple_list_new ();
+ if (TNY_IS_MSG (mime_part)) {
+ selected_messages = TRUE;
+ result = TRUE;
+ }
+ tny_mime_part_get_parts (mime_part, nested_list);
+ if (tny_list_get_length (nested_list) > 0) {
+ nested_attachments = TRUE;
+ result = TRUE;
+ }
+ g_object_unref (nested_list);
+ }
+ }
+
+ /* Set notifications */
+ if (result && rule != NULL) {
+ if (selected_messages) {
+ modest_dimming_rule_set_notification (rule, _("mcen_ib_unable_to_save_attach_mail"));
+ } else if (nested_attachments) {
+ modest_dimming_rule_set_notification (rule, _("FIXME:unable to save attachments with nested elements"));
+ } else if (n_selected == 0) {
+ modest_dimming_rule_set_notification (rule, _("FIXME:no attachment selected"));
+ } else if (unique) {
+ modest_dimming_rule_set_notification (rule, _("mcen_ib_unable_to_display_more"));
+ }
+ }
+
+ /* Free */
+ g_list_free (attachments);
+ }
+
+ return result;
+}
+
+static gboolean
+_purged_attach_selected (ModestWindow *win, gboolean all, ModestDimmingRule *rule)
+{
+ GList *attachments = NULL, *node;
+ gint purged = 0;
+ gint n_attachments = 0;
+ gboolean result = FALSE;
+
+ /* This should check if _all_ the attachments are already purged. If only some
+ * of them are purged, then it does not cause dim as there's a confirmation dialog
+ * for removing only local attachments */