diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-02-19 21:55:42 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-02-21 16:22:59 +0200 |
commit | 4c12b0f73059514d32c97c02c1c55b8c43e19197 (patch) | |
tree | 5d821b78b85c8ed9ad724e0bcd3c263b3fd15f96 /client | |
parent | e613dae225ac357fbe6eed321f89e52ab2e278b7 (diff) | |
download | connman-4c12b0f73059514d32c97c02c1c55b8c43e19197.tar.gz connman-4c12b0f73059514d32c97c02c1c55b8c43e19197.tar.bz2 connman-4c12b0f73059514d32c97c02c1c55b8c43e19197.zip |
client: Don't look up service on connect or disconnect
Attempt to connect or disconnect without looking up the service in
advace. Fix memory leak and update the error message.
Diffstat (limited to 'client')
-rw-r--r-- | client/data_manager.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/client/data_manager.c b/client/data_manager.c index 96374eca..0c8e7e43 100644 --- a/client/data_manager.c +++ b/client/data_manager.c @@ -106,7 +106,6 @@ free_servers: int connect_service(DBusConnection *connection, char *name) { DBusMessage *message, *message_connect = NULL; - struct service_data service; char *path = NULL; const char *path_name; DBusError err; @@ -116,11 +115,7 @@ int connect_service(DBusConnection *connection, char *name) if (message == NULL) return -ENOMEM; - path_name = find_service(connection, message, name, &service); - if (path_name == NULL) { - err_ret = -ENXIO; - goto error; - } + path_name = strip_service_path(name); path = g_strdup_printf("/net/connman/service/%s", path_name); message_connect = dbus_message_new_method_call("net.connman", path, @@ -136,7 +131,8 @@ int connect_service(DBusConnection *connection, char *name) -1, &err); if (dbus_error_is_set(&err)) { - printf("Connection failed; error: '%s'\n", err.message); + printf("Error '%s': %s\n", path, err.message); + dbus_error_free(&err); err_ret = -EINVAL; goto error; } @@ -157,7 +153,6 @@ error: int disconnect_service(DBusConnection *connection, char *name) { DBusMessage *message, *message_disconnect = NULL; - struct service_data service; char *path = NULL; const char *path_name; DBusError err; @@ -167,14 +162,9 @@ int disconnect_service(DBusConnection *connection, char *name) if (message == NULL) return -ENOMEM; - path_name = find_service(connection, message, name, &service); - if (path_name == NULL) { - err_ret = -ENXIO; - goto error; - } - + path_name = strip_service_path(name); path = g_strdup_printf("/net/connman/service/%s", path_name); - printf("%s\n", path); + message_disconnect = dbus_message_new_method_call("net.connman", path, "net.connman.Service", "Disconnect"); @@ -189,7 +179,8 @@ int disconnect_service(DBusConnection *connection, char *name) -1, &err); if (dbus_error_is_set(&err)) { - printf("Connection failed; error: '%s'\n", err.message); + printf("Error '%s': %s\n", path, err.message); + dbus_error_free(&err); err_ret = -EINVAL; goto error; } |