[evolution-activesync] daemon: incomplete fix for invalid folder ID problem



commit 1a6086e841e9919311ddf7ac3802d8658e5b377d
Author: Patrick Ohly <patrick ohly intel com>
Date:   Fri Aug 31 19:30:14 2012 +0000

    daemon: incomplete fix for invalid folder ID problem
    
    While testing with Google contacts, tests randomly fail
    with "Fetch or Change operation that has an id no longer valid on the server".
    The reason is an empty <CollectionID/>.
    
    This patch adds debug messages around folder and collection ID
    retrieval and fixes one potential problem (a goto jumped over
    the code with sets priv->folderID), but that was not enough
    to fix the problem.
    
    The priv->folderID = eas_sync_folder_msg_get_def_con_folder()
    code gets a NULL from the priv->syncFolderMsg, although previous
    debug code shows that the right folders where found. Need to investigate
    further.

 eas-daemon/libeas/eas-sync-folder-msg.c |    5 +++++
 eas-daemon/libeas/eas-sync-msg.c        |    2 ++
 eas-daemon/libeas/eas-sync-req.c        |   23 ++++++++++++++---------
 3 files changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/eas-daemon/libeas/eas-sync-folder-msg.c b/eas-daemon/libeas/eas-sync-folder-msg.c
index b4a3d71..d584fb0 100644
--- a/eas-daemon/libeas/eas-sync-folder-msg.c
+++ b/eas-daemon/libeas/eas-sync-folder-msg.c
@@ -360,6 +360,11 @@ eas_sync_folder_msg_parse_fs_add_or_update (EasSyncFolderMsg *self, xmlNode *nod
 			f->folder_id = g_strdup (serverId);
 			f->display_name = g_strdup (displayName);
 			f->type = atoi (type);
+			g_debug ("analyzing folder info: name '%s', folder '%s', type %u",
+				 f->display_name, f->folder_id, f->type);
+			g_debug ("calendar folder '%s', contact folder '%s'",
+				 eas_account_get_calendar_folder (acc),
+				 eas_account_get_contact_folder (acc));
 
 			if (f->type == EAS_FOLDER_TYPE_DEFAULT_CALENDAR && eas_account_get_calendar_folder (acc) == NULL) {
 				g_debug ("setting default calendar account");
diff --git a/eas-daemon/libeas/eas-sync-msg.c b/eas-daemon/libeas/eas-sync-msg.c
index af75093..db569d1 100644
--- a/eas-daemon/libeas/eas-sync-msg.c
+++ b/eas-daemon/libeas/eas-sync-msg.c
@@ -148,6 +148,7 @@ eas_sync_msg_new (const gchar* syncKey, EasConnection *conn, const gchar *folder
 	priv->more_available = FALSE;
 	priv->sync_key_in = g_strdup (syncKey);
 	priv->connection = g_object_ref (conn);
+	g_debug ("new sync message for folder '%s'", folderID);
 	priv->folderID = g_strdup (folderID);
 	priv->ItemType = type;
 
@@ -194,6 +195,7 @@ eas_sync_msg_build_message (EasSyncMsg* self, guint filter_type, gboolean getCha
 			xmlNewChild (collection, NULL, (xmlChar *) "Class", (xmlChar *) "Calendar");
 	}
 	xmlNewChild (collection, NULL, (xmlChar *) "SyncKey", (xmlChar*) priv->sync_key_in);
+	g_debug ("sync message for collection '%s'", priv->folderID);
 	xmlNewChild (collection, NULL, (xmlChar *) "CollectionId", (xmlChar*) priv->folderID);
 	xmlNewChild (collection, NULL, (xmlChar *) "DeletesAsMoves", (xmlChar*) "1");
 
diff --git a/eas-daemon/libeas/eas-sync-req.c b/eas-daemon/libeas/eas-sync-req.c
index 8767972..8973289 100644
--- a/eas-daemon/libeas/eas-sync-req.c
+++ b/eas-daemon/libeas/eas-sync-req.c
@@ -222,9 +222,10 @@ eas_sync_req_Activate (EasSyncReq *self,
 		}
 		break;
 		case EAS_ITEM_CONTACT: {
-			g_debug ("default folder id for contacts = [%s]", priv->folderID);
+			g_debug ("get contact folder");
 			priv->folderID = g_strdup (eas_account_get_contact_folder (acc));
 			if (priv->folderID != NULL) {
+				g_debug ("default folder id for contacts = [%s]", priv->folderID);
 				priv->state = EasSyncReqStep2;
 			}
 		}
@@ -271,7 +272,7 @@ eas_sync_req_Activate (EasSyncReq *self,
 
 	} else {
 		EasConnection *conn = eas_request_base_GetConnection (EAS_REQUEST_BASE (self));
-		g_debug ("eas_sync_req_activate - new Sync  mesg");
+		g_debug ("eas_sync_req_activate - new Sync  mesg for folder '%s'", priv->folderID);
 
 		//create sync  msg type
 		priv->syncMsg = eas_sync_msg_new (priv->sync_key, conn, priv->folderID, priv->ItemType);
@@ -390,13 +391,9 @@ eas_sync_req_MessageComplete (EasSyncReq *self, xmlDoc* doc, GError* error_in)
 		eas_connection_update_folders(eas_request_base_GetConnection (EAS_REQUEST_BASE (self)), 
 		                              ret_sync_key, added_folders,
 					      updated_folders, deleted_folders, error);
-		
-		if (g_strcmp0 (priv->sync_key, "0")) {
-			g_debug ("switching state");
-			priv->state = EasSyncReqStep3;
-			goto start_step3;
-		}
-		priv->state = EasSyncReqStep2;
+
+		// ensure that we have priv->folderID for eas_sync_msg_new()
+		// below and in start_step3
 		if (!priv->folderID) {
 			if (priv->ItemType == EAS_ITEM_CALENDAR) {
 				// cannot get from gconf - as the update takes too long - get from sync msg response
@@ -405,6 +402,7 @@ eas_sync_req_MessageComplete (EasSyncReq *self, xmlDoc* doc, GError* error_in)
 				// cannot get from gconf - as the update takes too long - get from sync msg response
 				priv->folderID = g_strdup (eas_sync_folder_msg_get_def_con_folder (priv->syncFolderMsg));
 			}
+			g_debug ("retrieved default folder '%s' from sync folder msg", priv->folderID);
 		}
 		//clean up old message
 		if (priv->syncFolderMsg) {
@@ -412,6 +410,13 @@ eas_sync_req_MessageComplete (EasSyncReq *self, xmlDoc* doc, GError* error_in)
 			priv->syncFolderMsg = NULL;
 		}
 
+		if (g_strcmp0 (priv->sync_key, "0")) {
+			g_debug ("switching state");
+			priv->state = EasSyncReqStep3;
+			goto start_step3;
+		}
+		priv->state = EasSyncReqStep2;
+
 		g_assert (NULL == priv->syncMsg);
 		//create sync  msg type
 		priv->syncMsg = eas_sync_msg_new (priv->sync_key, conn, priv->folderID, priv->ItemType);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]