summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2012-10-17 10:46:15 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-10-17 12:19:33 +0300
commit569e0e85d96229a28bb08b8f900fd7d1ce3c7789 (patch)
tree19f755bedffb781e5072eace73b0a72edc4a3b4c
parent45d78b9b12b6242d40a3e65fd8ada7be1329e1e6 (diff)
downloadconnman-569e0e85d96229a28bb08b8f900fd7d1ce3c7789.tar.gz
connman-569e0e85d96229a28bb08b8f900fd7d1ce3c7789.tar.bz2
connman-569e0e85d96229a28bb08b8f900fd7d1ce3c7789.zip
client: Add Remove() method support for service
-rw-r--r--client/commands.c5
-rw-r--r--client/services.c31
-rw-r--r--client/services.h2
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);