зеркало из https://github.com/mozilla/pjs.git
Bug 333511 - Only the first of multiple selected attachments are deleted/detached from a given message
p=Christian Schmidt <bugzilla.mozilla.org-1@chsc.dk>, r=mkmelin
This commit is contained in:
Родитель
a720752345
Коммит
75147c7520
|
@ -1089,26 +1089,12 @@ function createNewAttachmentInfo(contentType, url, displayName, uri, isExternalA
|
||||||
this.isExternalAttachment = isExternalAttachment;
|
this.isExternalAttachment = isExternalAttachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
function dofunc(aFunctionName, aFunctionArg)
|
|
||||||
{
|
|
||||||
if (aFunctionName == "saveAttachment")
|
|
||||||
saveAttachment(aFunctionArg);
|
|
||||||
else if (aFunctionName == "openAttachment")
|
|
||||||
openAttachment(aFunctionArg);
|
|
||||||
else if (aFunctionName == "printAttachment")
|
|
||||||
printAttachment(aFunctionArg);
|
|
||||||
else if (aFunctionName == "deleteAttachment")
|
|
||||||
detachAttachment(aFunctionArg, false);
|
|
||||||
else if (aFunctionName == "detachAttachment")
|
|
||||||
detachAttachment(aFunctionArg, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveAttachment(aAttachment)
|
function saveAttachment(aAttachment)
|
||||||
{
|
{
|
||||||
messenger.saveAttachment(aAttachment.contentType,
|
messenger.saveAttachment(aAttachment.contentType,
|
||||||
aAttachment.url,
|
aAttachment.url,
|
||||||
encodeURIComponent(aAttachment.displayName),
|
encodeURIComponent(aAttachment.displayName),
|
||||||
aAttachment.messageUri, aAttachment.isExternalAttachment);
|
aAttachment.uri, aAttachment.isExternalAttachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
function openAttachment(aAttachment)
|
function openAttachment(aAttachment)
|
||||||
|
@ -1116,7 +1102,7 @@ function openAttachment(aAttachment)
|
||||||
messenger.openAttachment(aAttachment.contentType,
|
messenger.openAttachment(aAttachment.contentType,
|
||||||
aAttachment.url,
|
aAttachment.url,
|
||||||
encodeURIComponent(aAttachment.displayName),
|
encodeURIComponent(aAttachment.displayName),
|
||||||
aAttachment.messageUri, aAttachment.isExternalAttachment);
|
aAttachment.uri, aAttachment.isExternalAttachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
function printAttachment(aAttachment)
|
function printAttachment(aAttachment)
|
||||||
|
@ -1125,7 +1111,7 @@ function printAttachment(aAttachment)
|
||||||
messenger.printAttachment(aAttachment.contentType,
|
messenger.printAttachment(aAttachment.contentType,
|
||||||
aAttachment.url,
|
aAttachment.url,
|
||||||
encodeURIComponent(aAttachment.displayName),
|
encodeURIComponent(aAttachment.displayName),
|
||||||
aAttachment.messageUri);
|
aAttachment.uri);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1134,7 +1120,7 @@ function detachAttachment(aAttachment, aSaveFirst)
|
||||||
messenger.detachAttachment(aAttachment.contentType,
|
messenger.detachAttachment(aAttachment.contentType,
|
||||||
aAttachment.url,
|
aAttachment.url,
|
||||||
encodeURIComponent(aAttachment.displayName),
|
encodeURIComponent(aAttachment.displayName),
|
||||||
aAttachment.messageUri, aSaveFirst);
|
aAttachment.uri, aSaveFirst);
|
||||||
}
|
}
|
||||||
|
|
||||||
function CanDetachAttachments()
|
function CanDetachAttachments()
|
||||||
|
@ -1217,41 +1203,18 @@ function attachmentListClick(event)
|
||||||
var target = event.target;
|
var target = event.target;
|
||||||
if (target.localName == "descriptionitem")
|
if (target.localName == "descriptionitem")
|
||||||
{
|
{
|
||||||
dofunc("openAttachment", target.attachment);
|
openAttachment(target.attachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// on command handlers for the attachment list context menu...
|
|
||||||
// commandPrefix matches one of our existing functions
|
|
||||||
// (openAttachment, saveAttachment, etc.)
|
|
||||||
function handleAttachmentSelection(commandPrefix)
|
|
||||||
{
|
|
||||||
var attachmentList = document.getElementById('attachmentList');
|
|
||||||
var selectedAttachments = attachmentList.selectedItems;
|
|
||||||
|
|
||||||
// loop over all of the selected attachments...
|
|
||||||
|
|
||||||
// XXX hack alert. If we sit in tight loop and call doFunc for multiple attachments,
|
|
||||||
// we get chrome errors in layout as we start loading the first helper app dialog
|
|
||||||
// then before it loads, we kick off the next one and the next one. Subsequent helper app dialogs
|
|
||||||
// were failing because we were still loading the chrome files for the first attempt (error about the xul cache
|
|
||||||
// being empty). For now, work around this by doing the first helper app dialog right away, then waiting a bit
|
|
||||||
// before we launch the rest.
|
|
||||||
for (var i = 0; i < selectedAttachments.length; i++)
|
|
||||||
if (!i)
|
|
||||||
dofunc(commandPrefix, selectedAttachments[i].attachment);
|
|
||||||
else
|
|
||||||
setTimeout(dofunc, 100, commandPrefix, selectedAttachments[i].attachment);
|
|
||||||
}
|
|
||||||
|
|
||||||
function cloneAttachment(aAttachment)
|
function cloneAttachment(aAttachment)
|
||||||
{
|
{
|
||||||
var obj = new Object();
|
var obj = new Object();
|
||||||
obj.contentType = aAttachment.contentType;
|
obj.contentType = aAttachment.contentType;
|
||||||
obj.url = aAttachment.url;
|
obj.url = aAttachment.url;
|
||||||
obj.displayName = aAttachment.displayName;
|
obj.displayName = aAttachment.displayName;
|
||||||
obj.messageUri = aAttachment.uri;
|
obj.uri = aAttachment.uri;
|
||||||
obj.isExternalAttachment = aAttachment.isExternalAttachment;
|
obj.isExternalAttachment = aAttachment.isExternalAttachment;
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -1505,6 +1468,22 @@ function addAttachmentToPopup(popup, attachment, attachmentIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
function HandleAllAttachments(action)
|
function HandleAllAttachments(action)
|
||||||
|
{
|
||||||
|
HandleMultipleAttachments(currentAttachments, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
function HandleSelectedAttachments(action)
|
||||||
|
{
|
||||||
|
var attachmentList = document.getElementById('attachmentList');
|
||||||
|
var selectedAttachments = new Array();
|
||||||
|
for (var i in attachmentList.selectedItems)
|
||||||
|
selectedAttachments.push(attachmentList.selectedItems[i].attachment);
|
||||||
|
|
||||||
|
HandleMultipleAttachments(selectedAttachments, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
// supported actions: open, save, saveAs, detach, delete
|
||||||
|
function HandleMultipleAttachments(attachments, action)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1516,10 +1495,10 @@ function HandleAllAttachments(action)
|
||||||
|
|
||||||
// populate these arrays..
|
// populate these arrays..
|
||||||
var actionIndex = 0;
|
var actionIndex = 0;
|
||||||
for (var index in currentAttachments)
|
for (var index in attachments)
|
||||||
{
|
{
|
||||||
// exclude all attachments already deleted
|
// exclude all attachments already deleted
|
||||||
var attachment = currentAttachments[index];
|
var attachment = attachments[index];
|
||||||
if ( attachment.contentType != 'text/x-moz-deleted' )
|
if ( attachment.contentType != 'text/x-moz-deleted' )
|
||||||
{
|
{
|
||||||
attachmentContentTypeArray[actionIndex] = attachment.contentType;
|
attachmentContentTypeArray[actionIndex] = attachment.contentType;
|
||||||
|
@ -1545,12 +1524,29 @@ function HandleAllAttachments(action)
|
||||||
attachmentContentTypeArray, attachmentUrlArray,
|
attachmentContentTypeArray, attachmentUrlArray,
|
||||||
attachmentDisplayNameArray, attachmentMessageUriArray,
|
attachmentDisplayNameArray, attachmentMessageUriArray,
|
||||||
false); // don't save
|
false); // don't save
|
||||||
|
else if ( action == 'open'|| action == 'saveAs' ) {
|
||||||
|
// XXX hack alert. If we sit in tight loop and open/save multiple attachments,
|
||||||
|
// we get chrome errors in layout as we start loading the first helper app dialog
|
||||||
|
// then before it loads, we kick off the next one and the next one. Subsequent helper
|
||||||
|
// app dialogs were failing because we were still loading the chrome files for the
|
||||||
|
// first attempt (error about the xul cache being empty). For now, work around this
|
||||||
|
// by doing the first helper app dialog right away, then waiting a bit before we
|
||||||
|
// launch the rest.
|
||||||
|
var actionFunction = (action == 'open') ? openAttachment : saveAttachment;
|
||||||
|
for (var i = 0; i < attachments.length; i++)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
actionFunction(attachments[i]);
|
||||||
else
|
else
|
||||||
dump ("** unknown HandleAllAttachments action: " + action + "**\n");
|
setTimeout(actionFunction, 100, attachments[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dump ("** unknown HandleMultipleAttachments action: " + action + "**\n");
|
||||||
}
|
}
|
||||||
catch (ex)
|
catch (ex)
|
||||||
{
|
{
|
||||||
dump ("** failed to handle all attachments **\n");
|
dump ("** failed to handle multiple attachments **\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,14 +72,14 @@
|
||||||
|
|
||||||
<popup id="attachmentListContext" onpopupshowing="return onShowAttachmentContextMenu();">
|
<popup id="attachmentListContext" onpopupshowing="return onShowAttachmentContextMenu();">
|
||||||
<menuitem id="context-openAttachment" label="&openAttachmentCmd.label;" accesskey="&openAttachmentCmd.accesskey;"
|
<menuitem id="context-openAttachment" label="&openAttachmentCmd.label;" accesskey="&openAttachmentCmd.accesskey;"
|
||||||
oncommand="handleAttachmentSelection('openAttachment');"/>
|
oncommand="HandleSelectedAttachments('open');"/>
|
||||||
<menuitem id="context-saveAttachment" label="&saveAsAttachmentCmd.label;" accesskey="&saveAsAttachmentCmd.accesskey;"
|
<menuitem id="context-saveAttachment" label="&saveAsAttachmentCmd.label;" accesskey="&saveAsAttachmentCmd.accesskey;"
|
||||||
oncommand="handleAttachmentSelection('saveAttachment');"/>
|
oncommand="HandleSelectedAttachments('saveAs');"/>
|
||||||
<menuseparator id="context-menu-separator"/>
|
<menuseparator id="context-menu-separator"/>
|
||||||
<menuitem id="context-detachAttachment" label="&detachAttachmentCmd.label;"
|
<menuitem id="context-detachAttachment" label="&detachAttachmentCmd.label;"
|
||||||
oncommand="handleAttachmentSelection('detachAttachment');"/>
|
oncommand="HandleSelectedAttachments('detach');"/>
|
||||||
<menuitem id="context-deleteAttachment" label="&deleteAttachmentCmd.label;"
|
<menuitem id="context-deleteAttachment" label="&deleteAttachmentCmd.label;"
|
||||||
oncommand="handleAttachmentSelection('deleteAttachment');"/>
|
oncommand="HandleSelectedAttachments('delete');"/>
|
||||||
<menuitem id="context-saveAllAttachments" oncommand="HandleAllAttachments('save');"
|
<menuitem id="context-saveAllAttachments" oncommand="HandleAllAttachments('save');"
|
||||||
label="&saveAllAttachmentsCmd.label;" accesskey="&saveAllAttachmentsCmd.accesskey;"/>
|
label="&saveAllAttachmentsCmd.label;" accesskey="&saveAllAttachmentsCmd.accesskey;"/>
|
||||||
<menuitem id="context-detachAllAttachments" oncommand="HandleAllAttachments('detach');"
|
<menuitem id="context-detachAllAttachments" oncommand="HandleAllAttachments('detach');"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче