{
DBusMessage *reply;
DBusMessageIter array, dict;
- connman_bool_t offlinemode;
+ connman_bool_t offlinemode, sessionmode;
const char *str;
DBG("conn %p", conn);
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_PUBLIC) < 0)
- return __connman_error_permission_denied(msg);
-
reply = dbus_message_new_method_return(msg);
if (reply == NULL)
return NULL;
connman_dbus_dict_append_basic(&dict, "ActiveProfile",
DBUS_TYPE_OBJECT_PATH, &str);
- connman_dbus_dict_append_array(&dict, "Profiles",
- DBUS_TYPE_OBJECT_PATH, __connman_profile_list, NULL);
connman_dbus_dict_append_array(&dict, "Services",
DBUS_TYPE_OBJECT_PATH, __connman_service_list, NULL);
- connman_dbus_dict_append_array(&dict, "Providers",
- DBUS_TYPE_OBJECT_PATH, __connman_provider_list, NULL);
connman_dbus_dict_append_array(&dict, "Technologies",
DBUS_TYPE_OBJECT_PATH, __connman_technology_list, NULL);
connman_dbus_dict_append_array(&dict, "EnabledDebugs",
DBUS_TYPE_STRING, __connman_debug_list_enabled, NULL);
+ sessionmode = __connman_session_mode();
+ connman_dbus_dict_append_basic(&dict, "SessionMode",
+ DBUS_TYPE_BOOLEAN,
+ &sessionmode);
+
connman_dbus_dict_close(&array, &dict);
return reply;
dbus_message_iter_next(&iter);
dbus_message_iter_recurse(&iter, &value);
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
- return __connman_error_permission_denied(msg);
-
type = dbus_message_iter_get_arg_type(&value);
if (g_str_equal(name, "OfflineMode") == TRUE) {
dbus_message_iter_get_basic(&value, &offlinemode);
- __connman_profile_set_offlinemode(offlinemode);
+ __connman_profile_set_offlinemode(offlinemode, TRUE);
__connman_profile_save_default();
} else if (g_str_equal(name, "ActiveProfile") == TRUE) {
dbus_message_iter_get_basic(&value, &str);
return __connman_error_not_supported(msg);
+ } else if (g_str_equal(name, "SessionMode") == TRUE) {
+ connman_bool_t sessionmode;
+
+ if (type != DBUS_TYPE_BOOLEAN)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_get_basic(&value, &sessionmode);
+
+ __connman_session_set_mode(sessionmode);
} else
return __connman_error_invalid_property(msg);
DBG("conn %p", conn);
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_PUBLIC) < 0)
- return __connman_error_permission_denied(msg);
-
str = __connman_notifier_get_state();
return g_dbus_create_reply(msg, DBUS_TYPE_STRING, &str,
DBUS_TYPE_INVALID);
}
-static DBusMessage *create_profile(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- const char *name, *path;
- int err;
-
- DBG("conn %p", conn);
-
- dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &name,
- DBUS_TYPE_INVALID);
-
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
- return __connman_error_permission_denied(msg);
-
- err = __connman_profile_create(name, &path);
- if (err < 0)
- return __connman_error_failed(msg, -err);
-
- return g_dbus_create_reply(msg, DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-}
-
-static DBusMessage *remove_profile(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- const char *path;
- int err;
-
- DBG("conn %p", conn);
-
- dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
- return __connman_error_permission_denied(msg);
-
- err = __connman_profile_remove(path);
- if (err < 0)
- return __connman_error_failed(msg, -err);
-
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-}
-
static DBusMessage *remove_provider(DBusConnection *conn,
DBusMessage *msg, void *data)
{
DBG("conn %p", conn);
- dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &path,
- DBUS_TYPE_INVALID);
-
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
- return __connman_error_permission_denied(msg);
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
err = __connman_provider_remove(path);
if (err < 0)
return NULL;
}
+static DBusMessage *get_services(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ DBusMessageIter iter, array;
+
+ reply = dbus_message_new_method_return(msg);
+ if (reply == NULL)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &iter);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_OBJECT_PATH_AS_STRING
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING, &array);
+
+ __connman_service_list_struct(&array);
+
+ dbus_message_iter_close_container(&iter, &array);
+
+ return reply;
+}
+
+static DBusMessage *lookup_service(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ const char *pattern, *path;
+ int err;
+
+ DBG("conn %p", conn);
+
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &pattern,
+ DBUS_TYPE_INVALID);
+
+ err = __connman_service_lookup(pattern, &path);
+ if (err < 0)
+ return __connman_error_failed(msg, -err);
+
+ return g_dbus_create_reply(msg, DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
+}
+
static DBusMessage *connect_service(DBusConnection *conn,
DBusMessage *msg, void *data)
{
DBG("conn %p", conn);
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
- return __connman_error_permission_denied(msg);
+ if (__connman_session_mode() == TRUE) {
+ connman_info("Session mode enabled: "
+ "direct service connect disabled");
+
+ return __connman_error_failed(msg, -EINVAL);
+ }
err = __connman_service_create_and_connect(msg);
if (err < 0) {
return NULL;
}
+static DBusMessage *provision_service(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ int err;
+
+ DBG("conn %p", conn);
+
+ err = __connman_service_provision(msg);
+ if (err < 0)
+ return __connman_error_failed(msg, -err);
+
+ return NULL;
+}
static DBusMessage *connect_provider(DBusConnection *conn,
- DBusMessage *msg, void *data)
+ DBusMessage *msg, void *data)
{
int err;
DBG("conn %p", conn);
- if (__connman_security_check_privilege(msg,
- CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
- return __connman_error_permission_denied(msg);
+ if (__connman_session_mode() == TRUE) {
+ connman_info("Session mode enabled: "
+ "direct provider connect disabled");
+
+ return __connman_error_failed(msg, -EINVAL);
+ }
err = __connman_provider_create_and_connect(msg);
if (err < 0) {
DBusMessage *msg, void *data)
{
const char *sender, *path;
- unsigned int interval;
+ unsigned int accuracy, period;
int err;
DBG("conn %p", conn);
sender = dbus_message_get_sender(msg);
dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_UINT32, &interval,
+ DBUS_TYPE_UINT32, &accuracy,
+ DBUS_TYPE_UINT32, &period,
DBUS_TYPE_INVALID);
- err = __connman_counter_register(sender, path, interval);
+ /* FIXME: add handling of accuracy parameter */
+
+ err = __connman_counter_register(sender, path, period);
if (err < 0)
return __connman_error_failed(msg, -err);
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
-static DBusMessage *request_session(DBusConnection *conn,
+static DBusMessage *create_session(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- const char *bearer, *sender, *service_path;
- struct connman_service *service;
+ int err;
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);
+ err = __connman_session_create(msg);
+ if (err < 0)
+ return __connman_error_failed(msg, -err);
- return g_dbus_create_reply(msg, DBUS_TYPE_OBJECT_PATH, &service_path,
- DBUS_TYPE_INVALID);
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
-static DBusMessage *release_session(DBusConnection *conn,
+static DBusMessage *destroy_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);
+ err = __connman_session_destroy(msg);
if (err < 0)
return __connman_error_failed(msg, -err);
{ "GetProperties", "", "a{sv}", get_properties },
{ "SetProperty", "sv", "", set_property },
{ "GetState", "", "s", get_state },
- { "CreateProfile", "s", "o", create_profile },
- { "RemoveProfile", "o", "", remove_profile },
- { "RemoveProvider", "s", "", remove_provider },
+ { "RemoveProvider", "o", "", remove_provider },
{ "RequestScan", "s", "", request_scan },
{ "EnableTechnology", "s", "", enable_technology,
G_DBUS_METHOD_FLAG_ASYNC },
{ "DisableTechnology", "s", "", disable_technology,
G_DBUS_METHOD_FLAG_ASYNC },
+ { "GetServices", "", "a(oa{sv})", get_services },
+ { "LookupService", "s", "o", lookup_service, },
{ "ConnectService", "a{sv}", "o", connect_service,
G_DBUS_METHOD_FLAG_ASYNC },
+ { "ProvisionService", "s", "", provision_service,
+ G_DBUS_METHOD_FLAG_ASYNC },
{ "ConnectProvider", "a{sv}", "o", connect_provider,
G_DBUS_METHOD_FLAG_ASYNC },
{ "RegisterAgent", "o", "", register_agent },
{ "UnregisterAgent", "o", "", unregister_agent },
- { "RegisterCounter", "ou", "", register_counter },
+ { "RegisterCounter", "ouu", "", register_counter },
{ "UnregisterCounter", "o", "", unregister_counter },
- { "RequestSession", "s", "o", request_session },
- { "ReleaseSession", "s", "", release_session },
+ { "CreateSession", "a{sv}o", "o", create_session },
+ { "DestroySession", "o", "", destroy_session },
{ },
};
{ },
};
-static DBusMessage *nm_sleep(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- DBusMessage *reply;
-
- DBG("conn %p", conn);
-
- reply = dbus_message_new_method_return(msg);
- if (reply == NULL)
- return NULL;
-
- dbus_message_append_args(reply, DBUS_TYPE_INVALID);
-
- return reply;
-}
-
-static DBusMessage *nm_wake(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- DBusMessage *reply;
-
- DBG("conn %p", conn);
-
- reply = dbus_message_new_method_return(msg);
- if (reply == NULL)
- return NULL;
-
- dbus_message_append_args(reply, DBUS_TYPE_INVALID);
-
- return reply;
-}
-
-enum {
- NM_STATE_UNKNOWN = 0,
- NM_STATE_ASLEEP,
- NM_STATE_CONNECTING,
- NM_STATE_CONNECTED,
- NM_STATE_DISCONNECTED
-};
-
-static DBusMessage *nm_state(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- DBusMessage *reply;
- dbus_uint32_t state;
-
- DBG("conn %p", conn);
-
- reply = dbus_message_new_method_return(msg);
- if (reply == NULL)
- return NULL;
-
- if (__connman_notifier_count_connected() > 0)
- state = NM_STATE_CONNECTED;
- else
- state = NM_STATE_DISCONNECTED;
-
- dbus_message_append_args(reply, DBUS_TYPE_UINT32, &state,
- DBUS_TYPE_INVALID);
-
- return reply;
-}
-
-static GDBusMethodTable nm_methods[] = {
- { "sleep", "", "", nm_sleep },
- { "wake", "", "", nm_wake },
- { "state", "", "u", nm_state },
- { },
-};
-
-static gboolean nm_compat = FALSE;
-
-int __connman_manager_init(gboolean compat)
+int __connman_manager_init(void)
{
DBG("");
manager_methods,
manager_signals, NULL, NULL, NULL);
- if (compat == TRUE) {
- g_dbus_register_interface(connection, NM_PATH, NM_INTERFACE,
- nm_methods, NULL, NULL, NULL, NULL);
-
- nm_compat = TRUE;
- }
-
return 0;
}
if (connection == NULL)
return;
- if (nm_compat == TRUE) {
- g_dbus_unregister_interface(connection, NM_PATH, NM_INTERFACE);
- }
-
g_dbus_unregister_interface(connection, CONNMAN_MANAGER_PATH,
CONNMAN_MANAGER_INTERFACE);