mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-27 02:07:12 +00:00
RFC6047 compliance (2)
This commit is contained in:
parent
086237f12b
commit
67fa8ca8e2
3 changed files with 22 additions and 21 deletions
|
@ -3719,6 +3719,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
Attendee attendee = new Attendee(name, email);
|
||||
//attendee.setCalendarUserType(CalendarUserType.INDIVIDUAL);
|
||||
//attendee.setRole(Role.ATTENDEE);
|
||||
//attendee.setRsvp(true);
|
||||
|
||||
if (action == R.id.btnCalendarAccept) {
|
||||
//ev.setStatus(Status.accepted());
|
||||
|
|
|
@ -235,7 +235,6 @@ import javax.mail.util.ByteArrayDataSource;
|
|||
import biweekly.Biweekly;
|
||||
import biweekly.ICalendar;
|
||||
import biweekly.component.VEvent;
|
||||
import biweekly.property.Method;
|
||||
import biweekly.property.Organizer;
|
||||
|
||||
public class FragmentCompose extends FragmentBase {
|
||||
|
@ -5284,19 +5283,11 @@ public class FragmentCompose extends FragmentBase {
|
|||
null);
|
||||
|
||||
if ("participation".equals(action)) {
|
||||
ICalendar icalendar = Biweekly.parse(ics).first();
|
||||
VEvent event = icalendar.getEvents().get(0);
|
||||
|
||||
// https://www.rfc-editor.org/rfc/rfc6047#section-2.4
|
||||
Method method = icalendar.getMethod();
|
||||
|
||||
EntityAttachment attachment = new EntityAttachment();
|
||||
attachment.message = data.draft.id;
|
||||
attachment.sequence = 1;
|
||||
attachment.name = "meeting.ics";
|
||||
attachment.type = "text/calendar;" +
|
||||
(method == null ? "" : " method=" + method.getValue() + ";") +
|
||||
" charset=UTF-8;";
|
||||
attachment.type = "text/calendar";
|
||||
attachment.disposition = Part.ATTACHMENT;
|
||||
attachment.size = ics.length();
|
||||
attachment.progress = null;
|
||||
|
@ -5305,6 +5296,8 @@ public class FragmentCompose extends FragmentBase {
|
|||
File file = attachment.getFile(context);
|
||||
ics.renameTo(file);
|
||||
|
||||
ICalendar icalendar = Biweekly.parse(file).first();
|
||||
VEvent event = icalendar.getEvents().get(0);
|
||||
Organizer organizer = event.getOrganizer();
|
||||
if (organizer != null) {
|
||||
String email = organizer.getEmail();
|
||||
|
|
|
@ -137,6 +137,7 @@ import javax.mail.internet.ParseException;
|
|||
|
||||
import biweekly.Biweekly;
|
||||
import biweekly.ICalendar;
|
||||
import biweekly.property.Method;
|
||||
|
||||
public class MessageHelper {
|
||||
private boolean ensuredEnvelope = false;
|
||||
|
@ -1085,6 +1086,22 @@ public class MessageHelper {
|
|||
altMultiPart.addBodyPart(plainPart);
|
||||
altMultiPart.addBodyPart(htmlPart);
|
||||
|
||||
for (EntityAttachment attachment : attachments)
|
||||
if (attachment.available &&
|
||||
"text/calendar".equals(attachment.type)) {
|
||||
File file = attachment.getFile(context);
|
||||
ICalendar icalendar = Biweekly.parse(file).first();
|
||||
Method method = (icalendar == null ? null : icalendar.getMethod());
|
||||
if (method != null && method.isReply()) {
|
||||
// https://www.rfc-editor.org/rfc/rfc6047#section-2.4
|
||||
BodyPart calPart = new MimeBodyPart();
|
||||
calPart.setContent(icalendar.write(), attachment.type + ";" +
|
||||
" method=" + method.getValue() + ";" +
|
||||
" charset=UTF-8;");
|
||||
altMultiPart.addBodyPart(calPart);
|
||||
}
|
||||
}
|
||||
|
||||
int availableAttachments = 0;
|
||||
boolean hasInline = false;
|
||||
for (EntityAttachment attachment : attachments)
|
||||
|
@ -1131,17 +1148,7 @@ public class MessageHelper {
|
|||
public String getContentType(File file) {
|
||||
// https://tools.ietf.org/html/rfc6047
|
||||
if ("text/calendar".equals(attachment.type))
|
||||
try {
|
||||
ICalendar icalendar = Biweekly.parse(file).first();
|
||||
if (icalendar != null &&
|
||||
icalendar.getMethod() != null &&
|
||||
icalendar.getMethod().isReply())
|
||||
return "text/calendar" +
|
||||
"; method=REPLY" +
|
||||
"; charset=" + Charset.defaultCharset().name();
|
||||
} catch (IOException ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
return attachment.type + "; charset=UTF-8;";
|
||||
|
||||
return attachment.type;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue