remove nm-settings-connection-interface
NMSettingsConnectionInterface was created to allow the daemon and NM clients to have common code that handled both system and user connections. It's no longer needed now that user settings services are gone. This concludes the flattening of libnm-glib.
This commit is contained in:
@@ -757,13 +757,13 @@ remove_connection (NMManager *manager,
|
||||
/*******************************************************************/
|
||||
|
||||
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));
|
||||
@@ -792,7 +792,7 @@ system_connection_updated_cb (NMSettingsConnectionInterface *connection,
|
||||
}
|
||||
|
||||
static void
|
||||
system_connection_removed_cb (NMSettingsConnectionInterface *connection,
|
||||
system_connection_removed_cb (NMSysconfigConnection *connection,
|
||||
NMManager *manager)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
@@ -807,16 +807,16 @@ system_connection_removed_cb (NMSettingsConnectionInterface *connection,
|
||||
|
||||
static void
|
||||
system_internal_new_connection (NMManager *manager,
|
||||
NMSettingsConnectionInterface *connection)
|
||||
NMSysconfigConnection *connection)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
const char *path;
|
||||
|
||||
g_return_if_fail (connection != NULL);
|
||||
|
||||
g_signal_connect (connection, NM_SETTINGS_CONNECTION_INTERFACE_UPDATED,
|
||||
g_signal_connect (connection, NM_SYSCONFIG_CONNECTION_UPDATED,
|
||||
G_CALLBACK (system_connection_updated_cb), manager);
|
||||
g_signal_connect (connection, NM_SETTINGS_CONNECTION_INTERFACE_REMOVED,
|
||||
g_signal_connect (connection, NM_SYSCONFIG_CONNECTION_REMOVED,
|
||||
G_CALLBACK (system_connection_removed_cb), manager);
|
||||
|
||||
path = nm_connection_get_path (NM_CONNECTION (connection));
|
||||
@@ -826,7 +826,7 @@ system_internal_new_connection (NMManager *manager,
|
||||
|
||||
static void
|
||||
system_new_connection_cb (NMSysconfigSettings *settings,
|
||||
NMSettingsConnectionInterface *connection,
|
||||
NMSysconfigConnection *connection,
|
||||
NMManager *manager)
|
||||
{
|
||||
system_internal_new_connection (manager, connection);
|
||||
@@ -840,7 +840,7 @@ system_query_connections (NMManager *manager)
|
||||
|
||||
system_connections = nm_sysconfig_settings_list_connections (priv->sys_settings);
|
||||
for (iter = system_connections; iter; iter = g_slist_next (iter))
|
||||
system_internal_new_connection (manager, NM_SETTINGS_CONNECTION_INTERFACE (iter->data));
|
||||
system_internal_new_connection (manager, NM_SYSCONFIG_CONNECTION (iter->data));
|
||||
g_slist_free (system_connections);
|
||||
}
|
||||
|
||||
@@ -1838,7 +1838,7 @@ provider_cancel_secrets (NMSecretsProviderInterface *provider, gpointer user_dat
|
||||
}
|
||||
|
||||
static void
|
||||
system_get_secrets_reply_cb (NMSettingsConnectionInterface *connection,
|
||||
system_get_secrets_reply_cb (NMSysconfigConnection *connection,
|
||||
GHashTable *secrets,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -1886,12 +1886,12 @@ system_get_secrets_idle_cb (gpointer user_data)
|
||||
|
||||
hints[0] = info->hint1;
|
||||
hints[1] = info->hint2;
|
||||
nm_settings_connection_interface_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (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;
|
||||
}
|
||||
|
||||
|
@@ -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,31 +98,24 @@ 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)
|
||||
{
|
||||
@@ -250,6 +236,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));
|
||||
|
||||
@@ -258,6 +245,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
|
||||
|
@@ -26,7 +26,6 @@
|
||||
#include "nm-sysconfig-connection.h"
|
||||
#include "nm-system-config-error.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-settings-connection-interface.h"
|
||||
#include "nm-polkit-helpers.h"
|
||||
#include "nm-logging.h"
|
||||
|
||||
@@ -49,16 +48,20 @@ static void impl_sysconfig_connection_get_secrets (NMSysconfigConnection *connec
|
||||
|
||||
#include "nm-sysconfig-connection-glue.h"
|
||||
|
||||
static void settings_connection_interface_init (NMSettingsConnectionInterface *klass);
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (NMSysconfigConnection, nm_sysconfig_connection, NM_TYPE_CONNECTION, 0,
|
||||
G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
|
||||
settings_connection_interface_init))
|
||||
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,
|
||||
REMOVED,
|
||||
|
||||
LAST_SIGNAL
|
||||
};
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
typedef struct {
|
||||
PolkitAuthority *authority;
|
||||
GSList *pk_calls;
|
||||
@@ -102,7 +105,7 @@ nm_sysconfig_connection_replace_settings (NMSysconfigConnection *self,
|
||||
}
|
||||
|
||||
static void
|
||||
ignore_cb (NMSettingsConnectionInterface *connection,
|
||||
ignore_cb (NMSysconfigConnection *connection,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -116,7 +119,7 @@ ignore_cb (NMSettingsConnectionInterface *connection,
|
||||
void
|
||||
nm_sysconfig_connection_replace_and_commit (NMSysconfigConnection *self,
|
||||
NMConnection *new,
|
||||
NMSettingsConnectionInterfaceUpdateFunc callback,
|
||||
NMSysconfigConnectionCommitFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
@@ -133,43 +136,127 @@ nm_sysconfig_connection_replace_and_commit (NMSysconfigConnection *self,
|
||||
if (nm_connection_compare (NM_CONNECTION (self),
|
||||
NM_CONNECTION (new),
|
||||
NM_SETTING_COMPARE_FLAG_EXACT)) {
|
||||
callback (NM_SETTINGS_CONNECTION_INTERFACE (self), NULL, user_data);
|
||||
callback (self, NULL, user_data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (nm_sysconfig_connection_replace_settings (self, new, &error)) {
|
||||
nm_settings_connection_interface_update (NM_SETTINGS_CONNECTION_INTERFACE (self),
|
||||
callback, user_data);
|
||||
nm_sysconfig_connection_commit_changes (self, callback, user_data);
|
||||
} else {
|
||||
callback (NM_SETTINGS_CONNECTION_INTERFACE (self), error, user_data);
|
||||
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 gboolean
|
||||
update (NMSettingsConnectionInterface *connection,
|
||||
NMSettingsConnectionInterfaceUpdateFunc callback,
|
||||
gpointer user_data)
|
||||
static void
|
||||
emit_updated (NMSysconfigConnection *connection)
|
||||
{
|
||||
g_object_ref (connection);
|
||||
nm_settings_connection_interface_emit_updated (connection);
|
||||
callback (connection, NULL, user_data);
|
||||
g_object_unref (connection);
|
||||
return TRUE;
|
||||
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 gboolean
|
||||
do_delete (NMSettingsConnectionInterface *connection,
|
||||
NMSettingsConnectionInterfaceDeleteFunc callback,
|
||||
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);
|
||||
g_signal_emit_by_name (connection, "removed");
|
||||
g_signal_emit (connection, signals[REMOVED], 0);
|
||||
callback (connection, NULL, user_data);
|
||||
g_object_unref (connection);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GValue *
|
||||
@@ -246,16 +333,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;
|
||||
@@ -273,7 +359,7 @@ get_secrets (NMSettingsConnectionInterface *connection,
|
||||
__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);
|
||||
@@ -284,7 +370,7 @@ get_secrets (NMSettingsConnectionInterface *connection,
|
||||
__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
|
||||
@@ -300,7 +386,6 @@ 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;
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
@@ -420,7 +505,7 @@ polkit_call_free (PolkitCall *call)
|
||||
}
|
||||
|
||||
static void
|
||||
con_update_cb (NMSettingsConnectionInterface *connection,
|
||||
con_update_cb (NMSysconfigConnection *connection,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -533,7 +618,7 @@ impl_sysconfig_connection_update (NMSysconfigConnection *self,
|
||||
}
|
||||
|
||||
static void
|
||||
con_delete_cb (NMSettingsConnectionInterface *connection,
|
||||
con_delete_cb (NMSysconfigConnection *connection,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -594,9 +679,7 @@ pk_delete_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
||||
}
|
||||
|
||||
/* Caller is authenticated, now we can finally try to delete */
|
||||
nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (self),
|
||||
con_delete_cb,
|
||||
call);
|
||||
nm_sysconfig_connection_delete (self, con_delete_cb, call);
|
||||
|
||||
out:
|
||||
g_object_unref (pk_result);
|
||||
@@ -630,7 +713,7 @@ impl_sysconfig_connection_delete (NMSysconfigConnection *self,
|
||||
}
|
||||
|
||||
static void
|
||||
con_secrets_cb (NMSettingsConnectionInterface *connection,
|
||||
con_secrets_cb (NMSysconfigConnection *connection,
|
||||
GHashTable *secrets,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
@@ -692,12 +775,12 @@ pk_secrets_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
||||
}
|
||||
|
||||
/* 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,
|
||||
call->setting_name,
|
||||
(const char **) call->hints,
|
||||
call->request_new,
|
||||
con_secrets_cb,
|
||||
call);
|
||||
|
||||
out:
|
||||
g_object_unref (pk_result);
|
||||
@@ -728,14 +811,6 @@ impl_sysconfig_connection_get_secrets (NMSysconfigConnection *self,
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
static void
|
||||
settings_connection_interface_init (NMSettingsConnectionInterface *iface)
|
||||
{
|
||||
iface->update = update;
|
||||
iface->delete = do_delete;
|
||||
iface->get_secrets = get_secrets;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_sysconfig_connection_init (NMSysconfigConnection *self)
|
||||
{
|
||||
@@ -779,6 +854,28 @@ nm_sysconfig_connection_class_init (NMSysconfigConnectionClass *class)
|
||||
|
||||
/* Virtual methods */
|
||||
object_class->dispose = dispose;
|
||||
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);
|
||||
|
||||
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (class),
|
||||
&dbus_glib_nm_sysconfig_connection_object_info);
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#define NM_SYSCONFIG_CONNECTION_H
|
||||
|
||||
#include <nm-connection.h>
|
||||
#include <nm-settings-connection-interface.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@@ -34,25 +33,74 @@ 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 {
|
||||
NMConnection parent;
|
||||
} NMSysconfigConnection;
|
||||
#define NM_SYSCONFIG_CONNECTION_UPDATED "updated"
|
||||
#define NM_SYSCONFIG_CONNECTION_REMOVED "removed"
|
||||
|
||||
typedef struct {
|
||||
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;
|
||||
} NMSysconfigConnectionClass;
|
||||
|
||||
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);
|
||||
|
||||
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,
|
||||
NMSettingsConnectionInterfaceUpdateFunc callback,
|
||||
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);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@@ -76,7 +76,7 @@ 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,
|
||||
@@ -160,7 +160,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);
|
||||
}
|
||||
@@ -342,7 +342,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);
|
||||
@@ -531,7 +531,7 @@ 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);
|
||||
@@ -541,14 +541,14 @@ connection_removed (NMSettingsConnectionInterface *connection,
|
||||
|
||||
static void
|
||||
export_connection (NMSysconfigSettings *self,
|
||||
NMSettingsConnectionInterface *connection)
|
||||
NMSysconfigConnection *connection)
|
||||
{
|
||||
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_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 (NM_IS_SYSCONFIG_CONNECTION (connection));
|
||||
g_return_if_fail (priv->bus != NULL);
|
||||
|
||||
/* Don't allow exporting twice */
|
||||
@@ -563,13 +563,13 @@ export_connection (NMSysconfigSettings *self,
|
||||
|
||||
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))
|
||||
/* A plugin is lying to us. */
|
||||
@@ -577,7 +577,7 @@ claim_connection (NMSysconfigSettings *self,
|
||||
|
||||
g_hash_table_insert (priv->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);
|
||||
|
||||
@@ -589,16 +589,13 @@ claim_connection (NMSysconfigSettings *self,
|
||||
|
||||
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->connections, connection)) {
|
||||
g_signal_emit_by_name (G_OBJECT (connection), NM_SETTINGS_CONNECTION_INTERFACE_REMOVED);
|
||||
g_signal_emit_by_name (G_OBJECT (connection), NM_SYSCONFIG_CONNECTION_REMOVED);
|
||||
g_hash_table_remove (priv->connections, connection);
|
||||
}
|
||||
}
|
||||
@@ -1234,7 +1231,7 @@ cleanup:
|
||||
}
|
||||
|
||||
static void
|
||||
delete_cb (NMSettingsConnectionInterface *connection, GError *error, gpointer user_data)
|
||||
delete_cb (NMSysconfigConnection *connection, GError *error, gpointer user_data)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1256,11 +1253,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,
|
||||
@@ -1278,7 +1275,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;
|
||||
}
|
||||
|
||||
@@ -1329,7 +1326,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);
|
||||
@@ -1348,7 +1345,7 @@ 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);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user