protected void setClientAllday(VProperty property) { if (property != null) { // set VALUE=DATE param if (!property.hasParam("VALUE")) { property.addParam("VALUE", "DATE"); } // remove TZID property.removeParam("TZID"); String value = property.getValue(); if (value.length() != 8) { // try to convert datetime value to date value try { Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateParser = new SimpleDateFormat("yyyyMMdd'T'HHmmss"); calendar.setTime(dateParser.parse(value)); calendar.add(Calendar.HOUR_OF_DAY, 12); SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd"); value = dateFormatter.format(calendar.getTime()); } catch (ParseException e) { LOGGER.warn("Invalid date value in allday event: " + value); } } property.setValue(value); } }
protected void setServerAllday(VProperty property) { if (vTimezone != null) { // set TZID param if (!property.hasParam("TZID")) { property.addParam("TZID", vTimezone.getPropertyValue("TZID")); } // remove VALUE property.removeParam("VALUE"); String value = property.getValue(); if (value.length() != 8) { LOGGER.warn("Invalid date value in allday event: " + value); } property.setValue(property.getValue() + "T000000"); } }
protected void fixAlarm(VObject vObject, boolean fromServer) { if (vObject.vObjects != null) { if (Settings.getBooleanProperty("davmail.caldavDisableReminders", false)) { ArrayList<VObject> vAlarms = null; for (VObject vAlarm : vObject.vObjects) { if ("VALARM".equals(vAlarm.type)) { if (vAlarms == null) { vAlarms = new ArrayList<VObject>(); } vAlarms.add(vAlarm); } } // remove all vAlarms if (vAlarms != null) { for (VObject vAlarm : vAlarms) { vObject.vObjects.remove(vAlarm); } } } else { for (VObject vAlarm : vObject.vObjects) { if ("VALARM".equals(vAlarm.type)) { String action = vAlarm.getPropertyValue("ACTION"); if (fromServer && "DISPLAY".equals(action) // convert DISPLAY to AUDIO only if user defined an alarm sound && Settings.getProperty("davmail.caldavAlarmSound") != null) { // Convert alarm to audio for iCal vAlarm.setPropertyValue("ACTION", "AUDIO"); if (vAlarm.getPropertyValue("ATTACH") == null) { // Add defined sound into the audio alarm VProperty vProperty = new VProperty("ATTACH", Settings.getProperty("davmail.caldavAlarmSound")); vProperty.addParam("VALUE", "URI"); vAlarm.addProperty(vProperty); } } else if (!fromServer && "AUDIO".equals(action)) { // Use the alarm action that exchange (and blackberry) understand // (exchange and blackberry don't understand audio actions) vAlarm.setPropertyValue("ACTION", "DISPLAY"); } } } } } }
private void fixTzid(VProperty property) { if (property != null && !property.hasParam("TZID")) { property.addParam("TZID", vTimezone.getPropertyValue("TZID")); } }