evolution-data-server r9348 - in branches/EXCHANGE_MAPI_BRANCH: calendar/backends/mapi servers/mapi



Author: msuman
Date: Thu Aug 14 11:30:49 2008
New Revision: 9348
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9348&view=rev

Log:
Fix for attachment send/receive which was broken sometime ago (LF-CRLF issues), fixes for rendering/updating from meeting replies.

Modified:
   branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/ChangeLog
   branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi.c
   branches/EXCHANGE_MAPI_BRANCH/servers/mapi/ChangeLog
   branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-cal-utils.c

Modified: branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi.c	Thu Aug 14 11:30:49 2008
@@ -1330,7 +1330,7 @@
 	}
 
 	/* blatant HACK /me blames some stupid design in e-d-s */
-	if (e_cal_component_has_attachments (comp))
+	if (e_cal_component_has_attachments (comp) && !fetch_deltas(cbmapi))
 		g_cond_signal (priv->dlock->cond);
 
 	g_object_unref (comp);
@@ -1374,6 +1374,8 @@
 	GSList *recipients = NULL;
 	GSList *attachments = NULL;
 	struct cbdata cbdata;
+	gboolean no_increment = FALSE;
+	icalproperty *prop; 
 
 	*old_object = *new_object = NULL;
 	cbmapi = E_CAL_BACKEND_MAPI (backend);
@@ -1391,6 +1393,16 @@
 	if (!icalcomp)
 		return GNOME_Evolution_Calendar_InvalidObject;
 
+	prop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
+	while (prop) {
+		const char *name = icalproperty_get_x_name (prop);
+		if (!g_ascii_strcasecmp (name, "X-EVOLUTION-IS-REPLY")) {
+			no_increment = TRUE; 
+			icalcomponent_remove_property (icalcomp, prop);
+		}
+		prop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY);
+	}
+
 	comp = e_cal_component_new ();
 	e_cal_component_set_icalcomponent (comp, icalcomp);
 
@@ -1430,7 +1442,8 @@
 
 		get_server_data (cbmapi, icalcomp, &cbdata);
 		if (modifier_is_organizer(cbmapi, comp)) {
-			cbdata.appt_seq += 1;
+			if (!no_increment)
+				cbdata.appt_seq += 1;
 			cbdata.username = e_cal_backend_mapi_get_user_name (cbmapi);
 			cbdata.useridtype = "SMTP";
 			cbdata.userid = e_cal_backend_mapi_get_user_email (cbmapi);
@@ -1463,10 +1476,6 @@
 	*old_object = e_cal_component_get_as_string (cache_comp);
 	*new_object = e_cal_component_get_as_string (comp);
 
-	/* blatant HACK /me blames some stupid design in e-d-s */
-	if (e_cal_component_has_attachments (comp))
-		g_cond_signal (priv->dlock->cond);
-
 	g_object_unref (comp);
 	g_object_unref (cache_comp);
 	exchange_mapi_util_free_recipient_list (&recipients);

Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-cal-utils.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-cal-utils.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-cal-utils.c	Thu Aug 14 11:30:49 2008
@@ -194,18 +194,18 @@
 
 	for (l = comp_attach_list; l ; l = l->next) {
 		gchar *sfname_uri = (gchar *) l->data;
-		gchar *sfname = g_filename_from_uri (sfname_uri, NULL, NULL);
-		gchar *filename;
+		gchar *sfname = NULL, *filename = NULL;
 		GMappedFile *mapped_file;
 		GError *error = NULL;
 
+		sfname = g_filename_from_uri (sfname_uri, NULL, NULL);
 		mapped_file = g_mapped_file_new (sfname, FALSE, &error);
 		filename = g_path_get_basename (sfname);
 
 		if (mapped_file && g_str_has_prefix (filename, uid)) {
 			ExchangeMAPIAttachment *attach_item;
-			gchar *attach_crlf = exchange_lf_to_crlf (g_mapped_file_get_contents (mapped_file));
-			guint filelength = strlen (attach_crlf);
+			gchar *attach = g_mapped_file_get_contents (mapped_file);
+			guint filelength = g_mapped_file_get_length (mapped_file);
 			const gchar *split_name = (filename + strlen (uid) + strlen ("-"));
 
 			new_attach_list = g_slist_append (new_attach_list, g_strdup (sfname_uri));
@@ -213,13 +213,12 @@
 			attach_item = g_new0 (ExchangeMAPIAttachment, 1);
 			attach_item->filename = g_strdup(split_name);
 			attach_item->value = g_byte_array_sized_new (filelength);
-			attach_item->value = g_byte_array_append (attach_item->value, attach_crlf, filelength + 1);
+			attach_item->value = g_byte_array_append (attach_item->value, attach, filelength);
 			*attach_list = g_slist_append (*attach_list, attach_item);
 
 			g_mapped_file_free (mapped_file);
-			g_free (attach_crlf);
 		} else {
-			g_message ("DEBUG: could not map %s: %s\n", sfname, error->message);
+			g_debug ("Could not map %s: %s \n", sfname_uri, error->message);
 			g_error_free (error);
 		}
 
@@ -318,25 +317,28 @@
 	GSList *comp_attach_list = NULL, *l;
 	const char *uid;
 
+	g_return_if_fail (comp != NULL);
+
 	e_cal_component_get_uid (comp, &uid);
 	for (l = attach_list; l ; l = l->next) {
 		ExchangeMAPIAttachment *attach_item = (ExchangeMAPIAttachment *) (l->data);
 		gchar *attach_file_url, *filename;
 		guint len;
 		int fd = -1;
-		gchar *attach_lf = exchange_crlf_to_lf((const char *)attach_item->value->data);
 
-		len = (attach_lf != NULL) ? strlen (attach_lf) : 0;
+		gchar *attach = (const char *)attach_item->value->data;
+		len = attach_item->value->len;
+
 		attach_file_url = g_strconcat (local_store_uri, G_DIR_SEPARATOR_S, uid, "-", attach_item->filename, NULL);
 		filename = g_filename_from_uri (attach_file_url, NULL, NULL);
 
 		fd = g_open (filename, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600);
 		if (fd == -1) { 
 			/* skip gracefully */
-			g_message ("DEBUG: could not open %s for writing\n", filename);
-		} else if (len && write (fd, attach_lf, len) == -1) {
+			g_debug ("Could not open %s for writing \n", filename);
+		} else if (len && write (fd, attach, len) == -1) {
 			/* skip gracefully */
-			g_message ("DEBUG: attachment write failed.\n");
+			g_debug ("Attachment write failed \n");
 		}
 		if (fd != -1) {
 			close (fd);
@@ -345,7 +347,6 @@
 
 		g_free (filename);
 		g_free (attach_file_url);
-		g_free (attach_lf);
 	}
 
 	e_cal_component_set_attachment_list (comp, comp_attach_list);
@@ -839,6 +840,7 @@
 {
 	icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp);
 	icalproperty *attendee; 
+	gboolean found = FALSE;
 
 	attendee = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
 	while (attendee) {
@@ -850,11 +852,18 @@
 				icalparameter *sentby_param = icalparameter_new_sentby (sentby);
 				icalproperty_set_parameter (attendee, sentby_param);
 			}
+			found = TRUE;
 			break;
 		}
 		attendee = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
 	}
 
+	if (found) {
+		icalproperty *prop = icalproperty_new_x ("1");
+		icalproperty_set_x_name (prop, "X-EVOLUTION-IS-REPLY");
+		icalcomponent_add_property (icalcomp, prop);
+	}
+
 	e_cal_component_set_icalcomponent (comp, icalcomp);
 }
 
@@ -1128,10 +1137,7 @@
 	mapi_id_t mid = 0;
 	const bool *b = NULL;
 	icalcomponent *icalcomp = NULL;
-	char *str = NULL, *smid = NULL;
-	char *tmp;
-	gchar *filename;
-	gchar *fileuri;
+	gchar *str = NULL, *smid = NULL, *tmp, *filename, *fileuri;
 
 	msg_class = (const char *) exchange_mapi_util_find_array_propval (properties, PR_MESSAGE_CLASS);
 	g_return_val_if_fail (msg_class && *msg_class, NULL);
@@ -1145,12 +1151,13 @@
 		method = ICAL_METHOD_REPLY;
 		kind = ICAL_VEVENT_COMPONENT;
 	} else
-		return NULL;
+		return (g_strdup (""));
 
 	filename = g_build_filename (g_get_home_dir (), TEMP_ATTACH_STORE, NULL);
 	fileuri = g_filename_to_uri (filename, NULL, NULL);
 
 	check_server_for_object (properties, &mid);
+
 	if (method == ICAL_METHOD_REPLY) {
 		if (mid) { 
 	 		comp = update_attendee_status (properties, mid);
@@ -1163,7 +1170,7 @@
 			comp = server_cbd.comp;
 			set_attachments_to_cal_component (comp, attachments, fileuri);
 		}
-	} else { 
+	} else if (method == ICAL_METHOD_REQUEST) { 
 		if (mid)
 			smid = exchange_mapi_util_mapi_id_to_string (mid);
 		else 
@@ -1708,7 +1715,7 @@
 			flag32 = olResponseOrganized;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_RESPONSESTATUS], (const void *) &flag32);
 
-			b = 0;
+			b = 1;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_INVITED], (const void *) &b);
 
 			break;



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