Skip to content

Commit

Permalink
#598: remove "query-printers", the client will be responsible for sen…
Browse files Browse the repository at this point in the history
…ding an updated list of printers from now on (when the server supports printing)

git-svn-id: https://xpra.org/svn/Xpra/trunk@8750 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 8, 2015
1 parent 73172f2 commit 64cdd47
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
56 changes: 32 additions & 24 deletions src/xpra/client/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 0 additions & 6 deletions src/xpra/server/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 64cdd47

Please sign in to comment.