diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-07-19 20:24:35 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-07-19 20:24:35 +0200 |
commit | 26c2a395c34797223010ed6e2c00d6ebcf78241a (patch) | |
tree | 3dde984fdb2551fb88c6346ee672149b979c9384 /src/manager.c | |
parent | 1a034a2281665b7fad6442a9136a43fc2be87db4 (diff) | |
download | connman-26c2a395c34797223010ed6e2c00d6ebcf78241a.tar.gz connman-26c2a395c34797223010ed6e2c00d6ebcf78241a.tar.bz2 connman-26c2a395c34797223010ed6e2c00d6ebcf78241a.zip |
Add simple GetState method for really simple applications
Diffstat (limited to 'src/manager.c')
-rw-r--r-- | src/manager.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/manager.c b/src/manager.c index 580fe52f..814a063a 100644 --- a/src/manager.c +++ b/src/manager.c @@ -294,6 +294,26 @@ static DBusMessage *set_property(DBusConnection *conn, return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); } +static DBusMessage *get_state(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + const char *str; + + DBG("conn %p", conn); + + if (__connman_security_check_privilege(msg, + CONNMAN_SECURITY_PRIVILEGE_PUBLIC) < 0) + return __connman_error_permission_denied(msg); + + if (__connman_element_count(NULL, CONNMAN_ELEMENT_TYPE_CONNECTION) > 0) + str = "online"; + else + str = "offline"; + + return g_dbus_create_reply(msg, DBUS_TYPE_STRING, &str, + DBUS_TYPE_INVALID); +} + static DBusMessage *add_profile(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -505,6 +525,7 @@ static DBusMessage *unregister_agent(DBusConnection *conn, static GDBusMethodTable manager_methods[] = { { "GetProperties", "", "a{sv}", get_properties }, { "SetProperty", "sv", "", set_property }, + { "GetState", "", "s", get_state }, { "AddProfile", "s", "o", add_profile }, { "RemoveProfile", "o", "", remove_profile }, { "RequestScan", "s", "", request_scan }, |