mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-12-14 14:34:34 +08:00
tools/obexctl: Quit when done with command
This ensures that the commands don't stay hanging since bt_shell no longer quits immediatelly after executing a command.
This commit is contained in:
parent
487acb2a97
commit
b01d6c2739
229
tools/obexctl.c
229
tools/obexctl.c
@ -115,10 +115,12 @@ static void connect_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to connect: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Connection successful\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void append_variant(DBusMessageIter *iter, int type, void *val)
|
||||
@ -198,7 +200,7 @@ static void cmd_connect(int argc, char *argv[])
|
||||
|
||||
if (!client) {
|
||||
bt_shell_printf("Client proxy not available\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (argc > 2)
|
||||
@ -211,7 +213,7 @@ static void cmd_connect(int argc, char *argv[])
|
||||
if (g_dbus_proxy_method_call(client, "CreateSession", connect_setup,
|
||||
connect_reply, args, connect_args_free) == FALSE) {
|
||||
bt_shell_printf("Failed to connect\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to connect to %s\n", argv[1]);
|
||||
@ -226,10 +228,12 @@ static void disconnect_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to disconnect: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Disconnection successful\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void disconnect_setup(DBusMessageIter *iter, void *user_data)
|
||||
@ -254,13 +258,13 @@ static void cmd_disconnect(int argc, char *argv[])
|
||||
|
||||
if (proxy == NULL) {
|
||||
bt_shell_printf("Session not available\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (g_dbus_proxy_method_call(client, "RemoveSession", disconnect_setup,
|
||||
disconnect_reply, proxy, NULL) == FALSE) {
|
||||
bt_shell_printf("Failed to disconnect\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to disconnect to %s\n",
|
||||
@ -301,6 +305,8 @@ static void cmd_list(int argc, char *arg[])
|
||||
GDBusProxy *proxy = l->data;
|
||||
print_proxy(proxy, "Session", NULL);
|
||||
}
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static bool check_default_session(void)
|
||||
@ -399,7 +405,7 @@ static void cmd_show(int argc, char *argv[])
|
||||
|
||||
if (argc < 2) {
|
||||
if (check_default_session() == FALSE)
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
|
||||
proxy = default_session;
|
||||
} else {
|
||||
@ -407,7 +413,7 @@ static void cmd_show(int argc, char *argv[])
|
||||
OBEX_SESSION_INTERFACE);
|
||||
if (!proxy) {
|
||||
bt_shell_printf("Session %s not available\n", argv[1]);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,6 +421,8 @@ static void cmd_show(int argc, char *argv[])
|
||||
|
||||
print_property(proxy, "Destination");
|
||||
print_property(proxy, "Target");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void set_default_session(GDBusProxy *proxy)
|
||||
@ -445,15 +453,17 @@ static void cmd_select(int argc, char *argv[])
|
||||
OBEX_SESSION_INTERFACE);
|
||||
if (proxy == NULL) {
|
||||
bt_shell_printf("Session %s not available\n", argv[1]);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (default_session == proxy)
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
|
||||
set_default_session(proxy);
|
||||
|
||||
print_proxy(proxy, "Session", NULL);
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void transfer_info(GDBusProxy *proxy, int argc, char *argv[])
|
||||
@ -500,16 +510,18 @@ static void cmd_info(int argc, char *argv[])
|
||||
OBEX_TRANSFER_INTERFACE);
|
||||
if (proxy) {
|
||||
transfer_info(proxy, argc, argv);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
proxy = g_dbus_proxy_lookup(msgs, NULL, argv[1], OBEX_MSG_INTERFACE);
|
||||
if (proxy) {
|
||||
message_info(proxy, argc, argv);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
bt_shell_printf("Object %s not available\n", argv[1]);
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void cancel_reply(DBusMessage *message, void *user_data)
|
||||
@ -521,10 +533,12 @@ static void cancel_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to cancel: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Cancel successful\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void cmd_cancel(int argc, char *argv[])
|
||||
@ -535,13 +549,13 @@ static void cmd_cancel(int argc, char *argv[])
|
||||
OBEX_TRANSFER_INTERFACE);
|
||||
if (!proxy) {
|
||||
bt_shell_printf("Transfer %s not available\n", argv[1]);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (g_dbus_proxy_method_call(proxy, "Cancel", NULL, cancel_reply, NULL,
|
||||
NULL) == FALSE) {
|
||||
bt_shell_printf("Failed to cancel transfer\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to cancel transfer %s\n",
|
||||
@ -557,10 +571,12 @@ static void suspend_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to suspend: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Suspend successful\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void cmd_suspend(int argc, char *argv[])
|
||||
@ -571,13 +587,13 @@ static void cmd_suspend(int argc, char *argv[])
|
||||
OBEX_TRANSFER_INTERFACE);
|
||||
if (!proxy) {
|
||||
bt_shell_printf("Transfer %s not available\n", argv[1]);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (g_dbus_proxy_method_call(proxy, "Suspend", NULL, suspend_reply,
|
||||
NULL, NULL) == FALSE) {
|
||||
bt_shell_printf("Failed to suspend transfer\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to suspend transfer %s\n",
|
||||
@ -593,10 +609,12 @@ static void resume_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to resume: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Resume successful\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void cmd_resume(int argc, char *argv[])
|
||||
@ -607,13 +625,13 @@ static void cmd_resume(int argc, char *argv[])
|
||||
OBEX_TRANSFER_INTERFACE);
|
||||
if (!proxy) {
|
||||
bt_shell_printf("Transfer %s not available\n", argv[1]);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (g_dbus_proxy_method_call(proxy, "Resume", NULL, resume_reply,
|
||||
NULL, NULL) == FALSE) {
|
||||
bt_shell_printf("Failed to resume transfer\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to resume transfer %s\n",
|
||||
@ -675,12 +693,14 @@ static void send_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to send/pull: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(message, &iter);
|
||||
|
||||
print_transfer_iter(&iter);
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void send_setup(DBusMessageIter *iter, void *user_data)
|
||||
@ -695,7 +715,7 @@ static void opp_send(GDBusProxy *proxy, int argc, char *argv[])
|
||||
if (g_dbus_proxy_method_call(proxy, "SendFile", send_setup, send_reply,
|
||||
g_strdup(argv[1]), g_free) == FALSE) {
|
||||
bt_shell_printf("Failed to send\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to send %s to %s\n", argv[1],
|
||||
@ -707,7 +727,7 @@ static void opp_pull(GDBusProxy *proxy, int argc, char *argv[])
|
||||
if (g_dbus_proxy_method_call(proxy, "PullBusinessCard", send_setup,
|
||||
send_reply, g_strdup(argv[1]), g_free) == FALSE) {
|
||||
bt_shell_printf("Failed to pull\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to pull %s from %s\n", argv[1],
|
||||
@ -724,12 +744,14 @@ static void push_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to PushMessage: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(message, &iter);
|
||||
|
||||
print_transfer_iter(&iter);
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void push_setup(DBusMessageIter *iter, void *user_data)
|
||||
@ -757,7 +779,7 @@ static void map_send(GDBusProxy *proxy, int argc, char *argv[])
|
||||
push_reply, g_strdup(argv[1]),
|
||||
g_free) == FALSE) {
|
||||
bt_shell_printf("Failed to send\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to send %s to %s\n", argv[1],
|
||||
@ -770,7 +792,7 @@ static void cmd_send(int argc, char *argv[])
|
||||
GDBusProxy *proxy;
|
||||
|
||||
if (!check_default_session())
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
|
||||
proxy = g_dbus_proxy_lookup(opps, NULL, path, OBEX_OPP_INTERFACE);
|
||||
if (proxy) {
|
||||
@ -785,6 +807,8 @@ static void cmd_send(int argc, char *argv[])
|
||||
}
|
||||
|
||||
bt_shell_printf("Command not supported\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void cmd_pull(int argc, char *argv[])
|
||||
@ -793,7 +817,7 @@ static void cmd_pull(int argc, char *argv[])
|
||||
GDBusProxy *proxy;
|
||||
|
||||
if (!check_default_session())
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
|
||||
proxy = g_dbus_proxy_lookup(opps, NULL, path, OBEX_OPP_INTERFACE);
|
||||
if (proxy) {
|
||||
@ -802,6 +826,8 @@ static void cmd_pull(int argc, char *argv[])
|
||||
}
|
||||
|
||||
bt_shell_printf("Command not supported\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void change_folder_reply(DBusMessage *message, void *user_data)
|
||||
@ -813,10 +839,12 @@ static void change_folder_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to ChangeFolder: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("ChangeFolder successful\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void change_folder_setup(DBusMessageIter *iter, void *user_data)
|
||||
@ -836,12 +864,14 @@ static void select_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to Select: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(message, &iter);
|
||||
|
||||
bt_shell_printf("Select successful\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void select_setup(DBusMessageIter *iter, void *user_data)
|
||||
@ -862,10 +892,12 @@ static void setfolder_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to SetFolder: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("SetFolder successful\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void setfolder_setup(DBusMessageIter *iter, void *user_data)
|
||||
@ -881,7 +913,7 @@ static void ftp_cd(GDBusProxy *proxy, int argc, char *argv[])
|
||||
change_folder_reply, g_strdup(argv[1]),
|
||||
g_free) == FALSE) {
|
||||
bt_shell_printf("Failed to ChangeFolder\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to ChangeFolder to %s\n", argv[1]);
|
||||
@ -893,7 +925,7 @@ static void pbap_cd(GDBusProxy *proxy, int argc, char *argv[])
|
||||
select_reply, g_strdup(argv[1]),
|
||||
g_free) == FALSE) {
|
||||
bt_shell_printf("Failed to Select\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to Select to %s\n", argv[1]);
|
||||
@ -905,7 +937,7 @@ static void map_cd(GDBusProxy *proxy, int argc, char *argv[])
|
||||
setfolder_reply, g_strdup(argv[1]),
|
||||
g_free) == FALSE) {
|
||||
bt_shell_printf("Failed to SetFolder\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to SetFolder to %s\n", argv[1]);
|
||||
@ -917,7 +949,7 @@ static void cmd_cd(int argc, char *argv[])
|
||||
GDBusProxy *proxy;
|
||||
|
||||
if (!check_default_session())
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
|
||||
proxy = g_dbus_proxy_lookup(ftps, NULL, path, OBEX_FTP_INTERFACE);
|
||||
if (proxy) {
|
||||
@ -938,6 +970,8 @@ static void cmd_cd(int argc, char *argv[])
|
||||
}
|
||||
|
||||
bt_shell_printf("Command not supported\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void list_folder_reply(DBusMessage *message, void *user_data)
|
||||
@ -950,13 +984,13 @@ static void list_folder_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to ListFolder: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(message, &iter);
|
||||
|
||||
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
|
||||
dbus_message_iter_recurse(&iter, &array);
|
||||
|
||||
@ -964,6 +998,8 @@ static void list_folder_reply(DBusMessage *message, void *user_data)
|
||||
print_dict_iter(&array);
|
||||
dbus_message_iter_next(&array);
|
||||
}
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void ftp_ls(GDBusProxy *proxy, int argc, char *argv[])
|
||||
@ -972,7 +1008,7 @@ static void ftp_ls(GDBusProxy *proxy, int argc, char *argv[])
|
||||
list_folder_reply, NULL,
|
||||
NULL) == FALSE) {
|
||||
bt_shell_printf("Failed to ls\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to ListFolder\n");
|
||||
@ -985,7 +1021,7 @@ static void parse_list_reply(DBusMessage *message)
|
||||
dbus_message_iter_init(message, &iter);
|
||||
|
||||
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
|
||||
dbus_message_iter_recurse(&iter, &array);
|
||||
|
||||
@ -1003,6 +1039,8 @@ static void parse_list_reply(DBusMessage *message)
|
||||
print_iter("\t", vcard, &entry);
|
||||
dbus_message_iter_next(&array);
|
||||
}
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void list_reply(DBusMessage *message, void *user_data)
|
||||
@ -1014,7 +1052,7 @@ static void list_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to List: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
parse_list_reply(message);
|
||||
@ -1043,7 +1081,7 @@ static void search_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to Search: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
parse_list_reply(message);
|
||||
@ -1076,7 +1114,7 @@ static void pbap_search(GDBusProxy *proxy, int argc, char *argv[])
|
||||
search_reply, g_strdup(argv[1]),
|
||||
g_free) == FALSE) {
|
||||
bt_shell_printf("Failed to Search\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to Search\n");
|
||||
@ -1092,13 +1130,13 @@ static void list_folders_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to ListFolders: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(message, &iter);
|
||||
|
||||
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
|
||||
dbus_message_iter_recurse(&iter, &array);
|
||||
|
||||
@ -1106,6 +1144,8 @@ static void list_folders_reply(DBusMessage *message, void *user_data)
|
||||
print_dict_iter(&array);
|
||||
dbus_message_iter_next(&array);
|
||||
}
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void list_folders_setup(DBusMessageIter *iter, void *user_data)
|
||||
@ -1132,13 +1172,13 @@ static void list_messages_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to ListFolders: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(message, &iter);
|
||||
|
||||
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
|
||||
dbus_message_iter_recurse(&iter, &array);
|
||||
|
||||
@ -1152,6 +1192,8 @@ static void list_messages_reply(DBusMessage *message, void *user_data)
|
||||
bt_shell_printf("\t%s\n", obj);
|
||||
dbus_message_iter_next(&array);
|
||||
}
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void list_messages_setup(DBusMessageIter *iter, void *user_data)
|
||||
@ -1179,7 +1221,7 @@ static void pbap_list(GDBusProxy *proxy, int argc, char *argv[])
|
||||
if (g_dbus_proxy_method_call(proxy, "List", list_setup, list_reply,
|
||||
NULL, NULL) == FALSE) {
|
||||
bt_shell_printf("Failed to List\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to List\n");
|
||||
@ -1196,7 +1238,7 @@ static void get_size_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to GetSize: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(message, &iter);
|
||||
@ -1204,6 +1246,8 @@ static void get_size_reply(DBusMessage *message, void *user_data)
|
||||
print_iter("\t", "Size", &iter);
|
||||
|
||||
pbap_list(proxy, 0, NULL);
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void pbap_get_size(GDBusProxy *proxy, int argc, char *argv[])
|
||||
@ -1211,7 +1255,7 @@ static void pbap_get_size(GDBusProxy *proxy, int argc, char *argv[])
|
||||
if (g_dbus_proxy_method_call(proxy, "GetSize", NULL, get_size_reply,
|
||||
proxy, NULL) == FALSE) {
|
||||
bt_shell_printf("Failed to GetSize\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to GetSize\n");
|
||||
@ -1236,7 +1280,7 @@ static void map_ls_messages(GDBusProxy *proxy, int argc, char *argv[])
|
||||
list_messages_reply, g_strdup(argv[1]),
|
||||
g_free) == FALSE) {
|
||||
bt_shell_printf("Failed to ListMessages\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to ListMessages\n");
|
||||
@ -1253,7 +1297,7 @@ static void map_ls(GDBusProxy *proxy, int argc, char *argv[])
|
||||
list_folders_reply, NULL,
|
||||
NULL) == FALSE) {
|
||||
bt_shell_printf("Failed to ListFolders\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to ListFolders\n");
|
||||
@ -1286,6 +1330,8 @@ static void cmd_ls(int argc, char *argv[])
|
||||
}
|
||||
|
||||
bt_shell_printf("Command not supported\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
struct cp_args {
|
||||
@ -1344,10 +1390,12 @@ static void copy_file_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to CopyFile: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("CopyFile successful\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void ftp_copy(GDBusProxy *proxy, int argc, char *argv[])
|
||||
@ -1359,10 +1407,12 @@ static void ftp_copy(GDBusProxy *proxy, int argc, char *argv[])
|
||||
if (g_dbus_proxy_method_call(proxy, "CopyFile", cp_setup,
|
||||
copy_file_reply, args, cp_free) == FALSE) {
|
||||
bt_shell_printf("Failed to CopyFile\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to CopyFile\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void get_file_reply(DBusMessage *message, void *user_data)
|
||||
@ -1375,12 +1425,14 @@ static void get_file_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to GetFile: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(message, &iter);
|
||||
|
||||
print_transfer_iter(&iter);
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void get_file_setup(DBusMessageIter *iter, void *user_data)
|
||||
@ -1403,7 +1455,7 @@ static void ftp_get(GDBusProxy *proxy, int argc, char *argv[])
|
||||
if (g_dbus_proxy_method_call(proxy, "GetFile", get_file_setup,
|
||||
get_file_reply, args, cp_free) == FALSE) {
|
||||
bt_shell_printf("Failed to GetFile\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to GetFile\n");
|
||||
@ -1419,12 +1471,14 @@ static void put_file_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to PutFile: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(message, &iter);
|
||||
|
||||
print_transfer_iter(&iter);
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void ftp_put(GDBusProxy *proxy, int argc, char *argv[])
|
||||
@ -1433,7 +1487,7 @@ static void ftp_put(GDBusProxy *proxy, int argc, char *argv[])
|
||||
|
||||
if (rindex(argv[2], ':') != NULL) {
|
||||
bt_shell_printf("Invalid target file argument\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
args = cp_new(argv);
|
||||
@ -1441,7 +1495,7 @@ static void ftp_put(GDBusProxy *proxy, int argc, char *argv[])
|
||||
if (g_dbus_proxy_method_call(proxy, "PutFile", cp_setup, put_file_reply,
|
||||
args, cp_free) == FALSE) {
|
||||
bt_shell_printf("Failed to PutFile\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to PutFile\n");
|
||||
@ -1464,7 +1518,7 @@ static void pull_all_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to PullAll: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@ -1494,7 +1548,7 @@ static void pbap_pull_all(GDBusProxy *proxy, int argc, char *argv[])
|
||||
pull_all_reply, g_strdup(argv[2]),
|
||||
g_free) == FALSE) {
|
||||
bt_shell_printf("Failed to PullAll\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to PullAll\n");
|
||||
@ -1509,7 +1563,7 @@ static void pull_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to Pull: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@ -1543,7 +1597,7 @@ static void pbap_pull(GDBusProxy *proxy, int argc, char *argv[])
|
||||
if (g_dbus_proxy_method_call(proxy, "Pull", pull_setup, pull_reply,
|
||||
args, cp_free) == FALSE) {
|
||||
bt_shell_printf("Failed to Pull\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to Pull\n");
|
||||
@ -1567,12 +1621,14 @@ static void get_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to Get: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dbus_message_iter_init(message, &iter);
|
||||
|
||||
print_transfer_iter(&iter);
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void get_setup(DBusMessageIter *iter, void *user_data)
|
||||
@ -1591,13 +1647,13 @@ static void map_cp(GDBusProxy *proxy, int argc, char *argv[])
|
||||
obj = g_dbus_proxy_lookup(msgs, NULL, argv[1], OBEX_MSG_INTERFACE);
|
||||
if (obj == NULL) {
|
||||
bt_shell_printf("Invalid message argument\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (g_dbus_proxy_method_call(obj, "Get", get_setup, get_reply,
|
||||
g_strdup(argv[2]), g_free) == FALSE) {
|
||||
bt_shell_printf("Failed to Get\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to Get\n");
|
||||
@ -1609,7 +1665,7 @@ static void cmd_cp(int argc, char *argv[])
|
||||
GDBusProxy *proxy;
|
||||
|
||||
if (!check_default_session())
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
|
||||
proxy = g_dbus_proxy_lookup(ftps, NULL, path, OBEX_FTP_INTERFACE);
|
||||
if (proxy) {
|
||||
@ -1630,6 +1686,8 @@ static void cmd_cp(int argc, char *argv[])
|
||||
}
|
||||
|
||||
bt_shell_printf("Command not supported\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void move_file_reply(DBusMessage *message, void *user_data)
|
||||
@ -1641,10 +1699,12 @@ static void move_file_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to MoveFile: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("MoveFile successful\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void cmd_mv(int argc, char *argv[])
|
||||
@ -1654,12 +1714,12 @@ static void cmd_mv(int argc, char *argv[])
|
||||
struct cp_args *args;
|
||||
|
||||
if (!check_default_session())
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
|
||||
proxy = g_dbus_proxy_lookup(ftps, NULL, path, OBEX_FTP_INTERFACE);
|
||||
if (proxy == NULL) {
|
||||
bt_shell_printf("Command not supported\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
args = cp_new(argv);
|
||||
@ -1667,7 +1727,7 @@ static void cmd_mv(int argc, char *argv[])
|
||||
if (g_dbus_proxy_method_call(proxy, "MoveFile", cp_setup,
|
||||
move_file_reply, args, cp_free) == FALSE) {
|
||||
bt_shell_printf("Failed to MoveFile\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to MoveFile\n");
|
||||
@ -1682,10 +1742,12 @@ static void delete_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to Delete: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Delete successful\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void delete_setup(DBusMessageIter *iter, void *user_data)
|
||||
@ -1701,7 +1763,7 @@ static void ftp_rm(GDBusProxy *proxy, int argc, char *argv[])
|
||||
delete_reply, g_strdup(argv[1]),
|
||||
g_free) == FALSE) {
|
||||
bt_shell_printf("Failed to Delete\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to Delete\n");
|
||||
@ -1709,10 +1771,13 @@ static void ftp_rm(GDBusProxy *proxy, int argc, char *argv[])
|
||||
|
||||
static void set_delete_reply(const DBusError *error, void *user_data)
|
||||
{
|
||||
if (dbus_error_is_set(error))
|
||||
if (dbus_error_is_set(error)) {
|
||||
bt_shell_printf("Failed to set Deleted: %s\n", error->name);
|
||||
else
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
} else {
|
||||
bt_shell_printf("Set Deleted successful\n");
|
||||
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
static void map_rm(GDBusProxy *proxy, int argc, char *argv[])
|
||||
@ -1723,14 +1788,14 @@ static void map_rm(GDBusProxy *proxy, int argc, char *argv[])
|
||||
msg = g_dbus_proxy_lookup(msgs, NULL, argv[1], OBEX_MSG_INTERFACE);
|
||||
if (msg == NULL) {
|
||||
bt_shell_printf("Invalid message argument\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (g_dbus_proxy_set_property_basic(msg, "Deleted", DBUS_TYPE_BOOLEAN,
|
||||
&value, set_delete_reply,
|
||||
NULL, NULL) == FALSE) {
|
||||
bt_shell_printf("Failed to set Deleted\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to set Deleted\n");
|
||||
@ -1742,7 +1807,7 @@ static void cmd_rm(int argc, char *argv[])
|
||||
GDBusProxy *proxy;
|
||||
|
||||
if (!check_default_session())
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
|
||||
proxy = g_dbus_proxy_lookup(ftps, NULL, path, OBEX_FTP_INTERFACE);
|
||||
if (proxy) {
|
||||
@ -1757,6 +1822,8 @@ static void cmd_rm(int argc, char *argv[])
|
||||
}
|
||||
|
||||
bt_shell_printf("Command not supported\n");
|
||||
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void create_folder_reply(DBusMessage *message, void *user_data)
|
||||
@ -1768,7 +1835,7 @@ static void create_folder_reply(DBusMessage *message, void *user_data)
|
||||
if (dbus_set_error_from_message(&error, message) == TRUE) {
|
||||
bt_shell_printf("Failed to CreateFolder: %s\n", error.name);
|
||||
dbus_error_free(&error);
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("CreateFolder successful\n");
|
||||
@ -1787,19 +1854,19 @@ static void cmd_mkdir(int argc, char *argv[])
|
||||
GDBusProxy *proxy;
|
||||
|
||||
if (!check_default_session())
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
|
||||
proxy = g_dbus_proxy_lookup(ftps, NULL, path, OBEX_FTP_INTERFACE);
|
||||
if (proxy == NULL) {
|
||||
bt_shell_printf("Command not supported\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (g_dbus_proxy_method_call(proxy, "CreateFolder", create_folder_setup,
|
||||
create_folder_reply, g_strdup(argv[1]),
|
||||
g_free) == FALSE) {
|
||||
bt_shell_printf("Failed to CreateFolder\n");
|
||||
return;
|
||||
return bt_shell_noninteractive_quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
bt_shell_printf("Attempting to CreateFolder\n");
|
||||
|
Loading…
Reference in New Issue
Block a user