int __connman_service_disconnect(struct connman_service *service);
int __connman_service_disconnect_all(void);
int __connman_service_create_and_connect(DBusMessage *msg);
+int __connman_service_provision(DBusMessage *msg);
void __connman_service_auto_connect(void);
const char *__connman_service_type2string(enum connman_service_type type);
return NULL;
}
+static DBusMessage *provision_service(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ int err;
+
+ DBG("conn %p", conn);
+
+ err = __connman_service_provision(msg);
+ if (err < 0)
+ return __connman_error_failed(msg, -err);
+
+ return NULL;
+}
static DBusMessage *connect_provider(DBusConnection *conn,
DBusMessage *msg, void *data)
{ "LookupService", "s", "o", lookup_service, },
{ "ConnectService", "a{sv}", "o", connect_service,
G_DBUS_METHOD_FLAG_ASYNC },
+ { "ProvisionService", "s", "", provision_service,
+ G_DBUS_METHOD_FLAG_ASYNC },
{ "ConnectProvider", "a{sv}", "o", connect_provider,
G_DBUS_METHOD_FLAG_ASYNC },
{ "RegisterAgent", "o", "", register_agent },
return err;
}
+int __connman_service_provision(DBusMessage *msg)
+{
+ GKeyFile *keyfile = NULL;
+ const char *config_str = NULL;
+ char *group = NULL, *ident = NULL;
+ int err = 0;
+
+ DBG("");
+
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &config_str,
+ DBUS_TYPE_INVALID);
+
+ if (config_str == NULL || strlen(config_str) == 0)
+ return -EINVAL;
+
+ keyfile = g_key_file_new();
+
+ /* populate GKeyFile with config_str */
+ if (g_key_file_load_from_data(keyfile, config_str,
+ strlen(config_str), 0, NULL) == FALSE) {
+ err = -EINVAL;
+ goto done;
+ }
+
+ /*
+ * read only one group of settings (only one service supported, no
+ * global settings)
+ */
+ group = g_key_file_get_start_group(keyfile);
+
+ if (group == NULL || g_str_has_prefix(group, "service_") == FALSE) {
+ err = -EINVAL;
+ goto done;
+ }
+
+ err = __connman_config_load_service(keyfile, group);
+ if (err < 0)
+ goto done;
+
+ ident = group + strlen("service_");
+
+ /* trigger service provisioning if service exists */
+ service = lookup_by_identifier(ident);
+ if (service != NULL)
+ __connman_config_provision_service(service);
+
+ g_dbus_send_reply(connection, msg, DBUS_TYPE_INVALID);
+
+done:
+ if (group != NULL)
+ g_free(group);
+
+ if (keyfile != NULL)
+ g_key_file_free(keyfile);
+
+ return err;
+}
+
/**
* __connman_service_get:
* @identifier: service identifier