api/settings: add Connections property

Helps out bindings.
This commit is contained in:
Dan Williams 2013-11-25 14:58:21 -06:00
parent 67676c65bf
commit 69fc0d7c87
3 changed files with 29 additions and 0 deletions

View file

@ -147,6 +147,12 @@
</arg>
</method>
<property name="Connections" type="ao" access="read">
<tp:docstring>
List of object paths of available network connection profiles.
</tp:docstring>
</property>
<property name="Hostname" type="s" access="read">
<tp:docstring>
The machine hostname stored in persistent configuration.

View file

@ -164,6 +164,7 @@ enum {
PROP_UNMANAGED_SPECS,
PROP_HOSTNAME,
PROP_CAN_MODIFY,
PROP_CONNECTIONS,
LAST_PROP
};
@ -751,6 +752,7 @@ connection_removed (NMSettingsConnection *connection, gpointer user_data)
/* Re-emit for listeners like NMPolicy */
g_signal_emit (self, signals[CONNECTION_REMOVED], 0, connection);
g_signal_emit_by_name (self, NM_CP_SIGNAL_CONNECTION_REMOVED, connection);
g_object_notify (G_OBJECT (self), NM_SETTINGS_CONNECTIONS);
g_object_unref (connection);
}
@ -879,6 +881,7 @@ claim_connection (NMSettings *self,
/* Internal added signal */
g_signal_emit (self, signals[CONNECTION_ADDED], 0, connection);
g_signal_emit_by_name (self, NM_CP_SIGNAL_CONNECTION_ADDED, connection);
g_object_notify (G_OBJECT (self), NM_SETTINGS_CONNECTIONS);
/* Exported D-Bus signal */
g_signal_emit (self, signals[NEW_CONNECTION], 0, connection);
@ -1873,8 +1876,12 @@ get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMSettings *self = NM_SETTINGS (object);
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
const GSList *specs, *iter;
GSList *copy = NULL;
GHashTableIter citer;
GPtrArray *array;
const char *path;
switch (prop_id) {
case PROP_UNMANAGED_SPECS:
@ -1893,6 +1900,13 @@ get_property (GObject *object, guint prop_id,
case PROP_CAN_MODIFY:
g_value_set_boolean (value, !!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS));
break;
case PROP_CONNECTIONS:
array = g_ptr_array_sized_new (g_hash_table_size (priv->connections));
g_hash_table_iter_init (&citer, priv->connections);
while (g_hash_table_iter_next (&citer, (gpointer) &path, NULL))
g_ptr_array_add (array, g_strdup (path));
g_value_take_boxed (value, array);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1938,6 +1952,14 @@ nm_settings_class_init (NMSettingsClass *class)
FALSE,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_CONNECTIONS,
g_param_spec_boxed (NM_SETTINGS_CONNECTIONS,
"Connections",
"Connections",
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
G_PARAM_READABLE));
/* signals */
signals[PROPERTIES_CHANGED] =
g_signal_new ("properties-changed",

View file

@ -43,6 +43,7 @@
#define NM_SETTINGS_UNMANAGED_SPECS "unmanaged-specs"
#define NM_SETTINGS_HOSTNAME "hostname"
#define NM_SETTINGS_CAN_MODIFY "can-modify"
#define NM_SETTINGS_CONNECTIONS "connections"
#define NM_SETTINGS_SIGNAL_CONNECTION_ADDED "connection-added"
#define NM_SETTINGS_SIGNAL_CONNECTION_UPDATED "connection-updated"