mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 18:20:29 +01:00
libnm: implement serialization options (inject timestamp/seen-bssids) for nm_connection_to_dbus_full()
This commit is contained in:
parent
441dd1f3c8
commit
df2ba4226d
3 changed files with 69 additions and 1 deletions
|
|
@ -165,7 +165,13 @@ gpointer _nm_connection_check_main_setting (NMConnection *connection,
|
|||
GError **error);
|
||||
|
||||
typedef struct {
|
||||
int dummy;
|
||||
struct {
|
||||
guint64 val;
|
||||
bool has;
|
||||
} timestamp;
|
||||
|
||||
const char **seen_bssids;
|
||||
|
||||
} NMConnectionSerializationOptions;
|
||||
|
||||
GVariant *nm_connection_to_dbus_full (NMConnection *connection,
|
||||
|
|
|
|||
|
|
@ -590,6 +590,26 @@ nm_setting_connection_get_timestamp (NMSettingConnection *setting)
|
|||
return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->timestamp;
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
_to_dbus_fcn_timestamp (const NMSettInfoSetting *sett_info,
|
||||
guint property_idx,
|
||||
NMConnection *connection,
|
||||
NMSetting *setting,
|
||||
NMConnectionSerializationFlags flags,
|
||||
const NMConnectionSerializationOptions *options)
|
||||
{
|
||||
guint64 v;
|
||||
|
||||
v = options && options->timestamp.has
|
||||
? options->timestamp.val
|
||||
: NM_SETTING_CONNECTION_GET_PRIVATE (setting)->timestamp;
|
||||
|
||||
if (v == 0u)
|
||||
return NULL;
|
||||
|
||||
return g_variant_new_uint64 (v);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_connection_get_read_only:
|
||||
* @setting: the #NMSettingConnection
|
||||
|
|
@ -1875,6 +1895,13 @@ nm_setting_connection_class_init (NMSettingConnectionClass *klass)
|
|||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
_properties_override_add_override (properties_override,
|
||||
obj_properties[PROP_TIMESTAMP],
|
||||
G_VARIANT_TYPE_UINT64,
|
||||
_to_dbus_fcn_timestamp,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/**
|
||||
* NMSettingConnection:read-only:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -725,6 +725,34 @@ nm_setting_wireless_get_seen_bssid (NMSettingWireless *setting,
|
|||
return priv->seen_bssids->pdata[i];
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
_to_dbus_fcn_seen_bssids (const NMSettInfoSetting *sett_info,
|
||||
guint property_idx,
|
||||
NMConnection *connection,
|
||||
NMSetting *setting,
|
||||
NMConnectionSerializationFlags flags,
|
||||
const NMConnectionSerializationOptions *options)
|
||||
{
|
||||
NMSettingWirelessPrivate *priv;
|
||||
|
||||
if ( options
|
||||
&& options->seen_bssids) {
|
||||
return options->seen_bssids[0]
|
||||
? g_variant_new_strv (options->seen_bssids, -1)
|
||||
: NULL;
|
||||
}
|
||||
|
||||
priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
|
||||
|
||||
if ( !priv->seen_bssids
|
||||
|| priv->seen_bssids->len == 0)
|
||||
return NULL;
|
||||
|
||||
return g_variant_new_strv ((const char *const*) priv->seen_bssids->pdata, priv->seen_bssids->len);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||
{
|
||||
|
|
@ -1605,6 +1633,13 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *klass)
|
|||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
_properties_override_add_override (properties_override,
|
||||
obj_properties[PROP_SEEN_BSSIDS],
|
||||
G_VARIANT_TYPE_STRING_ARRAY,
|
||||
_to_dbus_fcn_seen_bssids,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:mtu:
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue