mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
proxy resolver portal: Fix the async api
This commit is contained in:
parent
5cede43df6
commit
db0bf5bbf1
@ -99,6 +99,26 @@ g_proxy_resolver_portal_lookup (GProxyResolver *proxy_resolver,
|
|||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
lookup_done (GObject *source,
|
||||||
|
GAsyncResult *result,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GTask *task = data;
|
||||||
|
GError *error = NULL;
|
||||||
|
gchar **proxies = NULL;
|
||||||
|
|
||||||
|
if (!gxdp_proxy_resolver_call_lookup_finish (GXDP_PROXY_RESOLVER (source),
|
||||||
|
&proxies,
|
||||||
|
result,
|
||||||
|
&error))
|
||||||
|
g_task_return_error (task, error);
|
||||||
|
else
|
||||||
|
g_task_return_pointer (task, proxies, NULL);
|
||||||
|
|
||||||
|
g_object_unref (task);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_proxy_resolver_portal_lookup_async (GProxyResolver *proxy_resolver,
|
g_proxy_resolver_portal_lookup_async (GProxyResolver *proxy_resolver,
|
||||||
const gchar *uri,
|
const gchar *uri,
|
||||||
@ -107,12 +127,15 @@ g_proxy_resolver_portal_lookup_async (GProxyResolver *proxy_resolver,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GProxyResolverPortal *resolver = G_PROXY_RESOLVER_PORTAL (proxy_resolver);
|
GProxyResolverPortal *resolver = G_PROXY_RESOLVER_PORTAL (proxy_resolver);
|
||||||
|
GTask *task;
|
||||||
|
|
||||||
|
task = g_task_new (proxy_resolver, cancellable, callback, user_data);
|
||||||
gxdp_proxy_resolver_call_lookup (resolver->resolver,
|
gxdp_proxy_resolver_call_lookup (resolver->resolver,
|
||||||
uri,
|
uri,
|
||||||
cancellable,
|
cancellable,
|
||||||
callback,
|
lookup_done,
|
||||||
user_data);
|
g_object_ref (task));
|
||||||
|
g_object_unref (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar **
|
static gchar **
|
||||||
@ -121,21 +144,20 @@ g_proxy_resolver_portal_lookup_finish (GProxyResolver *proxy_resolver,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GProxyResolverPortal *resolver = G_PROXY_RESOLVER_PORTAL (proxy_resolver);
|
GProxyResolverPortal *resolver = G_PROXY_RESOLVER_PORTAL (proxy_resolver);
|
||||||
char **proxy = NULL;
|
GTask *task = G_TASK (result);
|
||||||
|
char **proxies;
|
||||||
|
|
||||||
if (!gxdp_proxy_resolver_call_lookup_finish (resolver->resolver,
|
proxies = g_task_propagate_pointer (task, error);
|
||||||
&proxy,
|
if (proxies == NULL)
|
||||||
result,
|
|
||||||
error))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!resolver->network_available)
|
if (!resolver->network_available)
|
||||||
{
|
{
|
||||||
g_strfreev (proxy);
|
g_strfreev (proxies);
|
||||||
proxy = g_strdupv ((gchar **)no_proxy);
|
proxies = g_strdupv ((gchar **)no_proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return proxy;
|
return proxies;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user