Added proxy_enumerate method to GSocketConnectable

Reviewed-by: Dan Winship <danw@gnome.org>
This commit is contained in:
Nicolas Dufresne 2010-08-10 16:53:25 -04:00
parent 6749ffce59
commit f82f484b8f
6 changed files with 47 additions and 3 deletions

View File

@ -1633,6 +1633,7 @@ g_srv_target_get_type
GSocketConnectable GSocketConnectable
GSocketConnectableIface GSocketConnectableIface
g_socket_connectable_enumerate g_socket_connectable_enumerate
g_socket_connectable_proxy_enumerate
<SUBSECTION> <SUBSECTION>
GSocketAddressEnumerator GSocketAddressEnumerator
g_socket_address_enumerator_next g_socket_address_enumerator_next

View File

@ -1248,8 +1248,9 @@ g_network_service_new
#if IN_HEADER(__G_SOCKET_CONNECTABLE_H__) #if IN_HEADER(__G_SOCKET_CONNECTABLE_H__)
#if IN_FILE(__G_SOCKET_CONNECTABLE_C__) #if IN_FILE(__G_SOCKET_CONNECTABLE_C__)
g_socket_connectable_enumerate
g_socket_connectable_get_type G_GNUC_CONST g_socket_connectable_get_type G_GNUC_CONST
g_socket_connectable_enumerate
g_socket_connectable_proxy_enumerate
#endif #endif
#endif #endif

View File

@ -422,7 +422,7 @@ g_network_address_parse (const gchar *host_and_port,
#define G_URI_OTHER_UNRESERVED "-._~" #define G_URI_OTHER_UNRESERVED "-._~"
/* This or something equivalent will eventually go into glib/guri.h */ /* This or something equivalent will eventually go into glib/guri.h */
static gboolean gboolean
_g_uri_parse_authority (const char *uri, _g_uri_parse_authority (const char *uri,
char **host, char **host,
guint16 *port, guint16 *port,

View File

@ -120,6 +120,11 @@ GList *_g_resolver_targets_from_DnsQuery (const gchar *rrname,
GError **error); GError **error);
#endif #endif
gboolean _g_uri_parse_authority (const char *uri,
char **host,
guint16 *port,
char **userinfo);
G_END_DECLS G_END_DECLS
#endif /* __G_NETWORKINGPRIVATE_H__ */ #endif /* __G_NETWORKINGPRIVATE_H__ */

View File

@ -120,3 +120,34 @@ g_socket_connectable_enumerate (GSocketConnectable *connectable)
return (* iface->enumerate) (connectable); return (* iface->enumerate) (connectable);
} }
/**
* g_socket_connectable_proxy_enumerate:
* @connectable: a #GSocketConnectable
*
* Creates a #GSocketAddressEnumerator for @connectable that will
* return #GProxyAddress<!-- -->es for addresses that you must connect
* to via a proxy.
*
* If @connectable does not implement
* g_socket_connectable_proxy_enumerate(), this will fall back to
* calling g_socket_connectable_enumerate().
*
* Return value: a new #GSocketAddressEnumerator.
*
* Since: 2.26
*/
GSocketAddressEnumerator *
g_socket_connectable_proxy_enumerate (GSocketConnectable *connectable)
{
GSocketConnectableIface *iface;
g_return_val_if_fail (G_IS_SOCKET_CONNECTABLE (connectable), NULL);
iface = G_SOCKET_CONNECTABLE_GET_IFACE (connectable);
if (iface->proxy_enumerate)
return (* iface->proxy_enumerate) (connectable);
else
return (* iface->enumerate) (connectable);
}

View File

@ -45,8 +45,10 @@ typedef struct _GSocketConnectableIface GSocketConnectableIface;
* GSocketConnectableIface: * GSocketConnectableIface:
* @g_iface: The parent interface. * @g_iface: The parent interface.
* @enumerate: Creates a #GSocketAddressEnumerator * @enumerate: Creates a #GSocketAddressEnumerator
* @proxy_enumerate: Creates a #GProxyAddressEnumerator
* *
* Provides an interface for returning a #GSocketAddressEnumerator * Provides an interface for returning a #GSocketAddressEnumerator
* and #GProxyAddressEnumerator
*/ */
struct _GSocketConnectableIface struct _GSocketConnectableIface
{ {
@ -54,7 +56,9 @@ struct _GSocketConnectableIface
/* Virtual Table */ /* Virtual Table */
GSocketAddressEnumerator * (* enumerate) (GSocketConnectable *connectable); GSocketAddressEnumerator * (* enumerate) (GSocketConnectable *connectable);
GSocketAddressEnumerator * (* proxy_enumerate) (GSocketConnectable *connectable);
}; };
@ -62,6 +66,8 @@ GType g_socket_connectable_get_type (void) G_GNUC_CONST;
GSocketAddressEnumerator *g_socket_connectable_enumerate (GSocketConnectable *connectable); GSocketAddressEnumerator *g_socket_connectable_enumerate (GSocketConnectable *connectable);
GSocketAddressEnumerator *g_socket_connectable_proxy_enumerate (GSocketConnectable *connectable);
G_END_DECLS G_END_DECLS