[PATCH 1/5] New 'zone' property of the NMSettingConnection.
- From: Jiri Popelka <jpopelka redhat com>
- To: networkmanager-list gnome org
- Subject: [PATCH 1/5] New 'zone' property of the NMSettingConnection.
- Date: Fri, 7 Oct 2011 15:58:05 +0200
libnm-util/nm-setting-connection
---
libnm-util/libnm-util.ver | 1 +
libnm-util/nm-setting-connection.c | 52 ++++++++++++++++++++++++++++++++++++
libnm-util/nm-setting-connection.h | 9 ++++++
3 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver
index edf5d29..fc06624 100644
--- a/libnm-util/libnm-util.ver
+++ b/libnm-util/libnm-util.ver
@@ -185,6 +185,7 @@ global:
nm_setting_connection_get_id;
nm_setting_connection_get_num_permissions;
nm_setting_connection_get_permission;
+ nm_setting_connection_get_zone;
nm_setting_connection_get_read_only;
nm_setting_connection_get_timestamp;
nm_setting_connection_get_type;
diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c
index e9030b1..aed7190 100644
--- a/libnm-util/nm-setting-connection.c
+++ b/libnm-util/nm-setting-connection.c
@@ -101,6 +101,7 @@ typedef struct {
gboolean autoconnect;
guint64 timestamp;
gboolean read_only;
+ char *zone;
} NMSettingConnectionPrivate;
enum {
@@ -112,6 +113,7 @@ enum {
PROP_AUTOCONNECT,
PROP_TIMESTAMP,
PROP_READ_ONLY,
+ PROP_ZONE,
LAST_PROP
};
@@ -478,6 +480,22 @@ nm_setting_connection_get_read_only (NMSettingConnection *setting)
return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->read_only;
}
+/**
+ * nm_setting_connection_get_zone:
+ * @setting: the #NMSettingConnection
+ *
+ * Returns the #NMSettingConnection:zone property of the connection.
+ *
+ * Returns: the trust level of a connection
+ **/
+const char *
+nm_setting_connection_get_zone (NMSettingConnection *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
+
+ return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->zone;
+}
+
static gint
find_setting_by_name (gconstpointer a, gconstpointer b)
{
@@ -549,6 +567,15 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NM_SETTING_CONNECTION_TYPE);
return FALSE;
}
+ if (!priv->zone) {
+ g_set_error (error,
+ NM_SETTING_CONNECTION_ERROR,
+ NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
+ NM_SETTING_CONNECTION_TYPE);
+ return FALSE;
+ } else if (!strlen (priv->zone)) {
+ /* blank zone means the default zone */
+ }
/* Make sure the corresponding 'type' item is present */
if (all_settings && !g_slist_find_custom (all_settings, priv->type, find_setting_by_name)) {
@@ -591,6 +618,7 @@ finalize (GObject *object)
g_free (priv->id);
g_free (priv->uuid);
g_free (priv->type);
+ g_free (priv->zone);
nm_utils_slist_free (priv->permissions, (GDestroyNotify) permission_free);
G_OBJECT_CLASS (nm_setting_connection_parent_class)->finalize (object);
@@ -644,6 +672,10 @@ set_property (GObject *object, guint prop_id,
case PROP_READ_ONLY:
priv->read_only = g_value_get_boolean (value);
break;
+ case PROP_ZONE:
+ g_free (priv->zone);
+ priv->zone = g_value_dup_string (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -689,6 +721,9 @@ get_property (GObject *object, guint prop_id,
case PROP_READ_ONLY:
g_value_set_boolean (value, nm_setting_connection_get_read_only (setting));
break;
+ case PROP_ZONE:
+ g_value_set_string (value, nm_setting_connection_get_zone (setting));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -876,4 +911,21 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
"cannot yet write updated connections back out.",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
+
+ /**
+ * NMSettingConnection:zone:
+ *
+ * The trust level of a the connection.
+ * Free form case-insensitive string (for example "Home", "Work", "Public").
+ **/
+ g_object_class_install_property
+ (object_class, PROP_ZONE,
+ g_param_spec_string (NM_SETTING_CONNECTION_ZONE,
+ "Zone",
+ "The trust level of a the connection."
+ "Free form case-insensitive string"
+ "(for example \"Home\", \"Work\", \"Public\").",
+ NM_SETTING_CONNECTION_ZONE_DEFAULT,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
+
}
diff --git a/libnm-util/nm-setting-connection.h b/libnm-util/nm-setting-connection.h
index 1ec5bf1..0a7ec81 100644
--- a/libnm-util/nm-setting-connection.h
+++ b/libnm-util/nm-setting-connection.h
@@ -75,6 +75,14 @@ GQuark nm_setting_connection_error_quark (void);
#define NM_SETTING_CONNECTION_TIMESTAMP "timestamp"
#define NM_SETTING_CONNECTION_READ_ONLY "read-only"
#define NM_SETTING_CONNECTION_PERMISSIONS "permissions"
+#define NM_SETTING_CONNECTION_ZONE "zone"
+
+#define NM_SETTING_CONNECTION_ZONE_DEFAULT "default"
+#define NM_SETTING_CONNECTION_ZONE_TRUSTED "trusted"
+#define NM_SETTING_CONNECTION_ZONE_HOME "home"
+#define NM_SETTING_CONNECTION_ZONE_WORK "work"
+#define NM_SETTING_CONNECTION_ZONE_PUBLIC "public"
+#define NM_SETTING_CONNECTION_ZONE_BLOCK "block"
/**
* NMSettingConnection:
@@ -112,6 +120,7 @@ gboolean nm_setting_connection_get_permission (NMSettingConnection *set
const char **out_ptype,
const char **out_pitem,
const char **out_detail);
+const char *nm_setting_connection_get_zone (NMSettingConnection *setting);
gboolean nm_setting_connection_permissions_user_allowed (NMSettingConnection *setting, const char *uname);
gboolean nm_setting_connection_add_permission (NMSettingConnection *setting,
const char *ptype,
--
1.7.6.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]