31
31
#include "common.h"
34
#include "ui/liferea_htmlview.h"
35
#include "ui/liferea_shell.h"
37
34
#define HOMEPAGE "http://liferea.sf.net/"
39
static SoupSession *session;
40
static SoupSession *session_no_proxy;
41
static SoupSession *session_no_cookies;
42
static SoupSession *session_no_cookies_no_proxy;
36
static SoupSession *session = NULL;
44
38
static gchar *proxyname = NULL;
45
39
static gchar *proxyusername = NULL;
46
40
static gchar *proxypassword = NULL;
47
41
static int proxyport = 0;
49
static gboolean online = FALSE;
52
44
network_process_callback (SoupSession *session, SoupMessage *msg, gpointer user_data)
67
59
debug1 (DEBUG_NET, "download status code: %d", msg->status_code);
68
debug1 (DEBUG_NET, "source after download: >>>%s<<<\n", job->result->source);
60
debug1 (DEBUG_NET, "source after download: >>>%s<<<", job->result->source);
70
62
job->result->data = g_memdup (msg->response_body->data, msg->response_body->length+1);
71
63
job->result->size = (size_t)msg->response_body->length;
175
165
if (job->request->updateState && job->request->updateState->cookies) {
176
166
soup_message_headers_append (msg->request_headers, "Cookie",
177
167
job->request->updateState->cookies);
179
/* This might be confusing: But what we mean by setting this flag
180
is that we do want to ignore the cookie file in ~/.liferea_1.x
181
and pass a single cookie in the headers instead. */
168
soup_message_disable_feature (msg, SOUP_TYPE_COOKIE_JAR);
185
171
/* TODO: Right now we send the msg, and if it requires authentication and
190
176
* msg to a callback in case of 401 (see soup_message_add_status_code_handler())
191
177
* displaying the dialog ourselves, and requeing the msg if we get credentials */
193
/* We queue the message in one session or the other depending on the global
194
* proxy settings and whether the feed properties has the "dont use a proxy"
195
* checkbox enabled */
179
/* If the feed has "dont use a proxy" selected, disable the proxy for the msg */
196
180
if ((job->request->options && job->request->options->dontUseProxy) ||
197
(NULL == network_get_proxy_host ()))
181
(network_get_proxy_host () == NULL))
182
soup_message_disable_feature (msg, SOUP_TYPE_PROXY_URI_RESOLVER);
200
if (no_proxy && no_cookies) {
201
soup_session_queue_message (session_no_cookies_no_proxy, msg, network_process_callback, job);
202
} else if (no_proxy) {
203
soup_session_queue_message (session_no_proxy, msg, network_process_callback, job);
204
} else if (no_cookies) {
205
soup_session_queue_message (session_no_cookies, msg, network_process_callback, job);
207
soup_session_queue_message (session, msg, network_process_callback, job);
184
soup_session_queue_message (session, msg, network_process_callback, job);
250
225
/* Initialize libsoup */
251
226
proxy = network_get_proxy_uri ();
252
227
session = soup_session_async_new_with_options (SOUP_SESSION_USER_AGENT, useragent,
253
SOUP_SESSION_TIMEOUT, 120,
228
SOUP_SESSION_TIMEOUT, 120,
254
229
SOUP_SESSION_IDLE_TIMEOUT, 30,
255
230
SOUP_SESSION_PROXY_URI, proxy,
256
231
SOUP_SESSION_ADD_FEATURE, cookies,
232
SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_DECODER,
259
235
soup_uri_free (proxy);
261
237
g_signal_connect (session, "authenticate", G_CALLBACK (network_authenticate), NULL);
263
/* This session is for those cases where we are told not to use the proxy */
264
session_no_proxy = soup_session_async_new_with_options (SOUP_SESSION_USER_AGENT, useragent,
265
SOUP_SESSION_TIMEOUT, 120,
266
SOUP_SESSION_IDLE_TIMEOUT, 30,
267
SOUP_SESSION_ADD_FEATURE, cookies,
270
/* This session is for those cases where we need to add specific cookies, e.g. Google Reader.
271
* Once GNOME #574571 is fixed, we will be able to use the normal session */
272
session_no_cookies = soup_session_async_new_with_options (SOUP_SESSION_USER_AGENT, useragent,
273
SOUP_SESSION_TIMEOUT, 120,
274
SOUP_SESSION_IDLE_TIMEOUT, 30,
275
SOUP_SESSION_PROXY_URI, proxy,
278
/* And this one is for cases where we need to use our own cookies, and bypass the proxy, e.g.
279
* Google Reader subscription where the "ignore proxy" preference is set */
280
session_no_cookies_no_proxy = soup_session_async_new_with_options (SOUP_SESSION_USER_AGENT, useragent,
281
SOUP_SESSION_TIMEOUT, 120,
282
SOUP_SESSION_IDLE_TIMEOUT, 30,
285
239
/* Soup debugging */
286
240
if (debug_level & DEBUG_NET) {
287
241
logger = soup_logger_new (SOUP_LOGGER_LOG_HEADERS, -1);
341
297
SoupURI *newproxy = network_get_proxy_uri ();
343
g_object_set (session,
344
SOUP_SESSION_PROXY_URI, newproxy,
346
g_object_set (session_no_cookies,
299
g_object_set (G_OBJECT (session),
347
300
SOUP_SESSION_PROXY_URI, newproxy,