libnm: add nmtst_connection_assert_unchanging() helper

This commit is contained in:
Thomas Haller 2019-05-29 17:10:51 +02:00
parent 31382c9727
commit 1a398421ff
2 changed files with 65 additions and 19 deletions

View file

@ -1689,6 +1689,43 @@ nm_connection_normalize (NMConnection *connection,
return TRUE;
}
/*****************************************************************************/
#if NM_MORE_ASSERTS
static void
_nmtst_connection_unchanging_changed_cb (NMConnection *connection, gpointer user_data)
{
nm_assert_not_reached ();
}
static void
_nmtst_connection_unchanging_secrets_updated_cb (NMConnection *connection, const char *setting_name, gpointer user_data)
{
nm_assert_not_reached ();
}
void
nmtst_connection_assert_unchanging (NMConnection *connection)
{
nm_assert (NM_IS_CONNECTION (connection));
g_signal_connect (connection,
NM_CONNECTION_CHANGED,
G_CALLBACK (_nmtst_connection_unchanging_changed_cb),
NULL);
g_signal_connect (connection,
NM_CONNECTION_SECRETS_CLEARED,
G_CALLBACK (_nmtst_connection_unchanging_changed_cb),
NULL);
g_signal_connect (connection,
NM_CONNECTION_SECRETS_UPDATED,
G_CALLBACK (_nmtst_connection_unchanging_secrets_updated_cb),
NULL);
}
#endif
/*****************************************************************************/
/**
* nm_connection_update_secrets:
* @connection: the #NMConnection
@ -3158,13 +3195,13 @@ nm_connection_default_init (NMConnectionInterface *iface)
*/
signals[SECRETS_UPDATED] =
g_signal_new (NM_CONNECTION_SECRETS_UPDATED,
NM_TYPE_CONNECTION,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMConnectionInterface, secrets_updated),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
NM_TYPE_CONNECTION,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMConnectionInterface, secrets_updated),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
/**
* NMConnection::secrets-cleared:
@ -3175,12 +3212,12 @@ nm_connection_default_init (NMConnectionInterface *iface)
*/
signals[SECRETS_CLEARED] =
g_signal_new (NM_CONNECTION_SECRETS_CLEARED,
NM_TYPE_CONNECTION,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMConnectionInterface, secrets_cleared),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
NM_TYPE_CONNECTION,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMConnectionInterface, secrets_cleared),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* NMConnection::changed:
@ -3192,10 +3229,10 @@ nm_connection_default_init (NMConnectionInterface *iface)
*/
signals[CHANGED] =
g_signal_new (NM_CONNECTION_CHANGED,
NM_TYPE_CONNECTION,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMConnectionInterface, changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
NM_TYPE_CONNECTION,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMConnectionInterface, changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}

View file

@ -203,6 +203,15 @@ NMSettingVerifyResult _nm_connection_verify (NMConnection *connection, GError **
gboolean _nm_connection_remove_setting (NMConnection *connection, GType setting_type);
#if NM_MORE_ASSERTS
void nmtst_connection_assert_unchanging (NMConnection *connection);
#else
static inline void
nmtst_connection_assert_unchanging (NMConnection *connection)
{
}
#endif
NMConnection *_nm_simple_connection_new_from_dbus (GVariant *dict,
NMSettingParseFlags parse_flags,
GError **error);