diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2013-10-02 11:50:22 +0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2013-10-15 16:50:21 +0300 |
commit | 12451a9a7fc1166ca5cc6cba447e88cb9e67b884 (patch) | |
tree | b8859beb828616d096f3b575fcb9f47b92900e83 /tools/obexctl.c | |
parent | a5d2a89d61a8cab0571da85ab92b12668c722263 (diff) | |
download | bluez-12451a9a7fc1166ca5cc6cba447e88cb9e67b884.tar.gz |
tools/obexctl: Add cp command support for MAP messages
Add cp command support for MAP messages which can be used to copy message
contents using Message interface.
Diffstat (limited to 'tools/obexctl.c')
-rw-r--r-- | tools/obexctl.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/obexctl.c b/tools/obexctl.c index 7b83c0a87..2f9d94679 100644 --- a/tools/obexctl.c +++ b/tools/obexctl.c @@ -1475,6 +1475,62 @@ static void pbap_cp(GDBusProxy *proxy, int argc, char *argv[]) return pbap_pull(proxy, argc, argv); } +static void get_reply(DBusMessage *message, void *user_data) +{ + DBusMessageIter iter; + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == TRUE) { + rl_printf("Failed to Get: %s\n", error.name); + dbus_error_free(&error); + return; + } + + dbus_message_iter_init(message, &iter); + + print_transfer_iter(&iter); +} + +static void get_setup(DBusMessageIter *iter, void *user_data) +{ + const char *file = user_data; + dbus_bool_t attachment = TRUE; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &file); + dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &attachment); +} + +static void map_cp(GDBusProxy *proxy, int argc, char *argv[]) +{ + GDBusProxy *obj; + + if (argc < 2) { + rl_printf("Missing message argument\n"); + return; + } + + obj = find_message(argv[1]); + if (obj == NULL) { + rl_printf("Invalid message argument\n"); + return; + } + + if (argc < 3) { + rl_printf("Missing target file argument\n"); + return; + } + + if (g_dbus_proxy_method_call(obj, "Get", get_setup, get_reply, + g_strdup(argv[2]), g_free) == FALSE) { + rl_printf("Failed to Get\n"); + return; + } + + rl_printf("Attempting to Get\n"); +} + static void cmd_cp(int argc, char *argv[]) { @@ -1495,6 +1551,12 @@ static void cmd_cp(int argc, char *argv[]) return; } + proxy = find_map(g_dbus_proxy_get_path(default_session)); + if (proxy) { + map_cp(proxy, argc, argv); + return; + } + rl_printf("Command not supported\n"); } |