libnm: add _nm_setting_emit_property_changed() function

Will be used next.
This commit is contained in:
Thomas Haller 2019-01-20 13:49:08 +01:00
parent c7b3c23af2
commit 0b20b44c99
2 changed files with 32 additions and 1 deletions

View file

@ -39,6 +39,8 @@ int _nm_setting_compare_priority (gconstpointer a, gconstpointer b);
/*****************************************************************************/
void _nm_setting_emit_property_changed (NMSetting *setting);
typedef enum NMSettingUpdateSecretResult {
NM_SETTING_UPDATE_SECRET_ERROR = FALSE,
NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED = TRUE,

View file

@ -67,7 +67,7 @@ typedef struct {
NMSettingPriority priority;
} SettingInfo;
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
NM_GOBJECT_PROPERTIES_DEFINE (NMSetting,
PROP_NAME,
);
@ -553,6 +553,35 @@ _nm_setting_class_get_sett_info (NMSettingClass *setting_class)
/*****************************************************************************/
void
_nm_setting_emit_property_changed (NMSetting *setting)
{
/* Some settings have "properties" that are not implemented as GObject properties.
*
* For example:
*
* - gendata-base settings like NMSettingEthtool. Here properties are just
* GVariant values in the gendata hash.
*
* - NMSettingWireGuard's peers are not backed by a GObject property. Instead
* there is C-API to access/modify peers.
*
* We still want to emit property-changed notifications for such properties,
* in particular because NMConnection registers to such signals to re-emit
* it as NM_CONNECTION_CHANGED signal. In fact, there are unlikely any other
* uses of such a property-changed signal, because generally it doesn't make
* too much sense.
*
* So, instead of adding yet another (artificial) signal "setting-changed",
* hijack the "notify" signal and just notify about changes of the "name".
* Of course, the "name" doesn't really ever change, because it's tied to
* the GObject's type.
*/
_notify (setting, PROP_NAME);
}
/*****************************************************************************/
gboolean
_nm_setting_use_legacy_property (NMSetting *setting,
GVariant *connection_dict,