diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/commands.c | 5 | ||||
-rw-r--r-- | client/services.c | 31 | ||||
-rw-r--r-- | client/services.h | 2 |
3 files changed, 38 insertions, 0 deletions
diff --git a/client/commands.c b/client/commands.c index 73a92ebe..4cc3b2d0 100644 --- a/client/commands.c +++ b/client/commands.c @@ -88,6 +88,7 @@ void show_help(void) " [METHOD|URL|SERVERS|EXCLUDES]\n" " if METHOD = manual, enter 'servers' then the list of servers\n" " then enter 'excludes' then the list of excludes\n" + " --remove Remove the service from favorite\n" " monitor Monitor signals from all Connman interfaces\n" " --services Monitor signals from the Service interface\n" " --tech Monitor signals from the Technology interface\n" @@ -202,6 +203,9 @@ int config_switch(int argc, char *argv[], int c, DBusConnection *conn) error = -EINVAL; } break; + case 'r': + error = remove_service(conn, message, argv[1]); + break; default: fprintf(stderr, "Command not recognized, please check help\n"); error = -EINVAL; @@ -392,6 +396,7 @@ int commands_options(DBusConnection *connection, char *argv[], int argc) {"proxy", required_argument, 0, 'x'}, {"autoconnect", required_argument, 0, 'a'}, {"ipv4", required_argument, 0, 'i'}, + {"remove", 0, 0, 'r'}, {0, 0, 0, 0} }; diff --git a/client/services.c b/client/services.c index e4f177cd..ff2c7294 100644 --- a/client/services.c +++ b/client/services.c @@ -496,3 +496,34 @@ int set_service_property(DBusConnection *connection, DBusMessage *message, return 0; } + +int remove_service(DBusConnection *connection, DBusMessage *message, + char *name) +{ + struct service_data service; + DBusMessage *message_send; + const char *path_name; + char *path; + + path_name = find_service(connection, message, name, &service); + if (path_name == NULL) + return -ENXIO; + + if (service.favorite == FALSE) + return 0; + + path = g_strdup_printf("/net/connman/service/%s", path_name); + message_send = dbus_message_new_method_call(CONNMAN_SERVICE, path, + CONNMAN_SERVICE_INTERFACE, + "Remove"); + if (message_send == NULL) { + g_free(path); + return -ENOMEM; + } + + dbus_connection_send(connection, message_send, NULL); + dbus_message_unref(message_send); + g_free(path); + + return 0; +} diff --git a/client/services.h b/client/services.h index cdcc7b20..15805b4b 100644 --- a/client/services.h +++ b/client/services.h @@ -39,6 +39,8 @@ void extract_service_name(DBusMessageIter *dict, struct service_data *service); int set_service_property(DBusConnection *connection, DBusMessage *message, char *name, char *property, char **keys, void *data, int num_args); +int remove_service(DBusConnection *connection, DBusMessage *message, + char *name); int set_proxy_manual(DBusConnection *connection, DBusMessage *message, char *name, char **servers, char **excludes, int num_servers, int num_excludes); |