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

Caldav: improve MIME message headers in createOrUpdateEvent

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@858 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-11-25 21:58:25 +00:00
parent 849ba11a5e
commit 98bd73aa16

View File

@ -72,20 +72,25 @@ public class ExchangeSession {
public static final SimpleTimeZone GMT_TIMEZONE = new SimpleTimeZone(0, "GMT"); public static final SimpleTimeZone GMT_TIMEZONE = new SimpleTimeZone(0, "GMT");
protected static final Set<String> USER_NAME_FIELDS = new HashSet<String>(); protected static final Set<String> USER_NAME_FIELDS = new HashSet<String>();
static { static {
USER_NAME_FIELDS.add("username"); USER_NAME_FIELDS.add("username");
USER_NAME_FIELDS.add("txtUserName"); USER_NAME_FIELDS.add("txtUserName");
USER_NAME_FIELDS.add("userid"); USER_NAME_FIELDS.add("userid");
USER_NAME_FIELDS.add("SafeWordUser"); USER_NAME_FIELDS.add("SafeWordUser");
} }
protected static final Set<String> PASSWORD_FIELDS = new HashSet<String>(); protected static final Set<String> PASSWORD_FIELDS = new HashSet<String>();
static { static {
PASSWORD_FIELDS.add("password"); PASSWORD_FIELDS.add("password");
PASSWORD_FIELDS.add("txtUserPass"); PASSWORD_FIELDS.add("txtUserPass");
PASSWORD_FIELDS.add("pw"); PASSWORD_FIELDS.add("pw");
PASSWORD_FIELDS.add("basicPassword"); PASSWORD_FIELDS.add("basicPassword");
} }
protected static final Set<String> TOKEN_FIELDS = new HashSet<String>(); protected static final Set<String> TOKEN_FIELDS = new HashSet<String>();
static { static {
TOKEN_FIELDS.add("SafeWordPassword"); TOKEN_FIELDS.add("SafeWordPassword");
} }
@ -2361,14 +2366,16 @@ public class ExchangeSession {
} }
} }
Participants participants = new Participants(); Participants participants = new Participants();
StringBuilder result = new StringBuilder(); if (!attendees.isEmpty()) {
for (String recipient : attendees) { StringBuilder result = new StringBuilder();
if (result.length() > 0) { for (String recipient : attendees) {
result.append(", "); if (result.length() > 0) {
result.append(", ");
}
result.append(recipient);
} }
result.append(recipient); participants.attendees = result.toString();
} }
participants.attendees = result.toString();
participants.organizer = organizer; participants.organizer = organizer;
return participants; return participants;
} }
@ -2394,6 +2401,11 @@ public class ExchangeSession {
"Content-class: "); "Content-class: ");
writer.write(contentClass); writer.write(contentClass);
writer.write("\r\n"); writer.write("\r\n");
// append date
SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss Z", Locale.ENGLISH);
writer.write("Date: ");
writer.write(formatter.format(new Date()));
writer.write("\r\n");
if ("urn:content-classes:calendarmessage".equals(contentClass)) { if ("urn:content-classes:calendarmessage".equals(contentClass)) {
// need to parse attendees and organizer to build recipients // need to parse attendees and organizer to build recipients
Participants participants = getParticipants(icsBody, true); Participants participants = getParticipants(icsBody, true);
@ -2423,16 +2435,21 @@ public class ExchangeSession {
// need to parse attendees and organizer to build recipients // need to parse attendees and organizer to build recipients
Participants participants = getParticipants(icsBody, false); Participants participants = getParticipants(icsBody, false);
// storing appointment, full recipients header // storing appointment, full recipients header
writer.write("To: ");
if (participants.attendees != null) { if (participants.attendees != null) {
writer.write("To: ");
writer.write(participants.attendees); writer.write(participants.attendees);
writer.write("\r\n"); } else {
writer.write(email);
} }
writer.write("\r\n");
writer.write("From: ");
if (participants.organizer != null) { if (participants.organizer != null) {
writer.write("From: ");
writer.write(participants.organizer); writer.write(participants.organizer);
writer.write("\r\n"); } else {
writer.write(email);
} }
writer.write("\r\n");
// if not organizer, set REPLYTIME to force Outlook in attendee mode // if not organizer, set REPLYTIME to force Outlook in attendee mode
if (participants.organizer != null && !email.equalsIgnoreCase(participants.organizer)) { if (participants.organizer != null && !email.equalsIgnoreCase(participants.organizer)) {
if (icsBody.indexOf("METHOD:") < 0) { if (icsBody.indexOf("METHOD:") < 0) {