bug 379198 r=Philipp
git-svn-id: svn://10.0.0.236/trunk@246430 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -450,80 +450,12 @@ function checkForAttendees(aItem, aOriginalItem)
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Until we rethink attendee support and until such support
|
||||
// is worked into the event dialog (which has been done in the prototype
|
||||
// dialog to a degree) then we are going to simply hack in some attendee
|
||||
// support so that we can round-trip iTIP invitations.
|
||||
// Check to see if some part of the item was updated, if so, re-send invites
|
||||
if (!sendInvite && (aItem.generation != aOriginalItem.generation))
|
||||
sendInvite = true;
|
||||
|
||||
if (sendInvite) {
|
||||
// Since there is no way to determine the type of transport an
|
||||
// attendee requires, we default to email
|
||||
var emlSvc = Components.classes["@mozilla.org/calendar/itip-transport;1?type=email"]
|
||||
.createInstance(Components.interfaces.calIItipTransport);
|
||||
|
||||
var itipItem = Components.classes["@mozilla.org/calendar/itip-item;1"]
|
||||
.createInstance(Components.interfaces.calIItipItem);
|
||||
|
||||
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
||||
.getService(Components.interfaces.nsIStringBundleService);
|
||||
|
||||
var sb = sbs.createBundle("chrome://lightning/locale/lightning.properties");
|
||||
var recipients = [];
|
||||
|
||||
// We have to modify our item a little, so we clone it.
|
||||
var item = aItem.clone();
|
||||
|
||||
// Fix up our attendees for invitations using some good defaults
|
||||
itemAtt = item.getAttendees({}); // reuse cloned attendees
|
||||
item.removeAllAttendees();
|
||||
for each (var attendee in itemAtt) {
|
||||
attendee.role = "REQ-PARTICIPANT";
|
||||
attendee.participationStatus = "NEEDS-ACTION";
|
||||
attendee.rsvp = true;
|
||||
item.addAttendee(attendee);
|
||||
recipients.push(attendee);
|
||||
}
|
||||
|
||||
// XXX The event dialog has no means to set us as the organizer
|
||||
// since we defaulted to email above, we know we need to prepend
|
||||
// mailto when we convert it to an attendee
|
||||
var organizer = Components.classes["@mozilla.org/calendar/attendee;1"]
|
||||
.createInstance(Components.interfaces.calIAttendee);
|
||||
organizer.id = "mailto:" + emlSvc.defaultIdentity;
|
||||
organizer.role = "REQ-PARTICIPANT";
|
||||
organizer.participationStatus = "ACCEPTED";
|
||||
organizer.isOrganizer = true;
|
||||
|
||||
// Add our organizer to the item. Again, the event dialog really doesn't
|
||||
// have a mechanism for creating an item with a method, so let's add
|
||||
// that too while we're at it. We'll also fake Sequence ID support.
|
||||
item.organizer = organizer;
|
||||
item.setProperty("METHOD", "REQUEST");
|
||||
item.setProperty("SEQUENCE", "1");
|
||||
|
||||
var summary
|
||||
if (item.getProperty("SUMMARY")) {
|
||||
summary = item.getProperty("SUMMARY");
|
||||
} else {
|
||||
summary = "";
|
||||
}
|
||||
|
||||
// Initialize and set our properties on the item
|
||||
itipItem.init(item.icalString);
|
||||
itipItem.isSend = true;
|
||||
itipItem.receivedMethod = "REQUEST";
|
||||
itipItem.responseMethod = "REQUEST";
|
||||
itipItem.autoResponse = Components.interfaces.calIItipItem.USER;
|
||||
|
||||
// Get ourselves some default text - when we handle organizer properly
|
||||
// We'll need a way to configure the Common Name attribute and we should
|
||||
// use it here rather than the email address
|
||||
var subject = sb.formatStringFromName("itipRequestSubject",
|
||||
[summary], 1);
|
||||
var body = sb.formatStringFromName("itipRequestBody",
|
||||
[emlSvc.defaultIdentity, summary],
|
||||
2);
|
||||
|
||||
// Send it!
|
||||
emlSvc.sendItems(recipients.length, recipients, subject, body, itipItem);
|
||||
// Now use calUtils.js to send these
|
||||
sendItipInvitation(aItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,6 +164,13 @@ var calendarViewController = {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the item contains attendees then they need to be notified
|
||||
if (instance.hasProperty("X-MOZ-SEND-INVITATIONS") &&
|
||||
(instance.getProperty("X-MOZ-SEND-INVITATIONS") == "TRUE")) {
|
||||
sendItipInvitation(instance);
|
||||
}
|
||||
|
||||
doTransaction('modify', instance, instance.calendar, aOccurrence, null);
|
||||
} else {
|
||||
// prompt for choice between occurrence and master for recurrent items
|
||||
@@ -669,4 +676,3 @@ function selectAllEvents() {
|
||||
|
||||
composite.getItems(filter, 0, currentView().startDay, end, listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -2154,3 +2154,86 @@ calPropertyBagEnumerator.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
// Send iTIP invitation
|
||||
function sendItipInvitation(aItem) {
|
||||
// XXX Until we rethink attendee support and until such support
|
||||
// is worked into the event dialog (which has been done in the prototype
|
||||
// dialog to a degree) then we are going to simply hack in some attendee
|
||||
// support so that we can round-trip iTIP invitations.
|
||||
// Since there is no way to determine the type of transport an
|
||||
// attendee requires, we default to email
|
||||
var emlSvc = Components.classes["@mozilla.org/calendar/itip-transport;1?type=email"]
|
||||
.createInstance(Components.interfaces.calIItipTransport);
|
||||
|
||||
var itipItem = Components.classes["@mozilla.org/calendar/itip-item;1"]
|
||||
.createInstance(Components.interfaces.calIItipItem);
|
||||
|
||||
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
||||
.getService(Components.interfaces.nsIStringBundleService);
|
||||
|
||||
var sb = sbs.createBundle("chrome://lightning/locale/lightning.properties");
|
||||
var recipients = [];
|
||||
|
||||
// We have to modify our item a little, so we clone it.
|
||||
var item = aItem.clone();
|
||||
|
||||
// Fix up our attendees for invitations using some good defaults
|
||||
itemAtt = item.getAttendees({}); // reuse cloned attendees
|
||||
item.removeAllAttendees();
|
||||
for each (var attendee in itemAtt) {
|
||||
attendee.role = "REQ-PARTICIPANT";
|
||||
attendee.participationStatus = "NEEDS-ACTION";
|
||||
attendee.rsvp = true;
|
||||
item.addAttendee(attendee);
|
||||
recipients.push(attendee);
|
||||
}
|
||||
|
||||
// XXX The event dialog has no means to set us as the organizer
|
||||
// since we defaulted to email above, we know we need to prepend
|
||||
// mailto when we convert it to an attendee
|
||||
// This also means that when we are Updating an event, we will be making
|
||||
// a blatant assumption that you (the updater) are the organizer of the event.
|
||||
// This is probably ok since we don't support the iTIP COUNTER method,
|
||||
// but it would be better if we didn't allow you to modify an event that you
|
||||
// are not the organizer of and send out invitations to it as if you were.
|
||||
// For this support, we'll need a real invitation manager component.
|
||||
var organizer = Components.classes["@mozilla.org/calendar/attendee;1"]
|
||||
.createInstance(Components.interfaces.calIAttendee);
|
||||
organizer.id = "mailto:" + emlSvc.defaultIdentity;
|
||||
organizer.role = "REQ-PARTICIPANT";
|
||||
organizer.participationStatus = "ACCEPTED";
|
||||
organizer.isOrganizer = true;
|
||||
|
||||
// Add our organizer to the item. Again, the event dialog really doesn't
|
||||
// have a mechanism for creating an item with a method, so let's add
|
||||
// that too while we're at it. We'll also fake Sequence ID support.
|
||||
item.organizer = organizer;
|
||||
item.setProperty("METHOD", "REQUEST");
|
||||
item.setProperty("SEQUENCE", item.generation);
|
||||
|
||||
var summary
|
||||
if (item.getProperty("SUMMARY")) {
|
||||
summary = item.getProperty("SUMMARY");
|
||||
} else {
|
||||
summary = "";
|
||||
}
|
||||
|
||||
// Initialize and set our properties on the item
|
||||
itipItem.init(item.icalString);
|
||||
itipItem.isSend = true;
|
||||
itipItem.receivedMethod = "REQUEST";
|
||||
itipItem.responseMethod = "REQUEST";
|
||||
itipItem.autoResponse = Components.interfaces.calIItipItem.USER;
|
||||
|
||||
// Get ourselves some default text - when we handle organizer properly
|
||||
// We'll need a way to configure the Common Name attribute and we should
|
||||
// use it here rather than the email address
|
||||
var subject = sb.formatStringFromName("itipRequestSubject",
|
||||
[summary], 1);
|
||||
var body = sb.formatStringFromName("itipRequestBody",
|
||||
[emlSvc.defaultIdentity, summary],
|
||||
2);
|
||||
|
||||
// Send it!
|
||||
emlSvc.sendItems(recipients.length, recipients, subject, body, itipItem);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user