#include "modest-debug.h"
#include "modest-tny-folder.h"
#include "modest-tny-account.h"
+#include "modest-tny-msg.h"
#include "modest-tny-mime-part.h"
#include "modest-text-utils.h"
+#include <modest-address-book.h>
#include <widgets/modest-attachments-view.h>
#include <modest-runtime.h>
#include <tny-simple-list.h>
return dimmed;
}
+#ifdef MODEST_TOOLKIT_HILDON2
+gboolean
+modest_ui_dimming_rules_on_add_to_contacts (ModestWindow *win, gpointer user_data)
+{
+ TnyMsg *msg;
+ GSList *recipients, *node;
+ gboolean has_recipients_to_add;
+
+ g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
+ g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (win), FALSE);
+
+ msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (win));
+ recipients = modest_tny_msg_get_all_recipients_list (msg);
+
+ has_recipients_to_add = FALSE;
+ for (node = recipients; node != NULL; node = g_slist_next (node)) {
+ if (!modest_address_book_has_address ((const gchar *) node->data)) {
+ has_recipients_to_add = TRUE;
+ break;
+ }
+ }
+
+ g_slist_foreach (recipients, (GFunc) g_free, NULL);
+ g_slist_free (recipients);
+ g_object_unref (msg);
+
+ return !has_recipients_to_add;
+}
+#else
gboolean
modest_ui_dimming_rules_on_add_to_contacts (ModestWindow *win, gpointer user_data)
{
gboolean dimmed = FALSE;
GtkWidget *focused = NULL;
- g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
+ g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
rule = MODEST_DIMMING_RULE (user_data);
focused = gtk_window_get_focus (GTK_WINDOW (win));
return dimmed;
}
+#endif
/* *********************** static utility functions ******************** */
while (!tny_iterator_is_done (iter) && !result) {
TnyMimePart *mime_part = TNY_MIME_PART (tny_iterator_get_current (iter));
TnyList *nested_list = tny_simple_list_new ();
+
if (!for_remove && modest_tny_mime_part_is_msg (mime_part)) {
- selected_messages = TRUE;
- result = TRUE;
+ TnyMsg *window_msg;
+ window_msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (win));
+ if ((TnyMimePart *) window_msg != mime_part) {
+ selected_messages = TRUE;
+ result = TRUE;
+ }
+ g_object_unref (window_msg);
}
tny_mime_part_get_parts (mime_part, nested_list);
if (!for_remove && tny_list_get_length (nested_list) > 0) {
if (attachments == NULL)
return FALSE;
- if (tny_list_get_length (attachments)) {
+ if (tny_list_get_length (attachments) == 0) {
g_object_unref (attachments);
return FALSE;
}