ecb_ews_receive_objects_sync (ECalBackendSync *sync_backend,
			      EDataCal *cal,
			      GCancellable *cancellable,
			      const gchar *calobj,
			      GError **error)
{
	ECalBackendEws *cbews;
	ECalBackend *cal_backend;
	CamelEwsSettings *ews_settings;
	icalcomponent *icalcomp, *subcomp;
	icalcomponent_kind kind;
	gchar *user_email;
	gboolean success = TRUE, do_refresh = FALSE;

	g_return_if_fail (E_IS_CAL_BACKEND_EWS (sync_backend));

	cbews = E_CAL_BACKEND_EWS (sync_backend);

	if (!e_cal_meta_backend_ensure_connected_sync (E_CAL_META_BACKEND (cbews), cancellable, error))
		return;

	icalcomp = calobj ? icalparser_parse_string (calobj) : NULL;

	if (!icalcomp) {
		g_propagate_error (error, EDC_ERROR (InvalidObject));
		return;
	}

	/* make sure ical data we parse is actually a vCalendar component */
	if (icalcomponent_isa (icalcomp) != ICAL_VCALENDAR_COMPONENT) {
		icalcomponent_free (icalcomp);
		g_propagate_error (error, EDC_ERROR (InvalidObject));
		return;
	}

	cal_backend = E_CAL_BACKEND (cbews);
	kind = e_cal_backend_get_kind (cal_backend);

	ews_settings = ecb_ews_get_collection_settings (cbews);
	user_email = camel_ews_settings_dup_email (ews_settings);

	switch (icalcomponent_get_method (icalcomp)) {
	case ICAL_METHOD_REQUEST:
	case ICAL_METHOD_PUBLISH:
	case ICAL_METHOD_REPLY:
		for (subcomp = icalcomponent_get_first_component (icalcomp, kind);
		     subcomp && success;
		     subcomp = icalcomponent_get_next_component (icalcomp, kind)) {
			ECalComponent *comp;
			const gchar *response_type;
			gboolean rsvp_requested = FALSE;

			/* getting a data for meeting request response */
			response_type = ecb_ews_get_current_user_meeting_reponse (cbews, subcomp, user_email, &rsvp_requested);

			comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (subcomp));

			success = ecb_ews_do_method_request_publish_reply (cbews, icalcomp, comp, subcomp, response_type, user_email, rsvp_requested, cancellable, error);

			do_refresh = TRUE;

			g_object_unref (comp);
		}
		break;
	case ICAL_METHOD_COUNTER:
		/*
		 * this is a new time proposal mail from one of the attendees
		 * if we decline the proposal, nothing have to be done
		 * if we accept it we will call to modify_object
		 */
		for (subcomp = icalcomponent_get_first_component (icalcomp, kind);
		     subcomp && success;
		     subcomp = icalcomponent_get_next_component (icalcomp, kind)) {
			const gchar *response_type;

			/* getting a data for meeting request response */
			response_type = ecb_ews_get_current_user_meeting_reponse (cbews, subcomp, user_email, NULL);

			if (g_strcmp0 (response_type, "ACCEPTED") == 0) {
				gchar **split_subject;
				icalproperty *summary;

				/* we have to edit the meeting subject to remove exchange header */
				summary = icalcomponent_get_first_property (subcomp, ICAL_SUMMARY_PROPERTY);
				split_subject =
					g_strsplit (icalproperty_get_value_as_string (summary), ":", -1);
				icalproperty_set_value_from_string (summary, split_subject[1] , "NO");
				g_strfreev (split_subject);

				success = ecb_ews_modify_item_sync (cbews, NULL, NULL, subcomp, cancellable, error);

				do_refresh = TRUE;
			}
		}
		break;
	default:
		break;
	}

	icalcomponent_free (icalcomp);
	g_free (user_email);

	if (success && do_refresh)
		e_cal_meta_backend_schedule_refresh (E_CAL_META_BACKEND (cbews));

	ecb_ews_convert_error_to_edc_error (error);
	ecb_ews_maybe_disconnect_sync (cbews, error, cancellable);
}