Re: [PATCH 1/5] New GObject NMProxyConfig added to hold proxy details.
On Tue, 2016-06-28 at 16:45 -0500, Dan Williams wrote: > On Wed, 2016-06-29 at 02:08 +0530, Atul Anand wrote: > > > > Apologies for these stupid mistakes. And there's no reason to > > export > > ProxyConfig on DBus. Only useful property was pac-url which also > > isn't > > needed to be on Bus as the url is apparently passed into pacrunner. > > Will remove them . > No problem, they aren't stupid mistakes you've worked with the NM and "*unless* you've worked with the NM" I meant to say... > GDBus code for a couple years. Plus copy & paste is pretty standard > for a new GObject :) I'm pretty sure nobody writes them from > scratch. > > Dan > > > > > Thanks! > > > > On 6/29/16, Dan Williamswrote: > > > > > > > > > On Fri, 2016-06-24 at 00:42 +0530, Atul Anand wrote: > > > > > > > > > > > > A new Object NMProxyConfig added with properties for proxies, > > > > PAC Url and PAC Script. Getters are setters implemented for > > > > manipulating those fields. > > > > > > > I couldn't find anywhere in the code that actually uses the > > > GObject > > > properties for the ProxyConfig object, it seems everything uses > > > the > > > accessors. Which is fine, as long as the object isn't exported > > > over D- > > > Bus, and since I don't think it is, we probably don't need > > > GObject > > > properties on the ProxyConfig object yet. > > > > > > Dan > > > > > > > > > > > > > > > --- > > > > src/Makefile.am | 4 + > > > > src/nm-proxy-config.c | 243 > > > > ++ > > > > src/nm-proxy-config.h | 53 +++ > > > > 3 files changed, 300 insertions(+) > > > > create mode 100644 src/nm-proxy-config.c > > > > create mode 100644 src/nm-proxy-config.h > > > > > > > > diff --git a/src/Makefile.am b/src/Makefile.am > > > > index 5e289d9..700cfc4 100644 > > > > --- a/src/Makefile.am > > > > +++ b/src/Makefile.am > > > > @@ -415,6 +415,8 @@ libNetworkManager_la_SOURCES = \ > > > > nm-exported-object.h \ > > > > nm-firewall-manager.c \ > > > > nm-firewall-manager.h \ > > > > + nm-proxy-config.c \ > > > > + nm-proxy-config.h \ > > > > nm-ip4-config.c \ > > > > nm-ip4-config.h \ > > > > nm-ip6-config.c \ > > > > @@ -565,6 +567,8 @@ libnm_iface_helper_la_SOURCES = \ > > > > \ > > > > nm-exported-object.c \ > > > > nm-exported-object.h \ > > > > + nm-proxy-config.c \ > > > > + nm-proxy-config.h \ > > > > nm-ip4-config.c \ > > > > nm-ip4-config.h \ > > > > nm-ip6-config.c \ > > > > diff --git a/src/nm-proxy-config.c b/src/nm-proxy-config.c > > > > new file mode 100644 > > > > index 000..93f9b21 > > > > --- /dev/null > > > > +++ b/src/nm-proxy-config.c > > > > @@ -0,0 +1,243 @@ > > > > +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic- > > > > offset: 4 > > > > -*- */ > > > > + > > > > +#include "nm-default.h" > > > > + > > > > +#include "nm-proxy-config.h" > > > > + > > > > +#include > > > > + > > > > +#include "nm-utils.h" > > > > +#include "NetworkManagerUtils.h" > > > > + > > > > +#define NM_PROXY_CONFIG_GET_PRIVATE(o) > > > > (G_TYPE_INSTANCE_GET_PRIVATE > > > > ((o), NM_TYPE_PROXY_CONFIG, NMProxyConfigPrivate)) > > > > + > > > > +G_DEFINE_TYPE (NMProxyConfig, nm_proxy_config, G_TYPE_OBJECT) > > > > + > > > > +typedef struct { > > > > + NMProxyConfigMethod method; > > > > + GPtrArray *proxies; > > > > + char *pac_url; > > > > + char *pac_script; > > > > +} NMProxyConfigPrivate; > > > > + > > > > +NM_GOBJECT_PROPERTIES_DEFINE (NMProxyConfig, > > > > + PROP_METHOD, > > > > + PROP_PROXIES, > > > > + PROP_PAC_URL, > > > > + PROP_PAC_SCRIPT, > > > > +); > > > > + > > > > +NMProxyConfig * > > > > +nm_proxy_config_new (void) > > > > +{ > > > > + return NM_PROXY_CONFIG (g_object_new > > > > (NM_TYPE_PROXY_CONFIG, > > > > NULL)); > > > > +} > > > > + > > > > +void > > > > +nm_proxy_config_set_method (NMProxyConfig *config, > > > > NMProxyConfigMethod method) > > > > +{ > > > > + NMProxyConfigPrivate *priv = > > > > NM_PROXY_CONFIG_GET_PRIVATE > > > > (config); > > > > + > > > > + priv->method = method; > > > > +} > > > > + > > > > +NMProxyConfigMethod > > > > +nm_proxy_config_get_method (const NMProxyConfig *config) > > > > +{ > > > > + NMProxyConfigPrivate *priv = > > > > NM_PROXY_CONFIG_GET_PRIVATE > > > > (config); > > > > + > > > > + return priv->method; > > > > +} > > > > + > > > > +void > > > > +nm_proxy_config_reset_proxies (NMProxyConfig *config) > > > > +{ > > > > + NMProxyConfigPrivate *priv = > > > > NM_PROXY_CONFIG_GET_PRIVATE > > > > (config); > > > > + > > > > + if (priv->proxies->len !=0) { > > > > + g_ptr_array_set_size (priv->proxies, 0); > > > > + _notify (config, PROP_PROXIES); > > > > + } > > > > +} > > > > + > > > > +void > > > > +nm_proxy_config_add_proxy
Re: [PATCH 1/5] New GObject NMProxyConfig added to hold proxy details.
On Wed, 2016-06-29 at 02:08 +0530, Atul Anand wrote: > Apologies for these stupid mistakes. And there's no reason to export > ProxyConfig on DBus. Only useful property was pac-url which also > isn't > needed to be on Bus as the url is apparently passed into pacrunner. > Will remove them . No problem, they aren't stupid mistakes you've worked with the NM and GDBus code for a couple years. Plus copy & paste is pretty standard for a new GObject :) I'm pretty sure nobody writes them from scratch. Dan > Thanks! > > On 6/29/16, Dan Williamswrote: > > > > On Fri, 2016-06-24 at 00:42 +0530, Atul Anand wrote: > > > > > > A new Object NMProxyConfig added with properties for proxies, > > > PAC Url and PAC Script. Getters are setters implemented for > > > manipulating those fields. > > > > > I couldn't find anywhere in the code that actually uses the GObject > > properties for the ProxyConfig object, it seems everything uses the > > accessors. Which is fine, as long as the object isn't exported > > over D- > > Bus, and since I don't think it is, we probably don't need GObject > > properties on the ProxyConfig object yet. > > > > Dan > > > > > > > > --- > > > src/Makefile.am | 4 + > > > src/nm-proxy-config.c | 243 > > > ++ > > > src/nm-proxy-config.h | 53 +++ > > > 3 files changed, 300 insertions(+) > > > create mode 100644 src/nm-proxy-config.c > > > create mode 100644 src/nm-proxy-config.h > > > > > > diff --git a/src/Makefile.am b/src/Makefile.am > > > index 5e289d9..700cfc4 100644 > > > --- a/src/Makefile.am > > > +++ b/src/Makefile.am > > > @@ -415,6 +415,8 @@ libNetworkManager_la_SOURCES = \ > > > nm-exported-object.h \ > > > nm-firewall-manager.c \ > > > nm-firewall-manager.h \ > > > + nm-proxy-config.c \ > > > + nm-proxy-config.h \ > > > nm-ip4-config.c \ > > > nm-ip4-config.h \ > > > nm-ip6-config.c \ > > > @@ -565,6 +567,8 @@ libnm_iface_helper_la_SOURCES = \ > > > \ > > > nm-exported-object.c \ > > > nm-exported-object.h \ > > > + nm-proxy-config.c \ > > > + nm-proxy-config.h \ > > > nm-ip4-config.c \ > > > nm-ip4-config.h \ > > > nm-ip6-config.c \ > > > diff --git a/src/nm-proxy-config.c b/src/nm-proxy-config.c > > > new file mode 100644 > > > index 000..93f9b21 > > > --- /dev/null > > > +++ b/src/nm-proxy-config.c > > > @@ -0,0 +1,243 @@ > > > +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic- > > > offset: 4 > > > -*- */ > > > + > > > +#include "nm-default.h" > > > + > > > +#include "nm-proxy-config.h" > > > + > > > +#include > > > + > > > +#include "nm-utils.h" > > > +#include "NetworkManagerUtils.h" > > > + > > > +#define NM_PROXY_CONFIG_GET_PRIVATE(o) > > > (G_TYPE_INSTANCE_GET_PRIVATE > > > ((o), NM_TYPE_PROXY_CONFIG, NMProxyConfigPrivate)) > > > + > > > +G_DEFINE_TYPE (NMProxyConfig, nm_proxy_config, G_TYPE_OBJECT) > > > + > > > +typedef struct { > > > + NMProxyConfigMethod method; > > > + GPtrArray *proxies; > > > + char *pac_url; > > > + char *pac_script; > > > +} NMProxyConfigPrivate; > > > + > > > +NM_GOBJECT_PROPERTIES_DEFINE (NMProxyConfig, > > > + PROP_METHOD, > > > + PROP_PROXIES, > > > + PROP_PAC_URL, > > > + PROP_PAC_SCRIPT, > > > +); > > > + > > > +NMProxyConfig * > > > +nm_proxy_config_new (void) > > > +{ > > > + return NM_PROXY_CONFIG (g_object_new > > > (NM_TYPE_PROXY_CONFIG, > > > NULL)); > > > +} > > > + > > > +void > > > +nm_proxy_config_set_method (NMProxyConfig *config, > > > NMProxyConfigMethod method) > > > +{ > > > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > > > (config); > > > + > > > + priv->method = method; > > > +} > > > + > > > +NMProxyConfigMethod > > > +nm_proxy_config_get_method (const NMProxyConfig *config) > > > +{ > > > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > > > (config); > > > + > > > + return priv->method; > > > +} > > > + > > > +void > > > +nm_proxy_config_reset_proxies (NMProxyConfig *config) > > > +{ > > > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > > > (config); > > > + > > > + if (priv->proxies->len !=0) { > > > + g_ptr_array_set_size (priv->proxies, 0); > > > + _notify (config, PROP_PROXIES); > > > + } > > > +} > > > + > > > +void > > > +nm_proxy_config_add_proxy (NMProxyConfig *config, const char > > > *proxy) > > > +{ > > > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > > > (config); > > > + int i; > > > + > > > + g_return_if_fail (proxy != NULL); > > > + g_return_if_fail (proxy[0] != '\0'); > > > + > > > + for (i = 0; i < priv->proxies->len; i++) > > > + if (!g_strcmp0 (g_ptr_array_index (priv- > > > >proxies, > > > i), proxy)) > > > + return; > > > + > > > + g_ptr_array_add (priv->proxies, g_strdup (proxy)); > > > + _notify (config, PROP_PROXIES); > > > +} > > > + > > > +void > > > +nm_proxy_config_del_proxy (NMProxyConfig *config, guint i) > > > +{ > > > + NMProxyConfigPrivate *priv =
Re: [PATCH 1/5] New GObject NMProxyConfig added to hold proxy details.
Apologies for these stupid mistakes. And there's no reason to export ProxyConfig on DBus. Only useful property was pac-url which also isn't needed to be on Bus as the url is apparently passed into pacrunner. Will remove them . Thanks! On 6/29/16, Dan Williamswrote: > On Fri, 2016-06-24 at 00:42 +0530, Atul Anand wrote: >> A new Object NMProxyConfig added with properties for proxies, >> PAC Url and PAC Script. Getters are setters implemented for >> manipulating those fields. >> > > I couldn't find anywhere in the code that actually uses the GObject > properties for the ProxyConfig object, it seems everything uses the > accessors. Which is fine, as long as the object isn't exported over D- > Bus, and since I don't think it is, we probably don't need GObject > properties on the ProxyConfig object yet. > > Dan > >> --- >> src/Makefile.am | 4 + >> src/nm-proxy-config.c | 243 >> ++ >> src/nm-proxy-config.h | 53 +++ >> 3 files changed, 300 insertions(+) >> create mode 100644 src/nm-proxy-config.c >> create mode 100644 src/nm-proxy-config.h >> >> diff --git a/src/Makefile.am b/src/Makefile.am >> index 5e289d9..700cfc4 100644 >> --- a/src/Makefile.am >> +++ b/src/Makefile.am >> @@ -415,6 +415,8 @@ libNetworkManager_la_SOURCES = \ >> nm-exported-object.h \ >> nm-firewall-manager.c \ >> nm-firewall-manager.h \ >> +nm-proxy-config.c \ >> +nm-proxy-config.h \ >> nm-ip4-config.c \ >> nm-ip4-config.h \ >> nm-ip6-config.c \ >> @@ -565,6 +567,8 @@ libnm_iface_helper_la_SOURCES = \ >> \ >> nm-exported-object.c \ >> nm-exported-object.h \ >> +nm-proxy-config.c \ >> +nm-proxy-config.h \ >> nm-ip4-config.c \ >> nm-ip4-config.h \ >> nm-ip6-config.c \ >> diff --git a/src/nm-proxy-config.c b/src/nm-proxy-config.c >> new file mode 100644 >> index 000..93f9b21 >> --- /dev/null >> +++ b/src/nm-proxy-config.c >> @@ -0,0 +1,243 @@ >> +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 >> -*- */ >> + >> +#include "nm-default.h" >> + >> +#include "nm-proxy-config.h" >> + >> +#include >> + >> +#include "nm-utils.h" >> +#include "NetworkManagerUtils.h" >> + >> +#define NM_PROXY_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE >> ((o), NM_TYPE_PROXY_CONFIG, NMProxyConfigPrivate)) >> + >> +G_DEFINE_TYPE (NMProxyConfig, nm_proxy_config, G_TYPE_OBJECT) >> + >> +typedef struct { >> +NMProxyConfigMethod method; >> +GPtrArray *proxies; >> +char *pac_url; >> +char *pac_script; >> +} NMProxyConfigPrivate; >> + >> +NM_GOBJECT_PROPERTIES_DEFINE (NMProxyConfig, >> +PROP_METHOD, >> +PROP_PROXIES, >> +PROP_PAC_URL, >> +PROP_PAC_SCRIPT, >> +); >> + >> +NMProxyConfig * >> +nm_proxy_config_new (void) >> +{ >> +return NM_PROXY_CONFIG (g_object_new (NM_TYPE_PROXY_CONFIG, >> NULL)); >> +} >> + >> +void >> +nm_proxy_config_set_method (NMProxyConfig *config, >> NMProxyConfigMethod method) >> +{ >> +NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE >> (config); >> + >> +priv->method = method; >> +} >> + >> +NMProxyConfigMethod >> +nm_proxy_config_get_method (const NMProxyConfig *config) >> +{ >> +NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE >> (config); >> + >> +return priv->method; >> +} >> + >> +void >> +nm_proxy_config_reset_proxies (NMProxyConfig *config) >> +{ >> +NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE >> (config); >> + >> +if (priv->proxies->len !=0) { >> +g_ptr_array_set_size (priv->proxies, 0); >> +_notify (config, PROP_PROXIES); >> +} >> +} >> + >> +void >> +nm_proxy_config_add_proxy (NMProxyConfig *config, const char *proxy) >> +{ >> +NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE >> (config); >> +int i; >> + >> +g_return_if_fail (proxy != NULL); >> +g_return_if_fail (proxy[0] != '\0'); >> + >> +for (i = 0; i < priv->proxies->len; i++) >> +if (!g_strcmp0 (g_ptr_array_index (priv->proxies, >> i), proxy)) >> +return; >> + >> +g_ptr_array_add (priv->proxies, g_strdup (proxy)); >> +_notify (config, PROP_PROXIES); >> +} >> + >> +void >> +nm_proxy_config_del_proxy (NMProxyConfig *config, guint i) >> +{ >> +NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE >> (config); >> + >> +g_return_if_fail (i < priv->proxies->len); >> + >> +g_ptr_array_remove_index (priv->proxies, i); >> +_notify (config, PROP_PROXIES); >> +} >> + >> +guint32 >> +nm_proxy_config_get_num_proxies (const NMProxyConfig *config) >> +{ >> +NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE >> (config); >> + >> +return priv->proxies->len; >> +} >> + >> +const char * >> +nm_proxy_config_get_proxy (const NMProxyConfig *config, guint i) >> +{ >> +NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE >> (config); >> + >> +return g_ptr_array_index (priv->proxies, i);
Re: [PATCH 1/5] New GObject NMProxyConfig added to hold proxy details.
On Fri, 2016-06-24 at 00:42 +0530, Atul Anand wrote: > A new Object NMProxyConfig added with properties for proxies, > PAC Url and PAC Script. Getters are setters implemented for > manipulating those fields. > I couldn't find anywhere in the code that actually uses the GObject properties for the ProxyConfig object, it seems everything uses the accessors. Which is fine, as long as the object isn't exported over D- Bus, and since I don't think it is, we probably don't need GObject properties on the ProxyConfig object yet. Dan > --- > src/Makefile.am | 4 + > src/nm-proxy-config.c | 243 > ++ > src/nm-proxy-config.h | 53 +++ > 3 files changed, 300 insertions(+) > create mode 100644 src/nm-proxy-config.c > create mode 100644 src/nm-proxy-config.h > > diff --git a/src/Makefile.am b/src/Makefile.am > index 5e289d9..700cfc4 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -415,6 +415,8 @@ libNetworkManager_la_SOURCES = \ > nm-exported-object.h \ > nm-firewall-manager.c \ > nm-firewall-manager.h \ > + nm-proxy-config.c \ > + nm-proxy-config.h \ > nm-ip4-config.c \ > nm-ip4-config.h \ > nm-ip6-config.c \ > @@ -565,6 +567,8 @@ libnm_iface_helper_la_SOURCES = \ > \ > nm-exported-object.c \ > nm-exported-object.h \ > + nm-proxy-config.c \ > + nm-proxy-config.h \ > nm-ip4-config.c \ > nm-ip4-config.h \ > nm-ip6-config.c \ > diff --git a/src/nm-proxy-config.c b/src/nm-proxy-config.c > new file mode 100644 > index 000..93f9b21 > --- /dev/null > +++ b/src/nm-proxy-config.c > @@ -0,0 +1,243 @@ > +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 > -*- */ > + > +#include "nm-default.h" > + > +#include "nm-proxy-config.h" > + > +#include > + > +#include "nm-utils.h" > +#include "NetworkManagerUtils.h" > + > +#define NM_PROXY_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE > ((o), NM_TYPE_PROXY_CONFIG, NMProxyConfigPrivate)) > + > +G_DEFINE_TYPE (NMProxyConfig, nm_proxy_config, G_TYPE_OBJECT) > + > +typedef struct { > + NMProxyConfigMethod method; > + GPtrArray *proxies; > + char *pac_url; > + char *pac_script; > +} NMProxyConfigPrivate; > + > +NM_GOBJECT_PROPERTIES_DEFINE (NMProxyConfig, > + PROP_METHOD, > + PROP_PROXIES, > + PROP_PAC_URL, > + PROP_PAC_SCRIPT, > +); > + > +NMProxyConfig * > +nm_proxy_config_new (void) > +{ > + return NM_PROXY_CONFIG (g_object_new (NM_TYPE_PROXY_CONFIG, > NULL)); > +} > + > +void > +nm_proxy_config_set_method (NMProxyConfig *config, > NMProxyConfigMethod method) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + priv->method = method; > +} > + > +NMProxyConfigMethod > +nm_proxy_config_get_method (const NMProxyConfig *config) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + return priv->method; > +} > + > +void > +nm_proxy_config_reset_proxies (NMProxyConfig *config) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + if (priv->proxies->len !=0) { > + g_ptr_array_set_size (priv->proxies, 0); > + _notify (config, PROP_PROXIES); > + } > +} > + > +void > +nm_proxy_config_add_proxy (NMProxyConfig *config, const char *proxy) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + int i; > + > + g_return_if_fail (proxy != NULL); > + g_return_if_fail (proxy[0] != '\0'); > + > + for (i = 0; i < priv->proxies->len; i++) > + if (!g_strcmp0 (g_ptr_array_index (priv->proxies, > i), proxy)) > + return; > + > + g_ptr_array_add (priv->proxies, g_strdup (proxy)); > + _notify (config, PROP_PROXIES); > +} > + > +void > +nm_proxy_config_del_proxy (NMProxyConfig *config, guint i) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + g_return_if_fail (i < priv->proxies->len); > + > + g_ptr_array_remove_index (priv->proxies, i); > + _notify (config, PROP_PROXIES); > +} > + > +guint32 > +nm_proxy_config_get_num_proxies (const NMProxyConfig *config) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + return priv->proxies->len; > +} > + > +const char * > +nm_proxy_config_get_proxy (const NMProxyConfig *config, guint i) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + return g_ptr_array_index (priv->proxies, i); > +} > + > +void > +nm_proxy_config_set_pac_url (NMProxyConfig *config, const char *url) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + g_free (priv->pac_url); > + priv->pac_url = g_strdup (url); > +} > + > +const char * > +nm_proxy_config_get_pac_url (const NMProxyConfig *config) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE >
Re: [PATCH 1/5] New GObject NMProxyConfig added to hold proxy details.
Hi, nice work; the patch set looks overall very good. I'll take a closer look tomorrow. Two general nitpicks: Please comment more. Especially the non-static procedures often need a Gtk-Doc block. E.g. looking at nm_pacrunner_manager_send() I have very little idea why do I need to pass ip* configs, and what are they used for without digging too deep into the code. Also, the logic sometimes need comments: for instance after a quick look at add_ip4_config() I can't figure why it only works for type=vpn. Also, please add license blocks for files you add and copyright notices wherever you add non-trivial amount of code. Thank you, Lubo On Fri, 2016-06-24 at 00:42 +0530, Atul Anand wrote: > A new Object NMProxyConfig added with properties for proxies, > PAC Url and PAC Script. Getters are setters implemented for > manipulating those fields. > --- > src/Makefile.am | 4 + > src/nm-proxy-config.c | 243 > ++ > src/nm-proxy-config.h | 53 +++ > 3 files changed, 300 insertions(+) > create mode 100644 src/nm-proxy-config.c > create mode 100644 src/nm-proxy-config.h > > diff --git a/src/Makefile.am b/src/Makefile.am > index 5e289d9..700cfc4 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -415,6 +415,8 @@ libNetworkManager_la_SOURCES = \ > nm-exported-object.h \ > nm-firewall-manager.c \ > nm-firewall-manager.h \ > + nm-proxy-config.c \ > + nm-proxy-config.h \ > nm-ip4-config.c \ > nm-ip4-config.h \ > nm-ip6-config.c \ > @@ -565,6 +567,8 @@ libnm_iface_helper_la_SOURCES = \ > \ > nm-exported-object.c \ > nm-exported-object.h \ > + nm-proxy-config.c \ > + nm-proxy-config.h \ > nm-ip4-config.c \ > nm-ip4-config.h \ > nm-ip6-config.c \ > diff --git a/src/nm-proxy-config.c b/src/nm-proxy-config.c > new file mode 100644 > index 000..93f9b21 > --- /dev/null > +++ b/src/nm-proxy-config.c > @@ -0,0 +1,243 @@ > +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 > -*- */ > + > +#include "nm-default.h" > + > +#include "nm-proxy-config.h" > + > +#include > + > +#include "nm-utils.h" > +#include "NetworkManagerUtils.h" > + > +#define NM_PROXY_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE > ((o), NM_TYPE_PROXY_CONFIG, NMProxyConfigPrivate)) > + > +G_DEFINE_TYPE (NMProxyConfig, nm_proxy_config, G_TYPE_OBJECT) > + > +typedef struct { > + NMProxyConfigMethod method; > + GPtrArray *proxies; > + char *pac_url; > + char *pac_script; > +} NMProxyConfigPrivate; > + > +NM_GOBJECT_PROPERTIES_DEFINE (NMProxyConfig, > + PROP_METHOD, > + PROP_PROXIES, > + PROP_PAC_URL, > + PROP_PAC_SCRIPT, > +); > + > +NMProxyConfig * > +nm_proxy_config_new (void) > +{ > + return NM_PROXY_CONFIG (g_object_new (NM_TYPE_PROXY_CONFIG, > NULL)); > +} > + > +void > +nm_proxy_config_set_method (NMProxyConfig *config, > NMProxyConfigMethod method) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + priv->method = method; > +} > + > +NMProxyConfigMethod > +nm_proxy_config_get_method (const NMProxyConfig *config) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + return priv->method; > +} > + > +void > +nm_proxy_config_reset_proxies (NMProxyConfig *config) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + if (priv->proxies->len !=0) { > + g_ptr_array_set_size (priv->proxies, 0); > + _notify (config, PROP_PROXIES); > + } > +} > + > +void > +nm_proxy_config_add_proxy (NMProxyConfig *config, const char *proxy) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + int i; > + > + g_return_if_fail (proxy != NULL); > + g_return_if_fail (proxy[0] != '\0'); > + > + for (i = 0; i < priv->proxies->len; i++) > + if (!g_strcmp0 (g_ptr_array_index (priv->proxies, > i), proxy)) > + return; > + > + g_ptr_array_add (priv->proxies, g_strdup (proxy)); > + _notify (config, PROP_PROXIES); > +} > + > +void > +nm_proxy_config_del_proxy (NMProxyConfig *config, guint i) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + g_return_if_fail (i < priv->proxies->len); > + > + g_ptr_array_remove_index (priv->proxies, i); > + _notify (config, PROP_PROXIES); > +} > + > +guint32 > +nm_proxy_config_get_num_proxies (const NMProxyConfig *config) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + return priv->proxies->len; > +} > + > +const char * > +nm_proxy_config_get_proxy (const NMProxyConfig *config, guint i) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE > (config); > + > + return g_ptr_array_index (priv->proxies, i); > +} > + > +void > +nm_proxy_config_set_pac_url (NMProxyConfig *config, const char *url) >
Re: [PATCH 1/5] New GObject NMProxyConfig added to hold proxy details.
NM_PROXY_CONFIG_METHOD_MANUAL and other unused fields get used in next and independent patch set where we implement NMSettingProxy and make a new Tab "Proxy" in nm-connection-editor. On 6/24/16, Atul Anandwrote: > A new Object NMProxyConfig added with properties for proxies, > PAC Url and PAC Script. Getters are setters implemented for > manipulating those fields. > --- > src/Makefile.am | 4 + > src/nm-proxy-config.c | 243 > ++ > src/nm-proxy-config.h | 53 +++ > 3 files changed, 300 insertions(+) > create mode 100644 src/nm-proxy-config.c > create mode 100644 src/nm-proxy-config.h > > diff --git a/src/Makefile.am b/src/Makefile.am > index 5e289d9..700cfc4 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -415,6 +415,8 @@ libNetworkManager_la_SOURCES = \ > nm-exported-object.h \ > nm-firewall-manager.c \ > nm-firewall-manager.h \ > + nm-proxy-config.c \ > + nm-proxy-config.h \ > nm-ip4-config.c \ > nm-ip4-config.h \ > nm-ip6-config.c \ > @@ -565,6 +567,8 @@ libnm_iface_helper_la_SOURCES = \ > \ > nm-exported-object.c \ > nm-exported-object.h \ > + nm-proxy-config.c \ > + nm-proxy-config.h \ > nm-ip4-config.c \ > nm-ip4-config.h \ > nm-ip6-config.c \ > diff --git a/src/nm-proxy-config.c b/src/nm-proxy-config.c > new file mode 100644 > index 000..93f9b21 > --- /dev/null > +++ b/src/nm-proxy-config.c > @@ -0,0 +1,243 @@ > +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- > */ > + > +#include "nm-default.h" > + > +#include "nm-proxy-config.h" > + > +#include > + > +#include "nm-utils.h" > +#include "NetworkManagerUtils.h" > + > +#define NM_PROXY_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), > NM_TYPE_PROXY_CONFIG, NMProxyConfigPrivate)) > + > +G_DEFINE_TYPE (NMProxyConfig, nm_proxy_config, G_TYPE_OBJECT) > + > +typedef struct { > + NMProxyConfigMethod method; > + GPtrArray *proxies; > + char *pac_url; > + char *pac_script; > +} NMProxyConfigPrivate; > + > +NM_GOBJECT_PROPERTIES_DEFINE (NMProxyConfig, > + PROP_METHOD, > + PROP_PROXIES, > + PROP_PAC_URL, > + PROP_PAC_SCRIPT, > +); > + > +NMProxyConfig * > +nm_proxy_config_new (void) > +{ > + return NM_PROXY_CONFIG (g_object_new (NM_TYPE_PROXY_CONFIG, NULL)); > +} > + > +void > +nm_proxy_config_set_method (NMProxyConfig *config, NMProxyConfigMethod > method) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); > + > + priv->method = method; > +} > + > +NMProxyConfigMethod > +nm_proxy_config_get_method (const NMProxyConfig *config) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); > + > + return priv->method; > +} > + > +void > +nm_proxy_config_reset_proxies (NMProxyConfig *config) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); > + > + if (priv->proxies->len !=0) { > + g_ptr_array_set_size (priv->proxies, 0); > + _notify (config, PROP_PROXIES); > + } > +} > + > +void > +nm_proxy_config_add_proxy (NMProxyConfig *config, const char *proxy) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); > + int i; > + > + g_return_if_fail (proxy != NULL); > + g_return_if_fail (proxy[0] != '\0'); > + > + for (i = 0; i < priv->proxies->len; i++) > + if (!g_strcmp0 (g_ptr_array_index (priv->proxies, i), proxy)) > + return; > + > + g_ptr_array_add (priv->proxies, g_strdup (proxy)); > + _notify (config, PROP_PROXIES); > +} > + > +void > +nm_proxy_config_del_proxy (NMProxyConfig *config, guint i) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); > + > + g_return_if_fail (i < priv->proxies->len); > + > + g_ptr_array_remove_index (priv->proxies, i); > + _notify (config, PROP_PROXIES); > +} > + > +guint32 > +nm_proxy_config_get_num_proxies (const NMProxyConfig *config) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); > + > + return priv->proxies->len; > +} > + > +const char * > +nm_proxy_config_get_proxy (const NMProxyConfig *config, guint i) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); > + > + return g_ptr_array_index (priv->proxies, i); > +} > + > +void > +nm_proxy_config_set_pac_url (NMProxyConfig *config, const char *url) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); > + > + g_free (priv->pac_url); > + priv->pac_url = g_strdup (url); > +} > + > +const char * > +nm_proxy_config_get_pac_url (const NMProxyConfig *config) > +{ > + NMProxyConfigPrivate *priv = NM_PROXY_CONFIG_GET_PRIVATE (config); > + > + return priv->pac_url; > +} > + > +void > +nm_proxy_config_set_pac_script (NMProxyConfig *config, const char *script) > +{ > + NMProxyConfigPrivate