Browse Source

mconnectctl: commands for sharing URLs and text

bboozzoo/share-upload
Maciek Borzecki 7 years ago
parent
commit
aff638ae0c
1 changed files with 41 additions and 0 deletions
  1. +41
    -0
      src/mconnectctl/main.vala

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

@ -46,6 +46,13 @@ namespace Mconnect {
public abstract string certificate { owned get;}
}
[DBus (name = "org.mconnect.Device.Share")]
public interface ShareIface : Object {
public abstract void share_url(string url) throws IOError;
public abstract void share_text(string text) throws IOError;
}
public class Client {
private static bool log_debug = false;
@ -96,6 +103,9 @@ namespace Mconnect {
list-devices List devices
allow-device <path> Allow device
show-device <path> Show device details
share-url <path> <url> Share URL with device
share-text <path> <url> Share text with device
"""
);
opt_context.set_help_enabled(true);
@ -118,6 +128,8 @@ namespace Mconnect {
Command("list-devices", 0, cl.cmd_list_devices),
Command("allow-device", 1, cl.cmd_allow_device),
Command("show-device", 1, cl.cmd_show_device),
Command("share-url", 2, cl.cmd_share_url),
Command("share-text", 2, cl.cmd_share_text),
};
handle_command(remaining, commands);
@ -193,6 +205,24 @@ namespace Mconnect {
});
}
private int cmd_share_url(string[] args) {
return checked_dbus_call(() => {
var dp = args[0];
var share = get_share(new ObjectPath(dp));
share.share_url(args[1]);
return 0;
});
}
private int cmd_share_text(string[] args) {
return checked_dbus_call(() => {
var dp = args[0];
var share = get_share(new ObjectPath(dp));
share.share_text(args[1]);
return 0;
});
}
private void print_sorted_caps(string[] caps, string format) {
qsort_with_data<string>(caps, sizeof(string),
(a, b) => GLib.strcmp(a, b));
@ -301,6 +331,17 @@ namespace Mconnect {
return get_mconnect_obj_proxy(path);
}
/**
* get_share:
*
* Obtain DBus interface to Share of given device
*
* @return interface or null
*/
private ShareIface? get_share(ObjectPath path) throws IOError {
return get_mconnect_obj_proxy(path);
}
/**
* print_paths:
* @objs: object paths


Loading…
Cancel
Save