From 0197b4eaa7581d57c42c3378df7a957c5d888eb4 Mon Sep 17 00:00:00 2001 From: mguessan Date: Mon, 19 Oct 2009 08:58:12 +0000 Subject: [PATCH] Caldav: Create a new setting davmail.forceActiveSyncUpdate to let users choose to force ActiveSync event. Note: custom iCal or Lightning ICS properties are lost if this option is enabled. git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@785 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../davmail/exchange/ExchangeSession.java | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 7ab4b961..71233423 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -2391,33 +2391,15 @@ public class ExchangeSession { eventResult.etag = putmethod.getResponseHeader("GetETag").getValue(); } - // trigger activeSync push event - if (status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED) { + // trigger activeSync push event, only if davmail.forceActiveSyncUpdate setting is true + if ((status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED) && + (Settings.getBooleanProperty("davmail.forceActiveSyncUpdate"))) { ArrayList propertyList = new ArrayList(); propertyList.add(new DefaultDavProperty(DavPropertyName.create("contentclass", Namespace.getNamespace("DAV:")), contentClass)); PropPatchMethod propPatchMethod = new PropPatchMethod(messageUrl, propertyList); int patchStatus = DavGatewayHttpClientFacade.executeHttpMethod(httpClient, propPatchMethod); if (patchStatus != HttpStatus.SC_MULTI_STATUS) { LOGGER.warn("Unable to patch event to trigger activeSync push"); - } else { - // Yet another patch: restore message custom body, all custom lines are removed by PROPPATCH - PutMethod restorePutMethod = new PutMethod(messageUrl); - restorePutMethod.setRequestHeader("Translate", "f"); - restorePutMethod.setRequestHeader("Overwrite", "f"); - restorePutMethod.setRequestEntity(new ByteArrayRequestEntity(baos.toByteArray(), "message/rfc822")); - try { - status = httpClient.executeMethod(restorePutMethod); - if (status == HttpURLConnection.HTTP_OK) { - LOGGER.warn("Unable to create or update message " + status + ' ' + restorePutMethod.getStatusLine()); - } - } finally { - putmethod.releaseConnection(); - } - // Need to get event again to get updated etag - Event event = getEvent(messageUrl); - if (event.getEtag() != null) { - eventResult.etag = event.getEtag(); - } } } return eventResult;