1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 03:02:22 -05:00

Caldav: implement 2899430, change the subject line when replying to invites

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1346 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-08-16 20:33:56 +00:00
parent c3c08afbfd
commit 8c30891d0c
5 changed files with 51 additions and 6 deletions

View File

@ -2014,12 +2014,14 @@ public abstract class ExchangeSession {
writer.writeHeader("Date", new Date());
// Make sure invites have a proper subject line
// TODO: get current user attendee status, i18n
String subject = vCalendar.getFirstVeventPropertyValue("SUMMARY");
if (subject == null) {
subject = BundleMessage.format("MEETING_REQUEST");
}
writer.writeHeader("Subject", subject);
// Write a part of the message that contains the
// ICS description so that invites contain the description text
String description = vCalendar.getFirstVeventPropertyValue("DESCRIPTION");
if ("urn:content-classes:calendarmessage".equals(contentClass)) {
// need to parse attendees and organizer to build recipients
@ -2033,6 +2035,16 @@ public abstract class ExchangeSession {
return null;
}
} else {
// reset body
description = "";
String status = vCalendar.getAttendeeStatus();
if (status != null) {
writer.writeHeader("Subject", BundleMessage.format(status)+ subject);
} else {
writer.writeHeader("Subject", subject);
}
// notify only organizer
writer.writeHeader("To", recipients.organizer);
// do not send notification if no recipients found
@ -2078,10 +2090,6 @@ public abstract class ExchangeSession {
writer.writeLn();
writer.writeLn("------=_NextPart_" + boundary);
// Write a part of the message that contains the
// ICS description so that invites contain the description text
String description = vCalendar.getFirstVeventPropertyValue("DESCRIPTION");
if (description != null && description.length() > 0) {
writer.writeHeader("Content-Type", "text/plain;\r\n" +
"\tcharset=\"utf-8\"");

View File

@ -411,4 +411,20 @@ public class VCalendar extends VObject {
return recipients;
}
protected String getAttendeeStatus() {
String status = null;
List<VProperty> attendeeProperties = getFirstVeventProperties("ATTENDEE");
if (attendeeProperties != null) {
for (VProperty property : attendeeProperties) {
String attendeeEmail = getEmailValue(property);
if (email.equalsIgnoreCase(attendeeEmail) && property.hasParam("PARTSTAT")) {
// found current user attendee line
status = property.getParam("PARTSTAT").getValue();
break;
}
}
}
return status;
}
}

View File

@ -255,3 +255,7 @@ UI_IMAP_IDLE_DELAY_HELP=IMAP folder idle monitor delay in minutes, leave empty t
EXCEPTION_EWS_NOT_AVAILABLE=EWS end point not available
EXCEPTION_FOLDER_NOT_FOUND=Folder {0} not found
UNKNOWN_ATTRIBUTE=Unknown attribute: {0}
NEEDS-ACTION=
ACCEPTED=Accepted:
TENTATIVE=Tentative:
DECLINED=Declined:

View File

@ -255,3 +255,6 @@ UI_IMAP_AUTO_EXPUNGE_HELP=Supprimer imm
EXCEPTION_EWS_NOT_AVAILABLE=Point d''accès EWS non disponible
EXCEPTION_FOLDER_NOT_FOUND=Dossier {0} non trouvé
UNKNOWN_ATTRIBUTE=Attribut inconnu: {0}
ACCEPTED=Accepté :
TENTATIVE=Provisoire :
DECLINED=Refusé :

View File

@ -18,6 +18,7 @@
*/
package davmail.exchange;
import davmail.BundleMessage;
import junit.framework.TestCase;
import java.io.IOException;
@ -262,4 +263,17 @@ public class TestExchangeSessionEvent extends TestCase {
System.out.println(toClient);
}
public void testAttendeeStatus() throws IOException {
String itemBody = "BEGIN:VCALENDAR\n" +
"BEGIN:VEVENT\n" +
"ATTENDEE;PARTSTAT=ACCEPTED;RSVP=FALSE:MAILTO:" + email + "\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
VCalendar vCalendar = new VCalendar(itemBody, email, vTimeZone);
vCalendar.fixVCalendar(false);
String status = vCalendar.getAttendeeStatus();
assertEquals("ACCEPTED", status);
System.out.println("'"+BundleMessage.format(status)+"'");
}
}