X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgproxyaddress.c;h=1d0ab217ad9557597a14b2f70c8bbd7a1324235f;hb=7103484017ff000d01ed94567539d37fa09b32b2;hp=61dfc7d08abd3a381579c5363f4c1824a717a5d0;hpb=63adeda0861a26b38ec0adc76255666554c18951;p=platform%2Fupstream%2Fglib.git diff --git a/gio/gproxyaddress.c b/gio/gproxyaddress.c index 61dfc7d..1d0ab21 100644 --- a/gio/gproxyaddress.c +++ b/gio/gproxyaddress.c @@ -13,9 +13,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. + * Public License along with this library; if not, see . * * Authors: Nicolas Dufresne */ @@ -32,6 +30,7 @@ /** * SECTION:gproxyaddress * @short_description: An internet address with proxy information + * @include: gio/gio.h * * Support for proxied #GInetSocketAddress. */ @@ -43,45 +42,52 @@ * * Since: 2.26 **/ -G_DEFINE_TYPE (GProxyAddress, g_proxy_address, G_TYPE_INET_SOCKET_ADDRESS); enum { PROP_0, PROP_PROTOCOL, + PROP_DESTINATION_PROTOCOL, PROP_DESTINATION_HOSTNAME, PROP_DESTINATION_PORT, PROP_USERNAME, - PROP_PASSWORD + PROP_PASSWORD, + PROP_URI }; struct _GProxyAddressPrivate { + gchar *uri; gchar *protocol; gchar *username; gchar *password; + gchar *dest_protocol; gchar *dest_hostname; guint16 dest_port; }; +G_DEFINE_TYPE_WITH_PRIVATE (GProxyAddress, g_proxy_address, G_TYPE_INET_SOCKET_ADDRESS) + static void g_proxy_address_finalize (GObject *object) { GProxyAddress *proxy = G_PROXY_ADDRESS (object); + g_free (proxy->priv->uri); g_free (proxy->priv->protocol); g_free (proxy->priv->username); g_free (proxy->priv->password); g_free (proxy->priv->dest_hostname); + g_free (proxy->priv->dest_protocol); G_OBJECT_CLASS (g_proxy_address_parent_class)->finalize (object); } static void g_proxy_address_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { GProxyAddress *proxy = G_PROXY_ADDRESS (object); @@ -92,6 +98,11 @@ g_proxy_address_set_property (GObject *object, proxy->priv->protocol = g_value_dup_string (value); break; + case PROP_DESTINATION_PROTOCOL: + g_free (proxy->priv->dest_protocol); + proxy->priv->dest_protocol = g_value_dup_string (value); + break; + case PROP_DESTINATION_HOSTNAME: g_free (proxy->priv->dest_hostname); proxy->priv->dest_hostname = g_value_dup_string (value); @@ -111,6 +122,11 @@ g_proxy_address_set_property (GObject *object, proxy->priv->password = g_value_dup_string (value); break; + case PROP_URI: + g_free (proxy->priv->uri); + proxy->priv->uri = g_value_dup_string (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -130,6 +146,10 @@ g_proxy_address_get_property (GObject *object, g_value_set_string (value, proxy->priv->protocol); break; + case PROP_DESTINATION_PROTOCOL: + g_value_set_string (value, proxy->priv->dest_protocol); + break; + case PROP_DESTINATION_HOSTNAME: g_value_set_string (value, proxy->priv->dest_hostname); break; @@ -146,6 +166,10 @@ g_proxy_address_get_property (GObject *object, g_value_set_string (value, proxy->priv->password); break; + case PROP_URI: + g_value_set_string (value, proxy->priv->uri); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -156,8 +180,6 @@ g_proxy_address_class_init (GProxyAddressClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (GProxyAddressPrivate)); - gobject_class->finalize = g_proxy_address_finalize; gobject_class->set_property = g_proxy_address_set_property; gobject_class->get_property = g_proxy_address_get_property; @@ -192,6 +214,24 @@ g_proxy_address_class_init (GProxyAddressClass *klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + /** + * GProxyAddress:destination-protocol: + * + * The protocol being spoke to the destination host, or %NULL if + * the #GProxyAddress doesn't know. + * + * Since: 2.34 + */ + g_object_class_install_property (gobject_class, + PROP_DESTINATION_PROTOCOL, + g_param_spec_string ("destination-protocol", + P_("Destionation Protocol"), + P_("The proxy destination protocol"), + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_DESTINATION_HOSTNAME, g_param_spec_string ("destination-hostname", @@ -211,14 +251,30 @@ g_proxy_address_class_init (GProxyAddressClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + + /** + * GProxyAddress:uri: + * + * The URI string that the proxy was constructed from (or %NULL + * if the creator didn't specify this). + * + * Since: 2.34 + */ + g_object_class_install_property (gobject_class, + PROP_URI, + g_param_spec_string ("uri", + P_("URI"), + P_("The proxy's URI"), + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); } static void g_proxy_address_init (GProxyAddress *proxy) { - proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, - G_TYPE_PROXY_ADDRESS, - GProxyAddressPrivate); + proxy->priv = g_proxy_address_get_instance_private (proxy); proxy->priv->protocol = NULL; proxy->priv->username = NULL; proxy->priv->password = NULL; @@ -231,14 +287,20 @@ g_proxy_address_init (GProxyAddress *proxy) * @inetaddr: The proxy server #GInetAddress. * @port: The proxy server port. * @protocol: The proxy protocol to support, in lower case (e.g. socks, http). - * @dest_hostname: The destination hostname the the proxy should tunnel to. + * @dest_hostname: The destination hostname the proxy should tunnel to. * @dest_port: The destination port to tunnel to. - * @username: The username to authenticate to the proxy server (or %NULL). - * @password: The password to authenticate to the proxy server (or %NULL). + * @username: (allow-none): The username to authenticate to the proxy server + * (or %NULL). + * @password: (allow-none): The password to authenticate to the proxy server + * (or %NULL). * * Creates a new #GProxyAddress for @inetaddr with @protocol that should * tunnel through @dest_hostname and @dest_port. * + * (Note that this method doesn't set the #GProxyAddress:uri or + * #GProxyAddress:destination-protocol fields; use g_object_new() + * directly if you want to set those.) + * * Returns: a new #GProxyAddress * * Since: 2.26 @@ -268,7 +330,7 @@ g_proxy_address_new (GInetAddress *inetaddr, * g_proxy_address_get_protocol: * @proxy: a #GProxyAddress * - * Gets @proxy's protocol. + * Gets @proxy's protocol. eg, "socks" or "http" * * Returns: the @proxy's protocol * @@ -281,10 +343,29 @@ g_proxy_address_get_protocol (GProxyAddress *proxy) } /** - * g_proxy_address_get_destination_hostname + * g_proxy_address_get_destination_protocol: + * @proxy: a #GProxyAddress + * + * Gets the protocol that is being spoken to the destination + * server; eg, "http" or "ftp". + * + * Returns: the @proxy's destination protocol + * + * Since: 2.34 + */ +const gchar * +g_proxy_address_get_destination_protocol (GProxyAddress *proxy) +{ + return proxy->priv->dest_protocol; +} + +/** + * g_proxy_address_get_destination_hostname: * @proxy: a #GProxyAddress * - * Gets @proxy's destination hostname. + * Gets @proxy's destination hostname; that is, the name of the host + * that will be connected to via the proxy, not the name of the proxy + * itself. * * Returns: the @proxy's destination hostname * @@ -297,10 +378,12 @@ g_proxy_address_get_destination_hostname (GProxyAddress *proxy) } /** - * g_proxy_address_get_destination_port + * g_proxy_address_get_destination_port: * @proxy: a #GProxyAddress * - * Gets @proxy's destination port. + * Gets @proxy's destination port; that is, the port on the + * destination host that will be connected to via the proxy, not the + * port number of the proxy itself. * * Returns: the @proxy's destination port * @@ -313,7 +396,7 @@ g_proxy_address_get_destination_port (GProxyAddress *proxy) } /** - * g_proxy_address_get_username + * g_proxy_address_get_username: * @proxy: a #GProxyAddress * * Gets @proxy's username. @@ -329,7 +412,7 @@ g_proxy_address_get_username (GProxyAddress *proxy) } /** - * g_proxy_address_get_password + * g_proxy_address_get_password: * @proxy: a #GProxyAddress * * Gets @proxy's password. @@ -343,3 +426,20 @@ g_proxy_address_get_password (GProxyAddress *proxy) { return proxy->priv->password; } + + +/** + * g_proxy_address_get_uri: + * @proxy: a #GProxyAddress + * + * Gets the proxy URI that @proxy was constructed from. + * + * Returns: the @proxy's URI, or %NULL if unknown + * + * Since: 2.34 + */ +const gchar * +g_proxy_address_get_uri (GProxyAddress *proxy) +{ + return proxy->priv->uri; +}