Hi Martin,

On Mon, Apr 12, 2010 at 02:35:05PM +0800, martin...@intel.com wrote:
> From: Martin Xu <martin...@intel.com>
> 
> ipconfig may not be created when creating service, so the ipconfig setting
> has no chance to be loaded. Loading ipconfig setting at function
> __connman_service_create_ipcofnig() can resolve the issue. Calling
> connman_network_set_index() to create ipconfig, the ipconfig setting can be 
> loaded.
> ---
>  src/service.c |   67 +++++++++++++++++++++++++++++++++++++++-----------------
>  1 files changed, 46 insertions(+), 21 deletions(-)
> 
> diff --git a/src/service.c b/src/service.c
> index e0e363e..b9b6b15 100644
> --- a/src/service.c
> +++ b/src/service.c
> @@ -2223,13 +2223,57 @@ static void setup_ipconfig(struct connman_service 
> *service, int index)
>       connman_ipconfig_set_ops(service->ipconfig, &service_ops);
>  }
>  
> +static GKeyFile *create_keyfile(const char *ident)
> +{
> +     GKeyFile *keyfile;
> +     gchar *pathname, *data = NULL;
> +     gsize length;
> +
> +     pathname = g_strdup_printf("%s/%s.profile", STORAGEDIR, ident);
> +     if (pathname == NULL)
> +             return NULL;
> +
> +     keyfile = g_key_file_new();
> +
> +     if (g_file_get_contents(pathname, &data, &length, NULL) == FALSE) {
> +             g_free(pathname);
> +             return NULL;
> +     }
> +
> +     g_free(pathname);
> +
> +     if (g_key_file_load_from_data(keyfile, data, length,
> +                                                     0, NULL) == FALSE) {
> +             g_free(data);
> +             return NULL;
> +     }
> +
> +     g_free(data);
> +
> +     return keyfile;
> +}
This routine is what __connman_storage_open_profile() does...


>  void __connman_service_create_ipconfig(struct connman_service *service,
>                                                               int index)
>  {
> +     const char *ident = service->profile;
> +     GKeyFile *keyfile;
> +
>       if (service->ipconfig != NULL)
>               return;
>  
>       setup_ipconfig(service, index);
> +
> +     if (ident == NULL)
> +             return;
> +
> +     keyfile = create_keyfile(ident);
...So I replaced this with __connman_storage_open_profile().


> +     if (keyfile == NULL)
> +             return;
> +
> +     __connman_ipconfig_load(service->ipconfig, keyfile,
> +                                     service->identifier, "IPv4.");
> +     g_key_file_free(keyfile);
>  }



I also removed the 2 chunks below as they become irrelevant to this patch.
If you want to submit an additional patch to replace service_load() key
opening code with __connman_storage_open_profile(), please do it separately.

>  /**
> @@ -2580,8 +2624,6 @@ static int service_load(struct connman_service *service)
>       const char *ident = service->profile;
>       GKeyFile *keyfile;
>       GError *error = NULL;
> -     gchar *pathname, *data = NULL;
> -     gsize length;
>       gchar *str;
>       connman_bool_t autoconnect;
>       unsigned int ssid_len;
> @@ -2592,26 +2634,9 @@ static int service_load(struct connman_service 
> *service)
>       if (ident == NULL)
>               return -EINVAL;
>  
> -     pathname = g_strdup_printf("%s/%s.profile", STORAGEDIR, ident);
> -     if (pathname == NULL)
> -             return -ENOMEM;
> -
> -     keyfile = g_key_file_new();
> -
> -     if (g_file_get_contents(pathname, &data, &length, NULL) == FALSE) {
> -             g_free(pathname);
> +     keyfile = create_keyfile(ident);
> +     if (keyfile == NULL)
>               return -ENOENT;
> -     }
> -
> -     g_free(pathname);
> -
> -     if (g_key_file_load_from_data(keyfile, data, length,
> -                                                     0, NULL) == FALSE) {
> -             g_free(data);
> -             return -EILSEQ;
> -     }
> -
> -     g_free(data);
>  
>       switch (service->type) {
>       case CONNMAN_SERVICE_TYPE_UNKNOWN:
> -- 
> 1.6.1.3
> 
> _______________________________________________
> connman mailing list
> connman@connman.net
> http://lists.connman.net/listinfo/connman

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to