Commit f4c1ad9b authored by Markus Weiland's avatar Markus Weiland Committed by GitHub

Merge pull request #189 from llange/thunderbird-60-2nd-try

Second try towards making it work for thunderbird 60
parents a4fbd262 87b2a933
......@@ -107,17 +107,21 @@ erExpandDLRequest.prototype = {
rm = null;
var allMailboxes = new Array();
for each(var expansion in dlExpansion) {
if (dlExpansion) {
for (var expansion of Object.values(dlExpansion)) {
var totalItemsInView = expansion.getAttribute("TotalItemsInView", 0);
var includesLastItem = expansion.getAttribute("IncludesLastItemInRange", "false");
var totalItemsInView = expansion.getAttribute("TotalItemsInView", 0);
var includesLastItem = expansion.getAttribute("IncludesLastItemInRange", "false");
var mailboxes = expansion.getTags("t:Mailbox");
for each(var mailbox in mailboxes) {
allMailboxes.push(mailbox);
}
mailboxes = null;
var mailboxes = expansion.getTags("t:Mailbox");
if (mailboxes) {
for (var mailbox of Object.values(mailboxes)) {
allMailboxes.push(mailbox);
}
}
mailboxes = null;
}
}
dlExpansion = null;
......
......@@ -132,24 +132,32 @@ erFindContactsRequest.prototype = {
return;
}
for each(var contact in rootFolder[0].XPath("/t:Items/t:Contact")) {
exchWebService.commonAbFunctions.logInfo("erFindContactsRequest.contacts: id:" + contact.getAttributeByTag("t:ItemId", "Id") + ", changekey:" + contact.getAttributeByTag("t:ItemId", "ChangeKey"));
this.contacts.push({
Id: contact.getAttributeByTag("t:ItemId", "Id"),
ChangeKey: contact.getAttributeByTag("t:ItemId", "ChangeKey"),
name: contact.getTagValue("t:Subject"),
displayName: contact.getTagValue("t:DisplayName")
});
var contact_result = rootFolder[0].XPath("/t:Items/t:Contact");
if (contact_result) {
for (var contact of Object.values(contact_result)) {
exchWebService.commonAbFunctions.logInfo("erFindContactsRequest.contacts: id:" + contact.getAttributeByTag("t:ItemId", "Id") + ", changekey:" + contact.getAttributeByTag("t:ItemId", "ChangeKey"));
this.contacts.push({
Id: contact.getAttributeByTag("t:ItemId", "Id"),
ChangeKey: contact.getAttributeByTag("t:ItemId", "ChangeKey"),
name: contact.getTagValue("t:Subject"),
displayName: contact.getTagValue("t:DisplayName")
});
}
}
for each(var distlist in rootFolder[0].XPath("/t:Items/t:DistributionList")) {
this.distlists.push({
Id: distlist.getAttributeByTag("t:ItemId", "Id"),
ChangeKey: distlist.getAttributeByTag("t:ItemId", "ChangeKey"),
name: distlist.getTagValue("t:Subject"),
displayName: distlist.getTagValue("t:DisplayName")
});
contact_result = null;
var distributionlist_result = rootFolder[0].XPath("/t:Items/t:DistributionList");
if (distributionlist_result) {
for (var distlist of Object.values(distributionlist_result)) {
this.distlists.push({
Id: distlist.getAttributeByTag("t:ItemId", "Id"),
ChangeKey: distlist.getAttributeByTag("t:ItemId", "ChangeKey"),
name: distlist.getTagValue("t:Subject"),
displayName: distlist.getTagValue("t:DisplayName")
});
}
}
distributionlist_result = null;
// RootFolder attributes received after a FindItem request:
// https://msdn.microsoft.com/EN-US/library/office/aa493859%28v=exchg.150%29.aspx
......
......@@ -103,13 +103,15 @@ erGetContactsRequest.prototype = {
itemids = null;
var itemids = req.addChildTag("ItemIds", "nsMessages", null);
for each(var item in this.ids) {
var itemId = itemids.addChildTag("ItemId", "nsTypes", null);
itemId.setAttribute("Id", item.Id);
if (item.ChangeKey) {
itemId.setAttribute("ChangeKey", item.ChangeKey);
if (this.ids) {
for (var item of Object.values(this.ids)) {
var itemId = itemids.addChildTag("ItemId", "nsTypes", null);
itemId.setAttribute("Id", item.Id);
if (item.ChangeKey) {
itemId.setAttribute("ChangeKey", item.ChangeKey);
}
itemId = null;
}
itemId = null;
}
itemids = null;
......
......@@ -127,16 +127,20 @@ erResolveNames.prototype = {
else {
var resolutionsSets = rm[0].getTags("m:ResolutionSet");
for each(var resolutionsSet in resolutionsSets) {
if (resolutionsSets) {
for (var resolutionsSet of Object.values(resolutionsSets)) {
var totalItemsInView = resolutionsSet.getAttribute("TotalItemsInView", 0);
var includesLastItem = resolutionsSet.getAttribute("IncludesLastItemInRange", "false");
var totalItemsInView = resolutionsSet.getAttribute("TotalItemsInView", 0);
var includesLastItem = resolutionsSet.getAttribute("IncludesLastItemInRange", "false");
var resList = resolutionsSet.XPath("/t:Resolution");
for each(var resolution in resList) {
allResolutions.push(resolution);
}
var resList = resolutionsSet.XPath("/t:Resolution");
if (resList) {
for (var resolution of Object.values(resList)) {
allResolutions.push(resolution);
}
}
}
}
resolutionsSets = null;
}
......
......@@ -142,51 +142,79 @@ erSyncContactsFolderRequest.prototype = {
var lastItemInRange = rm[0].getTagValue("m:IncludesLastItemInRange");
for each(var creation in rm[0].XPath("/m:Changes/t:Create")) {
for each(var contact in creation.XPath("/t:Contact")) {
//this.creations.contacts.push(contact);
this.creations.contacts.push({
Id: contact.getAttributeByTag("t:ItemId", "Id"),
ChangeKey: contact.getAttributeByTag("t:ItemId", "ChangeKey"),
name: contact.getTagValue("t:Subject"),
displayName: contact.getTagValue("t:DisplayName")
});
}
for each(var distlist in creation.XPath("/t:DistributionList")) {
//this.creations.distlists.push(distlist);
this.creations.distlists.push({
Id: distlist.getAttributeByTag("t:ItemId", "Id"),
ChangeKey: distlist.getAttributeByTag("t:ItemId", "ChangeKey"),
name: distlist.getTagValue("t:Subject"),
displayName: distlist.getTagValue("t:DisplayName")
});
var create_result = rm[0].XPath("/m:Changes/t:Create");
if (create_result) {
for (var creation of Object.values(create_result)) {
var contact_result = creation.XPath("/t:Contact");
if (contact_result) {
for (var contact of Object.values(contact_result)) {
//this.creations.contacts.push(contact);
this.creations.contacts.push({
Id: contact.getAttributeByTag("t:ItemId", "Id"),
ChangeKey: contact.getAttributeByTag("t:ItemId", "ChangeKey"),
name: contact.getTagValue("t:Subject"),
displayName: contact.getTagValue("t:DisplayName")
});
}
}
contact_result = null;
var distlist_result = creation.XPath("/t:DistributionList");
if (distlist_result) {
for (var distlist of Object.values(distlist_result)) {
//this.creations.distlists.push(distlist);
this.creations.distlists.push({
Id: distlist.getAttributeByTag("t:ItemId", "Id"),
ChangeKey: distlist.getAttributeByTag("t:ItemId", "ChangeKey"),
name: distlist.getTagValue("t:Subject"),
displayName: distlist.getTagValue("t:DisplayName")
});
}
}
distlist_result = null;
}
}
for each(var update in rm[0].XPath("/m:Changes/t:Update")) {
for each(var contact in update.XPath("/t:Contact")) {
//this.updates.contacts.push(contact);
this.updates.contacts.push({
Id: contact.getAttributeByTag("t:ItemId", "Id"),
ChangeKey: contact.getAttributeByTag("t:ItemId", "ChangeKey"),
name: contact.getTagValue("t:Subject"),
displayName: contact.getTagValue("t:DisplayName")
});
}
for each(var distlist in update.XPath("/t:DistributionList")) {
//this.updates.distlists.push(distlist);
this.updates.distlists.push({
Id: distlist.getAttributeByTag("t:ItemId", "Id"),
ChangeKey: distlist.getAttributeByTag("t:ItemId", "ChangeKey"),
name: distlist.getTagValue("t:Subject"),
displayName: distlist.getTagValue("t:DisplayName")
});
create_result = null;
var update_result = rm[0].XPath("/m:Changes/t:Update");
if (update_result) {
for (var update of Object.values(update_result)) {
var contact_result = update.XPath("/t:Contact");
if (contact_result) {
for (var contact of Object.values(contact_result)) {
//this.updates.contacts.push(contact);
this.updates.contacts.push({
Id: contact.getAttributeByTag("t:ItemId", "Id"),
ChangeKey: contact.getAttributeByTag("t:ItemId", "ChangeKey"),
name: contact.getTagValue("t:Subject"),
displayName: contact.getTagValue("t:DisplayName")
});
}
}
contact_result = null;
var distlist_result = update.XPath("/t:DistributionList");
if (distlist_result) {
for (var distlist of Object.values(distlist_result)) {
//this.updates.distlists.push(distlist);
this.updates.distlists.push({
Id: distlist.getAttributeByTag("t:ItemId", "Id"),
ChangeKey: distlist.getAttributeByTag("t:ItemId", "ChangeKey"),
name: distlist.getTagValue("t:Subject"),
displayName: distlist.getTagValue("t:DisplayName")
});
}
}
distlist_result = null;
}
}
update_result = null;
for each(var deleted in rm[0].XPath("/m:Changes/t:Delete")) {
this.deletions.contacts.push(deleted);
var delete_result = rm[0].XPath("/m:Changes/t:Delete");
if (delete_result) {
for (var deleted of Object.values(delete_result)) {
this.deletions.contacts.push(deleted);
}
}
delete_result = null;
rm = null;
......
......@@ -101,10 +101,12 @@ exchWebService.commonAbFunctions = {
this.logInfo("deleteAccount:" + aUUID);
var currentAccounts = this.getAccounts();
var newAccounts = [];
for each(var account in currentAccounts) {
this.logInfo(" Account:" + account);
if (account != aUUID) {
newAccounts.push(account);
if (currentAccounts) {
for (var account of Object.values(currentAccounts)) {
this.logInfo(" Account:" + account);
if (account != aUUID) {
newAccounts.push(account);
}
}
}
this.logInfo(" accounts:" + newAccounts.join(","));
......
......@@ -63,7 +63,6 @@ mivExchangeAbCard.prototype = {
classID: components.ID("{" + mivExchangeAbCardGUID + "}"),
contractID: "@1st-setup.nl/exchange/abcard;1",
flags: Ci.nsIClassInfo.THREADSAFE,
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
// External methods
......
......@@ -380,7 +380,7 @@ exchangeAbRootDirectory.prototype = {
var results = [];
if (accounts.length > 0) {
var dir;
for each(var account in accounts) {
for (var account of accounts) {
if (account != "") {
var dirName = this.childNodeURI + "id=" + encodeURI(account) + "&type=basefolder";
try {
......
......@@ -53,7 +53,6 @@ mivExchangeAutoCompleteResult.prototype = {
classID: components.ID("{" + mivExchangeAutoCompleteResultGUID + "}"),
contractID: "@1st-setup.nl/exchange/autocompleteresult;1",
flags: Ci.nsIClassInfo.THREADSAFE,
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
getInterfaces: function _getInterfaces(count) {
var ifaces = [Ci.mivExchangeAutoCompleteResult,
......@@ -254,11 +253,13 @@ mivExchangeAutoCompleteResult.prototype = {
addResult: function _addResult(aCard) {
// First check if this card is not already in the list
var cardExists = false;
for each(var card in this._cards) {
if (card.localId == aCard.localId) {
if (this._cards) {
for (var card of Object.values(this._cards)) {
if (card.localId == aCard.localId) {
cardExists = true;
break;
cardExists = true;
break;
}
}
}
if (!cardExists) {
......
......@@ -59,7 +59,6 @@ mivExchangeAutoCompleteSearch.prototype = {
classID: components.ID("{" + mivExchangeAutoCompleteSearchGUID + "}"),
contractID: "@mozilla.org/autocomplete/search;1?name=exchangeAutoCompleteSearch",
flags: Ci.nsIClassInfo.SINGLETON || Ci.nsIClassInfo.THREADSAFE,
implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
getInterfaces: function _getInterfaces(count) {
var ifaces = [Ci.mivExchangeAutoCompleteSearch,
......@@ -78,9 +77,11 @@ mivExchangeAutoCompleteSearch.prototype = {
observe: function (subject, topic, data) {
// Do your stuff here.
var uuid;
for each(var search in this._searches) {
if (search.query == data) {
uuid = search.uuid;
if (this._searches) {
for (var search of Object.values(this._searches)) {
if (search.query == data) {
uuid = search.uuid;
}
}
}
......@@ -183,10 +184,12 @@ mivExchangeAutoCompleteSearch.prototype = {
if (item.QueryInterface(Ci.mivExchangeAbCard)) {
// Check to which search it belongs
for each(var search in this._searches) {
if (rightDir.URI.indexOf(search.query) > -1) {
dump(" 1.@@@ displayName:" + item.displayName + ", localId:" + item.localId + "\n");
search.autoCompleteResult.addResult(item);
if (this._searches) {
for (var search of Object.values(this._searches)) {
if (rightDir.URI.indexOf(search.query) > -1) {
dump(" 1.@@@ displayName:" + item.displayName + ", localId:" + item.localId + "\n");
search.autoCompleteResult.addResult(item);
}
}
}
}
......@@ -198,9 +201,11 @@ mivExchangeAutoCompleteSearch.prototype = {
//void stopSearch();
stopSearch: function _stopSearch() {
//dump("mivExchangeAutoCompleteSearch: stopSearch\n");
for each(var search in this._searches) {
// Clearing the results because it appears the are being reused.
search.autoCompleteResult.clearResults();
if (this._searches) {
for (var search of Object.values(this._searches)) {
// Clearing the results because it appears the are being reused.
search.autoCompleteResult.clearResults();
}
}
this._searches = {};
......
......@@ -165,7 +165,7 @@ exchCalPopUpMenu.prototype = {
}
this.globalFunctions.LOG("username:" + username);
this.globalFunctions.LOG("domainname:" + domainname);
this.globalFunctions.LOG("url:" + tmpURI.scheme + "://" + tmpURI.hostPort + tmpURI.path);
this.globalFunctions.LOG("url:" + tmpURI.scheme + "://" + tmpURI.hostPort + tmpURI.pathQueryRef);
var newPrefs = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService)
......@@ -182,7 +182,7 @@ exchCalPopUpMenu.prototype = {
newPrefs.setCharPref("ecFolderbase", "calendar");
newPrefs.setCharPref("ecFolderpath", "/");
newPrefs.setCharPref("ecMailbox", mailbox.value); // We have to ask this in a prompt
newPrefs.setCharPref("ecServer", tmpURI.scheme + "://" + tmpURI.hostPort + tmpURI.path);
newPrefs.setCharPref("ecServer", tmpURI.scheme + "://" + tmpURI.hostPort + tmpURI.pathQueryRef);
newPrefs.setCharPref("ecUser", username);
currentPrefs.setCharPref("type", "exchangecalendar");
......
......@@ -74,7 +74,7 @@
completedefaultindex="true"
forcecomplete="true"
minresultsforpopup="1"
onblur="if (this.localName === 'textbox') document.getBindingParent(this).onBlurInput(event);"
onblur="if (this.localName === 'textbox') { if (document.getBindingParent(this).onBlurInput) { document.getBindingParent(this).onBlurInput(event); } };"
ignoreblurwhilesearching="true"
oninput="this.setAttribute('dirty', 'true');">
</xul:textbox>
......@@ -141,7 +141,7 @@
var numRowsAdded = 0;
if (attendees.length > 0) {
for each (var attendee in attendees) {
for (var attendee of Object.values(attendees)) {
this.appendAttendee(attendee, listbox, template, false);
numRowsAdded++;
}
......
......@@ -32,6 +32,7 @@ var Ci = Components.interfaces;
var Cc = Components.classes;
Cu.import("resource://calendar/modules/calUtils.jsm");
Cu.import("resource://gre/modules/Preferences.jsm");
if (!exchWebService) var exchWebService = {};
......@@ -47,7 +48,7 @@ function exchChangeCalendarPropertiesReminder(aDocument, aWindow, aArgument) {
exchChangeCalendarPropertiesReminder.prototype = {
onLoad: function _onLoad() {
if ((!cal.isEvent(this._argument.item)) && (this._argument.calendar.type == "exchangecalendar")) {
if ((!cal.item.isEvent(this._argument.item)) && (this._argument.calendar.type == "exchangecalendar")) {
this._document.getElementById("reminder-relative-box").hidden = true;
//this._document.getElementById("reminder-relative-radio").checked = false;
......@@ -60,7 +61,7 @@ exchChangeCalendarPropertiesReminder.prototype = {
dump(" WHAT is this:" + this._argument.calendar.type + "\n");
if ((cal.isEvent(this._argument.item)) && (this._argument.calendar.type == "exchangecalendar")) {
if ((cal.item.isEvent(this._argument.item)) && (this._argument.calendar.type == "exchangecalendar")) {
this._document.getElementById("reminder-relation-origin").hidden = true;
this._document.getElementById("exchWebService-reminder-relation-origin").hidden = false;
}
......@@ -72,12 +73,12 @@ exchChangeCalendarPropertiesReminder.prototype = {
},
onNewReminder: function _onNewReminder() {
if ((!cal.isEvent(this._argument.item)) && (this._argument.calendar.type == "exchangecalendar")) {
let itemType = (isEvent(this._argument.item) ? "event" : "todo");
if ((!cal.item.isEvent(this._argument.item)) && (this._argument.calendar.type == "exchangecalendar")) {
let itemType = (cal.item.isEvent(this._argument.item) ? "event" : "todo");
let listbox = this._document.getElementById("reminder-listbox");
let reminder = cal.createAlarm();
let alarmlen = getPrefSafe("calendar.alarms." + itemType + "alarmlen", 15);
let alarmlen = Preferences.get("calendar.alarms." + itemType + "alarmlen", 15);
// Default is an absolute DISPLAY alarm, |alarmlen| minutes before the event.
// If DISPLAY is not supported by the provider, then pick the provider's
......
......@@ -109,7 +109,7 @@
aProps.AppendElement(cal.getAtomFromService(bgColorProp));
// Set a property to get the contrasting text color (foreground)
let fgColorProp = cal.getContrastingTextColor(color || "a8c2e1");
let fgColorProp = cal.view.getContrastingTextColor(color || "a8c2e1");
aProps.AppendElement(cal.getAtomFromService(fgColorProp));
if (calendar.type == "exchangecalendar") {
......@@ -154,7 +154,7 @@
properties.push("color-" + (color || "default"));
// Set a property to get the contrasting text color (foreground)
properties.push(cal.getContrastingTextColor(color || "a8c2e1"));
properties.push(cal.view.getContrastingTextColor(color || "a8c2e1"));
if (calendar.type == "exchangecalendar") {
let exchangeCurrentStatus = calendar.getProperty("exchangeCurrentStatus");
......
......@@ -154,12 +154,14 @@ exchEventSummaryDialog.prototype = {
var attendees = item.getAttendees({});
var optionalAttendeeList = new Array();
var requiredAttendeeList = new Array();
for each(var attendee in attendees) {
if (attendee.role == "OPT-PARTICIPANT") {
optionalAttendeeList.push(attendee);
}
else {
requiredAttendeeList.push(attendee);
if (attendees) {
for (var attendee of Object.values(attendees)) {
if (attendee.role == "OPT-PARTICIPANT") {
optionalAttendeeList.push(attendee);
}
else {
requiredAttendeeList.push(attendee);
}
}
}
......@@ -201,7 +203,8 @@ exchEventSummaryDialog.prototype = {
var list = listbox.getElementsByTagName("listitem");
var page = 0;
var line = 0;
for each(var attendee in attendees) {
if (attendees) {
for (var attendee of Object.values(attendees)) {
var itemNode = list[line];
var listcell = itemNode.getElementsByTagName("listcell")[page];
if (attendee.commonName && attendee.commonName.length) {
......@@ -221,6 +224,7 @@ exchEventSummaryDialog.prototype = {
}
} //end of for
}
},
......@@ -449,7 +453,7 @@ exchEventSummaryDialog.prototype = {
//dump("this.inlineImages.length:"+this.inlineImages.length+"\n");
if (aAttachments.length > 0) {
for (var index in aAttachments) {
for (var index of aAttachments) {
if (aAttachments[index].contentId) {
// Find the image this attachment is for.
for (var i = 0; i < this.inlineImages.length; i++) {
......@@ -548,7 +552,7 @@ exchEventSummaryDialog.prototype = {
if (calendar.getProperty("exchWebService.offlineOrNotConnected")) {
var tmpArray = tmpButtons.split(",");
var newArray = [];
for (var index in tmpArray) {
for (var index of tmpArray) {
if (tmpArray[index] != "extra1") {
newArray.push(tmpArray[index]);
}
......@@ -683,8 +687,10 @@ exchEventSummaryDialog.prototype = {
unLoad: function _unLoad(aEvent) {
//dump("unLoading window:"+aEvent.type+"\n");
for each(var cachedImage in this.imageCache) {
cachedImage.remove(false);
if (this.imageCache) {
for (var cachedImage of Object.values(this.imageCache)) {
cachedImage.remove(false);
}
}
},
}
......
......@@ -8,10 +8,7 @@ var Cr = Components.results;
var components = Components;
Cu.import("resource://exchangecommon/ecFunctions.js");
Cu.import("resource:///modules/gloda/public.js")
Cu.import("resource:///modules/MailUtils.js");
Cu.import("resource://calendar/modules/calUtils.jsm");
Cu.import("resource://calendar/modules/calXMLUtils.jsm");
const globalFunctions = Cc["@1st-setup.nl/global/functions;1"]
.getService(Ci.mivFunctions);
......
......@@ -372,10 +372,12 @@ exchDelegateCalendarSettings.prototype = {
.getService(Ci.calICalendarManager);
let calendars = calManager.getCalendars({});
for each(let calendar in calendars) {
if (tmpUUID == calendar.id) {
calManager.unregisterCalendar(calendar);
calManager.deleteCalendar(calendar);
if (calendars) {
for (let calendar of Object.values(calendars)) {
if (tmpUUID == calendar.id) {
calManager.unregisterCalendar(calendar);
calManager.deleteCalendar(calendar);
}
}
}
}
......
......@@ -51,7 +51,7 @@ exchangeEventDialog.prototype = {
*/
onAcceptCallback: function _onAcceptCallback(aItem, aCalendar, aOriginalItem, aIsClosing) {
if (aCalendar.type === "exchangecalendar") {
if (cal.isEvent(aItem)) {
if (cal.item.isEvent(aItem)) {
if (!aItem.className) {
var newItem = Cc["@1st-setup.nl/exchange/calendarevent;1"]
.createInstance(Ci.mivExchangeEvent);
......@@ -154,7 +154,7 @@ exchangeEventDialog.prototype = {
}
// If not an event, add Exchange task extra informations
if (!cal.isEvent(item)) {
if (!cal.item.isEvent(item)) {
// Set and display task owner
......@@ -213,7 +213,7 @@ exchangeEventDialog.prototype = {
}
// For events and other calendar type, hidde back all Exchange task details, display back standard items
if (cal.isEvent(item)
if (cal.item.isEvent(item)
|| cal.type !== "exchangecalendar") {
// Hide Exchange task details
......
......@@ -109,7 +109,7 @@ exchTaskDelegation.prototype = {
let dtFormat = Cc["@mozilla.org/calendar/datetime-formatter;1"]
.getService(Ci.calIDateTimeFormatter);
var tmpDate = cal.fromRFC3339(task.getProperty("exchWebService-PidLidTaskLastUpdate"), this.globalFunctions.ecTZService().UTC).getInTimezone(this.globalFunctions.ecDefaultTimeZone());
var tmpDate = cal.dtz.fromRFC3339(task.getProperty("exchWebService-PidLidTaskLastUpdate"), this.globalFunctions.ecTZService().UTC).getInTimezone(this.globalFunctions.ecDefaultTimeZone());
var lastChange = task.getProperty("exchWebService-PidLidTaskHistory");
switch (lastChange) {
...