diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-01-25 13:49:42 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-01-27 11:21:24 +0100 |
commit | aba4ca9ea9a9ea1626883b72649498b91ba33fb4 (patch) | |
tree | 8fe5388224ca9bd14082a5f9c4cc3197a64c8a35 | |
parent | d05c00b6f152f32de71abc9521eb53555b477676 (diff) | |
download | connman-aba4ca9ea9a9ea1626883b72649498b91ba33fb4.tar.gz connman-aba4ca9ea9a9ea1626883b72649498b91ba33fb4.tar.bz2 connman-aba4ca9ea9a9ea1626883b72649498b91ba33fb4.zip |
provider: Factor out service creation
Factor out the creation of a service when given a provider.
-rw-r--r-- | src/provider.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/src/provider.c b/src/provider.c index 1f952824..baa3c9b2 100644 --- a/src/provider.c +++ b/src/provider.c @@ -557,6 +557,20 @@ static void provider_dbus_ident(char *ident) } } +static int provider_create_service(struct connman_provider *provider) +{ + if (provider->vpn_service != NULL) + return -EALREADY; + + provider->vpn_service = + __connman_service_create_from_provider(provider); + + if (provider->vpn_service == NULL) + return -EOPNOTSUPP; + + return 0; +} + int __connman_provider_create_and_connect(DBusMessage *msg) { struct connman_provider *provider; @@ -650,19 +664,19 @@ int __connman_provider_create_and_connect(DBusMessage *msg) g_free(ident); - if (provider->vpn_service == NULL) { - provider->vpn_service = - __connman_service_create_from_provider(provider); - if (provider->vpn_service == NULL) { - err = -EOPNOTSUPP; + err = provider_create_service(provider); + if (err == -EALREADY) { + DBG("provider already connected"); + } else { + if (err == -EOPNOTSUPP) { goto unref; - } + } else { + err = __connman_service_connect(provider->vpn_service); - err = __connman_service_connect(provider->vpn_service); - if (err < 0 && err != -EINPROGRESS) - goto failed; - } else - DBG("provider already connected"); + if (err < 0 && err != -EINPROGRESS) + goto failed; + } + } connman_provider_save(provider); service_path = __connman_service_get_path(provider->vpn_service); |