config: Provision service after adding new .config files.
authorMohamed Abbas <mohamed.abbas@intel.com>
Wed, 22 Jun 2011 17:53:04 +0000 (10:53 -0700)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 27 Jun 2011 14:15:08 +0000 (16:15 +0200)
For now if new .config files are added connman will create
new config and but do not provision existing services. This
patch will provision existing service if any config file are
added or modified.

Fixes bug #4880.

src/config.c
src/connman.h
src/service.c

index 9bfa9ae..90a2180 100644 (file)
@@ -651,6 +651,7 @@ static gboolean inotify_data(GIOChannel *channel, GIOCondition cond,
                        if (config != NULL) {
                                g_hash_table_remove_all(config->service_table);
                                load_config(config);
+                               __connman_service_provision_changed(ident);
                        }
                }
 
@@ -870,3 +871,24 @@ int __connman_config_provision_service(struct connman_service *service)
 
        return 0;
 }
+
+int __connman_config_provision_service_ident(struct connman_service *service,
+                                                       const char *ident)
+{
+       enum connman_service_type type;
+       struct connman_config *config;
+
+       DBG("service %p", service);
+
+       /* For now only WiFi services are supported */
+       type = connman_service_get_type(service);
+       if (type != CONNMAN_SERVICE_TYPE_WIFI)
+               return -ENOSYS;
+
+       config = g_hash_table_lookup(config_table, ident);
+       if(config != NULL)
+               g_hash_table_foreach(config->service_table,
+                                               provision_service, service);
+
+       return 0;
+}
index b12aa55..fef3ce5 100644 (file)
@@ -401,6 +401,8 @@ void __connman_config_cleanup(void);
 
 int __connman_config_load_service(GKeyFile *keyfile, const char *group, connman_bool_t persistent);
 int __connman_config_provision_service(struct connman_service *service);
+int __connman_config_provision_service_ident(struct connman_service *service,
+                                                       const char *ident);
 
 #include <connman/profile.h>
 
@@ -508,6 +510,8 @@ int __connman_service_create_and_connect(DBusMessage *msg);
 int __connman_service_provision(DBusMessage *msg);
 void __connman_service_auto_connect(void);
 
+void __connman_service_provision_changed(const char *ident);
+
 const char *__connman_service_type2string(enum connman_service_type type);
 
 int __connman_service_nameserver_append(struct connman_service *service,
index 4b0e725..7c11cfa 100644 (file)
@@ -4235,6 +4235,19 @@ failed:
        return err;
 }
 
+static void provision_changed(gpointer value, gpointer user_data)
+{
+        struct connman_service *service = value;
+       char *path = user_data;
+
+       __connman_config_provision_service_ident(service, path);
+}
+
+void __connman_service_provision_changed(const char *ident)
+{
+       g_sequence_foreach(service_list, provision_changed, (void *)ident);
+}
+
 int __connman_service_provision(DBusMessage *msg)
 {
        GKeyFile *keyfile = NULL;