#include <config.h>
#endif
+#include <errno.h>
+
#include <gdbus.h>
#include "connman.h"
+connman_bool_t connman_state_idle;
+DBusMessage *session_mode_pending = NULL;
+
static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
connman_dbus_dict_open(&array, &dict);
- str = __connman_profile_active_path();
- if (str != NULL)
- connman_dbus_dict_append_basic(&dict, "ActiveProfile",
- DBUS_TYPE_OBJECT_PATH, &str);
-
connman_dbus_dict_append_array(&dict, "Services",
DBUS_TYPE_OBJECT_PATH, __connman_service_list, NULL);
connman_dbus_dict_append_array(&dict, "Technologies",
connman_dbus_dict_append_basic(&dict, "State",
DBUS_TYPE_STRING, &str);
- offlinemode = __connman_profile_get_offlinemode();
+ offlinemode = __connman_technology_get_offlinemode();
connman_dbus_dict_append_basic(&dict, "OfflineMode",
DBUS_TYPE_BOOLEAN, &offlinemode);
dbus_message_iter_get_basic(&value, &offlinemode);
- __connman_profile_set_offlinemode(offlinemode, TRUE);
-
- __connman_profile_save_default();
- } else if (g_str_equal(name, "ActiveProfile") == TRUE) {
- const char *str;
-
- dbus_message_iter_get_basic(&value, &str);
-
- return __connman_error_not_supported(msg);
+ __connman_technology_set_offlinemode(offlinemode);
} else if (g_str_equal(name, "SessionMode") == TRUE) {
connman_bool_t sessionmode;
dbus_message_iter_get_basic(&value, &sessionmode);
+ if (session_mode_pending != NULL)
+ return __connman_error_in_progress(msg);
+
__connman_session_set_mode(sessionmode);
+
+ if (sessionmode == TRUE && connman_state_idle == FALSE) {
+ session_mode_pending = msg;
+ return NULL;
+ }
+
} else
return __connman_error_invalid_property(msg);
else
return __connman_error_invalid_arguments(msg);
- err = __connman_element_request_scan(type);
+ err = __connman_device_request_scan(type);
if (err < 0) {
if (err == -EINPROGRESS) {
connman_error("Invalid return code from scan");
static DBusConnection *connection = NULL;
-static enum connman_service_type technology_type;
-static connman_bool_t technology_enabled;
-static DBusMessage *technology_pending = NULL;
-static guint technology_timeout = 0;
-
-static void technology_reply(int error)
+static void session_mode_notify(void)
{
- DBG("");
-
- if (technology_timeout > 0) {
- g_source_remove(technology_timeout);
- technology_timeout = 0;
- }
-
- if (technology_pending != NULL) {
- if (error > 0) {
- DBusMessage *reply;
-
- reply = __connman_error_failed(technology_pending,
- error);
- if (reply != NULL)
- g_dbus_send_message(connection, reply);
- } else
- g_dbus_send_reply(connection, technology_pending,
- DBUS_TYPE_INVALID);
+ DBusMessage *reply;
- dbus_message_unref(technology_pending);
- technology_pending = NULL;
- }
+ reply = g_dbus_create_reply(session_mode_pending, DBUS_TYPE_INVALID);
+ g_dbus_send_message(connection, reply);
- technology_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
+ dbus_message_unref(session_mode_pending);
+ session_mode_pending = NULL;
}
-static gboolean technology_abort(gpointer user_data)
+static void idle_state(connman_bool_t idle)
{
- DBG("");
- technology_timeout = 0;
+ DBG("idle %d", idle);
- technology_reply(ETIMEDOUT);
+ connman_state_idle = idle;
- return FALSE;
-}
-
-static void technology_notify(enum connman_service_type type,
- connman_bool_t enabled)
-{
- DBG("type %d enabled %d", type, enabled);
+ if (connman_state_idle == FALSE || session_mode_pending == NULL)
+ return;
- if (type == technology_type && enabled == technology_enabled)
- technology_reply(0);
+ session_mode_notify();
}
static struct connman_notifier technology_notifier = {
.name = "manager",
.priority = CONNMAN_NOTIFIER_PRIORITY_HIGH,
- .service_enabled= technology_notify,
+ .idle_state = idle_state,
};
static DBusMessage *enable_technology(DBusConnection *conn,
{
enum connman_service_type type;
const char *str;
- int err;
DBG("conn %p", conn);
- if (technology_pending != NULL)
- return __connman_error_in_progress(msg);
-
dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &str,
DBUS_TYPE_INVALID);
if (__connman_notifier_is_enabled(type) == TRUE)
return __connman_error_already_enabled(msg);
- technology_type = type;
- technology_enabled = TRUE;
- technology_pending = dbus_message_ref(msg);
-
- err = __connman_element_enable_technology(type);
- if (err < 0 && err != -EINPROGRESS)
- technology_reply(-err);
- else
- technology_timeout = g_timeout_add_seconds(15,
- technology_abort, NULL);
+ __connman_technology_enable(type, msg);
return NULL;
}
{
enum connman_service_type type;
const char *str;
- int err;
DBG("conn %p", conn);
- if (technology_pending != NULL)
- return __connman_error_in_progress(msg);
-
dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &str,
DBUS_TYPE_INVALID);
if (__connman_notifier_is_enabled(type) == FALSE)
return __connman_error_already_disabled(msg);
- technology_type = type;
- technology_enabled = FALSE;
- technology_pending = dbus_message_ref(msg);
-
- err = __connman_element_disable_technology(type);
- if (err < 0 && err != -EINPROGRESS)
- technology_reply(-err);
- else
- technology_timeout = g_timeout_add_seconds(10,
- technology_abort, NULL);
+ __connman_technology_disable(type, msg);
return NULL;
}
sender = dbus_message_get_sender(msg);
- err = __connman_private_network_request(sender);
+ err = __connman_private_network_request(msg, sender);
if (err < 0)
return __connman_error_failed(msg, -err);
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ return NULL;
}
static DBusMessage *release_private_network(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- const char *sender;
+ const char *path;
int err;
DBG("conn %p", conn);
- sender = dbus_message_get_sender(msg);
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
- err = __connman_private_network_release(sender);
+ err = __connman_private_network_release(path);
if (err < 0)
return __connman_error_failed(msg, -err);
static GDBusMethodTable manager_methods[] = {
{ "GetProperties", "", "a{sv}", get_properties },
- { "SetProperty", "sv", "", set_property },
+ { "SetProperty", "sv", "", set_property,
+ G_DBUS_METHOD_FLAG_ASYNC },
{ "GetState", "", "s", get_state },
{ "RemoveProvider", "o", "", remove_provider },
{ "RequestScan", "s", "", request_scan },
{ "UnregisterCounter", "o", "", unregister_counter },
{ "CreateSession", "a{sv}o", "o", create_session },
{ "DestroySession", "o", "", destroy_session },
- { "RequestPrivateNetwork", "", "",
- request_private_network },
- { "ReleasePrivateNetwork", "", "",
+ { "RequestPrivateNetwork", "", "oa{sv}h",
+ request_private_network,
+ G_DBUS_METHOD_FLAG_ASYNC },
+ { "ReleasePrivateNetwork", "o", "",
release_private_network },
{ },
};
manager_methods,
manager_signals, NULL, NULL, NULL);
+ connman_state_idle = TRUE;
+
return 0;
}
{
DBG("");
- connman_notifier_unregister(&technology_notifier);
-
if (connection == NULL)
return;
+ connman_notifier_unregister(&technology_notifier);
+
g_dbus_unregister_interface(connection, CONNMAN_MANAGER_PATH,
CONNMAN_MANAGER_INTERFACE);