From d55c478a09cb438bdd7268effb75994b6abf885c Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Thu, 1 Apr 2010 12:25:33 +0200 Subject: [PATCH] Add session D-Bus manager API --- doc/manager-api.txt | 15 +++++++++++++++ src/manager.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/doc/manager-api.txt b/doc/manager-api.txt index c898935..fb8a78c 100644 --- a/doc/manager-api.txt +++ b/doc/manager-api.txt @@ -122,6 +122,21 @@ Methods dict GetProperties() Possible Errors: [service].Error.InvalidArguments + string RequestSession(string bearer) + + Request a networking session. + + If the bearer is an empty string the best available + service will be picked. + + Possible Errors: [service].Error.InvalidArguments + + void ReleaseSession() + + Release a networking session. + + Possible Errors: [service].Error.InvalidArguments + Signals PropertyChanged(string name, variant value) This signal indicates a changed value of the given diff --git a/src/manager.c b/src/manager.c index 141e959..da0ee53 100644 --- a/src/manager.c +++ b/src/manager.c @@ -538,6 +538,46 @@ static DBusMessage *unregister_counter(DBusConnection *conn, return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); } +static DBusMessage *request_session(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + const char *bearer, *sender, *service_path; + struct connman_service *service; + + DBG("conn %p", conn); + + sender = dbus_message_get_sender(msg); + + dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &bearer, + DBUS_TYPE_INVALID); + + service = __connman_session_request(bearer, sender); + if (service == NULL) + return __connman_error_failed(msg, EINVAL); + + service_path = __connman_service_get_path(service); + + return g_dbus_create_reply(msg, DBUS_TYPE_OBJECT_PATH, &service_path, + DBUS_TYPE_INVALID); +} + +static DBusMessage *release_session(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + const char *sender; + int err; + + DBG("conn %p", conn); + + sender = dbus_message_get_sender(msg); + + err = __connman_session_release(sender); + if (err < 0) + return __connman_error_failed(msg, -err); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + static GDBusMethodTable manager_methods[] = { { "GetProperties", "", "a{sv}", get_properties }, { "SetProperty", "sv", "", set_property }, @@ -558,6 +598,8 @@ static GDBusMethodTable manager_methods[] = { { "UnregisterAgent", "o", "", unregister_agent }, { "RegisterCounter", "ou", "", register_counter }, { "UnregisterCounter", "o", "", unregister_counter }, + { "RequestSession", "s", "o", request_session }, + { "ReleaseSession", "s", "", release_session }, { }, }; -- 2.7.4