Bug 1158036 - Support sendMailTo for URN type attendees;r=philipp

This commit is contained in:
MakeMyDay 2015-05-10 13:22:52 +02:00
Родитель f039d125f1
Коммит f82b211a11
5 изменённых файлов: 36 добавлений и 90 удалений

Просмотреть файл

@ -411,30 +411,8 @@ calMailButtonDNDObserver.prototype = {
*/ */
onDropItems: function(aItems) { onDropItems: function(aItems) {
if (aItems && aItems.length > 0) { if (aItems && aItems.length > 0) {
var item = aItems[0]; let item = aItems[0];
let recipients = cal.getRecipientList(item.getAttendees({}));
var recipients = "";
var attendees = item.getAttendees({});
for each (var attendee in attendees) {
if (attendee.id && attendee.id.length) {
var email = attendee.id;
var re = new RegExp("^mailto:(.*)", "i");
if (email && email.length) {
if (re.test(email)) {
email = RegExp.$1;
} else {
email = email;
}
}
// Prevent trailing commas.
if (recipients.length > 0) {
recipients += ",";
}
// Add this recipient id to the list.
recipients += email;
}
}
let identity = item.calendar.getProperty("imip.identity"); let identity = item.calendar.getProperty("imip.identity");
sendMailTo(recipients, item.title, item.getProperty("DESCRIPTION"), identity); sendMailTo(recipients, item.title, item.getProperty("DESCRIPTION"), identity);
} }

Просмотреть файл

@ -213,30 +213,13 @@ function taskViewUpdate(aFilter) {
function sendMailToOrganizer() { function sendMailToOrganizer() {
var item = document.getElementById("calendar-task-tree").currentTask; var item = document.getElementById("calendar-task-tree").currentTask;
if (item != null) { if (item != null) {
var organizer = item.organizer; let organizer = item.organizer;
if (organizer) { let email = cal.getAttendeeEmail(organizer, true);
if (organizer.id && organizer.id.length) { let emailSubject = cal.calGetString("calendar-event-dialog", "emailSubjectReply", [item.title]);
var email = organizer.id;
var re = new RegExp("^mailto:(.*)", "i");
if (email && email.length) {
if (re.test(email)) {
email = RegExp.$1;
} else {
email = email;
}
}
// Set up the subject
var emailSubject = calGetString("calendar-event-dialog",
"emailSubjectReply",
[item.title]);
let identity = item.calendar.getProperty("imip.identity"); let identity = item.calendar.getProperty("imip.identity");
sendMailTo(email, emailSubject, null, identity); sendMailTo(email, emailSubject, null, identity);
} }
} }
}
}
/** /**
* Handler function to observe changing of the calendar display deck. Updates * Handler function to observe changing of the calendar display deck. Updates

Просмотреть файл

@ -3665,33 +3665,9 @@ function sendMailToUndecidedAttendees(aAttendees) {
* @param aAttendees The attendees to send mail to. * @param aAttendees The attendees to send mail to.
*/ */
function sendMailToAttendees(aAttendees) { function sendMailToAttendees(aAttendees) {
var toList = ""; let toList = cal.getRecipientList(aAttendees);
var item = saveItem(); let item = saveItem();
let emailSubject = cal.calGetString("calendar-event-dialog", "emailSubjectReply", [item.title]);
for each (var attendee in aAttendees) {
if (attendee.id && attendee.id.length) {
var email = attendee.id;
var re = new RegExp("^mailto:(.*)", "i");
if (email && email.length) {
if (re.test(email)) {
email = RegExp.$1;
} else {
email = email;
}
}
// Prevent trailing commas.
if (toList.length > 0) {
toList += ",";
}
// Add this recipient id to the list.
toList += email;
}
}
// Set up the subject
var emailSubject = calGetString("calendar-event-dialog",
"emailSubjectReply",
[item.title]);
let identity = window.calendarItem.calendar.getProperty("imip.identity"); let identity = window.calendarItem.calendar.getProperty("imip.identity");
sendMailTo(toList, emailSubject, null, identity); sendMailTo(toList, emailSubject, null, identity);
} }

Просмотреть файл

@ -359,24 +359,14 @@ function browseDocument() {
* organizer an email. * organizer an email.
*/ */
function sendMailToOrganizer() { function sendMailToOrganizer() {
var args = window.arguments[0]; let args = window.arguments[0];
var item = args.calendarEvent; let item = args.calendarEvent;
let organizer = item.organizer;
var organizer = item.organizer; let email = cal.getAttendeeEmail(organizer, true);
if (organizer) { let emailSubject = cal.calGetString("calendar-event-dialog", "emailSubjectReply", [item.title]);
if (organizer.id && organizer.id.length) {
var email = organizer.id.replace(/^mailto:/i, "");
// Set up the subject
var emailSubject = calGetString("calendar-event-dialog",
"emailSubjectReply",
[item.title]);
let identity = item.calendar.getProperty("imip.identity"); let identity = item.calendar.getProperty("imip.identity");
sendMailTo(email, emailSubject, null, identity); sendMailTo(email, emailSubject, null, identity);
} }
}
}
/** /**
* This hack allows the attendees listbox to remain cropping when resized. * This hack allows the attendees listbox to remain cropping when resized.

Просмотреть файл

@ -330,6 +330,25 @@ let cal = {
return email; return email;
}, },
/**
* Provides a string to use in email "to" header for given attendees
*
* @param {array} aAttendees - array of calIAttendee's to check
* @return {string} Valid string to use in a 'to' header of an email
*/
getRecipientList: function (aAttendees) {
let cbEmail = function (aVal, aInd, aArr) {
let email = cal.getAttendeeEmail(aVal, true);
if (!email.length) {
cal.LOG("Dropping invalid recipient for email transport: " + aVal.toString());
}
return email;
}
return aToList.map(cbEmail)
.filter(function (aVal, aInd, aArr) {return (aVal.length)})
.join(', ');
},
/** /**
* Returns the default transparency to apply for an event depending on whether its an all-day event * Returns the default transparency to apply for an event depending on whether its an all-day event
* *