Skip to content

Commit

Permalink
#3930 use the same prefix for all subsystem packets
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Sep 2, 2023
1 parent ef032fc commit 3e21c8a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/unittests/unit/server/mixins/notification_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_notification(self):
self._test_mixin_class(notification.NotificationForwarder, opts)
self.verify_packet_error(("notification-close", 1, "test", "hello"))
self.verify_packet_error(("notification-action", 1))
self.handle_packet(("set-notify", False))
self.handle_packet(("notification-status", False))
self.mixin.cleanup()
time.sleep(0.1)
finally:
Expand Down
10 changes: 7 additions & 3 deletions xpra/client/mixins/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,12 @@ def process_ui_capabilities(self, caps : typedict) -> None:


def init_authenticated_packet_handlers(self) -> None:
self.add_packet_handler("set-clipboard-enabled", self._process_clipboard_enabled_status)
self.add_packet_handler("set-clipboard-enabled", self._process_clipboard_status)
for x in (
"token", "request",
"contents", "contents-none",
"pending-requests", "enable-selections",
"status",
):
self.add_packet_handler("clipboard-%s" % x, self._process_clipboard_packet)

Expand Down Expand Up @@ -243,10 +244,13 @@ def make_clipboard_helper(self):
def _process_clipboard_packet(self, packet : PacketType) -> None:
ch = self.clipboard_helper
log("process_clipboard_packet: %s, helper=%s", bytestostr(packet[0]), ch)
if ch:
packet_type = packet[0]
if packet_type=="clipboard-status":
self._process_clipboard_status(packet)
elif ch:
ch.process_clipboard_packet(packet)

def _process_clipboard_enabled_status(self, packet: PacketType) -> None:
def _process_clipboard_status(self, packet: PacketType) -> None:
clipboard_enabled, reason = packet[1:3]
if self.clipboard_enabled!=clipboard_enabled:
log.info("clipboard toggled to %s by the server, reason given:", ["off", "on"][int(clipboard_enabled)])
Expand Down
9 changes: 7 additions & 2 deletions xpra/server/mixins/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ def _process_clipboard_packet(self, proto, packet : PacketType) -> None:
if not ss:
#protocol has been dropped!
return
packet_type = packet[0]
if packet_type=="clipboard-status":
self._process_clipboard_status(proto, packet)
return
if self._clipboard_client!=ss:
log("the clipboard packet '%s' does not come from the clipboard owner!", packet[0])
return
Expand All @@ -211,7 +215,7 @@ def _process_clipboard_packet(self, proto, packet : PacketType) -> None:
assert ch, "received a clipboard packet but clipboard sharing is disabled"
self.idle_add(ch.process_clipboard_packet, packet)

def _process_clipboard_enabled_status(self, proto, packet : PacketType) -> None:
def _process_clipboard_status(self, proto, packet : PacketType) -> None:
assert self.clipboard
if self.readonly:
return
Expand Down Expand Up @@ -253,9 +257,10 @@ def send_clipboard_packet(self, *parts) -> None:

def init_packet_handlers(self) -> None:
if self.clipboard:
self.add_packet_handler("set-clipboard-enabled", self._process_clipboard_enabled_status)
self.add_packet_handler("set-clipboard-enabled", self._process_clipboard_status)
for x in (
"token", "request", "contents", "contents-none",
"pending-requests", "enable-selections", "loop-uuids",
"status",
):
self.add_packet_handler("clipboard-%s" % x, self._process_clipboard_packet)
5 changes: 3 additions & 2 deletions xpra/server/mixins/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def notify_close_callback(self, nid:int) -> None:
ss.notify_close(int(nid))


def _process_set_notify(self, proto, packet : PacketType) -> None:
def _process_notification_status(self, proto, packet : PacketType) -> None:
assert self.notifications, "cannot toggle notifications: the feature is disabled"
ss = self.get_server_source(proto)
if ss:
Expand Down Expand Up @@ -204,5 +204,6 @@ def init_packet_handlers(self) -> None:
self.add_packet_handlers({
"notification-close" : self._process_notification_close,
"notification-action" : self._process_notification_action,
"set-notify" : self._process_set_notify,
"notification-status" : self._process_notification_status,
"set-notify" : self._process_notification_status,
})

0 comments on commit 3e21c8a

Please sign in to comment.