#include "connman.h"
-enum connman_policy {
- CONNMAN_POLICY_UNKNOWN = 0,
- CONNMAN_POLICY_SINGLE = 1,
- CONNMAN_POLICY_MULTIPLE = 2,
- CONNMAN_POLICY_ASK = 3,
-};
-
-static enum connman_policy global_policy = CONNMAN_POLICY_SINGLE;
static connman_bool_t global_offlinemode = FALSE;
-static const char *policy2string(enum connman_policy policy)
+static void append_profiles(DBusMessageIter *dict)
{
- switch (policy) {
- case CONNMAN_POLICY_UNKNOWN:
- break;
- case CONNMAN_POLICY_SINGLE:
- return "single";
- case CONNMAN_POLICY_MULTIPLE:
- return "multiple";
- case CONNMAN_POLICY_ASK:
- return "ask";
- }
+ DBusMessageIter entry, value, iter;
+ const char *key = "Profiles";
- return NULL;
-}
+ dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
+ NULL, &entry);
-static enum connman_policy string2policy(const char *policy)
-{
- if (g_str_equal(policy, "single") == TRUE)
- return CONNMAN_POLICY_SINGLE;
- else if (g_str_equal(policy, "multiple") == TRUE)
- return CONNMAN_POLICY_MULTIPLE;
- else if (g_str_equal(policy, "ask") == TRUE)
- return CONNMAN_POLICY_ASK;
- else
- return CONNMAN_POLICY_UNKNOWN;
+ 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(&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_profiles(DBusMessageIter *dict)
+static void append_services(DBusMessageIter *dict)
{
DBusMessageIter entry, value, iter;
- const char *key = "Profiles";
+ const char *key = "Services";
dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
NULL, &entry);
dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
-
- __connman_profile_list(&iter);
-
+ __connman_service_list(&iter);
dbus_message_iter_close_container(&value, &iter);
dbus_message_iter_close_container(&entry, &value);
dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
-
__connman_element_list(NULL, CONNMAN_ELEMENT_TYPE_DEVICE, &iter);
-
dbus_message_iter_close_container(&value, &iter);
dbus_message_iter_close_container(&entry, &value);
dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
-
__connman_element_list(NULL, CONNMAN_ELEMENT_TYPE_CONNECTION, &iter);
-
dbus_message_iter_close_container(&value, &iter);
dbus_message_iter_close_container(&entry, &value);
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+ str = __connman_profile_active_path();
+ 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);
connman_dbus_dict_append_variant(&dict, "State",
DBUS_TYPE_STRING, &str);
- str = policy2string(global_policy);
- if (str != NULL)
- connman_dbus_dict_append_variant(&dict, "Policy",
- DBUS_TYPE_STRING, &str);
-
connman_dbus_dict_append_variant(&dict, "OfflineMode",
DBUS_TYPE_BOOLEAN, &global_offlinemode);
CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
return __connman_error_permission_denied(msg);
- if (g_str_equal(name, "Policy") == TRUE) {
- enum connman_policy policy;
- const char *str;
-
- dbus_message_iter_get_basic(&value, &str);
- policy = string2policy(str);
- if (policy == CONNMAN_POLICY_UNKNOWN)
- return __connman_error_invalid_arguments(msg);
-
- global_policy = policy;
- } else if (g_str_equal(name, "OfflineMode") == TRUE) {
+ if (g_str_equal(name, "OfflineMode") == TRUE) {
connman_bool_t offlinemode;
dbus_message_iter_get_basic(&value, &offlinemode);
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);
+ } else
+ return __connman_error_invalid_property(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 *connect_service(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessageIter iter, array;
+
+ DBG("conn %p", conn);
+
+ if (__connman_security_check_privilege(msg,
+ CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
+ return __connman_error_permission_denied(msg);
+
+ dbus_message_iter_init(msg, &iter);
+ dbus_message_iter_recurse(&iter, &array);
+
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, value;
+ const char *key;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &value);
+
+ switch (dbus_message_iter_get_arg_type(&value)) {
+ }
+
+ dbus_message_iter_next(&array);
+ }
+
+ return __connman_error_not_implemented(msg);
+}
+
static DBusMessage *register_agent(DBusConnection *conn,
DBusMessage *msg, void *data)
{
}
static GDBusMethodTable manager_methods[] = {
- { "GetProperties", "", "a{sv}", get_properties },
- { "SetProperty", "sv", "", set_property },
- { "RegisterAgent", "o", "", register_agent },
- { "UnregisterAgent", "o", "", unregister_agent },
+ { "GetProperties", "", "a{sv}", get_properties },
+ { "SetProperty", "sv", "", set_property },
+ { "AddProfile", "s", "o", add_profile },
+ { "RemoveProfile", "o", "", remove_profile },
+ { "ConnectService", "a{sv}", "o", connect_service },
+ { "RegisterAgent", "o", "", register_agent },
+ { "UnregisterAgent", "o", "", unregister_agent },
{ },
};
static GDBusSignalTable manager_signals[] = {
{ "PropertyChanged", "sv" },
+ { "StateChanged", "s" },
{ },
};