Bug 308988 support delegated use of imap shared folders

p=me r=mnyromyr sr=bienvenu
This commit is contained in:
bugzilla%arlen.demon.co.uk 2005-11-21 00:37:38 +00:00
parent ffac17f9c5
commit dc7dc785a9
5 changed files with 116 additions and 116 deletions

View File

@ -121,12 +121,12 @@ var gMessageListeners = new Array;
// Our first view is the collapsed view. This is very light weight view of the data. We only show a couple
// fields.
var gCollapsedHeaderList = [ {name:"subject", outputFunction:updateHeaderValueInTextNode},
{name:"from", useShortView:true, outputFunction:OutputEmailAddresses},
{name:"from", useToggle:true, useShortView:true, outputFunction:OutputEmailAddresses},
{name:"date", outputFunction:updateHeaderValueInTextNode}];
// We also have an expanded header view. This shows many of your more common (and useful) headers.
var gExpandedHeaderList = [ {name:"subject"},
{name:"from", outputFunction:OutputEmailAddresses},
{name:"from", useToggle:true, outputFunction:OutputEmailAddresses},
{name:"sender", outputFunction:OutputEmailAddresses},
{name:"reply-to", outputFunction:OutputEmailAddresses},
{name:"date"},
@ -167,11 +167,21 @@ var currentAttachments = new Array();
// headerListInfo --> entry from a header list.
function createHeaderEntry(prefix, headerListInfo)
{
var useShortView = false;
var partialIDName = prefix + headerListInfo.name;
this.enclosingBox = document.getElementById(partialIDName + 'Box');
this.textNode = document.getElementById(partialIDName + 'Value');
this.isValid = false;
if ("useShortView" in headerListInfo)
{
useShortView = headerListInfo.useShortView;
if (useShortView)
this.enclosingBox = this.textNode;
else
this.enclosingBox.emailAddressNode = this.textNode;
}
if ("useToggle" in headerListInfo)
{
this.useToggle = headerListInfo.useToggle;
@ -185,13 +195,8 @@ function createHeaderEntry(prefix, headerListInfo)
else
this.useToggle = false;
if ("useShortView" in headerListInfo)
{
this.useShortView = headerListInfo.useShortView;
this.enclosingBox.emailAddressNode = this.textNode;
}
else
this.useShortView = false;
if (this.textNode)
this.textNode.useShortView = useShortView;
if ("outputFunction" in headerListInfo)
this.outputFunction = headerListInfo.outputFunction;
@ -359,8 +364,8 @@ var messageHeaderSink = {
processHeaders: function(headerNameEnumerator, headerValueEnumerator, dontCollectAddress)
{
this.onStartHeaders();
var fromMailbox;
const kMailboxSeparator = ", ";
var index = 0;
while (headerNameEnumerator.hasMore())
{
@ -414,11 +419,9 @@ var messageHeaderSink = {
}
else
currentHeaderData[lowerCaseHeaderName] = header;
if (lowerCaseHeaderName == "from")
{
if (msgHeaderParser && header.headerValue)
fromMailbox = msgHeaderParser.extractHeaderAddressMailboxes(null, header.headerValue);
if (header.headerValue)
{
try
@ -430,12 +433,9 @@ var messageHeaderSink = {
.getService(Components.interfaces.nsIAbAddressCollecter);
gCollectAddress = header.headerValue;
if (gCollectOutgoing)
// collect, but only update existing cards, unknown preferred send format
gCollectAddressTimer = setTimeout('abAddressCollector.collectUnicodeAddress(gCollectAddress, false, Components.interfaces.nsIAbPreferMailFormat.unknown);', 2000);
else
// collect, and add card if doesn't exist, unknown preferred send format
gCollectAddressTimer = setTimeout('abAddressCollector.collectUnicodeAddress(gCollectAddress, true, Components.interfaces.nsIAbPreferMailFormat.unknown);', 2000);
// collect, add card if doesn't exist and gCollectOutgoing is set,
// otherwise only update existing cards, unknown preferred send format
gCollectAddressTimer = setTimeout('abAddressCollector.collectUnicodeAddress(gCollectAddress, !gCollectOutgoing, Components.interfaces.nsIAbPreferMailFormat.unknown);', 2000);
}
}
catch(ex) {}
@ -443,6 +443,16 @@ var messageHeaderSink = {
} // if lowerCaseHeaderName == "from"
} // while we have more headers to parse
if (("from" in currentHeaderData) && ("sender" in currentHeaderData) && msgHeaderParser)
{
var senderMailbox = kMailboxSeparator + msgHeaderParser.extractHeaderAddressMailboxes(null,
currentHeaderData.sender.headerValue) + kMailboxSeparator;
var fromMailboxes = kMailboxSeparator + msgHeaderParser.extractHeaderAddressMailboxes(null,
currentHeaderData.from.headerValue) + kMailboxSeparator;
if (fromMailboxes.indexOf(senderMailbox) >= 0)
delete currentHeaderData.sender;
}
this.onEndHeaders();
},
@ -741,7 +751,6 @@ function createNewHeaderView(headerName)
this.enclosingBox = newHeader;
this.isValid = false;
this.useToggle = false;
this.useShortView = false;
this.outputFunction = updateHeaderValue;
}
@ -753,6 +762,7 @@ function UpdateMessageHeaders()
// iterate over each header we received and see if we have a matching entry in each
// header view table...
var headerName;
for (headerName in currentHeaderData)
{
var headerField = currentHeaderData[headerName];
@ -870,17 +880,12 @@ function OutputNewsgroups(headerEntry, headerValue)
// extracts them one by one, linkifying each email address into a mailto url.
// Then we add the link-ified email address to the parentDiv passed in.
//
// defaultParentDiv --> the div to add the link-ified email addresses into.
// emailAddresses --> comma separated list of the addresses for this header field
// includeShortLongToggle --> true if you want to include the ability to toggle between short/long
// address views for this header field. If true, then pass in a another div which is the div the long
// view will be added too...
// useShortView --> if true, we'll only generate the Name of the email address field instead of
// showing the name + the email address.
function OutputEmailAddresses(headerEntry, emailAddresses)
{
if ( !emailAddresses ) return;
if (!emailAddresses)
return;
if (msgHeaderParser)
{
@ -896,19 +901,14 @@ function OutputEmailAddresses(headerEntry, emailAddresses)
// if we want to include short/long toggle views and we have a long view, always add it.
// if we aren't including a short/long view OR if we are and we haven't parsed enough
// addresses to reach the cutoff valve yet then add it to the default (short) div.
var address = {};
address.emailAddress = addresses.value[index];
address.fullAddress = fullNames.value[index];
address.displayName = names.value[index];
if (headerEntry.useToggle)
{
var address = {};
address.emailAddress = addresses.value[index];
address.fullAddress = fullNames.value[index];
address.displayName = names.value[index];
headerEntry.enclosingBox.addAddressView(address);
}
else
{
updateEmailAddressNode(headerEntry.enclosingBox.emailAddressNode, addresses.value[index],
fullNames.value[index], names.value[index], headerEntry.useShortView);
}
updateEmailAddressNode(headerEntry.enclosingBox.emailAddressNode, address);
if (headerEntry.enclosingBox.getAttribute("id") == "expandedfromBox") {
setFromBuddyIcon(addresses.value[index]);
@ -967,22 +967,16 @@ function setFromBuddyIcon(email)
fromBuddyIcon.setAttribute("src", "");
}
function updateEmailAddressNode(emailAddressNode, emailAddress, fullAddress, displayName, useShortView)
function updateEmailAddressNode(emailAddressNode, address)
{
if (useShortView && displayName) {
emailAddressNode.setAttribute("label", displayName);
emailAddressNode.setAttribute("tooltiptext", emailAddress);
} else {
emailAddressNode.setAttribute("label", fullAddress);
emailAddressNode.removeAttribute("tooltiptext");
}
emailAddressNode.setTextAttribute("emailAddress", emailAddress);
emailAddressNode.setTextAttribute("fullAddress", fullAddress);
emailAddressNode.setTextAttribute("displayName", displayName);
emailAddressNode.setAttribute("label", address.fullAddress || address.displayName);
emailAddressNode.removeAttribute("tooltiptext");
emailAddressNode.setTextAttribute("emailAddress", address.emailAddress);
emailAddressNode.setTextAttribute("fullAddress", address.fullAddress);
emailAddressNode.setTextAttribute("displayName", address.displayName);
if ("AddExtraAddressProcessing" in this)
AddExtraAddressProcessing(emailAddress, emailAddressNode);
AddExtraAddressProcessing(address.emailAddress, emailAddressNode);
}
// thunderbird has smart logic for determining if we should show just the display name.

View File

@ -116,10 +116,9 @@
</hbox>
</column>
<column id="collapsedfromBox" collapsed="true">
<column id="collapsedfromBox" flex="1">
<hbox align="start">
<label class="collapsedHeaderDisplayName" value="&fromField.label;"/>
<mail-emailaddress id="collapsedfromValue" flex="1"/>
<mail-multi-emailHeaderField id="collapsedfromValue" class="collapsedHeaderDisplayName" label="&fromField.label;" collapsed="true" flex="1"/>
</hbox>
</column>
@ -144,7 +143,7 @@
<vbox id="expandedHeaders" flex="1">
<mail-toggle-headerfield keywordrelated="true" id="expandedsubjectBox" class="subjectvalue" label="&subjectField.label;" ontwistyclick="ToggleHeaderView();" collapsed="true"/>
<mail-emailheaderfield id="expandedfromBox" label="&fromField.label;" collapsed="true"/>
<mail-multi-emailHeaderField id="expandedfromBox" label="&fromField.label;" collapsed="true"/>
<mail-emailheaderfield id="expandedsenderBox" label="&senderField.label;" collapsed="true"/>
<mail-headerfield id="expandedorganizationBox" label="&organizationField.label;" collapsed="true"/>
<mail-emailheaderfield id="expandedreply-toBox" label="&replyToField.label;" collapsed="true"/>

View File

@ -683,9 +683,18 @@
<parameter name="aAddress"/>
<body>
<![CDATA[
aEmailNode.setAttribute("label", aAddress.fullAddress);
if (aEmailNode.parentNode.useShortView && aAddress.displayName)
{
aEmailNode.setAttribute("label", aAddress.displayName);
aEmailNode.setAttribute("tooltiptext", aAddress.fullAddress);
}
else
{
aEmailNode.setAttribute("label", aAddress.fullAddress || aAddress.displayName);
aEmailNode.removeAttribute("tooltiptext");
}
aEmailNode.setTextAttribute("emailAddress", aAddress.emailAddress);
aEmailNode.setTextAttribute("fullAddress", aAddress.fullAddress);
aEmailNode.setTextAttribute("fullAddress", aAddress.fullAddress);
aEmailNode.setTextAttribute("displayName", aAddress.displayName);
try

View File

@ -109,12 +109,13 @@ var gMessageListeners = new Array;
// Our first view is the collapsed view. This is very light weight view of the data. We only show a couple
// fields.
var gCollapsedHeaderList = [ {name:"subject", outputFunction:updateHeaderValueInTextNode},
{name:"from", useShortView:true, outputFunction:OutputEmailAddresses},
{name:"from", useToggle:true, useShortView:true, outputFunction:OutputEmailAddresses},
{name:"date", outputFunction:updateHeaderValueInTextNode}];
// We also have an expanded header view. This shows many of your more common (and useful) headers.
var gExpandedHeaderList = [ {name:"subject"},
{name:"from", outputFunction:OutputEmailAddresses},
{name:"from", useToggle:true, outputFunction:OutputEmailAddresses},
{name:"sender", outputFunction:OutputEmailAddresses},
{name:"reply-to", outputFunction:OutputEmailAddresses},
{name:"date"},
{name:"to", useToggle:true, outputFunction:OutputEmailAddresses},
@ -153,11 +154,21 @@ var currentAttachments = new Array();
// headerListInfo --> entry from a header list.
function createHeaderEntry(prefix, headerListInfo)
{
var useShortView = false;
var partialIDName = prefix + headerListInfo.name;
this.enclosingBox = document.getElementById(partialIDName + 'Box');
this.textNode = document.getElementById(partialIDName + 'Value');
this.isValid = false;
if ("useShortView" in headerListInfo)
{
useShortView = headerListInfo.useShortView;
if (useShortView)
this.enclosingBox = this.textNode;
else
this.enclosingBox.emailAddressNode = this.textNode;
}
if ("useToggle" in headerListInfo)
{
this.useToggle = headerListInfo.useToggle;
@ -171,13 +182,8 @@ function createHeaderEntry(prefix, headerListInfo)
else
this.useToggle = false;
if ("useShortView" in headerListInfo)
{
this.useShortView = headerListInfo.useShortView;
this.enclosingBox.emailAddressNode = this.textNode;
}
else
this.useShortView = false;
if (this.textNode)
this.textNode.useShortView = useShortView;
if ("outputFunction" in headerListInfo)
this.outputFunction = headerListInfo.outputFunction;
@ -323,6 +329,7 @@ var messageHeaderSink = {
{
this.onStartHeaders();
const kMailboxSeparator = ", ";
var index = 0;
while (headerNameEnumerator.hasMore())
{
@ -377,31 +384,37 @@ var messageHeaderSink = {
if (lowerCaseHeaderName == "from")
{
if (header.value)
if (header.headerValue)
{
if ((gCollectIncoming && !dontCollectAddress) ||
(gCollectNewsgroup && dontCollectAddress))
try
{
if (!abAddressCollector)
abAddressCollector = Components.classes[abAddressCollectorContractID].getService(Components.interfaces.nsIAbAddressCollecter);
if (!dontCollectAddress && (gCollectIncoming || gCollectNewsgroup || gCollectOutgoing))
{
if (!abAddressCollector)
abAddressCollector = Components.classes[abAddressCollectorContractID]
.getService(Components.interfaces.nsIAbAddressCollecter);
gCollectAddress = header.headerValue;
// collect, and add card if doesn't exist, unknown preferred send format
gCollectAddressTimer = setTimeout('abAddressCollector.collectUnicodeAddress(gCollectAddress, true, Components.interfaces.nsIAbPreferMailFormat.unknown);', 2000);
}
else if (gCollectOutgoing)
{
if (!abAddressCollector)
abAddressCollector = Components.classes[abAddressCollectorContractID].getService(Components.interfaces.nsIAbAddressCollecter);
// collect, but only update existing cards, unknown preferred send format
gCollectAddress = header.headerValue;
gCollectAddressTimer = setTimeout('abAddressCollector.collectUnicodeAddress(gCollectAddress, false, Components.interfaces.nsIAbPreferMailFormat.unknown);', 2000);
gCollectAddress = header.headerValue;
// collect, add card if doesn't exist and gCollectOutgoing is set,
// otherwise only update existing cards, unknown preferred send format
gCollectAddressTimer = setTimeout('abAddressCollector.collectUnicodeAddress(gCollectAddress, !gCollectOutgoing, Components.interfaces.nsIAbPreferMailFormat.unknown);', 2000);
}
}
catch(ex) {}
}
} // if lowerCaseHeaderName == "from"
} // while we have more headers to parse
if (("from" in currentHeaderData) && ("sender" in currentHeaderData) && msgHeaderParser)
{
var senderMailbox = kMailboxSeparator + msgHeaderParser.extractHeaderAddressMailboxes(null,
currentHeaderData.sender.headerValue) + kMailboxSeparator;
var fromMailboxes = kMailboxSeparator + msgHeaderParser.extractHeaderAddressMailboxes(null,
currentHeaderData.from.headerValue) + kMailboxSeparator;
if (fromMailboxes.indexOf(senderMailbox) >= 0)
delete currentHeaderData.sender;
}
this.onEndHeaders();
},
@ -646,7 +659,6 @@ function createNewHeaderView(headerName)
this.enclosingBox = newHeader
this.isValid = false;
this.useToggle = false;
this.useShortView = false;
this.outputFunction = updateHeaderValue;
}
@ -658,6 +670,7 @@ function UpdateMessageHeaders()
// iterate over each header we received and see if we have a matching entry in each
// header view table...
var headerName;
for (headerName in currentHeaderData)
{
var headerField = currentHeaderData[headerName];
@ -771,17 +784,12 @@ function OutputNewsgroups(headerEntry, headerValue)
// extracts them one by one, linkifying each email address into a mailto url.
// Then we add the link'ified email address to the parentDiv passed in.
//
// defaultParentDiv --> the div to add the link-ified email addresses into.
// emailAddresses --> comma separated list of the addresses for this header field
// includeShortLongToggle --> true if you want to include the ability to toggle between short/long
// address views for this header field. If true, then pass in a another div which is the div the long
// view will be added too...
// useShortView --> if true, we'll only generate the Name of the email address field instead of
// showing the name + the email address.
function OutputEmailAddresses(headerEntry, emailAddresses)
{
if ( !emailAddresses ) return;
if (!emailAddresses)
return;
if (msgHeaderParser)
{
@ -797,19 +805,14 @@ function OutputEmailAddresses(headerEntry, emailAddresses)
// if we want to include short/long toggle views and we have a long view, always add it.
// if we aren't including a short/long view OR if we are and we haven't parsed enough
// addresses to reach the cutoff valve yet then add it to the default (short) div.
var address = {};
address.emailAddress = addresses.value[index];
address.fullAddress = fullNames.value[index];
address.displayName = names.value[index];
if (headerEntry.useToggle)
{
var address = {};
address.emailAddress = addresses.value[index];
address.fullAddress = fullNames.value[index];
address.displayName = names.value[index];
headerEntry.enclosingBox.addAddressView(address);
}
else
{
updateEmailAddressNode(headerEntry.enclosingBox.emailAddressNode, addresses.value[index],
fullNames.value[index], names.value[index], headerEntry.useShortView);
}
updateEmailAddressNode(headerEntry.enclosingBox.emailAddressNode, address);
if (headerEntry.enclosingBox.getAttribute("id") == "expandedfromBox") {
setFromBuddyIcon(addresses.value[index]);
@ -867,21 +870,16 @@ function setFromBuddyIcon(email)
fromBuddyIcon.setAttribute("src", "");
}
function updateEmailAddressNode(emailAddressNode, emailAddress, fullAddress, displayName, useShortView)
function updateEmailAddressNode(emailAddressNode, address)
{
if (useShortView && displayName) {
emailAddressNode.setAttribute("label", displayName);
emailAddressNode.setAttribute("tooltiptext", emailAddress);
} else {
emailAddressNode.setAttribute("label", fullAddress || displayName);
emailAddressNode.removeAttribute("tooltiptext");
}
emailAddressNode.setTextAttribute("emailAddress", emailAddress);
emailAddressNode.setTextAttribute("fullAddress", fullAddress);
emailAddressNode.setTextAttribute("displayName", displayName);
emailAddressNode.setAttribute("label", address.fullAddress || address.displayName);
emailAddressNode.removeAttribute("tooltiptext");
emailAddressNode.setTextAttribute("emailAddress", address.emailAddress);
emailAddressNode.setTextAttribute("fullAddress", address.fullAddress);
emailAddressNode.setTextAttribute("displayName", address.displayName);
if ("AddExtraAddressProcessing" in this)
AddExtraAddressProcessing(emailAddress, emailAddressNode);
AddExtraAddressProcessing(address.emailAddress, emailAddressNode);
}
// createnewAttachmentInfo --> constructor method for creating new attachment object which goes into the

View File

@ -129,10 +129,9 @@
</hbox>
</column>
<column id="collapsedfromBox" collapsed="true">
<column id="collapsedfromBox" flex="1">
<hbox align="start">
<label class="collapsedHeaderDisplayName" value="&fromField.label;"/>
<mail-emailaddress id="collapsedfromValue" flex="1"/>
<mail-multi-emailHeaderField id="collapsedfromValue" class="collapsedHeaderDisplayName" label="&fromField.label;" collapsed="true" flex="1"/>
</hbox>
</column>
@ -161,7 +160,8 @@
<vbox id="expandedHeaders" flex="1">
<mail-toggle-headerfield keywordrelated="true" id="expandedsubjectBox" class="subjectvalue" label="&subjectField.label;" ontwistyclick="ToggleHeaderView();" collapsed="true"/>
<mail-emailheaderfield id="expandedfromBox" label="&fromField.label;" collapsed="true"/>
<mail-multi-emailHeaderField id="expandedfromBox" label="&fromField.label;" collapsed="true"/>
<mail-emailheaderfield id="expandedsenderBox" label="&senderField.label;" collapsed="true"/>
<mail-headerfield id="expandedorganizationBox" label="&organizationField.label;" collapsed="true"/>
<mail-emailheaderfield id="expandedreply-toBox" label="&replyToField.label;" collapsed="true"/>