utils: add @filter_func argument to nm_utils_g_value_set_object_path_array()
This commit is contained in:

committed by
Thomas Haller

parent
9e36ccbe28
commit
15d305c07f
@@ -3440,11 +3440,16 @@ nm_utils_g_value_set_object_path (GValue *value, gpointer object)
|
||||
* nm_utils_g_value_set_object_path_array:
|
||||
* @value: a #GValue, initialized to store an object path
|
||||
* @objects: a #GSList of #NMExportedObjects
|
||||
* @filter_func: (allow-none): function to call on each object in @objects
|
||||
* @user_data: data to pass to @filter_func
|
||||
*
|
||||
* Sets @value to an array of object paths of the objects in @objects.
|
||||
*/
|
||||
void
|
||||
nm_utils_g_value_set_object_path_array (GValue *value, GSList *objects)
|
||||
nm_utils_g_value_set_object_path_array (GValue *value,
|
||||
GSList *objects,
|
||||
NMUtilsObjectFunc filter_func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GPtrArray *paths;
|
||||
GSList *iter;
|
||||
@@ -3455,6 +3460,8 @@ nm_utils_g_value_set_object_path_array (GValue *value, GSList *objects)
|
||||
|
||||
if (!nm_exported_object_is_exported (object))
|
||||
continue;
|
||||
if (filter_func && !filter_func (G_OBJECT (object), user_data))
|
||||
continue;
|
||||
g_ptr_array_add (paths, g_strdup (nm_exported_object_get_path (object)));
|
||||
}
|
||||
g_ptr_array_add (paths, NULL);
|
||||
|
@@ -320,7 +320,20 @@ NMUtilsTestFlags nm_utils_get_testing (void);
|
||||
void _nm_utils_set_testing (NMUtilsTestFlags flags);
|
||||
|
||||
void nm_utils_g_value_set_object_path (GValue *value, gpointer object);
|
||||
void nm_utils_g_value_set_object_path_array (GValue *value, GSList *objects);
|
||||
void nm_utils_g_value_set_strv (GValue *value, GPtrArray *strings);
|
||||
|
||||
/**
|
||||
* NMUtilsObjectFunc:
|
||||
* @object: the object to filter on
|
||||
* @user_data: data passed to the function from the caller
|
||||
*
|
||||
* Returns: %TRUE if the object should be used, %FALSE if not
|
||||
*/
|
||||
typedef gboolean (*NMUtilsObjectFunc) (GObject *object, gpointer user_data);
|
||||
|
||||
void nm_utils_g_value_set_object_path_array (GValue *value,
|
||||
GSList *objects,
|
||||
NMUtilsObjectFunc filter_func,
|
||||
gpointer user_data);
|
||||
|
||||
#endif /* __NETWORKMANAGER_UTILS_H__ */
|
||||
|
@@ -501,7 +501,7 @@ get_property (GObject *object, guint prop_id,
|
||||
break;
|
||||
case PROP_SLAVES:
|
||||
list = nm_device_master_get_slaves (NM_DEVICE (object));
|
||||
nm_utils_g_value_set_object_path_array (value, list);
|
||||
nm_utils_g_value_set_object_path_array (value, list, NULL, NULL);
|
||||
g_slist_free (list);
|
||||
break;
|
||||
default:
|
||||
|
@@ -447,7 +447,7 @@ get_property (GObject *object, guint prop_id,
|
||||
break;
|
||||
case PROP_SLAVES:
|
||||
list = nm_device_master_get_slaves (NM_DEVICE (object));
|
||||
nm_utils_g_value_set_object_path_array (value, list);
|
||||
nm_utils_g_value_set_object_path_array (value, list, NULL, NULL);
|
||||
g_slist_free (list);
|
||||
break;
|
||||
default:
|
||||
|
@@ -758,7 +758,7 @@ get_property (GObject *object, guint prop_id,
|
||||
break;
|
||||
case PROP_SLAVES:
|
||||
list = nm_device_master_get_slaves (NM_DEVICE (object));
|
||||
nm_utils_g_value_set_object_path_array (value, list);
|
||||
nm_utils_g_value_set_object_path_array (value, list, NULL, NULL);
|
||||
g_slist_free (list);
|
||||
break;
|
||||
default:
|
||||
|
@@ -5100,7 +5100,7 @@ get_property (GObject *object, guint prop_id,
|
||||
g_value_set_boolean (value, FALSE);
|
||||
break;
|
||||
case PROP_ACTIVE_CONNECTIONS:
|
||||
nm_utils_g_value_set_object_path_array (value, priv->active_connections);
|
||||
nm_utils_g_value_set_object_path_array (value, priv->active_connections, NULL, NULL);
|
||||
break;
|
||||
case PROP_CONNECTIVITY:
|
||||
g_value_set_uint (value, nm_connectivity_get_state (priv->connectivity));
|
||||
@@ -5129,7 +5129,7 @@ get_property (GObject *object, guint prop_id,
|
||||
g_value_set_boolean (value, priv->sleeping);
|
||||
break;
|
||||
case PROP_DEVICES:
|
||||
nm_utils_g_value_set_object_path_array (value, priv->devices);
|
||||
nm_utils_g_value_set_object_path_array (value, priv->devices, NULL, NULL);
|
||||
break;
|
||||
case PROP_METERED:
|
||||
g_value_set_uint (value, priv->metered);
|
||||
|
Reference in New Issue
Block a user