Handle the case of invalid connections in mailer.
authorChenthill Palanisamy <pchenthill@novell.com>
Tue, 19 May 2009 12:31:32 +0000 (18:01 +0530)
committerChenthill Palanisamy <pchenthill@novell.com>
Tue, 19 May 2009 13:32:18 +0000 (19:02 +0530)
camel/providers/groupwise/camel-groupwise-folder.c
camel/providers/groupwise/camel-groupwise-store.c
servers/groupwise/e-gw-connection.c

index da3b6f2..69f9302 100644 (file)
@@ -286,6 +286,10 @@ groupwise_populate_msg_body_from_item (EGwConnection *cnc, CamelMultipart *multi
                        status = e_gw_connection_get_attachment (cnc, 
                                        e_gw_item_get_msg_body_id (item), 0, -1, 
                                        (const char **)&temp_body, &len);
+                       if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+                               status = e_gw_connection_get_attachment (cnc, 
+                                       e_gw_item_get_msg_body_id (item), 0, -1, 
+                                       (const char **)&temp_body, &len);
                        if (status != E_GW_CONNECTION_STATUS_OK) {
                                g_warning ("Could not get Messagebody\n");
                        }
@@ -558,6 +562,7 @@ update_junk_list (CamelStore *store, CamelMessageInfo *info, int flag)
        CamelGroupwiseStore *gw_store= CAMEL_GROUPWISE_STORE(store);
        CamelGroupwiseStorePrivate  *priv = gw_store->priv;
        EGwConnection *cnc = cnc_lookup (priv);
+       EGwConnectionStatus status;
 
        if (!(from = g_strdup (camel_message_info_from (info))))
                goto error;
@@ -574,12 +579,19 @@ update_junk_list (CamelStore *store, CamelMessageInfo *info, int flag)
        if (!email || !email[index])
                goto error;
 
-       if (flag == ADD_JUNK_ENTRY)
-               e_gw_connection_create_junk_entry (cnc, email[index], "email", "junk");
-       else if (flag == REMOVE_JUNK_ENTRY) {
+       if (flag == ADD_JUNK_ENTRY) {
+               status = e_gw_connection_create_junk_entry (cnc, email[index], "email", "junk");
+               if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+                       status = e_gw_connection_create_junk_entry (cnc, email[index], "email", "junk");
+               
+       } else if (flag == REMOVE_JUNK_ENTRY) {
                GList *list = NULL;
                EGwJunkEntry *entry;
-               if (e_gw_connection_get_junk_entries (cnc, &list)== E_GW_CONNECTION_STATUS_OK){
+               status = e_gw_connection_get_junk_entries (cnc, &list);
+               if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+                       status = e_gw_connection_get_junk_entries (cnc, &list);
+
+               if (status == E_GW_CONNECTION_STATUS_OK){
                        while (list) {
                                entry = list->data;
                                if (!g_ascii_strcasecmp (entry->match, email[index])) { 
@@ -1005,6 +1017,8 @@ update_update (CamelSession *session, CamelSessionThreadMsg *msg)
        camel_operation_start (NULL, _("Checking for deleted messages %s"), m->folder->name);
 
        status = e_gw_connection_create_cursor (m->cnc, m->container_id, "id", NULL, &cursor);
+       if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+               status = e_gw_connection_create_cursor (m->cnc, m->container_id, "id", NULL, &cursor);
        if (status != E_GW_CONNECTION_STATUS_OK) {
                g_warning ("ERROR update update\n");
                goto end1;
@@ -1226,6 +1240,10 @@ groupwise_refresh_folder(CamelFolder *folder, CamelException *ex)
                status = e_gw_connection_get_quick_messages (cnc, container_id,
                                "peek id",
                                &t_str, "New", NULL, source, -1, &slist);
+               if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+                       status = e_gw_connection_get_quick_messages (cnc, container_id,
+                                       "peek id",
+                                       &t_str, "New", NULL, source, -1, &slist);
                if (status != E_GW_CONNECTION_STATUS_OK) {
                        camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
                        goto end2;
@@ -1263,7 +1281,10 @@ groupwise_refresh_folder(CamelFolder *folder, CamelException *ex)
                status = e_gw_connection_get_quick_messages (cnc, container_id,
                                "peek id",
                                &t_str, "Modified", NULL, source, -1, &slist);
-
+               if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+                       status = e_gw_connection_get_quick_messages (cnc, container_id,
+                                       "peek id",
+                                       &t_str, "Modified", NULL, source, -1, &slist);
                if (status != E_GW_CONNECTION_STATUS_OK) {
                        camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
                        goto end3;
index 0f26dff..8da055b 100644 (file)
@@ -624,6 +624,12 @@ groupwise_get_folder (CamelStore *store, const char *folder_name, guint32 flags,
                                CREATE_CURSOR_VIEW,
                                NULL,
                                &cursor);
+               if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+                       status = e_gw_connection_create_cursor (priv->cnc, container_id, 
+                               CREATE_CURSOR_VIEW,
+                               NULL,
+                               &cursor);
+
                if (status != E_GW_CONNECTION_STATUS_OK) {
                        CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
                        g_free (container_id);
@@ -749,6 +755,11 @@ gw_store_reload_folder (CamelGroupwiseStore *gw_store, CamelFolder *folder, guin
                                                                        CREATE_CURSOR_VIEW,
                                                                        NULL,
                                                                        &cursor);
+                       if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+                                       status = e_gw_connection_create_cursor (priv->cnc, container_id, 
+                                                                       CREATE_CURSOR_VIEW,
+                                                                       NULL,
+                                                                       &cursor);
                        if (status != E_GW_CONNECTION_STATUS_OK) {
                                        CAMEL_SERVICE_REC_UNLOCK (gw_store, connect_lock);
                                        g_free (container_id);
@@ -946,6 +957,8 @@ groupwise_folders_sync (CamelGroupwiseStore *store, CamelException *ex)
        }
 
        status = e_gw_connection_get_container_list (priv->cnc, "folders", &folder_list);
+       if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+               status = e_gw_connection_get_container_list (priv->cnc, "folders", &folder_list);
        if (status != E_GW_CONNECTION_STATUS_OK) {
                g_warning ("Could not get folder list..\n");
                return;
@@ -1222,6 +1235,8 @@ create_junk_folder (CamelStore *store)
                
        CAMEL_SERVICE_REC_LOCK (store, connect_lock);
        status = e_gw_connection_modify_junk_settings (priv->cnc, JUNK_ENABLE, 0, 0,  JUNK_PERSISTENCE);
+       if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+               status = e_gw_connection_modify_junk_settings (priv->cnc, JUNK_ENABLE, 0, 0,  JUNK_PERSISTENCE);
        if (status == E_GW_CONNECTION_STATUS_OK) {
                root = groupwise_build_folder_info(groupwise_store, parent_name, folder_name);
                camel_store_summary_save((CamelStoreSummary *)groupwise_store->summary);
@@ -1281,6 +1296,8 @@ groupwise_create_folder(CamelStore *store,
        }
        CAMEL_SERVICE_REC_LOCK (store, connect_lock);
        status = e_gw_connection_create_folder(priv->cnc,parent_id,folder_name, &child_container_id);
+       if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+               status = e_gw_connection_create_folder(priv->cnc,parent_id,folder_name, &child_container_id);
        if (status == E_GW_CONNECTION_STATUS_OK) {
                root = groupwise_build_folder_info(groupwise_store, parent_name,folder_name);
                camel_store_summary_save((CamelStoreSummary *)groupwise_store->summary);
@@ -1315,6 +1332,8 @@ groupwise_delete_folder(CamelStore *store,
        container = g_hash_table_lookup (priv->name_hash, folder_name);
 
        status = e_gw_connection_remove_item (priv->cnc, container, container);
+       if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+               status = e_gw_connection_remove_item (priv->cnc, container, container);
 
        if (status == E_GW_CONNECTION_STATUS_OK) {
                groupwise_store_set_current_folder (groupwise_store, NULL);
index 3b6bf7c..fa586a8 100644 (file)
@@ -803,6 +803,8 @@ e_gw_connection_get_container_id (EGwConnection *cnc, const char *name)
        g_return_val_if_fail (name != NULL, NULL);
 
         status = e_gw_connection_get_container_list (cnc, "folders", &container_list);
+       if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+               status = e_gw_connection_get_container_list (cnc, "folders", &container_list);
        if (status != E_GW_CONNECTION_STATUS_OK) {
                e_gw_connection_free_container_list (container_list);
                 return NULL;