2019-09-10 11:19:01 +02:00
|
|
|
// SPDX-License-Identifier: LGPL-2.1+
|
2016-08-16 05:55:55 +05:30
|
|
|
/*
|
2019-10-01 09:20:35 +02:00
|
|
|
* Copyright (C) 2016 Atul Anand <atulhjp@gmail.com>.
|
2016-08-16 05:55:55 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "nm-default.h"
|
|
|
|
|
|
|
|
|
|
#include "nm-setting-proxy.h"
|
2019-01-11 08:32:54 +01:00
|
|
|
|
2016-08-16 05:55:55 +05:30
|
|
|
#include "nm-utils.h"
|
|
|
|
|
#include "nm-setting-private.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:nm-setting-proxy
|
2017-01-13 21:39:04 +01:00
|
|
|
* @short_description: Describes proxy URL, script and other related properties
|
2016-08-16 05:55:55 +05:30
|
|
|
*
|
|
|
|
|
* The #NMSettingProxy object is a #NMSetting subclass that describes properties
|
2017-01-13 21:39:04 +01:00
|
|
|
* related to Proxy settings like PAC URL, PAC script etc.
|
2016-08-16 05:55:55 +05:30
|
|
|
*
|
2016-09-05 21:34:27 +05:30
|
|
|
* NetworkManager support 2 values for the #NMSettingProxy:method property for
|
2017-01-13 21:39:04 +01:00
|
|
|
* proxy. If "auto" is specified then WPAD takes place and the appropriate details
|
|
|
|
|
* are pushed into PacRunner or user can override this URL with a new PAC URL or a
|
|
|
|
|
* PAC script. If "none" is selected then no proxy configuration is given to PacRunner
|
2016-09-05 21:34:27 +05:30
|
|
|
* to fulfill client queries.
|
2016-08-16 05:55:55 +05:30
|
|
|
**/
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
2016-08-16 05:55:55 +05:30
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
|
|
|
|
|
PROP_METHOD,
|
|
|
|
|
PROP_BROWSER_ONLY,
|
|
|
|
|
PROP_PAC_URL,
|
|
|
|
|
PROP_PAC_SCRIPT,
|
|
|
|
|
);
|
2016-08-16 05:55:55 +05:30
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
char *pac_url;
|
|
|
|
|
char *pac_script;
|
2019-12-12 11:51:21 +01:00
|
|
|
NMSettingProxyMethod method;
|
|
|
|
|
bool browser_only:1;
|
2016-08-16 05:55:55 +05:30
|
|
|
} NMSettingProxyPrivate;
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
G_DEFINE_TYPE (NMSettingProxy, nm_setting_proxy, NM_TYPE_SETTING)
|
2016-08-16 05:55:55 +05:30
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
#define NM_SETTING_PROXY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_PROXY, NMSettingProxyPrivate))
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-08-16 05:55:55 +05:30
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_proxy_get_method:
|
|
|
|
|
* @setting: the #NMSettingProxy
|
|
|
|
|
*
|
2017-01-13 21:39:04 +01:00
|
|
|
* Returns the proxy configuration method. By default the value is %NM_SETTING_PROXY_METHOD_NONE.
|
|
|
|
|
* %NM_SETTING_PROXY_METHOD_NONE should be selected for a connection intended for direct network
|
2016-08-16 05:55:55 +05:30
|
|
|
* access.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the proxy configuration method
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.6
|
|
|
|
|
**/
|
|
|
|
|
NMSettingProxyMethod
|
|
|
|
|
nm_setting_proxy_get_method (NMSettingProxy *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_PROXY (setting), NM_SETTING_PROXY_METHOD_NONE);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_PROXY_GET_PRIVATE (setting)->method;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_proxy_get_browser_only:
|
|
|
|
|
* @setting: the #NMSettingProxy
|
|
|
|
|
*
|
2017-01-13 21:39:04 +01:00
|
|
|
* Returns: %TRUE if this proxy configuration is only for browser
|
|
|
|
|
* clients/schemes, %FALSE otherwise.
|
2016-08-16 05:55:55 +05:30
|
|
|
*
|
|
|
|
|
* Since: 1.6
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_proxy_get_browser_only (NMSettingProxy *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_PROXY (setting), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_PROXY_GET_PRIVATE (setting)->browser_only;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_proxy_get_pac_url:
|
|
|
|
|
* @setting: the #NMSettingProxy
|
|
|
|
|
*
|
2017-01-13 21:39:04 +01:00
|
|
|
* Returns: the PAC URL for obtaining PAC file
|
2016-08-16 05:55:55 +05:30
|
|
|
*
|
|
|
|
|
* Since: 1.6
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_proxy_get_pac_url (NMSettingProxy *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_PROXY (setting), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_PROXY_GET_PRIVATE (setting)->pac_url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_proxy_get_pac_script:
|
|
|
|
|
* @setting: the #NMSettingProxy
|
|
|
|
|
*
|
2017-01-13 21:39:04 +01:00
|
|
|
* Returns: the PAC script
|
2016-08-16 05:55:55 +05:30
|
|
|
*
|
|
|
|
|
* Since: 1.6
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_proxy_get_pac_script (NMSettingProxy *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_PROXY (setting), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_PROXY_GET_PRIVATE (setting)->pac_script;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMSettingProxyPrivate *priv = NM_SETTING_PROXY_GET_PRIVATE (setting);
|
|
|
|
|
NMSettingProxyMethod method;
|
|
|
|
|
|
|
|
|
|
method = priv->method;
|
2016-10-04 16:32:09 +02:00
|
|
|
|
|
|
|
|
if (!NM_IN_SET (method,
|
|
|
|
|
NM_SETTING_PROXY_METHOD_NONE,
|
|
|
|
|
NM_SETTING_PROXY_METHOD_AUTO)) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("invalid proxy method"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_PROXY_SETTING_NAME, NM_SETTING_PROXY_PAC_URL);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (method != NM_SETTING_PROXY_METHOD_AUTO) {
|
2016-08-16 05:55:55 +05:30
|
|
|
if (priv->pac_url) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2016-09-05 21:34:27 +05:30
|
|
|
_("this property is not allowed for method none"));
|
2016-08-16 05:55:55 +05:30
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_PROXY_SETTING_NAME, NM_SETTING_PROXY_PAC_URL);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->pac_script) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2016-09-05 21:34:27 +05:30
|
|
|
_("this property is not allowed for method none"));
|
2016-08-16 05:55:55 +05:30
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_PROXY_SETTING_NAME, NM_SETTING_PROXY_PAC_SCRIPT);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-06 22:01:41 +01:00
|
|
|
if (priv->pac_script) {
|
|
|
|
|
if (strlen (priv->pac_script) > 1*1024*1024) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("the script is too large"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_PROXY_SETTING_NAME, NM_SETTING_PROXY_PAC_SCRIPT);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (!g_utf8_validate (priv->pac_script, -1, NULL)) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("the script is not valid utf8"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_PROXY_SETTING_NAME, NM_SETTING_PROXY_PAC_SCRIPT);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (!strstr (priv->pac_script, "FindProxyForURL")) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("the script lacks FindProxyForURL function"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_PROXY_SETTING_NAME, NM_SETTING_PROXY_PAC_SCRIPT);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2016-09-27 11:09:13 +02:00
|
|
|
}
|
|
|
|
|
|
2016-08-16 05:55:55 +05:30
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
2016-08-16 05:55:55 +05:30
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object, guint prop_id,
|
2016-10-04 16:32:09 +02:00
|
|
|
GValue *value, GParamSpec *pspec)
|
2016-08-16 05:55:55 +05:30
|
|
|
{
|
|
|
|
|
NMSettingProxy *setting = NM_SETTING_PROXY (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_METHOD:
|
|
|
|
|
g_value_set_int (value, nm_setting_proxy_get_method (setting));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_BROWSER_ONLY:
|
|
|
|
|
g_value_set_boolean (value, nm_setting_proxy_get_browser_only (setting));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_PAC_URL:
|
|
|
|
|
g_value_set_string (value, nm_setting_proxy_get_pac_url (setting));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_PAC_SCRIPT:
|
|
|
|
|
g_value_set_string (value, nm_setting_proxy_get_pac_script (setting));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMSettingProxyPrivate *priv = NM_SETTING_PROXY_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_METHOD:
|
|
|
|
|
priv->method = g_value_get_int (value);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_BROWSER_ONLY:
|
|
|
|
|
priv->browser_only = g_value_get_boolean (value);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_PAC_URL:
|
|
|
|
|
g_free (priv->pac_url);
|
|
|
|
|
priv->pac_url = g_value_dup_string (value);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_PAC_SCRIPT:
|
|
|
|
|
g_free (priv->pac_script);
|
|
|
|
|
priv->pac_script = g_value_dup_string (value);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
2019-12-12 11:52:11 +01:00
|
|
|
nm_setting_proxy_init (NMSettingProxy *self)
|
2019-01-11 08:32:54 +01:00
|
|
|
{
|
2019-12-12 11:52:11 +01:00
|
|
|
nm_assert (NM_SETTING_PROXY_GET_PRIVATE (self)->method == NM_SETTING_PROXY_METHOD_NONE);
|
2019-01-11 08:32:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_proxy_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #NMSettingProxy object.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the new empty #NMSettingProxy object
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.6
|
|
|
|
|
**/
|
|
|
|
|
NMSetting *
|
|
|
|
|
nm_setting_proxy_new (void)
|
|
|
|
|
{
|
|
|
|
|
return (NMSetting *) g_object_new (NM_TYPE_SETTING_PROXY, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMSettingProxy *self = NM_SETTING_PROXY (object);
|
|
|
|
|
NMSettingProxyPrivate *priv = NM_SETTING_PROXY_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
g_free (priv->pac_url);
|
|
|
|
|
g_free (priv->pac_script);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_setting_proxy_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-16 05:55:55 +05:30
|
|
|
static void
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
nm_setting_proxy_class_init (NMSettingProxyClass *klass)
|
2016-08-16 05:55:55 +05:30
|
|
|
{
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
NMSettingClass *setting_class = NM_SETTING_CLASS (klass);
|
2016-08-16 05:55:55 +05:30
|
|
|
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
g_type_class_add_private (klass, sizeof (NMSettingProxyPrivate));
|
2016-08-16 05:55:55 +05:30
|
|
|
|
|
|
|
|
object_class->get_property = get_property;
|
2019-01-11 08:32:54 +01:00
|
|
|
object_class->set_property = set_property;
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
object_class->finalize = finalize;
|
|
|
|
|
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
setting_class->verify = verify;
|
2016-08-16 05:55:55 +05:30
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingProxy:method:
|
|
|
|
|
*
|
2017-01-13 21:39:04 +01:00
|
|
|
* Method for proxy configuration, Default is %NM_SETTING_PROXY_METHOD_NONE
|
2016-08-16 05:55:55 +05:30
|
|
|
*
|
|
|
|
|
* Since: 1.6
|
|
|
|
|
**/
|
2017-01-17 12:18:42 +01:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: method
|
|
|
|
|
* variable: PROXY_METHOD(+)
|
|
|
|
|
* default: none
|
|
|
|
|
* description: Method for proxy configuration. For "auto", WPAD is used for
|
|
|
|
|
* proxy configuration, or set the PAC file via PAC_URL or PAC_SCRIPT.
|
|
|
|
|
* values: none, auto
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_METHOD] =
|
|
|
|
|
g_param_spec_int (NM_SETTING_PROXY_METHOD, "", "",
|
|
|
|
|
G_MININT32, G_MAXINT32, NM_SETTING_PROXY_METHOD_NONE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2016-08-16 05:55:55 +05:30
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingProxy:browser-only:
|
|
|
|
|
*
|
2017-01-13 21:39:04 +01:00
|
|
|
* Whether the proxy configuration is for browser only.
|
2016-08-16 05:55:55 +05:30
|
|
|
*
|
|
|
|
|
* Since: 1.6
|
|
|
|
|
**/
|
2017-01-17 12:18:42 +01:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: browser-only
|
|
|
|
|
* variable: BROWSER_ONLY(+)
|
|
|
|
|
* default: no
|
|
|
|
|
* description: Whether the proxy configuration is for browser only.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_BROWSER_ONLY] =
|
|
|
|
|
g_param_spec_boolean (NM_SETTING_PROXY_BROWSER_ONLY, "", "",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2016-08-16 05:55:55 +05:30
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingProxy:pac-url:
|
|
|
|
|
*
|
2017-01-13 21:39:04 +01:00
|
|
|
* PAC URL for obtaining PAC file.
|
2016-08-16 05:55:55 +05:30
|
|
|
*
|
|
|
|
|
* Since: 1.6
|
|
|
|
|
**/
|
2017-01-17 12:18:42 +01:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: pac-url
|
|
|
|
|
* variable: PAC_URL(+)
|
|
|
|
|
* description: URL for PAC file.
|
|
|
|
|
* example: PAC_URL=http://wpad.mycompany.com/wpad.dat
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_PAC_URL] =
|
|
|
|
|
g_param_spec_string (NM_SETTING_PROXY_PAC_URL, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2016-08-16 05:55:55 +05:30
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingProxy:pac-script:
|
|
|
|
|
*
|
2017-01-13 21:39:04 +01:00
|
|
|
* PAC script for the connection.
|
2016-08-16 05:55:55 +05:30
|
|
|
*
|
|
|
|
|
* Since: 1.6
|
|
|
|
|
**/
|
2017-01-17 12:18:42 +01:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: pac-script
|
|
|
|
|
* variable: PAC_SCRIPT(+)
|
|
|
|
|
* description: Path of the PAC script.
|
|
|
|
|
* example: PAC_SCRIPT=/home/joe/proxy.pac
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_PAC_SCRIPT] =
|
|
|
|
|
g_param_spec_string (NM_SETTING_PROXY_PAC_SCRIPT, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
|
|
|
|
|
_nm_setting_class_commit (setting_class, NM_META_SETTING_TYPE_PROXY);
|
2016-08-16 05:55:55 +05:30
|
|
|
}
|