Diff between e007c73662295d67e0e9d7a7149d497e938421fc and c11131647f0a909028d7faf755f42ca481bd64a1

Changed Files

File Additions Deletions Status
tools/obexctl.c +51 -0 modified

Full Patch

diff --git a/tools/obexctl.c b/tools/obexctl.c
index f8e76e7..3dd3a4d 100644
--- a/tools/obexctl.c
+++ b/tools/obexctl.c
@@ -992,6 +992,56 @@ static void cmd_mv(int argc, char *argv[])
 	rl_printf("Attempting to MoveFile\n");
 }
 
+static void delete_reply(DBusMessage *message, void *user_data)
+{
+	DBusError error;
+
+	dbus_error_init(&error);
+
+	if (dbus_set_error_from_message(&error, message) == TRUE) {
+		rl_printf("Failed to Delete: %s\n", error.name);
+		dbus_error_free(&error);
+		return;
+	}
+
+	rl_printf("Delete successful\n");
+}
+
+static void delete_setup(DBusMessageIter *iter, void *user_data)
+{
+	const char *file = user_data;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &file);
+}
+
+static void cmd_rm(int argc, char *argv[])
+{
+	GDBusProxy *proxy;
+
+	if (!check_default_session())
+		return;
+
+	if (argc < 2) {
+		rl_printf("Missing file argument\n");
+		return;
+	}
+
+	proxy = find_ftp(g_dbus_proxy_get_path(default_session));
+	if (proxy == NULL) {
+		rl_printf("Command not supported\n");
+		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");
+		return;
+	}
+
+	rl_printf("Attempting to Delete\n");
+}
+
 static const struct {
 	const char *cmd;
 	const char *arg;
@@ -1012,6 +1062,7 @@ static const struct {
 				"Copy source file to destination file" },
 	{ "mv",          "<source file> <destination file>",   cmd_mv,
 				"Move source file to destination file" },
+	{ "rm",          "<file>",    cmd_rm, "Delete file" },
 	{ "quit",         NULL,       cmd_quit, "Quit program" },
 	{ "exit",         NULL,       cmd_quit },
 	{ "help" },