summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-03-11 20:39:37 +0100
committerMarcel Holtmann <marcel@holtmann.org>2009-03-11 20:39:37 +0100
commit64e21423a7872663e23bb369af56c6d0776b3658 (patch)
tree606af74b436d9bdbb2955644384e411c31b040be
parent306c84e60b5779356addbbeff7084c0c7478a056 (diff)
downloadconnman-64e21423a7872663e23bb369af56c6d0776b3658.tar.gz
connman-64e21423a7872663e23bb369af56c6d0776b3658.tar.bz2
connman-64e21423a7872663e23bb369af56c6d0776b3658.zip
Add more helpers for handling profile/service support
-rw-r--r--doc/manager-api.txt40
-rw-r--r--src/connman.h2
-rw-r--r--src/manager.c64
-rw-r--r--src/profile.c14
-rwxr-xr-xtest/test-manager4
5 files changed, 122 insertions, 2 deletions
diff --git a/doc/manager-api.txt b/doc/manager-api.txt
index 1f50d944..dd819418 100644
--- a/doc/manager-api.txt
+++ b/doc/manager-api.txt
@@ -22,6 +22,29 @@ Methods dict GetProperties()
Possible Errors: [service].Error.InvalidArguments
[service].Error.DoesNotExist
+ object AddProfile(string name)
+
+ Add a new profile with the specified name.
+
+ It is possible to create two profiles with the same
+ name. The identification is done via the object path
+ and not the name of the profile.
+
+ Possible Errors: [service].Error.InvalidArguments
+
+ void RemoveProfile(object path)
+
+ Remove profile with specified object path.
+
+ It is not possible to remove the current active
+ profile. To remove the active profile a different
+ one must be selected via ActiveProfile property
+ first.
+
+ At minium one profile must be available all the time.
+
+ Possible Errors: [service].Error.InvalidArguments
+
void RegisterAgent(object path)
Register new agent for handling user requests.
@@ -74,6 +97,10 @@ Properties string State [readonly]
the limited usage of WiFi or Bluetooth devices might
be allowed in some situations.
+ object ActiveProfile [readwrite]
+
+ Object path of the current active profile.
+
array{object} Profiles [readonly]
List of profile object paths.
@@ -82,6 +109,19 @@ Properties string State [readonly]
List of device object paths.
+ array{object} Services [readonly]
+
+ List of service object paths.
+
+ This list represents the available services for the
+ current selected profile. If the profile gets changed
+ then this list will be updated.
+
+ The same list is available via the profile object
+ itself. It is just provided here for convenience of
+ applications only dealing with the current active
+ profile.
+
array{object} Connections [readonly]
List of active connection object paths.
diff --git a/src/connman.h b/src/connman.h
index c4a079e7..e9d72ae9 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -52,6 +52,8 @@ int __connman_profile_init(DBusConnection *conn);
void __connman_profile_cleanup(void);
void __connman_profile_list(DBusMessageIter *iter);
+void __connman_profile_list_services(DBusMessageIter *iter);
+const char *__connman_profile_active(void);
#include <connman/log.h>
diff --git a/src/manager.c b/src/manager.c
index 5e68e4f5..4814f532 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -89,6 +89,30 @@ static void append_profiles(DBusMessageIter *dict)
dbus_message_iter_close_container(dict, &entry);
}
+static void append_services(DBusMessageIter *dict)
+{
+ DBusMessageIter entry, value, iter;
+ const char *key = "Services";
+
+ dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
+ NULL, &entry);
+
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+
+ dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
+ DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
+ &value);
+
+ dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
+ __connman_profile_list_services(&iter);
+ dbus_message_iter_close_container(&value, &iter);
+
+ dbus_message_iter_close_container(&entry, &value);
+
+ dbus_message_iter_close_container(dict, &entry);
+}
+
static void append_devices(DBusMessageIter *dict)
{
DBusMessageIter entry, value, iter;
@@ -161,7 +185,13 @@ static DBusMessage *get_properties(DBusConnection *conn,
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+ str = __connman_profile_active();
+ if (str != NULL)
+ connman_dbus_dict_append_variant(&dict, "ActiveProfile",
+ DBUS_TYPE_OBJECT_PATH, &str);
+
append_profiles(&dict);
+ append_services(&dict);
append_devices(&dict);
append_connections(&dict);
@@ -227,11 +257,43 @@ static DBusMessage *set_property(DBusConnection *conn,
global_offlinemode = offlinemode;
__connman_device_set_offlinemode(offlinemode);
+ } else if (g_str_equal(name, "ActiveProfile") == TRUE) {
+ const char *str;
+
+ dbus_message_iter_get_basic(&value, &str);
+
+ return __connman_error_not_supported(msg);
}
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
+static DBusMessage *add_profile(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ const char *name;
+
+ DBG("conn %p", conn);
+
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_INVALID);
+
+ return __connman_error_not_supported(msg);
+}
+
+static DBusMessage *remove_profile(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ const char *path;
+
+ DBG("conn %p", conn);
+
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
+
+ return __connman_error_not_supported(msg);
+}
+
static DBusMessage *register_agent(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -283,6 +345,8 @@ static DBusMessage *unregister_agent(DBusConnection *conn,
static GDBusMethodTable manager_methods[] = {
{ "GetProperties", "", "a{sv}", get_properties },
{ "SetProperty", "sv", "", set_property },
+ { "AddProfile", "s", "o", add_profile },
+ { "RemoveProfile", "o", "", remove_profile },
{ "RegisterAgent", "o", "", register_agent },
{ "UnregisterAgent", "o", "", unregister_agent },
{ },
diff --git a/src/profile.c b/src/profile.c
index f9d643ce..d1aea70c 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -56,15 +56,27 @@ int __connman_profile_remove_network(struct connman_network *network)
return 0;
}
+const char *__connman_profile_active(void)
+{
+ DBG("");
+
+ return "/profile/default";
+}
+
void __connman_profile_list(DBusMessageIter *iter)
{
- const char *path = "/profile/default";
+ const char *path = __connman_profile_active();
DBG("");
dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path);
}
+void __connman_profile_list_services(DBusMessageIter *iter)
+{
+ DBG("");
+}
+
static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
diff --git a/test/test-manager b/test/test-manager
index 7915eaf5..4b056f9f 100755
--- a/test/test-manager
+++ b/test/test-manager
@@ -16,6 +16,8 @@ def print_properties(key, value):
interface = "org.moblin.connman.Device"
elif key == "Connections":
interface = "org.moblin.connman.Connection"
+ elif key == "Services":
+ interface = "org.moblin.connman.Service"
else:
return
@@ -52,7 +54,7 @@ def print_properties(key, value):
print " Networks = [ %s]" % (list)
for key in properties.keys():
- if key in ["Profiles", "Devices", "Connections"]:
+ if key in ["Profiles", "Devices", "Connections", "Services"]:
print_properties(key, properties[key])
elif key in ["OfflineMode"]:
print "%s" % (key)