Commit 1bb00ae6 authored by Marius Vollmer's avatar Marius Vollmer Committed by Thomas Haller

manager: Add "Capabilities" property

parent c3ecca22
......@@ -380,6 +380,15 @@
-->
<property name="Version" type="s" access="read"/>
<!--
Capabilities:
The current set of capabilities. See <link
linkend="NMCapability">NMCapability</link> for currently
defined capability numbers.
-->
<property name="Capabilities" type="ai" access="read"/>
<!--
State:
......
......@@ -83,6 +83,14 @@
#define NM_DBUS_INTERFACE_SECRET_AGENT NM_DBUS_INTERFACE ".SecretAgent"
#define NM_DBUS_PATH_SECRET_AGENT "/org/freedesktop/NetworkManager/SecretAgent"
/**
* NMCapability:
*
* #NMCapability names the numbers in the Capabilities property.
**/
typedef enum {
} NMCapability;
/**
* NMState:
* @NM_STATE_UNKNOWN: networking state is unknown
......
......@@ -752,6 +752,7 @@ global:
nm_simple_connection_new_clone;
nm_simple_connection_new_from_dbus;
nm_state_get_type;
nm_capability_get_type;
nm_utils_ap_mode_security_valid;
nm_utils_bin2hexstr;
nm_utils_check_virtual_device_compatibility;
......
......@@ -100,6 +100,8 @@ typedef struct {
} RadioState;
typedef struct {
GArray *capabilities;
GSList *active_connections;
GSList *authorizing_connections;
guint ac_cleanup_id;
......@@ -180,6 +182,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
NM_GOBJECT_PROPERTIES_DEFINE (NMManager,
PROP_VERSION,
PROP_CAPABILITIES,
PROP_STATE,
PROP_STARTUP,
PROP_NETWORKING_ENABLED,
......@@ -5439,6 +5442,45 @@ dbus_connection_changed_cb (NMBusManager *dbus_mgr,
/**********************************************************************/
gboolean
nm_manager_check_capability (NMManager *self,
NMCapability cap)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
int i;
for (i = 0; i < priv->capabilities->len; i++) {
NMCapability test = g_array_index (priv->capabilities, gint, i);
if (test == cap)
return TRUE;
if (test > cap)
return FALSE;
}
return FALSE;
}
static int
cmp_caps (gconstpointer a, gconstpointer b)
{
return *(gint *)a - *(gint *)b;
}
void
nm_manager_set_capability (NMManager *self,
NMCapability cap)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
if (!nm_manager_check_capability (self, cap)) {
g_array_append_val (priv->capabilities, cap);
g_array_sort (priv->capabilities, cmp_caps);
_notify (self, PROP_CAPABILITIES);
}
}
/**********************************************************************/
NM_DEFINE_SINGLETON_REGISTER (NMManager);
NMManager *
......@@ -5485,6 +5527,8 @@ constructed (GObject *object)
G_OBJECT_CLASS (nm_manager_parent_class)->constructed (object);
priv->capabilities = g_array_new (FALSE, FALSE, sizeof (gint));
_set_prop_filter (self, nm_bus_manager_get_connection (priv->dbus_mgr));
priv->settings = nm_settings_new ();
......@@ -5643,6 +5687,12 @@ get_property (GObject *object, guint prop_id,
case PROP_VERSION:
g_value_set_string (value, VERSION);
break;
case PROP_CAPABILITIES:
g_value_set_variant (value, g_variant_new_fixed_array (G_VARIANT_TYPE ("i"),
priv->capabilities->data,
priv->capabilities->len,
sizeof(gint)));
break;
case PROP_STATE:
nm_manager_update_state (self);
g_value_set_uint (value, priv->state);
......@@ -5859,6 +5909,8 @@ dispose (GObject *object)
nm_clear_g_source (&priv->timestamp_update_id);
g_array_free (priv->capabilities, TRUE);
G_OBJECT_CLASS (nm_manager_parent_class)->dispose (object);
}
......@@ -5883,6 +5935,13 @@ nm_manager_class_init (NMManagerClass *manager_class)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_CAPABILITIES] =
g_param_spec_variant (NM_MANAGER_CAPABILITIES, "", "",
G_VARIANT_TYPE ("au"),
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_STATE] =
g_param_spec_uint (NM_MANAGER_STATE, "", "",
0, NM_STATE_DISCONNECTED, 0,
......@@ -6120,4 +6179,3 @@ nm_manager_class_init (NMManagerClass *manager_class)
"CheckpointRollback", impl_manager_checkpoint_rollback,
NULL);
}
......@@ -33,6 +33,7 @@
#define NM_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_MANAGER, NMManagerClass))
#define NM_MANAGER_VERSION "version"
#define NM_MANAGER_CAPABILITIES "capabilities"
#define NM_MANAGER_STATE "state"
#define NM_MANAGER_STARTUP "startup"
#define NM_MANAGER_NETWORKING_ENABLED "networking-enabled"
......@@ -111,5 +112,7 @@ gboolean nm_manager_deactivate_connection (NMManager *manager,
NMDeviceStateReason reason,
GError **error);
gboolean nm_manager_check_capability (NMManager *self, NMCapability cap);
void nm_manager_set_capability (NMManager *self, NMCapability cap);
#endif /* __NETWORKMANAGER_MANAGER_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment