summaryrefslogtreecommitdiff
path: root/src/manager.c
diff options
context:
space:
mode:
authorAlok Barsode <alok.barsode@linux.intel.com>2011-08-24 16:44:10 +0300
committerSamuel Ortiz <sameo@linux.intel.com>2011-08-25 11:14:21 +0200
commit902f7b27814640781c07158b25bf9c7738338cf2 (patch)
tree18c1c278afe1bf786e0feefabd2f2e3e26120478 /src/manager.c
parent7abedeb03775038f334e2edf03f73675425579fd (diff)
downloadconnman-902f7b27814640781c07158b25bf9c7738338cf2.tar.gz
connman-902f7b27814640781c07158b25bf9c7738338cf2.tar.bz2
connman-902f7b27814640781c07158b25bf9c7738338cf2.zip
technology: Modify technology enable/disable APIs
Add the pending dbus message per technology. Also move the pending timeout from manager to technology.
Diffstat (limited to 'src/manager.c')
-rw-r--r--src/manager.c88
1 files changed, 4 insertions, 84 deletions
diff --git a/src/manager.c b/src/manager.c
index a276e0b2..54de6431 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -221,59 +221,6 @@ static DBusMessage *request_scan(DBusConnection *conn,
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)
-{
- 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);
-
- dbus_message_unref(technology_pending);
- technology_pending = NULL;
- }
-
- technology_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
-}
-
-static gboolean technology_abort(gpointer user_data)
-{
- DBG("");
-
- technology_timeout = 0;
-
- technology_reply(ETIMEDOUT);
-
- return FALSE;
-}
-
-static void technology_notify(enum connman_service_type type,
- connman_bool_t enabled)
-{
- DBG("type %d enabled %d", type, enabled);
-
- if (type == technology_type && enabled == technology_enabled)
- technology_reply(0);
-}
-
static void session_mode_notify(void)
{
DBusMessage *reply;
@@ -301,7 +248,6 @@ static void idle_state(connman_bool_t idle)
static struct connman_notifier technology_notifier = {
.name = "manager",
.priority = CONNMAN_NOTIFIER_PRIORITY_HIGH,
- .service_enabled= technology_notify,
.idle_state = idle_state,
};
@@ -310,13 +256,9 @@ 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);
@@ -339,16 +281,7 @@ static DBusMessage *enable_technology(DBusConnection *conn,
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_technology_enable(type);
- if (err < 0)
- technology_reply(-err);
- else
- technology_timeout = g_timeout_add_seconds(15,
- technology_abort, NULL);
+ __connman_technology_enable(type, msg);
return NULL;
}
@@ -358,13 +291,9 @@ static DBusMessage *disable_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);
@@ -387,16 +316,7 @@ static DBusMessage *disable_technology(DBusConnection *conn,
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_technology_disable(type);
- if (err < 0)
- technology_reply(-err);
- else
- technology_timeout = g_timeout_add_seconds(10,
- technology_abort, NULL);
+ __connman_technology_disable(type, msg);
return NULL;
}
@@ -729,11 +649,11 @@ void __connman_manager_cleanup(void)
{
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);