Browse Source

mconnectctl: command for sharing files

bboozzoo/share-upload
Maciek Borzecki 7 years ago
parent
commit
5ed3431163
2 changed files with 15 additions and 0 deletions
  1. +14
    -0
      src/mconnectctl/main.vala
  2. +1
    -0
      src/mconnectctl/share-iface.vala

+ 14
- 0
src/mconnectctl/main.vala View File

@ -73,6 +73,7 @@ namespace Mconnect {
share-url <path> <url> Share URL with device
share-text <path> <text> Share text with device
share-file <path> <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<string>(caps, sizeof(string),
(a, b) => GLib.strcmp(a, b));


+ 1
- 0
src/mconnectctl/share-iface.vala View File

@ -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;
}
}

Loading…
Cancel
Save