From 8348e53d250ebede40dee2cb1b2c703f2ef29e97 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 9 Oct 2013 15:03:26 +0300 Subject: [PATCH] tools/obexctl: Add rm command support for MAP messages Add rm command support for MAP messages which can be used to set Delete property using Message interface. --- tools/obexctl.c | 67 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/tools/obexctl.c b/tools/obexctl.c index f7c64e03a..931ff261b 100644 --- a/tools/obexctl.c +++ b/tools/obexctl.c @@ -1698,32 +1698,77 @@ static void delete_setup(DBusMessageIter *iter, void *user_data) dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &file); } -static void cmd_rm(int argc, char *argv[]) +static void ftp_rm(GDBusProxy *proxy, int argc, char *argv[]) { - GDBusProxy *proxy; + if (argc < 2) { + rl_printf("Missing file argument\n"); + return; + } - if (!check_default_session()) + if (g_dbus_proxy_method_call(proxy, "Delete", delete_setup, + delete_reply, g_strdup(argv[1]), + g_free) == FALSE) { + rl_printf("Failed to Delete\n"); return; + } + + rl_printf("Attempting to Delete\n"); +} + +static void set_delete_reply(const DBusError *error, void *user_data) +{ + if (dbus_error_is_set(error)) + rl_printf("Failed to set Deleted: %s\n", error->name); + else + rl_printf("Set Deleted successful\n"); +} + +static void map_rm(GDBusProxy *proxy, int argc, char *argv[]) +{ + GDBusProxy *msg; + dbus_bool_t value = TRUE; if (argc < 2) { - rl_printf("Missing file argument\n"); + rl_printf("Missing message argument\n"); return; } + msg = find_message(argv[1]); + if (msg == NULL) { + rl_printf("Invalid message argument\n"); + return; + } + + if (g_dbus_proxy_set_property_basic(msg, "Deleted", DBUS_TYPE_BOOLEAN, + &value, set_delete_reply, + NULL, NULL) == FALSE) { + rl_printf("Failed to set Deleted\n"); + return; + } + + rl_printf("Attempting to set Deleted\n"); +} + +static void cmd_rm(int argc, char *argv[]) +{ + GDBusProxy *proxy; + + if (!check_default_session()) + return; + proxy = find_ftp(g_dbus_proxy_get_path(default_session)); - if (proxy == NULL) { - rl_printf("Command not supported\n"); + if (proxy) { + ftp_rm(proxy, argc, argv); return; } - if (g_dbus_proxy_method_call(proxy, "Delete", delete_setup, - delete_reply, g_strdup(argv[1]), - g_free) == FALSE) { - rl_printf("Failed to Delete\n"); + proxy = find_map(g_dbus_proxy_get_path(default_session)); + if (proxy) { + map_rm(proxy, argc, argv); return; } - rl_printf("Attempting to Delete\n"); + rl_printf("Command not supported\n"); } static void create_folder_reply(DBusMessage *message, void *user_data) -- 2.47.3