[PATCH v3 6/7] nmcli: Add Proxy support to nmcli



nmcli fixed to allow users edit proxy properties.
---
 clients/cli/connections.c |  31 ++++-
 clients/cli/devices.c     |   5 +
 clients/cli/settings.c    | 319 +++++++++++++++++++++++++++++++++++++++++++++-
 clients/cli/settings.h    |   1 +
 4 files changed, 354 insertions(+), 2 deletions(-)

diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 10b7df7..e80731f 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -167,6 +167,7 @@ extern NmcOutputField nmc_fields_setting_tun[];
 extern NmcOutputField nmc_fields_setting_ip_tunnel[];
 extern NmcOutputField nmc_fields_setting_macvlan[];
 extern NmcOutputField nmc_fields_setting_vxlan[];
+extern NmcOutputField nmc_fields_setting_proxy[];
 
 /* Available settings for 'connection show <con>' - profile part */
 static NmcOutputField nmc_fields_settings_names[] = {
@@ -199,6 +200,7 @@ static NmcOutputField nmc_fields_settings_names[] = {
        SETTING_FIELD (NM_SETTING_IP_TUNNEL_SETTING_NAME,         nmc_fields_setting_ip_tunnel + 1),         
/* 26 */
        SETTING_FIELD (NM_SETTING_MACVLAN_SETTING_NAME,           nmc_fields_setting_macvlan + 1),           
/* 27 */
        SETTING_FIELD (NM_SETTING_VXLAN_SETTING_NAME,             nmc_fields_setting_vxlan + 1),             
/* 28 */
+       SETTING_FIELD (NM_SETTING_PROXY_SETTING_NAME,             nmc_fields_setting_proxy + 1),             
/* 29 */
        {NULL, NULL, 0, NULL, NULL, FALSE, FALSE, 0}
 };
 #define NMC_FIELDS_SETTINGS_NAMES_ALL_X  NM_SETTING_CONNECTION_SETTING_NAME","\
@@ -228,7 +230,8 @@ static NmcOutputField nmc_fields_settings_names[] = {
                                          NM_SETTING_TUN_SETTING_NAME"," \
                                          NM_SETTING_IP_TUNNEL_SETTING_NAME"," \
                                          NM_SETTING_MACVLAN_SETTING_NAME"," \
-                                         NM_SETTING_VXLAN_SETTING_NAME
+                                         NM_SETTING_VXLAN_SETTING_NAME"," \
+                                         NM_SETTING_PROXY_SETTING_NAME
 #define NMC_FIELDS_SETTINGS_NAMES_ALL    NMC_FIELDS_SETTINGS_NAMES_ALL_X
 
 /* Active connection data */
@@ -2882,6 +2885,7 @@ static const NameItem nmc_bridge_slave_settings [] = {
 static const NameItem nmc_no_slave_settings [] = {
        { NM_SETTING_IP4_CONFIG_SETTING_NAME, NULL,   NULL, FALSE },
        { NM_SETTING_IP6_CONFIG_SETTING_NAME, NULL,   NULL, FALSE },
+       { NM_SETTING_PROXY_SETTING_NAME,      NULL,   NULL, FALSE },
        { NULL, NULL, NULL, FALSE }
 };
 
@@ -4129,6 +4133,20 @@ static OptionInfo option_info[] = {
        { NM_SETTING_IP4_CONFIG_SETTING_NAME,   NM_SETTING_IP_CONFIG_GATEWAY,           "gw4",          
OPTION_NONE, N_("IPv4 gateway [none]"), NULL, NULL, NULL },
        { NM_SETTING_IP6_CONFIG_SETTING_NAME,   NM_SETTING_IP_CONFIG_ADDRESSES,         "ip6",          
OPTION_MULTI, N_("IPv6 address (IP[/plen]) [none]"), NULL, NULL, NULL },
        { NM_SETTING_IP6_CONFIG_SETTING_NAME,   NM_SETTING_IP_CONFIG_GATEWAY,           "gw6",          
OPTION_NONE, N_("IPv6 gateway [none]"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_METHOD,                "method",       
OPTION_NONE, N_("Proxy method"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_HTTP_PROXY,            "http-proxy",   
OPTION_NONE, N_("HTTP Proxy"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_HTTP_PORT,             "http-port",    
OPTION_NONE, N_("HTTP Port"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_HTTP_DEFAULT,          "http-default", 
OPTION_NONE, N_("HTTP Default"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_SSL_PROXY,             "ssl-proxy",    
OPTION_NONE, N_("SSL Proxy"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_SSL_PORT,              "ssl-port",     
OPTION_NONE, N_("SSL Port"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_FTP_PROXY,             "ftp-proxy",    
OPTION_NONE, N_("FTP Proxy"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_FTP_PORT,              "ftp-port",     
OPTION_NONE, N_("FTP Port"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_SOCKS_PROXY,           "socks-proxy",  
OPTION_NONE, N_("SOCKS Proxy"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_SOCKS_PORT,            "socks-port",   
OPTION_NONE, N_("SOCKS Port"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_SOCKS_VERSION_5,       "socks-version-5", 
OPTION_NONE, N_("SOCKS V5"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_NO_PROXY_FOR,          "no-proxy-for", 
OPTION_NONE, N_("NO Proxy For"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_PAC_URL,               "pac-url",      
OPTION_NONE, N_("PAC Url"), NULL, NULL, NULL },
+       { NM_SETTING_PROXY_SETTING_NAME,        NM_SETTING_PROXY_PAC_SCRIPT,            "pac-script",   
OPTION_NONE, N_("PAC Script"), NULL, NULL, NULL },
        { NULL, NULL, NULL, OPTION_NONE, NULL, NULL, NULL, NULL },
 };
 
@@ -4618,6 +4636,8 @@ setting_name_to_name (const char *name)
                return _("IPv4 protocol");
        if (strcmp (name, NM_SETTING_IP6_CONFIG_SETTING_NAME) == 0)
                return _("IPv6 protocol");
+       if (strcmp (name, NM_SETTING_PROXY_SETTING_NAME) == 0)
+               return _("Proxy");
 
        /* Should not happen; but let's still try to be somewhat sensible. */
        return name;
@@ -7549,6 +7569,11 @@ editor_init_new_connection (NmCli *nmc, NMConnection *connection)
                setting = nm_setting_ip6_config_new ();
                nmc_setting_custom_init (setting);
                nm_connection_add_setting (connection, setting);
+
+               /* Also Proxy Setting */
+               setting = nm_setting_proxy_new ();
+               nmc_setting_custom_init (setting);
+               nm_connection_add_setting (connection, setting);
        }
 }
 
@@ -7556,11 +7581,13 @@ static void
 editor_init_existing_connection (NMConnection *connection)
 {
        NMSettingIPConfig *s_ip4, *s_ip6;
+       NMSettingProxy *s_proxy;
        NMSettingWireless *s_wireless;
        NMSettingConnection *s_con;
 
        s_ip4 = nm_connection_get_setting_ip4_config (connection);
        s_ip6 = nm_connection_get_setting_ip6_config (connection);
+       s_proxy = nm_connection_get_setting_proxy (connection);
        s_wireless = nm_connection_get_setting_wireless (connection);
        s_con = nm_connection_get_setting_connection (connection);
 
@@ -7568,6 +7595,8 @@ editor_init_existing_connection (NMConnection *connection)
                nmc_setting_ip4_connect_handlers (s_ip4);
        if (s_ip6)
                nmc_setting_ip6_connect_handlers (s_ip6);
+       if (s_proxy)
+               nmc_setting_proxy_connect_handler (s_proxy);
        if (s_wireless)
                nmc_setting_wireless_connect_handlers (s_wireless);
        if (s_con)
diff --git a/clients/cli/devices.c b/clients/cli/devices.c
index 7b043fd..74393e8 100644
--- a/clients/cli/devices.c
+++ b/clients/cli/devices.c
@@ -3268,6 +3268,7 @@ do_device_wifi_hotspot (NmCli *nmc, int argc, char **argv)
        NMSettingWireless *s_wifi;
        NMSettingWirelessSecurity *s_wsec;
        NMSettingIPConfig *s_ip4, *s_ip6;
+       NMSettingProxy *s_proxy;
        GBytes *ssid_bytes;
        GError *error = NULL;
 
@@ -3440,6 +3441,10 @@ do_device_wifi_hotspot (NmCli *nmc, int argc, char **argv)
        nm_connection_add_setting (connection, NM_SETTING (s_ip6));
        g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL);
 
+       s_proxy = (NMSettingProxy *) nm_setting_proxy_new ();
+       nm_connection_add_setting (connection, NM_SETTING (s_proxy));
+       g_object_set (s_proxy, NM_SETTING_PROXY_METHOD, NM_SETTING_PROXY_METHOD_NONE, NULL);
+
        /* Activate the connection now */
        nmc->nowait_flag = (nmc->timeout == 0);
        nmc->should_wait++;
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
index 98d0c8b..232a4bb 100644
--- a/clients/cli/settings.c
+++ b/clients/cli/settings.c
@@ -795,6 +795,40 @@ NmcOutputField nmc_fields_setting_vxlan[] = {
                                              NM_SETTING_VXLAN_L2_MISS","\
                                              NM_SETTING_VXLAN_L3_MISS
 
+/* Available fields for NM_SETTING_PROXY_SETTING_NAME */
+NmcOutputField nmc_fields_setting_proxy[] = {
+       SETTING_FIELD ("name"),                            /* 0 */
+       SETTING_FIELD (NM_SETTING_PROXY_METHOD),           /* 1 */
+       SETTING_FIELD (NM_SETTING_PROXY_HTTP_PROXY),       /* 2 */
+       SETTING_FIELD (NM_SETTING_PROXY_HTTP_PORT),        /* 3 */
+       SETTING_FIELD (NM_SETTING_PROXY_HTTP_DEFAULT),     /* 4 */
+       SETTING_FIELD (NM_SETTING_PROXY_SSL_PROXY),        /* 5 */
+       SETTING_FIELD (NM_SETTING_PROXY_SSL_PORT),         /* 6 */
+       SETTING_FIELD (NM_SETTING_PROXY_FTP_PROXY),        /* 7 */
+       SETTING_FIELD (NM_SETTING_PROXY_FTP_PORT),         /* 8 */
+       SETTING_FIELD (NM_SETTING_PROXY_SOCKS_PROXY),      /* 9 */
+       SETTING_FIELD (NM_SETTING_PROXY_SOCKS_PORT),       /* 10 */
+       SETTING_FIELD (NM_SETTING_PROXY_SOCKS_VERSION_5),  /* 11 */
+       SETTING_FIELD (NM_SETTING_PROXY_NO_PROXY_FOR),     /* 12 */
+       SETTING_FIELD (NM_SETTING_PROXY_PAC_URL),          /* 13 */
+       SETTING_FIELD (NM_SETTING_PROXY_PAC_SCRIPT),       /* 14 */
+       {NULL, NULL, 0, NULL, FALSE, FALSE, 0}
+};
+#define NMC_FIELDS_SETTING_PROXY_ALL         "name"","\
+                                             NM_SETTING_PROXY_METHOD","\
+                                             NM_SETTING_PROXY_HTTP_PROXY","\
+                                             NM_SETTING_PROXY_HTTP_PORT","\
+                                             NM_SETTING_PROXY_HTTP_DEFAULT","\
+                                             NM_SETTING_PROXY_SSL_PROXY","\
+                                             NM_SETTING_PROXY_SSL_PORT","\
+                                             NM_SETTING_PROXY_FTP_PROXY","\
+                                             NM_SETTING_PROXY_FTP_PORT","\
+                                             NM_SETTING_PROXY_SOCKS_PROXY","\
+                                             NM_SETTING_PROXY_SOCKS_PORT","\
+                                             NM_SETTING_PROXY_SOCKS_VERSION_5","\
+                                             NM_SETTING_PROXY_NO_PROXY_FOR","\
+                                             NM_SETTING_PROXY_PAC_URL","\
+                                             NM_SETTING_PROXY_PAC_SCRIPT
 /*----------------------------------------------------------------------------*/
 static char *
 wep_key_type_to_string (NMWepKeyType type)
@@ -2100,6 +2134,85 @@ DEFINE_GETTER (nmc_property_vxlan_get_rsc, NM_SETTING_VXLAN_RSC)
 DEFINE_GETTER (nmc_property_vxlan_get_l2_miss, NM_SETTING_VXLAN_L2_MISS)
 DEFINE_GETTER (nmc_property_vxlan_get_l3_miss, NM_SETTING_VXLAN_L3_MISS)
 
+/* --- NM_SETTING_PROXY_SETTING_NAME property get functions --- */
+DEFINE_GETTER (nmc_property_proxy_get_http_proxy, NM_SETTING_PROXY_HTTP_PROXY)
+DEFINE_GETTER (nmc_property_proxy_get_http_port, NM_SETTING_PROXY_HTTP_PORT)
+DEFINE_GETTER (nmc_property_proxy_get_http_default, NM_SETTING_PROXY_HTTP_DEFAULT)
+DEFINE_GETTER (nmc_property_proxy_get_ssl_proxy, NM_SETTING_PROXY_SSL_PROXY)
+DEFINE_GETTER (nmc_property_proxy_get_ssl_port, NM_SETTING_PROXY_SSL_PORT)
+DEFINE_GETTER (nmc_property_proxy_get_ftp_proxy, NM_SETTING_PROXY_FTP_PROXY)
+DEFINE_GETTER (nmc_property_proxy_get_ftp_port, NM_SETTING_PROXY_FTP_PORT)
+DEFINE_GETTER (nmc_property_proxy_get_socks_proxy, NM_SETTING_PROXY_SOCKS_PROXY)
+DEFINE_GETTER (nmc_property_proxy_get_socks_port, NM_SETTING_PROXY_SOCKS_PORT)
+DEFINE_GETTER (nmc_property_proxy_get_socks_version_5, NM_SETTING_PROXY_SOCKS_VERSION_5)
+DEFINE_GETTER (nmc_property_proxy_get_no_proxy_for, NM_SETTING_PROXY_NO_PROXY_FOR)
+DEFINE_GETTER (nmc_property_proxy_get_pac_url, NM_SETTING_PROXY_PAC_URL)
+DEFINE_GETTER (nmc_property_proxy_get_pac_script, NM_SETTING_PROXY_PAC_SCRIPT)
+
+static char *
+nmc_property_proxy_get_method (NMSetting *setting, NmcPropertyGetType get_type)
+{
+       NMSettingProxy *s_proxy = NM_SETTING_PROXY (setting);
+       NMSettingProxyMethod method;
+
+       method = nm_setting_proxy_get_method (s_proxy);
+       return nm_utils_enum_to_str (nm_setting_proxy_method_get_type (), method);
+}
+
+static gboolean
+nmc_property_proxy_set_method (NMSetting *setting, const char *prop,
+                                  const char *val, GError **error)
+{
+       NMSettingProxyMethod method;
+       gboolean ret;
+
+       ret = nm_utils_enum_from_str (nm_setting_proxy_method_get_type(), val,
+                                      (int *) &method, NULL);
+
+       if (!ret) {
+               gs_free const char **values = NULL;
+               gs_free char *values_str = NULL;
+
+               values = nm_utils_enum_get_values (nm_setting_proxy_method_get_type (),
+                                                  NM_SETTING_PROXY_METHOD_AUTO,
+                                                  G_MAXINT);
+               values_str = g_strjoinv (",", (char **) values);
+               g_set_error (error, 1, 0, _("invalid method '%s', use one of %s"),
+                            val, values_str);
+
+               return FALSE;
+       }
+
+       g_object_set (setting, prop, method, NULL);
+       return TRUE;
+}
+
+/* No Proxy For */
+static gboolean
+nmc_property_proxy_set_no_proxy_for (NMSetting *setting, const char *prop, const char *val, GError **error)
+{
+       char **strv = NULL, **no_proxy_for = NULL, **iter;
+       GPtrArray *tmp_array = NULL;
+
+       g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+       tmp_array = g_ptr_array_new ();
+       strv = nmc_strsplit_set (val, " \t,", 0);
+       for (iter = strv; iter && *iter; iter++) {
+               char *stripped = g_strstrip (*iter);
+
+               if (strlen (stripped))
+                       g_ptr_array_add (tmp_array, g_strdup (stripped));
+       }
+       g_strfreev (strv);
+
+       g_ptr_array_add (tmp_array, NULL);
+       no_proxy_for = (char **) g_ptr_array_free (tmp_array, (tmp_array->len == 1));
+
+       g_object_set (setting, prop, no_proxy_for, NULL);
+       return TRUE;
+}
+
 /*----------------------------------------------------------------------------*/
 
 static void
@@ -2311,6 +2424,56 @@ ipv6_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
 }
 
 static void
+proxy_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
+{
+       NMSettingProxyMethod method;
+
+       method = nm_setting_proxy_get_method (NM_SETTING_PROXY (object));
+
+       switch (method) {
+       case NM_SETTING_PROXY_METHOD_AUTO:
+               g_object_set (object,
+                             NM_SETTING_PROXY_HTTP_PROXY, NULL,
+                             NM_SETTING_PROXY_HTTP_PORT, 0,
+                             NM_SETTING_PROXY_HTTP_DEFAULT, FALSE,
+                             NM_SETTING_PROXY_SSL_PROXY, NULL,
+                             NM_SETTING_PROXY_SSL_PORT, 0,
+                             NM_SETTING_PROXY_FTP_PROXY, NULL,
+                             NM_SETTING_PROXY_FTP_PORT, 0,
+                             NM_SETTING_PROXY_SOCKS_PROXY, NULL,
+                             NM_SETTING_PROXY_SOCKS_PORT, 0,
+                             NM_SETTING_PROXY_SOCKS_VERSION_5, FALSE,
+                             NM_SETTING_PROXY_NO_PROXY_FOR, NULL,
+                             NULL);
+
+               break;
+       case NM_SETTING_PROXY_METHOD_MANUAL:
+               g_object_set (object,
+                             NM_SETTING_PROXY_PAC_URL, NULL,
+                             NM_SETTING_PROXY_PAC_SCRIPT, NULL,
+                             NULL);
+
+               break;
+       case NM_SETTING_PROXY_METHOD_NONE:
+               g_object_set (object,
+                             NM_SETTING_PROXY_HTTP_PROXY, NULL,
+                             NM_SETTING_PROXY_HTTP_PORT, 0,
+                             NM_SETTING_PROXY_HTTP_DEFAULT, FALSE,
+                             NM_SETTING_PROXY_SSL_PROXY, NULL,
+                             NM_SETTING_PROXY_SSL_PORT, 0,
+                             NM_SETTING_PROXY_FTP_PROXY, NULL,
+                             NM_SETTING_PROXY_FTP_PORT, 0,
+                             NM_SETTING_PROXY_SOCKS_PROXY, NULL,
+                             NM_SETTING_PROXY_SOCKS_PORT, 0,
+                             NM_SETTING_PROXY_SOCKS_VERSION_5, FALSE,
+                             NM_SETTING_PROXY_NO_PROXY_FOR, NULL,
+                             NM_SETTING_PROXY_PAC_URL, NULL,
+                             NM_SETTING_PROXY_PAC_SCRIPT, NULL,
+                             NULL);
+       }
+}
+
+static void
 wireless_band_channel_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
 {
        const char *value = NULL, *mode;
@@ -2388,6 +2551,15 @@ nmc_setting_ip6_connect_handlers (NMSettingIPConfig *setting)
 }
 
 void
+nmc_setting_proxy_connect_handler (NMSettingProxy *setting)
+{
+       g_return_if_fail (NM_IS_SETTING_PROXY (setting));
+
+       g_signal_connect (setting, "notify::" NM_SETTING_PROXY_METHOD,
+                         G_CALLBACK (proxy_method_changed_cb), NULL);
+}
+
+void
 nmc_setting_wireless_connect_handlers (NMSettingWireless *setting)
 {
        g_return_if_fail (NM_IS_SETTING_WIRELESS (setting));
@@ -2463,6 +2635,11 @@ nmc_setting_custom_init (NMSetting *setting)
                              NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
                              NULL);
                nmc_setting_ip6_connect_handlers (NM_SETTING_IP_CONFIG (setting));
+       } else if (NM_IS_SETTING_PROXY (setting)) {
+               g_object_set (NM_SETTING_PROXY (setting),
+                             NM_SETTING_PROXY_METHOD, NM_SETTING_PROXY_METHOD_NONE,
+                             NULL);
+               nmc_setting_proxy_connect_handler (NM_SETTING_PROXY (setting));
        } else if (NM_IS_SETTING_TUN (setting)) {
                g_object_set (NM_SETTING_TUN (setting),
                              NM_SETTING_TUN_MODE, NM_SETTING_TUN_MODE_TUN,
@@ -7792,6 +7969,106 @@ nmc_properties_init (void)
                            NULL,
                            NULL,
                            NULL);
+
+       /* Add editable properties for NM_SETTING_PROXY_SETTING_NAME */
+       nmc_add_prop_funcs (GLUE (PROXY, METHOD),
+                           nmc_property_proxy_get_method,
+                           nmc_property_proxy_set_method,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, HTTP_PROXY),
+                           nmc_property_proxy_get_http_proxy,
+                           nmc_property_set_string,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, HTTP_PORT),
+                           nmc_property_proxy_get_http_port,
+                           nmc_property_set_uint,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, HTTP_DEFAULT),
+                           nmc_property_proxy_get_http_default,
+                           nmc_property_set_bool,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, SSL_PROXY),
+                           nmc_property_proxy_get_ssl_proxy,
+                           nmc_property_set_string,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, SSL_PORT),
+                           nmc_property_proxy_get_ssl_port,
+                           nmc_property_set_uint,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, FTP_PROXY),
+                           nmc_property_proxy_get_ftp_proxy,
+                           nmc_property_set_string,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, FTP_PORT),
+                           nmc_property_proxy_get_ftp_port,
+                           nmc_property_set_uint,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, SOCKS_PROXY),
+                           nmc_property_proxy_get_socks_proxy,
+                           nmc_property_set_string,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, SOCKS_PORT),
+                           nmc_property_proxy_get_socks_port,
+                           nmc_property_set_uint,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, SOCKS_VERSION_5),
+                           nmc_property_proxy_get_socks_version_5,
+                           nmc_property_set_bool,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, NO_PROXY_FOR),
+                           nmc_property_proxy_get_no_proxy_for,
+                           nmc_property_proxy_set_no_proxy_for,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, PAC_URL),
+                           nmc_property_proxy_get_pac_url,
+                           nmc_property_set_string,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
+       nmc_add_prop_funcs (GLUE (PROXY, PAC_SCRIPT),
+                           nmc_property_proxy_get_pac_script,
+                           nmc_property_set_string,
+                           NULL,
+                           NULL,
+                           NULL,
+                           NULL);
 }
 
 void
@@ -9047,7 +9324,7 @@ setting_macvlan_details (NMSetting *setting, NmCli *nmc,  const char *one_prop,
        return TRUE;
 }
 
- static gboolean
+static gboolean
 setting_vxlan_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
 {
        NMSettingVxlan *s_vxlan = NM_SETTING_VXLAN (setting);
@@ -9088,6 +9365,45 @@ setting_vxlan_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gb
        return TRUE;
 }
 
+static gboolean
+setting_proxy_details (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets)
+{
+       NMSettingProxy *s_proxy = NM_SETTING_PROXY (setting);
+       NmcOutputField *tmpl, *arr;
+       size_t tmpl_len;
+
+       g_return_val_if_fail (NM_IS_SETTING_PROXY (s_proxy), FALSE);
+
+       tmpl = nmc_fields_setting_proxy;
+       tmpl_len = sizeof (nmc_fields_setting_proxy);
+       nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_PROXY_ALL,
+                                                        tmpl, FALSE, NULL, NULL);
+       arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES);
+       g_ptr_array_add (nmc->output_data, arr);
+
+       arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
+       set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
+       set_val_str (arr, 1, nmc_property_proxy_get_method (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 2, nmc_property_proxy_get_http_proxy (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 3, nmc_property_proxy_get_http_port (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 4, nmc_property_proxy_get_http_default (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 5, nmc_property_proxy_get_ssl_proxy (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 6, nmc_property_proxy_get_ssl_port (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 7, nmc_property_proxy_get_ftp_proxy (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 8, nmc_property_proxy_get_ftp_port (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 9, nmc_property_proxy_get_socks_proxy (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 10, nmc_property_proxy_get_socks_port (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 11, nmc_property_proxy_get_socks_version_5 (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 12, nmc_property_proxy_get_no_proxy_for (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 13, nmc_property_proxy_get_pac_url (setting, NMC_PROPERTY_GET_PRETTY));
+       set_val_str (arr, 14, nmc_property_proxy_get_pac_script (setting, NMC_PROPERTY_GET_PRETTY));
+       g_ptr_array_add (nmc->output_data, arr);
+
+       print_data (nmc);  /* Print all data */
+
+       return TRUE;
+}
+
 typedef struct {
        const char *sname;
        gboolean (*func) (NMSetting *setting, NmCli *nmc,  const char *one_prop, gboolean secrets);
@@ -9123,6 +9439,7 @@ static const SettingDetails detail_printers[] = {
        { NM_SETTING_IP_TUNNEL_SETTING_NAME,         setting_ip_tunnel_details },
        { NM_SETTING_MACVLAN_SETTING_NAME,           setting_macvlan_details },
        { NM_SETTING_VXLAN_SETTING_NAME,             setting_vxlan_details },
+       { NM_SETTING_PROXY_SETTING_NAME,             setting_proxy_details },
        { NULL },
 };
 
diff --git a/clients/cli/settings.h b/clients/cli/settings.h
index bab00ee..1105960 100644
--- a/clients/cli/settings.h
+++ b/clients/cli/settings.h
@@ -32,6 +32,7 @@ NMSetting *nmc_setting_new_for_name (const char *name);
 void nmc_setting_custom_init (NMSetting *setting);
 void nmc_setting_ip4_connect_handlers (NMSettingIPConfig *setting);
 void nmc_setting_ip6_connect_handlers (NMSettingIPConfig *setting);
+void nmc_setting_proxy_connect_handler (NMSettingProxy *setting);
 void nmc_setting_wireless_connect_handlers (NMSettingWireless *setting);
 void nmc_setting_connection_connect_handlers (NMSettingConnection *setting, NMConnection *connection);
 
-- 
2.5.5



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]