diff --git a/src/xpra/client/client_base.py b/src/xpra/client/client_base.py index b23cc5ec84..4b984ea669 100644 --- a/src/xpra/client/client_base.py +++ b/src/xpra/client/client_base.py @@ -196,7 +196,6 @@ def setup_connection(self, conn): def init_packet_handlers(self): self._packet_handlers = { "hello" : self._process_hello, - "query-printers" : self._process_query_printers, "send-file" : self._process_send_file, } self._ui_packet_handlers = { @@ -522,11 +521,43 @@ def server_connection_established(self): if not self.parse_encryption_capabilities(): log("server_connection_established() failed encryption capabilities") return False + self.parse_printing_capabilities() log("server_connection_established() adding authenticated packet handlers") self.init_authenticated_packet_handlers() return True + def parse_printing_capabilities(self): + if self.printing: + if self.server_capabilities.boolget("printing"): + try: + self.send_printers() + except Exception: + log.warn("failed to send printers", exc_info=True) + + def send_printers(self): + from xpra.platform.printing import get_printers + printers = get_printers() + printlog("send_printers() found printers=%s", printers) + #remove xpra forwarded ones to avoid loops and multi-forwards: + exported_printers = {} + for k,v in printers.items(): + device_uri = v.get("device-uri", "") + if device_uri: + printlog("send_printers: device-uri(%s)=%s", k, device_uri) + if device_uri.startswith("xpraforwarder"): + printlog("process_query_printers skipping xpra forwarded printer=%s", k) + continue + state = v.get("printer-state") + if state==5: + printlog("send_printers skipping stopped printer=%s", k) + continue + #"3" if the destination is idle, "4" if the destination is printing a job, and "5" if the destination is stopped. + exported_printers[k.encode("utf8")] = v + printlog("send_printers() exported printers=%s", ", ".join(str(x) for x in exported_printers.keys())) + self.send("printers", exported_printers) + + def parse_version_capabilities(self): c = self.server_capabilities self._remote_machine_id = c.strget("machine_id") @@ -578,29 +609,6 @@ def _process_set_deflate(self, packet): pass - def _process_query_printers(self, packet): - from xpra.platform.printing import get_printers - printers = get_printers() - printlog("process_query_printers(%s) found printers=%s", packet, printers) - #remove xpra forwarded ones to avoid loops and multi-forwards: - exported_printers = {} - for k,v in printers.items(): - device_uri = v.get("device-uri", "") - if device_uri: - printlog("process_query_printers: device-uri(%s)=%s", k, device_uri) - if device_uri.startswith("xpraforwarder"): - printlog("process_query_printers skipping xpra forwarded printer=%s", k) - continue - state = v.get("printer-state") - if state==5: - printlog("process_query_printers skipping stopped printer=%s", k) - continue - #"3" if the destination is idle, "4" if the destination is printing a job, and "5" if the destination is stopped. - exported_printers[k.encode("utf8")] = v - printlog("process_query_printers(%s) exported printers=%s", packet, ", ".join(str(x) for x in exported_printers.keys())) - self.send("printers", exported_printers) - - def _process_send_file(self, packet): #send-file basefilename, printit, openit, filesize, 0, data) from xpra.platform.features import DOWNLOAD_PATH diff --git a/src/xpra/server/server_base.py b/src/xpra/server/server_base.py index 7a1f92f59b..88690f34b3 100644 --- a/src/xpra/server/server_base.py +++ b/src/xpra/server/server_base.py @@ -836,9 +836,6 @@ def do_parse_hello_ui(self, ss, c, auth_caps, send_ui, share_count): # now we can set the modifiers to match the client self.send_windows_and_cursors(ss, share_count>0) - if self.printing and ss.printing: - ss.query_printers() - ss.startup_complete() self.server_event("startup-complete", ss.uuid) diff --git a/src/xpra/server/source.py b/src/xpra/server/source.py index 281cf7e160..88709c5b3d 100644 --- a/src/xpra/server/source.py +++ b/src/xpra/server/source.py @@ -753,12 +753,6 @@ def parse_proxy_video(self): self.video_helper.add_encoder_spec(encoding, colorspace, spec) - def query_printers(self): - assert self.printing - if self.machine_id!=get_machine_id() or ADD_LOCAL_PRINTERS: - self.send("query-printers") - - def startup_complete(self): log("startup_complete()") if self.notify_startup_complete: