Fixes NB#120338, modest plugins need a way to notify modest that they don't want...
authorSergio Villar Senin <svillar@igalia.com>
Tue, 2 Jun 2009 16:42:15 +0000 (18:42 +0200)
committerSergio Villar Senin <svillar@igalia.com>
Tue, 2 Jun 2009 16:42:15 +0000 (18:42 +0200)
src/modest-protocol-registry.h
src/modest-ui-actions.c

index 3d26e1b..30aea7d 100644 (file)
@@ -54,6 +54,7 @@ G_BEGIN_DECLS
 #define MODEST_PROTOCOL_REGISTRY_USE_ALTERNATE_PORT "use-alternate-port"
 #define MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS "store-has-folders"
 #define MODEST_PROTOCOL_REGISTRY_STORE_FORBID_MESSAGE_ADD "store-forbid-message-add"
+#define MODEST_PROTOCOL_REGISTRY_NO_AUTO_UPDATE_PROTOCOLS "no-auto-update"
 
 /* convenience macros */
 #define MODEST_TYPE_PROTOCOL_REGISTRY             (modest_protocol_registry_get_type())
index ed7051a..1d9e166 100644 (file)
@@ -2363,6 +2363,7 @@ modest_ui_actions_do_send_receive (const gchar *account_name,
        gchar *acc_name = NULL;
        SendReceiveInfo *info;
        ModestTnyAccountStore *acc_store;
+       TnyAccount *account;
 
        /* If no account name was provided then get the current account, and if
           there is no current account then pick the default one: */
@@ -2380,6 +2381,25 @@ modest_ui_actions_do_send_receive (const gchar *account_name,
        }
 
        acc_store = modest_runtime_get_account_store ();
+       account = modest_tny_account_store_get_server_account (acc_store, acc_name, TNY_ACCOUNT_TYPE_STORE);
+
+       /* Do not automatically refresh accounts that are flagged as
+          NO_AUTO_UPDATE. This could be useful for accounts that
+          handle their own update times */
+       if (!interactive) {
+               ModestProtocolType proto = modest_tny_account_get_protocol_type (account);
+               if (proto != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
+                       const gchar *tag = MODEST_PROTOCOL_REGISTRY_NO_AUTO_UPDATE_PROTOCOLS;
+                       ModestProtocolRegistry *registry = modest_runtime_get_protocol_registry ();
+
+                       if (modest_protocol_registry_protocol_type_has_tag (registry, proto, tag)) {
+                               g_debug ("%s no auto update allowed for account %s", __FUNCTION__, account_name);
+                               g_object_unref (account);
+                               g_free (acc_name);
+                               return;
+                       }
+               }
+       }
 
        /* Create the info for the connect and perform */
        info = g_slice_new (SendReceiveInfo);
@@ -2387,8 +2407,7 @@ modest_ui_actions_do_send_receive (const gchar *account_name,
        info->win = (win) ? g_object_ref (win) : NULL;
        info->poke_status = poke_status;
        info->interactive = interactive;
-       info->account = modest_tny_account_store_get_server_account (acc_store, acc_name,
-                                                                    TNY_ACCOUNT_TYPE_STORE);
+       info->account = account;
        /* We need to create the operation here, because otherwise it
           could happen that the queue emits the queue-empty signal
           while we're trying to connect the account */