Exemplo n.º 1
0
static SoupSessionHost *
soup_session_host_new (SoupSession *session, SoupURI *uri)
{
	SoupSessionHost *host;

	host = g_slice_new0 (SoupSessionHost);
	host->uri = soup_uri_copy_host (uri);
	host->addr = soup_address_new (host->uri->host, host->uri->port);

	return host;
}
Exemplo n.º 2
0
/* This is a somewhat hacky way to get FTP to almost work. The proper way to
 * get FTP to _really_ work involves hacking GIO to have APIs to handle
 * canoncial URLs.
 */
static GFile *
webkit_soup_request_file_ensure_file_ftp (SoupURI       *uri,
					  GCancellable  *cancellable,
					  GError       **error)
{
	SoupURI *host;
	char *s;
	GFile *file, *result;
	GMount *mount;

	host = soup_uri_copy_host (uri);
	s = soup_uri_to_string (host, FALSE);
	file = g_file_new_for_uri (s);
	soup_uri_free (host);
	g_free (s);

	mount = g_file_find_enclosing_mount (file, cancellable, error);
	if (mount == NULL && g_file_supports_thread_contexts (file)) {
		GMainContext *context = g_main_context_new ();
		GMainLoop *loop = g_main_loop_new (context, FALSE);

		g_clear_error (error);
		g_main_context_push_thread_default (context);
		g_file_mount_enclosing_volume (file,
					       G_MOUNT_MOUNT_NONE,
					       NULL, /* FIXME! */
					       cancellable,
					       webkit_soup_request_file_ftp_main_loop_quit,
					       loop);
		g_main_loop_run (loop);
		g_main_context_pop_thread_default (context);
		g_main_loop_unref (loop);
		g_main_context_unref (context);
		mount = g_file_find_enclosing_mount (file, cancellable, error);
	}
	if (mount == NULL)
		return NULL;
	g_object_unref (file);

	file = g_mount_get_default_location (mount);
	g_object_unref (mount);

	s = g_strdup (uri->path);
	if (strchr (s, ';'))
		*strchr (s, ';') = 0;

	result = g_file_resolve_relative_path (file, s);
	g_free (s);
	g_object_unref (file);

	return result;
}
Exemplo n.º 3
0
Arquivo: ui.c Projeto: imgflo/imgflo
static gboolean
ensure_hostname_set(UiConnection *self, SoupURI *uri) {
    if (g_strcmp0(self->hostname, "") != 0) {
        // Already configured
        return FALSE;
    }

    SoupURI *hostUri = soup_uri_copy_host(uri);
    g_free(self->hostname);
    self->hostname = soup_uri_to_string(hostUri, FALSE);
    soup_uri_free(hostUri);
    // NOTE: does not check wether existing hostname was equivalent
    return TRUE;
}
Exemplo n.º 4
0
static SoupAuthHost *
get_auth_host_for_uri (SoupAuthManagerPrivate *priv, SoupURI *uri)
{
	SoupAuthHost *host;

	host = g_hash_table_lookup (priv->auth_hosts, uri);
	if (host)
		return host;

	host = g_slice_new0 (SoupAuthHost);
	host->uri = soup_uri_copy_host (uri);
	g_hash_table_insert (priv->auth_hosts, host->uri, host);

	return host;
}