diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala index 36fb396..ff9582e 100644 --- a/src/mconnectctl/main.vala +++ b/src/mconnectctl/main.vala @@ -73,6 +73,7 @@ namespace Mconnect { share-url Share URL with device share-text Share text with device + share-file Share file with device """ ); opt_context.set_help_enabled(true); @@ -97,6 +98,7 @@ namespace Mconnect { Command("show-device", 1, cl.cmd_show_device), Command("share-url", 2, cl.cmd_share_url), Command("share-text", 2, cl.cmd_share_text), + Command("share-file", 2, cl.cmd_share_file), }; handle_command(remaining, commands); @@ -190,6 +192,18 @@ namespace Mconnect { }); } + private int cmd_share_file(string[] args) { + return checked_dbus_call(() => { + var dp = args[0]; + var share = get_share(new ObjectPath(dp)); + var file = File.new_for_path(args[1]); + var path = file.get_path(); + debug("share path: %s", path); + share.share_file(path); + return 0; + }); + } + private void print_sorted_caps(string[] caps, string format) { qsort_with_data(caps, sizeof(string), (a, b) => GLib.strcmp(a, b)); diff --git a/src/mconnectctl/share-iface.vala b/src/mconnectctl/share-iface.vala index efca59f..611111f 100644 --- a/src/mconnectctl/share-iface.vala +++ b/src/mconnectctl/share-iface.vala @@ -23,6 +23,7 @@ namespace Mconnect { public abstract void share_url(string url) throws IOError; public abstract void share_text(string text) throws IOError; + public abstract void share_file(string path) throws IOError; } } \ No newline at end of file