MozillaZine

Thunderbird Extension: Delete Junk Context Menu 0.3.2

Talk about add-ons and extension development.
chuonthis
 
Posts: 519
Joined: July 23rd, 2003, 10:17 am

Post Posted February 23rd, 2004, 8:06 pm

<a href="http://www.chuonthis.com/extensions/deletejunk.php"><b>Delete Junk Context Menu 0.3.2</b></a> - Adds a menu item to <u>delete mail marked as junk</u> from the folder that you right click on. Optionally bypasses the Trash folder when deleting!

[ <a href="http://www.chuonthis.com/extensions/deletejunk.php"><b>more info</b></a> | <a href="http://www.chuonthis.com/extensions/tb/deletejunk_0_3_2.xpi"><b>download</b></a> ]

<img src="http://www.chuonthis.com/extensions/tb/deletejunk.gif">

</ul><b>History</b><ul><li><a href="http://www.chuonthis.com/extensions/tb/deletejunk_0_3_2.xpi"><b>0.3.2</b></a> - 2004.09.09 - Fixed issue with 0.7+ nightlies where the context menu would show hidden menuitems. Hopefully fixed any issues with messages left in preview pane. Added icon for Extension Manager. Updated for 0.8+.
<li><a href="http://www.chuonthis.com/extensions/tb/deletejunk_0_3_1.xpi"><b>0.3.1</b></a> - 2004.06.14 - Updated for new Extension Manager. New version numbering scheme. No functional changes.
</ul>
Last edited by chuonthis on September 8th, 2004, 11:58 pm, edited 9 times in total.
chuonthis extensions: [fx] BookKey 0.0.1, OpenBook 2.0.1.1, Update Bookmark 0.0.5.1 [tb] Buttons! 0.5.3.2, DeleteJunk 0.3.2, Flipping the Thunderbird 0.0.0.1, Folderpane 0.0.5, NNWODC 0.2.3

matejkorat
 
Posts: 3
Joined: February 13th, 2004, 5:03 am

Post Posted February 24th, 2004, 3:11 am

Hi.
About the 'insertafter' and 'insertbefore'...

You should add the following lines to the overlay section in your 'contents.rdf' file:

...
<!-- overlay information -->
<RDF:Seq about="urn:mozilla:overlays">
<RDF:li resource="chrome://messenger/content/mailWindowOverlay.xul"/>
<RDF:li resource="chrome://messenger/content/folderPane.xul"/>
<RDF:li resource="chrome://messenger/content/msgFolderPickerOverlay.xul"/>
<RDF:li resource="chrome://messenger/content/folderProps.xul"/>
</RDF:Seq>

<RDF:Seq about="chrome://messenger/content/mailWindowOverlay.xul">
<RDF:li>chrome://deletejunk/content/deletejunk.xul</RDF:li>
</RDF:Seq>

<RDF:Seq about="chrome://messenger/content/folderPane.xul">
<RDF:li>chrome://deletejunk/content/deletejunk.xul</RDF:li>
</RDF:Seq>

<RDF:Seq about="chrome://messenger/content/msgFolderPickerOverlay.xul">
<RDF:li>chrome://deletejunkcontent/deletejunk.xul</RDF:li>
</RDF:Seq>

<RDF:Seq about="chrome://messenger/content/folderProps.xul">
<RDF:li>chrome://deletejunk/content/deletejunk.xul</RDF:li>
</RDF:Seq>
...

and then the 'insertafter' and 'insertbefore' commands
...
<popup id="folderPaneContext">
<menuitem id="folderPaneContext-deletejunk" label="Delete Mail Marked as Junk" accesskey="e" insertafter="folderPaneContext-properties" oncommand="deletejunk();" />
<menuseparator id="folderPaneContext-sepjunk" insertafter="folderPaneContext-properties" />
</popup>
...
in your deletejunk.xul file should take effect.

Bye.
--
<matej.korat@uni-mb.si>

chuonthis
 
Posts: 519
Joined: July 23rd, 2003, 10:17 am

Post Posted February 24th, 2004, 4:18 pm

Thanks matejkorat, made the changes and moved the menu item. Bump for new version.
chuonthis extensions: [fx] BookKey 0.0.1, OpenBook 2.0.1.1, Update Bookmark 0.0.5.1 [tb] Buttons! 0.5.3.2, DeleteJunk 0.3.2, Flipping the Thunderbird 0.0.0.1, Folderpane 0.0.5, NNWODC 0.2.3

PeterR
 
Posts: 51
Joined: February 12th, 2004, 12:29 am
Location: USA

Post Posted February 25th, 2004, 11:23 am

chuonthis,

You've got a great thing going here.

Is it possible to have the extension add another item called "Empty Junk" in the File menu and when right-clicking on the Junk folder? This would directly delete the contents of the Junk folder (not put it in the Trash).

The Trash folder has a File and context menu item like this but Junk does not and I see many people asking for it.

Thanks!

chuonthis
 
Posts: 519
Joined: July 23rd, 2003, 10:17 am

Post Posted February 25th, 2004, 12:08 pm

I'll look into it. Hopefully, it won't use any version-specific code. =)
chuonthis extensions: [fx] BookKey 0.0.1, OpenBook 2.0.1.1, Update Bookmark 0.0.5.1 [tb] Buttons! 0.5.3.2, DeleteJunk 0.3.2, Flipping the Thunderbird 0.0.0.1, Folderpane 0.0.5, NNWODC 0.2.3

PeterR
 
Posts: 51
Joined: February 12th, 2004, 12:29 am
Location: USA

Post Posted February 25th, 2004, 12:20 pm

Fantastic! And I agree on the version-specific code issue.

Old Ausdilecce
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted February 25th, 2004, 4:41 pm

hey chuonthis,

I made a very basic macro that delete's the contents of Junk
It does delete messages in Junk (not put it in the Trash).

Here is the macro code that you could possibly add to the extension you are making
Hope it helps

var message = GetLoadedMessage()
if (message > "") {
// This will save the users currently selected message if there is one
var gCurrentMessageUri;
gCurrentMessageUri = gDBView.URIForFirstSelectedMessage;
}
var selectedFolders = GetSelectedMsgFolders();
var selectedFolder = selectedFolders[0];
var resource = selectedFolder.QueryInterface(Components.interfaces.nsIRDFResource);
var msgfolder = resource.QueryInterface(Components.interfaces.nsIMsgFolder);
var CurrentFolder = msgfolder.URI
SelectFolder("mailbox://nobody@Local%20Folders/Junk");
goDoCommand('cmd_selectAll');
goDoCommand('cmd_shiftDelete');
MsgCompactFolder(false);
SelectFolder(CurrentFolder);
if (message > "") {
SelectMessage(gCurrentMessageUri);}

Please don't flame me if there is a better way.
I made this quick n dirty.

Obviously, this macro only works on local folders (where I use it)
It shouldn't be too dificult to modify it to work on pop folders as well

Good luck

chuonthis
 
Posts: 519
Joined: July 23rd, 2003, 10:17 am

Post Posted February 25th, 2004, 5:03 pm

Hmm...a couple ideas (thanks ausdilecce):

1) Would people be interested if I made a key binding, say Ctrl-Alt-J or something that will run the Delete Junk command on the currently selected account's Junk folder (even if you're not in the Junk folder)? I think I can put that together.

2) Do people want the menuitem to restore the folder you were in before you clicked on the menuitem? It seems like there's no way to get around having to load the folder you select, then delete the junk from it, but I can restore the original folder if that'd be more useful (or add a pref?).

3) If I add an option to delete junk mail permanently bypassing the Trash, it will be using some lower-level calls that may become version-dependent but currently, seems like it is okay unless there are major changes to the code. I'll work on a version that does this and see if it is working for everyone.
chuonthis extensions: [fx] BookKey 0.0.1, OpenBook 2.0.1.1, Update Bookmark 0.0.5.1 [tb] Buttons! 0.5.3.2, DeleteJunk 0.3.2, Flipping the Thunderbird 0.0.0.1, Folderpane 0.0.5, NNWODC 0.2.3

Old Ausdilecce
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted February 25th, 2004, 5:26 pm

Chuonthis,

It seems as tho the delete (bypass trash) is something that TB itself does (shift delete?) so thats why I used 'goDoCommand('cmd_shiftDelete');
' because thats a call that *many* TB functions use

Old Ausdilecce
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted February 25th, 2004, 5:29 pm

Sorry for the multiple posts but
please note that I added 'MsgCompactFolder(false);' after deleting junk
this function actually does compact the folder.
The 'false' bit tells TB not to compact all folders, just the currently selected one.

chuonthis
 
Posts: 519
Joined: July 23rd, 2003, 10:17 am

Post Posted February 25th, 2004, 9:36 pm

ausdilecce, I'm actually just calling a deleteJunkInFolder() function that already exists after selecting the folder. The function basically looks for all messages marked as junk and then deletes them (not shift delete). So either a) I copy the function into my own function and replace their delete command with a command that bypasses the trash (easy) but if there is some code change in that function, I'd want to update my function too, or b) I wanted to somehow capture the delete event and change it to a delete-and-bypass-trash command and just call the function and change their deletes. I've been trying to figure out how to do this but it's tough, especially with xulplanet down for the time being. For now, I'll just use method A to get things going. :)

I'm gonna work on a prefs window...how do these options sound?

Compact folder after deleting junk
Bypass trash always/only for Junk folder
Restore folder after executing command

Old Ausdilecce
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted February 25th, 2004, 9:48 pm

Options sound damn fine to me.

Ahh, I see. You are taking messages marked as junk and deleting them, as opposed to deleting the contents of the Junk folder. Right ?

I see copying the deleteJunkInFolder() into your own function a sure sign that you will be required to maintain your baby to keep up with version changes.

What you could do is make a array of messages marked as junk BEFORE you actually run the real deleteJunkInFolder(), then run a routine to really delete those message IDs from the trash (just a thot)

Capturing the delete event is a scary one, IMHO. As delete could be delete for a lot of things (folders, attachements, newsgroups etc.)

K.I.S.S. always works.

Cant wait (getting sick of my horrible macro already hehe)

chuonthis
 
Posts: 519
Joined: July 23rd, 2003, 10:17 am

Post Posted February 26th, 2004, 3:26 am

Bump for new version.

ausdilecce, did you ever have problems running compact folder after the delete? For some reason, when I enabled the option, I'd get weird things happening. A couple of times, I'd get an error saying "Could not delete message from folder because an operation is currently processing the folder" or something like that. Then the mails would show up in my Trash but would also still be in the folder. Looks like the compact folder command jumps in too soon? And then another couple of times, after running the command on some folder, all the mails that were marked as junk in my Trash were no longer marked as junk. I tried running lower level commands to compact the folder but the results were the same. I did not have any of these problems without compacting folders so I had to disable the option.
chuonthis extensions: [fx] BookKey 0.0.1, OpenBook 2.0.1.1, Update Bookmark 0.0.5.1 [tb] Buttons! 0.5.3.2, DeleteJunk 0.3.2, Flipping the Thunderbird 0.0.0.1, Folderpane 0.0.5, NNWODC 0.2.3

sboulema
 
Posts: 6615
Joined: May 20th, 2003, 12:34 am
Location: Amstelveen, The Netherlands

Post Posted February 26th, 2004, 4:51 am


PeterR
 
Posts: 51
Joined: February 12th, 2004, 12:29 am
Location: USA

Post Posted February 26th, 2004, 12:17 pm

chuonthis,

Those options look good. As for the "operation currently processing" message, I've seen that before while using Mozilla. Maybe I had too many filters moving stuff around. :)

If compacting after emptying the folder is problematic, you could leave it out since the folder can be compacted manually. It can also be compacted semi-automatically by turning on the "when 'x' bytes of space are wasted" option (whatever it's really called).

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 0 guests