summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--callouts/nm-dispatcher-action.h1
-rw-r--r--cli/src/connections.c201
-rw-r--r--cli/src/nmcli.c11
-rw-r--r--cli/src/nmcli.h8
-rw-r--r--docs/libnm-glib/Makefile.am4
-rw-r--r--docs/libnm-glib/libnm-glib-docs.sgml7
-rwxr-xr-xexamples/python/add-system-connection.py4
-rw-r--r--examples/python/list-connections.py17
-rw-r--r--examples/python/nm-state.py7
-rw-r--r--examples/python/vpn.py18
-rw-r--r--include/NetworkManager.h15
-rw-r--r--introspection/Makefile.am3
-rw-r--r--introspection/all.xml2
-rw-r--r--introspection/errors.xml14
-rw-r--r--introspection/nm-active-connection.xml3
-rw-r--r--introspection/nm-manager-client.xml1
-rw-r--r--introspection/nm-manager.xml6
-rw-r--r--introspection/nm-settings-system.xml81
-rw-r--r--introspection/nm-settings.xml37
-rw-r--r--introspection/nm-sysconfig-connection.xml (renamed from introspection/nm-exported-connection.xml)21
-rw-r--r--introspection/nm-vpn-connection.xml3
-rw-r--r--libnm-glib/Makefile.am34
-rw-r--r--libnm-glib/libnm-glib.ver34
-rw-r--r--libnm-glib/nm-active-connection.c90
-rw-r--r--libnm-glib/nm-active-connection.h3
-rw-r--r--libnm-glib/nm-client.c38
-rw-r--r--libnm-glib/nm-client.h12
-rw-r--r--libnm-glib/nm-exported-connection.c281
-rw-r--r--libnm-glib/nm-exported-connection.h75
-rw-r--r--libnm-glib/nm-remote-connection.c204
-rw-r--r--libnm-glib/nm-remote-connection.h38
-rw-r--r--libnm-glib/nm-remote-settings-system.c375
-rw-r--r--libnm-glib/nm-remote-settings-system.h64
-rw-r--r--libnm-glib/nm-remote-settings.c371
-rw-r--r--libnm-glib/nm-remote-settings.h52
-rw-r--r--libnm-glib/nm-settings-connection-interface.c192
-rw-r--r--libnm-glib/nm-settings-connection-interface.h116
-rw-r--r--libnm-glib/nm-settings-interface.c206
-rw-r--r--libnm-glib/nm-settings-interface.h109
-rw-r--r--libnm-glib/nm-settings-service.c372
-rw-r--r--libnm-glib/nm-settings-service.h82
-rw-r--r--libnm-glib/nm-settings-system-interface.c150
-rw-r--r--libnm-glib/nm-settings-system-interface.h108
-rw-r--r--libnm-util/libnm-util.ver4
-rw-r--r--libnm-util/nm-connection.c71
-rw-r--r--libnm-util/nm-connection.h23
-rw-r--r--libnm-util/nm-setting-connection.c128
-rw-r--r--libnm-util/nm-setting-connection.h21
-rw-r--r--man/nmcli.1.in32
-rw-r--r--po/POTFILES.in1
-rw-r--r--policy/Makefile.am1
-rw-r--r--policy/org.freedesktop.NetworkManager.policy.in41
-rw-r--r--policy/org.freedesktop.network-manager-settings.system.policy.in48
-rw-r--r--src/NetworkManager.conf14
-rw-r--r--src/NetworkManagerUtils.c11
-rw-r--r--src/nm-activation-request.c11
-rw-r--r--src/nm-active-connection.c22
-rw-r--r--src/nm-active-connection.h3
-rw-r--r--src/nm-dbus-manager.c18
-rw-r--r--src/nm-device.c4
-rw-r--r--src/nm-manager-auth.c63
-rw-r--r--src/nm-manager-auth.h20
-rw-r--r--src/nm-manager.c1186
-rw-r--r--src/nm-manager.h16
-rw-r--r--src/nm-policy.c12
-rw-r--r--src/system-settings/Makefile.am17
-rw-r--r--src/system-settings/nm-default-wired-connection.c39
-rw-r--r--src/system-settings/nm-polkit-helpers.h5
-rw-r--r--src/system-settings/nm-session-info.c189
-rw-r--r--src/system-settings/nm-session-info.h59
-rw-r--r--src/system-settings/nm-session-manager.c752
-rw-r--r--src/system-settings/nm-session-manager.h82
-rw-r--r--src/system-settings/nm-sysconfig-connection.c1035
-rw-r--r--src/system-settings/nm-sysconfig-connection.h90
-rw-r--r--src/system-settings/nm-sysconfig-settings.c502
-rw-r--r--src/system-settings/nm-sysconfig-settings.h23
-rw-r--r--src/system-settings/nm-system-config-error.c16
-rw-r--r--src/system-settings/nm-system-config-error.h7
-rw-r--r--src/system-settings/nm-system-config-interface.c2
-rw-r--r--src/system-settings/nm-system-config-interface.h10
-rw-r--r--src/vpn-manager/nm-vpn-connection.c11
-rw-r--r--system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c42
-rw-r--r--system-settings/plugins/ifcfg-rh/plugin.c45
-rw-r--r--system-settings/plugins/ifnet/nm-ifnet-connection.c91
-rw-r--r--system-settings/plugins/ifnet/plugin.c41
-rw-r--r--system-settings/plugins/ifupdown/nm-ifupdown-connection.c16
-rw-r--r--system-settings/plugins/ifupdown/plugin.c22
-rw-r--r--system-settings/plugins/keyfile/nm-keyfile-connection.c48
-rw-r--r--system-settings/plugins/keyfile/plugin.c28
-rw-r--r--system-settings/plugins/keyfile/writer.c1
-rw-r--r--test/nm-tool.c80
91 files changed, 3347 insertions, 5126 deletions
diff --git a/callouts/nm-dispatcher-action.h b/callouts/nm-dispatcher-action.h
index 39aefd8f83..e4f2fab2f4 100644
--- a/callouts/nm-dispatcher-action.h
+++ b/callouts/nm-dispatcher-action.h
@@ -22,7 +22,6 @@
#define NM_DISPATCHER_DBUS_IFACE "org.freedesktop.nm_dispatcher"
#define NM_DISPATCHER_DBUS_PATH "/org/freedesktop/nm_dispatcher"
-#define NMD_CONNECTION_PROPS_SERVICE_NAME "service-name"
#define NMD_CONNECTION_PROPS_PATH "path"
#define NMD_DEVICE_PROPS_INTERFACE "interface"
diff --git a/cli/src/connections.c b/cli/src/connections.c
index e0b94ceb8c..1dd70c164e 100644
--- a/cli/src/connections.c
+++ b/cli/src/connections.c
@@ -45,9 +45,6 @@
#include <nm-device-bt.h>
//#include <nm-device-olpc-mesh.h>
#include <nm-remote-settings.h>
-#include <nm-remote-settings-system.h>
-#include <nm-settings-interface.h>
-#include <nm-settings-connection-interface.h>
#include <nm-vpn-connection.h>
#include "utils.h"
@@ -60,32 +57,29 @@ static NmcOutputField nmc_fields_con_status[] = {
{"NAME", N_("NAME"), 25, NULL, 0}, /* 0 */
{"UUID", N_("UUID"), 38, NULL, 0}, /* 1 */
{"DEVICES", N_("DEVICES"), 10, NULL, 0}, /* 2 */
- {"SCOPE", N_("SCOPE"), 8, NULL, 0}, /* 3 */
- {"DEFAULT", N_("DEFAULT"), 8, NULL, 0}, /* 4 */
- {"DBUS-SERVICE", N_("DBUS-SERVICE"), 45, NULL, 0}, /* 5 */
- {"SPEC-OBJECT", N_("SPEC-OBJECT"), 10, NULL, 0}, /* 6 */
- {"VPN", N_("VPN"), 5, NULL, 0}, /* 7 */
- {"DBUS-PATH", N_("DBUS-PATH"), 51, NULL, 0}, /* 8 */
+ {"DEFAULT", N_("DEFAULT"), 8, NULL, 0}, /* 3 */
+ {"SPEC-OBJECT", N_("SPEC-OBJECT"), 10, NULL, 0}, /* 4 */
+ {"VPN", N_("VPN"), 5, NULL, 0}, /* 5 */
+ {"DBUS-PATH", N_("DBUS-PATH"), 51, NULL, 0}, /* 6 */
{NULL, NULL, 0, NULL, 0}
};
-#define NMC_FIELDS_CON_STATUS_ALL "NAME,UUID,DEVICES,SCOPE,DEFAULT,VPN,DBUS-SERVICE,DBUS-PATH,SPEC-OBJECT"
-#define NMC_FIELDS_CON_STATUS_COMMON "NAME,UUID,DEVICES,SCOPE,DEFAULT,VPN"
+#define NMC_FIELDS_CON_STATUS_ALL "NAME,UUID,DEVICES,DEFAULT,VPN,DBUS-PATH,SPEC-OBJECT"
+#define NMC_FIELDS_CON_STATUS_COMMON "NAME,UUID,DEVICES,DEFAULT,VPN"
/* Available fields for 'con list' */
static NmcOutputField nmc_fields_con_list[] = {
{"NAME", N_("NAME"), 25, NULL, 0}, /* 0 */
{"UUID", N_("UUID"), 38, NULL, 0}, /* 1 */
{"TYPE", N_("TYPE"), 17, NULL, 0}, /* 2 */
- {"SCOPE", N_("SCOPE"), 8, NULL, 0}, /* 3 */
- {"TIMESTAMP", N_("TIMESTAMP"), 12, NULL, 0}, /* 4 */
- {"TIMESTAMP-REAL", N_("TIMESTAMP-REAL"), 34, NULL, 0}, /* 5 */
- {"AUTOCONNECT", N_("AUTOCONNECT"), 13, NULL, 0}, /* 6 */
- {"READONLY", N_("READONLY"), 10, NULL, 0}, /* 7 */
- {"DBUS-PATH", N_("DBUS-PATH"), 42, NULL, 0}, /* 8 */
+ {"TIMESTAMP", N_("TIMESTAMP"), 12, NULL, 0}, /* 3 */
+ {"TIMESTAMP-REAL", N_("TIMESTAMP-REAL"), 34, NULL, 0}, /* 4 */
+ {"AUTOCONNECT", N_("AUTOCONNECT"), 13, NULL, 0}, /* 5 */
+ {"READONLY", N_("READONLY"), 10, NULL, 0}, /* 6 */
+ {"DBUS-PATH", N_("DBUS-PATH"), 42, NULL, 0}, /* 7 */
{NULL, NULL, 0, NULL, 0}
};
-#define NMC_FIELDS_CON_LIST_ALL "NAME,UUID,TYPE,SCOPE,TIMESTAMP,TIMESTAMP-REAL,AUTOCONNECT,READONLY,DBUS-PATH"
-#define NMC_FIELDS_CON_LIST_COMMON "NAME,UUID,TYPE,SCOPE,TIMESTAMP-REAL"
+#define NMC_FIELDS_CON_LIST_ALL "NAME,UUID,TYPE,TIMESTAMP,TIMESTAMP-REAL,AUTOCONNECT,READONLY,DBUS-PATH"
+#define NMC_FIELDS_CON_LIST_COMMON "NAME,UUID,TYPE,TIMESTAMP-REAL"
/* Helper macro to define fields */
@@ -147,7 +141,7 @@ static gboolean find_device_for_connection (NmCli *nmc, NMConnection *connection
static const char *active_connection_state_to_string (NMActiveConnectionState state);
static void active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpointer user_data);
static void activate_connection_cb (gpointer user_data, const char *path, GError *error);
-static void get_connections_cb (NMSettingsInterface *settings, gpointer user_data);
+static void get_connections_cb (NMRemoteSettings *settings, gpointer user_data);
static NMCResultCode do_connections_list (NmCli *nmc, int argc, char **argv);
static NMCResultCode do_connections_status (NmCli *nmc, int argc, char **argv);
static NMCResultCode do_connection_up (NmCli *nmc, int argc, char **argv);
@@ -159,7 +153,7 @@ usage (void)
fprintf (stderr,
_("Usage: nmcli con { COMMAND | help }\n"
" COMMAND := { list | status | up | down }\n\n"
- " list [id <id> | uuid <id> | system | user]\n"
+ " list [id <id> | uuid <id>]\n"
" status\n"
" up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [--nowait] [--timeout <timeout>]\n"
" down id <id> | uuid <id>\n"));
@@ -382,12 +376,11 @@ show_connection (NMConnection *data, gpointer user_data)
nmc->allowed_fields[0].value = nm_setting_connection_get_id (s_con);
nmc->allowed_fields[1].value = nm_setting_connection_get_uuid (s_con);
nmc->allowed_fields[2].value = nm_setting_connection_get_connection_type (s_con);
- nmc->allowed_fields[3].value = nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM ? _("system") : _("user");
- nmc->allowed_fields[4].value = timestamp_str;
- nmc->allowed_fields[5].value = timestamp ? timestamp_real_str : _("never");
- nmc->allowed_fields[6].value = nm_setting_connection_get_autoconnect (s_con) ? _("yes") : _("no");
- nmc->allowed_fields[7].value = nm_setting_connection_get_read_only (s_con) ? _("yes") : _("no");
- nmc->allowed_fields[8].value = nm_connection_get_path (connection);
+ nmc->allowed_fields[3].value = timestamp_str;
+ nmc->allowed_fields[4].value = timestamp ? timestamp_real_str : _("never");
+ nmc->allowed_fields[5].value = nm_setting_connection_get_autoconnect (s_con) ? _("yes") : _("no");
+ nmc->allowed_fields[6].value = nm_setting_connection_get_read_only (s_con) ? _("yes") : _("no");
+ nmc->allowed_fields[7].value = nm_connection_get_path (connection);
nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
print_fields (nmc->print_fields, nmc->allowed_fields);
@@ -458,22 +451,15 @@ do_connections_list (NmCli *nmc, int argc, char **argv)
goto error;
valid_param_specified = TRUE;
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
- nmc->print_fields.header_name = _("System connections");
+ nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
print_fields (nmc->print_fields, nmc->allowed_fields);
g_slist_foreach (nmc->system_connections, (GFunc) show_connection, nmc);
-
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
- nmc->print_fields.header_name = _("User connections");
- print_fields (nmc->print_fields, nmc->allowed_fields);
- g_slist_foreach (nmc->user_connections, (GFunc) show_connection, nmc);
}
else {
while (argc > 0) {
if (strcmp (*argv, "id") == 0 || strcmp (*argv, "uuid") == 0) {
const char *selector = *argv;
- NMConnection *con1;
- NMConnection *con2;
+ NMConnection *con;
if (next_arg (&argc, &argv) != 0) {
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *argv);
@@ -484,42 +470,16 @@ do_connections_list (NmCli *nmc, int argc, char **argv)
if (!nmc->mode_specified)
nmc->multiline_output = TRUE; /* multiline mode is default for 'con list id|uuid' */
- con1 = find_connection (nmc->system_connections, selector, *argv);
- con2 = find_connection (nmc->user_connections, selector, *argv);
- if (con1) nmc_connection_detail (con1, nmc);
- if (con2) nmc_connection_detail (con2, nmc);
- if (!con1 && !con2) {
+ con = find_connection (nmc->system_connections, selector, *argv);
+ if (con) {
+ nmc_connection_detail (con, nmc);
+ }
+ else {
g_string_printf (nmc->return_text, _("Error: %s - no such connection."), *argv);
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
}
break;
}
- else if (strcmp (*argv, "system") == 0) {
- if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error2))
- goto error;
- if (error1)
- goto error;
- valid_param_specified = TRUE;
-
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
- nmc->print_fields.header_name = _("System connections");
- print_fields (nmc->print_fields, nmc->allowed_fields);
- g_slist_foreach (nmc->system_connections, (GFunc) show_connection, nmc);
- break;
- }
- else if (strcmp (*argv, "user") == 0) {
- if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error2))
- goto error;
- if (error1)
- goto error;
- valid_param_specified = TRUE;
-
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
- nmc->print_fields.header_name = _("User connections");
- print_fields (nmc->print_fields, nmc->allowed_fields);
- g_slist_foreach (nmc->user_connections, (GFunc) show_connection, nmc);
- break;
- }
else {
fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
}
@@ -553,29 +513,19 @@ error:
return nmc->return_value;
}
-typedef struct {
- NmCli *nmc;
- NMConnectionScope scope;
-} StatusInfo;
-
static void
show_active_connection (gpointer data, gpointer user_data)
{
NMActiveConnection *active = NM_ACTIVE_CONNECTION (data);
- StatusInfo *info = (StatusInfo *) user_data;
+ NmCli *nmc = (NmCli *) user_data;
GSList *con_list, *iter;
const char *active_path;
- NMConnectionScope active_service_scope;
NMSettingConnection *s_con;
const GPtrArray *devices;
GString *dev_str;
int i;
active_path = nm_active_connection_get_connection (active);
- active_service_scope = nm_active_connection_get_scope (active);
-
- if (active_service_scope != info->scope)
- return;
/* Get devices of the active connection */
dev_str = g_string_new (NULL);
@@ -589,7 +539,7 @@ show_active_connection (gpointer data, gpointer user_data)
if (dev_str->len > 0)
g_string_truncate (dev_str, dev_str->len - 1); /* Cut off last ',' */
- con_list = (info->scope == NM_CONNECTION_SCOPE_SYSTEM) ? info->nmc->system_connections : info->nmc->user_connections;
+ con_list = nmc->system_connections;
for (iter = con_list; iter; iter = g_slist_next (iter)) {
NMConnection *connection = (NMConnection *) iter->data;
const char *con_path = nm_connection_get_path (connection);
@@ -600,18 +550,16 @@ show_active_connection (gpointer data, gpointer user_data)
g_assert (s_con != NULL);
/* Obtain field values */
- info->nmc->allowed_fields[0].value = nm_setting_connection_get_id (s_con);
- info->nmc->allowed_fields[1].value = nm_setting_connection_get_uuid (s_con);
- info->nmc->allowed_fields[2].value = dev_str->str;
- info->nmc->allowed_fields[3].value = active_service_scope == NM_CONNECTION_SCOPE_SYSTEM ? _("system") : _("user");
- info->nmc->allowed_fields[4].value = nm_active_connection_get_default (active) ? _("yes") : _("no");
- info->nmc->allowed_fields[5].value = nm_active_connection_get_service_name (active);
- info->nmc->allowed_fields[6].value = nm_active_connection_get_specific_object (active);
- info->nmc->allowed_fields[7].value = NM_IS_VPN_CONNECTION (active) ? _("yes") : _("no");
- info->nmc->allowed_fields[8].value = nm_object_get_path (NM_OBJECT (active));
-
- info->nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
- print_fields (info->nmc->print_fields, info->nmc->allowed_fields);
+ nmc->allowed_fields[0].value = nm_setting_connection_get_id (s_con);
+ nmc->allowed_fields[1].value = nm_setting_connection_get_uuid (s_con);
+ nmc->allowed_fields[2].value = dev_str->str;
+ nmc->allowed_fields[3].value = nm_active_connection_get_default (active) ? _("yes") : _("no");
+ nmc->allowed_fields[4].value = nm_active_connection_get_specific_object (active);
+ nmc->allowed_fields[5].value = NM_IS_VPN_CONNECTION (active) ? _("yes") : _("no");
+ nmc->allowed_fields[6].value = nm_object_get_path (NM_OBJECT (active));
+
+ nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
+ print_fields (nmc->print_fields, nmc->allowed_fields);
break;
}
}
@@ -624,7 +572,6 @@ do_connections_status (NmCli *nmc, int argc, char **argv)
{
const GPtrArray *active_cons;
GError *error = NULL;
- StatusInfo *info;
char *fields_str;
char *fields_all = NMC_FIELDS_CON_STATUS_ALL;
char *fields_common = NMC_FIELDS_CON_STATUS_COMMON;
@@ -664,15 +611,8 @@ do_connections_status (NmCli *nmc, int argc, char **argv)
nmc->print_fields.header_name = _("Active connections");
print_fields (nmc->print_fields, nmc->allowed_fields);
- if (active_cons && active_cons->len) {
- info = g_malloc0 (sizeof (StatusInfo));
- info->nmc = nmc;
- info->scope = NM_CONNECTION_SCOPE_SYSTEM;
- g_ptr_array_foreach ((GPtrArray *) active_cons, show_active_connection, (gpointer) info);
- info->scope = NM_CONNECTION_SCOPE_USER;
- g_ptr_array_foreach ((GPtrArray *) active_cons, show_active_connection, (gpointer) info);
- g_free (info);
- }
+ if (active_cons && active_cons->len)
+ g_ptr_array_foreach ((GPtrArray *) active_cons, show_active_connection, (gpointer) nmc);
error:
@@ -1319,7 +1259,6 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
gboolean device_found;
NMConnection *connection = NULL;
NMSettingConnection *s_con;
- gboolean is_system;
const char *con_path;
const char *con_type;
const char *iface = NULL;
@@ -1344,8 +1283,7 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
goto error;
}
- if ((connection = find_connection (nmc->system_connections, selector, *argv)) == NULL)
- connection = find_connection (nmc->user_connections, selector, *argv);
+ connection = find_connection (nmc->system_connections, selector, *argv);
if (!connection) {
g_string_printf (nmc->return_text, _("Error: Unknown connection: %s."), *argv);
@@ -1405,7 +1343,6 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
if (!nmc->get_client (nmc))
goto error;
- is_system = (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) ? TRUE : FALSE;
con_path = nm_connection_get_path (connection);
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
@@ -1428,7 +1365,6 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
nmc->nowait_flag = !wait;
nmc->should_wait = TRUE;
nm_client_activate_connection (nmc->client,
- is_system ? NM_DBUS_SERVICE_SYSTEM_SETTINGS : NM_DBUS_SERVICE_USER_SETTINGS,
con_path,
device,
spec_object,
@@ -1449,7 +1385,6 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
const GPtrArray *active_cons;
const char *con_path;
const char *active_path;
- NMConnectionScope active_service_scope, con_scope;
gboolean id_specified = FALSE;
gboolean wait = TRUE;
int i;
@@ -1465,8 +1400,7 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
goto error;
}
- if ((connection = find_connection (nmc->system_connections, selector, *argv)) == NULL)
- connection = find_connection (nmc->user_connections, selector, *argv);
+ connection = find_connection (nmc->system_connections, selector, *argv);
if (!connection) {
g_string_printf (nmc->return_text, _("Error: Unknown connection: %s."), *argv);
@@ -1496,20 +1430,21 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
goto error;
con_path = nm_connection_get_path (connection);
- con_scope = nm_connection_get_scope (connection);
active_cons = nm_client_get_active_connections (nmc->client);
for (i = 0; active_cons && (i < active_cons->len); i++) {
NMActiveConnection *candidate = g_ptr_array_index (active_cons, i);
active_path = nm_active_connection_get_connection (candidate);
- active_service_scope = nm_active_connection_get_scope (candidate);
- if (!strcmp (active_path, con_path) && active_service_scope == con_scope) {
+ if (!strcmp (active_path, con_path)) {
active = candidate;
break;
}
}
+ /* TODO: fail gracefully if we are using an old N-M with user settings
+ * support */
+
if (active)
nm_client_deactivate_connection (nmc->client, active);
else {
@@ -1524,26 +1459,12 @@ error:
/* callback called when connections are obtained from the settings service */
static void
-get_connections_cb (NMSettingsInterface *settings, gpointer user_data)
+get_connections_cb (NMRemoteSettings *settings, gpointer user_data)
{
ArgsInfo *args = (ArgsInfo *) user_data;
- static gboolean system_cb_called = FALSE;
- static gboolean user_cb_called = FALSE;
GError *error = NULL;
- if (NM_IS_REMOTE_SETTINGS_SYSTEM (settings)) {
- system_cb_called = TRUE;
- args->nmc->system_connections = nm_settings_interface_list_connections (settings);
- }
- else {
- user_cb_called = TRUE;
- args->nmc->user_connections = nm_settings_interface_list_connections (settings);
- }
-
- /* return and wait for the callback of the second settings is called */
- if ( (args->nmc->system_settings_running && !system_cb_called)
- || (args->nmc->user_settings_running && !user_cb_called))
- return;
+ args->nmc->system_connections = nm_remote_settings_list_connections (settings);
if (args->argc == 0) {
if (!nmc_terse_option_check (args->nmc->print_output, args->nmc->required_fields, &error))
@@ -1612,38 +1533,26 @@ do_connections (NmCli *nmc, int argc, char **argv)
}
/* get system settings */
- if (!(nmc->system_settings = nm_remote_settings_system_new (bus))) {
+ if (!(nmc->system_settings = nm_remote_settings_new (bus))) {
g_string_printf (nmc->return_text, _("Error: Could not get system settings."));
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
return nmc->return_value;
}
- /* get user settings */
- if (!(nmc->user_settings = nm_remote_settings_new (bus, NM_CONNECTION_SCOPE_USER))) {
- g_string_printf (nmc->return_text, _("Error: Could not get user settings."));
- nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
- return nmc->return_value;
- }
-
- /* find out whether setting services are running */
+ /* find out whether settings service is running */
g_object_get (nmc->system_settings, NM_REMOTE_SETTINGS_SERVICE_RUNNING, &nmc->system_settings_running, NULL);
- g_object_get (nmc->user_settings, NM_REMOTE_SETTINGS_SERVICE_RUNNING, &nmc->user_settings_running, NULL);
- if (!nmc->system_settings_running && !nmc->user_settings_running) {
- g_string_printf (nmc->return_text, _("Error: Can't obtain connections: settings services are not running."));
+ if (!nmc->system_settings_running) {
+ g_string_printf (nmc->return_text, _("Error: Can't obtain connections: settings service is not running."));
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
return nmc->return_value;
}
/* connect to signal "connections-read" - emitted when connections are fetched and ready */
- if (nmc->system_settings_running)
- g_signal_connect (nmc->system_settings, NM_SETTINGS_INTERFACE_CONNECTIONS_READ,
- G_CALLBACK (get_connections_cb), &args_info);
+ g_signal_connect (nmc->system_settings, NM_REMOTE_SETTINGS_CONNECTIONS_READ,
+ G_CALLBACK (get_connections_cb), &args_info);
- if (nmc->user_settings_running)
- g_signal_connect (nmc->user_settings, NM_SETTINGS_INTERFACE_CONNECTIONS_READ,
- G_CALLBACK (get_connections_cb), &args_info);
dbus_g_connection_unref (bus);
diff --git a/cli/src/nmcli.c b/cli/src/nmcli.c
index d416952c6c..bfd90b15a4 100644
--- a/cli/src/nmcli.c
+++ b/cli/src/nmcli.c
@@ -35,9 +35,6 @@
#include <nm-client.h>
#include <nm-setting-connection.h>
#include <nm-remote-settings.h>
-#include <nm-remote-settings-system.h>
-#include <nm-settings-interface.h>
-#include <nm-settings-connection-interface.h>
#include "nmcli.h"
#include "utils.h"
@@ -277,13 +274,8 @@ nmc_init (NmCli *nmc)
nmc->timeout = 10;
nmc->system_settings = NULL;
- nmc->user_settings = NULL;
-
nmc->system_settings_running = FALSE;
- nmc->user_settings_running = FALSE;
-
nmc->system_connections = NULL;
- nmc->user_connections = NULL;
nmc->should_wait = FALSE;
nmc->nowait_flag = TRUE;
@@ -304,10 +296,7 @@ nmc_cleanup (NmCli *nmc)
g_string_free (nmc->return_text, TRUE);
if (nmc->system_settings) g_object_unref (nmc->system_settings);
- if (nmc->user_settings) g_object_unref (nmc->user_settings);
-
g_slist_free (nmc->system_connections);
- g_slist_free (nmc->user_connections);
g_free (nmc->required_fields);
if (nmc->print_fields.indices)
diff --git a/cli/src/nmcli.h b/cli/src/nmcli.h
index 9788ef086c..c980f4981f 100644
--- a/cli/src/nmcli.h
+++ b/cli/src/nmcli.h
@@ -24,7 +24,6 @@
#include <nm-client.h>
#include <nm-remote-settings.h>
-#include <nm-remote-settings-system.h>
/* nmcli exit codes */
typedef enum {
@@ -92,14 +91,9 @@ typedef struct _NmCli {
int timeout; /* Operation timeout */
- NMRemoteSettingsSystem *system_settings; /* System settings */
- NMRemoteSettings *user_settings; /* User settings */
-
+ NMRemoteSettings *system_settings; /* System settings */
gboolean system_settings_running; /* Is system settings service running? */
- gboolean user_settings_running; /* Is user settings service running? */
-
GSList *system_connections; /* List of system connections */
- GSList *user_connections; /* List of user connections */
gboolean should_wait; /* Indication that nmcli should not end yet */
gboolean nowait_flag; /* '--nowait' option; used for passing to callbacks */
diff --git a/docs/libnm-glib/Makefile.am b/docs/libnm-glib/Makefile.am
index 96ff66eee3..f3665f2bcd 100644
--- a/docs/libnm-glib/Makefile.am
+++ b/docs/libnm-glib/Makefile.am
@@ -45,13 +45,11 @@ IGNORE_HFILES= \
nm-device-wifi-bindings.h \
nm-dhcp4-config-bindings.h \
nm-dhcp6-config-bindings.h \
- nm-exported-connection-bindings.h \
- nm-exported-connection-glue.h \
+ nm-sysconfig-connection-glue.h \
nm-ip4-config-bindings.h \
nm-ip6-config-bindings.h \
nm-settings-bindings.h \
nm-settings-glue.h \
- nm-settings-system-bindings.h \
nm-vpn-connection-bindings.h \
nm-vpn-plugin-glue.h
diff --git a/docs/libnm-glib/libnm-glib-docs.sgml b/docs/libnm-glib/libnm-glib-docs.sgml
index b4e5dac25a..efe379744a 100644
--- a/docs/libnm-glib/libnm-glib-docs.sgml
+++ b/docs/libnm-glib/libnm-glib-docs.sgml
@@ -27,15 +27,10 @@
<xi:include href="xml/nm-ip6-config.xml"/>
<xi:include href="xml/nm-dhcp4-config.xml"/>
<xi:include href="xml/nm-dhcp6-config.xml"/>
- <xi:include href="xml/nm-exported-connection.xml"/>
+ <xi:include href="xml/nm-sysconfig-connection.xml"/>
<xi:include href="xml/nm-object.xml"/>
<xi:include href="xml/nm-remote-connection.xml"/>
<xi:include href="xml/nm-remote-settings.xml"/>
- <xi:include href="xml/nm-remote-settings-system.xml"/>
- <xi:include href="xml/nm-settings-connection-interface.xml"/>
- <xi:include href="xml/nm-settings-interface.xml"/>
- <xi:include href="xml/nm-settings-service.xml"/>
- <xi:include href="xml/nm-settings-system-interface.xml"/>
<xi:include href="xml/nm-types.xml"/>
<xi:include href="xml/nm-vpn-connection.xml"/>
<xi:include href="xml/nm-vpn-plugin.xml"/>
diff --git a/examples/python/add-system-connection.py b/examples/python/add-system-connection.py
index 39eaabee0d..d508e8c6eb 100755
--- a/examples/python/add-system-connection.py
+++ b/examples/python/add-system-connection.py
@@ -41,8 +41,8 @@ con = dbus.Dictionary({
bus = dbus.SystemBus()
-proxy = bus.get_object("org.freedesktop.NetworkManagerSystemSettings", "/org/freedesktop/NetworkManagerSettings")
-settings = dbus.Interface(proxy, "org.freedesktop.NetworkManagerSettings")
+proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings")
+settings = dbus.Interface(proxy, "org.freedesktop.NetworkManager.Settings")
settings.AddConnection(con)
diff --git a/examples/python/list-connections.py b/examples/python/list-connections.py
index ad8d9047c4..9c3e1771c6 100644
--- a/examples/python/list-connections.py
+++ b/examples/python/list-connections.py
@@ -70,25 +70,24 @@ def connection_to_string(config):
print ""
-def print_one_services_connections(service_name, desc):
+def print_connections():
# Ask the settings service for the list of connections it provides
- proxy = bus.get_object(service_name, "/org/freedesktop/NetworkManagerSettings")
- settings = dbus.Interface(proxy, "org.freedesktop.NetworkManagerSettings")
+ service_name = "org.freedesktop.NetworkManager"
+ proxy = bus.get_object(service_name, "/org/freedesktop/NetworkManager/Settings")
+ settings = dbus.Interface(proxy, "org.freedesktop.NetworkManager.Settings")
connection_paths = settings.ListConnections()
- print "%s connections --------------------------------------------\n" % desc
-
# List each connection's name, UUID, and type
for path in connection_paths:
con_proxy = bus.get_object(service_name, path)
- connection = dbus.Interface(con_proxy, "org.freedesktop.NetworkManagerSettings.Connection")
+ connection = dbus.Interface(con_proxy, "org.freedesktop.NetworkManager.Settings.Connection")
config = connection.GetSettings()
# Now get secrets too; we grab the secrets for each type of connection
# (since there isn't a "get all secrets" call because most of the time
# you only need 'wifi' secrets or '802.1x' secrets, not everything) and
# merge that into the configuration data
- connection_secrets = dbus.Interface(con_proxy, "org.freedesktop.NetworkManagerSettings.Connection.Secrets")
+ connection_secrets = dbus.Interface(con_proxy, "org.freedesktop.NetworkManager.Settings.Connection.Secrets")
merge_secrets(connection_secrets, config, '802-11-wireless')
merge_secrets(connection_secrets, config, '802-11-wireless-security')
merge_secrets(connection_secrets, config, '802-1x')
@@ -106,7 +105,5 @@ def print_one_services_connections(service_name, desc):
print ""
-# Print out connection information for all connections
-print_one_services_connections("org.freedesktop.NetworkManagerSystemSettings", "System")
-print_one_services_connections("org.freedesktop.NetworkManagerUserSettings", "User")
+print_connections()
diff --git a/examples/python/nm-state.py b/examples/python/nm-state.py
index fddd2da629..42c96bf56d 100644
--- a/examples/python/nm-state.py
+++ b/examples/python/nm-state.py
@@ -53,11 +53,8 @@ for a in active:
# needed to connect to a specific network. Lets get those details so we
# can find the user-readable name of the connection.
con_path = prop_iface.Get("org.freedesktop.NetworkManager.ActiveConnection", "Connection")
- con_service = prop_iface.Get("org.freedesktop.NetworkManager.ActiveConnection", "ServiceName")
-
- # ask the provider of the connection for its details
- service_proxy = bus.get_object(con_service, con_path)
- con_iface = dbus.Interface(service_proxy, "org.freedesktop.NetworkManagerSettings.Connection")
+ service_proxy = bus.get_object("org.freedesktop.NetworkManager", con_path)
+ con_iface = dbus.Interface(service_proxy, "org.freedesktop.NetworkManager.Settings.Connection")
con_details = con_iface.GetSettings()
con_name = con_details['connection']['id']
diff --git a/examples/python/vpn.py b/examples/python/vpn.py
index 4b4057fc2b..7e3e19f378 100644
--- a/examples/python/vpn.py
+++ b/examples/python/vpn.py
@@ -37,16 +37,16 @@ DBusGMainLoop(set_as_default=True)
def get_connections():
bus = dbus.SystemBus()
- proxy = bus.get_object('org.freedesktop.NetworkManagerUserSettings', '/org/freedesktop/NetworkManagerSettings')
- iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManagerSettings')
+ proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager/Settings')
+ iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager.Settings')
return iface.ListConnections()
def get_connection_by_uuid(uuid):
bus = dbus.SystemBus()
for c in get_connections():
- proxy = bus.get_object('org.freedesktop.NetworkManagerUserSettings', c)
- iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManagerSettings.Connection')
+ proxy = bus.get_object('org.freedesktop.NetworkManager', c)
+ iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager.Settings.Connection')
settings = iface.GetSettings()
if settings['connection']['uuid'] == uuid:
return c
@@ -57,8 +57,8 @@ def get_connection_by_uuid(uuid):
def list_uuids():
bus = dbus.SystemBus()
for c in get_connections():
- proxy = bus.get_object('org.freedesktop.NetworkManagerUserSettings', c)
- iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManagerSettings.Connection')
+ proxy = bus.get_object('org.freedesktop.NetworkManager', c)
+ iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager.Settings.Connection')
settings = iface.GetSettings()
conn = settings['connection']
print "%s - %s (%s)" % (conn['uuid'], conn['id'], conn['type'])
@@ -76,8 +76,8 @@ def get_active_connection_path(uuid):
iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties')
path = iface.Get('org.freedesktop.NetworkManager.Connection.Active', 'Connection')
- proxy = bus.get_object('org.freedesktop.NetworkManagerUserSettings', path)
- iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManagerSettings.Connection')
+ proxy = bus.get_object('org.freedesktop.NetworkManager', path)
+ iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager.Settings.Connection')
settings = iface.GetSettings()
if settings['connection']['uuid'] == uuid:
@@ -112,7 +112,7 @@ def activate_connection(connection_path, device_path):
bus = dbus.SystemBus()
proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager')
iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager')
- iface.ActivateConnection('org.freedesktop.NetworkManagerUserSettings',
+ iface.ActivateConnection('org.freedesktop.NetworkManager',
connection_path,
device_path,
"/",
diff --git a/include/NetworkManager.h b/include/NetworkManager.h
index f58b84bcdd..eef2bb1d1d 100644
--- a/include/NetworkManager.h
+++ b/include/NetworkManager.h
@@ -45,15 +45,12 @@
#define NM_DBUS_INTERFACE_DHCP6_CONFIG NM_DBUS_INTERFACE ".DHCP6Config"
-#define NM_DBUS_SERVICE_USER_SETTINGS "org.freedesktop.NetworkManagerUserSettings"
-#define NM_DBUS_SERVICE_SYSTEM_SETTINGS "org.freedesktop.NetworkManagerSystemSettings"
-#define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManagerSettings"
-#define NM_DBUS_IFACE_SETTINGS_SYSTEM "org.freedesktop.NetworkManagerSettings.System"
-#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManagerSettings"
-
-#define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManagerSettings.Connection"
-#define NM_DBUS_PATH_SETTINGS_CONNECTION "/org/freedesktop/NetworkManagerSettings/Connection"
-#define NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS "org.freedesktop.NetworkManagerSettings.Connection.Secrets"
+#define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManager.Settings"
+#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManager/Settings"
+
+#define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManager.Settings.Connection"
+#define NM_DBUS_PATH_SETTINGS_CONNECTION "/org/freedesktop/NetworkManager/Settings/Connection"
+#define NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS "org.freedesktop.NetworkManager.Settings.Connection.Secrets"
/*
diff --git a/introspection/Makefile.am b/introspection/Makefile.am
index 212da3ab93..0092504266 100644
--- a/introspection/Makefile.am
+++ b/introspection/Makefile.am
@@ -17,8 +17,7 @@ EXTRA_DIST = \
nm-manager.xml \
nm-manager-client.xml \
nm-settings.xml \
- nm-settings-system.xml \
- nm-exported-connection.xml \
+ nm-sysconfig-connection.xml \
nm-vpn-plugin.xml \
nm-vpn-connection.xml \
nm-ppp-manager.xml \
diff --git a/introspection/all.xml b/introspection/all.xml
index d6b2f23674..1f33708e53 100644
--- a/introspection/all.xml
+++ b/introspection/all.xml
@@ -40,7 +40,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</
<xi:include href="nm-dhcp4-config.xml"/>
<xi:include href="nm-dhcp6-config.xml"/>
<xi:include href="nm-settings.xml"/>
-<xi:include href="nm-exported-connection.xml"/>
+<xi:include href="nm-sysconfig-connection.xml"/>
<xi:include href="nm-active-connection.xml"/>
<xi:include href="nm-vpn-connection.xml"/>
<xi:include href="nm-vpn-plugin.xml"/>
diff --git a/introspection/errors.xml b/introspection/errors.xml
index 444b325d5e..f2db86679f 100644
--- a/introspection/errors.xml
+++ b/introspection/errors.xml
@@ -5,7 +5,7 @@
<tp:error name="Unknown Connection">
<tp:docstring>
- Connection was not provided by any known settings service.
+ Connection was not provided by the settings service.
</tp:docstring>
</tp:error>
@@ -15,18 +15,6 @@
</tp:docstring>
</tp:error>
- <tp:error name="Invalid Service">
- <tp:docstring>
- Invalid settings service (not a recognized system or user settings service name).
- </tp:docstring>
- </tp:error>
-
- <tp:error name="System Connection">
- <tp:docstring>
- Connection was superseded by a system connection.
- </tp:docstring>
- </tp:error>
-
<tp:error name="Permission Denied">
<tp:docstring>
User does not have the permission to activate this connection.
diff --git a/introspection/nm-active-connection.xml b/introspection/nm-active-connection.xml
index 765830a1dc..494eba42b2 100644
--- a/introspection/nm-active-connection.xml
+++ b/introspection/nm-active-connection.xml
@@ -2,9 +2,6 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.Connection.Active">
- <property name="ServiceName" type="s" access="read">
- <tp:docstring>The D-Bus service name providing this connection.</tp:docstring>
- </property>
<property name="Connection" type="o" access="read">
<tp:docstring>The path of the connection.</tp:docstring>
</property>
diff --git a/introspection/nm-manager-client.xml b/introspection/nm-manager-client.xml
index 24e4a29eb5..540aff3780 100644
--- a/introspection/nm-manager-client.xml
+++ b/introspection/nm-manager-client.xml
@@ -22,7 +22,6 @@ object. dbus-glib generates the same bound function names for D-Bus the methods
<method name="ActivateConnection">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_activate_connection"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg name="service_name" type="s" direction="in"/>
<arg name="connection" type="o" direction="in"/>
<arg name="device" type="o" direction="in"/>
<arg name="specific_object" type="o" direction="in"/>
diff --git a/introspection/nm-manager.xml b/introspection/nm-manager.xml
index f281d9d2c4..92a78b349a 100644
--- a/introspection/nm-manager.xml
+++ b/introspection/nm-manager.xml
@@ -27,11 +27,6 @@
<tp:docstring>
Activate a connection using the supplied device.
</tp:docstring>
- <arg name="service_name" type="s" direction="in">
- <tp:docstring>
- The D-Bus service name of the settings service that provides this connection.
- </tp:docstring>
- </arg>
<arg name="connection" type="o" direction="in">
<tp:docstring>
The connection to activate the devices with.
@@ -62,7 +57,6 @@
<tp:possible-errors>
<tp:error name="org.freedesktop.NetworkManager.Error.UnknownConnection"/>
<tp:error name="org.freedesktop.NetworkManager.Error.UnknownDevice"/>
- <tp:error name="org.freedesktop.NetworkManager.Error.InvalidService"/>
<tp:error name="org.freedesktop.NetworkManager.Error.ConnectionActivating">
<tp:docstring>Another connection is already activating or the same connection is already active. FIXME: check if the error name is correct. FIXME: split into 2 errors?</tp:docstring>
</tp:error>
diff --git a/introspection/nm-settings-system.xml b/introspection/nm-settings-system.xml
deleted file mode 100644
index 598274c0d1..0000000000
--- a/introspection/nm-settings-system.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
- <interface name="org.freedesktop.NetworkManagerSettings.System">
- <tp:docstring>
- Implemented by the system settings service to provide additional settings to NetworkManager.
- </tp:docstring>
-
- <method name="SaveHostname">
- <tp:docstring>
- Save the hostname to persistent configuration.
- </tp:docstring>
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_save_hostname"/>
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg name="hostname" type="s" direction="in">
- <tp:docstring>
- The hostname to save to persistent configuration. If blank, the persistent hostname is cleared.
- </tp:docstring>
- </arg>
- </method>
-
- <property name="Hostname" type="s" access="read">
- <tp:docstring>
- The machine hostname stored in persistent configuration.
- </tp:docstring>
- </property>
-
- <property name="CanModify" type="b" access="read">
- <tp:docstring>
- If true, adding and modifying connections is supported.
- </tp:docstring>
- </property>
-
- <signal name="PropertiesChanged">
- <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
- <tp:docstring>
- A dictionary mapping property names to variant boxed values
- </tp:docstring>
- </arg>
- </signal>
-
- <signal name="CheckPermissions">
- <tp:docstring>
- Emitted when system authorization details change, indicating that clients may wish to recheck permissions with GetPermissions.
- </tp:docstring>
- </signal>
-
- <method name="GetPermissions">
- <tp:docstring>
- Returns a bitfield indicating certain operations the caller is permitted to perform. Some of these operations may require authorization by the user.
- </tp:docstring>
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_get_permissions"/>
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg name="permissions" type="u" direction="out" tp:type="NM_SETTINGS_SYSTEM_PERMISSIONS">
- <tp:docstring>
- A bitfield of permitted operations. Some of these operations may require the user to authorize via password entry or other means.
- </tp:docstring>
- </arg>
- </method>
-
- <tp:flags name="NM_SETTINGS_SYSTEM_PERMISSIONS" value-prefix="NM_SETTINGS_SYSTEM_PERMISSION" type="u">
- <tp:flag suffix="NONE" value="0x0">
- <tp:docstring>No permissions.</tp:docstring>
- </tp:flag>
- <tp:flag suffix="CONNECTION_MODIFY" value="0x1">
- <tp:docstring>Can modify/add/delete connections.</tp:docstring>
- </tp:flag>
- <tp:flag suffix="WIFI_SHARING_PROTECTED" value="0x2">
- <tp:docstring>Can share connections via a encrypted user-created WiFi network.</tp:docstring>
- </tp:flag>
- <tp:flag suffix="WIFI_SHARING_OPEN" value="0x4">
- <tp:docstring>Can share connections via a open/unencrypted user-created WiFi network.</tp:docstring>
- </tp:flag>
- <tp:flag suffix="HOSTNAME_MODIFY" value="0x8">
- <tp:docstring>Can modify the persistent system hostname.</tp:docstring>
- </tp:flag>
- </tp:flags>
-
- </interface>
-</node>
-
diff --git a/introspection/nm-settings.xml b/introspection/nm-settings.xml
index b252c00d59..f10a6e1c63 100644
--- a/introspection/nm-settings.xml
+++ b/introspection/nm-settings.xml
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
- <interface name="org.freedesktop.NetworkManagerSettings">
+ <interface name="org.freedesktop.NetworkManager.Settings">
<tp:docstring>
- The NetworkManagerSettings interface is provided by the service which provides connections to NetworkManager.
+ The Settings interface allows clients to view and administrate the connections stored and used by NetworkManager.
</tp:docstring>
<method name="ListConnections">
@@ -31,6 +31,39 @@
</arg>
</method>
+ <method name="SaveHostname">
+ <tp:docstring>
+ Save the hostname to persistent configuration.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_save_hostname"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="hostname" type="s" direction="in">
+ <tp:docstring>
+ The hostname to save to persistent configuration. If blank, the persistent hostname is cleared.
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <property name="Hostname" type="s" access="read">
+ <tp:docstring>
+ The machine hostname stored in persistent configuration.
+ </tp:docstring>
+ </property>
+
+ <property name="CanModify" type="b" access="read">
+ <tp:docstring>
+ If true, adding and modifying connections is supported.
+ </tp:docstring>
+ </property>
+
+ <signal name="PropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
+
<signal name="NewConnection">
<tp:docstring>
Emitted when a new connection has been added.
diff --git a/introspection/nm-exported-connection.xml b/introspection/nm-sysconfig-connection.xml
index 46907c05e9..427213269f 100644
--- a/introspection/nm-exported-connection.xml
+++ b/introspection/nm-sysconfig-connection.xml
@@ -2,7 +2,7 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
- <interface name="org.freedesktop.NetworkManagerSettings.Connection">
+ <interface name="org.freedesktop.NetworkManager.Settings.Connection">
<tp:docstring>
Represents a single network connection configuration.
</tp:docstring>
@@ -11,7 +11,7 @@
<tp:docstring>
Update the connection with new settings and properties, replacing all previous settings and properties.
</tp:docstring>
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_update"/>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_sysconfig_connection_update"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="properties" type="a{sa{sv}}" direction="in">
<tp:docstring>
@@ -24,7 +24,7 @@
<tp:docstring>
Delete the connection.
</tp:docstring>
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_delete"/>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_sysconfig_connection_delete"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
</method>
@@ -32,7 +32,8 @@
<tp:docstring>
Get the settings maps describing this object.
</tp:docstring>
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_get_settings"/>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_sysconfig_connection_get_settings"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="settings" type="a{sa{sv}}" direction="out" tp:type="String_String_Variant_Map_Map">
<tp:docstring>
The nested settings maps describing this object.
@@ -53,13 +54,19 @@
<signal name="Removed">
<tp:docstring>
- Emitted when this connection has been deleted/removed. After receipt of this signal, the object no longer exists.
+ Emitted when this connection is no longer available. This happens when the connection is deleted or if it is no longer accessable by any of the system's logged in users. After receipt of this signal, the object no longer exists.
+ </tp:docstring>
+ </signal>
+
+ <signal name="CheckPermissions">
+ <tp:docstring>
+ Emitted when a client's permission to access this connection may have changed. Generally, clients should re-test their ability to access this connecton whenever this signal is emmited.
</tp:docstring>
</signal>
</interface>
- <interface name="org.freedesktop.NetworkManagerSettings.Connection.Secrets">
+ <interface name="org.freedesktop.NetworkManager.Settings.Connection.Secrets">
<tp:docstring>
Secrets have a separate interface so that they can be locked down.
</tp:docstring>
@@ -68,7 +75,7 @@
<tp:docstring>
Get the secrets encapsulated in this object.
</tp:docstring>
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_get_secrets"/>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_sysconfig_connection_get_secrets"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="setting_name" type="s" direction="in">
<tp:docstring>
diff --git a/introspection/nm-vpn-connection.xml b/introspection/nm-vpn-connection.xml
index 3a47cdf1b2..eaf0fa678e 100644
--- a/introspection/nm-vpn-connection.xml
+++ b/introspection/nm-vpn-connection.xml
@@ -2,9 +2,6 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.Connection.Active">
- <property name="ServiceName" type="s" access="read">
- <tp:docstring>The D-Bus service name providing this connection.</tp:docstring>
- </property>
<property name="Connection" type="o" access="read">
<tp:docstring>The path of the connection.</tp:docstring>
</property>
diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am
index ec21a328e9..aa6f959608 100644
--- a/libnm-glib/Makefile.am
+++ b/libnm-glib/Makefile.am
@@ -10,11 +10,8 @@ BUILT_SOURCES = \
nm-device-ethernet-bindings.h \
nm-device-wifi-bindings.h \
nm-device-bt-bindings.h \
- nm-exported-connection-glue.h \
- nm-exported-connection-bindings.h \
- nm-settings-glue.h \
+ nm-sysconfig-connection-bindings.h \
nm-settings-bindings.h \
- nm-settings-system-bindings.h \
nm-vpn-connection-bindings.h \
nm-vpn-plugin-glue.h \
nm-active-connection-bindings.h \
@@ -79,13 +76,7 @@ libnminclude_HEADERS = \
nm-ip6-config.h \
nm-dhcp6-config.h \
nm-remote-connection.h \
- nm-settings-interface.h \
- nm-settings-system-interface.h \
- nm-remote-settings.h \
- nm-remote-settings-system.h \
- nm-settings-connection-interface.h \
- nm-exported-connection.h \
- nm-settings-service.h
+ nm-remote-settings.h
libnm_glib_la_SOURCES = \
nm-object.c \
@@ -114,13 +105,7 @@ libnm_glib_la_SOURCES = \
nm-dhcp6-config.c \
nm-remote-connection.c \
nm-remote-connection-private.h \
- nm-settings-interface.c \
- nm-settings-system-interface.c \
- nm-remote-settings.c \
- nm-remote-settings-system.c \
- nm-settings-connection-interface.c \
- nm-exported-connection.c \
- nm-settings-service.c
+ nm-remote-settings.c
libnm_glib_la_LIBADD = \
$(top_builddir)/libnm-util/libnm-util.la \
@@ -166,20 +151,11 @@ nm-device-bt-bindings.h: $(top_srcdir)/introspection/nm-device-bt.xml
nm-access-point-bindings.h: $(top_srcdir)/introspection/nm-access-point.xml
$(AM_V_GEN) dbus-binding-tool --prefix=nm_access_point --mode=glib-client --output=$@ $<
-nm-settings-glue.h: $(top_srcdir)/introspection/nm-settings.xml
- $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-server --output=$@ $<
-
nm-settings-bindings.h: $(top_srcdir)/introspection/nm-settings.xml
$(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-client --output=$@ $<
-nm-settings-system-bindings.h: $(top_srcdir)/introspection/nm-settings-system.xml
- $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings_system --mode=glib-client --output=$@ $<
-
-nm-exported-connection-glue.h: $(top_srcdir)/introspection/nm-exported-connection.xml
- $(AM_V_GEN) dbus-binding-tool --prefix=nm_exported_connection --mode=glib-server --output=$@ $<
-
-nm-exported-connection-bindings.h: $(top_srcdir)/introspection/nm-exported-connection.xml
- $(AM_V_GEN) dbus-binding-tool --prefix=nm_exported_connection --mode=glib-client --output=$@ $<
+nm-sysconfig-connection-bindings.h: $(top_srcdir)/introspection/nm-sysconfig-connection.xml
+ $(AM_V_GEN) dbus-binding-tool --prefix=nm_sysconfig_connection --mode=glib-client --output=$@ $<
nm-vpn-connection-bindings.h: $(top_srcdir)/introspection/nm-vpn-connection.xml
$(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection --mode=glib-client --output=$@ $<
diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver
index 1596afaad9..1ac3bdb5c4 100644
--- a/libnm-glib/libnm-glib.ver
+++ b/libnm-glib/libnm-glib.ver
@@ -20,8 +20,6 @@ global:
nm_active_connection_get_default;
nm_active_connection_get_default6;
nm_active_connection_get_devices;
- nm_active_connection_get_scope;
- nm_active_connection_get_service_name;
nm_active_connection_get_specific_object;
nm_active_connection_get_state;
nm_active_connection_get_type;
@@ -95,9 +93,6 @@ global:
nm_dhcp4_config_get_options;
nm_dhcp4_config_get_type;
nm_dhcp4_config_new;
- nm_exported_connection_export;
- nm_exported_connection_get_type;
- nm_exported_connection_new;
nm_gsm_device_get_type;
nm_gsm_device_new;
nm_ip4_config_get_addresses;
@@ -121,34 +116,21 @@ global:
nm_object_get_connection;
nm_object_get_path;
nm_object_get_type;
+ nm_remote_connection_delete;
+ nm_remote_connection_get_secrets;
+ nm_remote_connection_commit_changes;
nm_remote_connection_get_type;
nm_remote_connection_new;
+ nm_remote_settings_add_connection;
+ nm_remote_settings_get_connection_by_path;
+ nm_remote_settings_list_connections;
+ nm_remote_settings_get_permissions;
+ nm_remote_settings_save_hostname;
nm_remote_settings_get_type;
nm_remote_settings_new;
- nm_remote_settings_system_get_type;
- nm_remote_settings_system_new;
nm_serial_device_get_bytes_received;
nm_serial_device_get_bytes_sent;
nm_serial_device_get_type;
- nm_settings_connection_interface_delete;
- nm_settings_connection_interface_emit_updated;
- nm_settings_connection_interface_get_secrets;
- nm_settings_connection_interface_get_type;
- nm_settings_connection_interface_update;
- nm_settings_interface_add_connection;
- nm_settings_interface_error_get_type;
- nm_settings_interface_error_quark;
- nm_settings_interface_get_connection_by_path;
- nm_settings_interface_get_type;
- nm_settings_interface_list_connections;
- nm_settings_service_export;
- nm_settings_service_export_connection;
- nm_settings_service_get_connection_by_path;
- nm_settings_service_get_type;
- nm_settings_system_interface_get_type;
- nm_settings_system_interface_add_connection;
- nm_settings_system_interface_get_permissions;
- nm_settings_system_interface_save_hostname;
nm_settings_error_quark;
nm_settings_get_type;
nm_settings_list_connections;
diff --git a/libnm-glib/nm-active-connection.c b/libnm-glib/nm-active-connection.c
index 2468da099f..f9e8adbf14 100644
--- a/libnm-glib/nm-active-connection.c
+++ b/libnm-glib/nm-active-connection.c
@@ -43,8 +43,6 @@ typedef struct {
gboolean disposed;
DBusGProxy *proxy;
- char *service_name;
- NMConnectionScope scope;
char *connection;
char *specific_object;
GPtrArray *devices;
@@ -55,7 +53,6 @@ typedef struct {
enum {
PROP_0,
- PROP_SERVICE_NAME,
PROP_CONNECTION,
PROP_SPECIFIC_OBJECT,
PROP_DEVICES,
@@ -66,7 +63,6 @@ enum {
LAST_PROP
};
-#define DBUS_PROP_SERVICE_NAME "ServiceName"
#define DBUS_PROP_CONNECTION "Connection"
#define DBUS_PROP_SPECIFIC_OBJECT "SpecificObject"
#define DBUS_PROP_DEVICES "Devices"
@@ -95,62 +91,6 @@ nm_active_connection_new (DBusGConnection *connection, const char *path)
NULL);
}
-static NMConnectionScope
-get_scope_for_service_name (const char *service_name)
-{
- if (service_name && !strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS))
- return NM_CONNECTION_SCOPE_USER;
- else if (service_name && !strcmp (service_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS))
- return NM_CONNECTION_SCOPE_SYSTEM;
-
- return NM_CONNECTION_SCOPE_UNKNOWN;
-}
-
-/**
- * nm_active_connection_get_service_name:
- * @connection: a #NMActiveConnection
- *
- * Gets the service name of the active connection.
- *
- * Returns: the service name. This is the internal string used by the
- * connection, and must not be modified.
- **/
-const char *
-nm_active_connection_get_service_name (NMActiveConnection *connection)
-{
- NMActiveConnectionPrivate *priv;
-
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
-
- priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
- if (!priv->service_name) {
- priv->service_name = _nm_object_get_string_property (NM_OBJECT (connection),
- NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
- DBUS_PROP_SERVICE_NAME);
- priv->scope = get_scope_for_service_name (priv->service_name);
- }
-
- return priv->service_name;
-}
-
-/**
- * nm_active_connection_get_scope:
- * @connection: a #NMActiveConnection
- *
- * Gets the scope of the active connection.
- *
- * Returns: the connection's scope
- **/
-NMConnectionScope
-nm_active_connection_get_scope (NMActiveConnection *connection)
-{
- g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NM_CONNECTION_SCOPE_UNKNOWN);
-
- /* Make sure service_name and scope are up-to-date */
- nm_active_connection_get_service_name (connection);
- return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->scope;
-}
-
/**
* nm_active_connection_get_connection:
* @connection: a #NMActiveConnection
@@ -345,7 +285,6 @@ finalize (GObject *object)
{
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object);
- g_free (priv->service_name);
g_free (priv->connection);
g_free (priv->specific_object);
@@ -361,9 +300,6 @@ get_property (GObject *object,
NMActiveConnection *self = NM_ACTIVE_CONNECTION (object);
switch (prop_id) {
- case PROP_SERVICE_NAME:
- g_value_set_string (value, nm_active_connection_get_service_name (self));
- break;
case PROP_CONNECTION:
g_value_set_boxed (value, nm_active_connection_get_connection (self));
break;
@@ -401,24 +337,11 @@ demarshal_devices (NMObject *object, GParamSpec *pspec, GValue *value, gpointer
return TRUE;
}
-static gboolean
-demarshal_service (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object);
-
- if (_nm_object_demarshal_generic (object, pspec, value, field)) {
- priv->scope = get_scope_for_service_name (priv->service_name);
- return TRUE;
- }
- return FALSE;
-}
-
static void
register_for_property_changed (NMActiveConnection *connection)
{
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
const NMPropertiesChangedInfo property_changed_info[] = {
- { NM_ACTIVE_CONNECTION_SERVICE_NAME, demarshal_service, &priv->service_name },
{ NM_ACTIVE_CONNECTION_CONNECTION, _nm_object_demarshal_generic, &priv->connection },
{ NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, _nm_object_demarshal_generic, &priv->specific_object },
{ NM_ACTIVE_CONNECTION_DEVICES, demarshal_devices, &priv->devices },
@@ -476,19 +399,6 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class)
/* properties */
/**
- * NMActiveConnection:service-name:
- *
- * The service name of the active connection.
- **/
- g_object_class_install_property
- (object_class, PROP_SERVICE_NAME,
- g_param_spec_string (NM_ACTIVE_CONNECTION_SERVICE_NAME,
- "Service Name",
- "Service Name",
- NULL,
- G_PARAM_READABLE));
-
- /**
* NMActiveConnection:connection:
*
* The connection's path of the active connection.
diff --git a/libnm-glib/nm-active-connection.h b/libnm-glib/nm-active-connection.h
index 30edf047a0..a641e7c1a5 100644
--- a/libnm-glib/nm-active-connection.h
+++ b/libnm-glib/nm-active-connection.h
@@ -39,7 +39,6 @@ G_BEGIN_DECLS
#define NM_IS_ACTIVE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_ACTIVE_CONNECTION))
#define NM_ACTIVE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionClass))
-#define NM_ACTIVE_CONNECTION_SERVICE_NAME "service-name"
#define NM_ACTIVE_CONNECTION_CONNECTION "connection"
#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
@@ -67,8 +66,6 @@ GType nm_active_connection_get_type (void);
GObject *nm_active_connection_new (DBusGConnection *connection, const char *path);
-const char * nm_active_connection_get_service_name (NMActiveConnection *connection);
-NMConnectionScope nm_active_connection_get_scope (NMActiveConnection *connection);
const char * nm_active_connection_get_connection (NMActiveConnection *connection);
const char * nm_active_connection_get_specific_object (NMActiveConnection *connection);
const GPtrArray *nm_active_connection_get_devices (NMActiveConnection *connection);
diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c
index 88fe15b550..e7770df64e 100644
--- a/libnm-glib/nm-client.c
+++ b/libnm-glib/nm-client.c
@@ -290,10 +290,15 @@ register_for_property_changed (NMClient *client)
property_changed_info);
}
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK "org.freedesktop.NetworkManager.enable-disable-network"
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI "org.freedesktop.NetworkManager.enable-disable-wifi"
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN "org.freedesktop.NetworkManager.enable-disable-wwan"
-#define NM_AUTH_PERMISSION_USE_USER_CONNECTIONS "org.freedesktop.NetworkManager.use-user-connections"
+#define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK "org.freedesktop.NetworkManager.enable-disable-network"
+#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI "org.freedesktop.NetworkManager.enable-disable-wifi"
+#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN "org.freedesktop.NetworkManager.enable-disable-wwan"
+#define NM_AUTH_PERMISSION_SLEEP_WAKE "org.freedesktop.NetworkManager.sleep-wake"
+#define NM_AUTH_PERMISSION_NETWORK_CONTROL "org.freedesktop.NetworkManager.network-control"
+#define NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED "org.freedesktop.NetworkManager.wifi.share.protected"
+#define NM_AUTH_PERMISSION_WIFI_SHARE_OPEN "org.freedesktop.NetworkManager.wifi.share.open"
+#define NM_AUTH_PERMISSION_SETTINGS_CONNECTION_MODIFY "org.freedesktop.NetworkManager.settings.modify"
+#define NM_AUTH_PERMISSION_SETTINGS_HOSTNAME_MODIFY "org.freedesktop.NetworkManager.settings.hostname.modify"
static NMClientPermission
nm_permission_to_client (const char *nm)
@@ -304,8 +309,19 @@ nm_permission_to_client (const char *nm)
return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI;
else if (!strcmp (nm, NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN))
return NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN;
- else if (!strcmp (nm, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS))
- return NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_SLEEP_WAKE))
+ return NM_CLIENT_PERMISSION_SLEEP_WAKE;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_NETWORK_CONTROL))
+ return NM_CLIENT_PERMISSION_NETWORK_CONTROL;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED))
+ return NM_CLIENT_PERMISSION_WIFI_SHARE_PROTECTED;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_WIFI_SHARE_OPEN))
+ return NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_SETTINGS_CONNECTION_MODIFY))
+ return NM_CLIENT_PERMISSION_SETTINGS_CONNECTION_MODIFY;
+ else if (!strcmp (nm, NM_AUTH_PERMISSION_SETTINGS_HOSTNAME_MODIFY))
+ return NM_CLIENT_PERMISSION_SETTINGS_HOSTNAME_MODIFY;
+
return NM_CLIENT_PERMISSION_NONE;
}
@@ -464,9 +480,9 @@ constructor (GType type,
get_permissions_sync (NM_CLIENT (object));
priv->bus_proxy = dbus_g_proxy_new_for_name (connection,
- "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus");
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged",
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
@@ -993,7 +1009,6 @@ activate_cb (DBusGProxy *proxy,
/**
* nm_client_activate_connection:
* @client: a #NMClient
- * @service_name: the connection's service name
* @connection_path: the connection's DBus path
* @device: the #NMDevice
* @specific_object: the device specific object (currently used only for
@@ -1005,7 +1020,6 @@ activate_cb (DBusGProxy *proxy,
**/
void
nm_client_activate_connection (NMClient *client,
- const char *service_name,
const char *connection_path,
NMDevice *device,
const char *specific_object,
@@ -1017,7 +1031,6 @@ nm_client_activate_connection (NMClient *client,
g_return_if_fail (NM_IS_CLIENT (client));
g_return_if_fail (NM_IS_DEVICE (device));
- g_return_if_fail (service_name != NULL);
g_return_if_fail (connection_path != NULL);
/* NULL specific object must be translated into "/" because D-Bus does
@@ -1031,7 +1044,6 @@ nm_client_activate_connection (NMClient *client,
info->user_data = user_data;
org_freedesktop_NetworkManager_activate_connection_async (NM_CLIENT_GET_PRIVATE (client)->client_proxy,
- service_name,
connection_path,
nm_object_get_path (NM_OBJECT (device)),
internal_so,
diff --git a/libnm-glib/nm-client.h b/libnm-glib/nm-client.h
index c67e0d8f84..69847fdcc6 100644
--- a/libnm-glib/nm-client.h
+++ b/libnm-glib/nm-client.h
@@ -56,9 +56,14 @@ typedef enum {
NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK = 1,
NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI = 2,
NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN = 3,
- NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS = 4,
-
- NM_CLIENT_PERMISSION_LAST = NM_CLIENT_PERMISSION_USE_USER_CONNECTIONS
+ NM_CLIENT_PERMISSION_SLEEP_WAKE = 4,
+ NM_CLIENT_PERMISSION_NETWORK_CONTROL = 5,
+ NM_CLIENT_PERMISSION_WIFI_SHARE_PROTECTED = 6,
+ NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN = 7,
+ NM_CLIENT_PERMISSION_SETTINGS_CONNECTION_MODIFY = 8,
+ NM_CLIENT_PERMISSION_SETTINGS_HOSTNAME_MODIFY = 9,
+
+ NM_CLIENT_PERMISSION_LAST = NM_CLIENT_PERMISSION_SETTINGS_HOSTNAME_MODIFY
} NMClientPermission;
typedef enum {
@@ -99,7 +104,6 @@ NMDevice *nm_client_get_device_by_path (NMClient *client, const char *object_
typedef void (*NMClientActivateDeviceFn) (gpointer user_data, const char *object_path, GError *error);
void nm_client_activate_connection (NMClient *client,
- const char *service_name,
const char *connection_path,
NMDevice *device,
const char *specific_object,
diff --git a/libnm-glib/nm-exported-connection.c b/libnm-glib/nm-exported-connection.c
deleted file mode 100644
index 3a8e51ce79..0000000000
--- a/libnm-glib/nm-exported-connection.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager system settings service
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * (C) Copyright 2008 Novell, Inc.
- * (C) Copyright 2008 - 2009 Red Hat, Inc.
- */
-
-#include <NetworkManager.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <nm-setting-connection.h>
-
-#include "nm-exported-connection.h"
-#include "nm-settings-interface.h"
-#include "nm-settings-connection-interface.h"
-
-static gboolean impl_exported_connection_get_settings (NMExportedConnection *connection,
- GHashTable **settings,
- GError **error);
-
-static void impl_exported_connection_update (NMExportedConnection *connection,
- GHashTable *new_settings,
- DBusGMethodInvocation *context);
-
-static void impl_exported_connection_delete (NMExportedConnection *connection,
- DBusGMethodInvocation *context);
-
-static void impl_exported_connection_get_secrets (NMExportedConnection *connection,
- const gchar *setting_name,
- const gchar **hints,
- gboolean request_new,
- DBusGMethodInvocation *context);
-
-#include "nm-exported-connection-glue.h"
-
-static void settings_connection_interface_init (NMSettingsConnectionInterface *class);
-
-G_DEFINE_TYPE_EXTENDED (NMExportedConnection, nm_exported_connection, NM_TYPE_CONNECTION, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
- settings_connection_interface_init))
-
-#define NM_EXPORTED_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- NM_TYPE_EXPORTED_CONNECTION, \
- NMExportedConnectionPrivate))
-
-typedef struct {
- gboolean foo;
-} NMExportedConnectionPrivate;
-
-
-/**************************************************************/
-
-static GHashTable *
-real_get_settings (NMExportedConnection *self, GError **error)
-{
- NMConnection *no_secrets;
- GHashTable *settings;
-
- /* Secrets should *never* be returned by the GetSettings method, they
- * get returned by the GetSecrets method which can be better
- * protected against leakage of secrets to unprivileged callers.
- */
- no_secrets = nm_connection_duplicate (NM_CONNECTION (self));
- g_assert (no_secrets);
- nm_connection_clear_secrets (no_secrets);
- settings = nm_connection_to_hash (no_secrets);
- g_assert (settings);
- g_object_unref (no_secrets);
-
- return settings;
-}
-
-/**************************************************************/
-
-static gboolean
-check_writable (NMConnection *connection, GError **error)
-{
- NMSettingConnection *s_con;
-
- g_return_val_if_fail (connection != NULL, FALSE);
- g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
-
- s_con = (NMSettingConnection *) nm_connection_get_setting (connection,
- NM_TYPE_SETTING_CONNECTION);
- if (!s_con) {
- g_set_error_literal (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
- "Connection did not have required 'connection' setting");
- return FALSE;
- }
-
- /* If the connection is read-only, that has to be changed at the source of
- * the problem (ex a system settings plugin that can't write connections out)
- * instead of over D-Bus.
- */
- if (nm_setting_connection_get_read_only (s_con)) {
- g_set_error_literal (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_READ_ONLY_CONNECTION,
- "Connection is read-only");
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-impl_exported_connection_get_settings (NMExportedConnection *self,
- GHashTable **settings,
- GError **error)
-{
- /* Must always be implemented */
- g_assert (NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_settings);
- *settings = NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_settings (self, error);
- return *settings ? TRUE : FALSE;
-}
-
-static gboolean
-update (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceUpdateFunc callback,
- gpointer user_data)
-{
- g_object_ref (connection);
- nm_settings_connection_interface_emit_updated (connection);
- callback (connection, NULL, user_data);
- g_object_unref (connection);
- return TRUE;
-}
-
-static void
-impl_exported_connection_update (NMExportedConnection *self,
- GHashTable *new_settings,
- DBusGMethodInvocation *context)
-{
- NMConnection *tmp;
- GError *error = NULL;
-
- /* If the connection is read-only, that has to be changed at the source of
- * the problem (ex a system settings plugin that can't write connections out)
- * instead of over D-Bus.
- */
- if (!check_writable (NM_CONNECTION (self), &error)) {
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- return;
- }
-
- /* Check if the settings are valid first */
- tmp = nm_connection_new_from_hash (new_settings, &error);
- if (!tmp) {
- g_assert (error);
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- return;
- }
- g_object_unref (tmp);
-
- if (NM_EXPORTED_CONNECTION_GET_CLASS (self)->update)
- NM_EXPORTED_CONNECTION_GET_CLASS (self)->update (self, new_settings, context);
- else {
- error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
- "%s: %s:%d update() unimplemented", __func__, __FILE__, __LINE__);
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- }
-}
-
-static gboolean
-do_delete (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceDeleteFunc callback,
- gpointer user_data)
-{
- g_object_ref (connection);
- g_signal_emit_by_name (connection, "removed");
- callback (connection, NULL, user_data);
- g_object_unref (connection);
- return TRUE;
-}
-
-static void
-impl_exported_connection_delete (NMExportedConnection *self,
- DBusGMethodInvocation *context)
-{
- GError *error = NULL;
-
- if (!check_writable (NM_CONNECTION (self), &error)) {
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- return;
- }
-
- if (NM_EXPORTED_CONNECTION_GET_CLASS (self)->delete)
- NM_EXPORTED_CONNECTION_GET_CLASS (self)->delete (self, context);
- else {
- error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
- "%s: %s:%d delete() unimplemented", __func__, __FILE__, __LINE__);
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- }
-}
-
-static void
-impl_exported_connection_get_secrets (NMExportedConnection *self,
- const gchar *setting_name,
- const gchar **hints,
- gboolean request_new,
- DBusGMethodInvocation *context)
-{
- GError *error = NULL;
-
- if (NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_secrets)
- NM_EXPORTED_CONNECTION_GET_CLASS (self)->get_secrets (self, setting_name, hints, request_new, context);
- else {
- error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
- "%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__);
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- }
-}
-
-/**************************************************************/
-
-static void
-settings_connection_interface_init (NMSettingsConnectionInterface *iface)
-{
- iface->update = update;
- iface->delete = do_delete;
-}
-
-/**
- * nm_exported_connection_new:
- * @scope: the Connection scope (either user or system)
- *
- * Creates a new object representing the remote connection.
- *
- * Returns: the new exported connection object on success, or %NULL on failure
- **/
-NMExportedConnection *
-nm_exported_connection_new (NMConnectionScope scope)
-{
- g_return_val_if_fail (scope != NM_CONNECTION_SCOPE_UNKNOWN, NULL);
-
- return (NMExportedConnection *) g_object_new (NM_TYPE_EXPORTED_CONNECTION,
- NM_CONNECTION_SCOPE, scope,
- NULL);
-}
-
-static void
-nm_exported_connection_init (NMExportedConnection *self)
-{
-}
-
-static void
-nm_exported_connection_class_init (NMExportedConnectionClass *class)
-{
- g_type_class_add_private (class, sizeof (NMExportedConnectionPrivate));
-
- /* Virtual methods */
- class->get_settings = real_get_settings;
-
- dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (class),
- &dbus_glib_nm_exported_connection_object_info);
-}
diff --git a/libnm-glib/nm-exported-connection.h b/libnm-glib/nm-exported-connection.h
deleted file mode 100644
index 53dc3b024e..0000000000
--- a/libnm-glib/nm-exported-connection.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager system settings service
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * (C) Copyright 2009 Red Hat, Inc.
- */
-
-#ifndef NM_EXPORTED_CONNECTION_H
-#define NM_EXPORTED_CONNECTION_H
-
-#include <nm-connection.h>
-#include <dbus/dbus-glib.h>
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_EXPORTED_CONNECTION (nm_exported_connection_get_type ())
-#define NM_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnection))
-#define NM_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnectionClass))
-#define NM_IS_EXPORTED_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_EXPORTED_CONNECTION))
-#define NM_IS_EXPORTED_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_EXPORTED_CONNECTION))
-#define NM_EXPORTED_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_EXPORTED_CONNECTION, NMExportedConnectionClass))
-
-typedef struct {
- NMConnection parent;
-} NMExportedConnection;
-
-typedef struct {
- NMConnectionClass parent;
-
- GHashTable * (*get_settings) (NMExportedConnection *self,
- GError **error);
-
- void (*update) (NMExportedConnection *self,
- GHashTable *new_settings,
- DBusGMethodInvocation *context);
-
- void (*delete) (NMExportedConnection *self,
- DBusGMethodInvocation *context);
-
- void (*get_secrets) (NMExportedConnection *self,
- const gchar *setting_name,
- const gchar **hints,
- gboolean request_new,
- DBusGMethodInvocation *context);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMExportedConnectionClass;
-
-GType nm_exported_connection_get_type (void);
-
-NMExportedConnection *nm_exported_connection_new (NMConnectionScope scope);
-
-G_END_DECLS
-
-#endif /* NM_EXPORTED_CONNECTION_H */
diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c
index 1039a7d188..9f52570cb8 100644
--- a/libnm-glib/nm-remote-connection.c
+++ b/libnm-glib/nm-remote-connection.c
@@ -29,15 +29,11 @@
#include "nm-remote-connection.h"
#include "nm-remote-connection-private.h"
#include "nm-dbus-glib-types.h"
-#include "nm-exported-connection-bindings.h"
-#include "nm-settings-connection-interface.h"
+#include "nm-sysconfig-connection-bindings.h"
#define NM_REMOTE_CONNECTION_BUS "bus"
-static void settings_connection_interface_init (NMSettingsConnectionInterface *klass);
-
-G_DEFINE_TYPE_EXTENDED (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNECTION, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE, settings_connection_interface_init))
+G_DEFINE_TYPE (NMRemoteConnection, nm_remote_connection, NM_TYPE_CONNECTION)
enum {
PROP_0,
@@ -47,6 +43,14 @@ enum {
LAST_PROP
};
+enum {
+ UPDATED,
+ REMOVED,
+
+ LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL] = { 0 };
+
typedef struct {
NMRemoteConnection *self;
@@ -88,22 +92,36 @@ static void
update_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
{
RemoteCall *call = user_data;
- NMSettingsConnectionInterfaceUpdateFunc func = (NMSettingsConnectionInterfaceUpdateFunc) call->callback;
+ NMRemoteConnectionCommitFunc func = (NMRemoteConnectionCommitFunc) call->callback;
- (*func)(NM_SETTINGS_CONNECTION_INTERFACE (call->self), error, call->user_data);
+ (*func)(call->self, error, call->user_data);
remote_call_complete (call->self, call);
}
-static gboolean
-update (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceUpdateFunc callback,
- gpointer user_data)
+/**
+ * nm_remote_connection_commit_changes:
+ * @connection: the #NMRemoteConnection
+ * @callback: a function to be called when the commit completes
+ * @user_data: caller-specific data to be passed to @callback
+ *
+ * Save any local changes to the settings and properties of this connection and
+ * save them in the settings service.
+ **/
+void
+nm_remote_connection_commit_changes (NMRemoteConnection *self,
+ NMRemoteConnectionCommitFunc callback,
+ gpointer user_data)
{
- NMRemoteConnection *self = NM_REMOTE_CONNECTION (connection);
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
+ NMRemoteConnectionPrivate *priv;
GHashTable *settings = NULL;
RemoteCall *call;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (NM_IS_REMOTE_CONNECTION (self));
+ g_return_if_fail (callback != NULL);
+
+ priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
+
call = g_malloc0 (sizeof (RemoteCall));
call->self = self;
call->callback = (GFunc) callback;
@@ -112,90 +130,114 @@ update (NMSettingsConnectionInterface *connection,
settings = nm_connection_to_hash (NM_CONNECTION (self));
- call->call = org_freedesktop_NetworkManagerSettings_Connection_update_async (priv->proxy,
- settings,
- update_cb,
- call);
+ call->call = org_freedesktop_NetworkManager_Settings_Connection_update_async (priv->proxy,
+ settings,
+ update_cb,
+ call);
g_assert (call->call);
priv->calls = g_slist_append (priv->calls, call);
g_hash_table_destroy (settings);
-
- return TRUE;
}
static void
delete_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
{
RemoteCall *call = user_data;
- NMSettingsConnectionInterfaceDeleteFunc func = (NMSettingsConnectionInterfaceDeleteFunc) call->callback;
+ NMRemoteConnectionDeleteFunc func = (NMRemoteConnectionDeleteFunc) call->callback;
- (*func)(NM_SETTINGS_CONNECTION_INTERFACE (call->self), error, call->user_data);
+ (*func)(call->self, error, call->user_data);
remote_call_complete (call->self, call);
}
-static gboolean
-do_delete (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceDeleteFunc callback,
- gpointer user_data)
+/**
+ * nm_remote_connection_delete:
+ * @connection: the #NMRemoteConnection
+ * @callback: a function to be called when the delete completes
+ * @user_data: caller-specific data to be passed to @callback
+ *
+ * Delete the connection.
+ **/
+void
+nm_remote_connection_delete (NMRemoteConnection *self,
+ NMRemoteConnectionDeleteFunc callback,
+ gpointer user_data)
{
- NMRemoteConnection *self = NM_REMOTE_CONNECTION (connection);
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
+ NMRemoteConnectionPrivate *priv;
RemoteCall *call;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (NM_IS_REMOTE_CONNECTION (self));
+ g_return_if_fail (callback != NULL);
+
+ priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
+
call = g_malloc0 (sizeof (RemoteCall));
call->self = self;
call->callback = (GFunc) callback;
call->user_data = user_data;
call->proxy = priv->proxy;
- call->call = org_freedesktop_NetworkManagerSettings_Connection_delete_async (priv->proxy,
- delete_cb,
- call);
+ call->call = org_freedesktop_NetworkManager_Settings_Connection_delete_async (priv->proxy,
+ delete_cb,
+ call);
g_assert (call->call);
priv->calls = g_slist_append (priv->calls, call);
-
- return TRUE;
}
static void
get_secrets_cb (DBusGProxy *proxy, GHashTable *secrets, GError *error, gpointer user_data)
{
RemoteCall *call = user_data;
- NMSettingsConnectionInterfaceGetSecretsFunc func = (NMSettingsConnectionInterfaceGetSecretsFunc) call->callback;
+ NMRemoteConnectionGetSecretsFunc func = (NMRemoteConnectionGetSecretsFunc) call->callback;
- (*func)(NM_SETTINGS_CONNECTION_INTERFACE (call->self), error ? NULL : secrets, error, call->user_data);
+ (*func)(call->self, error ? NULL : secrets, error, call->user_data);
remote_call_complete (call->self, call);
}
-static gboolean
-get_secrets (NMSettingsConnectionInterface *connection,
- const char *setting_name,
- const char **hints,
- gboolean request_new,
- NMSettingsConnectionInterfaceGetSecretsFunc callback,
- gpointer user_data)
+/**
+ * nm_remote_connection_get_secrets:
+ * @connection: the #NMRemoteConnection
+ * @setting_name: the #NMSetting object name to get secrets for
+ * @hints: #NMSetting key names to get secrets for (optional)
+ * @request_new: hint that new secrets (instead of cached or stored secrets)
+ * should be returned
+ * @callback: a function to be called when the update completes
+ * @user_data: caller-specific data to be passed to @callback
+ *
+ * Request the connection's secrets.
+ **/
+void
+nm_remote_connection_get_secrets (NMRemoteConnection *self,
+ const char *setting_name,
+ const char **hints,
+ gboolean request_new,
+ NMRemoteConnectionGetSecretsFunc callback,
+ gpointer user_data)
{
- NMRemoteConnection *self = NM_REMOTE_CONNECTION (connection);
- NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
+ NMRemoteConnectionPrivate *priv;
RemoteCall *call;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (NM_IS_REMOTE_CONNECTION (self));
+ g_return_if_fail (callback != NULL);
+
+ priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
+
call = g_malloc0 (sizeof (RemoteCall));
call->self = self;
call->callback = (GFunc) callback;
call->user_data = user_data;
call->proxy = priv->secrets_proxy;
- call->call = org_freedesktop_NetworkManagerSettings_Connection_Secrets_get_secrets_async (priv->secrets_proxy,
- setting_name,
- hints,
- request_new,
- get_secrets_cb,
- call);
+ call->call = org_freedesktop_NetworkManager_Settings_Connection_Secrets_get_secrets_async (priv->secrets_proxy,
+ setting_name,
+ hints,
+ request_new,
+ get_secrets_cb,
+ call);
g_assert (call->call);
priv->calls = g_slist_append (priv->calls, call);
-
- return TRUE;
}
/****************************************************************/
@@ -206,9 +248,8 @@ replace_settings (NMRemoteConnection *self, GHashTable *new_settings)
GError *error = NULL;
if (!nm_connection_replace_settings (NM_CONNECTION (self), new_settings, &error)) {
- g_warning ("%s: error updating %s connection %s settings: (%d) %s",
+ g_warning ("%s: error updating connection %s settings: (%d) %s",
__func__,
- (nm_connection_get_scope (NM_CONNECTION (self)) == NM_CONNECTION_SCOPE_USER) ? "user" : "system",
nm_connection_get_path (NM_CONNECTION (self)),
error ? error->code : -1,
(error && error->message) ? error->message : "(unknown)");
@@ -219,7 +260,7 @@ replace_settings (NMRemoteConnection *self, GHashTable *new_settings)
/* Emit update irregardless to let listeners figure out what to do with
* the connection; whether to delete / ignore it or not.
*/
- nm_settings_connection_interface_emit_updated (NM_SETTINGS_CONNECTION_INTERFACE (self));
+ g_signal_emit (self, signals[UPDATED], 0, new_settings);
return TRUE;
}
@@ -233,9 +274,8 @@ get_settings_cb (DBusGProxy *proxy,
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
if (error) {
- g_warning ("%s: error getting %s connection %s settings: (%d) %s",
+ g_warning ("%s: error getting connection %s settings: (%d) %s",
__func__,
- (nm_connection_get_scope (NM_CONNECTION (self)) == NM_CONNECTION_SCOPE_USER) ? "user" : "system",
nm_connection_get_path (NM_CONNECTION (self)),
error ? error->code : -1,
(error && error->message) ? error->message : "(unknown)");
@@ -259,26 +299,15 @@ updated_cb (DBusGProxy *proxy, GHashTable *settings, gpointer user_data)
static void
removed_cb (DBusGProxy *proxy, gpointer user_data)
{
- g_signal_emit_by_name (G_OBJECT (user_data), "removed");
+ g_signal_emit (G_OBJECT (user_data), signals[REMOVED], 0);
}
/****************************************************************/
-static void
-settings_connection_interface_init (NMSettingsConnectionInterface *klass)
-{
- /* interface implementation */
- klass->update = update;
- klass->delete = do_delete;
- klass->get_secrets = get_secrets;
-}
-
/**
* nm_remote_connection_new:
* @bus: a valid and connected D-Bus connection
- * @scope: the Connection scope (either user or system)
* @path: the D-Bus path of the connection as exported by the settings service
- * indicated by @scope
*
* Creates a new object representing the remote connection.
*
@@ -286,7 +315,6 @@ settings_connection_interface_init (NMSettingsConnectionInterface *klass)
**/
NMRemoteConnection *
nm_remote_connection_new (DBusGConnection *bus,
- NMConnectionScope scope,
const char *path)
{
g_return_val_if_fail (bus != NULL, NULL);
@@ -294,7 +322,6 @@ nm_remote_connection_new (DBusGConnection *bus,
return (NMRemoteConnection *) g_object_new (NM_TYPE_REMOTE_CONNECTION,
NM_REMOTE_CONNECTION_BUS, bus,
- NM_CONNECTION_SCOPE, scope,
NM_CONNECTION_PATH, path,
NULL);
}
@@ -306,7 +333,6 @@ constructor (GType type,
{
GObject *object;
NMRemoteConnectionPrivate *priv;
- const char *service = NM_DBUS_SERVICE_USER_SETTINGS;
object = G_OBJECT_CLASS (nm_remote_connection_parent_class)->constructor (type, n_construct_params, construct_params);
if (!object)
@@ -316,18 +342,15 @@ constructor (GType type,
g_assert (priv->bus);
g_assert (nm_connection_get_path (NM_CONNECTION (object)));
- if (nm_connection_get_scope (NM_CONNECTION (object)) == NM_CONNECTION_SCOPE_SYSTEM)
- service = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
-
priv->proxy = dbus_g_proxy_new_for_name (priv->bus,
- service,
+ NM_DBUS_SERVICE,
nm_connection_get_path (NM_CONNECTION (object)),
NM_DBUS_IFACE_SETTINGS_CONNECTION);
g_assert (priv->proxy);
dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT);
priv->secrets_proxy = dbus_g_proxy_new_for_name (priv->bus,
- service,
+ NM_DBUS_SERVICE,
nm_connection_get_path (NM_CONNECTION (object)),
NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS);
g_assert (priv->secrets_proxy);
@@ -339,9 +362,9 @@ constructor (GType type,
dbus_g_proxy_add_signal (priv->proxy, "Removed", G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, "Removed", G_CALLBACK (removed_cb), object, NULL);
- org_freedesktop_NetworkManagerSettings_Connection_get_settings_async (priv->proxy,
- get_settings_cb,
- object);
+ org_freedesktop_NetworkManager_Settings_Connection_get_settings_async (priv->proxy,
+ get_settings_cb,
+ object);
return object;
}
@@ -435,5 +458,24 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class)
NM_REMOTE_CONNECTION_INIT_RESULT_ERROR,
NM_REMOTE_CONNECTION_INIT_RESULT_UNKNOWN,
G_PARAM_READABLE));
-}
+ /* Signals */
+ signals[UPDATED] =
+ g_signal_new (NM_REMOTE_CONNECTION_UPDATED,
+ G_TYPE_FROM_CLASS (remote_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NMRemoteConnectionClass, updated),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT);
+
+ signals[REMOVED] =
+ g_signal_new (NM_REMOTE_CONNECTION_REMOVED,
+ G_TYPE_FROM_CLASS (remote_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NMRemoteConnectionClass, removed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+}
diff --git a/libnm-glib/nm-remote-connection.h b/libnm-glib/nm-remote-connection.h
index ef5452f99f..0c627a6044 100644
--- a/libnm-glib/nm-remote-connection.h
+++ b/libnm-glib/nm-remote-connection.h
@@ -38,6 +38,9 @@ G_BEGIN_DECLS
#define NM_IS_REMOTE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_REMOTE_CONNECTION))
#define NM_REMOTE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionClass))
+#define NM_REMOTE_CONNECTION_UPDATED "updated"
+#define NM_REMOTE_CONNECTION_REMOVED "removed"
+
typedef struct {
NMConnection parent;
} NMRemoteConnection;
@@ -45,6 +48,12 @@ typedef struct {
typedef struct {
NMConnectionClass parent_class;
+ /* Signals */
+ void (*updated) (NMRemoteConnection *connection,
+ GHashTable *new_settings);
+
+ void (*removed) (NMRemoteConnection *connection);
+
/* Padding for future expansion */
void (*_reserved1) (void);
void (*_reserved2) (void);
@@ -54,11 +63,38 @@ typedef struct {
void (*_reserved6) (void);
} NMRemoteConnectionClass;
+typedef void (*NMRemoteConnectionCommitFunc) (NMRemoteConnection *connection,
+ GError *error,
+ gpointer user_data);
+
+typedef void (*NMRemoteConnectionDeleteFunc) (NMRemoteConnection *connection,
+ GError *error,
+ gpointer user_data);
+
+typedef void (*NMRemoteConnectionGetSecretsFunc) (NMRemoteConnection *connection,
+ GHashTable *secrets,
+ GError *error,
+ gpointer user_data);
+
GType nm_remote_connection_get_type (void);
NMRemoteConnection *nm_remote_connection_new (DBusGConnection *bus,
- NMConnectionScope scope,
const char *path);
+
+void nm_remote_connection_commit_changes (NMRemoteConnection *connection,
+ NMRemoteConnectionCommitFunc callback,
+ gpointer user_data);
+
+void nm_remote_connection_delete (NMRemoteConnection *connection,
+ NMRemoteConnectionDeleteFunc callback,
+ gpointer user_data);
+
+void nm_remote_connection_get_secrets (NMRemoteConnection *connection,
+ const char *setting_name,
+ const char **hints,
+ gboolean request_new,
+ NMRemoteConnectionGetSecretsFunc callback,
+ gpointer user_data);
G_END_DECLS
#endif /* __NM_REMOTE_CONNECTION__ */
diff --git a/libnm-glib/nm-remote-settings-system.c b/libnm-glib/nm-remote-settings-system.c
deleted file mode 100644
index 95098c7e60..0000000000
--- a/libnm-glib/nm-remote-settings-system.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * libnm_glib -- Access network status & information from glib applications
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright (C) 2008 Novell, Inc.
- * Copyright (C) 2009 - 2010 Red Hat, Inc.
- */
-
-#include <string.h>
-#include <NetworkManager.h>
-#include <nm-connection.h>
-
-#include "nm-marshal.h"
-#include "nm-dbus-glib-types.h"
-#include "nm-remote-settings-system.h"
-#include "nm-settings-system-bindings.h"
-#include "nm-settings-system-interface.h"
-
-static void settings_system_interface_init (NMSettingsSystemInterface *klass);
-
-G_DEFINE_TYPE_EXTENDED (NMRemoteSettingsSystem, nm_remote_settings_system, NM_TYPE_REMOTE_SETTINGS, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_SYSTEM_INTERFACE, settings_system_interface_init))
-
-#define NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_SETTINGS_SYSTEM, NMRemoteSettingsSystemPrivate))
-
-typedef struct {
- DBusGProxy *proxy;
- DBusGProxy *props_proxy;
-
- char *hostname;
- gboolean can_modify;
-
- NMSettingsSystemPermissions permissions;
- gboolean have_permissions;
-
- gboolean disposed;
-} NMRemoteSettingsSystemPrivate;
-
-static void
-properties_changed_cb (DBusGProxy *proxy,
- GHashTable *properties,
- gpointer user_data)
-{
- NMRemoteSettingsSystem *self = NM_REMOTE_SETTINGS_SYSTEM (user_data);
- NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (self);
- GHashTableIter iter;
- gpointer key, tmp;
-
- g_hash_table_iter_init (&iter, properties);
- while (g_hash_table_iter_next (&iter, &key, &tmp)) {
- GValue *value = tmp;
-
- if (!strcmp ((const char *) key, "Hostname")) {
- g_free (priv->hostname);
- priv->hostname = g_value_dup_string (value);
- g_object_notify (G_OBJECT (self), NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME);
- }
-
- if (!strcmp ((const char *) key, "CanModify")) {
- priv->can_modify = g_value_get_boolean (value);
- g_object_notify (G_OBJECT (self), NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY);
- }
- }
-}
-
-static void
-get_all_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- NMRemoteSettingsSystem *self = NM_REMOTE_SETTINGS_SYSTEM (user_data);
- GHashTable *props = NULL;
- GError *error = NULL;
-
- if (!dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_MAP_OF_VARIANT, &props,
- G_TYPE_INVALID)) {
- /* Don't warn when the call times out because the settings service can't
- * be activated or whatever.
- */
- if (!(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_NO_REPLY)) {
- g_warning ("%s: couldn't retrieve system settings properties: (%d) %s.",
- __func__,
- error ? error->code : -1,
- (error && error->message) ? error->message : "(unknown)");
- }
- g_clear_error (&error);
- return;
- }
-
- properties_changed_cb (NULL, props, self);
- g_hash_table_destroy (props);
-}
-
-typedef struct {
- NMSettingsSystemInterface *settings;
- NMSettingsSystemSaveHostnameFunc callback;
- gpointer callback_data;
-} SaveHostnameInfo;
-
-static void
-save_hostname_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- SaveHostnameInfo *info = user_data;
- GError *error = NULL;
-
- dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
- info->callback (info->settings, error, info->callback_data);
- g_clear_error (&error);
-}
-
-static gboolean
-save_hostname (NMSettingsSystemInterface *settings,
- const char *hostname,
- NMSettingsSystemSaveHostnameFunc callback,
- gpointer user_data)
-{
- NMRemoteSettingsSystem *self = NM_REMOTE_SETTINGS_SYSTEM (settings);
- NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (self);
- SaveHostnameInfo *info;
-
- info = g_malloc0 (sizeof (SaveHostnameInfo));
- info->settings = settings;
- info->callback = callback;
- info->callback_data = user_data;
-
- dbus_g_proxy_begin_call (priv->proxy, "SaveHostname",
- save_hostname_cb,
- info,
- g_free,
- G_TYPE_STRING, hostname ? hostname : "",
- G_TYPE_INVALID);
- return TRUE;
-}
-
-typedef struct {
- NMSettingsSystemInterface *settings;
- NMSettingsSystemGetPermissionsFunc callback;
- gpointer callback_data;
-} GetPermissionsInfo;
-
-static void
-get_permissions_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- GetPermissionsInfo *info = user_data;
- NMRemoteSettingsSystem *self = NM_REMOTE_SETTINGS_SYSTEM (info->settings);
- NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (self);
- NMSettingsSystemPermissions permissions = NM_SETTINGS_SYSTEM_PERMISSION_NONE;
- GError *error = NULL;
-
- dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_UINT, &permissions,
- G_TYPE_INVALID);
- priv->permissions = permissions;
- priv->have_permissions = !error;
- info->callback (info->settings, permissions, error, info->callback_data);
- g_clear_error (&error);
-}
-
-static gboolean
-get_permissions (NMSettingsSystemInterface *settings,
- NMSettingsSystemGetPermissionsFunc callback,
- gpointer user_data)
-{
- NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (settings);
- GetPermissionsInfo *info;
-
- /* Skip D-Bus if we already have permissions */
- if (priv->have_permissions) {
- callback (settings, priv->permissions, NULL, user_data);
- return TRUE;
- }
-
- /* Otherwise fetch them from NM */
- info = g_malloc0 (sizeof (GetPermissionsInfo));
- info->settings = settings;
- info->callback = callback;
- info->callback_data = user_data;
-
- dbus_g_proxy_begin_call (priv->proxy, "GetPermissions",
- get_permissions_cb,
- info,
- g_free,
- G_TYPE_INVALID);
- return TRUE;
-}
-
-static void
-check_permissions_cb (DBusGProxy *proxy, gpointer user_data)
-{
- NMRemoteSettingsSystem *self = NM_REMOTE_SETTINGS_SYSTEM (user_data);
- NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (self);
-
- /* Permissions need to be re-fetched */
- priv->have_permissions = FALSE;
- g_signal_emit_by_name (self, NM_SETTINGS_SYSTEM_INTERFACE_CHECK_PERMISSIONS);
-}
-
-/****************************************************************/
-
-static void
-settings_system_interface_init (NMSettingsSystemInterface *klass)
-{
- /* interface implementation */
- klass->save_hostname = save_hostname;
- klass->get_permissions = get_permissions;
-}
-
-/**
- * nm_remote_settings_system_new:
- * @bus: a valid and connected D-Bus connection
- *
- * Creates a new object representing the remote system settings service.
- *
- * Returns: the new remote system settings object on success, or %NULL on failure
- **/
-NMRemoteSettingsSystem *
-nm_remote_settings_system_new (DBusGConnection *bus)
-{
- g_return_val_if_fail (bus != NULL, NULL);
-
- return (NMRemoteSettingsSystem *) g_object_new (NM_TYPE_REMOTE_SETTINGS_SYSTEM,
- NM_REMOTE_SETTINGS_BUS, bus,
- NM_REMOTE_SETTINGS_SCOPE, NM_CONNECTION_SCOPE_SYSTEM,
- NULL);
-}
-
-static void
-nm_remote_settings_system_init (NMRemoteSettingsSystem *self)
-{
-}
-
-static GObject *
-constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *object;
- NMRemoteSettingsSystemPrivate *priv;
- DBusGConnection *bus = NULL;
-
- object = G_OBJECT_CLASS (nm_remote_settings_system_parent_class)->constructor (type, n_construct_params, construct_params);
- if (!object)
- return NULL;
-
- priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (object);
-
- g_object_get (G_OBJECT (object), NM_REMOTE_SETTINGS_BUS, &bus, NULL);
- g_assert (bus);
-
- /* D-Bus properties proxy */
- priv->props_proxy = dbus_g_proxy_new_for_name (bus,
- NM_DBUS_SERVICE_SYSTEM_SETTINGS,
- NM_DBUS_PATH_SETTINGS,
- "org.freedesktop.DBus.Properties");
- g_assert (priv->props_proxy);
-
- /* System settings proxy */
- priv->proxy = dbus_g_proxy_new_for_name (bus,
- NM_DBUS_SERVICE_SYSTEM_SETTINGS,
- NM_DBUS_PATH_SETTINGS,
- NM_DBUS_IFACE_SETTINGS_SYSTEM);
- g_assert (priv->proxy);
- dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT);
-
- dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE,
- DBUS_TYPE_G_MAP_OF_VARIANT,
- G_TYPE_INVALID);
- dbus_g_proxy_add_signal (priv->proxy, "PropertiesChanged",
- DBUS_TYPE_G_MAP_OF_VARIANT,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->proxy, "PropertiesChanged",
- G_CALLBACK (properties_changed_cb),
- object,
- NULL);
-
- /* Monitor for permissions changes */
- dbus_g_proxy_add_signal (priv->proxy, "CheckPermissions", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->proxy, "CheckPermissions",
- G_CALLBACK (check_permissions_cb),
- object,
- NULL);
-
- /* Get properties */
- dbus_g_proxy_begin_call (priv->props_proxy, "GetAll",
- get_all_cb,
- object,
- NULL,
- G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS_SYSTEM,
- G_TYPE_INVALID);
-
- dbus_g_connection_unref (bus);
-
- return object;
-}
-
-static void
-dispose (GObject *object)
-{
- NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (object);
-
- if (priv->disposed)
- return;
-
- priv->disposed = TRUE;
-
- g_free (priv->hostname);
-
- g_object_unref (priv->props_proxy);
- g_object_unref (priv->proxy);
-
- G_OBJECT_CLASS (nm_remote_settings_system_parent_class)->dispose (object);
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMRemoteSettingsSystemPrivate *priv = NM_REMOTE_SETTINGS_SYSTEM_GET_PRIVATE (object);
-
- switch (prop_id) {
- case NM_SETTINGS_SYSTEM_INTERFACE_PROP_HOSTNAME:
- g_value_set_string (value, priv->hostname);
- break;
- case NM_SETTINGS_SYSTEM_INTERFACE_PROP_CAN_MODIFY:
- g_value_set_boolean (value, priv->can_modify);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-nm_remote_settings_system_class_init (NMRemoteSettingsSystemClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (NMRemoteSettingsSystemPrivate));
-
- /* Virtual methods */
- object_class->constructor = constructor;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
-
- /* Properties */
- g_object_class_override_property (object_class,
- NM_SETTINGS_SYSTEM_INTERFACE_PROP_HOSTNAME,
- NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME);
-
- g_object_class_override_property (object_class,
- NM_SETTINGS_SYSTEM_INTERFACE_PROP_CAN_MODIFY,
- NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY);
-}
-
diff --git a/libnm-glib/nm-remote-settings-system.h b/libnm-glib/nm-remote-settings-system.h
deleted file mode 100644
index b518227331..0000000000
--- a/libnm-glib/nm-remote-settings-system.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * libnm_glib -- Access network status & information from glib applications
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright (C) 2008 Novell, Inc.
- * Copyright (C) 2009 Red Hat, Inc.
- */
-
-#ifndef NM_REMOTE_SETTINGS_SYSTEM_H
-#define NM_REMOTE_SETTINGS_SYSTEM_H
-
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-
-#include "nm-remote-settings.h"
-#include "nm-settings-system-interface.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_REMOTE_SETTINGS_SYSTEM (nm_remote_settings_system_get_type ())
-#define NM_REMOTE_SETTINGS_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_REMOTE_SETTINGS_SYSTEM, NMRemoteSettingsSystem))
-#define NM_REMOTE_SETTINGS_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_REMOTE_SETTINGS_SYSTEM, NMRemoteSettingsSystemClass))
-#define NM_IS_REMOTE_SETTINGS_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_REMOTE_SETTINGS_SYSTEM))
-#define NM_IS_REMOTE_SETTINGS_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_REMOTE_SETTINGS_SYSTEM))
-#define NM_REMOTE_SETTINGS_SYSTEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_SETTINGS_SYSTEM, NMRemoteSettingsSystemClass))
-
-typedef struct {
- NMRemoteSettings parent;
-} NMRemoteSettingsSystem;
-
-typedef struct {
- NMRemoteSettingsClass parent;
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMRemoteSettingsSystemClass;
-
-GType nm_remote_settings_system_get_type (void);
-
-NMRemoteSettingsSystem *nm_remote_settings_system_new (DBusGConnection *bus);
-
-G_END_DECLS
-
-#endif /* NM_REMOTE_SETTINGS_SYSTEM_H */
diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c
index 6a9a1d71e9..f263df29fa 100644
--- a/libnm-glib/nm-remote-settings.c
+++ b/libnm-glib/nm-remote-settings.c
@@ -26,26 +26,26 @@
#include <nm-connection.h>
#include "nm-marshal.h"
+#include "nm-dbus-glib-types.h"
#include "nm-remote-settings.h"
#include "nm-settings-bindings.h"
-#include "nm-settings-interface.h"
#include "nm-remote-connection-private.h"
-static void settings_interface_init (NMSettingsInterface *class);
-
-G_DEFINE_TYPE_EXTENDED (NMRemoteSettings, nm_remote_settings, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_INTERFACE, settings_interface_init))
+G_DEFINE_TYPE (NMRemoteSettings, nm_remote_settings, G_TYPE_OBJECT)
#define NM_REMOTE_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsPrivate))
typedef struct {
DBusGConnection *bus;
- NMConnectionScope scope;
DBusGProxy *proxy;
GHashTable *connections;
GHashTable *pending; /* Connections we don't have settings for yet */
gboolean service_running;
+
+ DBusGProxy *props_proxy;
+ char *hostname;
+ gboolean can_modify;
DBusGProxy *dbus_proxy;
@@ -57,15 +57,39 @@ typedef struct {
enum {
PROP_0,
PROP_BUS,
- PROP_SCOPE,
PROP_SERVICE_RUNNING,
+ PROP_HOSTNAME,
+ PROP_CAN_MODIFY,
LAST_PROP
};
-static NMSettingsConnectionInterface *
-get_connection_by_path (NMSettingsInterface *settings, const char *path)
+/* Signals */
+enum {
+ NEW_CONNECTION,
+ CONNECTIONS_READ,
+
+ LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL] = { 0 };
+
+/**
+ * nm_remote_settings_get_connection_by_path:
+ * @settings: the %NMRemoteSettings
+ * @path: the D-Bus object path of the remote connection
+ *
+ * Returns the %NMRemoteConnection representing the connection at @path.
+ *
+ * Returns: the remote connection object on success, or NULL if the object was
+ * not known
+ **/
+NMRemoteConnection *
+nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings, const char *path)
{
+ g_return_val_if_fail (settings != NULL, NULL);
+ g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
+ g_return_val_if_fail (path != NULL, NULL);
+
return g_hash_table_lookup (NM_REMOTE_SETTINGS_GET_PRIVATE (settings)->connections, path);
}
@@ -116,7 +140,7 @@ connection_init_result_cb (NMRemoteConnection *remote,
/* Finally, let users know of the new connection now that it has all
* its settings and is valid.
*/
- g_signal_emit_by_name (self, "new-connection", remote);
+ g_signal_emit (self, signals[NEW_CONNECTION], 0, remote);
break;
case NM_REMOTE_CONNECTION_INIT_RESULT_ERROR:
default:
@@ -127,7 +151,7 @@ connection_init_result_cb (NMRemoteConnection *remote,
/* Let listeners know that all connections have been found */
if (!g_hash_table_size (priv->pending))
- g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_CONNECTIONS_READ);
+ g_signal_emit (self, signals[CONNECTIONS_READ], 0);
}
static void
@@ -137,7 +161,7 @@ new_connection_cb (DBusGProxy *proxy, const char *path, gpointer user_data)
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
NMRemoteConnection *connection;
- connection = nm_remote_connection_new (priv->bus, priv->scope, path);
+ connection = nm_remote_connection_new (priv->bus, path);
if (connection) {
g_signal_connect (connection, "removed",
G_CALLBACK (connection_removed_cb),
@@ -162,36 +186,27 @@ fetch_connections_done (DBusGProxy *proxy,
gpointer user_data)
{
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
int i;
if (error) {
- gboolean is_spawn_error = FALSE;
-
- /* Don't warn if the user settings service wasn't running since that's
- * just annoying when running headless.
- */
- if ( g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN)
- || g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NAME_HAS_NO_OWNER))
- is_spawn_error = TRUE;
-
- if (!is_spawn_error || priv->scope == NM_CONNECTION_SCOPE_SYSTEM) {
- g_warning ("%s: error fetching %s connections: (%d) %s.",
- __func__,
- priv->scope == NM_CONNECTION_SCOPE_USER ? "user" : "system",
+ /* Ignore settings service spawn errors */
+ if ( !g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN)
+ && !g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NAME_HAS_NO_OWNER)) {
+ g_warning ("%s: error fetching connections: (%d) %s.",
+ __func__,
error->code,
error->message ? error->message : "(unknown)");
}
g_clear_error (&error);
/* We tried to read connections and failed */
- g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_CONNECTIONS_READ);
+ g_signal_emit (self, signals[CONNECTIONS_READ], 0);
return;
}
/* Let listeners know we are done getting connections */
if (connections->len == 0) {
- g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_CONNECTIONS_READ);
+ g_signal_emit (self, signals[CONNECTIONS_READ], 0);
return;
}
@@ -212,20 +227,32 @@ fetch_connections (gpointer user_data)
priv->fetch_id = 0;
- org_freedesktop_NetworkManagerSettings_list_connections_async (priv->proxy,
- fetch_connections_done,
- self);
+ org_freedesktop_NetworkManager_Settings_list_connections_async (priv->proxy,
+ fetch_connections_done,
+ self);
return FALSE;
}
-static GSList *
-list_connections (NMSettingsInterface *settings)
+/**
+ * nm_remote_settings_list_connections:
+ * @settings: the %NMRemoteSettings
+ *
+ * Returns: all connections in the remote settings service, represented as
+ * %NMRemoteConnection instances
+ **/
+GSList *
+nm_remote_settings_list_connections (NMRemoteSettings *settings)
{
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
+ NMRemoteSettingsPrivate *priv;
GSList *list = NULL;
GHashTableIter iter;
gpointer value;
+ g_return_val_if_fail (settings != NULL, NULL);
+ g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL);
+
+ priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
+
g_hash_table_iter_init (&iter, priv->connections);
while (g_hash_table_iter_next (&iter, NULL, &value))
list = g_slist_prepend (list, NM_REMOTE_CONNECTION (value));
@@ -234,8 +261,8 @@ list_connections (NMSettingsInterface *settings)
}
typedef struct {
- NMSettingsInterface *self;
- NMSettingsAddConnectionFunc callback;
+ NMRemoteSettings *self;
+ NMRemoteSettingsAddConnectionFunc callback;
gpointer callback_data;
} AddConnectionInfo;
@@ -249,28 +276,47 @@ add_connection_done (DBusGProxy *proxy,
info->callback (info->self, error, info->callback_data);
g_free (info);
}
-
-static gboolean
-add_connection (NMSettingsInterface *settings,
- NMConnection *connection,
- NMSettingsAddConnectionFunc callback,
- gpointer user_data)
+/**
+ * nm_remote_settings_add_connection:
+ * @settings: the %NMRemoteSettings
+ * @connection: the connection to add. Note that this object's settings will be
+ * added, not the object itself
+ * @callback: callback to be called when the add operation completes
+ * @user_data: caller-specific data passed to @callback
+ *
+ * Requests that the remote settings service add the given settings to a new
+ * connection.
+ *
+ * Returns: TRUE if the request was successful, FALSE if it failed
+ **/
+gboolean
+nm_remote_settings_add_connection (NMRemoteSettings *settings,
+ NMConnection *connection,
+ NMRemoteSettingsAddConnectionFunc callback,
+ gpointer user_data)
{
- NMRemoteSettings *self = NM_REMOTE_SETTINGS (settings);
- NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
+ NMRemoteSettingsPrivate *priv;
AddConnectionInfo *info;
GHashTable *new_settings;
+ g_return_val_if_fail (settings != NULL, FALSE);
+ g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
+ g_return_val_if_fail (connection != NULL, FALSE);
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
+ g_return_val_if_fail (callback != NULL, FALSE);
+
+ priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
+
info = g_malloc0 (sizeof (AddConnectionInfo));
info->self = settings;
info->callback = callback;
info->callback_data = user_data;
new_settings = nm_connection_to_hash (connection);
- org_freedesktop_NetworkManagerSettings_add_connection_async (priv->proxy,
- new_settings,
- add_connection_done,
- info);
+ org_freedesktop_NetworkManager_Settings_add_connection_async (priv->proxy,
+ new_settings,
+ add_connection_done,
+ info);
g_hash_table_destroy (new_settings);
return TRUE;
}
@@ -301,6 +347,68 @@ remove_connections (gpointer user_data)
return FALSE;
}
+typedef struct {
+ NMRemoteSettings *settings;
+ NMRemoteSettingsSaveHostnameFunc callback;
+ gpointer callback_data;
+} SaveHostnameInfo;
+
+static void
+save_hostname_cb (DBusGProxy *proxy,
+ DBusGProxyCall *call,
+ gpointer user_data)
+{
+ SaveHostnameInfo *info = user_data;
+ GError *error = NULL;
+
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ info->callback (info->settings, error, info->callback_data);
+ g_clear_error (&error);
+}
+
+/**
+ * nm_remote_settings_save_hostname:
+ * @settings: the %NMRemoteSettings
+ * @hostname: the new persistent hostname to set, or NULL to clear any existing
+ * persistent hostname
+ * @callback: callback to be called when the hostname operation completes
+ * @user_data: caller-specific data passed to @callback
+ *
+ * Requests that the machine's persistent hostname be set to the specified value
+ * or cleared.
+ *
+ * Returns: TRUE if the request was successful, FALSE if it failed
+ **/
+gboolean
+nm_remote_settings_save_hostname (NMRemoteSettings *settings,
+ const char *hostname,
+ NMRemoteSettingsSaveHostnameFunc callback,
+ gpointer user_data)
+{
+ NMRemoteSettingsPrivate *priv;
+ SaveHostnameInfo *info;
+
+ g_return_val_if_fail (settings != NULL, FALSE);
+ g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
+ g_return_val_if_fail (hostname != NULL, FALSE);
+ g_return_val_if_fail (callback != NULL, FALSE);
+
+ priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
+
+ info = g_malloc0 (sizeof (SaveHostnameInfo));
+ info->settings = settings;
+ info->callback = callback;
+ info->callback_data = user_data;
+
+ dbus_g_proxy_begin_call (priv->proxy, "SaveHostname",
+ save_hostname_cb,
+ info,
+ g_free,
+ G_TYPE_STRING, hostname ? hostname : "",
+ G_TYPE_INVALID);
+ return TRUE;
+}
+
static void
name_owner_changed (DBusGProxy *proxy,
const char *name,
@@ -310,10 +418,7 @@ name_owner_changed (DBusGProxy *proxy,
{
NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
- const char *sname = NM_DBUS_SERVICE_USER_SETTINGS;
-
- if (priv->scope == NM_CONNECTION_SCOPE_SYSTEM)
- sname = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
+ const char *sname = NM_DBUS_SERVICE;
if (!strcmp (name, sname)) {
if (priv->fetch_id)
@@ -330,35 +435,79 @@ name_owner_changed (DBusGProxy *proxy,
}
}
-/****************************************************************/
+static void
+properties_changed_cb (DBusGProxy *proxy,
+ GHashTable *properties,
+ gpointer user_data)
+{
+ NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
+ NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
+ GHashTableIter iter;
+ gpointer key, tmp;
+
+ g_hash_table_iter_init (&iter, properties);
+ while (g_hash_table_iter_next (&iter, &key, &tmp)) {
+ GValue *value = tmp;
+
+ if (!strcmp ((const char *) key, "Hostname")) {
+ g_free (priv->hostname);
+ priv->hostname = g_value_dup_string (value);
+ g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_HOSTNAME);
+ }
+
+ if (!strcmp ((const char *) key, "CanModify")) {
+ priv->can_modify = g_value_get_boolean (value);
+ g_object_notify (G_OBJECT (self), NM_REMOTE_SETTINGS_CAN_MODIFY);
+ }
+ }
+}
static void
-settings_interface_init (NMSettingsInterface *iface)
+get_all_cb (DBusGProxy *proxy,
+ DBusGProxyCall *call,
+ gpointer user_data)
{
- /* interface implementation */
- iface->list_connections = list_connections;
- iface->get_connection_by_path = get_connection_by_path;
- iface->add_connection = add_connection;
+ NMRemoteSettings *self = NM_REMOTE_SETTINGS (user_data);
+ GHashTable *props = NULL;
+ GError *error = NULL;
+
+ if (!dbus_g_proxy_end_call (proxy, call, &error,
+ DBUS_TYPE_G_MAP_OF_VARIANT, &props,
+ G_TYPE_INVALID)) {
+ /* Don't warn when the call times out because the settings service can't
+ * be activated or whatever.
+ */
+ if (!(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_NO_REPLY)) {
+ g_warning ("%s: couldn't retrieve system settings properties: (%d) %s.",
+ __func__,
+ error ? error->code : -1,
+ (error && error->message) ? error->message : "(unknown)");
+ }
+ g_clear_error (&error);
+ return;
+ }
+
+ properties_changed_cb (NULL, props, self);
+ g_hash_table_destroy (props);
}
+/****************************************************************/
+
/**
* nm_remote_settings_new:
* @bus: a valid and connected D-Bus connection
- * @scope: the settings service scope (either user or system)
*
* Creates a new object representing the remote settings service.
*
* Returns: the new remote settings object on success, or %NULL on failure
**/
NMRemoteSettings *
-nm_remote_settings_new (DBusGConnection *bus, NMConnectionScope scope)
+nm_remote_settings_new (DBusGConnection *bus)
{
g_return_val_if_fail (bus != NULL, NULL);
- g_return_val_if_fail (scope != NM_CONNECTION_SCOPE_UNKNOWN, NULL);
return (NMRemoteSettings *) g_object_new (NM_TYPE_REMOTE_SETTINGS,
NM_REMOTE_SETTINGS_BUS, bus,
- NM_REMOTE_SETTINGS_SCOPE, scope,
NULL);
}
@@ -378,7 +527,6 @@ constructor (GType type,
{
GObject *object;
NMRemoteSettingsPrivate *priv;
- const char *service = NM_DBUS_SERVICE_USER_SETTINGS;
GError *error = NULL;
object = G_OBJECT_CLASS (nm_remote_settings_parent_class)->constructor (type, n_construct_params, construct_params);
@@ -406,12 +554,8 @@ constructor (GType type,
G_CALLBACK (name_owner_changed),
object, NULL);
- /* Settings service proxy */
- if (priv->scope == NM_CONNECTION_SCOPE_SYSTEM)
- service = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
-
if (!dbus_g_proxy_call (priv->dbus_proxy, "NameHasOwner", &error,
- G_TYPE_STRING, service,
+ G_TYPE_STRING, NM_DBUS_SERVICE,
G_TYPE_INVALID,
G_TYPE_BOOLEAN, &priv->service_running,
G_TYPE_INVALID)) {
@@ -424,7 +568,7 @@ constructor (GType type,
}
priv->proxy = dbus_g_proxy_new_for_name (priv->bus,
- service,
+ NM_DBUS_SERVICE,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS);
g_assert (priv->proxy);
@@ -440,6 +584,35 @@ constructor (GType type,
priv->fetch_id = g_idle_add (fetch_connections, object);
+
+ /* D-Bus properties proxy */
+ priv->props_proxy = dbus_g_proxy_new_for_name (priv->bus,
+ NM_DBUS_SERVICE,
+ NM_DBUS_PATH_SETTINGS,
+ "org.freedesktop.DBus.Properties");
+ g_assert (priv->props_proxy);
+
+ /* Monitor properties */
+ dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE,
+ DBUS_TYPE_G_MAP_OF_VARIANT,
+ G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (priv->proxy, "PropertiesChanged",
+ DBUS_TYPE_G_MAP_OF_VARIANT,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (priv->proxy, "PropertiesChanged",
+ G_CALLBACK (properties_changed_cb),
+ object,
+ NULL);
+
+ /* Get properties */
+ dbus_g_proxy_begin_call (priv->props_proxy, "GetAll",
+ get_all_cb,
+ object,
+ NULL,
+ G_TYPE_STRING, NM_DBUS_IFACE_SETTINGS,
+ G_TYPE_INVALID);
+
return object;
}
@@ -462,8 +635,11 @@ dispose (GObject *object)
if (priv->pending)
g_hash_table_destroy (priv->pending);
+ g_free (priv->hostname);
+
g_object_unref (priv->dbus_proxy);
g_object_unref (priv->proxy);
+ g_object_unref (priv->props_proxy);
dbus_g_connection_unref (priv->bus);
G_OBJECT_CLASS (nm_remote_settings_parent_class)->dispose (object);
@@ -480,9 +656,6 @@ set_property (GObject *object, guint prop_id,
/* Construct only */
priv->bus = dbus_g_connection_ref ((DBusGConnection *) g_value_get_boxed (value));
break;
- case PROP_SCOPE:
- priv->scope = (NMConnectionScope) g_value_get_uint (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -499,12 +672,15 @@ get_property (GObject *object, guint prop_id,
case PROP_BUS:
g_value_set_boxed (value, priv->bus);
break;
- case PROP_SCOPE:
- g_value_set_uint (value, priv->scope);
- break;
case PROP_SERVICE_RUNNING:
g_value_set_boolean (value, priv->service_running);
break;
+ case PROP_HOSTNAME:
+ g_value_set_string (value, priv->hostname);
+ break;
+ case PROP_CAN_MODIFY:
+ g_value_set_boolean (value, priv->can_modify);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -534,21 +710,46 @@ nm_remote_settings_class_init (NMRemoteSettingsClass *class)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
- (object_class, PROP_SCOPE,
- g_param_spec_uint (NM_REMOTE_SETTINGS_SCOPE,
- "Scope",
- "NMConnection scope",
- NM_CONNECTION_SCOPE_UNKNOWN,
- NM_CONNECTION_SCOPE_USER,
- NM_CONNECTION_SCOPE_USER,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
(object_class, PROP_SERVICE_RUNNING,
g_param_spec_boolean (NM_REMOTE_SETTINGS_SERVICE_RUNNING,
"Service running",
"Is service running",
FALSE,
G_PARAM_READABLE));
+
+ g_object_class_install_property
+ (object_class, PROP_HOSTNAME,
+ g_param_spec_string (NM_REMOTE_SETTINGS_HOSTNAME,
+ "Hostname",
+ "Persistent hostname",
+ NULL,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property
+ (object_class, PROP_CAN_MODIFY,
+ g_param_spec_boolean (NM_REMOTE_SETTINGS_CAN_MODIFY,
+ "CanModify",
+ "Can modify anything (hostname, connections, etc)",
+ FALSE,
+ G_PARAM_READABLE));
+
+ /* Signals */
+ signals[NEW_CONNECTION] =
+ g_signal_new (NM_REMOTE_SETTINGS_NEW_CONNECTION,
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NMRemoteSettingsClass, new_connection),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, G_TYPE_OBJECT);
+
+ signals[CONNECTIONS_READ] =
+ g_signal_new (NM_REMOTE_SETTINGS_CONNECTIONS_READ,
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NMRemoteSettingsClass, connections_read),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
diff --git a/libnm-glib/nm-remote-settings.h b/libnm-glib/nm-remote-settings.h
index d3085566ea..a1d3cee838 100644
--- a/libnm-glib/nm-remote-settings.h
+++ b/libnm-glib/nm-remote-settings.h
@@ -38,17 +38,40 @@ G_BEGIN_DECLS
#define NM_IS_REMOTE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_REMOTE_SETTINGS))
#define NM_REMOTE_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettingsClass))
-#define NM_REMOTE_SETTINGS_BUS "bus"
-#define NM_REMOTE_SETTINGS_SCOPE "scope"
+#define NM_REMOTE_SETTINGS_BUS "bus"
#define NM_REMOTE_SETTINGS_SERVICE_RUNNING "service-running"
+#define NM_REMOTE_SETTINGS_HOSTNAME "hostname"
+#define NM_REMOTE_SETTINGS_CAN_MODIFY "can-modify"
-typedef struct {
+#define NM_REMOTE_SETTINGS_NEW_CONNECTION "new-connection"
+#define NM_REMOTE_SETTINGS_CONNECTIONS_READ "connections-read"
+
+typedef struct _NMRemoteSettings NMRemoteSettings;
+typedef struct _NMRemoteSettingsClass NMRemoteSettingsClass;
+
+
+typedef void (*NMRemoteSettingsAddConnectionFunc) (NMRemoteSettings *settings,
+ GError *error,
+ gpointer user_data);
+
+typedef void (*NMRemoteSettingsSaveHostnameFunc) (NMRemoteSettings *settings,
+ GError *error,
+ gpointer user_data);
+
+
+struct _NMRemoteSettings {
GObject parent;
-} NMRemoteSettings;
+};
-typedef struct {
+struct _NMRemoteSettingsClass {
GObjectClass parent;
+ /* Signals */
+ void (*new_connection) (NMRemoteSettings *settings,
+ NMRemoteConnection *connection);
+
+ void (*connections_read) (NMRemoteSettings *settings);
+
/* Padding for future expansion */
void (*_reserved1) (void);
void (*_reserved2) (void);
@@ -56,11 +79,26 @@ typedef struct {
void (*_reserved4) (void);
void (*_reserved5) (void);
void (*_reserved6) (void);
-} NMRemoteSettingsClass;
+};
GType nm_remote_settings_get_type (void);
-NMRemoteSettings *nm_remote_settings_new (DBusGConnection *bus, NMConnectionScope scope);
+NMRemoteSettings *nm_remote_settings_new (DBusGConnection *bus);
+
+GSList * nm_remote_settings_list_connections (NMRemoteSettings *settings);
+
+NMRemoteConnection * nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings,
+ const char *path);
+
+gboolean nm_remote_settings_add_connection (NMRemoteSettings *self,
+ NMConnection *connection,
+ NMRemoteSettingsAddConnectionFunc callback,
+ gpointer user_data);
+
+gboolean nm_remote_settings_save_hostname (NMRemoteSettings *settings,
+ const char *hostname,
+ NMRemoteSettingsSaveHostnameFunc callback,
+ gpointer user_data);
G_END_DECLS
diff --git a/libnm-glib/nm-settings-connection-interface.c b/libnm-glib/nm-settings-connection-interface.c
deleted file mode 100644
index 868ad047a7..0000000000
--- a/libnm-glib/nm-settings-connection-interface.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager -- Network link manager
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright (C) 2007 - 2008 Novell, Inc.
- * Copyright (C) 2007 - 2009 Red Hat, Inc.
- */
-
-#include "nm-settings-connection-interface.h"
-#include "nm-dbus-glib-types.h"
-
-/**
- * nm_settings_connection_interface_update:
- * @connection: an object implementing #NMSettingsConnectionInterface
- * @callback: a function to be called when the update completes
- * @user_data: caller-specific data to be passed to @callback
- *
- * Update the connection with current settings and properties.
- *
- * Returns: TRUE on success, FALSE on failure
- **/
-gboolean
-nm_settings_connection_interface_update (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceUpdateFunc callback,
- gpointer user_data)
-{
- g_return_val_if_fail (connection != NULL, FALSE);
- g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection), FALSE);
- g_return_val_if_fail (callback != NULL, FALSE);
-
- if (NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->update) {
- return NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->update (connection,
- callback,
- user_data);
- }
- return FALSE;
-}
-
-/**
- * nm_settings_connection_interface_delete:
- * @connection: a objecting implementing #NMSettingsConnectionInterface
- * @callback: a function to be called when the delete completes
- * @user_data: caller-specific data to be passed to @callback
- *
- * Delete the connection.
- *
- * Returns: TRUE on success, FALSE on failure
- **/
-gboolean
-nm_settings_connection_interface_delete (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceDeleteFunc callback,
- gpointer user_data)
-{
- g_return_val_if_fail (connection != NULL, FALSE);
- g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection), FALSE);
- g_return_val_if_fail (callback != NULL, FALSE);
-
- if (NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->delete) {
- return NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->delete (connection,
- callback,
- user_data);
- }
- return FALSE;
-}
-
-/**
- * nm_settings_connection_interface_get_secrets:
- * @connection: a object implementing #NMSettingsConnectionInterface
- * @setting_name: the #NMSetting object name to get secrets for
- * @hints: #NMSetting key names to get secrets for (optional)
- * @request_new: hint that new secrets (instead of cached or stored secrets)
- * should be returned
- * @callback: a function to be called when the update completes
- * @user_data: caller-specific data to be passed to @callback
- *
- * Request the connection's secrets.
- *
- * Returns: TRUE on success, FALSE on failure
- **/
-gboolean
-nm_settings_connection_interface_get_secrets (NMSettingsConnectionInterface *connection,
- const char *setting_name,
- const char **hints,
- gboolean request_new,
- NMSettingsConnectionInterfaceGetSecretsFunc callback,
- gpointer user_data)
-{
- g_return_val_if_fail (connection != NULL, FALSE);
- g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection), FALSE);
- g_return_val_if_fail (callback != NULL, FALSE);
-
- if (NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->get_secrets) {
- return NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->get_secrets (connection,
- setting_name,
- hints,
- request_new,
- callback,
- user_data);
- }
- return FALSE;
-}
-
-void
-nm_settings_connection_interface_emit_updated (NMSettingsConnectionInterface *connection)
-{
- if (NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->emit_updated)
- NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE (connection)->emit_updated (connection);
- else {
- NMConnection *tmp;
- GHashTable *settings;
-
- tmp = nm_connection_duplicate (NM_CONNECTION (connection));
- nm_connection_clear_secrets (tmp);
- settings = nm_connection_to_hash (tmp);
- g_object_unref (tmp);
-
- g_signal_emit_by_name (connection, NM_SETTINGS_CONNECTION_INTERFACE_UPDATED, settings);
- g_hash_table_destroy (settings);
- }
-}
-
-static void
-nm_settings_connection_interface_init (gpointer g_iface)
-{
- GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
-
- /* Signals */
- g_signal_new (NM_SETTINGS_CONNECTION_INTERFACE_UPDATED,
- iface_type,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMSettingsConnectionInterface, updated),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT);
-
- g_signal_new (NM_SETTINGS_CONNECTION_INTERFACE_REMOVED,
- iface_type,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMSettingsConnectionInterface, removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- initialized = TRUE;
-}
-
-GType
-nm_settings_connection_interface_get_type (void)
-{
- static GType itype = 0;
-
- if (!itype) {
- const GTypeInfo iinfo = {
- sizeof (NMSettingsConnectionInterface), /* class_size */
- nm_settings_connection_interface_init, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- itype = g_type_register_static (G_TYPE_INTERFACE,
- "NMSettingsConnectionInterface",
- &iinfo, 0);
-
- g_type_interface_add_prerequisite (itype, NM_TYPE_CONNECTION);
- }
-
- return itype;
-}
-
diff --git a/libnm-glib/nm-settings-connection-interface.h b/libnm-glib/nm-settings-connection-interface.h
deleted file mode 100644
index 7c7a198c78..0000000000
--- a/libnm-glib/nm-settings-connection-interface.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * libnm_glib -- Access network status & information from glib applications
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright (C) 2007 - 2008 Novell, Inc.
- * Copyright (C) 2007 - 2009 Red Hat, Inc.
- */
-
-#ifndef __NM_SETTINGS_CONNECTION_INTERFACE_H__
-#define __NM_SETTINGS_CONNECTION_INTERFACE_H__
-
-#include <glib-object.h>
-#include <dbus/dbus-glib.h>
-
-#include <nm-connection.h>
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTINGS_CONNECTION_INTERFACE (nm_settings_connection_interface_get_type ())
-#define NM_SETTINGS_CONNECTION_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_CONNECTION_INTERFACE, NMSettingsConnectionInterface))
-#define NM_IS_SETTINGS_CONNECTION_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_CONNECTION_INTERFACE))
-#define NM_SETTINGS_CONNECTION_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SETTINGS_CONNECTION_INTERFACE, NMSettingsConnectionInterface))
-
-#define NM_SETTINGS_CONNECTION_INTERFACE_UPDATED "updated"
-#define NM_SETTINGS_CONNECTION_INTERFACE_REMOVED "removed"
-
-typedef struct _NMSettingsConnectionInterface NMSettingsConnectionInterface;
-
-typedef void (*NMSettingsConnectionInterfaceUpdateFunc) (NMSettingsConnectionInterface *connection,
- GError *error,
- gpointer user_data);
-
-typedef void (*NMSettingsConnectionInterfaceDeleteFunc) (NMSettingsConnectionInterface *connection,
- GError *error,
- gpointer user_data);
-
-typedef void (*NMSettingsConnectionInterfaceGetSecretsFunc) (NMSettingsConnectionInterface *connection,
- GHashTable *secrets,
- GError *error,
- gpointer user_data);
-
-struct _NMSettingsConnectionInterface {
- GTypeInterface g_iface;
-
- /* Methods */
- gboolean (*update) (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceUpdateFunc callback,
- gpointer user_data);
-
- gboolean (*delete) (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceDeleteFunc callback,
- gpointer user_data);
-
- gboolean (*get_secrets) (NMSettingsConnectionInterface *connection,
- const char *setting_name,
- const char **hints,
- gboolean request_new,
- NMSettingsConnectionInterfaceGetSecretsFunc callback,
- gpointer user_data);
-
- void (*emit_updated) (NMSettingsConnectionInterface *connection);
-
- /* Signals */
- /* 'new_settings' hash should *not* contain secrets */
- void (*updated) (NMSettingsConnectionInterface *connection,
- GHashTable *new_settings);
-
- void (*removed) (NMSettingsConnectionInterface *connection);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-};
-
-GType nm_settings_connection_interface_get_type (void);
-
-gboolean nm_settings_connection_interface_update (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceUpdateFunc callback,
- gpointer user_data);
-
-gboolean nm_settings_connection_interface_delete (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceDeleteFunc callback,
- gpointer user_data);
-
-gboolean nm_settings_connection_interface_get_secrets (NMSettingsConnectionInterface *connection,
- const char *setting_name,
- const char **hints,
- gboolean request_new,
- NMSettingsConnectionInterfaceGetSecretsFunc callback,
- gpointer user_data);
-
-void nm_settings_connection_interface_emit_updated (NMSettingsConnectionInterface *connection);
-
-G_END_DECLS
-
-#endif /* __NM_SETTINGS_CONNECTION_INTERFACE_H__ */
-
diff --git a/libnm-glib/nm-settings-interface.c b/libnm-glib/nm-settings-interface.c
deleted file mode 100644
index 3bd4037a1e..0000000000
--- a/libnm-glib/nm-settings-interface.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager -- Network link manager
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright (C) 2007 - 2008 Novell, Inc.
- * Copyright (C) 2007 - 2010 Red Hat, Inc.
- */
-
-#include "nm-settings-interface.h"
-
-
-/**
- * nm_settings_interface_error_quark:
- *
- * Setting error quark.
- *
- * Returns: the setting error quark
- **/
-GQuark
-nm_settings_interface_error_quark (void)
-{
- static GQuark quark;
-
- if (G_UNLIKELY (!quark))
- quark = g_quark_from_static_string ("nm-settings-interface-error-quark");
- return quark;
-}
-
-/* This should really be standard. */
-#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
-
-GType
-nm_settings_interface_error_get_type (void)
-{
- static GType etype = 0;
-
- if (etype == 0) {
- static const GEnumValue values[] = {
- /* The connection was invalid. */
- ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION, "InvalidConnection"),
- /* The connection is read-only; modifications are not allowed. */
- ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_READ_ONLY_CONNECTION, "ReadOnlyConnection"),
- /* A bug in the settings service caused the error. */
- ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR, "InternalError"),
- /* Retrieval or request of secrets failed. */
- ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE, "SecretsUnavailable"),
- /* The request for secrets was canceled. */
- ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED, "SecretsRequestCanceled"),
- /* The request could not be completed because permission was denied. */
- ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED, "PermissionDenied"),
- /* The requested setting does not existing in this connection. */
- ENUM_ENTRY (NM_SETTINGS_INTERFACE_ERROR_INVALID_SETTING, "InvalidSetting"),
- { 0, 0, 0 },
- };
- etype = g_enum_register_static ("NMSettingsInterfaceError", values);
- }
- return etype;
-}
-
-
-/**
- * nm_settings_list_connections:
- * @settings: a object implementing %NMSettingsInterface
- *
- * Returns: all connections known to the object.
- **/
-GSList *
-nm_settings_interface_list_connections (NMSettingsInterface *settings)
-{
- g_return_val_if_fail (settings != NULL, NULL);
- g_return_val_if_fail (NM_IS_SETTINGS_INTERFACE (settings), NULL);
-
- if (NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->list_connections)
- return NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->list_connections (settings);
- return NULL;
-}
-
-/**
- * nm_settings_get_connection_by_path:
- * @settings: a object implementing %NMSettingsInterface
- * @path: the D-Bus object path of the remote connection
- *
- * Returns the object implementing %NMSettingsConnectionInterface at @path.
- *
- * Returns: the remote connection object on success, or NULL if the object was
- * not known
- **/
-NMSettingsConnectionInterface *
-nm_settings_interface_get_connection_by_path (NMSettingsInterface *settings,
- const char *path)
-{
- g_return_val_if_fail (settings != NULL, NULL);
- g_return_val_if_fail (NM_IS_SETTINGS_INTERFACE (settings), NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- if (NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->get_connection_by_path)
- return NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->get_connection_by_path (settings, path);
- return NULL;
-}
-
-/**
- * nm_settings_interface_add_connection:
- * @settings: a object implementing %NMSettingsInterface
- * @connection: the settings to add; note that this object's settings will be
- * added, not the object itself
- * @callback: callback to be called when the add operation completes
- * @user_data: caller-specific data passed to @callback
- *
- * Requests that the settings service add the given settings to a new connection.
- *
- * Returns: TRUE if the request was successful, FALSE if it failed
- **/
-gboolean
-nm_settings_interface_add_connection (NMSettingsInterface *settings,
- NMConnection *connection,
- NMSettingsAddConnectionFunc callback,
- gpointer user_data)
-{
- g_return_val_if_fail (settings != NULL, FALSE);
- g_return_val_if_fail (NM_IS_SETTINGS_INTERFACE (settings), FALSE);
- g_return_val_if_fail (connection != NULL, FALSE);
- g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
- g_return_val_if_fail (callback != NULL, FALSE);
-
- if (NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->add_connection) {
- return NM_SETTINGS_INTERFACE_GET_INTERFACE (settings)->add_connection (settings,
- connection,
- callback,
- user_data);
- }
- return FALSE;
-}
-
-/*****************************************************************/
-
-static void
-nm_settings_interface_init (gpointer g_iface)
-{
- GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
-
- /* Signals */
- g_signal_new (NM_SETTINGS_INTERFACE_NEW_CONNECTION,
- iface_type,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMSettingsInterface, new_connection),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
-
- g_signal_new (NM_SETTINGS_INTERFACE_CONNECTIONS_READ,
- iface_type,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMSettingsInterface, connections_read),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- initialized = TRUE;
-}
-
-GType
-nm_settings_interface_get_type (void)
-{
- static GType settings_interface_type = 0;
-
- if (!settings_interface_type) {
- const GTypeInfo settings_interface_info = {
- sizeof (NMSettingsInterface), /* class_size */
- nm_settings_interface_init, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- settings_interface_type = g_type_register_static (G_TYPE_INTERFACE,
- "NMSettingsInterface",
- &settings_interface_info, 0);
-
- g_type_interface_add_prerequisite (settings_interface_type, G_TYPE_OBJECT);
- }
-
- return settings_interface_type;
-}
-
diff --git a/libnm-glib/nm-settings-interface.h b/libnm-glib/nm-settings-interface.h
deleted file mode 100644
index 5920bd8255..0000000000
--- a/libnm-glib/nm-settings-interface.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager -- Network link manager
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright (C) 2007 - 2008 Novell, Inc.
- * Copyright (C) 2007 - 2010 Red Hat, Inc.
- */
-
-#ifndef NM_SETTINGS_INTERFACE_H
-#define NM_SETTINGS_INTERFACE_H
-
-#include <glib-object.h>
-
-#include "NetworkManager.h"
-#include "nm-settings-connection-interface.h"
-
-G_BEGIN_DECLS
-
-typedef enum {
- NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION = 0,
- NM_SETTINGS_INTERFACE_ERROR_READ_ONLY_CONNECTION,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_SECRETS_UNAVAILABLE,
- NM_SETTINGS_INTERFACE_ERROR_SECRETS_REQUEST_CANCELED,
- NM_SETTINGS_INTERFACE_ERROR_PERMISSION_DENIED,
- NM_SETTINGS_INTERFACE_ERROR_INVALID_SETTING,
-} NMSettingsInterfaceError;
-
-#define NM_SETTINGS_INTERFACE_ERROR (nm_settings_interface_error_quark ())
-GQuark nm_settings_interface_error_quark (void);
-
-#define NM_TYPE_SETTINGS_INTERFACE_ERROR (nm_settings_interface_error_get_type ())
-GType nm_settings_interface_error_get_type (void);
-
-
-#define NM_TYPE_SETTINGS_INTERFACE (nm_settings_interface_get_type ())
-#define NM_SETTINGS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_INTERFACE, NMSettingsInterface))
-#define NM_IS_SETTINGS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_INTERFACE))
-#define NM_SETTINGS_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SETTINGS_INTERFACE, NMSettingsInterface))
-
-#define NM_SETTINGS_INTERFACE_NEW_CONNECTION "new-connection"
-#define NM_SETTINGS_INTERFACE_CONNECTIONS_READ "connections-read"
-
-typedef struct _NMSettingsInterface NMSettingsInterface;
-
-typedef void (*NMSettingsAddConnectionFunc) (NMSettingsInterface *settings,
- GError *error,
- gpointer user_data);
-
-struct _NMSettingsInterface {
- GTypeInterface g_iface;
-
- /* Methods */
- /* Returns a list of objects implementing NMSettingsConnectionInterface */
- GSList * (*list_connections) (NMSettingsInterface *settings);
-
- NMSettingsConnectionInterface * (*get_connection_by_path) (NMSettingsInterface *settings,
- const char *path);
-
- gboolean (*add_connection) (NMSettingsInterface *settings,
- NMConnection *connection,
- NMSettingsAddConnectionFunc callback,
- gpointer user_data);
-
- /* Signals */
- void (*new_connection) (NMSettingsInterface *settings,
- NMSettingsConnectionInterface *connection);
-
- void (*connections_read) (NMSettingsInterface *settings);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-};
-
-GType nm_settings_interface_get_type (void);
-
-/* Returns a list of objects implementing NMSettingsConnectionInterface */
-GSList *nm_settings_interface_list_connections (NMSettingsInterface *settings);
-
-NMSettingsConnectionInterface *nm_settings_interface_get_connection_by_path (NMSettingsInterface *settings,
- const char *path);
-
-gboolean nm_settings_interface_add_connection (NMSettingsInterface *settings,
- NMConnection *connection,
- NMSettingsAddConnectionFunc callback,
- gpointer user_data);
-
-G_END_DECLS
-
-#endif /* NM_SETTINGS_INTERFACE_H */
diff --git a/libnm-glib/nm-settings-service.c b/libnm-glib/nm-settings-service.c
deleted file mode 100644
index 6266d10dac..0000000000
--- a/libnm-glib/nm-settings-service.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager system settings service
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * (C) Copyright 2008 Novell, Inc.
- * (C) Copyright 2008 - 2009 Red Hat, Inc.
- */
-
-#include <string.h>
-#include <NetworkManager.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "nm-settings-service.h"
-#include "nm-settings-interface.h"
-#include "nm-exported-connection.h"
-
-static gboolean impl_settings_list_connections (NMSettingsService *self,
- GPtrArray **connections,
- GError **error);
-
-static void impl_settings_add_connection (NMSettingsService *self,
- GHashTable *settings,
- DBusGMethodInvocation *context);
-
-#include "nm-settings-glue.h"
-
-static void settings_interface_init (NMSettingsInterface *class);
-
-G_DEFINE_TYPE_EXTENDED (NMSettingsService, nm_settings_service, G_TYPE_OBJECT, G_TYPE_FLAG_ABSTRACT,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_INTERFACE, settings_interface_init))
-
-#define NM_SETTINGS_SERVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- NM_TYPE_SETTINGS_SERVICE, \
- NMSettingsServicePrivate))
-
-typedef struct {
- DBusGConnection *bus;
- NMConnectionScope scope;
- gboolean exported;
-
- gboolean disposed;
-} NMSettingsServicePrivate;
-
-enum {
- PROP_0,
- PROP_BUS,
- PROP_SCOPE,
-
- LAST_PROP
-};
-
-
-/**************************************************************/
-
-void
-nm_settings_service_export (NMSettingsService *self)
-{
- NMSettingsServicePrivate *priv;
-
- g_return_if_fail (self != NULL);
- g_return_if_fail (NM_IS_SETTINGS_SERVICE (self));
-
- priv = NM_SETTINGS_SERVICE_GET_PRIVATE (self);
-
- g_return_if_fail (priv->bus != NULL);
-
- /* Don't allow exporting twice */
- g_return_if_fail (priv->exported == FALSE);
-
- dbus_g_connection_register_g_object (priv->bus,
- NM_DBUS_PATH_SETTINGS,
- G_OBJECT (self));
- priv->exported = TRUE;
-}
-
-/**************************************************************/
-
-static GSList *
-list_connections (NMSettingsInterface *settings)
-{
- /* Must always be implemented */
- g_assert (NM_SETTINGS_SERVICE_GET_CLASS (settings)->list_connections);
- return NM_SETTINGS_SERVICE_GET_CLASS (settings)->list_connections (NM_SETTINGS_SERVICE (settings));
-}
-
-static gboolean
-impl_settings_list_connections (NMSettingsService *self,
- GPtrArray **connections,
- GError **error)
-{
- GSList *list = NULL, *iter;
-
- list = list_connections (NM_SETTINGS_INTERFACE (self));
- *connections = g_ptr_array_sized_new (g_slist_length (list) + 1);
- for (iter = list; iter; iter = g_slist_next (iter)) {
- g_ptr_array_add (*connections,
- g_strdup (nm_connection_get_path (NM_CONNECTION (iter->data))));
- }
- g_slist_free (list);
- return TRUE;
-}
-
-static NMSettingsConnectionInterface *
-get_connection_by_path (NMSettingsInterface *settings, const char *path)
-{
- NMExportedConnection *connection = NULL;
- GSList *list = NULL, *iter;
-
- list = list_connections (settings);
- for (iter = list; iter; iter = g_slist_next (iter)) {
- if (!strcmp (nm_connection_get_path (NM_CONNECTION (iter->data)), path)) {
- connection = NM_EXPORTED_CONNECTION (iter->data);
- break;
- }
- }
- g_slist_free (list);
-
- return (NMSettingsConnectionInterface *) connection;
-}
-
-NMExportedConnection *
-nm_settings_service_get_connection_by_path (NMSettingsService *self,
- const char *path)
-{
- g_return_val_if_fail (self != NULL, NULL);
- g_return_val_if_fail (NM_IS_SETTINGS_SERVICE (self), NULL);
-
- return (NMExportedConnection *) get_connection_by_path (NM_SETTINGS_INTERFACE (self), path);
-}
-
-static gboolean
-add_connection (NMSettingsInterface *settings,
- NMConnection *connection,
- NMSettingsAddConnectionFunc callback,
- gpointer user_data)
-{
- NMSettingsService *self = NM_SETTINGS_SERVICE (settings);
- GError *error = NULL;
- gboolean success = FALSE;
-
- if (NM_SETTINGS_SERVICE_GET_CLASS (self)->add_connection) {
- NM_SETTINGS_SERVICE_GET_CLASS (self)->add_connection (NM_SETTINGS_SERVICE (self),
- connection,
- NULL,
- callback,
- user_data);
- success = TRUE;
- } else {
- error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
- "%s: %s:%d add_connection() not implemented",
- __func__, __FILE__, __LINE__);
- callback (settings, error, user_data);
- g_error_free (error);
- }
-
- return success;
-}
-
-static void
-dbus_add_connection_cb (NMSettingsInterface *settings,
- GError *error,
- gpointer user_data)
-{
- DBusGMethodInvocation *context = user_data;
-
- if (error)
- dbus_g_method_return_error (context, error);
- else
- dbus_g_method_return (context);
-}
-
-static void
-impl_settings_add_connection (NMSettingsService *self,
- GHashTable *settings,
- DBusGMethodInvocation *context)
-{
- NMConnection *tmp;
- GError *error = NULL;
-
- /* Check if the settings are valid first */
- tmp = nm_connection_new_from_hash (settings, &error);
- if (!tmp) {
- g_assert (error);
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- return;
- }
-
- if (NM_SETTINGS_SERVICE_GET_CLASS (self)->add_connection) {
- NM_SETTINGS_SERVICE_GET_CLASS (self)->add_connection (NM_SETTINGS_SERVICE (self),
- tmp,
- context,
- dbus_add_connection_cb,
- context);
- } else {
- error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
- "%s: %s:%d add_connection() not implemented",
- __func__, __FILE__, __LINE__);
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- }
-
- g_object_unref (tmp);
-}
-
-void
-nm_settings_service_export_connection (NMSettingsService *self,
- NMSettingsConnectionInterface *connection)
-{
- NMSettingsServicePrivate *priv = NM_SETTINGS_SERVICE_GET_PRIVATE (self);
- static guint32 ec_counter = 0;
- char *path;
-
- g_return_if_fail (connection != NULL);
- g_return_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection));
- g_return_if_fail (priv->bus != NULL);
-
- /* Don't allow exporting twice */
- g_return_if_fail (nm_connection_get_path (NM_CONNECTION (connection)) == NULL);
-
- path = g_strdup_printf ("%s/%u", NM_DBUS_PATH_SETTINGS, ec_counter++);
- nm_connection_set_path (NM_CONNECTION (connection), path);
- nm_connection_set_scope (NM_CONNECTION (connection), priv->scope);
-
- dbus_g_connection_register_g_object (priv->bus, path, G_OBJECT (connection));
- g_free (path);
-}
-
-/**************************************************************/
-
-static void
-settings_interface_init (NMSettingsInterface *iface)
-{
- /* interface implementation */
- iface->list_connections = list_connections;
- iface->get_connection_by_path = get_connection_by_path;
- iface->add_connection = add_connection;
-
- dbus_g_object_type_install_info (G_TYPE_FROM_INTERFACE (iface),
- &dbus_glib_nm_settings_object_info);
-}
-
-static GObject *
-constructor (GType type,
- guint n_construct_params,
- GObjectConstructParam *construct_params)
-{
- GObject *object;
-
- object = G_OBJECT_CLASS (nm_settings_service_parent_class)->constructor (type, n_construct_params, construct_params);
- if (object) {
- g_assert (NM_SETTINGS_SERVICE_GET_PRIVATE (object)->scope != NM_CONNECTION_SCOPE_UNKNOWN);
- }
- return object;
-}
-
-static void
-nm_settings_service_init (NMSettingsService *self)
-{
-}
-
-static void
-set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- NMSettingsServicePrivate *priv = NM_SETTINGS_SERVICE_GET_PRIVATE (object);
- DBusGConnection *bus;
-
- switch (prop_id) {
- case PROP_BUS:
- /* Construct only */
- bus = g_value_get_boxed (value);
- if (bus)
- priv->bus = dbus_g_connection_ref (bus);
- break;
- case PROP_SCOPE:
- /* Construct only */
- priv->scope = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingsServicePrivate *priv = NM_SETTINGS_SERVICE_GET_PRIVATE (object);
-
- switch (prop_id) {
- case PROP_BUS:
- g_value_set_boxed (value, priv->bus);
- break;
- case PROP_SCOPE:
- g_value_set_uint (value, priv->scope);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-dispose (GObject *object)
-{
- NMSettingsServicePrivate *priv = NM_SETTINGS_SERVICE_GET_PRIVATE (object);
-
- if (!priv->disposed) {
- priv->disposed = TRUE;
- if (priv->bus)
- dbus_g_connection_unref (priv->bus);
- }
-
- G_OBJECT_CLASS (nm_settings_service_parent_class)->dispose (object);
-}
-
-static void
-nm_settings_service_class_init (NMSettingsServiceClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- g_type_class_add_private (class, sizeof (NMSettingsServicePrivate));
-
- /* Virtual methods */
- object_class->dispose = dispose;
- object_class->constructor = constructor;
- object_class->get_property = get_property;
- object_class->set_property = set_property;
-
- /**
- * NMSettingsService:bus:
- *
- * The %DBusGConnection which this object is exported on
- **/
- g_object_class_install_property (object_class, PROP_BUS,
- g_param_spec_boxed (NM_SETTINGS_SERVICE_BUS,
- "Bus",
- "Bus",
- DBUS_TYPE_G_CONNECTION,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- /**
- * NMSettingsService:scope:
- *
- * The capabilities of the device.
- **/
- g_object_class_install_property (object_class, PROP_SCOPE,
- g_param_spec_uint (NM_SETTINGS_SERVICE_SCOPE,
- "Scope",
- "Scope",
- NM_CONNECTION_SCOPE_SYSTEM,
- NM_CONNECTION_SCOPE_USER,
- NM_CONNECTION_SCOPE_USER,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-}
diff --git a/libnm-glib/nm-settings-service.h b/libnm-glib/nm-settings-service.h
deleted file mode 100644
index 9f4b95fcc5..0000000000
--- a/libnm-glib/nm-settings-service.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager system settings service
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * (C) Copyright 2009 Red Hat, Inc.
- */
-
-#ifndef NM_SETTINGS_SERVICE_H
-#define NM_SETTINGS_SERVICE_H
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <nm-exported-connection.h>
-#include <nm-settings-interface.h>
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_SETTINGS_SERVICE (nm_settings_service_get_type ())
-#define NM_SETTINGS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_SERVICE, NMSettingsService))
-#define NM_SETTINGS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTINGS_SERVICE, NMSettingsServiceClass))
-#define NM_IS_SETTINGS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_SERVICE))
-#define NM_IS_SETTINGS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SETTINGS_SERVICE))
-#define NM_SETTINGS_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTINGS_SERVICE, NMSettingsServiceClass))
-
-#define NM_SETTINGS_SERVICE_BUS "bus"
-#define NM_SETTINGS_SERVICE_SCOPE "scope"
-
-typedef struct {
- GObject parent;
-} NMSettingsService;
-
-typedef struct {
- GObjectClass parent;
-
- /* Returned list must contain all NMExportedConnection objects exported
- * by the settings service. The list (but not the NMExportedConnection
- * objects) will be freed by caller.
- */
- GSList * (*list_connections) (NMSettingsService *self);
-
- void (*add_connection) (NMSettingsService *self,
- NMConnection *connection,
- DBusGMethodInvocation *context, /* Only present for D-Bus calls */
- NMSettingsAddConnectionFunc callback,
- gpointer user_data);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-} NMSettingsServiceClass;
-
-GType nm_settings_service_get_type (void);
-
-NMExportedConnection *nm_settings_service_get_connection_by_path (NMSettingsService *self,
- const char *path);
-
-void nm_settings_service_export (NMSettingsService *self);
-
-void nm_settings_service_export_connection (NMSettingsService *self,
- NMSettingsConnectionInterface *exported);
-
-G_END_DECLS
-
-#endif /* NM_SETTINGS_SERVICE_H */
diff --git a/libnm-glib/nm-settings-system-interface.c b/libnm-glib/nm-settings-system-interface.c
deleted file mode 100644
index 0f59377a53..0000000000
--- a/libnm-glib/nm-settings-system-interface.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager -- Network link manager
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright (C) 2007 - 2008 Novell, Inc.
- * Copyright (C) 2007 - 2008 Red Hat, Inc.
- */
-
-#include "nm-settings-interface.h"
-#include "nm-settings-system-interface.h"
-
-
-/**
- * nm_settings_system_interface_save_hostname:
- * @settings: a object implementing %NMSettingsSystemInterface
- * @hostname: the new persistent hostname to set, or NULL to clear any existing
- * persistent hostname
- * @callback: callback to be called when the hostname operation completes
- * @user_data: caller-specific data passed to @callback
- *
- * Requests that the machine's persistent hostname be set to the specified value
- * or cleared.
- *
- * Returns: TRUE if the request was successful, FALSE if it failed
- **/
-gboolean
-nm_settings_system_interface_save_hostname (NMSettingsSystemInterface *settings,
- const char *hostname,
- NMSettingsSystemSaveHostnameFunc callback,
- gpointer user_data)
-{
- g_return_val_if_fail (settings != NULL, FALSE);
- g_return_val_if_fail (NM_IS_SETTINGS_SYSTEM_INTERFACE (settings), FALSE);
- g_return_val_if_fail (hostname != NULL, FALSE);
- g_return_val_if_fail (callback != NULL, FALSE);
-
- if (NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE (settings)->save_hostname) {
- return NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE (settings)->save_hostname (settings,
- hostname,
- callback,
- user_data);
- }
- return FALSE;
-}
-
-/**
- * nm_settings_system_interface_get_permissions:
- * @settings: a object implementing %NMSettingsSystemInterface
- * @callback: callback to be called when the permissions operation completes
- * @user_data: caller-specific data passed to @callback
- *
- * Requests an indication of the operations the caller is permitted to perform
- * including those that may require authorization.
- *
- * Returns: TRUE if the request was successful, FALSE if it failed
- **/
-gboolean
-nm_settings_system_interface_get_permissions (NMSettingsSystemInterface *settings,
- NMSettingsSystemGetPermissionsFunc callback,
- gpointer user_data)
-{
- g_return_val_if_fail (settings != NULL, FALSE);
- g_return_val_if_fail (NM_IS_SETTINGS_SYSTEM_INTERFACE (settings), FALSE);
- g_return_val_if_fail (callback != NULL, FALSE);
-
- if (NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE (settings)->get_permissions)
- return NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE (settings)->get_permissions (settings, callback, user_data);
- return FALSE;
-}
-
-static void
-nm_settings_system_interface_init (gpointer g_iface)
-{
- GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
-
- /* Properties */
- g_object_interface_install_property
- (g_iface,
- g_param_spec_string (NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME,
- "Hostname",
- "Persistent hostname",
- NULL,
- G_PARAM_READABLE));
-
- g_object_interface_install_property
- (g_iface,
- g_param_spec_boolean (NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY,
- "CanModify",
- "Can modify anything (hostname, connections, etc)",
- FALSE,
- G_PARAM_READABLE));
-
- /* Signals */
- g_signal_new (NM_SETTINGS_SYSTEM_INTERFACE_CHECK_PERMISSIONS,
- iface_type,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMSettingsSystemInterface, check_permissions),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- initialized = TRUE;
-}
-
-GType
-nm_settings_system_interface_get_type (void)
-{
- static GType itype = 0;
-
- if (!itype) {
- const GTypeInfo iinfo = {
- sizeof (NMSettingsSystemInterface), /* class_size */
- nm_settings_system_interface_init, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- itype = g_type_register_static (G_TYPE_INTERFACE,
- "NMSettingsSystemInterface",
- &iinfo, 0);
-
- g_type_interface_add_prerequisite (itype, NM_TYPE_SETTINGS_INTERFACE);
- }
-
- return itype;
-}
-
diff --git a/libnm-glib/nm-settings-system-interface.h b/libnm-glib/nm-settings-system-interface.h
deleted file mode 100644
index d016556123..0000000000
--- a/libnm-glib/nm-settings-system-interface.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager -- Network link manager
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright (C) 2007 - 2008 Novell, Inc.
- * Copyright (C) 2007 - 2009 Red Hat, Inc.
- */
-
-#ifndef NM_SETTINGS_SYSTEM_INTERFACE_H
-#define NM_SETTINGS_SYSTEM_INTERFACE_H
-
-#include <glib-object.h>
-
-#include "NetworkManager.h"
-
-G_BEGIN_DECLS
-
-typedef enum {
- NM_SETTINGS_SYSTEM_PERMISSION_NONE = 0x0,
- NM_SETTINGS_SYSTEM_PERMISSION_CONNECTION_MODIFY = 0x1,
- NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_PROTECTED = 0x2,
- NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_OPEN = 0x4,
- NM_SETTINGS_SYSTEM_PERMISSION_HOSTNAME_MODIFY = 0x8
-} NMSettingsSystemPermissions;
-
-#define NM_TYPE_SETTINGS_SYSTEM_INTERFACE (nm_settings_system_interface_get_type ())
-#define NM_SETTINGS_SYSTEM_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_SYSTEM_INTERFACE, NMSettingsSystemInterface))
-#define NM_IS_SETTINGS_SYSTEM_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_SYSTEM_INTERFACE))
-#define NM_SETTINGS_SYSTEM_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SETTINGS_SYSTEM_INTERFACE, NMSettingsSystemInterface))
-
-#define NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME "hostname"
-#define NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY "can-modify"
-
-#define NM_SETTINGS_SYSTEM_INTERFACE_CHECK_PERMISSIONS "check-permissions"
-
-typedef enum {
- NM_SETTINGS_SYSTEM_INTERFACE_PROP_FIRST = 0x1000,
-
- NM_SETTINGS_SYSTEM_INTERFACE_PROP_HOSTNAME = NM_SETTINGS_SYSTEM_INTERFACE_PROP_FIRST,
- NM_SETTINGS_SYSTEM_INTERFACE_PROP_CAN_MODIFY
-} NMSettingsSystemInterfaceProp;
-
-
-typedef struct _NMSettingsSystemInterface NMSettingsSystemInterface;
-
-
-typedef void (*NMSettingsSystemSaveHostnameFunc) (NMSettingsSystemInterface *settings,
- GError *error,
- gpointer user_data);
-
-typedef void (*NMSettingsSystemGetPermissionsFunc) (NMSettingsSystemInterface *settings,
- NMSettingsSystemPermissions permissions,
- GError *error,
- gpointer user_data);
-
-struct _NMSettingsSystemInterface {
- GTypeInterface g_iface;
-
- /* Methods */
- gboolean (*save_hostname) (NMSettingsSystemInterface *settings,
- const char *hostname,
- NMSettingsSystemSaveHostnameFunc callback,
- gpointer user_data);
-
- gboolean (*get_permissions) (NMSettingsSystemInterface *settings,
- NMSettingsSystemGetPermissionsFunc callback,
- gpointer user_data);
-
- /* Signals */
- void (*check_permissions) (NMSettingsSystemInterface *settings);
-
- /* Padding for future expansion */
- void (*_reserved1) (void);
- void (*_reserved2) (void);
- void (*_reserved3) (void);
- void (*_reserved4) (void);
- void (*_reserved5) (void);
- void (*_reserved6) (void);
-};
-
-GType nm_settings_system_interface_get_type (void);
-
-gboolean nm_settings_system_interface_save_hostname (NMSettingsSystemInterface *settings,
- const char *hostname,
- NMSettingsSystemSaveHostnameFunc callback,
- gpointer user_data);
-
-gboolean nm_settings_system_interface_get_permissions (NMSettingsSystemInterface *settings,
- NMSettingsSystemGetPermissionsFunc callback,
- gpointer user_data);
-
-G_END_DECLS
-
-#endif /* NM_SETTINGS_SYSTEM_INTERFACE_H */
diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver
index 6c2b9fc71e..8f5ddbe744 100644
--- a/libnm-util/libnm-util.ver
+++ b/libnm-util/libnm-util.ver
@@ -10,7 +10,6 @@ global:
nm_connection_error_quark;
nm_connection_for_each_setting_value;
nm_connection_get_path;
- nm_connection_get_scope;
nm_connection_get_setting;
nm_connection_get_setting_by_name;
nm_connection_get_type;
@@ -22,7 +21,6 @@ global:
nm_connection_remove_setting;
nm_connection_replace_settings;
nm_connection_set_path;
- nm_connection_set_scope;
nm_connection_to_hash;
nm_connection_update_secrets;
nm_connection_verify;
@@ -115,6 +113,8 @@ global:
nm_setting_connection_get_autoconnect;
nm_setting_connection_get_timestamp;
nm_setting_connection_get_read_only;
+ nm_setting_connection_get_num_permissions;
+ nm_setting_connection_get_permission;
nm_setting_duplicate;
nm_setting_enumerate_values;
nm_setting_error_get_type;
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
index 33790a6363..820ef3aa04 100644
--- a/libnm-util/nm-connection.c
+++ b/libnm-util/nm-connection.c
@@ -65,12 +65,6 @@
* parameters (MTU, SSID, APN, channel, rate, etc) and IP-level parameters
* (addresses, routes, addressing methods, etc).
*
- * Most connections also have a %NMConnectionScope; a connection will be
- * provided over D-Bus either by the user settings service
- * (org.freedesktop.NetworkManagerUserSettings) running in an active user
- * session, or by the system-wide system settings service
- * (org.freedesktop.NetworkManagerSystemSettings) which provides connections
- * for all users.
*/
/**
@@ -112,9 +106,6 @@ nm_connection_error_get_type (void)
typedef struct {
GHashTable *settings;
- /* Type of the connection (system or user) */
- NMConnectionScope scope;
-
/* D-Bus path of the connection, if any */
char *path;
} NMConnectionPrivate;
@@ -125,7 +116,6 @@ G_DEFINE_TYPE (NMConnection, nm_connection, G_TYPE_OBJECT)
enum {
PROP_0,
- PROP_SCOPE,
PROP_PATH,
LAST_PROP
@@ -901,43 +891,6 @@ nm_connection_dump (NMConnection *connection)
}
/**
- * nm_connection_set_scope:
- * @connection: the #NMConnection
- * @scope: the scope of the connection
- *
- * Sets the scope of the connection. This property is not serialized, and is
- * only for the reference of the caller. A connection may have no scope
- * (internal, temporary connections), "system" scope (provided by the system
- * settings service), or "user" scope, provided by a user settings service. The
- * creator of the #NMConnection object is responsible for setting the
- * connection's scope if needed. Sets the #NMConnection:scope property.
- **/
-void
-nm_connection_set_scope (NMConnection *connection, NMConnectionScope scope)
-{
- g_return_if_fail (NM_IS_CONNECTION (connection));
-
- NM_CONNECTION_GET_PRIVATE (connection)->scope = scope;
-}
-
-/**
- * nm_connection_get_scope:
- * @connection: the #NMConnection
- *
- * Returns the connection scope.
- *
- * Returns: the scope of the connection, previously set by a call to
- * nm_connection_set_scope().
- **/
-NMConnectionScope
-nm_connection_get_scope (NMConnection *connection)
-{
- g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_CONNECTION_SCOPE_UNKNOWN);
-
- return NM_CONNECTION_GET_PRIVATE (connection)->scope;
-}
-
-/**
* nm_connection_set_path:
* @connection: the #NMConnection
* @path: the D-Bus path of the connection as given by the settings service
@@ -1055,7 +1008,6 @@ nm_connection_duplicate (NMConnection *connection)
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
dup = nm_connection_new ();
- nm_connection_set_scope (dup, nm_connection_get_scope (connection));
nm_connection_set_path (dup, nm_connection_get_path (connection));
g_hash_table_foreach (NM_CONNECTION_GET_PRIVATE (connection)->settings, duplicate_cb, dup);
@@ -1092,9 +1044,6 @@ set_property (GObject *object, guint prop_id,
NMConnection *connection = NM_CONNECTION (object);
switch (prop_id) {
- case PROP_SCOPE:
- nm_connection_set_scope (connection, g_value_get_uint (value));
- break;
case PROP_PATH:
nm_connection_set_path (connection, g_value_get_string (value));
break;
@@ -1111,9 +1060,6 @@ get_property (GObject *object, guint prop_id,
NMConnection *connection = NM_CONNECTION (object);
switch (prop_id) {
- case PROP_SCOPE:
- g_value_set_uint (value, nm_connection_get_scope (connection));
- break;
case PROP_PATH:
g_value_set_string (value, nm_connection_get_path (connection));
break;
@@ -1138,23 +1084,6 @@ nm_connection_class_init (NMConnectionClass *klass)
/* Properties */
/**
- * NMConnection:scope:
- *
- * The connection's scope, used only by the calling process as a record
- * of which settings service the connection is provided by. One of the
- * NM_CONNECTION_SCOPE_* defines.
- **/
- g_object_class_install_property
- (object_class, PROP_SCOPE,
- g_param_spec_uint (NM_CONNECTION_SCOPE,
- "Scope",
- "Scope",
- NM_CONNECTION_SCOPE_UNKNOWN,
- NM_CONNECTION_SCOPE_USER,
- NM_CONNECTION_SCOPE_UNKNOWN,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- /**
* NMConnection:path:
*
* The connection's D-Bus path, used only by the calling process as a record
diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h
index 576db04984..453f9eff05 100644
--- a/libnm-util/nm-connection.h
+++ b/libnm-util/nm-connection.h
@@ -39,23 +39,6 @@ G_BEGIN_DECLS
#define NM_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_CONNECTION))
#define NM_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_CONNECTION, NMConnectionClass))
-/**
- * NMConnectionScope:
- * @NM_CONNECTION_SCOPE_UNKNOWN: scope not known or not yet set
- * @NM_CONNECTION_SCOPE_SYSTEM: connection is provided by the system settings
- * service
- * @NM_CONNECTION_SCOPE_USER: connection is provided by a user settings service
- *
- * Connection scope indicated what settings service, if any, provides the
- * connection.
- *
- **/
-typedef enum {
- NM_CONNECTION_SCOPE_UNKNOWN = 0,
- NM_CONNECTION_SCOPE_SYSTEM,
- NM_CONNECTION_SCOPE_USER
-} NMConnectionScope;
-
/**
* NMConnectionError:
@@ -79,7 +62,6 @@ GType nm_connection_error_get_type (void);
#define NM_CONNECTION_ERROR nm_connection_error_quark ()
GQuark nm_connection_error_quark (void);
-#define NM_CONNECTION_SCOPE "scope"
#define NM_CONNECTION_PATH "path"
/**
@@ -139,11 +121,6 @@ gboolean nm_connection_update_secrets (NMConnection *connection,
GHashTable *secrets,
GError **error);
-void nm_connection_set_scope (NMConnection *connection,
- NMConnectionScope scope);
-
-NMConnectionScope nm_connection_get_scope (NMConnection *connection);
-
void nm_connection_set_path (NMConnection *connection,
const char *path);
diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c
index 65f613eba9..644ed59ca8 100644
--- a/libnm-util/nm-setting-connection.c
+++ b/libnm-util/nm-setting-connection.c
@@ -19,14 +19,19 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2007 - 2008 Red Hat, Inc.
+ * (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
#include <string.h>
#include <ctype.h>
+#include "nm-utils.h"
+#include "nm-dbus-glib-types.h"
+#include "nm-param-spec-specialized.h"
#include "nm-setting-connection.h"
+#define NM_SETTINGS_CONNECTION_PERMISSION_PREFIX_USER "user:"
+
/**
* SECTION:nm-setting-connection
* @short_description: Describes general connection properties
@@ -85,6 +90,7 @@ typedef struct {
char *id;
char *uuid;
char *type;
+ GSList *permissions;
gboolean autoconnect;
guint64 timestamp;
gboolean read_only;
@@ -95,6 +101,7 @@ enum {
PROP_ID,
PROP_UUID,
PROP_TYPE,
+ PROP_PERMISSIONS,
PROP_AUTOCONNECT,
PROP_TIMESTAMP,
PROP_READ_ONLY,
@@ -162,6 +169,48 @@ nm_setting_connection_get_connection_type (NMSettingConnection *setting)
return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->type;
}
+
+/**
+ * nm_setting_connection_get_num_permissions:
+ * @setting: the #NMSettingConnection
+ *
+ * Returns the number of entires in the #NMSettingConnection:permissions
+ * property of this setting.
+ *
+ * Returns: the number of permissions entires
+ */
+guint32
+nm_setting_connection_get_num_permissions (NMSettingConnection *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), 0);
+
+ return g_slist_length (NM_SETTING_CONNECTION_GET_PRIVATE (setting)->permissions);
+}
+
+/**
+ * nm_setting_connection_get_permission:
+ * @setting: the #NMSettingConnection
+ * @index: the zero-based index of the permissions entry
+ *
+ * Retrieve one of the entries of the #NMSettingConnection:permissions property
+ * of this setting.
+ *
+ * Returns: the entry at the specified index
+ */
+const char *
+nm_setting_connection_get_permission (NMSettingConnection *setting, guint32 i)
+{
+ NMSettingConnectionPrivate *priv;
+
+ g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
+
+ priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
+
+ g_return_val_if_fail (i < g_slist_length (priv->permissions), NULL);
+
+ return (const char *) g_slist_nth_data (priv->permissions, i);
+}
+
/**
* nm_setting_connection_get_autoconnect:
* @setting: the #NMSettingConnection
@@ -235,6 +284,34 @@ validate_uuid (const char *uuid)
return TRUE;
}
+/* Check that every entry in the given permissions array is of proper form.
+ * Report a descriptive error if it's not. */
+static gboolean
+validate_permissions (GSList *permissions, GError **error)
+{
+ GSList *iter;
+
+ for (iter = permissions; iter; iter = iter->next) {
+ const char *entry = iter->data;
+ const char *usr_start = NULL;
+
+ if (!g_str_has_prefix (entry, NM_SETTINGS_CONNECTION_PERMISSION_PREFIX_USER))
+ continue;
+
+ usr_start = entry + strlen (NM_SETTINGS_CONNECTION_PERMISSION_PREFIX_USER);
+ if (!strchr (usr_start, ':')) {
+ g_set_error (error,
+ NM_SETTING_CONNECTION_ERROR,
+ NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
+ "permissions: entry '%s': two few ':' characters", entry);
+ return FALSE;
+ }
+ /* We don't (yet) care about what comes afterwards. */
+ }
+
+ return TRUE;
+}
+
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
@@ -291,6 +368,11 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
+ if (priv->permissions) {
+ if (!validate_permissions (priv->permissions, error))
+ return FALSE;
+ }
+
return TRUE;
}
@@ -308,6 +390,7 @@ finalize (GObject *object)
g_free (priv->id);
g_free (priv->uuid);
g_free (priv->type);
+ nm_utils_slist_free (priv->permissions, g_free);
G_OBJECT_CLASS (nm_setting_connection_parent_class)->finalize (object);
}
@@ -331,6 +414,10 @@ set_property (GObject *object, guint prop_id,
g_free (priv->type);
priv->type = g_value_dup_string (value);
break;
+ case PROP_PERMISSIONS:
+ nm_utils_slist_free (priv->permissions, g_free);
+ priv->permissions = g_value_dup_boxed (value);
+ break;
case PROP_AUTOCONNECT:
priv->autoconnect = g_value_get_boolean (value);
break;
@@ -362,6 +449,9 @@ get_property (GObject *object, guint prop_id,
case PROP_TYPE:
g_value_set_string (value, nm_setting_connection_get_connection_type (setting));
break;
+ case PROP_PERMISSIONS:
+ g_value_set_boxed (value, NM_SETTING_CONNECTION_GET_PRIVATE (setting)->permissions);
+ break;
case PROP_AUTOCONNECT:
g_value_set_boolean (value, nm_setting_connection_get_autoconnect (setting));
break;
@@ -465,6 +555,42 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
/**
+ * NMSettingConnection:permissions:
+ *
+ * An array of strings defining what access a given user has to this
+ * connection. If this is NULL or empty, all users are allowed to access
+ * this connection. Otherwise a user is allowed to access this connection
+ * if and only if they are in this list. Each entry is of the form
+ * "[type]:[id]:[reserved]", for example:
+ *
+ * user:dcbw:blah
+ *
+ * At this time only the 'user' [type] is allowed. Any other values are
+ * ignored and reserved for future use. [id] is the username that this
+ * permission refers to. Any [reserved] information present must be
+ * ignored and is reserved for future use.
+ */
+ g_object_class_install_property
+ (object_class, PROP_PERMISSIONS,
+ _nm_param_spec_specialized (NM_SETTING_CONNECTION_PERMISSIONS,
+ "Permissions",
+ "An array of strings defining what access a given "
+ "user has to this connection. If this is NULL or "
+ "empty, all users are allowed to access this "
+ "connection. Otherwise a user is allowed to access "
+ "this connection if and only if they are in this "
+ "array. Each entry is of the form "
+ "\"[type]:[id]:[reserved]\", for example: "
+ "\"user:dcbw:blah\" At this time only the 'user' "
+ "[type] is allowed. Any other values are ignored and "
+ "reserved for future use. [id] is the username that "
+ "this permission refers to. Any [reserved] "
+ "information (if present) must be ignored and is "
+ "reserved for future use.",
+ DBUS_TYPE_G_LIST_OF_STRING,
+ G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+
+ /**
* NMSettingConnection:autoconnect:
*
* Whether or not the connection should be automatically connected by
diff --git a/libnm-util/nm-setting-connection.h b/libnm-util/nm-setting-connection.h
index 6dedca220b..49dacb0b31 100644
--- a/libnm-util/nm-setting-connection.h
+++ b/libnm-util/nm-setting-connection.h
@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2007 - 2008 Red Hat, Inc.
+ * (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
@@ -74,6 +74,7 @@ GQuark nm_setting_connection_error_quark (void);
#define NM_SETTING_CONNECTION_AUTOCONNECT "autoconnect"
#define NM_SETTING_CONNECTION_TIMESTAMP "timestamp"
#define NM_SETTING_CONNECTION_READ_ONLY "read-only"
+#define NM_SETTING_CONNECTION_PERMISSIONS "permissions"
/**
* NMSettingConnection:
@@ -97,13 +98,17 @@ typedef struct {
GType nm_setting_connection_get_type (void);
-NMSetting * nm_setting_connection_new (void);
-const char *nm_setting_connection_get_id (NMSettingConnection *setting);
-const char *nm_setting_connection_get_uuid (NMSettingConnection *setting);
-const char *nm_setting_connection_get_connection_type (NMSettingConnection *setting);
-gboolean nm_setting_connection_get_autoconnect (NMSettingConnection *setting);
-guint64 nm_setting_connection_get_timestamp (NMSettingConnection *setting);
-gboolean nm_setting_connection_get_read_only (NMSettingConnection *setting);
+NMSetting * nm_setting_connection_new (void);
+const char *nm_setting_connection_get_id (NMSettingConnection *setting);
+const char *nm_setting_connection_get_uuid (NMSettingConnection *setting);
+const char *nm_setting_connection_get_connection_type (NMSettingConnection *setting);
+gboolean nm_setting_connection_get_autoconnect (NMSettingConnection *setting);
+guint64 nm_setting_connection_get_timestamp (NMSettingConnection *setting);
+gboolean nm_setting_connection_get_read_only (NMSettingConnection *setting);
+guint32 nm_setting_connection_get_num_permissions (NMSettingConnection *setting);
+const char *nm_setting_connection_get_permission (NMSettingConnection *setting, guint32 index);
+
+/* FIXME: need add/remove calls for permissions */
G_END_DECLS
diff --git a/man/nmcli.1.in b/man/nmcli.1.in
index 44e9558ad2..5afb802bc9 100644
--- a/man/nmcli.1.in
+++ b/man/nmcli.1.in
@@ -66,16 +66,18 @@ power users who prefer the command line.
The use cases comprise:
.IP \(em 4
Initscripts: ifup/ifdown can utilize NetworkManager via \fInmcli\fP instead of
-having to manage connections itself and possible interfere with NetworkManager.
+having to manage connections itself and possibly interfere with NetworkManager.
.IP \(em 4
-Servers, headless machines: No GUI is available; then \fInmcli\fP is used to
-talk directly to NetworkManager and control only system-wide connections.
+Servers, headless machines: No GUI is available; then \fInmcli\fP can be used
+to activate/deactivate connections. However, if a connection requires a secret
+to activate and if that secret is not stored at the system level, \fInmcli\fP
+will not be able to activate it; it is currently unable to supply the needed
+secrets to NetworkManager.
.IP \(em 4
-User sessions: For this case, \fInmcli\fP can talk to \fInm-applet\fP to find
-user connections. It can still talk directly to NetworkManager for manipulating
-these connections. As \fInmcli\fP doesn't have direct access to user
-configuration data in GConf, \fInm-applet\fP handles that itself. That may,
-for example, cause the applet to pop up keyring dialogs when secrets are needed.
+User sessions: \fInmcli\fP can be used activate/deactivate connections from the
+command line, but a full NetworkManager client (like \fInm-applet\fP) is used
+for supplying secrets not stored at the system level. Keyring dialogs and
+password prompts may appear if this happens.
.SS \fIOPTIONS\fP
.TP
.B \-t, \-\-terse
@@ -203,14 +205,12 @@ Get information about NetworkManager's connections.
.sp
.RS
.TP
-.B list [id <id> | uuid <id> | system | user]
-.br
-List configured connections. Without a parameter, configured connection from
-both system and user settings services are listed. \fIsystem\fP argument filters
-only system-wide connections, \fIuser\fP prints user connections only.
-In order to get connection details, \fIid\fP with connection's name or \fIuuid\fP
-with connection's UUID shall be specified.
-When no command is given to \fIcon\fP object, the default action is 'nmcli con list'.
+.B list [id <id> | uuid <id>]
+.br
+List configured connections. Without a parameter, all connections
+are listed. In order to get connection details, \fIid\fP with connection's
+name or \fIuuid\fP with connection's UUID shall be specified. When no command
+is given to the \fIcon\fP object, the default action is 'nmcli con list'.
.br
.nf
\fBReference to D-Bus:\fP
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f3421b4a60..a7a3ecb484 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,7 +11,6 @@ libnm-util/crypto.c
libnm-util/crypto_gnutls.c
libnm-util/crypto_nss.c
libnm-util/nm-utils.c
-policy/org.freedesktop.network-manager-settings.system.policy.in
policy/org.freedesktop.NetworkManager.policy.in
src/nm-netlink-monitor.c
src/main.c
diff --git a/policy/Makefile.am b/policy/Makefile.am
index 4778ce230a..289d220bdb 100644
--- a/policy/Makefile.am
+++ b/policy/Makefile.am
@@ -1,7 +1,6 @@
polkit_policydir = $(datadir)/polkit-1/actions
dist_polkit_policy_in_files = \
- org.freedesktop.network-manager-settings.system.policy.in \
org.freedesktop.NetworkManager.policy.in
dist_polkit_policy_DATA = $(dist_polkit_policy_in_files:.policy.in=.policy)
diff --git a/policy/org.freedesktop.NetworkManager.policy.in b/policy/org.freedesktop.NetworkManager.policy.in
index 3e7db0588e..af4b9a15b4 100644
--- a/policy/org.freedesktop.NetworkManager.policy.in
+++ b/policy/org.freedesktop.NetworkManager.policy.in
@@ -45,23 +45,50 @@
</defaults>
</action>
- <action id="org.freedesktop.NetworkManager.use-user-connections">
- <_description>Allow use of user-specific connections</_description>
- <_message>System policy prevents use of user-specific connections</_message>
+ <action id="org.freedesktop.NetworkManager.network-control">
+ <_description>Allow control of network connections</_description>
+ <_message>System policy prevents control of network connections</_message>
<defaults>
<allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>
- <action id="org.freedesktop.NetworkManager.network-control">
- <_description>Allow control of network connections</_description>
- <_message>System policy prevents control of network connections</_message>
+ <action id="org.freedesktop.NetworkManager.wifi.share.protected">
+ <_description>Connection sharing via a protected WiFi network</_description>
+ <_message>System policy prevents sharing connections via a protected WiFi network</_message>
<defaults>
- <allow_inactive>yes</allow_inactive>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>yes</allow_active>
+ </defaults>
+ </action>
+
+ <action id="org.freedesktop.NetworkManager.wifi.share.open">
+ <_description>Connection sharing via an open WiFi network</_description>
+ <_message>System policy prevents sharing connections via an open WiFi network</_message>
+ <defaults>
+ <allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>
+ <action id="org.freedesktop.NetworkManager.settings.modify">
+ <_description>Modify system connections</_description>
+ <_message>System policy prevents modification of system settings</_message>
+ <defaults>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>auth_admin_keep</allow_active>
+ </defaults>
+ </action>
+
+ <action id="org.freedesktop.NetworkManager.settings.hostname.modify">
+ <_description>Modify persistent system hostname</_description>
+ <_message>System policy prevents modification of the persistent system hostname</_message>
+ <defaults>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>auth_admin_keep</allow_active>
+ </defaults>
+ </action>
+
</policyconfig>
diff --git a/policy/org.freedesktop.network-manager-settings.system.policy.in b/policy/org.freedesktop.network-manager-settings.system.policy.in
deleted file mode 100644
index 620e3a6a58..0000000000
--- a/policy/org.freedesktop.network-manager-settings.system.policy.in
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE policyconfig PUBLIC
- "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
-
-<policyconfig>
-
- <vendor>NetworkManager</vendor>
- <vendor_url>http://www.gnome.org/projects/NetworkManager</vendor_url>
- <icon_name>nm-icon</icon_name>
-
- <action id="org.freedesktop.network-manager-settings.system.modify">
- <_description>Modify system connections</_description>
- <_message>System policy prevents modification of system settings</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_admin_keep</allow_active>
- </defaults>
- </action>
-
- <action id="org.freedesktop.network-manager-settings.system.hostname.modify">
- <_description>Modify persistent system hostname</_description>
- <_message>System policy prevents modification of the persistent system hostname</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>auth_admin_keep</allow_active>
- </defaults>
- </action>
-
- <action id="org.freedesktop.network-manager-settings.system.wifi.share.protected">
- <_description>Connection sharing via a protected WiFi network</_description>
- <_message>System policy prevents sharing connections via a protected WiFi network</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>yes</allow_active>
- </defaults>
- </action>
-
- <action id="org.freedesktop.network-manager-settings.system.wifi.share.open">
- <_description>Connection sharing via an open WiFi network</_description>
- <_message>System policy prevents sharing connections via an open WiFi network</_message>
- <defaults>
- <allow_inactive>no</allow_inactive>
- <allow_active>yes</allow_active>
- </defaults>
- </action>
-
-</policyconfig>
diff --git a/src/NetworkManager.conf b/src/NetworkManager.conf
index 1f1ed49b46..fbbeb935d0 100644
--- a/src/NetworkManager.conf
+++ b/src/NetworkManager.conf
@@ -4,10 +4,7 @@
<busconfig>
<policy user="root">
<allow own="org.freedesktop.NetworkManager"/>
- <allow own="org.freedesktop.NetworkManagerSystemSettings"/>
-
<allow send_destination="org.freedesktop.NetworkManager"/>
- <allow send_destination="org.freedesktop.NetworkManagerSystemSettings"/>
<allow send_destination="org.freedesktop.NetworkManager"
send_interface="org.freedesktop.NetworkManager.PPP"/>
@@ -75,10 +72,17 @@
</policy>
<policy context="default">
<deny own="org.freedesktop.NetworkManager"/>
- <deny own="org.freedesktop.NetworkManagerSystemSettings"/>
<deny send_destination="org.freedesktop.NetworkManager"/>
- <allow send_destination="org.freedesktop.NetworkManagerSystemSettings"/>
+
+ <allow send_destination="org.freedesktop.NetworkManager"
+ send_interface="org.freedesktop.NetworkManager.Settings"/>
+
+ <allow send_destination="org.freedesktop.NetworkManager"
+ send_interface="org.freedesktop.NetworkManager.Settings.Connection"/>
+
+ <allow send_destination="org.freedesktop.NetworkManager"
+ send_interface="org.freedesktop.NetworkManager.Settings.Secrets"/>
<deny send_destination="org.freedesktop.NetworkManager"
send_interface="org.freedesktop.NetworkManager"
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index 10240960b0..0f67889719 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -406,17 +406,6 @@ nm_utils_call_dispatcher (const char *action,
connection_props = value_hash_create ();
- /* Service name */
- if (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_USER) {
- value_hash_add_str (connection_props,
- NMD_CONNECTION_PROPS_SERVICE_NAME,
- NM_DBUS_SERVICE_USER_SETTINGS);
- } else if (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) {
- value_hash_add_str (connection_props,
- NMD_CONNECTION_PROPS_SERVICE_NAME,
- NM_DBUS_SERVICE_SYSTEM_SETTINGS);
- }
-
/* path */
value_hash_add_object_path (connection_props,
NMD_CONNECTION_PROPS_PATH,
diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c
index 2529e77f65..4d8d0d8603 100644
--- a/src/nm-activation-request.c
+++ b/src/nm-activation-request.c
@@ -83,7 +83,6 @@ typedef struct {
enum {
PROP_0,
- PROP_SERVICE_NAME,
PROP_CONNECTION,
PROP_SPECIFIC_OBJECT,
PROP_DEVICES,
@@ -256,9 +255,6 @@ get_property (GObject *object, guint prop_id,
GPtrArray *devices;
switch (prop_id) {
- case PROP_SERVICE_NAME:
- nm_active_connection_scope_to_value (priv->connection, value);
- break;
case PROP_CONNECTION:
g_value_set_boxed (value, nm_connection_get_path (priv->connection));
break;
@@ -305,13 +301,6 @@ nm_act_request_class_init (NMActRequestClass *req_class)
/* properties */
g_object_class_install_property
- (object_class, PROP_SERVICE_NAME,
- g_param_spec_string (NM_ACTIVE_CONNECTION_SERVICE_NAME,
- "Service name",
- "Service name",
- NULL,
- G_PARAM_READABLE));
- g_object_class_install_property
(object_class, PROP_CONNECTION,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_CONNECTION,
"Connection",
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
index 4207e14504..fc8eb64909 100644
--- a/src/nm-active-connection.c
+++ b/src/nm-active-connection.c
@@ -39,25 +39,3 @@ nm_active_connection_install_type_info (GObjectClass *klass)
&dbus_glib_nm_active_connection_object_info);
}
-void
-nm_active_connection_scope_to_value (NMConnection *connection, GValue *value)
-{
- if (!connection) {
- g_value_set_string (value, "");
- return;
- }
-
- switch (nm_connection_get_scope (connection)) {
- case NM_CONNECTION_SCOPE_SYSTEM:
- g_value_set_string (value, NM_DBUS_SERVICE_SYSTEM_SETTINGS);
- break;
- case NM_CONNECTION_SCOPE_USER:
- g_value_set_string (value, NM_DBUS_SERVICE_USER_SETTINGS);
- break;
- default:
- nm_log_err (LOGD_CORE, "unknown connection scope!");
- break;
- }
-}
-
-
diff --git a/src/nm-active-connection.h b/src/nm-active-connection.h
index 6a463cb257..15ae201d4c 100644
--- a/src/nm-active-connection.h
+++ b/src/nm-active-connection.h
@@ -24,7 +24,6 @@
#include <glib-object.h>
#include "nm-connection.h"
-#define NM_ACTIVE_CONNECTION_SERVICE_NAME "service-name"
#define NM_ACTIVE_CONNECTION_CONNECTION "connection"
#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
@@ -37,6 +36,4 @@ char *nm_active_connection_get_next_object_path (void);
void nm_active_connection_install_type_info (GObjectClass *klass);
-void nm_active_connection_scope_to_value (NMConnection *connection, GValue *value);
-
#endif /* NM_ACTIVE_CONNECTION_H */
diff --git a/src/nm-dbus-manager.c b/src/nm-dbus-manager.c
index 9b621b42ba..dec0615ff2 100644
--- a/src/nm-dbus-manager.c
+++ b/src/nm-dbus-manager.c
@@ -339,24 +339,6 @@ nm_dbus_manager_start_service (NMDBusManager *self)
return FALSE;
}
- if (!dbus_g_proxy_call (priv->proxy, "RequestName", &err,
- G_TYPE_STRING, NM_DBUS_SERVICE_SYSTEM_SETTINGS,
- G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE,
- G_TYPE_INVALID,
- G_TYPE_UINT, &result,
- G_TYPE_INVALID)) {
- nm_log_warn (LOGD_CORE, "Could not acquire the NetworkManagerSystemSettings service.\n"
- " Message: '%s'", err->message);
- g_error_free (err);
- return FALSE;
- }
-
- if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- nm_log_warn (LOGD_CORE, "Could not acquire the NetworkManagerSystemSettings service "
- "as it is already taken.");
- return FALSE;
- }
-
priv->started = TRUE;
return priv->started;
}
diff --git a/src/nm-device.c b/src/nm-device.c
index e8f0b206ca..27604e523a 100644
--- a/src/nm-device.c
+++ b/src/nm-device.c
@@ -3324,10 +3324,8 @@ dispose (GObject *object)
NMSettingIP4Config *s_ip4;
const char *method = NULL;
- /* Only system connections can be left up */
connection = nm_act_request_get_connection (priv->act_request);
- if ( connection
- && (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM)) {
+ if (connection) {
/* Only static or DHCP IPv4 connections can be left up.
* All IPv6 connections can be left up, so we don't have
diff --git a/src/nm-manager-auth.c b/src/nm-manager-auth.c
index 44c82c23e6..566fc80a67 100644
--- a/src/nm-manager-auth.c
+++ b/src/nm-manager-auth.c
@@ -359,66 +359,3 @@ out:
g_free (sender);
return success;
}
-
-gboolean
-nm_auth_uid_authorized (gulong uid,
- NMDBusManager *dbus_mgr,
- DBusGProxy *user_proxy,
- const char **out_error_desc)
-{
- DBusConnection *connection;
- DBusError dbus_error;
- char *service_owner = NULL;
- const char *service_name;
- gulong service_uid = G_MAXULONG;
-
- g_return_val_if_fail (dbus_mgr != NULL, FALSE);
- g_return_val_if_fail (out_error_desc != NULL, FALSE);
-
- /* Ensure the request to activate the user connection came from the
- * same session as the user settings service. FIXME: use ConsoleKit
- * too.
- */
-
- if (!user_proxy) {
- *out_error_desc = "No user settings service available";
- return FALSE;
- }
-
- service_name = dbus_g_proxy_get_bus_name (user_proxy);
- if (!service_name) {
- *out_error_desc = "Could not determine user settings service name";
- return FALSE;
- }
-
- connection = nm_dbus_manager_get_dbus_connection (dbus_mgr);
- if (!connection) {
- *out_error_desc = "Could not get the D-Bus system bus";
- return FALSE;
- }
-
- service_owner = nm_dbus_manager_get_name_owner (dbus_mgr, service_name, NULL);
- if (!service_owner) {
- *out_error_desc = "Could not determine D-Bus owner of the user settings service";
- return FALSE;
- }
-
- dbus_error_init (&dbus_error);
- service_uid = dbus_bus_get_unix_user (connection, service_owner, &dbus_error);
- g_free (service_owner);
-
- if (dbus_error_is_set (&dbus_error)) {
- dbus_error_free (&dbus_error);
- *out_error_desc = "Could not determine the Unix UID of the sender of the request";
- return FALSE;
- }
-
- /* And finally, the actual UID check */
- if (uid != service_uid) {
- *out_error_desc = "Requestor UID does not match the UID of the user settings service";
- return FALSE;
- }
-
- return TRUE;
-}
-
diff --git a/src/nm-manager-auth.h b/src/nm-manager-auth.h
index 6682f91ca1..9fae64c5fb 100644
--- a/src/nm-manager-auth.h
+++ b/src/nm-manager-auth.h
@@ -27,12 +27,15 @@
#include "nm-dbus-manager.h"
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK "org.freedesktop.NetworkManager.enable-disable-network"
-#define NM_AUTH_PERMISSION_SLEEP_WAKE "org.freedesktop.NetworkManager.sleep-wake"
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI "org.freedesktop.NetworkManager.enable-disable-wifi"
-#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN "org.freedesktop.NetworkManager.enable-disable-wwan"
-#define NM_AUTH_PERMISSION_USE_USER_CONNECTIONS "org.freedesktop.NetworkManager.use-user-connections"
-#define NM_AUTH_PERMISSION_NETWORK_CONTROL "org.freedesktop.NetworkManager.network-control"
+#define NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK "org.freedesktop.NetworkManager.enable-disable-network"
+#define NM_AUTH_PERMISSION_SLEEP_WAKE "org.freedesktop.NetworkManager.sleep-wake"
+#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI "org.freedesktop.NetworkManager.enable-disable-wifi"
+#define NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN "org.freedesktop.NetworkManager.enable-disable-wwan"
+#define NM_AUTH_PERMISSION_NETWORK_CONTROL "org.freedesktop.NetworkManager.network-control"
+#define NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED "org.freedesktop.NetworkManager.wifi.share.protected"
+#define NM_AUTH_PERMISSION_WIFI_SHARE_OPEN "org.freedesktop.NetworkManager.wifi.share.open"
+#define NM_AUTH_PERMISSION_SETTINGS_CONNECTION_MODIFY "org.freedesktop.NetworkManager.settings.modify"
+#define NM_AUTH_PERMISSION_SETTINGS_HOSTNAME_MODIFY "org.freedesktop.NetworkManager.settings.hostname.modify"
typedef struct NMAuthChain NMAuthChain;
@@ -85,10 +88,5 @@ gboolean nm_auth_get_caller_uid (DBusGMethodInvocation *context,
gulong *out_uid,
const char **out_error_desc);
-gboolean nm_auth_uid_authorized (gulong uid,
- NMDBusManager *dbus_mgr,
- DBusGProxy *user_proxy,
- const char **out_error_desc);
-
#endif /* NM_MANAGER_AUTH_H */
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 4a3e4997d9..b98600d623 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -53,9 +53,8 @@
#include "nm-bluez-manager.h"
#include "nm-bluez-common.h"
#include "nm-sysconfig-settings.h"
+#include "nm-sysconfig-connection.h"
#include "nm-secrets-provider-interface.h"
-#include "nm-settings-interface.h"
-#include "nm-settings-system-interface.h"
#include "nm-manager-auth.h"
#define NM_AUTOIP_DBUS_SERVICE "org.freedesktop.nm_avahi_autoipd"
@@ -65,7 +64,6 @@
static gboolean impl_manager_get_devices (NMManager *manager, GPtrArray **devices, GError **err);
static void impl_manager_activate_connection (NMManager *manager,
- const char *service_name,
const char *connection_path,
const char *device_path,
const char *specific_object_path,
@@ -99,10 +97,6 @@ static gboolean impl_manager_legacy_state (NMManager *manager, guint32 *state, G
#include "nm-manager-glue.h"
-static void connection_added_default_handler (NMManager *manager,
- NMConnection *connection,
- NMConnectionScope scope);
-
static void udev_device_added_cb (NMUdevManager *udev_mgr,
GUdevDevice *device,
NMDeviceCreatorFn creator_fn,
@@ -176,14 +170,11 @@ struct PendingActivation {
PendingActivationFunc callback;
NMAuthChain *chain;
- gboolean have_connection;
gboolean authorized;
- NMConnectionScope scope;
char *connection_path;
char *specific_object_path;
char *device_path;
- guint timeout_id;
};
typedef struct {
@@ -209,19 +200,12 @@ typedef struct {
NMUdevManager *udev_mgr;
NMBluezManager *bluez_mgr;
- GHashTable *user_connections;
- DBusGProxy *user_proxy;
- NMAuthCallResult user_con_perm;
- NMAuthCallResult user_net_perm;
-
GHashTable *system_connections;
NMSysconfigSettings *sys_settings;
char *hostname;
GSList *secrets_calls;
- GSList *pending_activations;
-
RadioState radio_states[RFKILL_TYPE_MAX];
gboolean sleeping;
gboolean net_enabled;
@@ -295,7 +279,6 @@ typedef enum
NM_MANAGER_ERROR_UNKNOWN_CONNECTION = 0,
NM_MANAGER_ERROR_UNKNOWN_DEVICE,
NM_MANAGER_ERROR_UNMANAGED_DEVICE,
- NM_MANAGER_ERROR_INVALID_SERVICE,
NM_MANAGER_ERROR_SYSTEM_CONNECTION,
NM_MANAGER_ERROR_PERMISSION_DENIED,
NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE,
@@ -331,10 +314,6 @@ nm_manager_error_get_type (void)
ENUM_ENTRY (NM_MANAGER_ERROR_UNKNOWN_DEVICE, "UnknownDevice"),
/* Unmanaged device. */
ENUM_ENTRY (NM_MANAGER_ERROR_UNMANAGED_DEVICE, "UnmanagedDevice"),
- /* Invalid settings service (not a recognized system or user
- * settings service name)
- */
- ENUM_ENTRY (NM_MANAGER_ERROR_INVALID_SERVICE, "InvalidService"),
/* Connection was superceded by a system connection. */
ENUM_ENTRY (NM_MANAGER_ERROR_SYSTEM_CONNECTION, "SystemConnection"),
/* User does not have the permission to activate this connection. */
@@ -607,18 +586,7 @@ emit_removed (gpointer key, gpointer value, gpointer user_data)
NMManager *manager = NM_MANAGER (user_data);
NMConnection *connection = NM_CONNECTION (value);
- g_signal_emit (manager, signals[CONNECTION_REMOVED], 0,
- connection,
- nm_connection_get_scope (connection));
-}
-
-static void
-nm_manager_pending_activation_remove (NMManager *self,
- PendingActivation *pending)
-{
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
-
- priv->pending_activations = g_slist_remove (priv->pending_activations, pending);
+ g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection);
}
static PendingActivation *
@@ -626,7 +594,6 @@ pending_activation_new (NMManager *manager,
PolkitAuthority *authority,
DBusGMethodInvocation *context,
const char *device_path,
- NMConnectionScope scope,
const char *connection_path,
const char *specific_object_path,
PendingActivationFunc callback)
@@ -646,7 +613,6 @@ pending_activation_new (NMManager *manager,
pending->callback = callback;
pending->device_path = g_strdup (device_path);
- pending->scope = scope;
pending->connection_path = g_strdup (connection_path);
/* "/" is special-cased to NULL to get through D-Bus */
@@ -657,39 +623,6 @@ pending_activation_new (NMManager *manager,
}
static void
-pending_auth_user_done (NMAuthChain *chain,
- GError *error,
- DBusGMethodInvocation *context,
- gpointer user_data)
-{
- PendingActivation *pending = user_data;
- NMAuthCallResult result;
-
- pending->chain = NULL;
-
- if (error) {
- pending->callback (pending, error);
- goto out;
- }
-
- /* Caller has had a chance to obtain authorization, so we only need to
- * check for 'yes' here.
- */
- result = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS));
- if (result != NM_AUTH_CALL_RESULT_YES) {
- error = g_error_new_literal (NM_MANAGER_ERROR,
- NM_MANAGER_ERROR_PERMISSION_DENIED,
- "Not authorized to use user connections.");
- pending->callback (pending, error);
- g_error_free (error);
- } else
- pending->callback (pending, NULL);
-
-out:
- nm_auth_chain_unref (chain);
-}
-
-static void
pending_auth_net_done (NMAuthChain *chain,
GError *error,
DBusGMethodInvocation *context,
@@ -718,67 +651,15 @@ pending_auth_net_done (NMAuthChain *chain,
goto out;
}
- if (pending->scope == NM_CONNECTION_SCOPE_SYSTEM) {
- /* System connection and the user is authorized for that if they have
- * the network-control permission.
- */
- pending->callback (pending, NULL);
- } else {
- g_assert (pending->scope == NM_CONNECTION_SCOPE_USER);
-
- /* User connection, check the 'use-user-connections' permission */
- pending->chain = nm_auth_chain_new (pending->authority,
- pending->context,
- NULL,
- pending_auth_user_done,
- pending);
- nm_auth_chain_add_call (pending->chain,
- NM_AUTH_PERMISSION_USE_USER_CONNECTIONS,
- TRUE);
- }
+ pending->callback (pending, NULL);
out:
nm_auth_chain_unref (chain);
}
-static gboolean
-check_user_authorized (NMDBusManager *dbus_mgr,
- DBusGProxy *user_proxy,
- DBusGMethodInvocation *context,
- NMConnectionScope scope,
- gulong *out_sender_uid,
- const char **out_error_desc)
-{
- g_return_val_if_fail (dbus_mgr != NULL, FALSE);
- g_return_val_if_fail (context != NULL, FALSE);
- g_return_val_if_fail (out_sender_uid != NULL, FALSE);
- g_return_val_if_fail (out_error_desc != NULL, FALSE);
-
- *out_sender_uid = G_MAXULONG;
-
- /* Get the UID */
- if (!nm_auth_get_caller_uid (context, dbus_mgr, out_sender_uid, out_error_desc))
- return FALSE;
-
- /* root gets to do anything */
- if (0 == *out_sender_uid)
- return TRUE;
-
- /* Check whether the UID is authorized for user connections */
- if ( scope == NM_CONNECTION_SCOPE_USER
- && !nm_auth_uid_authorized (*out_sender_uid,
- dbus_mgr,
- user_proxy,
- out_error_desc))
- return FALSE;
-
- return TRUE;
-}
-
static void
pending_activation_check_authorized (PendingActivation *pending,
- NMDBusManager *dbus_mgr,
- DBusGProxy *user_proxy)
+ NMDBusManager *dbus_mgr)
{
const char *error_desc = NULL;
gulong sender_uid = G_MAXULONG;
@@ -787,12 +668,10 @@ pending_activation_check_authorized (PendingActivation *pending,
g_return_if_fail (pending != NULL);
g_return_if_fail (dbus_mgr != NULL);
- if (!check_user_authorized (dbus_mgr,
- user_proxy,
- pending->context,
- pending->scope,
- &sender_uid,
- &error_desc)) {
+ if (!nm_auth_get_caller_uid (pending->context,
+ dbus_mgr,
+ &sender_uid,
+ &error_desc)) {
error = g_error_new_literal (NM_MANAGER_ERROR,
NM_MANAGER_ERROR_PERMISSION_DENIED,
error_desc);
@@ -828,8 +707,6 @@ pending_activation_destroy (PendingActivation *pending,
{
g_return_if_fail (pending != NULL);
- if (pending->timeout_id)
- g_source_remove (pending->timeout_id);
g_free (pending->connection_path);
g_free (pending->specific_object_path);
g_free (pending->device_path);
@@ -890,468 +767,24 @@ remove_connection (NMManager *manager,
*/
g_object_ref (connection);
g_hash_table_remove (hash, nm_connection_get_path (connection));
- g_signal_emit (manager, signals[CONNECTION_REMOVED], 0,
- connection,
- nm_connection_get_scope (connection));
+ g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection);
g_object_unref (connection);
bluez_manager_resync_devices (manager);
}
/*******************************************************************/
-/* User settings stuff via D-Bus */
-/*******************************************************************/
-
-static void
-user_proxy_cleanup (NMManager *self, gboolean resync_bt)
-{
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
-
- if (priv->user_connections) {
- g_hash_table_foreach (priv->user_connections, emit_removed, self);
- g_hash_table_remove_all (priv->user_connections);
- }
-
- priv->user_net_perm = NM_AUTH_CALL_RESULT_UNKNOWN;
- priv->user_con_perm = NM_AUTH_CALL_RESULT_UNKNOWN;
-
- if (priv->user_proxy) {
- g_object_unref (priv->user_proxy);
- priv->user_proxy = NULL;
- }
-
- if (resync_bt) {
- /* Resync BT devices since they are generated from connections */
- bluez_manager_resync_devices (self);
- }
-}
-
-typedef struct GetSettingsInfo {
- NMManager *manager;
- NMConnection *connection;
- DBusGProxy *proxy;
- guint32 *calls;
-} GetSettingsInfo;
-
-static void
-free_get_settings_info (gpointer data)
-{
- GetSettingsInfo *info = (GetSettingsInfo *) data;
-
- /* If this was the last pending call for a batch of GetSettings calls,
- * send out the connections-added signal.
- */
- if (info->calls) {
- (*info->calls)--;
- if (*info->calls == 0) {
- g_slice_free (guint32, (gpointer) info->calls);
- g_signal_emit (info->manager, signals[CONNECTIONS_ADDED], 0, NM_CONNECTION_SCOPE_USER);
-
- /* Update the Bluetooth connections for all the new connections */
- bluez_manager_resync_devices (info->manager);
- }
- }
-
- if (info->manager) {
- g_object_unref (info->manager);
- info->manager = NULL;
- }
- if (info->connection) {
- g_object_unref (info->connection);
- info->connection = NULL;
- }
- if (info->proxy) {
- g_object_unref (info->proxy);
- info->proxy = NULL;
- }
-
- g_slice_free (GetSettingsInfo, data);
-}
-
-static void
-user_connection_get_settings_cb (DBusGProxy *proxy,
- DBusGProxyCall *call_id,
- gpointer user_data)
-{
- GetSettingsInfo *info = (GetSettingsInfo *) user_data;
- GError *err = NULL;
- GHashTable *settings = NULL;
- NMConnection *connection;
- NMManager *manager;
-
- g_return_if_fail (info != NULL);
-
- if (!dbus_g_proxy_end_call (proxy, call_id, &err,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings,
- G_TYPE_INVALID)) {
- nm_log_info (LOGD_USER_SET, "couldn't retrieve connection settings: %s.",
- err && err->message ? err->message : "(unknown)");
- g_error_free (err);
- goto out;
- }
-
- manager = info->manager;
- connection = info->connection;
- if (connection == NULL) {
- const char *path = dbus_g_proxy_get_path (proxy);
- NMManagerPrivate *priv;
- GError *error = NULL;
- NMConnection *existing = NULL;
-
- connection = nm_connection_new_from_hash (settings, &error);
- if (connection == NULL) {
- nm_log_warn (LOGD_USER_SET, "invalid connection: '%s' / '%s' invalid: %d",
- g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
- error->message, error->code);
- g_error_free (error);
- goto out;
- }
-
- nm_connection_set_path (connection, path);
- nm_connection_set_scope (connection, NM_CONNECTION_SCOPE_USER);
-
- /* Add the new connection to the internal hashes only if the same
- * connection isn't already there.
- */
- priv = NM_MANAGER_GET_PRIVATE (manager);
-
- existing = g_hash_table_lookup (priv->user_connections, path);
- if (!existing || !nm_connection_compare (existing, connection, NM_SETTING_COMPARE_FLAG_EXACT)) {
- g_hash_table_insert (priv->user_connections,
- g_strdup (path),
- connection);
- existing = NULL;
-
- /* Attach the D-Bus proxy representing the remote NMConnection
- * to the local NMConnection object to ensure it stays alive to
- * continue delivering signals. It'll be destroyed once the
- * NMConnection is destroyed.
- */
- g_object_set_data_full (G_OBJECT (connection),
- "proxy",
- g_object_ref (info->proxy),
- g_object_unref);
- } else
- g_object_unref (connection);
-
- /* If the connection-added signal is supposed to be batched, don't
- * emit the single connection-added here. Also, don't emit the signal
- * if the connection wasn't actually added to the system or user hashes.
- */
- if (!info->calls && !existing) {
- g_signal_emit (manager, signals[CONNECTION_ADDED], 0, connection, NM_CONNECTION_SCOPE_USER);
- /* Update the Bluetooth connections for that single new connection */
- bluez_manager_resync_devices (manager);
- }
- } else {
- // FIXME: merge settings? or just replace?
- nm_log_dbg (LOGD_USER_SET, "implement merge settings");
- }
-
-out:
- if (settings)
- g_hash_table_destroy (settings);
-
- return;
-}
-
-static void
-user_connection_removed_cb (DBusGProxy *proxy, gpointer user_data)
-{
- NMManager *manager = NM_MANAGER (user_data);
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
- NMConnection *connection = NULL;
- const char *path;
-
- path = dbus_g_proxy_get_path (proxy);
- if (path) {
- connection = g_hash_table_lookup (priv->user_connections, path);
- if (connection)
- remove_connection (manager, connection, priv->user_connections);
- }
-}
-
-static void
-user_connection_updated_cb (DBusGProxy *proxy,
- GHashTable *settings,
- gpointer user_data)
-{
- NMManager *manager = NM_MANAGER (user_data);
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
- NMConnection *new_connection;
- NMConnection *old_connection = NULL;
- gboolean valid = FALSE;
- GError *error = NULL;
- const char *path;
-
- path = dbus_g_proxy_get_path (proxy);
- if (path)
- old_connection = g_hash_table_lookup (priv->user_connections, path);
-
- g_return_if_fail (old_connection != NULL);
-
- new_connection = nm_connection_new_from_hash (settings, &error);
- if (!new_connection) {
- /* New connection invalid, remove existing connection */
- nm_log_warn (LOGD_USER_SET, "invalid connection: '%s' / '%s' invalid: %d",
- g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
- error->message, error->code);
- g_error_free (error);
- remove_connection (manager, old_connection, priv->user_connections);
- return;
- }
- g_object_unref (new_connection);
-
- valid = nm_connection_replace_settings (old_connection, settings, NULL);
- if (valid) {
- g_signal_emit (manager, signals[CONNECTION_UPDATED], 0,
- old_connection,
- nm_connection_get_scope (old_connection));
-
- bluez_manager_resync_devices (manager);
- } else {
- remove_connection (manager, old_connection, priv->user_connections);
- }
-}
-
-static void
-user_internal_new_connection_cb (NMManager *manager,
- const char *path,
- guint32 *counter)
-{
- GetSettingsInfo *info;
- DBusGProxy *con_proxy;
- DBusGConnection *g_connection;
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
-
- g_connection = nm_dbus_manager_get_connection (priv->dbus_mgr);
- con_proxy = dbus_g_proxy_new_for_name (g_connection,
- NM_DBUS_SERVICE_USER_SETTINGS,
- path,
- NM_DBUS_IFACE_SETTINGS_CONNECTION);
- if (!con_proxy) {
- nm_log_err (LOGD_USER_SET, "could not init user connection proxy");
- return;
- }
-
- dbus_g_proxy_add_signal (con_proxy, "Updated",
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (con_proxy, "Updated",
- G_CALLBACK (user_connection_updated_cb),
- manager,
- NULL);
-
- dbus_g_proxy_add_signal (con_proxy, "Removed", G_TYPE_INVALID, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (con_proxy, "Removed",
- G_CALLBACK (user_connection_removed_cb),
- manager,
- NULL);
-
- info = g_slice_new0 (GetSettingsInfo);
- info->manager = g_object_ref (manager);
- info->proxy = con_proxy;
- if (counter) {
- info->calls = counter;
- (*info->calls)++;
- }
- dbus_g_proxy_begin_call (con_proxy, "GetSettings",
- user_connection_get_settings_cb,
- info,
- free_get_settings_info,
- G_TYPE_INVALID);
-}
-
-static void
-user_list_connections_cb (DBusGProxy *proxy,
- DBusGProxyCall *call_id,
- gpointer user_data)
-{
- NMManager *manager = NM_MANAGER (user_data);
- GError *err = NULL;
- GPtrArray *ops;
- guint32 *counter = NULL;
- int i;
-
- if (!dbus_g_proxy_end_call (proxy, call_id, &err,
- DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &ops,
- G_TYPE_INVALID)) {
- nm_log_warn (LOGD_USER_SET, "couldn't retrieve connections: %s",
- err && err->message ? err->message : "(unknown)");
- g_clear_error (&err);
- return;
- }
-
- /* Keep track of all calls made here; don't want to emit connection-added for
- * each one, but emit connections-added when they are all done.
- */
- counter = g_slice_new0 (guint32);
- for (i = 0; i < ops->len; i++) {
- char *op = g_ptr_array_index (ops, i);
-
- user_internal_new_connection_cb (manager, op, counter);
- g_free (op);
- }
- g_ptr_array_free (ops, TRUE);
-}
-
-static void
-user_proxy_destroyed_cb (DBusGProxy *proxy, NMManager *self)
-{
- nm_log_dbg (LOGD_USER_SET, "Removing user connections...");
-
- /* At this point the user proxy is already being disposed */
- NM_MANAGER_GET_PRIVATE (self)->user_proxy = NULL;
-
- /* User Settings service disappeared; throw away user connections */
- user_proxy_cleanup (self, TRUE);
-}
-
-static void
-user_new_connection_cb (DBusGProxy *proxy, const char *path, gpointer user_data)
-{
- user_internal_new_connection_cb (NM_MANAGER (user_data), path, NULL);
-}
-
-static gboolean
-user_settings_authorized (NMManager *self, NMAuthChain *chain)
-{
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- NMAuthCallResult old_net_perm = priv->user_net_perm;
- NMAuthCallResult old_con_perm = priv->user_con_perm;
-
- /* If the user could potentially get authorization to use networking and/or
- * to use user connections, the user settings service is authorized.
- */
- priv->user_net_perm = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL));
- priv->user_con_perm = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS));
-
- nm_log_dbg (LOGD_USER_SET, "User connections permissions: net %d, con %d",
- priv->user_net_perm, priv->user_con_perm);
-
- if (old_net_perm != priv->user_net_perm || old_con_perm != priv->user_con_perm)
- g_signal_emit (self, signals[USER_PERMISSIONS_CHANGED], 0);
-
- /* If the user can't control the network they certainly aren't allowed
- * to provide user connections.
- */
- if ( priv->user_net_perm == NM_AUTH_CALL_RESULT_UNKNOWN
- || priv->user_net_perm == NM_AUTH_CALL_RESULT_NO)
- return FALSE;
-
- /* And of course if they aren't allowed to use user connections, they can't
- * provide them either.
- */
- if ( priv->user_con_perm == NM_AUTH_CALL_RESULT_UNKNOWN
- || priv->user_con_perm == NM_AUTH_CALL_RESULT_NO)
- return FALSE;
-
- return TRUE;
-}
-
-static void
-user_proxy_auth_done (NMAuthChain *chain,
- GError *error,
- DBusGMethodInvocation *context,
- gpointer user_data)
-{
- NMManager *self = NM_MANAGER (user_data);
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- gboolean authorized = FALSE;
-
- priv->auth_chains = g_slist_remove (priv->auth_chains, chain);
-
- if (error) {
- nm_log_warn (LOGD_USER_SET, "User connections unavailable: (%d) %s",
- error->code, error->message ? error->message : "(unknown)");
- } else
- authorized = user_settings_authorized (self, chain);
-
- if (authorized) {
- /* If authorized, finish setting up the user settings service proxy */
- nm_log_dbg (LOGD_USER_SET, "Requesting user connections...");
-
- authorized = TRUE;
-
- dbus_g_proxy_add_signal (priv->user_proxy,
- "NewConnection",
- DBUS_TYPE_G_OBJECT_PATH,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (priv->user_proxy, "NewConnection",
- G_CALLBACK (user_new_connection_cb),
- self,
- NULL);
-
- /* Clean up when the user settings proxy goes away */
- g_signal_connect (priv->user_proxy, "destroy",
- G_CALLBACK (user_proxy_destroyed_cb),
- self);
-
- /* Request user connections */
- dbus_g_proxy_begin_call (priv->user_proxy, "ListConnections",
- user_list_connections_cb,
- self,
- NULL,
- G_TYPE_INVALID);
- } else {
- /* Otherwise, we ignore the user settings service completely */
- user_proxy_cleanup (self, TRUE);
- }
-
- nm_auth_chain_unref (chain);
-}
-
-static void
-user_proxy_init (NMManager *self)
-{
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- DBusGConnection *bus;
- NMAuthChain *chain;
- GError *error = NULL;
-
- g_return_if_fail (self != NULL);
- g_return_if_fail (priv->user_proxy == NULL);
-
- bus = nm_dbus_manager_get_connection (priv->dbus_mgr);
- priv->user_proxy = dbus_g_proxy_new_for_name_owner (bus,
- NM_DBUS_SERVICE_USER_SETTINGS,
- NM_DBUS_PATH_SETTINGS,
- NM_DBUS_IFACE_SETTINGS,
- &error);
- if (!priv->user_proxy) {
- nm_log_err (LOGD_USER_SET, "could not init user settings proxy: (%d) %s",
- error ? error->code : -1,
- error && error->message ? error->message : "(unknown)");
- g_clear_error (&error);
- return;
- }
-
- /* Kick off some PolicyKit authorization requests to figure out what
- * permissions this user settings service has.
- */
- chain = nm_auth_chain_new (priv->authority,
- NULL,
- priv->user_proxy,
- user_proxy_auth_done,
- self);
- priv->auth_chains = g_slist_prepend (priv->auth_chains, chain);
-
- nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS, FALSE);
- nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, FALSE);
-}
-
-/*******************************************************************/
/* System settings stuff via NMSysconfigSettings */
/*******************************************************************/
static void
-system_connection_updated_cb (NMSettingsConnectionInterface *connection,
+system_connection_updated_cb (NMSysconfigConnection *connection,
gpointer unused,
NMManager *manager)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
const char *path;
- NMSettingsConnectionInterface *existing;
+ NMSysconfigConnection *existing;
GError *error = NULL;
path = nm_connection_get_path (NM_CONNECTION (connection));
@@ -1374,14 +807,13 @@ system_connection_updated_cb (NMSettingsConnectionInterface *connection,
return;
}
- g_signal_emit (manager, signals[CONNECTION_UPDATED], 0,
- existing, NM_CONNECTION_SCOPE_SYSTEM);
+ g_signal_emit (manager, signals[CONNECTION_UPDATED], 0, existing);
bluez_manager_resync_devices (manager);
}
static void
-system_connection_removed_cb (NMSettingsConnectionInterface *connection,
+system_connection_removed_cb (NMSysconfigConnection *connection,
NMManager *manager)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
@@ -1395,43 +827,33 @@ system_connection_removed_cb (NMSettingsConnectionInterface *connection,
}
static void
-system_internal_new_connection (NMManager *manager,
- NMSettingsConnectionInterface *connection)
+_new_connection (NMSysconfigSettings *settings,
+ NMSysconfigConnection *connection,
+ gpointer user_data)
{
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
+ NMManager *self = NM_MANAGER (user_data);
+ NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
const char *path;
g_return_if_fail (connection != NULL);
- g_signal_connect (connection, NM_SETTINGS_CONNECTION_INTERFACE_UPDATED,
- G_CALLBACK (system_connection_updated_cb), manager);
- g_signal_connect (connection, NM_SETTINGS_CONNECTION_INTERFACE_REMOVED,
- G_CALLBACK (system_connection_removed_cb), manager);
+ g_signal_connect (connection, NM_SYSCONFIG_CONNECTION_UPDATED,
+ G_CALLBACK (system_connection_updated_cb), self);
+ g_signal_connect (connection, NM_SYSCONFIG_CONNECTION_REMOVED,
+ G_CALLBACK (system_connection_removed_cb), self);
path = nm_connection_get_path (NM_CONNECTION (connection));
g_hash_table_insert (priv->system_connections, g_strdup (path),
g_object_ref (connection));
- g_signal_emit (manager, signals[CONNECTION_ADDED], 0, connection, NM_CONNECTION_SCOPE_SYSTEM);
+ g_signal_emit (self, signals[CONNECTION_ADDED], 0, connection);
}
static void
system_new_connection_cb (NMSysconfigSettings *settings,
- NMSettingsConnectionInterface *connection,
- NMManager *manager)
+ NMSysconfigConnection *connection,
+ NMManager *self)
{
- system_internal_new_connection (manager, connection);
-}
-
-static void
-system_query_connections (NMManager *manager)
-{
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
- GSList *system_connections, *iter;
-
- system_connections = nm_settings_interface_list_connections (NM_SETTINGS_INTERFACE (priv->sys_settings));
- for (iter = system_connections; iter; iter = g_slist_next (iter))
- system_internal_new_connection (manager, NM_SETTINGS_CONNECTION_INTERFACE (iter->data));
- g_slist_free (system_connections);
+ _new_connection (settings, connection, self);
}
static void
@@ -1508,25 +930,6 @@ nm_manager_get_device_by_path (NMManager *manager, const char *path)
return NULL;
}
-static void
-nm_manager_name_owner_changed (NMDBusManager *mgr,
- const char *name,
- const char *old,
- const char *new,
- gpointer user_data)
-{
- NMManager *manager = NM_MANAGER (user_data);
- gboolean old_owner_good = (old && (strlen (old) > 0));
- gboolean new_owner_good = (new && (strlen (new) > 0));
-
- if (strcmp (name, NM_DBUS_SERVICE_USER_SETTINGS) == 0) {
- if (!old_owner_good && new_owner_good)
- user_proxy_init (manager);
- else
- user_proxy_cleanup (manager, TRUE);
- }
-}
-
/* Store value into key-file; supported types: boolean, int, string */
static gboolean
write_value_to_state_file (const char *filename,
@@ -1643,8 +1046,7 @@ manager_hidden_ap_found (NMDeviceInterface *device,
/* Look for this AP's BSSID in the seen-bssids list of a connection,
* and if a match is found, copy over the SSID */
- connections = nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
- connections = g_slist_concat (connections, nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_USER));
+ connections = nm_manager_get_connections (manager);
for (iter = connections; iter && !done; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
@@ -1847,43 +1249,13 @@ deactivate_disconnect_check_error (GError *auth_error,
} else if (result != NM_AUTH_CALL_RESULT_YES) {
return g_error_new (NM_MANAGER_ERROR,
NM_MANAGER_ERROR_PERMISSION_DENIED,
- "Not authorized to %s user connections",
+ "Not authorized to %s connections",
detail);
}
return NULL;
}
static void
-disconnect_user_auth_done_cb (NMAuthChain *chain,
- GError *error,
- DBusGMethodInvocation *context,
- gpointer user_data)
-{
- NMManager *self = NM_MANAGER (user_data);
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- GError *ret_error = NULL;
- NMAuthCallResult result;
- NMDevice *device;
-
- priv->auth_chains = g_slist_remove (priv->auth_chains, chain);
-
- result = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS));
- ret_error = deactivate_disconnect_check_error (error, result, "Disconnect");
- if (!ret_error) {
- /* Everything authorized, deactivate the connection */
- device = nm_auth_chain_get_data (chain, "device");
- if (nm_device_interface_disconnect (NM_DEVICE_INTERFACE (device), &ret_error))
- dbus_g_method_return (context);
- }
-
- if (ret_error)
- dbus_g_method_return_error (context, ret_error);
- g_clear_error (&ret_error);
-
- nm_auth_chain_unref (chain);
-}
-
-static void
disconnect_net_auth_done_cb (NMAuthChain *chain,
GError *error,
DBusGMethodInvocation *context,
@@ -1893,7 +1265,6 @@ disconnect_net_auth_done_cb (NMAuthChain *chain,
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
GError *ret_error = NULL;
NMAuthCallResult result;
- NMConnectionScope scope;
NMDevice *device;
priv->auth_chains = g_slist_remove (priv->auth_chains, chain);
@@ -1906,29 +1277,12 @@ disconnect_net_auth_done_cb (NMAuthChain *chain,
goto done;
}
- /* If it's a system connection, we're done */
device = nm_auth_chain_get_data (chain, "device");
- scope = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, "scope"));
- if (scope == NM_CONNECTION_SCOPE_USER) {
- NMAuthChain *user_chain;
-
- /* It's a user connection, so we need to ensure the caller is
- * authorized to manipulate user connections.
- */
- user_chain = nm_auth_chain_new (priv->authority, context, NULL, disconnect_user_auth_done_cb, self);
- g_assert (user_chain);
- priv->auth_chains = g_slist_append (priv->auth_chains, user_chain);
-
- nm_auth_chain_set_data (user_chain, "device", g_object_ref (device), g_object_unref);
- nm_auth_chain_set_data (user_chain, "scope", GUINT_TO_POINTER (scope), NULL);
- nm_auth_chain_add_call (user_chain, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS, TRUE);
- } else {
- if (!nm_device_interface_disconnect (NM_DEVICE_INTERFACE (device), &ret_error)) {
- dbus_g_method_return_error (context, ret_error);
- g_clear_error (&ret_error);
- } else
- dbus_g_method_return (context);
- }
+ if (!nm_device_interface_disconnect (NM_DEVICE_INTERFACE (device), &ret_error)) {
+ dbus_g_method_return_error (context, ret_error);
+ g_clear_error (&ret_error);
+ } else
+ dbus_g_method_return (context);
done:
nm_auth_chain_unref (chain);
@@ -1941,9 +1295,7 @@ manager_device_disconnect_request (NMDevice *device,
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
NMActRequest *req;
- NMConnection *connection;
GError *error = NULL;
- NMConnectionScope scope;
gulong sender_uid = G_MAXULONG;
const char *error_desc = NULL;
@@ -1957,19 +1309,13 @@ manager_device_disconnect_request (NMDevice *device,
return;
}
- connection = nm_act_request_get_connection (req);
- g_assert (connection);
-
/* Need to check the caller's permissions and stuff before we can
* deactivate the connection.
*/
- scope = nm_connection_get_scope (connection);
- if (!check_user_authorized (priv->dbus_mgr,
- priv->user_proxy,
- context,
- scope,
- &sender_uid,
- &error_desc)) {
+ if (!nm_auth_get_caller_uid (context,
+ priv->dbus_mgr,
+ &sender_uid,
+ &error_desc)) {
error = g_error_new_literal (NM_MANAGER_ERROR,
NM_MANAGER_ERROR_PERMISSION_DENIED,
error_desc);
@@ -1994,7 +1340,6 @@ manager_device_disconnect_request (NMDevice *device,
priv->auth_chains = g_slist_append (priv->auth_chains, chain);
nm_auth_chain_set_data (chain, "device", g_object_ref (device), g_object_unref);
- nm_auth_chain_set_data (chain, "scope", GUINT_TO_POINTER (scope), NULL);
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, TRUE);
}
}
@@ -2131,8 +1476,7 @@ add_device (NMManager *self, NMDevice *device)
if (ac_path)
g_object_notify (G_OBJECT (self), NM_MANAGER_ACTIVE_CONNECTIONS);
else {
- nm_log_warn (LOGD_DEVICE, "assumed connection (%d) %s failed to activate: (%d) %s",
- nm_connection_get_scope (existing),
+ nm_log_warn (LOGD_DEVICE, "assumed connection %s failed to activate: (%d) %s",
nm_connection_get_path (existing),
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
@@ -2175,8 +1519,7 @@ bluez_manager_find_connection (NMManager *manager,
NMConnection *found = NULL;
GSList *connections, *l;
- connections = nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
- connections = g_slist_concat (connections, nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_USER));
+ connections = nm_manager_get_connections (manager);
for (l = connections; l != NULL; l = l->next) {
NMConnection *candidate = NM_CONNECTION (l->data);
@@ -2511,101 +1854,7 @@ provider_cancel_secrets (NMSecretsProviderInterface *provider, gpointer user_dat
}
static void
-user_get_secrets_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
-{
- GetSecretsInfo *info = (GetSecretsInfo *) user_data;
- GHashTable *settings = NULL;
- GError *error = NULL;
- GObject *provider;
-
- g_return_if_fail (info != NULL);
- g_return_if_fail (info->provider);
- g_return_if_fail (info->setting_name);
-
- provider = g_object_ref (info->provider);
-
- if (dbus_g_proxy_end_call (proxy, call, &error,
- DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings,
- G_TYPE_INVALID)) {
- nm_secrets_provider_interface_get_secrets_result (info->provider,
- info->setting_name,
- info->caller,
- settings,
- NULL);
- g_hash_table_destroy (settings);
- } else {
- nm_secrets_provider_interface_get_secrets_result (info->provider,
- info->setting_name,
- info->caller,
- NULL,
- error);
- g_clear_error (&error);
- }
-
- info->call = NULL;
- free_get_secrets_info (info);
-
- g_object_unref (provider);
-}
-
-static GetSecretsInfo *
-user_get_secrets (NMManager *self,
- NMSecretsProviderInterface *provider,
- NMConnection *connection,
- const char *setting_name,
- gboolean request_new,
- RequestSecretsCaller caller_id,
- const char *hint1,
- const char *hint2)
-{
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- DBusGConnection *g_connection;
- GetSecretsInfo *info = NULL;
- GPtrArray *hints = NULL;
-
- info = g_malloc0 (sizeof (GetSecretsInfo));
-
- g_connection = nm_dbus_manager_get_connection (priv->dbus_mgr);
- info->proxy = dbus_g_proxy_new_for_name (g_connection,
- NM_DBUS_SERVICE_USER_SETTINGS,
- nm_connection_get_path (connection),
- NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS);
- if (!info->proxy) {
- nm_log_warn (LOGD_USER_SET, "could not create user connection secrets proxy");
- g_free (info);
- return NULL;
- }
-
- info->manager = self;
- info->provider = provider;
- info->caller = caller_id;
- info->setting_name = g_strdup (setting_name);
-
- g_object_weak_ref (G_OBJECT (provider), (GWeakNotify) free_get_secrets_info, info);
-
- hints = g_ptr_array_sized_new (2);
- if (hint1)
- g_ptr_array_add (hints, (char *) hint1);
- if (hint2)
- g_ptr_array_add (hints, (char *) hint2);
-
- info->call = dbus_g_proxy_begin_call_with_timeout (info->proxy, "GetSecrets",
- user_get_secrets_cb,
- info,
- NULL,
- G_MAXINT32,
- G_TYPE_STRING, setting_name,
- DBUS_TYPE_G_ARRAY_OF_STRING, hints,
- G_TYPE_BOOLEAN, request_new,
- G_TYPE_INVALID);
- g_ptr_array_free (hints, TRUE);
- return info;
-}
-
-static void
-system_get_secrets_reply_cb (NMSettingsConnectionInterface *connection,
+system_get_secrets_reply_cb (NMSysconfigConnection *connection,
GHashTable *secrets,
GError *error,
gpointer user_data)
@@ -2629,13 +1878,13 @@ system_get_secrets_idle_cb (gpointer user_data)
{
GetSecretsInfo *info = user_data;
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (info->manager);
- NMSettingsConnectionInterface *connection;
+ NMSysconfigConnection *connection;
GError *error = NULL;
const char *hints[3] = { NULL, NULL, NULL };
info->idle_id = 0;
- connection = nm_settings_interface_get_connection_by_path (NM_SETTINGS_INTERFACE (priv->sys_settings),
+ connection = nm_sysconfig_settings_get_connection_by_path (priv->sys_settings,
info->connection_path);
if (!connection) {
error = g_error_new_literal (NM_MANAGER_ERROR,
@@ -2653,12 +1902,12 @@ system_get_secrets_idle_cb (gpointer user_data)
hints[0] = info->hint1;
hints[1] = info->hint2;
- nm_settings_connection_interface_get_secrets (connection,
- info->setting_name,
- hints,
- info->request_new,
- system_get_secrets_reply_cb,
- info);
+ nm_sysconfig_connection_get_secrets (connection,
+ info->setting_name,
+ hints,
+ info->request_new,
+ system_get_secrets_reply_cb,
+ info);
return FALSE;
}
@@ -2706,7 +1955,6 @@ provider_get_secrets (NMSecretsProviderInterface *provider,
NMManager *self = NM_MANAGER (user_data);
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
GetSecretsInfo *info = NULL;
- NMConnectionScope scope;
GSList *iter;
g_return_val_if_fail (connection != NULL, FALSE);
@@ -2723,14 +1971,8 @@ provider_get_secrets (NMSecretsProviderInterface *provider,
}
/* Build up the new secrets request */
- scope = nm_connection_get_scope (connection);
- if (scope == NM_CONNECTION_SCOPE_SYSTEM) {
- info = system_get_secrets (self, provider, connection, setting_name,
- request_new, caller_id, hint1, hint2);
- } else if (scope == NM_CONNECTION_SCOPE_USER) {
- info = user_get_secrets (self, provider, connection, setting_name,
- request_new, caller_id, hint1, hint2);
- }
+ info = system_get_secrets (self, provider, connection, setting_name,
+ request_new, caller_id, hint1, hint2);
if (info)
priv->secrets_calls = g_slist_append (priv->secrets_calls, info);
@@ -2777,27 +2019,6 @@ internal_activate_device (NMManager *manager,
return success ? nm_act_request_get_active_connection_path (req) : NULL;
}
-static gboolean
-wait_for_connection_expired (gpointer data)
-{
- PendingActivation *pending = data;
- GError *error = NULL;
-
- g_return_val_if_fail (pending != NULL, FALSE);
-
- nm_log_warn (LOGD_CORE, "connection %s (scope %d) failed to activate (timeout)",
- pending->connection_path, pending->scope);
-
- nm_manager_pending_activation_remove (pending->manager, pending);
-
- error = g_error_new_literal (NM_MANAGER_ERROR,
- NM_MANAGER_ERROR_UNKNOWN_CONNECTION,
- "Connection was not provided by any settings service");
- pending_activation_destroy (pending, error, NULL);
- g_error_free (error);
- return FALSE;
-}
-
const char *
nm_manager_activate_connection (NMManager *manager,
NMConnection *connection,
@@ -2907,23 +2128,12 @@ nm_manager_activate_connection (NMManager *manager,
return path;
}
-static PendingActivation *
-nm_manager_pending_activation_find (NMManager *self,
- const char *path,
- NMConnectionScope scope)
-{
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- GSList *iter;
-
- for (iter = priv->pending_activations; iter; iter = g_slist_next (iter)) {
- PendingActivation *pending = iter->data;
-
- if (!strcmp (pending->connection_path, path) && (pending->scope == scope))
- return pending;
- }
- return NULL;
-}
-
+/*
+ * TODO this function was created and named in the era of user settings, where
+ * we could get activation requests for a connection before we got the settings
+ * data of that connection. Now that user settings are gone, flatten or rename
+ * it.
+ */
static void
check_pending_ready (NMManager *self, PendingActivation *pending)
{
@@ -2931,16 +2141,9 @@ check_pending_ready (NMManager *self, PendingActivation *pending)
const char *path = NULL;
GError *error = NULL;
- if (!pending->have_connection || !pending->authorized)
- return;
+ /* Ok, we're authorized */
- /* Ok, we're authorized and the connection is available */
-
- nm_manager_pending_activation_remove (self, pending);
-
- connection = nm_manager_get_connection_by_object_path (self,
- pending->scope,
- pending->connection_path);
+ connection = nm_manager_get_connection_by_object_path (self, pending->connection_path);
if (!connection) {
error = g_error_new_literal (NM_MANAGER_ERROR,
NM_MANAGER_ERROR_UNKNOWN_CONNECTION,
@@ -2955,8 +2158,8 @@ check_pending_ready (NMManager *self, PendingActivation *pending)
TRUE,
&error);
if (!path) {
- nm_log_warn (LOGD_CORE, "connection (%d) %s failed to activate: (%d) %s",
- pending->scope, pending->connection_path, error->code, error->message);
+ nm_log_warn (LOGD_CORE, "connection %s failed to activate: (%d) %s",
+ pending->connection_path, error->code, error->message);
} else
g_object_notify (G_OBJECT (pending->manager), NM_MANAGER_ACTIVE_CONNECTIONS);
@@ -2966,68 +2169,27 @@ out:
}
static void
-connection_added_default_handler (NMManager *self,
- NMConnection *connection,
- NMConnectionScope scope)
-{
- PendingActivation *pending;
-
- pending = nm_manager_pending_activation_find (self,
- nm_connection_get_path (connection),
- scope);
- if (pending) {
- pending->have_connection = TRUE;
- check_pending_ready (self, pending);
- }
-}
-
-static void
activation_auth_done (PendingActivation *pending, GError *error)
{
if (error) {
- nm_manager_pending_activation_remove (pending->manager, pending);
pending_activation_destroy (pending, error, NULL);
return;
} else {
pending->authorized = TRUE;
- /* Now that we're authorized, if the connection hasn't shown up yet,
- * start a timer and wait for it.
- */
- if (!pending->have_connection && !pending->timeout_id)
- pending->timeout_id = g_timeout_add_seconds (5, wait_for_connection_expired, pending);
-
check_pending_ready (pending->manager, pending);
}
}
static void
impl_manager_activate_connection (NMManager *self,
- const char *service_name,
const char *connection_path,
const char *device_path,
const char *specific_object_path,
DBusGMethodInvocation *context)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- NMConnectionScope scope = NM_CONNECTION_SCOPE_UNKNOWN;
PendingActivation *pending;
- GError *error = NULL;
-
- if (!strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS))
- scope = NM_CONNECTION_SCOPE_USER;
- else if (!strcmp (service_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS))
- scope = NM_CONNECTION_SCOPE_SYSTEM;
- else {
- error = g_error_new_literal (NM_MANAGER_ERROR,
- NM_MANAGER_ERROR_INVALID_SERVICE,
- "Invalid settings service name");
- dbus_g_method_return_error (context, error);
- nm_log_warn (LOGD_CORE, "connection (%d) %s failed to activate: (%d) %s",
- scope, connection_path, error->code, error->message);
- g_error_free (error);
- return;
- }
/* Need to check the caller's permissions and stuff before we can
* activate the connection.
@@ -3036,16 +2198,11 @@ impl_manager_activate_connection (NMManager *self,
priv->authority,
context,
device_path,
- scope,
connection_path,
specific_object_path,
activation_auth_done);
- priv->pending_activations = g_slist_prepend (priv->pending_activations, pending);
- if (nm_manager_get_connection_by_object_path (self, scope, connection_path))
- pending->have_connection = TRUE;
-
- pending_activation_check_authorized (pending, priv->dbus_mgr, priv->user_proxy);
+ pending_activation_check_authorized (pending, priv->dbus_mgr);
}
gboolean
@@ -3097,37 +2254,6 @@ done:
}
static void
-deactivate_user_auth_done_cb (NMAuthChain *chain,
- GError *error,
- DBusGMethodInvocation *context,
- gpointer user_data)
-{
- NMManager *self = NM_MANAGER (user_data);
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- GError *ret_error = NULL;
- NMAuthCallResult result;
-
- priv->auth_chains = g_slist_remove (priv->auth_chains, chain);
-
- result = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS));
- ret_error = deactivate_disconnect_check_error (error, result, "Deactivate");
- if (!ret_error) {
- /* Everything authorized, deactivate the connection */
- if (nm_manager_deactivate_connection (self,
- nm_auth_chain_get_data (chain, "path"),
- NM_DEVICE_STATE_REASON_USER_REQUESTED,
- &ret_error))
- dbus_g_method_return (context);
- }
-
- if (ret_error)
- dbus_g_method_return_error (context, ret_error);
- g_clear_error (&ret_error);
-
- nm_auth_chain_unref (chain);
-}
-
-static void
deactivate_net_auth_done_cb (NMAuthChain *chain,
GError *error,
DBusGMethodInvocation *context,
@@ -3138,7 +2264,6 @@ deactivate_net_auth_done_cb (NMAuthChain *chain,
GError *ret_error = NULL;
NMAuthCallResult result;
const char *active_path;
- NMConnectionScope scope;
priv->auth_chains = g_slist_remove (priv->auth_chains, chain);
@@ -3150,32 +2275,15 @@ deactivate_net_auth_done_cb (NMAuthChain *chain,
goto done;
}
- /* If it's a system connection, we're done */
active_path = nm_auth_chain_get_data (chain, "path");
- scope = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, "scope"));
- if (scope == NM_CONNECTION_SCOPE_USER) {
- NMAuthChain *user_chain;
-
- /* It's a user connection, so we need to ensure the caller is
- * authorized to manipulate user connections.
- */
- user_chain = nm_auth_chain_new (priv->authority, context, NULL, deactivate_user_auth_done_cb, self);
- g_assert (user_chain);
- priv->auth_chains = g_slist_append (priv->auth_chains, user_chain);
-
- nm_auth_chain_set_data (user_chain, "path", g_strdup (active_path), g_free);
- nm_auth_chain_set_data (user_chain, "scope", GUINT_TO_POINTER (scope), NULL);
- nm_auth_chain_add_call (user_chain, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS, TRUE);
- } else {
- if (!nm_manager_deactivate_connection (self,
- active_path,
- NM_DEVICE_STATE_REASON_USER_REQUESTED,
- &ret_error)) {
- dbus_g_method_return_error (context, ret_error);
- g_clear_error (&ret_error);
- } else
- dbus_g_method_return (context);
- }
+ if (!nm_manager_deactivate_connection (self,
+ active_path,
+ NM_DEVICE_STATE_REASON_USER_REQUESTED,
+ &ret_error)) {
+ dbus_g_method_return_error (context, ret_error);
+ g_clear_error (&ret_error);
+ } else
+ dbus_g_method_return (context);
done:
nm_auth_chain_unref (chain);
@@ -3192,7 +2300,6 @@ impl_manager_deactivate_connection (NMManager *self,
GSList *iter;
NMAuthChain *chain;
gulong sender_uid = G_MAXULONG;
- NMConnectionScope scope;
const char *error_desc = NULL;
/* Check for device connections first */
@@ -3226,13 +2333,10 @@ impl_manager_deactivate_connection (NMManager *self,
/* Need to check the caller's permissions and stuff before we can
* deactivate the connection.
*/
- scope = nm_connection_get_scope (connection);
- if (!check_user_authorized (priv->dbus_mgr,
- priv->user_proxy,
- context,
- scope,
- &sender_uid,
- &error_desc)) {
+ if (!nm_auth_get_caller_uid (context,
+ priv->dbus_mgr,
+ &sender_uid,
+ &error_desc)) {
error = g_error_new_literal (NM_MANAGER_ERROR,
NM_MANAGER_ERROR_PERMISSION_DENIED,
error_desc);
@@ -3261,7 +2365,6 @@ impl_manager_deactivate_connection (NMManager *self,
priv->auth_chains = g_slist_append (priv->auth_chains, chain);
nm_auth_chain_set_data (chain, "path", g_strdup (active_path), g_free);
- nm_auth_chain_set_data (chain, "scope", GUINT_TO_POINTER (scope), NULL);
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, TRUE);
}
@@ -3616,60 +2719,8 @@ impl_manager_enable (NMManager *self,
/* Permissions */
static void
-user_proxy_permissions_changed_done (NMAuthChain *chain,
- GError *error,
- DBusGMethodInvocation *context,
- gpointer user_data)
-{
- NMManager *self = NM_MANAGER (user_data);
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- gboolean authorized = FALSE;
-
- priv->auth_chains = g_slist_remove (priv->auth_chains, chain);
-
- if (error) {
- nm_log_warn (LOGD_USER_SET, "User connections unavailable: (%d) %s",
- error->code, error->message ? error->message : "(unknown)");
- } else
- authorized = user_settings_authorized (self, chain);
-
- if (authorized) {
- /* User connections are authorized */
- if (!priv->user_proxy)
- user_proxy_init (self);
- } else
- user_proxy_cleanup (self, TRUE);
-
- nm_auth_chain_unref (chain);
-}
-
-static void
pk_authority_changed_cb (GObject *object, gpointer user_data)
{
- NMManager *self = NM_MANAGER (user_data);
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
- NMAuthChain *chain;
-
- /* If the user settings service wasn't previously authorized, we wouldn't
- * care about it. But it might be authorized now, so lets check.
- */
- if (!priv->user_proxy)
- user_proxy_init (self);
- else {
- /* Otherwise the user settings permissions could have changed so we
- * need to recheck them.
- */
- chain = nm_auth_chain_new (priv->authority,
- NULL,
- priv->user_proxy,
- user_proxy_permissions_changed_done,
- self);
- priv->auth_chains = g_slist_prepend (priv->auth_chains, chain);
-
- nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS, FALSE);
- nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, FALSE);
- }
-
/* Let clients know they should re-check their authorization */
g_signal_emit (NM_MANAGER (user_data), signals[CHECK_PERMISSIONS], 0);
}
@@ -3717,8 +2768,11 @@ get_permissions_done_cb (NMAuthChain *chain,
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_SLEEP_WAKE);
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI);
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN);
- get_perm_add_result (chain, results, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS);
get_perm_add_result (chain, results, NM_AUTH_PERMISSION_NETWORK_CONTROL);
+ get_perm_add_result (chain, results, NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED);
+ get_perm_add_result (chain, results, NM_AUTH_PERMISSION_WIFI_SHARE_OPEN);
+ get_perm_add_result (chain, results, NM_AUTH_PERMISSION_SETTINGS_CONNECTION_MODIFY);
+ get_perm_add_result (chain, results, NM_AUTH_PERMISSION_SETTINGS_HOSTNAME_MODIFY);
dbus_g_method_return (context, results);
g_hash_table_destroy (results);
}
@@ -3744,8 +2798,11 @@ impl_manager_get_permissions (NMManager *self,
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_SLEEP_WAKE, FALSE);
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_ENABLE_DISABLE_WIFI, FALSE);
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_ENABLE_DISABLE_WWAN, FALSE);
- nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS, FALSE);
nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, FALSE);
+ nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED, FALSE);
+ nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_WIFI_SHARE_OPEN, FALSE);
+ nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_SETTINGS_CONNECTION_MODIFY, FALSE);
+ nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_SETTINGS_HOSTNAME_MODIFY, FALSE);
}
/* Legacy 0.6 compatibility interface */
@@ -3792,15 +2849,6 @@ impl_manager_set_logging (NMManager *manager,
/* Connections */
-gboolean
-nm_manager_auto_user_connections_allowed (NMManager *self)
-{
- NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
-
- return priv->user_net_perm == NM_AUTH_CALL_RESULT_YES
- && priv->user_con_perm == NM_AUTH_CALL_RESULT_YES;
-}
-
static int
connection_sort (gconstpointer pa, gconstpointer pb)
{
@@ -3839,8 +2887,7 @@ connections_to_slist (gpointer key, gpointer value, gpointer user_data)
* unref the connections in the list and destroy the list.
*/
GSList *
-nm_manager_get_connections (NMManager *manager,
- NMConnectionScope scope)
+nm_manager_get_connections (NMManager *manager)
{
NMManagerPrivate *priv;
GSList *list = NULL;
@@ -3848,18 +2895,12 @@ nm_manager_get_connections (NMManager *manager,
g_return_val_if_fail (NM_IS_MANAGER (manager), NULL);
priv = NM_MANAGER_GET_PRIVATE (manager);
- if (scope == NM_CONNECTION_SCOPE_USER)
- g_hash_table_foreach (priv->user_connections, connections_to_slist, &list);
- else if (scope == NM_CONNECTION_SCOPE_SYSTEM)
- g_hash_table_foreach (priv->system_connections, connections_to_slist, &list);
- else
- nm_log_err (LOGD_CORE, "unknown NMConnectionScope %d", scope);
+ g_hash_table_foreach (priv->system_connections, connections_to_slist, &list);
return list;
}
NMConnection *
nm_manager_get_connection_by_object_path (NMManager *manager,
- NMConnectionScope scope,
const char *path)
{
NMManagerPrivate *priv;
@@ -3869,12 +2910,7 @@ nm_manager_get_connection_by_object_path (NMManager *manager,
g_return_val_if_fail (path != NULL, NULL);
priv = NM_MANAGER_GET_PRIVATE (manager);
- if (scope == NM_CONNECTION_SCOPE_USER)
- connection = (NMConnection *) g_hash_table_lookup (priv->user_connections, path);
- else if (scope == NM_CONNECTION_SCOPE_SYSTEM)
- connection = (NMConnection *) g_hash_table_lookup (priv->system_connections, path);
- else
- nm_log_err (LOGD_CORE, "unknown NMConnectionScope %d", scope);
+ connection = (NMConnection *) g_hash_table_lookup (priv->system_connections, path);
return connection;
}
@@ -3917,14 +2953,11 @@ nm_manager_start (NMManager *self)
system_unmanaged_devices_changed_cb (priv->sys_settings, NULL, self);
system_hostname_changed_cb (priv->sys_settings, NULL, self);
- system_query_connections (self);
- /* Get user connections if the user settings service is around, otherwise
- * they will be queried when the user settings service shows up on the
- * bus in nm_manager_name_owner_changed().
- */
- if (nm_dbus_manager_name_has_owner (priv->dbus_mgr, NM_DBUS_SERVICE_USER_SETTINGS))
- user_proxy_init (self);
+ /* Get all connections */
+ nm_sysconfig_settings_for_each_connection (NM_MANAGER_GET_PRIVATE (self)->sys_settings,
+ _new_connection,
+ self);
nm_udev_manager_query_devices (priv->udev_mgr);
bluez_manager_resync_devices (self);
@@ -4177,12 +3210,11 @@ nm_manager_get (const char *config_file,
return NULL;
}
- priv->sys_settings = nm_sysconfig_settings_new (config_file, plugins, bus, error);
+ priv->sys_settings = nm_sysconfig_settings_new (config_file, plugins, error);
if (!priv->sys_settings) {
g_object_unref (singleton);
return NULL;
}
- nm_settings_service_export (NM_SETTINGS_SERVICE (priv->sys_settings));
priv->config_file = g_strdup (config_file);
@@ -4195,7 +3227,7 @@ nm_manager_get (const char *config_file,
g_signal_connect (priv->sys_settings, "notify::" NM_SYSCONFIG_SETTINGS_UNMANAGED_SPECS,
G_CALLBACK (system_unmanaged_devices_changed_cb), singleton);
- g_signal_connect (priv->sys_settings, "notify::" NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME,
+ g_signal_connect (priv->sys_settings, "notify::" NM_SYSCONFIG_SETTINGS_HOSTNAME,
G_CALLBACK (system_hostname_changed_cb), singleton);
g_signal_connect (priv->sys_settings, "new-connection",
G_CALLBACK (system_new_connection_cb), singleton);
@@ -4204,11 +3236,6 @@ nm_manager_get (const char *config_file,
NM_DBUS_PATH,
G_OBJECT (singleton));
- g_signal_connect (priv->dbus_mgr,
- "name-owner-changed",
- G_CALLBACK (nm_manager_name_owner_changed),
- singleton);
-
priv->udev_mgr = nm_udev_manager_new ();
g_signal_connect (priv->udev_mgr,
"device-added",
@@ -4243,7 +3270,6 @@ dispose (GObject *object)
{
NMManager *manager = NM_MANAGER (object);
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
- GSList *iter;
DBusGConnection *bus;
DBusConnection *dbus_connection;
@@ -4253,11 +3279,6 @@ dispose (GObject *object)
}
priv->disposed = TRUE;
- for (iter = priv->pending_activations; iter; iter = g_slist_next (iter))
- pending_activation_destroy ((PendingActivation *) iter->data, NULL, NULL);
- g_slist_free (priv->pending_activations);
- priv->pending_activations = NULL;
-
g_slist_foreach (priv->auth_chains, (GFunc) nm_auth_chain_unref, NULL);
g_slist_free (priv->auth_chains);
g_object_unref (priv->authority);
@@ -4272,10 +3293,6 @@ dispose (GObject *object)
TRUE);
}
- user_proxy_cleanup (manager, FALSE);
- g_hash_table_destroy (priv->user_connections);
- priv->user_connections = NULL;
-
g_hash_table_foreach (priv->system_connections, emit_removed, manager);
g_hash_table_remove_all (priv->system_connections);
g_hash_table_destroy (priv->system_connections);
@@ -4489,11 +3506,6 @@ nm_manager_init (NMManager *manager)
priv->dbus_mgr = nm_dbus_manager_get ();
- priv->user_connections = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- g_object_unref);
-
priv->system_connections = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
@@ -4593,8 +3605,6 @@ nm_manager_class_init (NMManagerClass *manager_class)
g_type_class_add_private (manager_class, sizeof (NMManagerPrivate));
/* virtual methods */
- manager_class->connection_added = connection_added_default_handler;
-
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->dispose = dispose;
@@ -4720,8 +3730,8 @@ nm_manager_class_init (NMManagerClass *manager_class)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMManagerClass, connections_added),
NULL, NULL,
- g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, 1, G_TYPE_UINT);
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
signals[CONNECTION_ADDED] =
g_signal_new ("connection-added",
@@ -4729,8 +3739,8 @@ nm_manager_class_init (NMManagerClass *manager_class)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMManagerClass, connection_added),
NULL, NULL,
- _nm_marshal_VOID__OBJECT_UINT,
- G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT);
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, G_TYPE_OBJECT);
signals[CONNECTION_UPDATED] =
g_signal_new ("connection-updated",
@@ -4738,8 +3748,8 @@ nm_manager_class_init (NMManagerClass *manager_class)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMManagerClass, connection_updated),
NULL, NULL,
- _nm_marshal_VOID__OBJECT_UINT,
- G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT);
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, G_TYPE_OBJECT);
signals[CONNECTION_REMOVED] =
g_signal_new ("connection-removed",
@@ -4747,8 +3757,8 @@ nm_manager_class_init (NMManagerClass *manager_class)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMManagerClass, connection_removed),
NULL, NULL,
- _nm_marshal_VOID__OBJECT_UINT,
- G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT);
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, G_TYPE_OBJECT);
signals[CHECK_PERMISSIONS] =
g_signal_new ("check-permissions",
diff --git a/src/nm-manager.h b/src/nm-manager.h
index 280d554b2b..5bf92d6028 100644
--- a/src/nm-manager.h
+++ b/src/nm-manager.h
@@ -61,19 +61,16 @@ typedef struct {
void (*state_changed) (NMManager *manager, guint state);
void (*properties_changed) (NMManager *manager, GHashTable *properties);
- void (*connections_added) (NMManager *manager, NMConnectionScope scope);
+ void (*connections_added) (NMManager *manager);
void (*connection_added) (NMManager *manager,
- NMConnection *connection,
- NMConnectionScope scope);
+ NMConnection *connection);
void (*connection_updated) (NMManager *manager,
- NMConnection *connection,
- NMConnectionScope scope);
+ NMConnection *connection);
void (*connection_removed) (NMManager *manager,
- NMConnection *connection,
- NMConnectionScope scope);
+ NMConnection *connection);
} NMManagerClass;
GType nm_manager_get_type (void);
@@ -110,12 +107,9 @@ NMState nm_manager_get_state (NMManager *manager);
/* Connections */
-GSList *nm_manager_get_connections (NMManager *manager, NMConnectionScope scope);
-
-gboolean nm_manager_auto_user_connections_allowed (NMManager *manager);
+GSList *nm_manager_get_connections (NMManager *manager);
NMConnection * nm_manager_get_connection_by_object_path (NMManager *manager,
- NMConnectionScope scope,
const char *path);
GPtrArray * nm_manager_get_active_connections_by_connection (NMManager *manager,
diff --git a/src/nm-policy.c b/src/nm-policy.c
index e8a18d0262..df7689b725 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -739,10 +739,7 @@ auto_activate_device (gpointer user_data)
if (nm_device_get_act_request (data->device))
goto out;
- /* System connections first, then user connections */
- connections = nm_manager_get_connections (policy->manager, NM_CONNECTION_SCOPE_SYSTEM);
- if (nm_manager_auto_user_connections_allowed (policy->manager))
- connections = g_slist_concat (connections, nm_manager_get_connections (policy->manager, NM_CONNECTION_SCOPE_USER));
+ connections = nm_manager_get_connections (policy->manager);
/* Remove connections that are in the invalid list. */
iter = connections;
@@ -833,8 +830,7 @@ sleeping_changed (NMManager *manager, GParamSpec *pspec, gpointer user_data)
/* Clear the invalid flag on all connections so they'll get retried on wakeup */
if (sleeping || !enabled) {
- connections = nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_SYSTEM);
- connections = g_slist_concat (connections, nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_USER));
+ connections = nm_manager_get_connections (manager);
for (iter = connections; iter; iter = g_slist_next (iter))
g_object_set_data (G_OBJECT (iter->data), INVALID_TAG, NULL);
g_slist_free (connections);
@@ -1048,7 +1044,6 @@ schedule_activate_all (NMPolicy *policy)
static void
connections_added (NMManager *manager,
- NMConnectionScope scope,
gpointer user_data)
{
schedule_activate_all ((NMPolicy *) user_data);
@@ -1057,7 +1052,6 @@ connections_added (NMManager *manager,
static void
connection_added (NMManager *manager,
NMConnection *connection,
- NMConnectionScope scope,
gpointer user_data)
{
schedule_activate_all ((NMPolicy *) user_data);
@@ -1066,7 +1060,6 @@ connection_added (NMManager *manager,
static void
connection_updated (NMManager *manager,
NMConnection *connection,
- NMConnectionScope scope,
gpointer user_data)
{
/* Clear the invalid tag on the connection if it got updated. */
@@ -1078,7 +1071,6 @@ connection_updated (NMManager *manager,
static void
connection_removed (NMManager *manager,
NMConnection *connection,
- NMConnectionScope scope,
gpointer user_data)
{
NMSettingConnection *s_con;
diff --git a/src/system-settings/Makefile.am b/src/system-settings/Makefile.am
index 0b92228f57..5f18623ce6 100644
--- a/src/system-settings/Makefile.am
+++ b/src/system-settings/Makefile.am
@@ -9,7 +9,8 @@ INCLUDES = -I${top_srcdir} \
noinst_LTLIBRARIES = libsystem-settings.la
BUILT_SOURCES = \
- nm-settings-system-glue.h
+ nm-settings-glue.h \
+ nm-sysconfig-connection-glue.h
libsystem_settings_la_SOURCES = \
nm-sysconfig-settings.c \
@@ -24,7 +25,11 @@ libsystem_settings_la_SOURCES = \
nm-sysconfig-connection.c \
nm-sysconfig-connection.h \
nm-default-wired-connection.c \
- nm-default-wired-connection.h
+ nm-default-wired-connection.h \
+ nm-session-info.c \
+ nm-session-info.h \
+ nm-session-manager.c \
+ nm-session-manager.h
libsystem_settings_la_CPPFLAGS = \
$(DBUS_CFLAGS) \
@@ -53,8 +58,12 @@ libsystem_settings_la_LIBADD = \
libsystem_settings_la_LDFLAGS = -rdynamic
-nm-settings-system-glue.h: $(top_srcdir)/introspection/nm-settings-system.xml
- $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings_system --mode=glib-server --output=$@ $<
+
+nm-settings-glue.h: $(top_srcdir)/introspection/nm-settings.xml
+ $(AM_V_GEN) dbus-binding-tool --prefix=nm_settings --mode=glib-server --output=$@ $<
+
+nm-sysconfig-connection-glue.h: $(top_srcdir)/introspection/nm-sysconfig-connection.xml
+ $(AM_V_GEN) dbus-binding-tool --prefix=nm_sysconfig_connection --mode=glib-server --output=$@ $<
CLEANFILES = \
$(BUILT_SOURCES)
diff --git a/src/system-settings/nm-default-wired-connection.c b/src/system-settings/nm-default-wired-connection.c
index 1cda3d9e23..b2c22baf3c 100644
--- a/src/system-settings/nm-default-wired-connection.c
+++ b/src/system-settings/nm-default-wired-connection.c
@@ -31,15 +31,8 @@
#include "nm-dbus-glib-types.h"
#include "nm-marshal.h"
#include "nm-default-wired-connection.h"
-#include "nm-settings-connection-interface.h"
-static NMSettingsConnectionInterface *parent_settings_connection_iface;
-
-static void settings_connection_interface_init (NMSettingsConnectionInterface *iface);
-
-G_DEFINE_TYPE_EXTENDED (NMDefaultWiredConnection, nm_default_wired_connection, NM_TYPE_SYSCONFIG_CONNECTION, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
- settings_connection_interface_init))
+G_DEFINE_TYPE (NMDefaultWiredConnection, nm_default_wired_connection, NM_TYPE_SYSCONFIG_CONNECTION)
#define NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEFAULT_WIRED_CONNECTION, NMDefaultWiredConnectionPrivate))
@@ -91,10 +84,10 @@ nm_default_wired_connection_get_device (NMDefaultWiredConnection *wired)
return NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (wired)->device;
}
-static gboolean
-update (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceUpdateFunc callback,
- gpointer user_data)
+static void
+commit_changes (NMSysconfigConnection *connection,
+ NMSysconfigConnectionCommitFunc callback,
+ gpointer user_data)
{
NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection);
@@ -105,32 +98,25 @@ update (NMSettingsConnectionInterface *connection,
g_signal_emit (self, signals[TRY_UPDATE], 0);
callback (connection, NULL, user_data);
g_object_unref (connection);
- return TRUE;
}
-static gboolean
-do_delete (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceDeleteFunc callback,
+static void
+do_delete (NMSysconfigConnection *connection,
+ NMSysconfigConnectionDeleteFunc callback,
gpointer user_data)
{
NMDefaultWiredConnection *self = NM_DEFAULT_WIRED_CONNECTION (connection);
NMDefaultWiredConnectionPrivate *priv = NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (connection);
g_signal_emit (self, signals[DELETED], 0, priv->mac);
- return parent_settings_connection_iface->delete (connection, callback, user_data);
+ NM_SYSCONFIG_CONNECTION_CLASS (nm_default_wired_connection_parent_class)->delete (connection,
+ callback,
+ user_data);
}
/****************************************************************/
static void
-settings_connection_interface_init (NMSettingsConnectionInterface *iface)
-{
- parent_settings_connection_iface = g_type_interface_peek_parent (iface);
- iface->update = update;
- iface->delete = do_delete;
-}
-
-static void
nm_default_wired_connection_init (NMDefaultWiredConnection *self)
{
}
@@ -251,6 +237,7 @@ static void
nm_default_wired_connection_class_init (NMDefaultWiredConnectionClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ NMSysconfigConnectionClass *sysconfig_class = NM_SYSCONFIG_CONNECTION_CLASS (klass);
g_type_class_add_private (klass, sizeof (NMDefaultWiredConnectionPrivate));
@@ -259,6 +246,8 @@ nm_default_wired_connection_class_init (NMDefaultWiredConnectionClass *klass)
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->finalize = finalize;
+ sysconfig_class->commit_changes = commit_changes;
+ sysconfig_class->delete = do_delete;
/* Properties */
g_object_class_install_property
diff --git a/src/system-settings/nm-polkit-helpers.h b/src/system-settings/nm-polkit-helpers.h
index a37c2eebaa..dfe9ecefc3 100644
--- a/src/system-settings/nm-polkit-helpers.h
+++ b/src/system-settings/nm-polkit-helpers.h
@@ -25,11 +25,6 @@
#include <config.h>
#include <polkit/polkit.h>
-#define NM_SYSCONFIG_POLICY_ACTION_CONNECTION_MODIFY "org.freedesktop.network-manager-settings.system.modify"
-#define NM_SYSCONFIG_POLICY_ACTION_WIFI_SHARE_PROTECTED "org.freedesktop.network-manager-settings.system.wifi.share.protected"
-#define NM_SYSCONFIG_POLICY_ACTION_WIFI_SHARE_OPEN "org.freedesktop.network-manager-settings.system.wifi.share.open"
-#define NM_SYSCONFIG_POLICY_ACTION_HOSTNAME_MODIFY "org.freedesktop.network-manager-settings.system.hostname.modify"
-
/* Fix for polkit 0.97 and later */
#if !HAVE_POLKIT_AUTHORITY_GET_SYNC
static inline PolkitAuthority *
diff --git a/src/system-settings/nm-session-info.c b/src/system-settings/nm-session-info.c
new file mode 100644
index 0000000000..3faf407dd6
--- /dev/null
+++ b/src/system-settings/nm-session-info.c
@@ -0,0 +1,189 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager user session tracker -- per-session data
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2010 Daniel Gnoutcheff <daniel@gnoutcheff.name>
+ */
+
+#include "nm-session-info.h"
+#include "nm-dbus-glib-types.h"
+#include "nm-utils.h"
+
+G_DEFINE_TYPE (NMSessionInfo, nm_session_info, G_TYPE_OBJECT);
+
+typedef struct {
+ char *id;
+ char *user;
+ gboolean is_default;
+} NMSessionInfoPrivate;
+
+#define NM_SESSION_INFO_GET_PRIVATE(self) (G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_SESSION_INFO, NMSessionInfoPrivate))
+
+enum {
+ PROP_0,
+ PROP_ID,
+ PROP_USER,
+ PROP_IS_DEFAULT
+};
+
+char *
+nm_session_info_get_id (NMSessionInfo *self)
+{
+ g_return_val_if_fail (NM_IS_SESSION_INFO (self), NULL);
+
+ return NM_SESSION_INFO_GET_PRIVATE (self)->id;
+}
+
+char *
+nm_session_info_get_unix_user (NMSessionInfo *self)
+{
+ g_return_val_if_fail (NM_IS_SESSION_INFO (self), NULL);
+
+ return NM_SESSION_INFO_GET_PRIVATE (self)->user;
+}
+
+gboolean
+nm_session_info_is_default_session (NMSessionInfo *self)
+{
+ g_return_val_if_fail (NM_IS_SESSION_INFO (self), FALSE);
+
+ return NM_SESSION_INFO_GET_PRIVATE (self)->is_default;
+}
+
+static void
+set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ NMSessionInfoPrivate *priv = NM_SESSION_INFO_GET_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_ID:
+ g_free (priv->id);
+ priv->id = g_value_dup_string (value);
+ break;
+ case PROP_USER:
+ g_free (priv->user);
+ priv->user = g_value_dup_string (value);
+ break;
+ case PROP_IS_DEFAULT:
+ priv->is_default = g_value_get_boolean (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ NMSessionInfoPrivate *priv = NM_SESSION_INFO_GET_PRIVATE (object);
+
+ switch (property_id) {
+ case PROP_ID:
+ g_value_set_string (value, priv->id);
+ break;
+ case PROP_USER:
+ g_value_set_string (value, priv->user);
+ break;
+ case PROP_IS_DEFAULT:
+ g_value_set_boolean (value, priv->is_default);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+nm_session_info_init (NMSessionInfo *self) {
+}
+
+static void
+dispose (GObject *object)
+{
+ NMSessionInfoPrivate *priv = NM_SESSION_INFO_GET_PRIVATE (object);
+
+ if (priv->id) {
+ g_free (priv->id);
+ priv->id = NULL;
+ }
+
+ if (priv->user) {
+ g_free (priv->user);
+ priv->user = NULL;
+ }
+
+ G_OBJECT_CLASS (nm_session_info_parent_class)->dispose (object);
+}
+
+static void
+nm_session_info_class_init (NMSessionInfoClass *info_class) {
+ GObjectClass *g_class = G_OBJECT_CLASS (info_class);
+
+ g_type_class_add_private (g_class, sizeof(NMSessionInfoPrivate));
+ g_class->set_property = set_property;
+ g_class->get_property = get_property;
+ g_class->dispose = dispose;
+
+ g_object_class_install_property
+ (g_class, PROP_ID,
+ g_param_spec_string (
+ NM_SESSION_INFO_ID,
+ "ConsoleKitSID",
+ "ConsoleKit session ID, or \"[none]\" if this is the \"default\" "
+ "session.",
+ NM_SESSION_INFO_DEFAULT_ID,
+ G_PARAM_READABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (g_class, PROP_USER,
+ g_param_spec_string (
+ NM_SESSION_INFO_UNIX_USER,
+ "UnixUser",
+ "String name of the unix user who owns this session, or NULL if "
+ "this is the default session.",
+ NULL,
+ G_PARAM_READABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (g_class, PROP_IS_DEFAULT,
+ g_param_spec_boolean (
+ NM_SESSION_INFO_IS_DEFAULT,
+ "IsDefaultSession",
+ "Indicates if this NMSessionInfo instance represents the "
+ "\"default\" session, the session containing all processes that "
+ "do not belong to a ConsoleKit-recognized session.",
+ TRUE,
+ G_PARAM_READABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_signal_new (
+ NM_SESSION_INFO_REMOVED,
+ NM_TYPE_SESSION_INFO,
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+}
diff --git a/src/system-settings/nm-session-info.h b/src/system-settings/nm-session-info.h
new file mode 100644
index 0000000000..aebe4f59b9
--- /dev/null
+++ b/src/system-settings/nm-session-info.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager user session tracker -- per-session data
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2010 Daniel Gnoutcheff <daniel@gnoutcheff.name>
+ */
+
+#ifndef NM_SESSION_INFO_H
+#define NM_SESSION_INFO_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define NM_TYPE_SESSION_INFO (nm_session_info_get_type ())
+#define NM_SESSION_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SESSION_INFO, NMSessionInfo))
+#define NM_SESSION_INFO_CLASS(class_struct) (G_TYPE_CHECK_CLASS_CAST ((class_struct), NM_TYPE_SESSION_INFO, NMSessionInfoClass))
+#define NM_IS_SESSION_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SESSION_INFO))
+#define NM_IS_SESSION_INFO_CLASS(class_struct) (G_TYPE_CHECK_CLASS_TYPE ((class_struct), NM_TYPE_SESSION_INFO))
+#define NM_SESSION_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SESSION_INFO, NMSessionInfoClass))
+
+#define NM_SESSION_INFO_ID "session-id"
+#define NM_SESSION_INFO_UNIX_USER "unix-user"
+#define NM_SESSION_INFO_IS_DEFAULT "is-default"
+
+#define NM_SESSION_INFO_REMOVED "removed"
+
+#define NM_SESSION_INFO_DEFAULT_ID "[none]"
+
+typedef struct {
+ GObject parent;
+} NMSessionInfo;
+
+typedef struct {
+ GObjectClass parent_class;
+} NMSessionInfoClass;
+
+GType nm_session_info_get_type (void);
+
+char * nm_session_info_get_id (NMSessionInfo *self);
+char * nm_session_info_get_unix_user (NMSessionInfo *self);
+gboolean nm_session_info_is_default_session (NMSessionInfo *self);
+
+G_END_DECLS
+
+#endif
diff --git a/src/system-settings/nm-session-manager.c b/src/system-settings/nm-session-manager.c
new file mode 100644
index 0000000000..80c4ab60e6
--- /dev/null
+++ b/src/system-settings/nm-session-manager.c
@@ -0,0 +1,752 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager user session tracker
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2010 Daniel Gnoutcheff <daniel@gnoutcheff.name>
+ */
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <grp.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <nm-utils.h>
+#include <nm-dbus-glib-types.h>
+#include "nm-dbus-manager.h"
+#include "nm-session-manager.h"
+#include "nm-logging.h"
+
+G_DEFINE_TYPE (NMSessionManager, nm_session_manager, G_TYPE_OBJECT);
+
+/* NMSessionManager data */
+typedef struct {
+ gboolean disposed;
+ gboolean initialized;
+ guint init_sessions_left;
+
+ /* The master table of NMSessionInfo instances, keyed by session id. */
+ GHashTable *sessions;
+
+ /* DBus proxy of the ConsoleKit manager */
+ DBusGProxy *ck_manager;
+
+ /* Table of PendingSessionInfo structs, representing sessions for which we
+ * are waiting for information on. Keyed by session id. */
+ GHashTable *pending_sessions;
+
+ /* List of PendingCallerInfo structs, representing ongoing
+ * get_session_of_caller calls. */
+ GSList *pending_callers;
+} NMSessionManagerPrivate;
+
+#define NM_SESSION_MANAGER_GET_PRIVATE(self) (G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_SESSION_MANAGER, NMSessionManagerPrivate))
+
+
+enum {
+ ADDED,
+ INIT_DONE,
+
+ LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL] = { 0 };
+
+
+/**** general utilities for managing callbacks *******************************/
+
+typedef struct {
+ NMSessionFunc callback;
+ gpointer user_data;
+} CallbackInfo;
+
+/* Allocate a new CallbackInfo for the given callback & data */
+static CallbackInfo *
+callback_info_new (NMSessionFunc callback, gpointer user_data)
+{
+ CallbackInfo *info = g_slice_new (CallbackInfo);
+ info->callback = callback;
+ info->user_data = user_data;
+ return info;
+}
+
+/* Run the callback represented by cb_info and free it. */
+static void
+callback_info_run (CallbackInfo *cb_info, NMSessionInfo *session, GError *error)
+{
+ if (cb_info->callback) {
+ (cb_info->callback) (session, error, cb_info->user_data);
+ }
+ g_slice_free (CallbackInfo, cb_info);
+}
+
+/* Run the callback with an error message indicating that we've been disposed. */
+static void
+callback_info_fail_disposed (CallbackInfo *cb_info)
+{
+ GError *error = g_error_new (NM_SESSION_MANAGER_ERROR,
+ NM_SESSION_MANAGER_ERROR_DISPOSED,
+ "NMSessionManager was disposed before operation completed.");
+ callback_info_run (cb_info, NULL, error);
+ g_error_free (error);
+}
+
+
+/**** get_session stuff ******************************************************/
+
+typedef struct {
+ NMSessionManager *manager;
+ DBusGProxy *session_proxy;
+ DBusGProxyCall *session_call;
+ char *session_id;
+
+ GSList *callbacks; /* List of CallbackInfo structs */
+} PendingSessionInfo;
+
+/* Called by the pending_sessions GHashTable when removing a PendingSession */
+static void
+pending_session_destroy (gpointer data)
+{
+ PendingSessionInfo *pending = (PendingSessionInfo *) data;
+
+ // FIXME this is ugly copy-and-paste
+ // If any callbacks remain, send failure messages to them.
+ while (pending->callbacks) {
+ CallbackInfo *cb_info = (CallbackInfo *) pending->callbacks->data;
+ callback_info_fail_disposed (cb_info);
+ pending->callbacks = g_slist_remove (pending->callbacks, cb_info);
+ }
+
+ g_free (pending->session_id);
+ g_object_unref (pending->session_proxy);
+ g_object_unref (pending->session_call);
+ g_slice_free (PendingSessionInfo, pending);
+}
+
+static void
+pending_session_finish (PendingSessionInfo *pending,
+ NMSessionInfo *session,
+ GError *error)
+{
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (pending->manager);
+
+ while (pending->callbacks) {
+ CallbackInfo *cb_info = (CallbackInfo *) pending->callbacks->data;
+ callback_info_run (cb_info, session, error);
+ pending->callbacks = g_slist_remove (pending->callbacks, cb_info);
+ }
+
+ g_hash_table_remove (priv->pending_sessions, pending->session_id);
+ // pending_session_destroy() will be called by GHashTable
+}
+
+static void
+pending_session_cancel (PendingSessionInfo *pending, GError *error)
+{
+ dbus_g_proxy_cancel_call (pending->session_proxy, pending->session_call);
+ pending_session_finish (pending, NULL, error);
+}
+
+static void
+get_unix_user_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
+{
+ PendingSessionInfo *pending = (PendingSessionInfo *) user_data;
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (pending->manager);
+ guint user_id;
+ struct passwd *pw_info = NULL;
+ NMSessionInfo *session = NULL;
+ GError *error = NULL;
+
+ if (!dbus_g_proxy_end_call (proxy, call_id, NULL,
+ G_TYPE_UINT, &user_id, G_TYPE_NONE)) {
+ error = g_error_new (NM_SESSION_MANAGER_ERROR,
+ NM_SESSION_MANAGER_ERROR_INFO_GATHERING_FAILED,
+ "session %s: failed to get uid",
+ pending->session_id);
+ goto out;
+ }
+
+ pw_info = getpwuid (user_id);
+ if (!pw_info) {
+ error = g_error_new (NM_SESSION_MANAGER_ERROR,
+ NM_SESSION_MANAGER_ERROR_INFO_GATHERING_FAILED,
+ "session %s: failed to get username for uid %u",
+ pending->session_id, user_id);
+ goto out;
+ }
+
+ session = g_object_new (NM_TYPE_SESSION_INFO,
+ NM_SESSION_INFO_ID, pending->session_id,
+ NM_SESSION_INFO_UNIX_USER, pw_info->pw_name,
+ NULL);
+ g_assert (session);
+
+ g_hash_table_insert (priv->sessions, nm_session_info_get_id (session), session);
+ g_signal_emit (pending->manager, signals[ADDED], 0, session);
+
+out:
+ pending_session_finish (pending, session, error);
+
+ g_clear_error (&error);
+}
+
+/* Start the process of loading information about the given session, and return
+ * the PendingSessionInfo struct that represents it.
+ */
+static PendingSessionInfo *
+pending_session_start (NMSessionManager *self, char *session_id)
+{
+ PendingSessionInfo *pending = g_slice_new (PendingSessionInfo);
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (self);
+ DBusGConnection *connection = nm_dbus_manager_get_connection (nm_dbus_manager_get ());
+
+ pending->session_id = g_strdup (session_id);
+ pending->manager = self;
+ pending->callbacks = NULL;
+
+ pending->session_proxy = dbus_g_proxy_new_for_name (connection,
+ "org.freedesktop.ConsoleKit",
+ pending->session_id,
+ "org.freedesktop.ConsoleKit.Session");
+
+ pending->session_call = dbus_g_proxy_begin_call (pending->session_proxy,
+ "GetUnixUser",
+ get_unix_user_cb,
+ pending,
+ NULL,
+ G_TYPE_INVALID);
+
+ g_hash_table_insert (priv->pending_sessions, pending->session_id, pending);
+
+ return pending;
+}
+
+static PendingSessionInfo *
+pending_session_find (NMSessionManager *self, char *session_id)
+{
+ GHashTable *pending_sessions = NM_SESSION_MANAGER_GET_PRIVATE (self)->pending_sessions;
+ return g_hash_table_lookup (pending_sessions, session_id);
+}
+
+static void
+pending_session_add_callback (PendingSessionInfo *pending, CallbackInfo *cb_info)
+{
+ pending->callbacks = g_slist_prepend (pending->callbacks, cb_info);
+}
+
+static void
+get_session_internal (NMSessionManager *self,
+ char *session_id,
+ CallbackInfo *cb_info)
+{
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (self);
+ NMSessionInfo *session;
+
+ if (priv->disposed) {
+ callback_info_fail_disposed (cb_info);
+ return;
+ }
+
+ session = g_hash_table_lookup (priv->sessions, session_id);
+ if (session) {
+ callback_info_run (cb_info, session, NULL);
+ } else {
+ PendingSessionInfo *pending = pending_session_find (self, session_id);
+ if (!pending) {
+ pending = pending_session_start (self, session_id);
+ }
+ pending_session_add_callback (pending, cb_info);
+ }
+}
+
+void
+nm_session_manager_get_session (NMSessionManager *self,
+ char *session_id,
+ NMSessionFunc callback,
+ gpointer user_data)
+{
+ CallbackInfo *cb_info;
+
+ g_return_if_fail (NM_IS_SESSION_MANAGER (self));
+ g_return_if_fail (session_id != NULL);
+ g_return_if_fail (callback != NULL);
+
+ cb_info = callback_info_new (callback, user_data);
+
+ get_session_internal (self, session_id, cb_info);
+}
+
+/**** get_sessions stuff *****************************************************/
+
+static void
+prepend_slist (gpointer key, gpointer value, gpointer user_data)
+{
+ GSList **sessions = (GSList **) user_data;
+
+ *sessions = g_slist_prepend (*sessions, value);
+}
+
+GSList *
+nm_session_manager_get_sessions (NMSessionManager *self)
+{
+ NMSessionManagerPrivate *priv;
+ GSList *sessions;
+
+ g_return_val_if_fail (NM_IS_SESSION_MANAGER (self), NULL);
+
+ priv = NM_SESSION_MANAGER_GET_PRIVATE (self);
+ g_hash_table_foreach (priv->sessions, prepend_slist, &sessions);
+
+ return sessions;
+}
+
+/**** ConsoleKit signal handling *********************************************/
+
+/* ConsoleKit reports a new session. Pull it into our cache. */
+static void
+session_added (NMSessionManager *self, char *new_session)
+{
+ nm_session_manager_get_session (self, new_session, NULL, NULL);
+}
+
+/* ConsoleKit reports that a session has been removed. */
+static void
+session_removed (NMSessionManager *self, char *removed_id)
+{
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (self);
+ NMSessionInfo *removed = g_hash_table_lookup (priv->sessions, removed_id);
+
+ if (removed) {
+ g_signal_emit_by_name (removed, NM_SESSION_INFO_REMOVED);
+ g_hash_table_remove (priv->sessions, removed_id);
+ } else {
+ PendingSessionInfo *removed_pending = pending_session_find (self, removed_id);
+ if (removed_pending) {
+ GError *error = g_error_new (NM_SESSION_MANAGER_ERROR,
+ NM_SESSION_MANAGER_ERROR_NOT_FOUND,
+ "session %s removed moments ago",
+ removed_id);
+ pending_session_cancel (removed_pending, error);
+ g_error_free (error);
+ }
+ }
+}
+
+/* A DBus signal filter for picking up ConsoleKit signals indicating that
+ * sessions have been added or removed. We use this custom message filter as
+ * we'd otherwise have to keep track of all the seats and register signal
+ * handlers in every one. */
+static DBusHandlerResult
+ck_session_signal_filter (DBusConnection *connection,
+ DBusMessage *message,
+ void *user_data)
+{
+ NMSessionManager *self = NM_SESSION_MANAGER (user_data);
+ char *session_id;
+
+ // TODO: filter by sender?
+
+ if (dbus_message_is_signal (message,
+ "org.freedesktop.ConsoleKit.Seat",
+ "SessionAdded")) {
+ if (dbus_message_get_args (message, NULL,
+ DBUS_TYPE_OBJECT_PATH, &session_id,
+ DBUS_TYPE_INVALID)) {
+ session_added (self, session_id);
+ }
+ }
+ else
+ if (dbus_message_is_signal (message,
+ "org.freedesktop.ConsoleKit.Seat",
+ "SessionRemoved")) {
+ if (dbus_message_get_args (message, NULL,
+ DBUS_TYPE_OBJECT_PATH, &session_id,
+ DBUS_TYPE_INVALID)) {
+ session_removed (self, session_id);
+ }
+ }
+
+ // If anything else registers message filters for these signals for some
+ // reason, we want to be sure not to step on them.
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+/**** get_session_of_caller stuff ********************************************/
+
+typedef struct {
+ NMSessionManager *manager;
+ CallbackInfo *cb_info;
+ DBusGProxy *bus_proxy;
+ DBusGProxy *current_call_proxy;
+ DBusGProxyCall *current_call;
+ char *caller_bus_name;
+ char *session_id;
+} PendingCallerInfo;
+
+static void
+pending_caller_free (PendingCallerInfo *info)
+{
+ if (info->bus_proxy)
+ g_object_unref (info->bus_proxy);
+
+ if (info->caller_bus_name)
+ g_free (info->caller_bus_name);
+
+ if (info->session_id)
+ g_free (info->session_id);
+
+ // cb_info gets freed when the callback it wraps is run
+
+ g_slice_free (PendingCallerInfo, info);
+}
+
+static void
+pending_caller_dispose (gpointer data)
+{
+ PendingCallerInfo *info = (PendingCallerInfo *) data;
+
+ if (info->current_call)
+ dbus_g_proxy_cancel_call (info->current_call_proxy, info->current_call);
+
+ callback_info_fail_disposed (info->cb_info);
+ pending_caller_free (info);
+}
+
+static void
+pending_caller_cb (NMSessionInfo *session, GError *error, gpointer user_data)
+{
+ PendingCallerInfo *info = (PendingCallerInfo *) user_data;
+
+ if (!session) {
+ get_session_internal (info->manager, NM_SESSION_INFO_DEFAULT_ID, info->cb_info);
+ } else {
+ callback_info_run (info->cb_info, session, error);
+ }
+
+ pending_caller_free (info);
+}
+
+static void
+pending_caller_abort (PendingCallerInfo *info, GError *error)
+{
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (info->manager);
+
+ priv->pending_callers = g_slist_remove (priv->pending_callers, info);
+ pending_caller_cb (NULL, error, info);
+}
+
+static void
+dbus_name_has_owner_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
+{
+ PendingCallerInfo *info = (PendingCallerInfo *) user_data;
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (info->manager);
+ gboolean has_owner;
+
+ if (!dbus_g_proxy_end_call (proxy, call_id, NULL,
+ G_TYPE_BOOLEAN, &has_owner, G_TYPE_INVALID)
+ || !has_owner) {
+ pending_caller_abort (info, NULL);
+ return;
+ }
+
+ info->current_call = NULL;
+ info->current_call_proxy = NULL;
+ priv->pending_callers = g_slist_remove (priv->pending_callers, info);
+
+ nm_session_manager_get_session (info->manager, info->session_id,
+ pending_caller_cb, info);
+}
+
+static void
+ck_get_session_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
+{
+ PendingCallerInfo *info = (PendingCallerInfo *) user_data;
+
+ if (!dbus_g_proxy_end_call (proxy, call_id, NULL,
+ G_TYPE_STRING, &(info->session_id),
+ G_TYPE_INVALID)) {
+ pending_caller_abort (info, NULL);
+ return;
+ }
+
+ // Finally, ensure that the calling process is still there, so we are sure
+ // that the process we've just examined is indeed the calling process.
+ info->current_call = dbus_g_proxy_begin_call (info->bus_proxy,
+ "NameHasOwner",
+ dbus_name_has_owner_cb,
+ info,
+ NULL,
+ G_TYPE_STRING, info->caller_bus_name,
+ G_TYPE_INVALID);
+ info->current_call_proxy = info->bus_proxy;
+}
+
+static void
+dbus_get_pid_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
+{
+ PendingCallerInfo *info = (PendingCallerInfo *) user_data;
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (info->manager);
+ guint pid;
+
+ if (!dbus_g_proxy_end_call (proxy, call_id, NULL,
+ G_TYPE_UINT, &pid, G_TYPE_INVALID)) {
+ pending_caller_abort (info, NULL);
+ return;
+ }
+
+ info->current_call = dbus_g_proxy_begin_call (priv->ck_manager,
+ "GetSessionForUnixProcess",
+ ck_get_session_cb,
+ info,
+ NULL,
+ G_TYPE_UINT, pid,
+ G_TYPE_INVALID);
+ info->current_call_proxy = priv->ck_manager;
+}
+
+static void
+get_session_of_caller_internal (NMSessionManager *manager,
+ DBusGMethodInvocation *method_call,
+ CallbackInfo *cb_info)
+{
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (manager);
+ DBusGConnection *connection;
+ PendingCallerInfo *info;
+
+ if (priv->disposed) {
+ callback_info_fail_disposed (cb_info);
+ return;
+ }
+ connection = nm_dbus_manager_get_connection (nm_dbus_manager_get());
+
+ info = g_slice_new (PendingCallerInfo);
+ info->manager = manager;
+ info->cb_info = cb_info;
+ info->caller_bus_name = dbus_g_method_get_sender (method_call);
+ info->bus_proxy = dbus_g_proxy_new_for_name (connection,
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus");
+
+ info->current_call = dbus_g_proxy_begin_call (info->bus_proxy,
+ "GetConnectionUnixProcessID",
+ dbus_get_pid_cb,
+ info,
+ NULL,
+ G_TYPE_STRING, info->caller_bus_name,
+ G_TYPE_INVALID);
+ info->current_call_proxy = info->bus_proxy;
+
+ priv->pending_callers = g_slist_prepend (priv->pending_callers, info);
+
+ g_object_unref (connection);
+}
+
+void
+nm_session_manager_get_session_of_caller (NMSessionManager *manager,
+ DBusGMethodInvocation *method_call,
+ NMSessionFunc callback,
+ gpointer user_data)
+{
+ CallbackInfo *cb_info;
+
+ g_return_if_fail (NM_IS_SESSION_MANAGER (manager));
+ g_return_if_fail (method_call != NULL);
+
+ cb_info = callback_info_new (callback, user_data);
+
+ get_session_of_caller_internal (manager, method_call, cb_info);
+}
+
+
+/**** Initialization & disposal **********************************************/
+
+gboolean
+nm_session_manager_is_initialized (NMSessionManager *self)
+{
+ g_return_val_if_fail (NM_IS_SESSION_MANAGER (self), FALSE);
+
+ return NM_SESSION_MANAGER_GET_PRIVATE (self)->initialized;
+}
+
+/* Callback run for sessions loaded during initialization. Emits the
+ * "initialized" signal when all sessions are loaded. */
+static void
+init_session_load_cb (NMSessionInfo *session, GError *error, gpointer user_data)
+{
+ NMSessionManager *self = NM_SESSION_MANAGER (user_data);
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (self);
+
+ priv->init_sessions_left--;
+ if (priv->init_sessions_left == 0) {
+ priv->initialized = TRUE;
+ g_signal_emit (self, signals[INIT_DONE], 0);
+ }
+}
+
+static void
+ck_get_sessions_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
+{
+ NMSessionManager *self = NM_SESSION_MANAGER (user_data);
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (self);
+ GPtrArray *session_ids;
+ int i;
+
+ g_assert (priv->initialized == FALSE);
+
+ if (!dbus_g_proxy_end_call (proxy, call_id, NULL,
+ DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &session_ids,
+ G_TYPE_INVALID)) {
+ nm_log_err (LOGD_SYS_SET, "failed to get initial ConsoleKit session list");
+ return;
+ }
+
+ priv->init_sessions_left = session_ids->len;
+ if (priv->init_sessions_left > 0) {
+ for (i = 0; i < session_ids->len; i++) {
+ char *session_id = g_ptr_array_index (session_ids, i);
+ nm_session_manager_get_session (self, session_id, init_session_load_cb, self);
+ g_free (session_id);
+ }
+ } else {
+ /* Make sure we send the init-done signal if there aren't any sessions */
+ priv->initialized = TRUE;
+ g_signal_emit (self, signals[INIT_DONE], 0);
+ }
+ g_ptr_array_free (session_ids, TRUE);
+}
+
+static void
+nm_session_manager_init (NMSessionManager *self)
+{
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (self);
+ NMSessionInfo *default_session;
+ DBusGConnection *g_connection = nm_dbus_manager_get_connection (nm_dbus_manager_get());
+ DBusConnection *connection = dbus_g_connection_get_connection (g_connection);
+
+ priv->disposed = FALSE;
+ priv->initialized = FALSE;
+ priv->sessions = g_hash_table_new_full (g_str_hash, g_str_equal,
+ NULL, g_object_unref);
+ priv->pending_sessions = g_hash_table_new_full (g_str_hash, g_str_equal,
+ NULL, pending_session_destroy);
+ priv->pending_callers = NULL;
+
+ default_session = NM_SESSION_INFO (g_object_new (NM_TYPE_SESSION_INFO,
+ NM_SESSION_INFO_IS_DEFAULT, TRUE,
+ NM_SESSION_INFO_ID, NM_SESSION_INFO_DEFAULT_ID,
+ NULL));
+ g_hash_table_insert (priv->sessions,
+ NM_SESSION_INFO_DEFAULT_ID, default_session);
+
+
+ priv->ck_manager = dbus_g_proxy_new_for_name (g_connection,
+ "org.freedesktop.ConsoleKit",
+ "/org/freedesktop/ConsoleKit/Manager",
+ "org.freedesktop.ConsoleKit.Manager");
+
+ // Setup a signal handler to catch SessionAdded/Removed signals for *all*
+ // seats, all in one shot.
+ dbus_connection_add_filter (connection,
+ ck_session_signal_filter,
+ self,
+ NULL);
+ dbus_bus_add_match (connection,
+ "type='signal',sender='org.freedesktop.ConsoleKit',"
+ "interface='org.freedesktop.ConsoleKit.Seat',member='SessionAdded'",
+ NULL);
+ dbus_bus_add_match (connection,
+ "type='signal',sender='org.freedesktop.ConsoleKit',"
+ "interface='org.freedesktop.ConsoleKit.Seat',member='SessionRemoved'",
+ NULL);
+
+ dbus_g_proxy_begin_call (priv->ck_manager,
+ "GetSessions",
+ ck_get_sessions_cb,
+ self,
+ NULL,
+ G_TYPE_INVALID);
+}
+
+static void
+dispose (GObject *object)
+{
+ NMSessionManagerPrivate *priv = NM_SESSION_MANAGER_GET_PRIVATE (object);
+ DBusConnection *connection = nm_dbus_manager_get_dbus_connection (nm_dbus_manager_get ());
+
+ if (priv->disposed)
+ return;
+
+ priv->disposed = TRUE;
+
+ dbus_connection_remove_filter (connection, ck_session_signal_filter, object);
+ nm_utils_slist_free (priv->pending_callers, pending_caller_dispose);
+ g_hash_table_unref (priv->pending_sessions);
+ g_hash_table_unref (priv->sessions);
+ g_object_unref(priv->ck_manager);
+
+ G_OBJECT_CLASS (nm_session_manager_parent_class)->dispose (object);
+}
+
+static void
+nm_session_manager_class_init (NMSessionManagerClass *manager_class)
+{
+ GObjectClass *g_class = G_OBJECT_CLASS (manager_class);
+
+ g_type_class_add_private (g_class, sizeof(NMSessionManagerPrivate));
+ g_class->dispose = dispose;
+
+ signals[ADDED] =
+ g_signal_new (NM_SESSION_MANAGER_SESSION_ADDED,
+ NM_TYPE_SESSION_MANAGER,
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1, NM_TYPE_SESSION_INFO);
+
+ signals[INIT_DONE] =
+ g_signal_new (NM_SESSION_MANAGER_INIT_DONE,
+ NM_TYPE_SESSION_MANAGER,
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+}
+
+NMSessionManager *
+nm_session_manager_get (void)
+{
+ static NMSessionManager *singleton = NULL;
+
+ if (!singleton) {
+ singleton = NM_SESSION_MANAGER (g_object_new (NM_TYPE_SESSION_MANAGER, NULL));
+ }
+
+ return singleton;
+}
+
+GQuark
+nm_session_manager_error_quark (void)
+{
+ static GQuark ret = 0;
+
+ if (ret == 0) {
+ ret = g_quark_from_string ("nm-session-manager-error");
+ }
+
+ return ret;
+}
diff --git a/src/system-settings/nm-session-manager.h b/src/system-settings/nm-session-manager.h
new file mode 100644
index 0000000000..a7f8642ca9
--- /dev/null
+++ b/src/system-settings/nm-session-manager.h
@@ -0,0 +1,82 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager user session tracker
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2010 Daniel Gnoutcheff <daniel@gnoutcheff.name>
+ */
+
+#ifndef NM_SESSION_MANAGER_H
+#define NM_SESSION_MANAGER_H
+
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+#include "nm-session-info.h"
+
+G_BEGIN_DECLS
+
+#define NM_SESSION_MANAGER_ERROR (nm_session_manager_error_quark())
+
+enum {
+ NM_SESSION_MANAGER_ERROR_NOT_FOUND,
+ NM_SESSION_MANAGER_ERROR_INFO_GATHERING_FAILED,
+ NM_SESSION_MANAGER_ERROR_DISPOSED
+} NMSessionManagerError;
+
+#define NM_TYPE_SESSION_MANAGER (nm_session_manager_get_type ())
+#define NM_SESSION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SESSION_MANAGER, NMSessionManager))
+#define NM_SESSION_MANAGER_CLASS(class_struct) (G_TYPE_CHECK_CLASS_CAST ((class_struct), NM_TYPE_SESSION_MANAGER, NMSessionManagerClass))
+#define NM_IS_SESSION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SESSION_MANAGER))
+#define NM_IS_SESSION_MANAGER_CLASS(class_struct) (G_TYPE_CHECK_CLASS_TYPE ((class_struct), NM_TYPE_SESSION_MANAGER))
+#define NM_SESSION_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SESSION_MANAGER, NMSessionManagerClass))
+
+#define NM_SESSION_MANAGER_SESSION_ADDED "session-added"
+#define NM_SESSION_MANAGER_INIT_DONE "init-done"
+
+typedef struct {
+ GObject parent;
+} NMSessionManager;
+
+typedef struct {
+ GObjectClass parent_class;
+} NMSessionManagerClass;
+
+typedef void (*NMSessionFunc) (NMSessionInfo *session,
+ GError *error,
+ gpointer user_data);
+
+NMSessionManager * nm_session_manager_get (void);
+
+gboolean nm_session_manager_is_initialized (NMSessionManager *manager);
+
+GSList * nm_session_manager_get_sessions (NMSessionManager *manager);
+
+void nm_session_manager_get_session (NMSessionManager *manager,
+ char *session_id,
+ NMSessionFunc callback,
+ gpointer user_data);
+
+void nm_session_manager_get_session_of_caller (NMSessionManager *manager,
+ DBusGMethodInvocation *method_call,
+ NMSessionFunc callback,
+ gpointer user_data);
+
+GType nm_session_manager_get_type (void);
+
+GQuark nm_session_manager_error_quark (void);
+
+G_END_DECLS
+
+#endif
diff --git a/src/system-settings/nm-sysconfig-connection.c b/src/system-settings/nm-sysconfig-connection.c
index 73906d20a7..66548d5697 100644
--- a/src/system-settings/nm-sysconfig-connection.c
+++ b/src/system-settings/nm-sysconfig-connection.c
@@ -21,46 +21,250 @@
#include <NetworkManager.h>
#include <dbus/dbus-glib-lowlevel.h>
+#include <nm-setting-connection.h>
+#include <nm-utils.h>
#include "nm-sysconfig-connection.h"
+#include "nm-session-manager.h"
+#include "nm-dbus-manager.h"
#include "nm-system-config-error.h"
#include "nm-dbus-glib-types.h"
-#include "nm-settings-connection-interface.h"
-#include "nm-settings-interface.h"
#include "nm-polkit-helpers.h"
#include "nm-logging.h"
+#include "nm-manager-auth.h"
+static void impl_sysconfig_connection_get_settings (NMSysconfigConnection *connection,
+ DBusGMethodInvocation *context);
-static void settings_connection_interface_init (NMSettingsConnectionInterface *klass);
+static void impl_sysconfig_connection_update (NMSysconfigConnection *connection,
+ GHashTable *new_settings,
+ DBusGMethodInvocation *context);
-G_DEFINE_TYPE_EXTENDED (NMSysconfigConnection, nm_sysconfig_connection, NM_TYPE_EXPORTED_CONNECTION, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
- settings_connection_interface_init))
+static void impl_sysconfig_connection_delete (NMSysconfigConnection *connection,
+ DBusGMethodInvocation *context);
+
+static void impl_sysconfig_connection_get_secrets (NMSysconfigConnection *connection,
+ const gchar *setting_name,
+ const gchar **hints,
+ gboolean request_new,
+ DBusGMethodInvocation *context);
+
+#include "nm-sysconfig-connection-glue.h"
+
+G_DEFINE_TYPE (NMSysconfigConnection, nm_sysconfig_connection, NM_TYPE_CONNECTION)
#define NM_SYSCONFIG_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
NM_TYPE_SYSCONFIG_CONNECTION, \
NMSysconfigConnectionPrivate))
+enum {
+ UPDATED,
+ CHECK_PERMISSIONS,
+ REMOVED,
+ PURGED,
+ UNHIDDEN,
+
+ LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL] = { 0 };
+
typedef struct {
PolkitAuthority *authority;
- GSList *pk_calls;
+ GSList *pending_auths; /* List of PendingAuth structs*/
NMConnection *secrets;
+ gboolean visible; /* Is this connection is visible by some session? */
+ GHashTable *access_list; /* Sessions that may access this connection. */
} NMSysconfigConnectionPrivate;
/**************************************************************/
+/* Returns true iff the given session should be permitted to access this
+ * connection. Used to update the access list */
+static gboolean
+session_allowed (NMSysconfigConnection *connection,
+ NMSessionInfo *session)
+{
+ NMSettingConnection *setting_connection = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION);
+ GSList *permissions_entries;
+ char *session_user;
+ GSList *p_iter;
+ gboolean allowed = FALSE;
+
+ g_object_get (setting_connection, NM_SETTING_CONNECTION_PERMISSIONS, &permissions_entries, NULL);
+
+ /* If permissions list is empty, the connection is world-accessible. */
+ if (permissions_entries == NULL) {
+ allowed = TRUE;
+ goto out;
+ }
+
+ /* The "default session" can only access world-accessible connections. */
+ if (nm_session_info_is_default_session (session)) {
+ allowed = FALSE;
+ goto out;
+ }
+
+ session_user = nm_session_info_get_unix_user (session);
+
+ for (p_iter = permissions_entries; p_iter != NULL; p_iter = p_iter->next) {
+ char **p_comps = g_strsplit ((char *)p_iter->data, ":", 3);
+ char *type = p_comps[0];
+ char *name = p_comps[1];
+
+ if (g_str_equal (type, "user")) {
+ if (g_str_equal (session_user, name)) {
+ allowed = TRUE;
+ goto out;
+ }
+ } else {
+ nm_log_err (LOGD_SYS_SET,
+ "connection %s: failed to parse permissions entry '%s'",
+ nm_setting_connection_get_id (setting_connection),
+ (char *) p_iter->data);
+ }
+ }
+
+out:
+ nm_utils_slist_free (permissions_entries, g_free);
+ return allowed;
+}
+
static void
-ignore_cb (NMSettingsConnectionInterface *connection,
- GError *error,
- gpointer user_data)
+set_visibility (NMSysconfigConnection *self, gboolean new_visibility)
+{
+ NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
+ DBusGConnection *connection = nm_dbus_manager_get_connection (nm_dbus_manager_get());
+ const char *dbus_path = nm_connection_get_path (NM_CONNECTION (self));
+
+ if (new_visibility && !priv->visible) {
+ priv->visible = TRUE;
+
+ dbus_g_connection_register_g_object (connection, dbus_path, G_OBJECT (self));
+ g_signal_emit (self, signals[UNHIDDEN], 0);
+ }
+ else
+ if (!new_visibility && priv->visible) {
+ priv->visible = FALSE;
+
+ g_signal_emit (self, signals[REMOVED], 0);
+ dbus_g_connection_unregister_g_object (connection, G_OBJECT (self));
+ }
+}
+
+/* One of the sessions on our access list has been removed. */
+static void
+session_removed_cb (NMSessionInfo *removed_session,
+ gpointer user_data)
{
+ NMSysconfigConnection *connection = NM_SYSCONFIG_CONNECTION (user_data);
+ NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (connection);
+ char *removed_session_id = nm_session_info_get_id (removed_session);
+
+ g_hash_table_remove (priv->access_list, removed_session_id);
+
+ if (g_hash_table_size (priv->access_list) == 0) {
+ set_visibility (connection, FALSE);
+ } else {
+ g_signal_emit (connection, signals[CHECK_PERMISSIONS], 0);
+ }
}
+/* The session manager reports that a new session has been added. */
+static void
+session_added_cb (NMSessionManager *mananager,
+ NMSessionInfo *session,
+ gpointer user_data)
+{
+ NMSysconfigConnection *connection = NM_SYSCONFIG_CONNECTION (user_data);
+ NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (connection);
+
+ if (session_allowed (connection, session)) {
+ g_object_ref (session);
+ g_signal_connect (session, NM_SESSION_INFO_REMOVED,
+ G_CALLBACK(session_removed_cb), connection);
+ g_hash_table_insert (priv->access_list, nm_session_info_get_id (session), session);
+ g_signal_emit (connection, signals[CHECK_PERMISSIONS], 0);
+ set_visibility (connection, TRUE);
+ }
+}
+
+/* Our permissions property may have been changed. Update the access list. */
+static void
+update_access_list (NMSysconfigConnection *self)
+{
+ NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
+ NMSessionManager *session_manager = nm_session_manager_get ();
+ GSList *sessions, *iter;
+
+ g_hash_table_remove_all (priv->access_list);
+ sessions = nm_session_manager_get_sessions (session_manager);
+ for (iter = sessions; iter != NULL; iter = iter->next) {
+ NMSessionInfo *session = NM_SESSION_INFO (iter->data);
+
+ if (session_allowed (self, session)) {
+ g_object_ref (session);
+ g_signal_connect (session, NM_SESSION_INFO_REMOVED,
+ G_CALLBACK (session_removed_cb), self);
+ g_hash_table_insert (priv->access_list, nm_session_info_get_id (session), session);
+ }
+ }
+ g_slist_free (sessions);
+
+ if (g_hash_table_size (priv->access_list) == 0) {
+ set_visibility (self, FALSE);
+ } else {
+ g_signal_emit (self, signals[CHECK_PERMISSIONS], 0);
+ }
+}
+
+gboolean
+nm_sysconfig_connection_is_visible (NMSysconfigConnection *connection)
+{
+ g_return_val_if_fail (NM_SYSCONFIG_CONNECTION (connection), FALSE);
+
+ return NM_SYSCONFIG_CONNECTION_GET_PRIVATE (connection)->visible;
+}
+
+GSList *
+nm_sysconfig_connection_get_session_access_list (NMSysconfigConnection *self)
+{
+ GHashTableIter iter;
+ gpointer value;
+ GSList *sessions = NULL;
+
+ g_hash_table_iter_init (&iter, NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self)->access_list);
+ while (g_hash_table_iter_next (&iter, NULL, &value))
+ sessions = g_slist_prepend (sessions, value);
+ return sessions;
+}
+
+gboolean
+nm_sysconfig_connection_is_accessible_by_session (NMSysconfigConnection *connection,
+ NMSessionInfo *session)
+{
+ NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (connection);
+ NMSessionInfo *stored_session = NULL;
+
+ g_return_val_if_fail (NM_IS_SYSCONFIG_CONNECTION (connection), FALSE);
+ g_return_val_if_fail (NM_IS_SESSION_INFO (session), FALSE);
+
+ stored_session = g_hash_table_lookup (priv->access_list,
+ nm_session_info_get_id (session));
+
+ if (stored_session == session)
+ return TRUE;
+
+ return FALSE;
+}
+
+/**************************************************************/
+
+/* Update the settings of this connection to match that of 'new', taking care to
+ * make a private copy of secrets. */
gboolean
-nm_sysconfig_connection_update (NMSysconfigConnection *self,
- NMConnection *new,
- gboolean signal_update,
- GError **error)
+nm_sysconfig_connection_replace_settings (NMSysconfigConnection *self,
+ NMConnection *new,
+ GError **error)
{
NMSysconfigConnectionPrivate *priv;
GHashTable *new_settings;
@@ -73,12 +277,6 @@ nm_sysconfig_connection_update (NMSysconfigConnection *self,
priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
- /* Do nothing if there's nothing to update */
- if (nm_connection_compare (NM_CONNECTION (self),
- NM_CONNECTION (new),
- NM_SETTING_COMPARE_FLAG_EXACT))
- return TRUE;
-
new_settings = nm_connection_to_hash (new);
g_assert (new_settings);
if (nm_connection_replace_settings (NM_CONNECTION (self), new_settings, error)) {
@@ -89,19 +287,170 @@ nm_sysconfig_connection_update (NMSysconfigConnection *self,
g_object_unref (priv->secrets);
priv->secrets = nm_connection_duplicate (NM_CONNECTION (self));
- if (signal_update) {
- nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (self),
- ignore_cb,
- NULL);
- }
+ update_access_list (self);
+
success = TRUE;
}
g_hash_table_destroy (new_settings);
return success;
}
+static void
+ignore_cb (NMSysconfigConnection *connection,
+ GError *error,
+ gpointer user_data)
+{
+}
+
+/* Replaces the settings in this connection with those in 'new'. If any changes
+ * are made, commits them to permanent storage and to any other subsystems
+ * watching this connection. Before returning, 'callback' is run with the given
+ * 'user_data' along with any errors encountered.
+ */
+void
+nm_sysconfig_connection_replace_and_commit (NMSysconfigConnection *self,
+ NMConnection *new,
+ NMSysconfigConnectionCommitFunc callback,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION (self));
+ g_return_if_fail (new != NULL);
+ g_return_if_fail (NM_IS_CONNECTION (new));
+
+ if (!callback)
+ callback = ignore_cb;
+
+ /* Do nothing if there's nothing to update */
+ if (nm_connection_compare (NM_CONNECTION (self),
+ NM_CONNECTION (new),
+ NM_SETTING_COMPARE_FLAG_EXACT)) {
+ callback (self, NULL, user_data);
+ return;
+ }
+
+ if (nm_sysconfig_connection_replace_settings (self, new, &error)) {
+ nm_sysconfig_connection_commit_changes (self, callback, user_data);
+ } else {
+ callback (self, error, user_data);
+ g_clear_error (&error);
+ }
+}
+
+void
+nm_sysconfig_connection_commit_changes (NMSysconfigConnection *connection,
+ NMSysconfigConnectionCommitFunc callback,
+ gpointer user_data)
+{
+ g_return_if_fail (connection != NULL);
+ g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION (connection));
+ g_return_if_fail (callback != NULL);
+
+ if (NM_SYSCONFIG_CONNECTION_GET_CLASS (connection)->commit_changes) {
+ NM_SYSCONFIG_CONNECTION_GET_CLASS (connection)->commit_changes (connection,
+ callback,
+ user_data);
+ } else {
+ GError *error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
+ "%s: %s:%d commit_changes() unimplemented", __func__, __FILE__, __LINE__);
+ callback (connection, error, user_data);
+ g_error_free (error);
+ }
+}
+
+void
+nm_sysconfig_connection_delete (NMSysconfigConnection *connection,
+ NMSysconfigConnectionDeleteFunc callback,
+ gpointer user_data)
+{
+ g_return_if_fail (connection != NULL);
+ g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION (connection));
+ g_return_if_fail (callback != NULL);
+
+ if (NM_SYSCONFIG_CONNECTION_GET_CLASS (connection)->delete) {
+ NM_SYSCONFIG_CONNECTION_GET_CLASS (connection)->delete (connection,
+ callback,
+ user_data);
+ } else {
+ GError *error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
+ "%s: %s:%d delete() unimplemented", __func__, __FILE__, __LINE__);
+ callback (connection, error, user_data);
+ g_error_free (error);
+ }
+}
+
+void
+nm_sysconfig_connection_get_secrets (NMSysconfigConnection *connection,
+ const char *setting_name,
+ const char **hints,
+ gboolean request_new,
+ NMSysconfigConnectionGetSecretsFunc callback,
+ gpointer user_data)
+{
+ g_return_if_fail (connection != NULL);
+ g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION (connection));
+ g_return_if_fail (callback != NULL);
+
+ if (NM_SYSCONFIG_CONNECTION_GET_CLASS (connection)->get_secrets) {
+ NM_SYSCONFIG_CONNECTION_GET_CLASS (connection)->get_secrets (connection,
+ setting_name,
+ hints,
+ request_new,
+ callback,
+ user_data);
+ } else {
+ GError *error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
+ "%s: %s:%d get_secrets() unimplemented", __func__, __FILE__, __LINE__);
+ callback (connection, NULL, error, user_data);
+ g_error_free (error);
+ }
+}
+
/**************************************************************/
+static void
+emit_updated (NMSysconfigConnection *connection)
+{
+ NMConnection *tmp;
+ GHashTable *settings;
+
+ tmp = nm_connection_duplicate (NM_CONNECTION (connection));
+ nm_connection_clear_secrets (tmp);
+ settings = nm_connection_to_hash (tmp);
+ g_object_unref (tmp);
+
+ g_signal_emit (connection, signals[UPDATED], 0, settings);
+ g_hash_table_destroy (settings);
+}
+
+static void
+commit_changes (NMSysconfigConnection *connection,
+ NMSysconfigConnectionCommitFunc callback,
+ gpointer user_data)
+{
+ g_object_ref (connection);
+ emit_updated (connection);
+ callback (connection, NULL, user_data);
+ g_object_unref (connection);
+}
+
+static void
+do_delete (NMSysconfigConnection *connection,
+ NMSysconfigConnectionDeleteFunc callback,
+ gpointer user_data)
+{
+ g_object_ref (connection);
+ set_visibility (connection, FALSE);
+ g_signal_emit (connection, signals[PURGED], 0);
+ callback (connection, NULL, user_data);
+ g_object_unref (connection);
+}
+
static GValue *
string_to_gvalue (const char *str)
{
@@ -176,16 +525,15 @@ destroy_gvalue (gpointer data)
g_slice_free (GValue, value);
}
-static gboolean
-get_secrets (NMSettingsConnectionInterface *connection,
+static void
+get_secrets (NMSysconfigConnection *connection,
const char *setting_name,
const char **hints,
gboolean request_new,
- NMSettingsConnectionInterfaceGetSecretsFunc callback,
+ NMSysconfigConnectionGetSecretsFunc callback,
gpointer user_data)
{
- NMSysconfigConnection *self = NM_SYSCONFIG_CONNECTION (connection);
- NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
+ NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (connection);
GHashTable *settings = NULL;
GHashTable *secrets = NULL;
NMSetting *setting;
@@ -194,27 +542,27 @@ get_secrets (NMSettingsConnectionInterface *connection,
/* Use priv->secrets to work around the fact that nm_connection_clear_secrets()
* will clear secrets on this object's settings. priv->secrets should be
* a complete copy of this object and kept in sync by
- * nm_sysconfig_connection_update().
+ * nm_sysconfig_connection_replace_settings().
*/
if (!priv->secrets) {
- error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
+ error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_INVALID_CONNECTION,
"%s.%d - Internal error; secrets cache invalid.",
__FILE__, __LINE__);
(*callback) (connection, NULL, error, user_data);
g_error_free (error);
- return TRUE;
+ return;
}
setting = nm_connection_get_setting_by_name (priv->secrets, setting_name);
if (!setting) {
- error = g_error_new (NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INVALID_SETTING,
+ error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_INVALID_SETTING,
"%s.%d - Connection didn't have requested setting '%s'.",
__FILE__, __LINE__, setting_name);
(*callback) (connection, NULL, error, user_data);
g_error_free (error);
- return TRUE;
+ return;
}
/* Returned secrets are a{sa{sv}}; this is the outer a{s...} hash that
@@ -230,388 +578,408 @@ get_secrets (NMSettingsConnectionInterface *connection,
g_hash_table_insert (settings, g_strdup (setting_name), secrets);
callback (connection, settings, NULL, user_data);
g_hash_table_destroy (settings);
- return TRUE;
}
-/**************************************************************/
+/**** User authorization **************************************/
+
+typedef void (*AuthCallback) (NMSysconfigConnection *connection,
+ DBusGMethodInvocation *context,
+ GError *error,
+ gpointer data);
typedef struct {
NMSysconfigConnection *self;
DBusGMethodInvocation *context;
PolkitSubject *subject;
GCancellable *cancellable;
+ gboolean check_modify;
gboolean disposed;
- /* Update */
- NMConnection *connection;
-
- /* Secrets */
- char *setting_name;
- char **hints;
- gboolean request_new;
-} PolkitCall;
-
-static PolkitCall *
-polkit_call_new (NMSysconfigConnection *self,
- DBusGMethodInvocation *context,
- NMConnection *connection,
- const char *setting_name,
- const char **hints,
- gboolean request_new)
-{
- PolkitCall *call;
- char *sender;
-
- g_return_val_if_fail (self != NULL, NULL);
- g_return_val_if_fail (context != NULL, NULL);
-
- call = g_malloc0 (sizeof (PolkitCall));
- call->self = self;
- call->context = context;
- call->cancellable = g_cancellable_new ();
- call->connection = connection;
- call->setting_name = g_strdup (setting_name);
- if (hints)
- call->hints = g_strdupv ((char **) hints);
- call->request_new = request_new;
-
- sender = dbus_g_method_get_sender (context);
- call->subject = polkit_system_bus_name_new (sender);
- g_free (sender);
-
- return call;
-}
+ AuthCallback callback;
+ gpointer callback_data;
+} PendingAuth;
static void
-polkit_call_free (PolkitCall *call)
+auth_finish (PendingAuth *info, GError *error)
{
- if (call->connection)
- g_object_unref (call->connection);
- g_free (call->setting_name);
- if (call->hints)
- g_strfreev (call->hints);
-
- g_object_unref (call->subject);
- g_object_unref (call->cancellable);
- g_free (call);
-}
+ NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (info->self);
+ priv->pending_auths = g_slist_remove (priv->pending_auths, info);
-static void
-con_update_cb (NMSettingsConnectionInterface *connection,
- GError *error,
- gpointer user_data)
-{
- PolkitCall *call = user_data;
+ info->callback (info->self, info->context, error, info->callback_data);
- if (error)
- dbus_g_method_return_error (call->context, error);
- else
- dbus_g_method_return (call->context);
+ if (info->subject)
+ g_object_unref (info->subject);
+ if (info->cancellable)
+ g_object_unref (info->cancellable);
- polkit_call_free (call);
+ g_slice_free (PendingAuth, info);
}
static void
-pk_update_cb (GObject *object, GAsyncResult *result, gpointer user_data)
+auth_pk_cb (GObject *object, GAsyncResult *result, gpointer user_data)
{
- PolkitCall *call = user_data;
- NMSysconfigConnection *self = call->self;
- NMSysconfigConnectionPrivate *priv;
+ PendingAuth *info = user_data;
+ NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (info->self);
PolkitAuthorizationResult *pk_result;
GError *error = NULL;
- /* If our NMSysconfigConnection is already gone, do nothing */
- if (call->disposed) {
+ if (info->disposed) {
error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_GENERAL,
"Request was canceled.");
- dbus_g_method_return_error (call->context, error);
+ auth_finish (info, error);
g_error_free (error);
- polkit_call_free (call);
return;
}
- priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
-
- priv->pk_calls = g_slist_remove (priv->pk_calls, call);
-
pk_result = polkit_authority_check_authorization_finish (priv->authority,
result,
&error);
- /* Some random error happened */
+
if (error) {
- dbus_g_method_return_error (call->context, error);
+ auth_finish (info, error);
g_error_free (error);
- polkit_call_free (call);
return;
}
- /* Caller didn't successfully authenticate */
if (!polkit_authorization_result_get_is_authorized (pk_result)) {
error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_NOT_PRIVILEGED,
"Insufficient privileges.");
- dbus_g_method_return_error (call->context, error);
+ auth_finish (info, error);
g_error_free (error);
- polkit_call_free (call);
goto out;
}
- /* Update our settings internally so the update() call will save the new
- * ones. We don't let nm_sysconfig_connection_update() handle the update
- * signal since we need our own callback after the update is done.
- */
- if (!nm_sysconfig_connection_update (self, call->connection, FALSE, &error)) {
- /* Shouldn't really happen since we've already validated the settings */
- dbus_g_method_return_error (call->context, error);
+ auth_finish (info, NULL);
+
+out:
+ g_object_unref (pk_result);
+}
+
+static void
+auth_get_session_cb (NMSessionInfo *session,
+ GError *session_error,
+ gpointer user_data)
+{
+ PendingAuth *info = user_data;
+ NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (info->self);
+ GError *error = NULL;
+
+ if (info->disposed || !session) {
+ error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_GENERAL,
+ "Request was canceled.");
+ auth_finish (info, error);
g_error_free (error);
- polkit_call_free (call);
- goto out;
+ return;
}
- /* Caller is authenticated, now we can finally try to commit the update */
- nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (self),
- con_update_cb,
- call);
+ if (!nm_sysconfig_connection_is_accessible_by_session (info->self, session)) {
+ error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_PERMISSION_DENIED,
+ "Caller's session is not authorized to access connection.");
+ auth_finish (info, error);
+ g_error_free (error);
+ return;
+ }
+
+ if (!info->check_modify) {
+ auth_finish (info, NULL);
+ } else {
+ char *sender = dbus_g_method_get_sender (info->context);
+ info->subject = polkit_system_bus_name_new (sender);
+ info->cancellable = g_cancellable_new();
+ g_free (sender);
+
+ polkit_authority_check_authorization (priv->authority,
+ info->subject,
+ NM_AUTH_PERMISSION_SETTINGS_CONNECTION_MODIFY,
+ NULL,
+ POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
+ info->cancellable,
+ auth_pk_cb,
+ info);
+ }
-out:
- g_object_unref (pk_result);
}
static void
-dbus_update (NMExportedConnection *exported,
- GHashTable *new_settings,
- DBusGMethodInvocation *context)
+auth_start (NMSysconfigConnection *self,
+ DBusGMethodInvocation *context,
+ gboolean check_modify,
+ AuthCallback callback,
+ gpointer callback_data)
{
- NMSysconfigConnection *self = NM_SYSCONFIG_CONNECTION (exported);
NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
- PolkitCall *call;
- NMConnection *tmp;
- GError *error = NULL;
+ PendingAuth *info = g_slice_new (PendingAuth);
+ info->self = self;
+ info->context = context;
+ info->subject = NULL;
+ info->cancellable = NULL;
+ info->check_modify = check_modify;
+ info->disposed = FALSE;
+ info->callback_data = callback_data;
+
+ priv->pending_auths = g_slist_prepend (priv->pending_auths, info);
+
+ nm_session_manager_get_session_of_caller (nm_session_manager_get(),
+ context,
+ auth_get_session_cb,
+ info);
- /* Check if the settings are valid first */
- tmp = nm_connection_new_from_hash (new_settings, &error);
- if (!tmp) {
- g_assert (error);
+}
+
+/**** DBus method handlers ************************************/
+
+static gboolean
+check_writable (NMConnection *connection, GError **error)
+{
+ NMSettingConnection *s_con;
+
+ g_return_val_if_fail (connection != NULL, FALSE);
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
+
+ s_con = (NMSettingConnection *) nm_connection_get_setting (connection,
+ NM_TYPE_SETTING_CONNECTION);
+ if (!s_con) {
+ g_set_error_literal (error,
+ NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Connection did not have required 'connection' setting");
+ return FALSE;
+ }
+
+ /* If the connection is read-only, that has to be changed at the source of
+ * the problem (ex a system settings plugin that can't write connections out)
+ * instead of over D-Bus.
+ */
+ if (nm_setting_connection_get_read_only (s_con)) {
+ g_set_error_literal (error,
+ NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_READ_ONLY_CONNECTION,
+ "Connection is read-only");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+get_settings_auth_cb (NMSysconfigConnection *self,
+ DBusGMethodInvocation *context,
+ GError *error,
+ gpointer data)
+{
+ NMConnection *no_secrets;
+ GHashTable *settings;
+
+ if (error) {
dbus_g_method_return_error (context, error);
- g_error_free (error);
return;
}
- call = polkit_call_new (self, context, tmp, NULL, NULL, FALSE);
- g_assert (call);
- polkit_authority_check_authorization (priv->authority,
- call->subject,
- NM_SYSCONFIG_POLICY_ACTION_CONNECTION_MODIFY,
- NULL,
- POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
- call->cancellable,
- pk_update_cb,
- call);
- priv->pk_calls = g_slist_prepend (priv->pk_calls, call);
+ /* Secrets should *never* be returned by the GetSettings method, they
+ * get returned by the GetSecrets method which can be better
+ * protected against leakage of secrets to unprivileged callers.
+ */
+ no_secrets = nm_connection_duplicate (NM_CONNECTION (self));
+ g_assert (no_secrets);
+ nm_connection_clear_secrets (no_secrets);
+ settings = nm_connection_to_hash (no_secrets);
+ g_assert (settings);
+
+ dbus_g_method_return (context, settings);
+
+ g_object_unref (no_secrets);
+ g_object_unref (settings);
+}
+
+static void
+impl_sysconfig_connection_get_settings (NMSysconfigConnection *self,
+ DBusGMethodInvocation *context)
+{
+ auth_start (self, context, FALSE, get_settings_auth_cb, NULL);
}
static void
-con_delete_cb (NMSettingsConnectionInterface *connection,
+con_update_cb (NMSysconfigConnection *connection,
GError *error,
gpointer user_data)
{
- PolkitCall *call = user_data;
+ DBusGMethodInvocation *context = user_data;
if (error)
- dbus_g_method_return_error (call->context, error);
+ dbus_g_method_return_error (context, error);
else
- dbus_g_method_return (call->context);
-
- polkit_call_free (call);
+ dbus_g_method_return (context);
}
static void
-pk_delete_cb (GObject *object, GAsyncResult *result, gpointer user_data)
+update_auth_cb (NMSysconfigConnection *self,
+ DBusGMethodInvocation *context,
+ GError *error,
+ gpointer data)
{
- PolkitCall *call = user_data;
- NMSysconfigConnection *self = call->self;
- NMSysconfigConnectionPrivate *priv;
- PolkitAuthorizationResult *pk_result;
- GError *error = NULL;
+ NMConnection *new_settings = data;
- /* If our NMSysconfigConnection is already gone, do nothing */
- if (call->disposed) {
- error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
- NM_SYSCONFIG_SETTINGS_ERROR_GENERAL,
- "Request was canceled.");
- dbus_g_method_return_error (call->context, error);
- g_error_free (error);
- polkit_call_free (call);
- return;
+ if (error) {
+ dbus_g_method_return_error (context, error);
+ goto out;
}
- priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
+ /* Update and commit our settings. */
+ nm_sysconfig_connection_replace_and_commit (self,
+ new_settings,
+ con_update_cb,
+ context);
- priv->pk_calls = g_slist_remove (priv->pk_calls, call);
+out:
+ g_object_unref (new_settings);
+}
- pk_result = polkit_authority_check_authorization_finish (priv->authority,
- result,
- &error);
- /* Some random error happened */
- if (error) {
- dbus_g_method_return_error (call->context, error);
+static void
+impl_sysconfig_connection_update (NMSysconfigConnection *self,
+ GHashTable *new_settings,
+ DBusGMethodInvocation *context)
+{
+ NMConnection *tmp;
+ GError *error = NULL;
+
+ /* If the connection is read-only, that has to be changed at the source of
+ * the problem (ex a system settings plugin that can't write connections out)
+ * instead of over D-Bus.
+ */
+ if (!check_writable (NM_CONNECTION (self), &error)) {
+ dbus_g_method_return_error (context, error);
g_error_free (error);
- polkit_call_free (call);
return;
}
- /* Caller didn't successfully authenticate */
- if (!polkit_authorization_result_get_is_authorized (pk_result)) {
- error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
- NM_SYSCONFIG_SETTINGS_ERROR_NOT_PRIVILEGED,
- "Insufficient privileges.");
- dbus_g_method_return_error (call->context, error);
+ /* Check if the settings are valid first */
+ tmp = nm_connection_new_from_hash (new_settings, &error);
+ if (!tmp) {
+ g_assert (error);
+ dbus_g_method_return_error (context, error);
g_error_free (error);
- polkit_call_free (call);
- goto out;
+ return;
}
- /* Caller is authenticated, now we can finally try to delete */
- nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (self),
- con_delete_cb,
- call);
-
-out:
- g_object_unref (pk_result);
+ auth_start (self, context, TRUE, update_auth_cb, tmp);
}
static void
-dbus_delete (NMExportedConnection *exported,
- DBusGMethodInvocation *context)
+con_delete_cb (NMSysconfigConnection *connection,
+ GError *error,
+ gpointer user_data)
{
- NMSysconfigConnection *self = NM_SYSCONFIG_CONNECTION (exported);
- NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
- PolkitCall *call;
+ DBusGMethodInvocation *context = user_data;
- call = polkit_call_new (self, context, NULL, NULL, NULL, FALSE);
- g_assert (call);
- polkit_authority_check_authorization (priv->authority,
- call->subject,
- NM_SYSCONFIG_POLICY_ACTION_CONNECTION_MODIFY,
- NULL,
- POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
- call->cancellable,
- pk_delete_cb,
- call);
- priv->pk_calls = g_slist_prepend (priv->pk_calls, call);
+ if (error)
+ dbus_g_method_return_error (context, error);
+ else
+ dbus_g_method_return (context);
}
static void
-con_secrets_cb (NMSettingsConnectionInterface *connection,
- GHashTable *secrets,
- GError *error,
- gpointer user_data)
+delete_auth_cb (NMSysconfigConnection *self,
+ DBusGMethodInvocation *context,
+ GError *error,
+ gpointer data)
{
- PolkitCall *call = user_data;
-
- if (error)
- dbus_g_method_return_error (call->context, error);
- else
- dbus_g_method_return (call->context, secrets);
+ if (error) {
+ dbus_g_method_return_error (context, error);
+ return;
+ }
- polkit_call_free (call);
+ nm_sysconfig_connection_delete (self, con_delete_cb, context);
}
static void
-pk_secrets_cb (GObject *object, GAsyncResult *result, gpointer user_data)
+impl_sysconfig_connection_delete (NMSysconfigConnection *self,
+ DBusGMethodInvocation *context)
{
- PolkitCall *call = user_data;
- NMSysconfigConnection *self = call->self;
- NMSysconfigConnectionPrivate *priv;
- PolkitAuthorizationResult *pk_result;
GError *error = NULL;
-
- /* If our NMSysconfigConnection is already gone, do nothing */
- if (call->disposed) {
- error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
- NM_SYSCONFIG_SETTINGS_ERROR_GENERAL,
- "Request was canceled.");
- dbus_g_method_return_error (call->context, error);
+
+ if (!check_writable (NM_CONNECTION (self), &error)) {
+ dbus_g_method_return_error (context, error);
g_error_free (error);
- polkit_call_free (call);
return;
}
- priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
+ auth_start (self, context, TRUE, delete_auth_cb, NULL);
+}
- priv->pk_calls = g_slist_remove (priv->pk_calls, call);
+typedef struct {
+ char *setting_name;
+ char **hints;
+ gboolean request_new;
+} GetSecretsInfo;
- pk_result = polkit_authority_check_authorization_finish (priv->authority,
- result,
- &error);
- /* Some random error happened */
- if (error) {
- dbus_g_method_return_error (call->context, error);
- g_error_free (error);
- polkit_call_free (call);
- return;
- }
+static void
+con_secrets_cb (NMSysconfigConnection *connection,
+ GHashTable *secrets,
+ GError *error,
+ gpointer user_data)
+{
+ DBusGMethodInvocation *context = user_data;
- /* Caller didn't successfully authenticate */
- if (!polkit_authorization_result_get_is_authorized (pk_result)) {
- error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
- NM_SYSCONFIG_SETTINGS_ERROR_NOT_PRIVILEGED,
- "Insufficient privileges.");
- dbus_g_method_return_error (call->context, error);
- g_error_free (error);
- polkit_call_free (call);
+ if (error)
+ dbus_g_method_return_error (context, error);
+ else
+ dbus_g_method_return (context, secrets);
+}
+
+static void
+secrets_auth_cb (NMSysconfigConnection *self,
+ DBusGMethodInvocation *context,
+ GError *error,
+ gpointer data)
+{
+ GetSecretsInfo *info = data;
+
+ if (error) {
+ dbus_g_method_return_error (context, error);
goto out;
}
- /* Caller is authenticated, now we can finally try to update */
- nm_settings_connection_interface_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (self),
- call->setting_name,
- (const char **) call->hints,
- call->request_new,
- con_secrets_cb,
- call);
+ nm_sysconfig_connection_get_secrets (self,
+ info->setting_name,
+ (const char **) info->hints,
+ info->request_new,
+ con_secrets_cb,
+ context);
out:
- g_object_unref (pk_result);
+ g_free (info->setting_name);
+ g_strfreev (info->hints);
+ g_slice_free (GetSecretsInfo, info);
}
static void
-dbus_get_secrets (NMExportedConnection *exported,
- const gchar *setting_name,
- const gchar **hints,
- gboolean request_new,
- DBusGMethodInvocation *context)
+impl_sysconfig_connection_get_secrets (NMSysconfigConnection *self,
+ const gchar *setting_name,
+ const gchar **hints,
+ gboolean request_new,
+ DBusGMethodInvocation *context)
{
- NMSysconfigConnection *self = NM_SYSCONFIG_CONNECTION (exported);
- NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
- PolkitCall *call;
+ GetSecretsInfo *info = g_slice_new (GetSecretsInfo);
+ info->setting_name = g_strdup (setting_name);
+ info->hints = g_strdupv ((char **) hints);
+ info->request_new = request_new;
- call = polkit_call_new (self, context, NULL, setting_name, hints, request_new);
- g_assert (call);
- polkit_authority_check_authorization (priv->authority,
- call->subject,
- NM_SYSCONFIG_POLICY_ACTION_CONNECTION_MODIFY,
- NULL,
- POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
- call->cancellable,
- pk_secrets_cb,
- call);
- priv->pk_calls = g_slist_prepend (priv->pk_calls, call);
+ auth_start (self, context, TRUE, secrets_auth_cb, info);
}
/**************************************************************/
static void
-settings_connection_interface_init (NMSettingsConnectionInterface *iface)
-{
- iface->get_secrets = get_secrets;
-}
-
-static void
nm_sysconfig_connection_init (NMSysconfigConnection *self)
{
NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
+ NMSessionManager *session_manager;
+ static guint32 dbus_counter = 0;
+ char *dbus_path;
GError *error = NULL;
priv->authority = polkit_authority_get_sync (NULL, NULL);
@@ -621,6 +989,17 @@ nm_sysconfig_connection_init (NMSysconfigConnection *self)
error && error->message ? error->message : "(unknown)");
g_clear_error (&error);
}
+
+ dbus_path = g_strdup_printf ("%s/%u", NM_DBUS_PATH_SETTINGS, dbus_counter++);
+ nm_connection_set_path (NM_CONNECTION (self), dbus_path);
+ g_free (dbus_path);
+ priv->visible = FALSE;
+
+ priv->access_list = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
+ session_manager = nm_session_manager_get();
+ g_signal_connect (session_manager, NM_SESSION_MANAGER_SESSION_ADDED,
+ G_CALLBACK (session_added_cb), self);
+
}
static void
@@ -628,20 +1007,32 @@ dispose (GObject *object)
{
NMSysconfigConnection *self = NM_SYSCONFIG_CONNECTION (object);
NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
+ NMSessionManager *session_manager = nm_session_manager_get ();
GSList *iter;
+ GHashTableIter hiter;
+ gpointer value;
if (priv->secrets)
g_object_unref (priv->secrets);
/* Cancel PolicyKit requests */
- for (iter = priv->pk_calls; iter; iter = g_slist_next (iter)) {
- PolkitCall *call = iter->data;
+ for (iter = priv->pending_auths; iter; iter = g_slist_next (iter)) {
+ PendingAuth *call = iter->data;
call->disposed = TRUE;
g_cancellable_cancel (call->cancellable);
}
- g_slist_free (priv->pk_calls);
- priv->pk_calls = NULL;
+ g_slist_free (priv->pending_auths);
+ priv->pending_auths = NULL;
+
+ set_visibility (self, FALSE);
+ g_signal_handlers_disconnect_by_func (session_manager, session_added_cb, self);
+
+ g_hash_table_iter_init (&hiter, priv->access_list);
+ while (g_hash_table_iter_next (&hiter, NULL, &value))
+ g_signal_handlers_disconnect_by_func (NM_SESSION_INFO (value), session_removed_cb, self);
+ g_hash_table_destroy (priv->access_list);
+ priv->access_list = NULL;
G_OBJECT_CLASS (nm_sysconfig_connection_parent_class)->dispose (object);
}
@@ -650,13 +1041,53 @@ static void
nm_sysconfig_connection_class_init (NMSysconfigConnectionClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
- NMExportedConnectionClass *ec_class = NM_EXPORTED_CONNECTION_CLASS (class);
g_type_class_add_private (class, sizeof (NMSysconfigConnectionPrivate));
/* Virtual methods */
object_class->dispose = dispose;
- ec_class->update = dbus_update;
- ec_class->delete = dbus_delete;
- ec_class->get_secrets = dbus_get_secrets;
+ class->commit_changes = commit_changes;
+ class->delete = do_delete;
+ class->get_secrets = get_secrets;
+
+ /* Signals */
+ signals[UPDATED] =
+ g_signal_new (NM_SYSCONFIG_CONNECTION_UPDATED,
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT);
+
+ signals[REMOVED] =
+ g_signal_new (NM_SYSCONFIG_CONNECTION_REMOVED,
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[PURGED] =
+ g_signal_new (NM_SYSCONFIG_CONNECTION_PURGED,
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[UNHIDDEN] =
+ g_signal_new (NM_SYSCONFIG_CONNECTION_UNHIDDEN,
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (class),
+ &dbus_glib_nm_sysconfig_connection_object_info);
+
}
diff --git a/src/system-settings/nm-sysconfig-connection.h b/src/system-settings/nm-sysconfig-connection.h
index 0431dc95c2..80e0743673 100644
--- a/src/system-settings/nm-sysconfig-connection.h
+++ b/src/system-settings/nm-sysconfig-connection.h
@@ -22,7 +22,8 @@
#define NM_SYSCONFIG_CONNECTION_H
#include <nm-connection.h>
-#include <nm-exported-connection.h>
+#include <dbus/dbus-glib.h>
+#include "nm-session-info.h"
G_BEGIN_DECLS
@@ -33,23 +34,84 @@ G_BEGIN_DECLS
#define NM_IS_SYSCONFIG_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SYSCONFIG_CONNECTION))
#define NM_SYSCONFIG_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_CONNECTION, NMSysconfigConnectionClass))
-typedef struct {
- NMExportedConnection parent;
-} NMSysconfigConnection;
+#define NM_SYSCONFIG_CONNECTION_UPDATED "updated"
+#define NM_SYSCONFIG_CONNECTION_REMOVED "removed"
+#define NM_SYSCONFIG_CONNECTION_PURGED "purged"
+#define NM_SYSCONFIG_CONNECTION_UNHIDDEN "unhidden"
-typedef struct {
- NMExportedConnectionClass parent;
-} NMSysconfigConnectionClass;
+typedef struct _NMSysconfigConnection NMSysconfigConnection;
+
+typedef struct _NMSysconfigConnectionClass NMSysconfigConnectionClass;
+
+typedef void (*NMSysconfigConnectionCommitFunc) (NMSysconfigConnection *connection,
+ GError *error,
+ gpointer user_data);
+
+typedef void (*NMSysconfigConnectionDeleteFunc) (NMSysconfigConnection *connection,
+ GError *error,
+ gpointer user_data);
+
+typedef void (*NMSysconfigConnectionGetSecretsFunc) (NMSysconfigConnection *connection,
+ GHashTable *secrets,
+ GError *error,
+ gpointer user_data);
+
+struct _NMSysconfigConnection {
+ NMConnection parent;
+};
+
+struct _NMSysconfigConnectionClass {
+ NMConnectionClass parent;
+
+ void (*commit_changes) (NMSysconfigConnection *connection,
+ NMSysconfigConnectionCommitFunc callback,
+ gpointer user_data);
+
+ void (*delete) (NMSysconfigConnection *connection,
+ NMSysconfigConnectionDeleteFunc callback,
+ gpointer user_data);
+
+ void (*get_secrets) (NMSysconfigConnection *connection,
+ const char *setting_name,
+ const char **hints,
+ gboolean request_new,
+ NMSysconfigConnectionGetSecretsFunc callback,
+ gpointer user_data);
+};
GType nm_sysconfig_connection_get_type (void);
-/* Called by a system-settings plugin to update a connection is out of sync
- * with it's backing storage.
- */
-gboolean nm_sysconfig_connection_update (NMSysconfigConnection *self,
- NMConnection *new_settings,
- gboolean signal_update,
- GError **error);
+void nm_sysconfig_connection_commit_changes (NMSysconfigConnection *connection,
+ NMSysconfigConnectionCommitFunc callback,
+ gpointer user_data);
+
+gboolean nm_sysconfig_connection_replace_settings (NMSysconfigConnection *self,
+ NMConnection *new_settings,
+ GError **error);
+
+void nm_sysconfig_connection_replace_and_commit (NMSysconfigConnection *self,
+ NMConnection *new_settings,
+ NMSysconfigConnectionCommitFunc callback,
+ gpointer user_data);
+
+void nm_sysconfig_connection_delete (NMSysconfigConnection *connection,
+ NMSysconfigConnectionDeleteFunc callback,
+ gpointer user_data);
+
+void nm_sysconfig_connection_get_secrets (NMSysconfigConnection *connection,
+ const char *setting_name,
+ const char **hints,
+ gboolean request_new,
+ NMSysconfigConnectionGetSecretsFunc callback,
+ gpointer user_data);
+
+gboolean nm_sysconfig_connection_is_visible (NMSysconfigConnection *connection);
+
+gboolean nm_sysconfig_connection_is_accessible_by_session (NMSysconfigConnection *connection,
+ NMSessionInfo *session);
+
+GSList * nm_sysconfig_connection_get_session_access_list (NMSysconfigConnection *connection);
+
G_END_DECLS
diff --git a/src/system-settings/nm-sysconfig-settings.c b/src/system-settings/nm-sysconfig-settings.c
index d929813f1b..8ac048fdab 100644
--- a/src/system-settings/nm-sysconfig-settings.c
+++ b/src/system-settings/nm-sysconfig-settings.c
@@ -33,7 +33,6 @@
#include <nm-connection.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <nm-settings-system-interface.h>
#include <nm-setting-8021x.h>
#include <nm-setting-bluetooth.h>
@@ -59,6 +58,8 @@
#include "nm-system-config-error.h"
#include "nm-default-wired-connection.h"
#include "nm-logging.h"
+#include "nm-dbus-manager.h"
+#include "nm-manager-auth.h"
#define CONFIG_KEY_NO_AUTO_DEFAULT "no-auto-default"
@@ -72,48 +73,54 @@ EXPORT(nm_inotify_helper_add_watch)
EXPORT(nm_inotify_helper_remove_watch)
EXPORT(nm_sysconfig_connection_get_type)
-EXPORT(nm_sysconfig_connection_update)
+EXPORT(nm_sysconfig_connection_replace_settings)
+EXPORT(nm_sysconfig_connection_replace_and_commit)
/* END LINKER CRACKROCK */
static void claim_connection (NMSysconfigSettings *self,
- NMSettingsConnectionInterface *connection,
+ NMSysconfigConnection *connection,
gboolean do_export);
+static gboolean impl_settings_list_connections (NMSysconfigSettings *self,
+ GPtrArray **connections,
+ GError **error);
+
+static void impl_settings_add_connection (NMSysconfigSettings *self,
+ GHashTable *settings,
+ DBusGMethodInvocation *context);
+
static void impl_settings_save_hostname (NMSysconfigSettings *self,
const char *hostname,
DBusGMethodInvocation *context);
-static void impl_settings_get_permissions (NMSysconfigSettings *self,
- DBusGMethodInvocation *context);
-
-#include "nm-settings-system-glue.h"
+#include "nm-settings-glue.h"
static void unmanaged_specs_changed (NMSystemConfigInterface *config, gpointer user_data);
typedef struct {
+ DBusGConnection *bus;
+ gboolean exported;
+
PolkitAuthority *authority;
guint auth_changed_id;
char *config_file;
GSList *pk_calls;
- GSList *permissions_calls;
GSList *plugins;
gboolean connections_loaded;
- GHashTable *connections;
+ GHashTable *visible_connections;
+ GHashTable *all_connections;
GSList *unmanaged_specs;
} NMSysconfigSettingsPrivate;
-static void settings_system_interface_init (NMSettingsSystemInterface *klass);
-
-G_DEFINE_TYPE_WITH_CODE (NMSysconfigSettings, nm_sysconfig_settings, NM_TYPE_SETTINGS_SERVICE,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_SYSTEM_INTERFACE,
- settings_system_interface_init))
+G_DEFINE_TYPE (NMSysconfigSettings, nm_sysconfig_settings, G_TYPE_OBJECT)
#define NM_SYSCONFIG_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettingsPrivate))
enum {
PROPERTIES_CHANGED,
+ NEW_CONNECTION,
LAST_SIGNAL
};
@@ -123,6 +130,8 @@ static guint signals[LAST_SIGNAL] = { 0 };
enum {
PROP_0,
PROP_UNMANAGED_SPECS,
+ PROP_HOSTNAME,
+ PROP_CAN_MODIFY,
LAST_PROP
};
@@ -148,7 +157,7 @@ load_connections (NMSysconfigSettings *self)
// priority plugin.
for (elt = plugin_connections; elt; elt = g_slist_next (elt))
- claim_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (elt->data), TRUE);
+ claim_connection (self, NM_SYSCONFIG_CONNECTION (elt->data), TRUE);
g_slist_free (plugin_connections);
}
@@ -159,20 +168,67 @@ load_connections (NMSysconfigSettings *self)
unmanaged_specs_changed (NULL, self);
}
-static GSList *
-list_connections (NMSettingsService *settings)
+void
+nm_sysconfig_settings_for_each_connection (NMSysconfigSettings *self,
+ NMSysconfigSettingsForEachFunc for_each_func,
+ gpointer user_data)
{
- NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (settings);
+ NMSysconfigSettingsPrivate *priv;
GHashTableIter iter;
gpointer key;
- GSList *list = NULL;
- load_connections (NM_SYSCONFIG_SETTINGS (settings));
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (self));
+ g_return_if_fail (for_each_func != NULL);
+
+ priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
+
+ load_connections (self);
- g_hash_table_iter_init (&iter, priv->connections);
+ g_hash_table_iter_init (&iter, priv->visible_connections);
while (g_hash_table_iter_next (&iter, &key, NULL))
- list = g_slist_prepend (list, NM_EXPORTED_CONNECTION (key));
- return g_slist_reverse (list);
+ for_each_func (self, NM_SYSCONFIG_CONNECTION (key), user_data);
+}
+
+static gboolean
+impl_settings_list_connections (NMSysconfigSettings *self,
+ GPtrArray **connections,
+ GError **error)
+{
+ NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
+ GHashTableIter iter;
+ gpointer key;
+
+ load_connections (self);
+
+ *connections = g_ptr_array_sized_new (g_hash_table_size (priv->visible_connections) + 1);
+ g_hash_table_iter_init (&iter, priv->visible_connections);
+ while (g_hash_table_iter_next (&iter, &key, NULL))
+ g_ptr_array_add (*connections, g_strdup (nm_connection_get_path (NM_CONNECTION (key))));
+ return TRUE;
+}
+
+NMSysconfigConnection *
+nm_sysconfig_settings_get_connection_by_path (NMSysconfigSettings *self, const char *path)
+{
+ NMSysconfigSettingsPrivate *priv;
+ GHashTableIter iter;
+ gpointer key;
+
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (NM_IS_SYSCONFIG_SETTINGS (self), NULL);
+ g_return_val_if_fail (path != NULL, NULL);
+
+ priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
+
+ load_connections (self);
+
+ g_hash_table_iter_init (&iter, priv->visible_connections);
+ while (g_hash_table_iter_next (&iter, &key, NULL)) {
+ if (!strcmp (nm_connection_get_path (NM_CONNECTION (key)), path))
+ return NM_SYSCONFIG_CONNECTION (key);
+ }
+ return NULL;
}
static void
@@ -287,7 +343,7 @@ nm_sysconfig_settings_get_hostname (NMSysconfigSettings *self)
static void
plugin_connection_added (NMSystemConfigInterface *config,
- NMSettingsConnectionInterface *connection,
+ NMSysconfigConnection *connection,
gpointer user_data)
{
claim_connection (NM_SYSCONFIG_SETTINGS (user_data), connection, TRUE);
@@ -339,7 +395,7 @@ hostname_changed (NMSystemConfigInterface *config,
GParamSpec *pspec,
gpointer user_data)
{
- g_object_notify (G_OBJECT (user_data), NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME);
+ g_object_notify (G_OBJECT (user_data), NM_SYSCONFIG_SETTINGS_HOSTNAME);
}
static void
@@ -476,53 +532,87 @@ load_plugins (NMSysconfigSettings *self, const char *plugins, GError **error)
}
static void
-connection_removed (NMSettingsConnectionInterface *connection,
+connection_removed (NMSysconfigConnection *connection,
gpointer user_data)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (user_data);
- g_hash_table_remove (priv->connections, connection);
+ g_hash_table_remove (priv->visible_connections, connection);
+}
+
+static void
+connection_unhidden (NMSysconfigConnection *connection,
+ gpointer user_data)
+{
+ NMSysconfigSettings *settings = user_data;
+ NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (settings);
+
+ g_hash_table_insert (priv->visible_connections,
+ connection, GINT_TO_POINTER (1));
+ g_signal_emit (settings, signals[NEW_CONNECTION], 0, connection);
+}
+
+static void
+connection_purged (NMSysconfigConnection *connection,
+ gpointer user_data)
+{
+ NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (user_data);
+
+ g_hash_table_remove (priv->all_connections, connection);
}
static void
claim_connection (NMSysconfigSettings *self,
- NMSettingsConnectionInterface *connection,
+ NMSysconfigConnection *connection,
gboolean do_export)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (self));
- g_return_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection));
+ g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION (connection));
- if (g_hash_table_lookup (priv->connections, connection))
+ if (g_hash_table_lookup (priv->all_connections, connection))
/* A plugin is lying to us. */
return;
- g_hash_table_insert (priv->connections, g_object_ref (connection), GINT_TO_POINTER (1));
+ g_hash_table_insert (priv->all_connections, g_object_ref (connection), GINT_TO_POINTER (1));
g_signal_connect (connection,
- NM_SETTINGS_CONNECTION_INTERFACE_REMOVED,
+ NM_SYSCONFIG_CONNECTION_REMOVED,
G_CALLBACK (connection_removed),
self);
+ g_signal_connect (connection,
+ NM_SYSCONFIG_CONNECTION_PURGED,
+ G_CALLBACK (connection_purged),
+ self);
+ g_signal_connect (connection,
+ NM_SYSCONFIG_CONNECTION_UNHIDDEN,
+ G_CALLBACK (connection_unhidden),
+ self);
- if (do_export) {
- nm_settings_service_export_connection (NM_SETTINGS_SERVICE (self), connection);
- g_signal_emit_by_name (self, NM_SETTINGS_INTERFACE_NEW_CONNECTION, connection);
+ if (nm_sysconfig_connection_is_visible (connection)) {
+ g_hash_table_insert (priv->visible_connections, connection, GINT_TO_POINTER (1));
+ g_signal_emit (self, signals[NEW_CONNECTION], 0, connection);
}
}
+// TODO it seems that this is only ever used to remove a
+// NMDefaultWiredConnection, and it probably needs to stay that way. So this
+// *needs* a better name!
static void
remove_connection (NMSysconfigSettings *self,
- NMSettingsConnectionInterface *connection,
+ NMSysconfigConnection *connection,
gboolean do_signal)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
- g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (self));
- g_return_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection));
+ if (g_hash_table_lookup (priv->visible_connections, connection)) {
+ g_signal_emit_by_name (G_OBJECT (connection), NM_SYSCONFIG_CONNECTION_REMOVED);
+ g_hash_table_remove (priv->visible_connections, connection);
+ }
- if (g_hash_table_lookup (priv->connections, connection)) {
- g_signal_emit_by_name (G_OBJECT (connection), NM_SETTINGS_CONNECTION_INTERFACE_REMOVED);
- g_hash_table_remove (priv->connections, connection);
+ if (g_hash_table_lookup (priv->all_connections, connection)) {
+ g_signal_emit_by_name (G_OBJECT (connection), NM_SYSCONFIG_CONNECTION_PURGED);
+ g_hash_table_remove (priv->all_connections, connection);
}
}
@@ -534,13 +624,9 @@ typedef struct {
gboolean disposed;
NMConnection *connection;
- NMSettingsAddConnectionFunc callback;
gpointer callback_data;
char *hostname;
-
- NMSettingsSystemPermissions permissions;
- guint32 permissions_calls;
} PolkitCall;
#include "nm-dbus-manager.h"
@@ -549,8 +635,6 @@ static PolkitCall *
polkit_call_new (NMSysconfigSettings *self,
DBusGMethodInvocation *context,
NMConnection *connection,
- NMSettingsAddConnectionFunc callback,
- gpointer callback_data,
const char *hostname)
{
PolkitCall *call;
@@ -565,10 +649,6 @@ polkit_call_new (NMSysconfigSettings *self,
call->context = context;
if (connection)
call->connection = g_object_ref (connection);
- if (callback) {
- call->callback = callback;
- call->callback_data = callback_data;
- }
if (hostname)
call->hostname = g_strdup (hostname);
@@ -652,7 +732,7 @@ pk_add_cb (GObject *object, GAsyncResult *result, gpointer user_data)
&error);
/* Some random error happened */
if (error) {
- call->callback (NM_SETTINGS_INTERFACE (self), error, call->callback_data);
+ dbus_g_method_return_error (call->context, error);
goto out;
}
@@ -661,12 +741,12 @@ pk_add_cb (GObject *object, GAsyncResult *result, gpointer user_data)
error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_NOT_PRIVILEGED,
"Insufficient privileges.");
- call->callback (NM_SETTINGS_INTERFACE (self), error, call->callback_data);
+ dbus_g_method_return_error (call->context, error);
goto out;
}
if (add_new_connection (self, call->connection, &add_error))
- call->callback (NM_SETTINGS_INTERFACE (self), NULL, call->callback_data);
+ dbus_g_method_return (call->context);
else {
error = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_ADD_FAILED,
@@ -674,7 +754,7 @@ pk_add_cb (GObject *object, GAsyncResult *result, gpointer user_data)
add_error ? add_error->code : -1,
(add_error && add_error->message) ? add_error->message : "(unknown)");
g_error_free (add_error);
- call->callback (NM_SETTINGS_INTERFACE (self), error, call->callback_data);
+ dbus_g_method_return_error (call->context, error);
}
out:
@@ -685,38 +765,46 @@ out:
}
static void
-add_connection (NMSettingsService *service,
- NMConnection *connection,
- DBusGMethodInvocation *context, /* Only present for D-Bus calls */
- NMSettingsAddConnectionFunc callback,
- gpointer user_data)
+impl_settings_add_connection (NMSysconfigSettings *self,
+ GHashTable *settings,
+ DBusGMethodInvocation *context)
{
- NMSysconfigSettings *self = NM_SYSCONFIG_SETTINGS (service);
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
PolkitCall *call;
+ NMConnection *connection;
GError *error = NULL;
+ connection = nm_connection_new_from_hash (settings, &error);
+ if (!connection) {
+ g_assert (error);
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+
/* Do any of the plugins support adding? */
if (!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS)) {
error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
NM_SYSCONFIG_SETTINGS_ERROR_ADD_NOT_SUPPORTED,
"None of the registered plugins support add.");
- callback (NM_SETTINGS_INTERFACE (service), error, user_data);
+ dbus_g_method_return_error (context, error);
g_error_free (error);
return;
}
- call = polkit_call_new (self, context, connection, callback, user_data, NULL);
+ call = polkit_call_new (self, context, connection, NULL);
g_assert (call);
polkit_authority_check_authorization (priv->authority,
call->subject,
- NM_SYSCONFIG_POLICY_ACTION_CONNECTION_MODIFY,
+ NM_AUTH_PERMISSION_SETTINGS_CONNECTION_MODIFY,
NULL,
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
call->cancellable,
pk_add_cb,
call);
priv->pk_calls = g_slist_append (priv->pk_calls, call);
+
+ g_object_unref (connection);
}
static void
@@ -809,11 +897,11 @@ impl_settings_save_hostname (NMSysconfigSettings *self,
return;
}
- call = polkit_call_new (self, context, NULL, NULL, NULL, hostname);
+ call = polkit_call_new (self, context, NULL, hostname);
g_assert (call);
polkit_authority_check_authorization (priv->authority,
call->subject,
- NM_SYSCONFIG_POLICY_ACTION_HOSTNAME_MODIFY,
+ NM_AUTH_PERMISSION_SETTINGS_HOSTNAME_MODIFY,
NULL,
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
call->cancellable,
@@ -822,182 +910,6 @@ impl_settings_save_hostname (NMSysconfigSettings *self,
priv->pk_calls = g_slist_append (priv->pk_calls, call);
}
-static void
-pk_authority_changed_cb (GObject *object, gpointer user_data)
-{
- /* Let clients know they should re-check their authorization */
- g_signal_emit_by_name (NM_SYSCONFIG_SETTINGS (user_data),
- NM_SETTINGS_SYSTEM_INTERFACE_CHECK_PERMISSIONS);
-}
-
-typedef struct {
- PolkitCall *pk_call;
- const char *pk_action;
- GCancellable *cancellable;
- NMSettingsSystemPermissions permission;
- gboolean disposed;
-} PermissionsCall;
-
-static void
-permission_call_done (GObject *object, GAsyncResult *result, gpointer user_data)
-{
- PermissionsCall *call = user_data;
- PolkitCall *pk_call = call->pk_call;
- NMSysconfigSettings *self = pk_call->self;
- NMSysconfigSettingsPrivate *priv;
- PolkitAuthorizationResult *pk_result;
- GError *error = NULL;
-
- /* If NMSysconfigSettings is gone, just skip to the end */
- if (call->disposed)
- goto done;
-
- priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
-
- priv->permissions_calls = g_slist_remove (priv->permissions_calls, call);
-
- pk_result = polkit_authority_check_authorization_finish (priv->authority,
- result,
- &error);
- /* Some random error happened */
- if (error) {
- nm_log_err (LOGD_SYS_SET, "error checking '%s' permission: (%d) %s",
- __FILE__, __LINE__, __func__,
- call->pk_action,
- error ? error->code : -1,
- error && error->message ? error->message : "(unknown)");
- if (error)
- g_error_free (error);
- } else {
- /* If the caller is authorized, or the caller could authorize via a
- * challenge, then authorization is possible. Otherwise, caller is out of
- * luck.
- */
- if ( polkit_authorization_result_get_is_authorized (pk_result)
- || polkit_authorization_result_get_is_challenge (pk_result))
- pk_call->permissions |= call->permission;
- }
-
- g_object_unref (pk_result);
-
-done:
- pk_call->permissions_calls--;
- if (pk_call->permissions_calls == 0) {
- if (call->disposed) {
- error = g_error_new_literal (NM_SYSCONFIG_SETTINGS_ERROR,
- NM_SYSCONFIG_SETTINGS_ERROR_GENERAL,
- "Request was canceled.");
- dbus_g_method_return_error (pk_call->context, error);
- g_error_free (error);
- } else {
- /* All the permissions calls are done, return the full permissions
- * bitfield back to the user.
- */
- dbus_g_method_return (pk_call->context, pk_call->permissions);
- }
-
- polkit_call_free (pk_call);
- }
- memset (call, 0, sizeof (PermissionsCall));
- g_free (call);
-}
-
-static void
-start_permission_check (NMSysconfigSettings *self,
- PolkitCall *pk_call,
- const char *pk_action,
- NMSettingsSystemPermissions permission)
-{
- NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
- PermissionsCall *call;
-
- g_return_if_fail (pk_call != NULL);
- g_return_if_fail (pk_action != NULL);
- g_return_if_fail (permission != NM_SETTINGS_SYSTEM_PERMISSION_NONE);
-
- call = g_malloc0 (sizeof (PermissionsCall));
- call->pk_call = pk_call;
- call->pk_action = pk_action;
- call->permission = permission;
- call->cancellable = g_cancellable_new ();
-
- pk_call->permissions_calls++;
-
- polkit_authority_check_authorization (priv->authority,
- pk_call->subject,
- pk_action,
- NULL,
- 0,
- call->cancellable,
- permission_call_done,
- call);
- priv->permissions_calls = g_slist_append (priv->permissions_calls, call);
-}
-
-static void
-impl_settings_get_permissions (NMSysconfigSettings *self,
- DBusGMethodInvocation *context)
-{
- PolkitCall *call;
-
- call = polkit_call_new (self, context, NULL, NULL, NULL, FALSE);
- g_assert (call);
-
- /* Start checks for the various permissions */
-
- /* Only check for connection-modify if one of our plugins supports it. */
- if (get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS)) {
- start_permission_check (self, call,
- NM_SYSCONFIG_POLICY_ACTION_CONNECTION_MODIFY,
- NM_SETTINGS_SYSTEM_PERMISSION_CONNECTION_MODIFY);
- }
-
- /* Only check for hostname-modify if one of our plugins supports it. */
- if (get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME)) {
- start_permission_check (self, call,
- NM_SYSCONFIG_POLICY_ACTION_HOSTNAME_MODIFY,
- NM_SETTINGS_SYSTEM_PERMISSION_HOSTNAME_MODIFY);
- }
-
- // FIXME: hook these into plugin permissions like the modify permissions */
- start_permission_check (self, call,
- NM_SYSCONFIG_POLICY_ACTION_WIFI_SHARE_OPEN,
- NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_OPEN);
- start_permission_check (self, call,
- NM_SYSCONFIG_POLICY_ACTION_WIFI_SHARE_PROTECTED,
- NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_PROTECTED);
-}
-
-static gboolean
-get_permissions (NMSettingsSystemInterface *settings,
- NMSettingsSystemGetPermissionsFunc callback,
- gpointer user_data)
-{
- NMSysconfigSettings *self = NM_SYSCONFIG_SETTINGS (settings);
- NMSettingsSystemPermissions permissions = NM_SETTINGS_SYSTEM_PERMISSION_NONE;
-
- /* Local caller (ie, NM) gets full permissions by default because it doesn't
- * need authorization. However, permissions are still subject to plugin's
- * restrictions. i.e. if no plugins support connection-modify, then even
- * the local caller won't get that permission.
- */
-
- /* Only check for connection-modify if one of our plugins supports it. */
- if (get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS))
- permissions |= NM_SETTINGS_SYSTEM_PERMISSION_CONNECTION_MODIFY;
-
- /* Only check for hostname-modify if one of our plugins supports it. */
- if (get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME))
- permissions |= NM_SETTINGS_SYSTEM_PERMISSION_HOSTNAME_MODIFY;
-
- // FIXME: hook these into plugin permissions like the modify permissions */
- permissions |= NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_OPEN;
- permissions |= NM_SETTINGS_SYSTEM_PERMISSION_WIFI_SHARE_PROTECTED;
-
- callback (settings, permissions, NULL, user_data);
- return TRUE;
-}
-
static gboolean
have_connection_for_device (NMSysconfigSettings *self, GByteArray *mac)
{
@@ -1013,7 +925,7 @@ have_connection_for_device (NMSysconfigSettings *self, GByteArray *mac)
g_return_val_if_fail (mac != NULL, FALSE);
/* Find a wired connection locked to the given MAC address, if any */
- g_hash_table_iter_init (&iter, priv->connections);
+ g_hash_table_iter_init (&iter, priv->visible_connections);
while (g_hash_table_iter_next (&iter, &key, NULL)) {
NMConnection *connection = NM_CONNECTION (key);
const char *connection_type;
@@ -1198,7 +1110,7 @@ cleanup:
}
static void
-delete_cb (NMSettingsConnectionInterface *connection, GError *error, gpointer user_data)
+delete_cb (NMSysconfigConnection *connection, GError *error, gpointer user_data)
{
}
@@ -1220,11 +1132,11 @@ default_wired_try_update (NMDefaultWiredConnection *wired,
id = nm_setting_connection_get_id (s_con);
g_assert (id);
- remove_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (wired), FALSE);
+ remove_connection (self, NM_SYSCONFIG_CONNECTION (wired), FALSE);
if (add_new_connection (self, NM_CONNECTION (wired), &error)) {
- nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (wired),
- delete_cb,
- NULL);
+ nm_sysconfig_connection_delete (NM_SYSCONFIG_CONNECTION (wired),
+ delete_cb,
+ NULL);
g_object_set_data (G_OBJECT (nm_default_wired_connection_get_device (wired)),
DEFAULT_WIRED_TAG,
@@ -1242,7 +1154,7 @@ default_wired_try_update (NMDefaultWiredConnection *wired,
* but add it back to the system settings service. Connection is already
* exported on the bus, don't export it again, thus do_export == FALSE.
*/
- claim_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (wired), FALSE);
+ claim_connection (self, NM_SYSCONFIG_CONNECTION (wired), FALSE);
return TRUE;
}
@@ -1293,7 +1205,7 @@ nm_sysconfig_settings_device_added (NMSysconfigSettings *self, NMDevice *device)
g_signal_connect (wired, "try-update", (GCallback) default_wired_try_update, self);
g_signal_connect (wired, "deleted", (GCallback) default_wired_deleted, self);
- claim_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (wired), TRUE);
+ claim_connection (self, NM_SYSCONFIG_CONNECTION (wired), TRUE);
g_object_unref (wired);
g_object_set_data (G_OBJECT (device), DEFAULT_WIRED_TAG, wired);
@@ -1312,21 +1224,20 @@ nm_sysconfig_settings_device_removed (NMSysconfigSettings *self, NMDevice *devic
connection = (NMDefaultWiredConnection *) g_object_get_data (G_OBJECT (device), DEFAULT_WIRED_TAG);
if (connection)
- remove_connection (self, NM_SETTINGS_CONNECTION_INTERFACE (connection), TRUE);
+ remove_connection (self, NM_SYSCONFIG_CONNECTION (connection), TRUE);
}
NMSysconfigSettings *
nm_sysconfig_settings_new (const char *config_file,
const char *plugins,
- DBusGConnection *bus,
GError **error)
{
NMSysconfigSettings *self;
NMSysconfigSettingsPrivate *priv;
+ NMDBusManager *dbus_mgr;
+ DBusGConnection *bus;
self = g_object_new (NM_TYPE_SYSCONFIG_SETTINGS,
- NM_SETTINGS_SERVICE_BUS, bus,
- NM_SETTINGS_SERVICE_SCOPE, NM_CONNECTION_SCOPE_SYSTEM,
NULL);
if (!self)
return NULL;
@@ -1344,6 +1255,11 @@ nm_sysconfig_settings_new (const char *config_file,
unmanaged_specs_changed (NULL, self);
}
+ dbus_mgr = nm_dbus_manager_get ();
+ bus = nm_dbus_manager_get_connection (dbus_mgr);
+ dbus_g_connection_register_g_object (bus, NM_DBUS_PATH_SETTINGS, G_OBJECT (self));
+ g_object_unref (dbus_mgr);
+
return self;
}
@@ -1371,16 +1287,6 @@ dispose (GObject *object)
g_slist_free (priv->pk_calls);
priv->pk_calls = NULL;
- /* Cancel PolicyKit permissions requests */
- for (iter = priv->permissions_calls; iter; iter = g_slist_next (iter)) {
- PermissionsCall *call = iter->data;
-
- call->disposed = TRUE;
- g_cancellable_cancel (call->cancellable);
- }
- g_slist_free (priv->permissions_calls);
- priv->permissions_calls = NULL;
-
G_OBJECT_CLASS (nm_sysconfig_settings_parent_class)->dispose (object);
}
@@ -1390,7 +1296,8 @@ finalize (GObject *object)
NMSysconfigSettings *self = NM_SYSCONFIG_SETTINGS (object);
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
- g_hash_table_destroy (priv->connections);
+ g_hash_table_destroy (priv->visible_connections);
+ g_hash_table_destroy (priv->all_connections);
clear_unmanaged_specs (self);
@@ -1403,15 +1310,6 @@ finalize (GObject *object)
}
static void
-settings_system_interface_init (NMSettingsSystemInterface *iface)
-{
- iface->get_permissions = get_permissions;
-
- dbus_g_object_type_install_info (G_TYPE_FROM_INTERFACE (iface),
- &dbus_glib_nm_settings_system_object_info);
-}
-
-static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
@@ -1426,14 +1324,14 @@ get_property (GObject *object, guint prop_id,
copy = g_slist_append (copy, g_strdup (iter->data));
g_value_take_boxed (value, copy);
break;
- case NM_SETTINGS_SYSTEM_INTERFACE_PROP_HOSTNAME:
+ case PROP_HOSTNAME:
g_value_take_string (value, nm_sysconfig_settings_get_hostname (self));
/* Don't ever pass NULL through D-Bus */
if (!g_value_get_string (value))
g_value_set_static_string (value, "");
break;
- case NM_SETTINGS_SYSTEM_INTERFACE_PROP_CAN_MODIFY:
+ case PROP_CAN_MODIFY:
g_value_set_boolean (value, !!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS));
break;
default:
@@ -1446,7 +1344,6 @@ static void
nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
- NMSettingsServiceClass *ss_class = NM_SETTINGS_SERVICE_CLASS (class);
g_type_class_add_private (class, sizeof (NMSysconfigSettingsPrivate));
@@ -1455,10 +1352,9 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class)
object_class->get_property = get_property;
object_class->dispose = dispose;
object_class->finalize = finalize;
- ss_class->list_connections = list_connections;
- ss_class->add_connection = add_connection;
/* properties */
+
g_object_class_install_property
(object_class, PROP_UNMANAGED_SPECS,
g_param_spec_boxed (NM_SYSCONFIG_SETTINGS_UNMANAGED_SPECS,
@@ -1467,13 +1363,21 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class)
DBUS_TYPE_G_LIST_OF_STRING,
G_PARAM_READABLE));
- g_object_class_override_property (object_class,
- NM_SETTINGS_SYSTEM_INTERFACE_PROP_HOSTNAME,
- NM_SETTINGS_SYSTEM_INTERFACE_HOSTNAME);
+ g_object_class_install_property
+ (object_class, PROP_HOSTNAME,
+ g_param_spec_string (NM_SYSCONFIG_SETTINGS_HOSTNAME,
+ "Hostname",
+ "Persistent hostname",
+ NULL,
+ G_PARAM_READABLE));
- g_object_class_override_property (object_class,
- NM_SETTINGS_SYSTEM_INTERFACE_PROP_CAN_MODIFY,
- NM_SETTINGS_SYSTEM_INTERFACE_CAN_MODIFY);
+ g_object_class_install_property
+ (object_class, PROP_CAN_MODIFY,
+ g_param_spec_boolean (NM_SYSCONFIG_SETTINGS_CAN_MODIFY,
+ "CanModify",
+ "Can modify anything (hostname, connections, etc)",
+ FALSE,
+ G_PARAM_READABLE));
/* signals */
signals[PROPERTIES_CHANGED] =
@@ -1484,14 +1388,18 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class)
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_VARIANT);
+ signals[NEW_CONNECTION] =
+ g_signal_new (NM_SYSCONFIG_SETTINGS_NEW_CONNECTION,
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, G_TYPE_OBJECT);
dbus_g_error_domain_register (NM_SYSCONFIG_SETTINGS_ERROR,
- NM_DBUS_IFACE_SETTINGS_SYSTEM,
- NM_TYPE_SYSCONFIG_SETTINGS_ERROR);
-
- dbus_g_error_domain_register (NM_SETTINGS_INTERFACE_ERROR,
NM_DBUS_IFACE_SETTINGS,
- NM_TYPE_SETTINGS_INTERFACE_ERROR);
+ NM_TYPE_SYSCONFIG_SETTINGS_ERROR);
/* And register all the settings errors with D-Bus */
dbus_g_error_domain_register (NM_CONNECTION_ERROR, NULL, NM_TYPE_CONNECTION_ERROR);
@@ -1511,6 +1419,10 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class)
dbus_g_error_domain_register (NM_SETTING_WIRELESS_SECURITY_ERROR, NULL, NM_TYPE_SETTING_WIRELESS_SECURITY_ERROR);
dbus_g_error_domain_register (NM_SETTING_WIRELESS_ERROR, NULL, NM_TYPE_SETTING_WIRELESS_ERROR);
dbus_g_error_domain_register (NM_SETTING_ERROR, NULL, NM_TYPE_SETTING_ERROR);
+
+ dbus_g_object_type_install_info (NM_TYPE_SYSCONFIG_SETTINGS,
+ &dbus_glib_nm_settings_object_info);
+
}
static void
@@ -1519,15 +1431,11 @@ nm_sysconfig_settings_init (NMSysconfigSettings *self)
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GError *error = NULL;
- priv->connections = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
+ priv->visible_connections = g_hash_table_new (g_direct_hash, g_direct_equal);
+ priv->all_connections = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
priv->authority = polkit_authority_get_sync (NULL, &error);
- if (priv->authority) {
- priv->auth_changed_id = g_signal_connect (priv->authority,
- "changed",
- G_CALLBACK (pk_authority_changed_cb),
- self);
- } else {
+ if (!priv->authority) {
nm_log_warn (LOGD_SYS_SET, "failed to create PolicyKit authority: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
diff --git a/src/system-settings/nm-sysconfig-settings.h b/src/system-settings/nm-sysconfig-settings.h
index ae2ba68329..948349820b 100644
--- a/src/system-settings/nm-sysconfig-settings.h
+++ b/src/system-settings/nm-sysconfig-settings.h
@@ -27,7 +27,6 @@
#define __NM_SYSCONFIG_SETTINGS_H__
#include <nm-connection.h>
-#include <nm-settings-service.h>
#include "nm-sysconfig-connection.h"
#include "nm-system-config-interface.h"
@@ -41,13 +40,17 @@
#define NM_SYSCONFIG_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettingsClass))
#define NM_SYSCONFIG_SETTINGS_UNMANAGED_SPECS "unmanaged-specs"
+#define NM_SYSCONFIG_SETTINGS_HOSTNAME "hostname"
+#define NM_SYSCONFIG_SETTINGS_CAN_MODIFY "can-modify"
+
+#define NM_SYSCONFIG_SETTINGS_NEW_CONNECTION "new-connection"
typedef struct {
- NMSettingsService parent_instance;
+ GObject parent_instance;
} NMSysconfigSettings;
typedef struct {
- NMSettingsServiceClass parent_class;
+ GObjectClass parent_class;
/* Signals */
void (*properties_changed) (NMSysconfigSettings *self, GHashTable *properties);
@@ -57,9 +60,21 @@ GType nm_sysconfig_settings_get_type (void);
NMSysconfigSettings *nm_sysconfig_settings_new (const char *config_file,
const char *plugins,
- DBusGConnection *bus,
GError **error);
+typedef void (*NMSysconfigSettingsForEachFunc) (NMSysconfigSettings *settings,
+ NMSysconfigConnection *connection,
+ gpointer user_data);
+
+void nm_sysconfig_settings_for_each_connection (NMSysconfigSettings *settings,
+ NMSysconfigSettingsForEachFunc for_each_func,
+ gpointer user_data);
+
+GSList * nm_sysconfig_settings_list_connections (NMSysconfigSettings *settings);
+
+NMSysconfigConnection * nm_sysconfig_settings_get_connection_by_path (NMSysconfigSettings *settings,
+ const char *path);
+
const GSList *nm_sysconfig_settings_get_unmanaged_specs (NMSysconfigSettings *self);
char *nm_sysconfig_settings_get_hostname (NMSysconfigSettings *self);
diff --git a/src/system-settings/nm-system-config-error.c b/src/system-settings/nm-system-config-error.c
index 13d47462f9..a4e52a6b60 100644
--- a/src/system-settings/nm-system-config-error.c
+++ b/src/system-settings/nm-system-config-error.c
@@ -42,6 +42,22 @@ nm_sysconfig_settings_error_get_type (void)
if (etype == 0) {
static const GEnumValue values[] = {
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_GENERAL, "GeneralError"),
+
+ /* The connection was invalid. */
+ ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_INVALID_CONNECTION, "InvalidConnection"),
+ /* The connection is read-only; modifications are not allowed. */
+ ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_READ_ONLY_CONNECTION, "ReadOnlyConnection"),
+ /* A bug in the settings service caused the error. */
+ ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR, "InternalError"),
+ /* Retrieval or request of secrets failed. */
+ ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_SECRETS_UNAVAILABLE, "SecretsUnavailable"),
+ /* The request for secrets was canceled. */
+ ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED, "SecretsRequestCanceled"),
+ /* The request could not be completed because permission was denied. */
+ ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_PERMISSION_DENIED, "PermissionDenied"),
+ /* The requested setting does not existing in this connection. */
+ ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_INVALID_SETTING, "InvalidSetting"),
+
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_NOT_PRIVILEGED, "NotPrivileged"),
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_ADD_NOT_SUPPORTED, "AddNotSupported"),
ENUM_ENTRY (NM_SYSCONFIG_SETTINGS_ERROR_UPDATE_NOT_SUPPORTED, "UpdateNotSupported"),
diff --git a/src/system-settings/nm-system-config-error.h b/src/system-settings/nm-system-config-error.h
index 63896fcd09..82753fde03 100644
--- a/src/system-settings/nm-system-config-error.h
+++ b/src/system-settings/nm-system-config-error.h
@@ -27,6 +27,13 @@
enum {
NM_SYSCONFIG_SETTINGS_ERROR_GENERAL = 0,
+ NM_SYSCONFIG_SETTINGS_ERROR_INVALID_CONNECTION,
+ NM_SYSCONFIG_SETTINGS_ERROR_READ_ONLY_CONNECTION,
+ NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_SECRETS_UNAVAILABLE,
+ NM_SYSCONFIG_SETTINGS_ERROR_SECRETS_REQUEST_CANCELED,
+ NM_SYSCONFIG_SETTINGS_ERROR_PERMISSION_DENIED,
+ NM_SYSCONFIG_SETTINGS_ERROR_INVALID_SETTING,
NM_SYSCONFIG_SETTINGS_ERROR_NOT_PRIVILEGED,
NM_SYSCONFIG_SETTINGS_ERROR_ADD_NOT_SUPPORTED,
NM_SYSCONFIG_SETTINGS_ERROR_UPDATE_NOT_SUPPORTED,
diff --git a/src/system-settings/nm-system-config-interface.c b/src/system-settings/nm-system-config-interface.c
index 90fd93ba3d..f522a9b44c 100644
--- a/src/system-settings/nm-system-config-interface.c
+++ b/src/system-settings/nm-system-config-interface.c
@@ -73,7 +73,7 @@ interface_init (gpointer g_iface)
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
- NM_TYPE_SETTINGS_CONNECTION_INTERFACE);
+ NM_TYPE_SYSCONFIG_CONNECTION);
g_signal_new (NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED,
iface_type,
diff --git a/src/system-settings/nm-system-config-interface.h b/src/system-settings/nm-system-config-interface.h
index 3daceb89bd..439586a408 100644
--- a/src/system-settings/nm-system-config-interface.h
+++ b/src/system-settings/nm-system-config-interface.h
@@ -25,7 +25,7 @@
#include <glib.h>
#include <glib-object.h>
#include <nm-connection.h>
-#include <nm-settings-connection-interface.h>
+#include <nm-sysconfig-connection.h>
G_BEGIN_DECLS
@@ -90,9 +90,9 @@ struct _NMSystemConfigInterface {
/* Called when the plugin is loaded to initialize it */
void (*init) (NMSystemConfigInterface *config);
- /* Returns a GSList of objects that implement NMSettingsConnectionInterface
- * that represent connections the plugin knows about. The returned list
- * is freed by the system settings service.
+ /* Returns a GSList of NMSysconfigConnection objects that represent
+ * connections the plugin knows about. The returned list is freed by the
+ * system settings service.
*/
GSList * (*get_connections) (NMSystemConfigInterface *config);
@@ -127,7 +127,7 @@ struct _NMSystemConfigInterface {
/* Emitted when a new connection has been found by the plugin */
void (*connection_added) (NMSystemConfigInterface *config,
- NMSettingsConnectionInterface *connection);
+ NMSysconfigConnection *connection);
/* Emitted when the list of unmanaged device specifications changes */
void (*unmanaged_specs_changed) (NMSystemConfigInterface *config);
diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c
index cf844992c0..6c2acfb56f 100644
--- a/src/vpn-manager/nm-vpn-connection.c
+++ b/src/vpn-manager/nm-vpn-connection.c
@@ -97,7 +97,6 @@ static guint signals[LAST_SIGNAL] = { 0 };
enum {
PROP_0,
- PROP_SERVICE_NAME,
PROP_CONNECTION,
PROP_SPECIFIC_OBJECT,
PROP_DEVICES,
@@ -1051,9 +1050,6 @@ get_property (GObject *object, guint prop_id,
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object);
switch (prop_id) {
- case PROP_SERVICE_NAME:
- nm_active_connection_scope_to_value (priv->connection, value);
- break;
case PROP_CONNECTION:
g_value_set_boxed (value, nm_connection_get_path (priv->connection));
break;
@@ -1102,13 +1098,6 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
/* properties */
g_object_class_install_property
- (object_class, PROP_SERVICE_NAME,
- g_param_spec_string (NM_ACTIVE_CONNECTION_SERVICE_NAME,
- "Service name",
- "Service name",
- NULL,
- G_PARAM_READABLE));
- g_object_class_install_property
(object_class, PROP_CONNECTION,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_CONNECTION,
"Connection",
diff --git a/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
index 52ce6e152d..e8df1b3764 100644
--- a/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
+++ b/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
@@ -33,7 +33,6 @@
#include <nm-setting-pppoe.h>
#include <nm-setting-wireless-security.h>
#include <nm-setting-8021x.h>
-#include <nm-settings-connection-interface.h>
#include "common.h"
#include "nm-ifcfg-connection.h"
@@ -41,13 +40,7 @@
#include "writer.h"
#include "nm-inotify-helper.h"
-static NMSettingsConnectionInterface *parent_settings_connection_iface;
-
-static void settings_connection_interface_init (NMSettingsConnectionInterface *klass);
-
-G_DEFINE_TYPE_EXTENDED (NMIfcfgConnection, nm_ifcfg_connection, NM_TYPE_SYSCONFIG_CONNECTION, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
- settings_connection_interface_init))
+G_DEFINE_TYPE (NMIfcfgConnection, nm_ifcfg_connection, NM_TYPE_SYSCONFIG_CONNECTION)
#define NM_IFCFG_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IFCFG_CONNECTION, NMIfcfgConnectionPrivate))
@@ -133,7 +126,7 @@ nm_ifcfg_connection_new (const char *filename,
}
/* Update our settings with what was read from the file */
- nm_sysconfig_connection_update (NM_SYSCONFIG_CONNECTION (object), tmp, FALSE, NULL);
+ nm_sysconfig_connection_replace_settings (NM_SYSCONFIG_CONNECTION (object), tmp, NULL);
g_object_unref (tmp);
priv = NM_IFCFG_CONNECTION_GET_PRIVATE (object);
@@ -171,10 +164,10 @@ nm_ifcfg_connection_get_unmanaged_spec (NMIfcfgConnection *self)
return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->unmanaged;
}
-static gboolean
-update (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceUpdateFunc callback,
- gpointer user_data)
+static void
+commit_changes (NMSysconfigConnection *connection,
+ NMSysconfigConnectionCommitFunc callback,
+ gpointer user_data)
{
NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection);
GError *error = NULL;
@@ -205,18 +198,18 @@ update (NMSettingsConnectionInterface *connection,
&error)) {
callback (connection, error, user_data);
g_error_free (error);
- return FALSE;
+ return;
}
out:
if (reread)
g_object_unref (reread);
- return parent_settings_connection_iface->update (connection, callback, user_data);
+ NM_SYSCONFIG_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, callback, user_data);
}
-static gboolean
-do_delete (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceDeleteFunc callback,
+static void
+do_delete (NMSysconfigConnection *connection,
+ NMSysconfigConnectionDeleteFunc callback,
gpointer user_data)
{
NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection);
@@ -230,20 +223,12 @@ do_delete (NMSettingsConnectionInterface *connection,
if (priv->route6file)
g_unlink (priv->route6file);
- return parent_settings_connection_iface->delete (connection, callback, user_data);
+ NM_SYSCONFIG_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->delete (connection, callback, user_data);
}
/* GObject */
static void
-settings_connection_interface_init (NMSettingsConnectionInterface *iface)
-{
- parent_settings_connection_iface = g_type_interface_peek_parent (iface);
- iface->update = update;
- iface->delete = do_delete;
-}
-
-static void
nm_ifcfg_connection_init (NMIfcfgConnection *connection)
{
}
@@ -331,6 +316,7 @@ static void
nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (ifcfg_connection_class);
+ NMSysconfigConnectionClass *sysconfig_class = NM_SYSCONFIG_CONNECTION_CLASS (ifcfg_connection_class);
g_type_class_add_private (ifcfg_connection_class, sizeof (NMIfcfgConnectionPrivate));
@@ -338,6 +324,8 @@ nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class)
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->finalize = finalize;
+ sysconfig_class->delete = do_delete;
+ sysconfig_class->commit_changes = commit_changes;
/* Properties */
g_object_class_install_property
diff --git a/system-settings/plugins/ifcfg-rh/plugin.c b/system-settings/plugins/ifcfg-rh/plugin.c
index e6dfa5bcea..5bd57a030b 100644
--- a/system-settings/plugins/ifcfg-rh/plugin.c
+++ b/system-settings/plugins/ifcfg-rh/plugin.c
@@ -38,12 +38,13 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <nm-setting-connection.h>
-#include <nm-settings-interface.h>
#include "common.h"
#include "nm-dbus-glib-types.h"
#include "plugin.h"
#include "nm-system-config-interface.h"
+#include "nm-system-config-error.h"
+
#include "nm-ifcfg-connection.h"
#include "nm-inotify-helper.h"
#include "shvar.h"
@@ -200,6 +201,17 @@ read_connections (SCPluginIfcfg *plugin)
/* Monitoring */
+/* Callback for nm_sysconfig_connection_replace_and_commit. Report any errors
+ * encountered when commiting connection settings updates. */
+static void
+commit_cb (NMSysconfigConnection *connection, GError *error, gpointer unused)
+{
+ if (error) {
+ PLUGIN_WARN (IFCFG_PLUGIN_NAME, " error updating: %s",
+ (error && error->message) ? error->message : "(unknown)");
+ }
+}
+
static void
connection_changed_handler (SCPluginIfcfg *plugin,
const char *path,
@@ -260,14 +272,9 @@ connection_changed_handler (SCPluginIfcfg *plugin,
g_signal_emit_by_name (plugin, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection);
}
- if (!nm_sysconfig_connection_update (NM_SYSCONFIG_CONNECTION (connection),
- NM_CONNECTION (new),
- TRUE,
- &error)) {
- PLUGIN_WARN (IFCFG_PLUGIN_NAME, " error updating: %s",
- (error && error->message) ? error->message : "(unknown)");
- g_clear_error (&error);
- }
+ nm_sysconfig_connection_replace_and_commit (NM_SYSCONFIG_CONNECTION (connection),
+ NM_CONNECTION (new),
+ commit_cb, NULL);
/* Update unmanaged status */
g_object_set (connection, "unmanaged", new_unmanaged, NULL);
@@ -537,8 +544,8 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
if (!g_path_is_absolute (in_ifcfg)) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
+ NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_INVALID_CONNECTION,
"ifcfg path '%s' is not absolute", in_ifcfg);
return FALSE;
}
@@ -546,8 +553,8 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
connection = g_hash_table_lookup (priv->connections, in_ifcfg);
if (!connection || nm_ifcfg_connection_get_unmanaged_spec (connection)) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INVALID_CONNECTION,
+ NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_INVALID_CONNECTION,
"ifcfg file '%s' unknown", in_ifcfg);
return FALSE;
}
@@ -555,8 +562,8 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION);
if (!s_con) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
"unable to retrieve the connection setting");
return FALSE;
}
@@ -564,8 +571,8 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
uuid = nm_setting_connection_get_uuid (s_con);
if (!uuid) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
"unable to get the UUID");
return FALSE;
}
@@ -573,8 +580,8 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
path = nm_connection_get_path (NM_CONNECTION (connection));
if (!path) {
g_set_error (error,
- NM_SETTINGS_INTERFACE_ERROR,
- NM_SETTINGS_INTERFACE_ERROR_INTERNAL_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR,
+ NM_SYSCONFIG_SETTINGS_ERROR_INTERNAL_ERROR,
"unable to get the connection D-Bus path");
return FALSE;
}
diff --git a/system-settings/plugins/ifnet/nm-ifnet-connection.c b/system-settings/plugins/ifnet/nm-ifnet-connection.c
index e47495cfbe..bfcb7202b2 100644
--- a/system-settings/plugins/ifnet/nm-ifnet-connection.c
+++ b/system-settings/plugins/ifnet/nm-ifnet-connection.c
@@ -34,18 +34,8 @@
#include "wpa_parser.h"
#include "plugin.h"
-static NMSettingsConnectionInterface *parent_settings_connection_iface;
-
-static void settings_connection_interface_init (NMSettingsConnectionInterface *
- klass);
-
-G_DEFINE_TYPE_EXTENDED (NMIfnetConnection, nm_ifnet_connection,
- NM_TYPE_SYSCONFIG_CONNECTION, 0,
- G_IMPLEMENT_INTERFACE
- (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
- settings_connection_interface_init))
-// G_DEFINE_TYPE(NMIfnetConnection, nm_ifnet_connection,
-// NM_TYPE_SYSCONFIG_CONNECTION)
+G_DEFINE_TYPE (NMIfnetConnection, nm_ifnet_connection, NM_TYPE_SYSCONFIG_CONNECTION)
+
#define NM_IFNET_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IFNET_CONNECTION, NMIfnetConnectionPrivate))
enum {
PROP_ZERO,
@@ -84,8 +74,7 @@ nm_ifnet_connection_new (gchar * conn_name)
g_object_unref (tmp);
return NULL;
}
- nm_sysconfig_connection_update (NM_SYSCONFIG_CONNECTION (object), tmp,
- FALSE, NULL);
+ nm_sysconfig_connection_replace_settings (NM_SYSCONFIG_CONNECTION (object), tmp, NULL);
g_object_unref (tmp);
return NM_IFNET_CONNECTION (object);
}
@@ -95,50 +84,49 @@ nm_ifnet_connection_init (NMIfnetConnection * connection)
{
}
-static gboolean
-update (NMSettingsConnectionInterface * connection,
- NMSettingsConnectionInterfaceUpdateFunc callback, gpointer user_data)
+static void
+commit_changes (NMSysconfigConnection *connection,
+ NMSysconfigConnectionCommitFunc callback,
+ gpointer user_data)
{
GError *error = NULL;
gchar *new_conn_name = NULL;
- gboolean result;
- NMIfnetConnectionPrivate *priv =
- NM_IFNET_CONNECTION_GET_PRIVATE (connection);
+ NMIfnetConnectionPrivate *priv = NM_IFNET_CONNECTION_GET_PRIVATE (connection);
+
g_signal_emit (connection, signals[IFNET_CANCEL_MONITORS], 0);
- if (!ifnet_update_parsers_by_connection
- (NM_CONNECTION (connection), priv->conn_name, &new_conn_name,
- CONF_NET_FILE, WPA_SUPPLICANT_CONF, &error)) {
+ if (!ifnet_update_parsers_by_connection (NM_CONNECTION (connection),
+ priv->conn_name,
+ &new_conn_name,
+ CONF_NET_FILE,
+ WPA_SUPPLICANT_CONF,
+ &error)) {
if (new_conn_name)
g_free (new_conn_name);
- PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Failed to update %s",
- priv->conn_name);
+ PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Failed to update %s", priv->conn_name);
reload_parsers ();
callback (connection, error, user_data);
g_error_free (error);
g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0);
- return FALSE;
+ return;
}
g_free (priv->conn_name);
priv->conn_name = new_conn_name;
- result =
- parent_settings_connection_iface->update (connection, callback,
- user_data);
- if (result)
- PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Successfully updated %s",
- priv->conn_name);
+
+ NM_SYSCONFIG_CONNECTION_CLASS (nm_ifnet_connection_parent_class)->commit_changes (connection, callback, user_data);
+ PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Successfully updated %s", priv->conn_name);
+
g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0);
- return result;
}
-static gboolean
-do_delete (NMSettingsConnectionInterface * connection,
- NMSettingsConnectionInterfaceDeleteFunc callback, gpointer user_data)
+static void
+do_delete (NMSysconfigConnection *connection,
+ NMSysconfigConnectionDeleteFunc callback,
+ gpointer user_data)
{
GError *error = NULL;
- gboolean result;
- NMIfnetConnectionPrivate *priv =
- NM_IFNET_CONNECTION_GET_PRIVATE (connection);
+ NMIfnetConnectionPrivate *priv = NM_IFNET_CONNECTION_GET_PRIVATE (connection);
+
g_signal_emit (connection, signals[IFNET_CANCEL_MONITORS], 0);
if (!ifnet_delete_connection_in_parsers
(priv->conn_name, CONF_NET_FILE, WPA_SUPPLICANT_CONF)) {
@@ -148,24 +136,14 @@ do_delete (NMSettingsConnectionInterface * connection,
callback (connection, error, user_data);
g_error_free (error);
g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0);
- return FALSE;
+ return;
}
- result =
- parent_settings_connection_iface->delete (connection, callback,
- user_data);
- if (result)
- PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Successfully deleted %s",
- priv->conn_name);
- g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0);
- return result;
-}
-static void
-settings_connection_interface_init (NMSettingsConnectionInterface * iface)
-{
- parent_settings_connection_iface = g_type_interface_peek_parent (iface);
- iface->update = update;
- iface->delete = do_delete;
+ NM_SYSCONFIG_CONNECTION_CLASS (nm_ifnet_connection_parent_class)->delete (connection, callback, user_data);
+
+ PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Successfully deleted %s",
+ priv->conn_name);
+ g_signal_emit (connection, signals[IFNET_SETUP_MONITORS], 0);
}
static void
@@ -222,6 +200,7 @@ static void
nm_ifnet_connection_class_init (NMIfnetConnectionClass * ifnet_connection_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (ifnet_connection_class);
+ NMSysconfigConnectionClass *sysconfig_class = NM_SYSCONFIG_CONNECTION_CLASS (ifnet_connection_class);
g_type_class_add_private (ifnet_connection_class,
sizeof (NMIfnetConnectionPrivate));
@@ -229,6 +208,8 @@ nm_ifnet_connection_class_init (NMIfnetConnectionClass * ifnet_connection_class)
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->finalize = finalize;
+ sysconfig_class->delete = do_delete;
+ sysconfig_class->commit_changes = commit_changes;
/* Properties */
g_object_class_install_property
diff --git a/system-settings/plugins/ifnet/plugin.c b/system-settings/plugins/ifnet/plugin.c
index 51d560246d..0bc333615e 100644
--- a/system-settings/plugins/ifnet/plugin.c
+++ b/system-settings/plugins/ifnet/plugin.c
@@ -194,23 +194,34 @@ monitor_file_changes (const char *filename,
return monitor;
}
+/* Callback for nm_sysconfig_connection_replace_and_commit. Report any errors
+ * encountered when commiting connection settings updates. */
+static void
+commit_cb (NMSysconfigConnection *connection, GError *error, gpointer unused)
+{
+ if (error) {
+ PLUGIN_WARN (IFNET_PLUGIN_NAME, " error updating: %s",
+ (error && error->message) ? error->message : "(unknown)");
+ } else {
+ NMSettingConnection *s_con;
+
+ s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection),
+ NM_TYPE_SETTING_CONNECTION);
+ g_assert (s_con);
+ PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Connection %s updated",
+ nm_setting_connection_get_id (s_con));
+ }
+}
+
static void
update_old_connection (gchar * conn_name,
NMIfnetConnection * old_conn,
NMIfnetConnection * new_conn,
SCPluginIfnetPrivate * priv)
{
- GError **error = NULL;
-
- if (!nm_sysconfig_connection_update (NM_SYSCONFIG_CONNECTION (old_conn),
- NM_CONNECTION (new_conn), TRUE,
- error)) {
- PLUGIN_WARN (IFNET_PLUGIN_NAME, "error updating: %s",
- (error
- && (*error)) ? (*error)->message : "(unknown)");
- } else
- PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Connection %s updated",
- conn_name);
+ nm_sysconfig_connection_replace_and_commit (NM_SYSCONFIG_CONNECTION (old_conn),
+ NM_CONNECTION (new_conn),
+ commit_cb, NULL);
g_object_unref (new_conn);
}
@@ -302,8 +313,7 @@ reload_connections (gpointer config)
PLUGIN_PRINT (IFNET_PLUGIN_NAME,
"Auto refreshing %s",
conn_name);
- g_signal_emit_by_name (old,
- NM_SETTINGS_CONNECTION_INTERFACE_REMOVED);
+ g_signal_emit_by_name (old, "removed");
g_hash_table_remove
(priv->config_connections,
conn_name);
@@ -334,8 +344,7 @@ reload_connections (gpointer config)
g_hash_table_iter_init (&iter, priv->config_connections);
while (g_hash_table_iter_next (&iter, &key, &value)) {
if (!g_hash_table_lookup (new_conn_names, key)) {
- g_signal_emit_by_name (value,
- NM_SETTINGS_CONNECTION_INTERFACE_REMOVED);
+ g_signal_emit_by_name (value, "removed");
g_hash_table_remove (priv->config_connections, key);
}
}
@@ -423,7 +432,7 @@ SCPluginIfnet_init (NMSystemConfigInterface * config)
g_signal_emit_by_name
(self,
NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED,
- NM_EXPORTED_CONNECTION (value));
+ NM_CONNECTION (value));
}
}
/* Read hostname */
diff --git a/system-settings/plugins/ifupdown/nm-ifupdown-connection.c b/system-settings/plugins/ifupdown/nm-ifupdown-connection.c
index ad9a479a6a..3c584cc3fe 100644
--- a/system-settings/plugins/ifupdown/nm-ifupdown-connection.c
+++ b/system-settings/plugins/ifupdown/nm-ifupdown-connection.c
@@ -58,11 +58,12 @@ nm_ifupdown_connection_new (if_block *block)
}
static void
-get_secrets (NMExportedConnection *exported,
+get_secrets (NMSysconfigConnection *connection,
const gchar *setting_name,
const gchar **hints,
gboolean request_new,
- DBusGMethodInvocation *context)
+ NMSysconfigConnectionGetSecretsFunc callback,
+ gpointer user_data)
{
GError *error = NULL;
@@ -76,12 +77,17 @@ get_secrets (NMExportedConnection *exported,
"%s.%d - security setting name not supported '%s'.",
__FILE__, __LINE__, setting_name);
PLUGIN_PRINT ("SCPlugin-Ifupdown", "%s", error->message);
- dbus_g_method_return_error (context, error);
+ callback (connection, NULL, error, user_data);
g_error_free (error);
return;
}
- NM_EXPORTED_CONNECTION_CLASS (nm_ifupdown_connection_parent_class)->get_secrets (exported, setting_name, hints, request_new, context);
+ NM_SYSCONFIG_CONNECTION_CLASS (nm_ifupdown_connection_parent_class)->get_secrets (connection,
+ setting_name,
+ hints,
+ request_new,
+ callback,
+ user_data);
}
static void
@@ -165,7 +171,7 @@ static void
nm_ifupdown_connection_class_init (NMIfupdownConnectionClass *ifupdown_connection_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (ifupdown_connection_class);
- NMExportedConnectionClass *connection_class = NM_EXPORTED_CONNECTION_CLASS (ifupdown_connection_class);
+ NMSysconfigConnectionClass *connection_class = NM_SYSCONFIG_CONNECTION_CLASS (ifupdown_connection_class);
g_type_class_add_private (ifupdown_connection_class, sizeof (NMIfupdownConnectionPrivate));
diff --git a/system-settings/plugins/ifupdown/plugin.c b/system-settings/plugins/ifupdown/plugin.c
index 33c058e5b4..0acdf0eafb 100644
--- a/system-settings/plugins/ifupdown/plugin.c
+++ b/system-settings/plugins/ifupdown/plugin.c
@@ -179,7 +179,7 @@ sc_plugin_ifupdown_class_init (SCPluginIfupdownClass *req_class)
}
static void
-ignore_cb (NMSettingsConnectionInterface *connection,
+ignore_cb (NMSysconfigConnection *connection,
GError *error,
gpointer user_data)
{
@@ -229,9 +229,9 @@ bind_device_to_connection (SCPluginIfupdown *self,
}
g_byte_array_free (mac_address, TRUE);
- nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (exported),
- ignore_cb,
- NULL);
+ nm_sysconfig_connection_commit_changes (NM_SYSCONFIG_CONNECTION (exported),
+ ignore_cb,
+ NULL);
}
static void
@@ -368,9 +368,9 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
/* Remove any connection for this block that was previously found */
exported = g_hash_table_lookup (priv->iface_connections, block->name);
if (exported) {
- nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (exported),
- ignore_cb,
- NULL);
+ nm_sysconfig_connection_delete (NM_SYSCONFIG_CONNECTION (exported),
+ ignore_cb,
+ NULL);
g_hash_table_remove (priv->iface_connections, block->name);
}
@@ -399,9 +399,9 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
setting = NM_SETTING (nm_connection_get_setting (NM_CONNECTION (exported), NM_TYPE_SETTING_CONNECTION));
g_object_set (setting, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL);
- nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (exported),
- ignore_cb,
- NULL);
+ nm_sysconfig_connection_commit_changes (NM_SYSCONFIG_CONNECTION (exported),
+ ignore_cb,
+ NULL);
PLUGIN_PRINT("SCPlugin-Ifupdown", "autoconnect");
}
@@ -460,7 +460,7 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
for (cl_iter = con_list; cl_iter; cl_iter = g_list_next (cl_iter)) {
g_signal_emit_by_name (self,
NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED,
- NM_EXPORTED_CONNECTION (cl_iter->data));
+ NM_SYSCONFIG_CONNECTION (cl_iter->data));
}
g_list_free (con_list);
}
diff --git a/system-settings/plugins/keyfile/nm-keyfile-connection.c b/system-settings/plugins/keyfile/nm-keyfile-connection.c
index 3c27a54c79..e149869170 100644
--- a/system-settings/plugins/keyfile/nm-keyfile-connection.c
+++ b/system-settings/plugins/keyfile/nm-keyfile-connection.c
@@ -24,7 +24,6 @@
#include <NetworkManager.h>
#include <nm-setting-connection.h>
#include <nm-utils.h>
-#include <nm-settings-connection-interface.h>
#include "nm-system-config-interface.h"
#include "nm-dbus-glib-types.h"
@@ -33,13 +32,7 @@
#include "writer.h"
#include "common.h"
-static NMSettingsConnectionInterface *parent_settings_connection_iface;
-
-static void settings_connection_interface_init (NMSettingsConnectionInterface *klass);
-
-G_DEFINE_TYPE_EXTENDED (NMKeyfileConnection, nm_keyfile_connection, NM_TYPE_SYSCONFIG_CONNECTION, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
- settings_connection_interface_init))
+G_DEFINE_TYPE (NMKeyfileConnection, nm_keyfile_connection, NM_TYPE_SYSCONFIG_CONNECTION)
#define NM_KEYFILE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnectionPrivate))
@@ -80,7 +73,7 @@ nm_keyfile_connection_new (const char *filename, GError **error)
g_assert (priv->filename);
/* Update our settings with what was read from the file */
- nm_sysconfig_connection_update (NM_SYSCONFIG_CONNECTION (object), tmp, FALSE, NULL);
+ nm_sysconfig_connection_replace_settings (NM_SYSCONFIG_CONNECTION (object), tmp, NULL);
g_object_unref (tmp);
/* if for some reason the connection didn't have a UUID, add one */
@@ -114,10 +107,10 @@ nm_keyfile_connection_get_filename (NMKeyfileConnection *self)
return NM_KEYFILE_CONNECTION_GET_PRIVATE (self)->filename;
}
-static gboolean
-update (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceUpdateFunc callback,
- gpointer user_data)
+static void
+commit_changes (NMSysconfigConnection *connection,
+ NMSysconfigConnectionCommitFunc callback,
+ gpointer user_data)
{
NMKeyfileConnectionPrivate *priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (connection);
char *filename = NULL;
@@ -126,7 +119,7 @@ update (NMSettingsConnectionInterface *connection,
if (!write_connection (NM_CONNECTION (connection), KEYFILE_DIR, 0, 0, &filename, &error)) {
callback (connection, error, user_data);
g_clear_error (&error);
- return FALSE;
+ return;
}
if (g_strcmp0 (priv->filename, filename)) {
@@ -136,32 +129,28 @@ update (NMSettingsConnectionInterface *connection,
} else
g_free (filename);
- return parent_settings_connection_iface->update (connection, callback, user_data);
+ NM_SYSCONFIG_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->commit_changes (connection,
+ callback,
+ user_data);
}
-static gboolean
-do_delete (NMSettingsConnectionInterface *connection,
- NMSettingsConnectionInterfaceDeleteFunc callback,
- gpointer user_data)
+static void
+do_delete (NMSysconfigConnection *connection,
+ NMSysconfigConnectionDeleteFunc callback,
+ gpointer user_data)
{
NMKeyfileConnectionPrivate *priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (connection);
g_unlink (priv->filename);
- return parent_settings_connection_iface->delete (connection, callback, user_data);
+ NM_SYSCONFIG_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->delete (connection,
+ callback,
+ user_data);
}
/* GObject */
static void
-settings_connection_interface_init (NMSettingsConnectionInterface *iface)
-{
- parent_settings_connection_iface = g_type_interface_peek_parent (iface);
- iface->update = update;
- iface->delete = do_delete;
-}
-
-static void
nm_keyfile_connection_init (NMKeyfileConnection *connection)
{
}
@@ -215,6 +204,7 @@ static void
nm_keyfile_connection_class_init (NMKeyfileConnectionClass *keyfile_connection_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (keyfile_connection_class);
+ NMSysconfigConnectionClass *sysconfig_class = NM_SYSCONFIG_CONNECTION_CLASS (keyfile_connection_class);
g_type_class_add_private (keyfile_connection_class, sizeof (NMKeyfileConnectionPrivate));
@@ -222,6 +212,8 @@ nm_keyfile_connection_class_init (NMKeyfileConnectionClass *keyfile_connection_c
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->finalize = finalize;
+ sysconfig_class->commit_changes = commit_changes;
+ sysconfig_class->delete = do_delete;
/* Properties */
g_object_class_install_property
diff --git a/system-settings/plugins/keyfile/plugin.c b/system-settings/plugins/keyfile/plugin.c
index 27ae0a06f6..815650e912 100644
--- a/system-settings/plugins/keyfile/plugin.c
+++ b/system-settings/plugins/keyfile/plugin.c
@@ -141,26 +141,28 @@ find_by_uuid (gpointer key, gpointer data, gpointer user_data)
}
static void
-update_connection_settings (NMKeyfileConnection *orig,
- NMKeyfileConnection *new)
-{
- GError *error = NULL;
-
- if (!nm_sysconfig_connection_update (NM_SYSCONFIG_CONNECTION (orig),
- NM_CONNECTION (new),
- TRUE,
- &error)) {
+update_connection_settings_commit_cb (NMSysconfigConnection *orig, GError *error, gpointer user_data) {
+ if (error) {
g_warning ("%s: '%s' / '%s' invalid: %d",
- __func__,
- error ? g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)) : "(none)",
- (error && error->message) ? error->message : "(none)",
- error ? error->code : -1);
+ __func__,
+ error ? g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)) : "(none)",
+ (error && error->message) ? error->message : "(none)",
+ error ? error->code : -1);
g_clear_error (&error);
g_signal_emit_by_name (orig, "removed");
}
}
+static void
+update_connection_settings (NMKeyfileConnection *orig,
+ NMKeyfileConnection *new)
+{
+ nm_sysconfig_connection_replace_and_commit (NM_SYSCONFIG_CONNECTION (orig),
+ NM_CONNECTION (new),
+ update_connection_settings_commit_cb, NULL);
+}
+
/* Monitoring */
static void
diff --git a/system-settings/plugins/keyfile/writer.c b/system-settings/plugins/keyfile/writer.c
index ffac35cff5..c6c9bbb81e 100644
--- a/system-settings/plugins/keyfile/writer.c
+++ b/system-settings/plugins/keyfile/writer.c
@@ -39,6 +39,7 @@
#include <ctype.h>
#include "nm-dbus-glib-types.h"
+#include "nm-system-config-error.h"
#include "writer.h"
#include "common.h"
diff --git a/test/nm-tool.c b/test/nm-tool.c
index b1178eaf0e..922bb63b1e 100644
--- a/test/nm-tool.c
+++ b/test/nm-tool.c
@@ -51,8 +51,7 @@
#define DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT))
#define DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH))
-static GHashTable *user_connections = NULL;
-static GHashTable *system_connections = NULL;
+static GHashTable *connections = NULL;
static gboolean
get_nm_state (NMClient *client)
@@ -260,7 +259,6 @@ get_dev_state_string (NMDeviceState state)
static NMConnection *
get_connection_for_active (NMActiveConnection *active)
{
- NMConnectionScope scope;
const char *path;
g_return_val_if_fail (active != NULL, NULL);
@@ -268,14 +266,7 @@ get_connection_for_active (NMActiveConnection *active)
path = nm_active_connection_get_connection (active);
g_return_val_if_fail (path != NULL, NULL);
- scope = nm_active_connection_get_scope (active);
- if (scope == NM_CONNECTION_SCOPE_USER)
- return (NMConnection *) g_hash_table_lookup (user_connections, path);
- else if (scope == NM_CONNECTION_SCOPE_SYSTEM)
- return (NMConnection *) g_hash_table_lookup (system_connections, path);
-
- g_warning ("error: unknown connection scope");
- return NULL;
+ return (NMConnection *) g_hash_table_lookup (connections, path);
}
struct cb_info {
@@ -566,12 +557,10 @@ detail_vpn (gpointer data, gpointer user_data)
static void
get_one_connection (DBusGConnection *bus,
const char *path,
- NMConnectionScope scope,
GHashTable *table)
{
DBusGProxy *proxy;
NMConnection *connection = NULL;
- const char *service;
GError *error = NULL;
GHashTable *settings = NULL;
@@ -579,10 +568,8 @@ get_one_connection (DBusGConnection *bus,
g_return_if_fail (path != NULL);
g_return_if_fail (table != NULL);
- service = (scope == NM_CONNECTION_SCOPE_SYSTEM) ?
- NM_DBUS_SERVICE_SYSTEM_SETTINGS : NM_DBUS_SERVICE_USER_SETTINGS;
-
- proxy = dbus_g_proxy_new_for_name (bus, service, path, NM_DBUS_IFACE_SETTINGS_CONNECTION);
+ proxy = dbus_g_proxy_new_for_name (bus, NM_DBUS_SERVICE,
+ path, NM_DBUS_IFACE_SETTINGS_CONNECTION);
if (!proxy)
return;
@@ -605,7 +592,6 @@ get_one_connection (DBusGConnection *bus,
goto out;
}
- nm_connection_set_scope (connection, scope);
nm_connection_set_path (connection, path);
g_hash_table_insert (table, g_strdup (path), g_object_ref (connection));
@@ -616,27 +602,29 @@ out:
g_object_unref (proxy);
}
-static void
-get_connections_for_service (DBusGConnection *bus,
- NMConnectionScope scope,
- GHashTable *table)
+static gboolean
+get_all_connections (void)
{
GError *error = NULL;
+ DBusGConnection *bus;
DBusGProxy *proxy;
GPtrArray *paths = NULL;
int i;
- const char *service;
+ gboolean sucess = FALSE;
- service = (scope == NM_CONNECTION_SCOPE_SYSTEM) ?
- NM_DBUS_SERVICE_SYSTEM_SETTINGS : NM_DBUS_SERVICE_USER_SETTINGS;
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (error || !bus) {
+ g_warning ("error: could not connect to dbus");
+ goto out;
+ }
proxy = dbus_g_proxy_new_for_name (bus,
- service,
+ NM_DBUS_SERVICE,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS);
if (!proxy) {
- g_warning ("error: failed to create DBus proxy for %s", service);
- return;
+ g_warning ("error: failed to create DBus proxy for settings service");
+ goto out;
}
if (!dbus_g_proxy_call (proxy, "ListConnections", &error,
@@ -648,33 +636,20 @@ get_connections_for_service (DBusGConnection *bus,
goto out;
}
- for (i = 0; paths && (i < paths->len); i++)
- get_one_connection (bus, g_ptr_array_index (paths, i), scope, table);
-
-out:
- g_object_unref (proxy);
-}
+ connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
-static gboolean
-get_all_connections (void)
-{
- DBusGConnection *bus;
- GError *error = NULL;
-
- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (error || !bus) {
- g_warning ("error: could not connect to dbus");
- return FALSE;
- }
+ for (i = 0; paths && (i < paths->len); i++)
+ get_one_connection (bus, g_ptr_array_index (paths, i), connections);
- user_connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- get_connections_for_service (bus, NM_CONNECTION_SCOPE_USER, user_connections);
+ sucess = TRUE;
- system_connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- get_connections_for_service (bus, NM_CONNECTION_SCOPE_SYSTEM, system_connections);
+out:
+ if (bus)
+ dbus_g_connection_unref (bus);
+ if (proxy)
+ g_object_unref (proxy);
- dbus_g_connection_unref (bus);
- return TRUE;
+ return sucess;
}
int
@@ -713,8 +688,7 @@ main (int argc, char *argv[])
g_ptr_array_foreach ((GPtrArray *) info.active, detail_vpn, &info);
g_object_unref (client);
- g_hash_table_unref (user_connections);
- g_hash_table_unref (system_connections);
+ g_hash_table_unref (connections);
return 0;
}