Open Bug 1578801 Opened 2 years ago Updated 8 months ago

Provide an additional save path attribute in function call nsMessenger::DetachAllAttachments().

Categories

(MailNews Core :: Attachments, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: Thunderbird_Mail_DE, Unassigned)

Details

In Thunderbird 68 Attachments can be deleted/detached with the following function:

messenger.detachAllAttachments(
  attachmentContentTypeArray.length,
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  true, // save
  true // [optional] delete / detach without confirmation
);

This function opens mandatory a dialog to choose a save path, when the last attribute is set to true to save the detached files.

To call this function for bulk operations it would be necessary to have an additional attribute for the save path instead of the mandatory save path dialog.

The function call could be like this:

messenger.detachAllAttachments(
  attachmentContentTypeArray.length,
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  true, // save
  true, // [optional] delete / detach without confirmation
  predefinedSavePath  // [optional]; if unset the save path dialog should be opened
);

To be more backwards compatible the predefinedSavePaht maybe could be combined in an array with the boolean attribute for save=true:

messenger.detachAllAttachments(
  attachmentContentTypeArray.length,
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  [true, predefinedSavePath],  // if true, the predefinedSavePath could be optional
  true // [optional] delete / detach without confirmation
);

This predefinedSavePath could be used in my addon "AttachmentExtractor Continued" for example. Then the addon would be able to use Thunderbirds internal detach routine and the deleted attachments could still be linked to the original messages (which is an improvement in Thunderbird 68).

For reference:
https://searchfox.org/comm-central/search?q=detachAllAttachments
https://searchfox.org/comm-central/source/mail/base/content/msgHdrView.js#3238
https://searchfox.org/comm-central/source/mailnews/base/src/nsMessenger.cpp#2651

Yes, it's unfortunate that the code in mailnews/base/src/nsMessenger.cpp does some mandatory prompting in the backend.

I'm sure we'd accept a patch for this.

Component: FileLink → Attachments
Priority: -- → P3
Product: Thunderbird → MailNews Core
Summary: Provide an additional save path attribute in function call "messenger.detachAllAttachments() → Provide an additional save path attribute in function call nsMessenger::DetachAllAttachments().
Version: unspecified → Trunk

Unfortunately I'm not able to do/provide the code in C++

Maybe @jobisoft could help out with a patch, because of his knowledge of my addon code.

Interesting, I will have a look.

Maybe some could provide the necessary patch?

Users of my addon are complaining about the missing links to the detached attachments.

In the meantime a new Attachment Extractor addon is created for Thunderbird 88+, which uses MailExtension-API in combination with a experiment API. This new addon still suffers from the lack of this Bug / Feature here and is forced to use a function, which doesn't provide the link to detached files on disc after extraction. And my efforts to provide an updated version of my addon needs the additional save path parameter still, too.

IMHO this is a sad annoyance, because you still have to do bulk detach operations without the improvement (link to files) introduced in Thunderbird 68.

So, if there is somebody, who could provide the additional code lines in the C++ part, it would be appreciated.

(In reply to Alex Ihrig [:Thunderbird_Mail_DE] from comment #0)

The function call could be like this:

messenger.detachAllAttachments(
  attachmentContentTypeArray.length,
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  true, // save
  true, // [optional] delete / detach without confirmation
  predefinedSavePath  // [optional]; if unset the save path dialog should be opened
);

To be more backwards compatible the predefinedSavePaht maybe could be combined in an array with the boolean attribute for save=true:

messenger.detachAllAttachments(
  attachmentContentTypeArray.length,
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  [true, predefinedSavePath],  // if true, the predefinedSavePath could be optional
  true // [optional] delete / detach without confirmation
);

From up Thunderbird 78 the first parameter must be removed, so it should now be like this:

messenger.detachAllAttachments(
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  [true, predefinedSavePath],  // if true, the predefinedSavePath could be optional
  true, // [optional] delete / detach without confirmation
);
You need to log in before you can comment on or make changes to this bug.