Hi Martin, > > when calling "test-connman apn <service> <apn>" and then "list-contexts" > > in oFono, it should show there, too. You only set it at connect time. > > > Hi Marcel: > In order to achieve the target you mentioned above, I think we need to add > setup() call back function in network->driver, and __connman_network_setup() > can be used to setup APN when user call test-connman apn <service> <apn>; > > Below is not the final patch, and just for you to rough reviewing. If you > agree with the method, I will give out the finished patch. > Thanks!
looks fine to me. > diff --git a/include/network.h b/include/network.h > index 6ab109d..f15dccd 100644 > --- a/include/network.h > +++ b/include/network.h > @@ -141,6 +141,8 @@ struct connman_network_driver { > void (*remove) (struct connman_network *network); > int (*connect) (struct connman_network *network); > int (*disconnect) (struct connman_network *network); > + int (*setup) (struct connman_network *network, > + const char *key, void *value); > }; > > int connman_network_driver_register(struct connman_network_driver *driver); > diff --git a/src/connman.h b/src/connman.h > index 4d869bb..fc0e4ea 100644 > --- a/src/connman.h > +++ b/src/connman.h > @@ -302,6 +302,8 @@ void __connman_device_decrease_connections(struct > connman_device *device); > > void __connman_device_set_network(struct connman_device *device, > struct connman_network *network); > +int __connman_network_setup(struct connman_network *network, > + const char *key, void *value); > void __connman_device_cleanup_networks(struct connman_device *device); > > int __connman_device_scan(struct connman_device *device); > diff --git a/src/network.c b/src/network.c > index c233c8f..dbac262 100644 > --- a/src/network.c > +++ b/src/network.c > @@ -841,6 +841,18 @@ connman_bool_t connman_network_get_associating(struct > connman_network *network) > return network->associating; > } > > +int __connman_network_setup(struct connman_network *network, > + const char *key, void *value) > +{ > + int err; > + > + if (network->driver->setup == NULL) > + return -ENOSYS; > + > + err = network->driver->setup(network, key, value); > + return err; > +} > + > /** > * __connman_network_connect: > * @network: network structure > diff --git a/src/service.c b/src/service.c > index 4e5a43f..aa403a9 100644 > --- a/src/service.c > +++ b/src/service.c > @@ -735,10 +735,14 @@ static DBusMessage *set_property(DBusConnection *conn, > > apn_changed(service); > > - if (service->network != NULL) > + if (service->network != NULL) { > connman_network_set_string(service->network, > "Cellular.APN", service->apn); > > + _connman_network_setup(service->network, > + "Cellular.APN", service->apn); > + } > + However we of course wanna combine set_string and setup here to make it simpler. Or better just hook this up into into set_string and friends directly. So you basically do set_string and that additionally triggers setup callback. Same goes for set_integer. And then you can just leave the extra value out of it. You only need to key. It is more like telling network drivers that this value got set. Regards Marcel _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman