| Index: src/ipconfig.c
|
| diff --git a/src/ipconfig.c b/src/ipconfig.c
|
| index 43e681b00ad27ebdf212ce0fa19a3f0f7b04dfde..c8ad783f7ade8c047543a5144060a5b12aaf3f74 100644
|
| --- a/src/ipconfig.c
|
| +++ b/src/ipconfig.c
|
| @@ -876,7 +876,7 @@ struct connman_ipconfig *connman_ipconfig_create(
|
|
|
| ipconfig_list = g_list_append(ipconfig_list, ipconfig);
|
|
|
| - __connman_storage_save_ipconfig(ipconfig);
|
| + __connman_profile_save_ipconfig(ipconfig);
|
|
|
| return ipconfig;
|
| }
|
| @@ -994,7 +994,7 @@ int connman_ipconfig_register(struct connman_ipconfig *ipconfig,
|
| {
|
| _DBG_IPCONFIG("ipconfig %p parent %p", ipconfig, parent);
|
|
|
| - __connman_storage_load_ipconfig(ipconfig);
|
| + __connman_profile_load_ipconfig(ipconfig);
|
|
|
| return connman_element_register(&ipconfig->element, parent);
|
| }
|
| @@ -1009,7 +1009,7 @@ void connman_ipconfig_unregister(struct connman_ipconfig *ipconfig)
|
| {
|
| _DBG_IPCONFIG("ipconfig %p", ipconfig);
|
|
|
| - __connman_storage_save_ipconfig(ipconfig);
|
| + __connman_profile_save_ipconfig(ipconfig);
|
|
|
| connman_element_unregister(&ipconfig->element);
|
| }
|
| @@ -1455,25 +1455,27 @@ static void setdomains(struct connman_ipaddress *ipaddr, const char *str)
|
| ipaddr->smask |= CONNMAN_IPCONFIG_SEARCH;
|
| }
|
|
|
| -static int ipconfig_storage_load(struct connman_ipconfig *ipconfig)
|
| +static int ipconfig_storage_load(struct connman_ipconfig *ipconfig,
|
| + GKeyFile *keyfile)
|
| {
|
| - const char *ident = __connman_profile_active_ident();
|
| - GKeyFile *keyfile;
|
| gchar *key;
|
| struct connman_ipaddress *ipaddr = ipconfig->address;
|
| GError *error;
|
| char *str;
|
| gint val;
|
| + int err = 0;
|
|
|
| _DBG_IPCONFIG("ipconfig %p", ipconfig);
|
|
|
| - keyfile = __connman_storage_open(ident);
|
| - if (keyfile == NULL)
|
| - return 0;
|
| -
|
| key = g_strdup_printf("ipconfig_%s", ipconfig->element.name);
|
| if (key == NULL) {
|
| connman_error("%s: no memory for identifier", __func__);
|
| + err = -ENOMEM;
|
| + goto done;
|
| + }
|
| +
|
| + if (g_key_file_has_group(keyfile, key) == FALSE) {
|
| + err = -ESRCH;
|
| goto done;
|
| }
|
|
|
| @@ -1518,8 +1520,8 @@ static int ipconfig_storage_load(struct connman_ipconfig *ipconfig)
|
| /* TODO(sleffler) do consistency checking */
|
| done:
|
| g_free(key);
|
| - __connman_storage_close(ident, keyfile, FALSE);
|
| - return 0;
|
| +
|
| + return err;
|
| }
|
|
|
| struct ipconfig_paths {
|
| @@ -1571,20 +1573,15 @@ static void set_integer(GKeyFile *keyfile, gchar *key,
|
| g_key_file_remove_key(keyfile, key, name, NULL);
|
| }
|
|
|
| -static int ipconfig_storage_save(const struct connman_ipconfig *ipconfig)
|
| +static int ipconfig_storage_save(const struct connman_ipconfig *ipconfig,
|
| + GKeyFile *keyfile)
|
| {
|
| - const char *ident = __connman_profile_active_ident();
|
| - GKeyFile *keyfile;
|
| gchar *key;
|
| const struct connman_ipaddress *ipaddr =
|
| connman_ipconfig_get_ipaddress(ipconfig);
|
|
|
| _DBG_IPCONFIG("ipconfig %p", ipconfig);
|
|
|
| - keyfile = __connman_storage_open(ident);
|
| - if (keyfile == NULL)
|
| - return 0;
|
| -
|
| key = g_strdup_printf("ipconfig_%s", ipconfig->element.name);
|
| if (key == NULL) {
|
| connman_error("%s: no memory for identifier", __func__);
|
| @@ -1626,17 +1623,20 @@ static int ipconfig_storage_save(const struct connman_ipconfig *ipconfig)
|
| }
|
| done:
|
| g_free(key);
|
| - __connman_storage_close(ident, keyfile, TRUE);
|
| return 0;
|
| }
|
|
|
| static int ipconfig_storage_remove(const struct connman_ipconfig *ipconfig)
|
| {
|
| - const char *ident = __connman_profile_active_ident();
|
| + const struct connman_storage_ident *ident =
|
| + __connman_profile_active_ident();
|
| GKeyFile *keyfile;
|
| gchar *group;
|
|
|
| - _DBG_IPCONFIG("ipconfig %p", ipconfig);
|
| + _DBG_IPCONFIG("ipconfig %p ident %p", ipconfig, ident);
|
| +
|
| + if (ident == NULL)
|
| + return -EINVAL;
|
|
|
| keyfile = __connman_storage_open(ident);
|
| if (keyfile == NULL)
|
| @@ -1864,7 +1864,7 @@ static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg,
|
| } else
|
| return __connman_error_invalid_property(msg);
|
|
|
| - __connman_storage_save_ipconfig(ipconfig);
|
| + __connman_profile_save_ipconfig(ipconfig);
|
|
|
| connman_element_update(&ipconfig->element);
|
|
|
| @@ -1911,7 +1911,7 @@ static DBusMessage *clear_property(DBusConnection *conn, DBusMessage *msg,
|
| /* TODO(sleffler) should we leave current state alone? */
|
| /* NB: no way to record dynamic state (e.g. DHCP dns config) */
|
| ipaddress_clear(ipaddr, mask);
|
| - __connman_storage_save_ipconfig(ipconfig);
|
| + __connman_profile_save_ipconfig(ipconfig);
|
|
|
| connman_element_update(&ipconfig->element);
|
|
|
| @@ -1935,7 +1935,7 @@ static DBusMessage *remove_ipconfig(DBusConnection *conn, DBusMessage *msg,
|
| /* NB: must be done before in-memory state is reclaimed */
|
| ipconfig_storage_remove(ipconfig);
|
| __connman_device_remove_ipconfig(device, ipconfig);
|
| - __connman_storage_save_device(device);
|
| + __connman_profile_save_device(device);
|
|
|
| return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
|
| }
|
| @@ -1960,7 +1960,7 @@ static DBusMessage *move_ipconfig(struct connman_ipconfig *ipconfig,
|
|
|
| device = connman_ipconfig_get_device(ipconfig);
|
| ipconfig_move(ipconfig, target, before ? 0 : 1);
|
| - __connman_storage_save_device(device);
|
| + __connman_profile_save_device(device);
|
|
|
| return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
|
| }
|
|
|