GSList *user_networks;
GResolv *resolv;
char **host_ip;
- DBusMessage *pending_msg;
struct vpn_ipconfig *ipconfig_ipv4;
struct vpn_ipconfig *ipconfig_ipv6;
char **nameservers;
g_strfreev(providers);
}
-int __vpn_provider_create_and_connect(DBusMessage *msg)
+int __vpn_provider_create(DBusMessage *msg)
{
struct vpn_provider *provider;
DBusMessageIter iter, array;
g_free(ident);
- provider->pending_msg = dbus_message_ref(msg);
-
- DBG("provider %p pending %p", provider, provider->pending_msg);
-
- if (provider->index > 0) {
- DBG("provider already connected");
- } else {
- err = __vpn_provider_connect(provider);
- if (err < 0 && err != -EINPROGRESS)
- goto failed;
- }
-
vpn_provider_save(provider);
- return 0;
+ err = provider_register(provider);
+ if (err != 0 && err != -EALREADY)
+ return err;
-failed:
- DBG("Can not connect (%d), deleting provider %p %s", err, provider,
- provider->identifier);
+ connection_register(provider);
- vpn_provider_indicate_error(provider,
- VPN_PROVIDER_ERROR_CONNECT_FAILED);
+ DBG("provider %p index %d path %s", provider, provider->index,
+ provider->path);
- g_hash_table_remove(provider_hash, provider->identifier);
+ g_dbus_send_reply(connection, msg,
+ DBUS_TYPE_OBJECT_PATH, &provider->path,
+ DBUS_TYPE_INVALID);
- return err;
+ return 0;
}
static void append_connection_structs(DBusMessageIter *iter, void *user_data)
void vpn_provider_set_index(struct vpn_provider *provider, int index)
{
- DBG("index %d provider %p pending %p", index, provider,
- provider->pending_msg);
-
- if (provider->pending_msg != NULL) {
- g_dbus_send_reply(connection, provider->pending_msg,
- DBUS_TYPE_STRING, &provider->identifier,
- DBUS_TYPE_INT32, &index,
- DBUS_TYPE_INVALID);
- dbus_message_unref(provider->pending_msg);
- provider->pending_msg = NULL;
- }
+ DBG("index %d provider %p", index, provider);
if (provider->ipconfig_ipv4 == NULL) {
provider->ipconfig_ipv4 = __vpn_ipconfig_create(index,
int family, const char *network, const char *netmask);
void __vpn_provider_append_properties(struct vpn_provider *provider, DBusMessageIter *iter);
void __vpn_provider_list(DBusMessageIter *iter, void *user_data);
-int __vpn_provider_create_and_connect(DBusMessage *msg);
+int __vpn_provider_create(DBusMessage *msg);
DBusMessage *__vpn_provider_get_connections(DBusMessage *msg);
const char * __vpn_provider_get_ident(struct vpn_provider *provider);
int __vpn_provider_indicate_state(struct vpn_provider *provider,