From 3412ea716fc79321cc5e8fc7c2b32770eeeb3e07 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Fri, 29 Sep 2017 23:45:34 +0200 Subject: [PATCH] share: add support for sharing URLs --- src/mconnect/share.vala | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/mconnect/share.vala b/src/mconnect/share.vala index 3dbe478..b308fbc 100644 --- a/src/mconnect/share.vala +++ b/src/mconnect/share.vala @@ -66,21 +66,27 @@ class ShareHandler : Object, PacketHandlerInterface { return; } - if (pkt.payload == null) { - warning("missing payload info"); - return; - } - - string name = pkt.body.get_string_member("filename"); - debug("file: %s size: %s", name, format_size(pkt.payload.size)); - - var t = new DownloadTransfer( - dev, - new InetSocketAddress(dev.host, - (uint16) pkt.payload.port), - pkt.payload.size, - make_downloads_path(name)); + if (pkt.body.has_member("filename")) { + if (pkt.payload == null) { + warning("missing payload info"); + return; + } - t.start_async.begin(); + string name = pkt.body.get_string_member("filename"); + debug("file: %s size: %s", name, format_size(pkt.payload.size)); + + var t = new DownloadTransfer( + dev, + new InetSocketAddress(dev.host, + (uint16) pkt.payload.port), + pkt.payload.size, + make_downloads_path(name)); + + t.start_async.begin(); + } else if (pkt.body.has_member("url")) { + var url = pkt.body.get_string_member("url"); + debug("got URL: %s, launching...", url); + AppInfo.launch_default_for_uri(url, null); + } } } \ No newline at end of file