cleidigh / printing-tools-ng

PrintingTools NG Thunderbird Extension - Printing Utilities
Other
35 stars 17 forks source link

Integrate PTNG with FiltaQuila for automatic printing #94

Closed cleidigh closed 2 years ago

cleidigh commented 2 years ago

Work with @realraven to have messaging between FQ and PTNG enabling automatic printing

@cleidigh

RealRaven2000 commented 2 years ago

If you would like me to integration test later, can you either commit your current changes, make a new branch or upload a version here in a comment?

RealRaven2000 commented 2 years ago

@cleidigh Some patch code - WIP!

printing_tools_patch_fq.zip

Currently the notification is not received by the listener in messengerOL.js (I tried adding notifyTools.enable() but no joy). Maybe @jobisoft can have a look!

Latest version of filtaquilla: filtaquilla-3.3.1pre22.zip

RealRaven2000 commented 2 years ago

@cleidigh I did some more tests today - created a background page (one of the differences I have in my add-ons that we have a page for the background and include the script there, there was some fundamental difference here that was explained too many weeks ago on the Dev Call. Then I also added the "notifications" permission to the manifest. I also refreshed both WindowListener and Notifications APIs to the latest versions (notifications was only 1.1 and is currently 1.3). Still the same problem - the event listener in messengerOL.js still does not receive the message.

I also commented out unnecessary documents from registering the WindowListener in background.js (messenger.xul, msgPrintEngine.xhtml, msgPrintEngine.xul, addressbook.xul) to avoid any errors on startup.

changed files: pntng-2.0.7p14.zip

cleidigh commented 2 years ago

i posted a first test i get multiple handle events on the exp side

RealRaven2000 commented 2 years ago

could you commit your changes?

RealRaven2000 commented 2 years ago

here are the latest changes from todays zoom conference

content-new.zip

cleidigh commented 2 years ago

@RealRaven2000 @madvinegar @querixg @ditchfinder @kiki-ja

All Axel and I have made a formal integration between FiltaQuila and PTNG

first you need the beta fq and ptng b14 https://github.com/cleidigh/printing-tools-ng/files/8091829/filtaquilla-3.3.1pre22.zip

on then enable ptng print in fq actions create your filter with the print action the message will print silently automatically

please post here with issues

thanks @RealRaven2000 @cleidigh

All

ditchfinder commented 2 years ago

@RealRaven2000 @madvinegar @querixg @ditchfinder @kiki-ja

Windows 10 FQ 3.3.1pre22 (installed zip file) PTNG 2.0.7-b14p1 (Installed .xpi) TB 91.6.1

Unable to get this to work still I'm afraid.

Used PTNG option ticked in FQ Set up a new filter in case that was affecting anything. Filter completes and logs show print action

CTRL + P uses PTNG options correctly

Tried a OS reboot and reinstall of add-ons but no change.

Only weird thing to note was that after reboot of OS both add-ons ahad already been removed from TB but not by me manually. Is there a setting in TB which automatically does this?

Cheers Martin

RealRaven2000 commented 2 years ago

Unable to get this to work still I'm afraid.

Used PTNG option ticked in FQ Set up a new filter in case that was affecting anything. Filter completes and logs show print action

When we successfully tested on my machine the other day I was definitely using 3.3.1 pre 22 - so it should be ok from that said. Did you install by dragging into extension manager or via "Debug ADd-ons"? The later would explain why they were removed on restart. Just drag the xpi / zip file into Extension manager and it should work. I believe @cleidigh added some logs to JavaScript error console, so you could check what's added there during filtering (Ctrl+Shift+J to open it)

ditchfinder commented 2 years ago

I Installed by clicking on the cog in the Add-ons manager and "Install Add-on from File"

I'll try again using the drag and drop approach and then look at the JS debugger

kiki-ja commented 2 years ago

@cleidigh @RealRaven2000 @madvinegar @querixg @ditchfinder All

FiltaQuilla 3.3.1pre22 PrintingTools NG 2.0.7-b14 (not -b14p1) Thunderbird 91.6.1 64bit Windows 10 Pro 21H2 64bit

The following is a report on the results of the automatic printing. The result is that only one of the seven messages was printed. I think it's probably the same as @ditchfinder.

Steps to Reproduce

  1. Set "Use PrintingTools NG for printing" as Filter Action in FiltaQuilla.
  2. In Filter Rules, set the Match Condition to Subject = "会議" and Action to Print.
  3. Manually Run was executed on the target folder.
  4. Only one of the seven messages whose subject matched "会議" was printed automatically.
  5. The Filter Log shows the record of the automatic printing of the seven messages.

Please refer to the screenshot below.

自動印刷の結果レポート 2 0 7-b14

@kiki-ja

ditchfinder commented 2 years ago

OK no change so using the debugger I can see: Object { command: "printMessage", messageHeader: {…} } background.js:159:10 but no output to printer

Other things to note. Inorder for 'Print to be an option in Filters I have to tick both the Print and PTNG boxes in FQ

image

RealRaven2000 commented 2 years ago

OK no change so using the debugger I can see: Object { command: "printMessage", messageHeader: {…} } background.js:159:10 but no output to printer

Other things to note. Inorder for 'Print to be an option in Filters I have to tick both the Print and PTNG boxes in FQ

Yes that's by design. About duplication: The problem is that Thunderbird has a hard time removing actions (unless you restart Thunderbird). And then it will only work if you have the [x] Print options switched on (this makes the Print command visible as action). the other checkbox "use Printing tools NG for printing" is just an additional option. To make that more obvious I should probably disable the option if the [x] Print option is disabled.

Since Tb messes up the removal of old actions, the topmost menu items may still trigger old code, so its probably best to restart Tb after installing a new version of FiltaQuilla.

ditchfinder commented 2 years ago

OK so changed opions in FQ image but no option in Filters image

This is after fresh install of FQ, New Filter created with different name and OS restart

ditchfinder commented 2 years ago

Doh, just reread your post @RealRaven2000, so both print options ticked and then TB restart and duplication is no longer there. Autoprint still not working though

ditchfinder commented 2 years ago

@RealRaven2000 @cleidigh so now another issue. If I right-click on message and try to print using PTNG option I get following errors. image

RealRaven2000 commented 2 years ago

Did you try running the filter manually? that's the best test.

Highlight an email making sure the condition will apply, then select tools / run filters on message (or use the appropriate quickFilters button, if you have my Add-on quickFilters installed.) image or image

ditchfinder commented 2 years ago

Run filter on message reults in this: image but it doesn't actually print

If I right-click on message and use PTNG option it prints but is not hiding the headers which I have set it to in PTNG

RealRaven2000 commented 2 years ago

Could it be that you're using the wrong version of PTNG?

PrintingTools NG 2.0.7-b14 (not -b14p1)

try this one: p1.zip

ditchfinder commented 2 years ago

image Think I'm on the right one but I'll install that one and test

ditchfinder commented 2 years ago

@RealRaven2000 @cleidigh @kiki-ja

We have a winner ! Installing the p1.zip got it working. Not sure why the .xpi I installed didn't but there you go

RealRaven2000 commented 2 years ago

I am not sure, but maybe @cleidigh didn't commit all the changes I sent him? Just a hunch.

Also I think he should add some safety in his function function handleMessage(message, sender) at least he should check whether the passed in message object has:

message.command == "printMessage"
cleidigh commented 2 years ago

@RealRaven2000 @ditchfinder

my changes were a slight modification given other cases needed now i will address necessary protections

a quick look may show incomplete messaging

i have to reproduce

cleidigh commented 2 years ago

@ditchfinder with b14 are all messages printed correctly now?

ditchfinder commented 2 years ago

@cleidigh Using the p1.zip posted by @RealRaven2000 above and the FQ 3.3.31 pre22 both installed by drag and drop - messages appear to be auto printing successfully and use the correct PTNG parameters that I set. I can do further testing tomorrow, so far I've only done simple .txt emails.

When I used the "printing-tools-ng-2.0.7-b14p1-tb.xpi" install I couldn't get it to work either auto printing or hiding headers when manually printing once FQ was installed

cleidigh commented 2 years ago

unfortunately b14p1 was never meant to be used it was between @realraven and I

cleidigh commented 2 years ago

@kiki-ja I understand you still have a multiple message issue I suspect it's a q issue @cleidigh

ditchfinder commented 2 years ago

Aha - Operator Error strikes again - image

If I'd read your post properly from yesterday I might not have wasted everyone's time - sorry about that

cleidigh commented 2 years ago

All I see q errors with a run filter on folder it is the darn new engine that has no completion events

@cleidigh

cleidigh commented 2 years ago

@ditchfinder no problem lots of moving parts

there is an issue with multiple messages I can see it now @cleidigh

cleidigh commented 2 years ago

@RealRaven2000 i think this will require some form of queing i also may see duplicate msgs from you but i can't be sure yet

kiki-ja commented 2 years ago

@RealRaven2000

Could it be that you're using the wrong version of PTNG? PrintingTools NG 2.0.7-b14 (not -b14p1) try this one: p1.zip

Yes, I tried using it.

FiltaQuilla 3.3.1pre22 PrintingTools NG 2.0.7-b14p1 (p1.zip) Thunderbird 91.6.1 64bit Windows 10 Pro 21H2 64bit

The following is a report on the results of the automatic printing. The result was that of the seven messages that matched, nothing was printed.

Steps to Reproduce

  1. Set "Use PrintingTools NG for printing" as Filter Action in FiltaQuilla.
  2. In Filter Rules, set the Match Condition to Subject = "会議" and Action to Print.
  3. Manually Run was executed on the target folder.
  4. None of the seven messages whose subject matched "会議" were printed automatically.
  5. The Filter Log shows the record of the automatic printing of the seven messages.

Is my procedure wrong? @RealRaven2000, Are you having success with automatic printing of multiple messages?

@cleidigh

I understand you still have a multiple message issue I suspect it's a q issue

Understood. I can email you the Thunderbird error console log if you need it. I hope to have this resolved in the near future.

@kiki-ja

kiki-ja commented 2 years ago

@3LaHoonK

Are you saying that you want to be able to autoprint with PrintingTools NG alone, without using FiltaQuilla? In other words, do you want to do autoprinting with message filters and PrintingTools NG?

Which of the following?

  1. FiltaQuilla + Message Filter + PrintingTools NG = Auto Print
  2. Message Filter + PrintingTools NG = Auto Print
  3. Other?

@kiki-ja

RealRaven2000 commented 2 years ago

@RealRaven2000 i think this will require some form of queing i also may see duplicate msgs from you but i can't be sure yet

We might need a better strategy of logging what we do. So I added a new debug switch

extensions.filtaquilla.debug.PrintingToolsNG = true

which you can activate on the filtaquilla settings in the About / Help page:

activate the debug box, then right-click it for more settings:

image

image

In error console enable these options: image

Then you will see an entry whenever FQ sends a command to PrintingToolsNG, containing subject and date / time of the message, e.g.:

printMessage ( 'Filtaquilla - print test' - 16/1/2022 15:50:11 )

New version with the debugging option below: filtaquilla-3.4pre50.zip

I already did a test running "filters on folder" manually, on a folder that contains 2 matching Emails, and it appears that I am sending two messages to PTNG, but nothing prints. It does print both mails if I set a breakpoint on PTNG's side and it has time to process the print commands one by one. So I guess it gets confused when multiple mails are sent for processing - queueing definitely has to be implemented on that side? I don't think I should implement the queue on the FiltaQuilla side as this would require a complicated handshake between both Add-ons.

3LaHoonK commented 2 years ago

@3LaHoonK

Are you saying that you want to be able to autoprint with PrintingTools NG alone, without using FiltaQuilla? In other words, do you want to do autoprinting with message filters and PrintingTools NG?

Which of the following?

  1. FiltaQuilla + Message Filter + PrintingTools NG = Auto Print
  2. Message Filter + PrintingTools NG = Auto Print
  3. Other?

@kiki-ja

Hello,,

@kiki-ja

The best option is number 2

RealRaven2000 commented 2 years ago

@3LaHoonK

  1. FiltaQuilla + Message Filter + PrintingTools NG = Auto Print
  2. Message Filter + PrintingTools NG = Auto Print
  3. Other?

@kiki-ja

Hello,,

@kiki-ja

The best option is number 2

"best"?

I (maintainer of FiltaQuilla, since Kent James retired for health reasons) wouldn't say (2) is impossible but you add an awful lot of unneeded complexity to PrintingTools NG - now that we already have integrated PTNG into the core business of FiltaQuilla (augmentation of filter capabilities) it seems highly unnecessary.

You have to keep in mind that if the highly specialized architecture of Filters changes, I have to adjust the FQ code accordingly based on the technical debt of both the inflexible Thunderbird Core code and the way the Add-on was implemented. I had to spend more than 3 full weeks to convert the code to make it compatible to Tb78 - after Mozilla removed xml bindings, and we are still very very far away from turning it from a mx with experimental APIs (Which requires full system access) into a pure mail extension that's based on the official APIs.

So in my opinion (1) is the best option for keeping the functionality alive. The other advantage of this solution is that this modular approach now also opens the road for integration of PrintingTools NG into other Add-ons - for instance cardbook or calendar Add-ons. Function bloat is one of the reasons that make software unmanageable. The other advantage is that Christopher will have an easier time converting PTNG to a pure mail extension, and that will translate into more users being able to use and promoting the Add-on.

What are your thoughts on this, @cleidigh ?

cleidigh commented 2 years ago

@RealRaven2000 @3LaHoonK Yes, ptng is a header formater at its core, attempting to implement filtering would be an enormous effort duplicating all of Axels hard work.

Right now just getting the new print engine working reliably is proving very difficult. @cleidigh

cleidigh commented 2 years ago

@RealRaven2000 i Think your side is fine, I was fooled by two emails with the same subject.

the problem is clearly a reentrancy issue. i am working on a q setup today. the print system does not like reentrancy as well

cleidigh commented 2 years ago

@RealRaven2000 @kiki-ja @ditchfinder @3LaHoonK

I think I have a solution to address the reentrancy issue with multiple incoming messages. Due to my limitations I could not do major testing,but I think I proved the q is mainly working,hopefully we can tease out any issues because I really want to release soon.

Use b15 https://github.com/cleidigh/printing-tools-ng/blob/v2.0.7/xpi/printing-tools-ng-2.0.7-b15-tb.xpi

@cleidigh

3LaHoonK commented 2 years ago

Hello @cleidigh

thunderbird Version 91.6.1 + PrintingTools NG Version 2.0.7-b15 + FiltaQuilla Version 3.3

It works fine but there is a problem

The header of the page cannot be hidden

Awaiting your reply, thank you

image image image

cleidigh commented 2 years ago

@3LaHoonK You are using the wrong FiltaQuila, you have to use Axel's beta which has the new PTNG capability. https://github.com/cleidigh/printing-tools-ng/files/8140168/filtaquilla-3.4pre50.zip

Also look up thread for the image on setting the FiltaQuila action for printing to ptng

Note : if you see the grey background with the last line darker, that is tb print not ptng @cleidigh

RealRaven2000 commented 2 years ago

@3LaHoonK make sure you add a comment or like on my github so you are notified of the latest versions. https://github.com/RealRaven2000/FiltaQuilla/issues/152#issuecomment-1050708632

ditchfinder commented 2 years ago

@RealRaven2000 @cleidigh @3LaHoonK @kiki-ja Windows 10 TB 91.6.1 (32-bit) FQ 3.3.1pre22 PTNG 2.0.7-b15

2 emails matching filter printed OK without headers as specified in PTNG using Tools > Run messages on folder Also worked on receipt of email matching filter rules.

Any other testing you need me to do.

(Never noticed my TB was the 32 bit version before - any reason to upgrade to 64?)

kiki-ja commented 2 years ago

@cleidigh All

FiltaQuilla 3.3.1pre22 PrintingTools NG 2.0.7-b15 Thunderbird 91.6.1 64bit Windows 10 Pro 21H2 64bit

Successfully printed 7 messages matched by the message filter in automatic sequence. It's great. Thank you very much.

@kiki-ja

cleidigh commented 2 years ago

@3LaHoonK With the correct versions were you successful? @cleidigh

3LaHoonK commented 2 years ago

Hello,

@cleidigh

Yes I succeeded thank you and I wish to develop my best thank you

cleidigh commented 2 years ago

@3LaHoonK Excellent! I think that makes us 5/5 I will consider this ready for the release Thanks for your help! @cleidigh

cleidigh commented 2 years ago

@RealRaven2000 Looks like our cool new integration is testing well! I will be releasing soon, what is your timeline? What shall we tell users? @cleidigh

RealRaven2000 commented 2 years ago

@RealRaven2000 Looks like our cool new integration is testing well! I will be releasing soon, what is your timeline? What shall we tell users?

I have another new 3rd party Add-on integration feature - this time it integrates filter actions with SmartTemplates, see issue 153 - just documented on the "SmartTemplates Premium" support page:

https://smarttemplates.quickfolders.org/premium.html#filterForward

...which I want to release concurrently with the new version of FiltaQuilla very soon (within the next fortnight). PrintingTools NG will be supported from the same version onward - FiltaQuilla 3.4. Since you add significant features are you planning to raise your minor version as well (to 2.1) ?