Xpra: Ticket #1048: win32 forwarded printer filtering

The current code only forwards the printer definitions for printers marked as "LOCAL", maybe we want to allow more than that, see EnumPrinters.



Wed, 09 Dec 2015 06:15:50 GMT - Antoine Martin: owner changed

Implemented in r11383:

To see more debugging, run the Print.exe tool with printing debugging turned on:

SET XPRA_PRINTING_DEBUG=1
Print.exe

Note: although the documentation seems to imply that flags values can be OR-ed together, in my testing this was not the case. So the code will just iterate over each flag and query each type individually. ie querying both LOCAL and SHARED printers:

C:\Program Files\Xpra>SET XPRA_WIN32_PRINTER_FLAGS=LOCAL,SHARED
C:\Program Files\Xpra>Print.exe
PRINTER_ENUM_VALUES: {'REMOTE': 16, 'NAME': 8, 'CONNECTIONS': 4, 'SHARED': 32, 'LOCAL': 2, 'NETWORK': 64}
PRINTER_FLAGS=SHARED, LOCAL
PRINTER_ENUMS=['SHARED', 'LOCAL']
querying SHARED printers
SHARED printers: []
querying LOCAL printers
skipped printer: 8388608, Microsoft XPS Document Writer,Microsoft XPS Document Writer,, Microsoft XPS Document Writer,
found printer: 8388608, Canon iP2700 series,Canon iP2700 series,hello, Canon iP2700 series, a1
LOCAL printers: ['Canon iP2700 series']
win32.get_printers()={'Canon iP2700 series': {'printer-info': 'Canon iP2700 series,hello', 'type': 'LOCAL', 'printer-make-and-model': 'a1'}}
* Canon iP2700 series
        printer-info                     : Canon iP2700 series,hello
        type                             : LOCAL
        printer-make-and-model           : a1

@afarr / llippold: do we want to change the default? how does that play with network printers? AD? Samba shared printers? Cups shared printers? More importantly: does this cause loops if the client can see the cups server where we forward the printer? etc..


Thu, 28 Jan 2016 22:08:27 GMT - J. Max Mena:

Re-attempting with a Win8.1 64-bit machine with a 0.17.0 r11765 client:

output:

C:\Program Files (x86)\Xpra>set XPRA_WIN32_PRINTER_FLAGS=LOCAL,SHARED
C:\Program Files (x86)\Xpra>Print.exe
2016-01-28 14:02:59,510 PRINTER_ENUM_VALUES: {'REMOTE': 16, 'NAME': 8, 'CONNECTI
ONS': 4, 'SHARED': 32, 'LOCAL': 2, 'NETWORK': 64}
2016-01-28 14:02:59,510 PRINTER_FLAGS=LOCAL, SHARED
2016-01-28 14:02:59,512 PRINTER_ENUMS=['LOCAL', 'SHARED']
get_printers() gsview is missing, not querying any printers
get_mimetype()=['application/pdf', 'application/postscript']
System Configuration:
        mimetypes                        : application/pdf, application/postscri
pt
        mimetypes.default                : application/pdf, application/postscri
pt

Thu, 28 Jan 2016 23:05:30 GMT - Antoine Martin: owner changed

Your problem comes from:

get_printers() gsview is missing, not querying any printers

This was caused by r11583 (for #1041), and should be fixed in r11772. New beta build uploaded.


Thu, 28 Jan 2016 23:43:54 GMT - J. Max Mena: owner changed

Upped to r11772:

C:\Program Files (x86)\Xpra>Print.exe
2016-01-28 15:40:40,249 PRINTER_ENUM_VALUES: {'REMOTE': 16, 'NAME': 8, 'CONNECTI
ONS': 4, 'SHARED': 32, 'LOCAL': 2, 'NETWORK': 64}
2016-01-28 15:40:40,249 PRINTER_FLAGS=LOCAL, SHARED
2016-01-28 15:40:40,249 PRINTER_ENUMS=['LOCAL', 'SHARED']
init_printing(None) printers_modified_callback=None
querying LOCAL printers
LOCAL printers: []
querying SHARED printers
SHARED printers: []
win32.get_printers()={}
get_mimetype()=['application/pdf', 'application/postscript']
System Configuration:
        mimetypes                        : application/pdf, application/postscri
pt
        mimetypes.default                : application/pdf, application/postscri
pt

Not sure what other logs to give you, I still have the debug enabled, along with the local and shared flags. The printer is added, and I can print to it from Notepad.


Thu, 28 Jan 2016 23:48:44 GMT - Antoine Martin: owner changed

Have you tried tweaking the XPRA_WIN32_PRINTER_FLAGS? ie:

SET XPRA_WIN32_PRINTER_FLAGS=LOCAL,SHARED,REMOTE,NETWORK

Thu, 28 Jan 2016 23:52:29 GMT - J. Max Mena: owner changed

Same result with XPRA_WIN32_PRINTER_FLAGS=LOCAL,SHARED,REMOTE,NETWORK.


Thu, 28 Jan 2016 23:56:42 GMT - Antoine Martin: owner changed

maxmylyn: please include the Print.exe -v output for this case


Thu, 28 Jan 2016 23:58:02 GMT - J. Max Mena:

Output as requested(with debug flag enabled):

C:\Program Files (x86)\Xpra>Print.exe -v
2016-01-28 15:57:45,318 PRINTER_ENUM_VALUES: {'REMOTE': 16, 'NAME': 8, 'CONNECTI
ONS': 4, 'SHARED': 32, 'LOCAL': 2, 'NETWORK': 64}
2016-01-28 15:57:45,318 PRINTER_FLAGS=LOCAL, SHARED, REMOTE, NETWORK
2016-01-28 15:57:45,318 PRINTER_ENUMS=['LOCAL', 'SHARED', 'REMOTE', 'NETWORK']
init_printing(None) printers_modified_callback=None
querying LOCAL printers
LOCAL printers: []
querying SHARED printers
SHARED printers: []
querying REMOTE printers
REMOTE printers: []
querying NETWORK printers
NETWORK printers: []
win32.get_printers()={}
get_mimetype()=['application/pdf', 'application/postscript']
System Configuration:
        mimetypes                        : application/pdf, application/postscri
pt
        mimetypes.default                : application/pdf, application/postscri
pt

Fri, 29 Jan 2016 00:07:35 GMT - Antoine Martin:

Not sure it will help but it is worth a try, can you try with values 2, 4 and 5:

set XPRA_WIN32_PRINTER_LEVEL=2
Print.exe -v

Fri, 29 Jan 2016 00:10:13 GMT - J. Max Mena: owner changed

Setting it to 2(and 4 and 5) added a new line to the print output:

Warning: failed to query REMOTE printers: (124, 'EnumPrinters', 'The system call
 level is not correct.')

Fri, 29 Jan 2016 00:55:03 GMT - Antoine Martin: owner changed

Damn. The documentation is not very helpful: EnumPrinters.

I did find one similar query for pywin32: printer identification on Windows network - and it seems that in order to query network printers we may need to pass all 3 flags at once... so r11775 allows you to do just that:

set XPRA_WIN32_PRINTER_FLAGS=LOCAL,NETWORK+SHARED+CONNECTIONS
Print.exe -v

You should first clear XPRA_WIN32_PRINTER_LEVEL (or reset to 1 which is the default), and maybe if you are desperate try different flag combinations and different printer levels.. (seems easier than understanding the API docs). I really hope this helps because my systems don't have such network printers available for testing, and I've wasted a lot of time on this already.

New beta posted.


Fri, 29 Jan 2016 19:37:02 GMT - J. Max Mena: owner changed

upped the client to r11776:

C:\Program Files (x86)\Xpra>Print.exe
* \\Spikes-dc3.Spikes.Inc\CM1415fnwOnQARack
        printer-info                     : \\Spikes-dc3.Spikes.Inc\CM1415fnwOnQA
Rack,HP Color LaserJet A4/Letter PCL6 Class Driver
        type                             : NETWORK, SHARED, CONNECTIONS
System Configuration:
        mimetypes                        : application/pdf, application/postscri
pt
        mimetypes.default                : application/pdf, application/postscri
pt

Looks like that did it.

Added a Windows Shared Printer(same flags):

C:\Program Files (x86)\Xpra>Print.exe
* \\DESKTOP-6OGV4KM\OfficePrinter (HP LaserJet CM1415fnw)
        printer-info                     : \\DESKTOP-6OGV4KM\OfficePrinter (HP L
aserJet CM1415fnw),HP LaserJet Professional CM1410 Series PCL 6,End of testbench
        type                             : NETWORK, SHARED, CONNECTIONS
        printer-make-and-model           : This is for testing, please do not us
e.
* \\Spikes-dc3.Spikes.Inc\CM1415fnwOnQARack
        printer-info                     : \\Spikes-dc3.Spikes.Inc\CM1415fnwOnQA
Rack,HP Color LaserJet A4/Letter PCL6 Class Driver
        type                             : NETWORK, SHARED, CONNECTIONS
System Configuration:
        mimetypes                        : application/pdf, application/postscri
pt
        mimetypes.default                : application/pdf, application/postscri
pt

Again looks like that worked. After chatting with Jok, it sounds like setting up a printer in CUPS, then sharing it over the network will be quite time consuming for little results. In his words, anyone that bothers to do it that way will definitely know what they're doing. I'll leave it up to you if you want us to try setting it up. I'll also look into sharing a printer from OSX, but I have a distinct feeling that Apple will make that hard. In the meantime, it's detecting the printers without difficulty.


Review


Fri, 29 Jan 2016 19:42:35 GMT - Antoine Martin: owner changed

@maxmylyn: cups should definitely be tested, as this is what we setup server side. We don't want to end up creating loops where a client then forwards a printer to the server, which adds it in cups, and gets picked up by the client again.. The machines will need to be on the same network with mdns enabled for the printers to be automatically added, Fedora does this by default I believe. Same for osx, which also uses cups. Until that is confirmed, I am reluctant to make it auto-add network printers.


Sat, 30 Jan 2016 00:54:56 GMT - J. Max Mena:

That took the better part of today. (Somebody owes Jok and me several beers now)

From here:

Now that I'm connected, I can print to the printer in Windows - the one I added from the SMB Share. This works. Refreshing the SMB share shows no new printers. This is a relatively clean Fedora 23 machine, so it seems to work here.

Still TODO:


Thu, 04 Feb 2016 23:03:33 GMT - Antoine Martin:

r11843 makes querying network printers the default in trunk.

r11844 backports both changes to v0.16.x

Please close if this works for you.


Thu, 04 Feb 2016 23:21:10 GMT - alas: status changed; resolution set

Ok... confirmed that maxmylyn set up the CUPS printer on a Fedora 23 machine as well as setting up the same printer as a local printer... then connected a windows client to the server which also had an AD network set up for the same printer, the same printer set up as a local printer on the windows client, and the same printer set up as a shared printer via yet another windows machine on the same network.

There were a lot of choices of icons to use in order to print to that printer (maybe the printer should be re-named to Rome)... but we didn't come up with any sane configuration that would produce any loops.

Closing - but will open a new ticket promptly if it turns out there's a configuration we missed which causes a problem.


Sat, 26 Mar 2016 04:31:20 GMT - Antoine Martin:

Contrary to what comment:15 says, network printers were not enabled by default in 0.16.x (and no one told me), r12222 fixes that.


Sat, 23 Jan 2021 05:13:29 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1048