Commit 41e02234 authored by Mechtilde's avatar Mechtilde

New upstream version 4.0.0~beta2

parent b0004b3b
This diff is collapsed.
......@@ -12,10 +12,14 @@ overlay chrome://calendar/content/calendar-calendars-list.xul chrome://exchangec
overlay chrome://messenger/content/messenger.xul chrome://exchangecalendar/content/progress_panel.xul
overlay chrome://calendar/content/calendar-task-view.xul chrome://exchangecalendar/content/messenger_task_delegation.xul
overlay chrome://lightning/content/lightning-standalone.xul chrome://exchangecalendar/content/progress_panel.xul
overlay chrome://calendar/content/calendar-event-dialog.xul chrome://exchangecalendar/content/calendar-event-dialog.xul
overlay chrome://lightning/content/lightning-item-iframe.xul chrome://exchangecalendar/content/lightning-item-iframe.xul
overlay chrome://calendar/content/calendar-event-dialog-reminder.xul chrome://exchangecalendar/content/calendar-event-dialog-reminder.xul
overlay chrome://calendar/content/calendar-summary-dialog.xul chrome://exchangecalendar/content/calendar-summary-dialog.xul
overlay chrome://calendar/content/calendar-properties-dialog.xul chrome://exchangecalendar/content/calendar-properties-dialog.xul
overlay chrome://messenger/content/messenger.xul chrome://exchangecalendar/content/sharedCalendarParser.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6}
overlay chrome://messenger/content/messenger.xul chrome://exchangecalendar/content/check4lightning.xul
overlay chrome://messenger/content/preferences/preferences.xul chrome://exchangecalendar/content/messenger-overlay-preferences.xul
......
......@@ -44,6 +44,7 @@ function exchAttachments(aDocument, aWindow)
}
exchAttachments.prototype = {
_initialized: false,
addAttachmentDialog: function _addAttachmentDialog()
{
......@@ -227,45 +228,75 @@ exchAttachments.prototype = {
}
},
/**
* Receives asynchronous messages from the parent context that contains the iframe.
*
* @param {MessageEvent} aEvent Contains the message being received
*/
receiveMessage: function _receiveMessage(aEvent) {
let validOrigin = gTabmail ? "chrome://messenger" : "chrome://calendar";
if (aEvent.origin !== validOrigin) {
return;
}
switch (aEvent.data.command) {
case "exchWebService_addAttachmentDialog": this.addAttachmentDialog(); break;
}
},
onLoad: function _onLoad()
{
if(this._initialized){
return;
}
var self = this;
if (this._document.getElementById("calendar-task-tree")) {
this.globalFunctions.LOG(" -- calendar-task-tree --");
var self = this;
this._document.getElementById("calendar-task-tree").addEventListener("select", function(){ self.onSelectTask();}, true);
return;
}
}
var args = this._window.arguments[0];
var item = args.calendarEvent;
//this.globalFunctions.LOG(" -- onLoad 2 ("+this.globalFunctions.STACKshort()+")");
this.attachmentListboxVisible = false;
// We can't update toolbar from iframe
if ((item.calendar) && (item.calendar.type == "exchangecalendar")) {
this.globalFunctions.LOG(" -- It is an Exchange Calendar event:"+item.title);
try {
// Hide Lightning URL button
this._document.getElementById("button-url").hidden = true;
this._document.getElementById("event-toolbar").setAttribute("currentset", "button-save,button-attendees,button-privacy,button-url,exchWebService-add-attachment-button,button-delete");
this._document.getElementById("exchWebService-add-attachment-button").hidden = false;
if(this._document.getElementById("options-attachments-menuitem")){
this._document.getElementById("options-attachments-menuitem").setAttribute("label", this._document.getElementById("exchWebService-add-attachment-button").getAttribute("label"));
this._document.getElementById("options-attachments-menuitem").setAttribute("command", "exchWebService_addAttachmentDialog");
}
if (this._document.getElementById("event-grid-attachment-row")) {
this._document.getElementById("event-grid-attachment-row").collapsed = true;
}
catch (ex) {this.globalFunctions.LOG(" -- Could not add exchange attachment buttons:"+ex.toString());}
// calendar-event-dialog (hide existing attachment view)
try {
this._document.getElementById("event-grid-attachment-row").setAttribute("collapsed", "true");
}
catch (ex) {}
// Modify context menu for the attachment list inside the "Attachment" panel
let attachmentListbox = this._document.getElementById("attachment-link");
attachmentListbox.context = "exchWebService-attachment-popup" ;
attachmentListbox.onkeypress = function (aEvent) { self.onKeyPress(aEvent); };
attachmentListbox.onclick = function (aEvent) { self.onSelect(aEvent); };
attachmentListbox.ondblclick = function (aEvent) { self.onDblClick(aEvent); };
this.addAttachmentsFromItem(item);
} else {
if (this._document.getElementById("event-grid-attachment-row")) {
this._document.getElementById("event-grid-attachment-row").collapsed = false;
}
// Modify context menu for the attachment list inside the "Attachment" panel
let attachmentListbox = this._document.getElementById("attachment-link");
attachmentListbox.context = "attachment-popup" ;
attachmentListbox.onkeypress="attachmentLinkKeyPress(event)" ;
attachmentListbox.onclick="attachmentClick(event);" ;
attachmentListbox.ondblclick="attachmentDblClick(event)" ;
}
// Add message listener to be able to receive message from parent window or tab
window.addEventListener("message", function(aEvent) { self.receiveMessage(aEvent); }, false);
this._initialized = true;
},
addAttachmentsFromItem: function _addAttachmentsFromItem(aItem)
......@@ -584,6 +615,6 @@ exchAttachments.prototype = {
}
var tmpAttachment = new exchAttachments(document, window);
window.addEventListener("load", function _onLoad() { window.removeEventListener("load",arguments.callee,false); tmpAttachment.onLoad(); }, true);
window.addEventListener("load", function _onLoad() { tmpAttachment.onLoad(); }, false);
......@@ -47,20 +47,19 @@
<overlay id="exchWebService-attachment-view"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://exchangecalendar/content/attachments-view.js"/>
<script type="application/javascript" src="chrome://exchangecalendar/content/attachments-view.js"/>
<!-- Commands -->
<commandset id="itemCommands">
<commandset>
<command id="exchWebService_openAttachment"
oncommand="tmpAttachment.openAttachment();"/>
oncommand="tmpAttachment.openAttachment();"/>
<command id="exchWebService_saveAttachment"
oncommand="tmpAttachment.saveAttachment();"/>
oncommand="tmpAttachment.saveAttachment();"/>
<command id="exchWebService_deleteAttachment"
oncommand="tmpAttachment.deleteAttachment();"/>
<command id="exchWebService_addAttachmentDialog"
oncommand="tmpAttachment.addAttachmentDialog();"/>
oncommand="tmpAttachment.deleteAttachment();"/>
</commandset>
<!-- Update context popup-->
<popupset id="event-dialog-popupset">
<menupopup id="exchWebService-attachment-popup">
<menuitem id="exchWebService-attachment-popup-open"
......@@ -74,26 +73,9 @@
<menuitem id="exchWebService-attachment-popup-delete"
label="&event.menu.item.delete.label;"
accesskey="&event.menu.item.delete.accesskey;"
disable-on-readonly="true"
disable-on-readonly="true"
command="exchWebService_deleteAttachment"/>
</menupopup>
</popupset>
<toolbarpalette id="event-toolbarpalette">
<toolbarbutton id="exchWebService-add-attachment-button"
mode="dialog"
class="cal-event-toolbarbutton toolbarbutton-1"
label="&exchWebServie.add.attachment.button.label;"
disable-on-readonly="true"
removable="true"
command="exchWebService_addAttachmentDialog"
oncommand="tmpAttachment.addAttachmentDialog();"
hidden="true"/>
</toolbarpalette>
<toolbar id="event-toolbar" defaultset="button-save,button-attendees,button-privacy,button-url,exchWebService-add-attachment-button,button-delete">
</toolbar>
</overlay>
/* ***** BEGIN LICENSE BLOCK *****
* Version: GPL 3.0
*
* The contents of this file are subject to the General Public License
* 3.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.gnu.org/licenses/gpl.html
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* -- Exchange 2007/2010 Calendar and Tasks Provider.
* -- For Thunderbird with the Lightning add-on.
*
* Author: Michel Verbraak (info@1st-setup.nl)
* Website: http://www.1st-setup.nl/wordpress/?page_id=133
* email: exchangecalendar@extensions.1st-setup.nl
*
*
* This code uses parts of the Microsoft Exchange Calendar Provider code on which the
* "Exchange Data Provider for Lightning" was based.
* The Initial Developer of the Microsoft Exchange Calendar Provider Code is
* Andrea Bittau <a.bittau@cs.ucl.ac.uk>, University College London
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* ***** BEGIN LICENSE BLOCK *****/
var Cu = Components.utils;
var Ci = Components.interfaces;
var Cc = Components.classes;
Cu.import("resource://calendar/modules/calUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function exchangeEventDialog(aDocument, aWindow)
function exchCalendarEventDialog(aDocument, aWindow)
{
this._document = aDocument;
this._window = aWindow;
......@@ -43,376 +13,47 @@ function exchangeEventDialog(aDocument, aWindow)
.getService(Ci.mivFunctions);
}
exchangeEventDialog.prototype = {
_initialized: false,
_oldCallback: null,
exchCalendarEventDialog.prototype = {
/*
* onAcceptCallback: read caller content to save extra information if caller was exchangecalendar
* setup menu window and button toolbars when editing an Exchange item
*/
onAcceptCallback: function _onAcceptCallback(aItem, aCalendar, aOriginalItem, aIsClosing)
{
if (aCalendar.type === "exchangecalendar") {
if (cal.isEvent(aItem)) {
if (!aItem.className) {
var newItem = Cc["@1st-setup.nl/exchange/calendarevent;1"]
.createInstance(Ci.mivExchangeEvent);
newItem.cloneToCalEvent(aItem);
aItem = newItem;
}
}
else if (!cal.isEvent(aItem)) {
// Save extra exchange fields to item.
if (!aItem.className) {
var newItem = Cc["@1st-setup.nl/exchange/calendartodo;1"]
.createInstance(Ci.mivExchangeTodo);
newItem.cloneToCalEvent(aItem);
aItem = newItem;
}
aItem.totalWork = this._document.getElementById("exchWebService-totalWork-count").value;
aItem.actualWork = this._document.getElementById("exchWebService-actualWork-count").value;
aItem.mileage = this._document.getElementById("exchWebService-mileage-count").value;
aItem.billingInformation = this._document.getElementById("exchWebService-billingInformation-count").value;
aItem.companies = this._document.getElementById("exchWebService-companies-count").value;
}
}
try{
if (this.newItem) {
aItem.bodyType = "HTML";
aItem.body = this._document.getElementById("exchWebService-body-editor").content;
}
else if (aItem.bodyType === "HTML") {
aItem.body = this._document.getElementById("exchWebService-body-editor").content;
}
} catch(err) {
dump("Error saving content\n");
}
if (this._oldCallback) {
this._oldCallback(aItem, aCalendar, aOriginalItem, aIsClosing);
}
},
// This will remove the time value from the repeat part and tooltip.
updateRepeat: function _updateRepeat()
{
var repeatDetails = this._document.getElementById("repeat-details").childNodes;
if (repeatDetails.length === 3) {
this._document.getElementById("repeat-details").removeChild(repeatDetails[2]);
var toolTip = repeatDetails[0].getAttribute("tooltiptext");
var tmpArray = toolTip.split("\n");
tmpArray.splice(2,1);
repeatDetails[0].setAttribute("tooltiptext", tmpArray.join("\n"));
repeatDetails[1].setAttribute("tooltiptext", tmpArray.join("\n"));
}
},
updateScreen: function _updateScreen(aItem, aCalendar)
{
var item = aItem;
// If not an event and calendar type is exchangeCalendar, update Attendees dialog
if (!cal.isEvent(item)
&& aCalendar.type === "exchangecalendar") {
var ownerLabel = this._document.getElementById("exchWebService-owner-label");
if (ownerLabel) {
ownerLabel.value = item.owner;
}
try {
this._document.getElementById("exchWebService-details-row1").removeAttribute("collapsed");
this._document.getElementById("exchWebService-details-row2").removeAttribute("collapsed");
this._document.getElementById("exchWebService-details-row3").removeAttribute("collapsed");
}
catch (ex) {
}
this._document.getElementById("exchWebService-owner-row").setAttribute("collapsed", "false");
this._document.getElementById("exchWebService-details-separator").hidden = false;
if (item.className) {
this._document.getElementById("exchWebService-totalWork-count").value = item.totalWork;
this._document.getElementById("exchWebService-actualWork-count").value = item.actualWork;
this._document.getElementById("exchWebService-mileage-count").value = item.mileage;
this._document.getElementById("exchWebService-billingInformation-count").value = item.billingInformation;
this._document.getElementById("exchWebService-companies-count").value = item.companies;
}
this._document.getElementById("event-grid-location-row").hidden = true;
// Clear reminder select list for todo
this._document.getElementById("reminder-none-separator").hidden = true;
this._document.getElementById("reminder-0minutes-menuitem").hidden = true;
this._document.getElementById("reminder-5minutes-menuitem").hidden = true;
this._document.getElementById("reminder-15minutes-menuitem").hidden = true;
this._document.getElementById("reminder-30minutes-menuitem").hidden = true;
this._document.getElementById("reminder-minutes-separator").hidden = true;
this._document.getElementById("reminder-1hour-menuitem").hidden = true;
this._document.getElementById("reminder-2hours-menuitem").hidden = true;
this._document.getElementById("reminder-12hours-menuitem").hidden = true;
this._document.getElementById("reminder-hours-separator").hidden = true;
this._document.getElementById("reminder-1day-menuitem").hidden = true;
this._document.getElementById("reminder-2days-menuitem").hidden = true;
this._document.getElementById("reminder-1week-menuitem").hidden = true;
// Clear timezone start/end time
this._document.getElementById("timezone-starttime").hidden = true;
this._document.getElementById("timezone-endtime").hidden = true;
if (this._document.getElementById("item-repeat")) {
this._document.getElementById("item-repeat").addEventListener("command", function() { self.updateRepeat(); }, false);
}
this.updateRepeat();
}
// For other item type and other calendar type, reset Atttendees dialog
else {
try {
this._document.getElementById("exchWebService-details-row1").setAttribute("collapsed", "true");
this._document.getElementById("exchWebService-details-row2").setAttribute("collapsed", "true");
this._document.getElementById("exchWebService-details-row3").setAttribute("collapsed", "true");
}
catch (ex) {}
this._document.getElementById("exchWebService-owner-row").setAttribute("collapsed", "true");
this._document.getElementById("exchWebService-details-separator").hidden = true;
this._document.getElementById("event-grid-location-row").hidden = false;
this._document.getElementById("event-grid-recurrence-row").hidden=false;
// Reset reminder select list for todo
this._document.getElementById("reminder-none-separator").hidden = false;
this._document.getElementById("reminder-0minutes-menuitem").hidden = false;
this._document.getElementById("reminder-5minutes-menuitem").hidden = false;
this._document.getElementById("reminder-15minutes-menuitem").hidden = false;
this._document.getElementById("reminder-30minutes-menuitem").hidden = false;
this._document.getElementById("reminder-minutes-separator").hidden = false;
this._document.getElementById("reminder-1hour-menuitem").hidden = false;
this._document.getElementById("reminder-2hours-menuitem").hidden = false;
this._document.getElementById("reminder-12hours-menuitem").hidden = false;
this._document.getElementById("reminder-hours-separator").hidden = false;
this._document.getElementById("reminder-1day-menuitem").hidden = false;
this._document.getElementById("reminder-2days-menuitem").hidden = false;
this._document.getElementById("reminder-1week-menuitem").hidden = false;
// Reset timezone start/end time
this._document.getElementById("timezone-starttime").hidden = false;
this._document.getElementById("timezone-endtime").hidden = false;
}
},
/*
* onLoad: setup event dialog window
* - Add callback
**/
onLoad: function _onLoad()
{
if (this._document.getElementById("exchWebService-body-editor")) {
this._document.getElementById("exchWebService-body-editor").setAttribute("scrollbars","yes");
}
if (this._window.arguments[0].calendarEvent.calendar.type != "exchangecalendar") {
if (this._document.getElementById("item-description")) {
this._document.getElementById("item-description").hidden = false;
}
if (this._document.getElementById("exchWebService-body-editor")) {
this._document.getElementById("exchWebService-body-editor").hidden = true;
}
return;
}
if (this._initialized) {
return;
}
// Set window.calendarItem to be able to call getCalendar()
var args = this._window.arguments[0];
var item = args.calendarEvent;
this._window.calendarItem = item.clone();
// Override dialog callback to add extra exchangecalendar information processing
this._oldCallback = this._window.onAcceptCallback;
var self = this;
this._window.onAcceptCallback = function(aItem, aCalendar, aOriginalItem, aIsClosing) {
self.onAcceptCallback(aItem, aCalendar, aOriginalItem, aIsClosing);
};
// If DOM contain a "todo-entrydate", we check if we need to display our HTML body editor
if (this._document.getElementById("todo-entrydate")) {
this._initialized = true;
this.updateScreen(item, item.calendar);
// Display (or not) our body HTML editor
if (item.bodyType === undefined // item is not already defined
|| item.bodyType.toLowerCase() === "html" // current item contains HTML
) {
// Hidde original item description
if (this._document.getElementById("item-description")) {
this._document.getElementById("item-description").hidden = true;
}
// Display our own body editor
if (this._document.getElementById("exchWebService-body-editor")) {
this._document.getElementById("exchWebService-body-editor").hidden = false;
}
}
// Set content to our body HTML editor
// If item contains already HTML content, just use it
if (item.bodyType.toLowerCase() === "html") {
this._document.getElementById("exchWebService-body-editor").content = item.body;
}
else {
this.newItem = true;
}
// If the body is already filled and it contains HTML, save it to our body editor
if (item.body
&& item.body.toLowerCase().indexOf("<body>") > -1) {
this._document.getElementById("exchWebService-body-editor").content = item.body;
}
else {
// Otherwise, translate the DESCRIPTION property to HTML and give it to editor
this._document.getElementById("exchWebService-body-editor").content = this.globalFunctions.fromText2HTML(item.getProperty("DESCRIPTION"));
}
}
else {
// DOM doesn't contain "todo-entrydate"
// Display original editor and hidde our own HTML body editor
if (this._document.getElementById("item-description")) {
this._document.getElementById("item-description").hidden = false;
}
if (this._document.getElementById("exchWebService-body-editor")) {
this._document.getElementById("exchWebService-body-editor").hidden = true;
}
}
},
/*
* selectedCalendarChanged: modify event-dialog to add extra exchangecalendar info when an exchange calendar is selected
*/
selectedCalendarChanged: function _selectedCalendarChanged(aMenuList)
{
updateCalendar();
this.updateScreen(this._window.calendarItem, getCurrentCalendar());
},
/*
* editAttendees: call editAttendees with some already known informations
*/
editAttendees: function _editAttendees() {
var eventDialog = this._window;
var calendar = eventDialog.getCurrentCalendar();
let args = this._window.arguments[0];
let item = args.calendarEvent;
var callback = function (attendees, organizer, startTime, endTime) {
eventDialog.attendees = attendees;
// We can't update toolbar from iframe
if ((item.calendar) && (item.calendar.type == "exchangecalendar")) {
if (organizer) {
// In case we didn't have an organizer object before we
// added attendees to our event we take the one created
// by the 'invite attendee'-dialog.
if (eventDialog.organizer) {
// The other case is that we already had an organizer object
// before we went throught the 'invite attendee'-dialog. In that
// case make sure we don't carry over attributes that have been
// set to their default values by the dialog but don't actually
// exist in the original organizer object.
if (!eventDialog.organizer.id) {
organizer.id = null;
}
if (!eventDialog.organizer.role) {
organizer.role = null;
}
if (!eventDialog.organizer.participationStatus) {
organizer.participationStatus = null;
}
if (!eventDialog.organizer.commonName) {
organizer.commonName = null;
}
}
eventDialog.organizer = organizer;
}
let eventToolbar = this._document.getElementById("event-toolbar");
var duration = endTime.subtractDate(startTime);
var startTime = startTime.clone();
var endTime = endTime.clone();
var kDefaultTimezone = calendarDefaultTimezone();
var gStartTimezone = startTime.timezone;
var gEndTimezone = endTime.timezone;
var gStartTime = startTime.getInTimezone(kDefaultTimezone);
var gEndTime = endTime.getInTimezone(kDefaultTimezone);
var gItemDuration = duration;
updateDateTime();
updateAllDay();
if (isAllDay != gStartTime.isDate) {
setShowTimeAs(gStartTime.isDate)
// If the standard add url button was enabled, hidde it and show exchangecalendar attachment
let currentSet = eventToolbar.getAttribute("currentset");
if (currentSet.indexOf("button-url") === 1
&& currentSet.indexOf("exchWebService-add-attachment-button") === -1) {
currentSet = currentSet.replace("button-url", "exchWebService-add-attachment-button");
}
};
var startTime = {};
var endTime = {};
// Switch toolbar buttons display
this._document.getElementById("button-url").hidden = true;
this._document.getElementById("exchWebService-add-attachment-button").hidden = false;
if (eventDialog.gStartTime) {
startTime = eventDialog.gStartTime.getInTimezone(eventDialog.gStartTimezone);
}
if (eventDialog.gEndTime) {
endTime = eventDialog.gEndTime.getInTimezone(eventDialog.gEndTimezone);
}
// Switch window menu display
this._document.getElementById("options-attachments-menu").collapsed = true;
this._document.getElementById("exchWebService-options-attachments").collapsed = false;
var isAllDay = null;
var isAllDayBox = this._document.getElementById("event-all-day");
if (isAllDayBox) {
isAllDay = isAllDayBox.getAttribute('checked');
}
if (isAllDay) {