From: Marcel Holtmann Date: Wed, 11 Mar 2009 19:39:37 +0000 (+0100) Subject: Add more helpers for handling profile/service support X-Git-Tag: 0.13~12 X-Git-Url: http://git.maemo.org/git/?p=connman;a=commitdiff_plain;h=64e21423a7872663e23bb369af56c6d0776b3658 Add more helpers for handling profile/service support --- diff --git a/doc/manager-api.txt b/doc/manager-api.txt index 1f50d94..dd81941 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 c4a079e..e9d72ae 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 diff --git a/src/manager.c b/src/manager.c index 5e68e4f..4814f53 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 f9d643c..d1aea70 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 7915eaf..4b056f9 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)