static gboolean
_forbid_outgoing_xfers (ModestWindow *window)
{
- const gchar *account_name;
- TnyAccount *account;
+ const gchar *account_name = NULL;
+ TnyAccount *account = NULL;
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);
+#ifdef MODEST_TOOLKIT_HILDON2
+ /* We cannot just get the active account because the active
+ account of a header window that shows the headers of a
+ local account is the ID of the remote account */
+ if (MODEST_IS_HEADER_WINDOW (window)) {
+ ModestHeaderView *header_view;
+ TnyFolder *folder;
+
+ header_view = modest_header_window_get_header_view ((ModestHeaderWindow *) window);
+ folder = modest_header_view_get_folder (header_view);
+
+ if (folder) {
+ account = modest_tny_folder_get_account (folder);
+ g_object_unref (folder);
+ }
+ }
+#endif
+
+ if (!account) {
+ 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;
gboolean
modest_ui_dimming_rules_on_add_to_contacts (ModestWindow *win, gpointer user_data)
{
- TnyMsg *msg;
- GSList *recipients, *node;
+ GSList *recipients = NULL;
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));
+ if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
+ TnyMsg *msg;
- /* Message is loaded asynchronously, so this could happen */
- if (!msg) {
-#ifdef MODEST_TOOLKIT_HILDON2
- TnyHeader *header;
+ msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (win));
- header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
- if (!header)
- return TRUE;
+ /* Message is loaded asynchronously, so this could happen */
+ if (!msg) {
+ TnyHeader *header;
- recipients = modest_tny_msg_header_get_all_recipients_list (header);
- g_object_unref (header);
-#else
- return TRUE;
-#endif
- } else {
- recipients = modest_tny_msg_get_all_recipients_list (msg);
- g_object_unref (msg);
+ header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
+ if (!header)
+ return TRUE;
+
+ recipients = modest_tny_msg_header_get_all_recipients_list (header);
+ g_object_unref (header);
+ } else {
+ recipients = modest_tny_msg_get_all_recipients_list (msg);
+ g_object_unref (msg);
+ }
+ } else if (MODEST_IS_MSG_EDIT_WINDOW (win)) {
+ /* Check if there are pending addresses to add */
+ return !modest_msg_edit_window_has_pending_addresses ((ModestMsgEditWindow *) win);
}
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;
+
+ if (recipients) {
+ GSList *node;
+ for (node = recipients; node != NULL; node = g_slist_next (node)) {
+ const gchar *recipient = (const gchar *) node->data;
+ if (modest_text_utils_validate_recipient (recipient, NULL)) {
+ if (!modest_address_book_has_address (recipient)) {
+ has_recipients_to_add = TRUE;
+ break;
+ }
+ }
}
+ g_slist_foreach (recipients, (GFunc) g_free, NULL);
+ g_slist_free (recipients);
}
- g_slist_foreach (recipients, (GFunc) g_free, NULL);
- g_slist_free (recipients);
-
return !has_recipients_to_add;
}
#else