Advertisement
Guest User

Untitled

a guest
May 9th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. Index: src/net.c
  2. ===================================================================
  3. --- src/net.c (revisiĆ³n: 4603)
  4. +++ src/net.c (copia de trabajo)
  5. @@ -40,6 +40,7 @@
  6. static SoupSession *session_no_proxy;
  7. static SoupSession *session_no_cookies;
  8. static SoupSession *session_no_cookies_no_proxy;
  9. +static SoupURI *proxy;
  10.  
  11. static gchar *proxyname = NULL;
  12. static gchar *proxyusername = NULL;
  13. @@ -190,9 +191,13 @@
  14. cookies = soup_cookie_jar_text_new (filename, FALSE);
  15. g_free (filename);
  16.  
  17. + /* conf_init() calls network_set_proxy(), and it's called before net_init() */
  18. + g_assert (proxy);
  19. +
  20. /* Initialize libsoup */
  21. session = soup_session_async_new_with_options (SOUP_SESSION_USER_AGENT, useragent,
  22. SOUP_SESSION_IDLE_TIMEOUT, 30,
  23. + SOUP_SESSION_PROXY_URI, proxy,
  24. SOUP_SESSION_ADD_FEATURE, cookies,
  25. NULL);
  26.  
  27. @@ -206,6 +211,7 @@
  28. * Once GNOME #574571 is fixed, we will be able to use the normal session */
  29. session_no_cookies = soup_session_async_new_with_options (SOUP_SESSION_USER_AGENT, useragent,
  30. SOUP_SESSION_IDLE_TIMEOUT, 30,
  31. + SOUP_SESSION_PROXY_URI, proxy,
  32. NULL);
  33.  
  34. /* And this one is for cases where we need to use our own cookies, and bypass the proxy, e.g.
  35. @@ -220,24 +226,6 @@
  36. soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));
  37. }
  38.  
  39. - /* Set the initial proxy */
  40. - if (proxyname) {
  41. - proxy = soup_uri_new (proxyname);
  42. - if (proxy) {
  43. - soup_uri_set_port (proxy, proxyport);
  44. - soup_uri_set_user (proxy, proxyusername);
  45. - soup_uri_set_password (proxy, proxypassword);
  46. -
  47. - g_object_set (session,
  48. - SOUP_SESSION_PROXY_URI, proxy,
  49. - NULL);
  50. -
  51. - g_object_set (session_no_cookies,
  52. - SOUP_SESSION_PROXY_URI, proxy,
  53. - NULL);
  54. - }
  55. - }
  56. -
  57. g_free (useragent);
  58. }
  59.  
  60. @@ -280,33 +268,22 @@
  61. proxyname = newProxyName;
  62. proxyport = newProxyPort;
  63.  
  64. - /* If session is NULL, network_init() hasn't been called yet
  65. - * and when it's called it will set the proxy */
  66. - if (session) {
  67. - SoupURI *proxy;
  68. - g_object_get (G_OBJECT (session),
  69. - SOUP_SESSION_PROXY_URI, &proxy,
  70. - NULL);
  71. + /* This is only the case upon startup, when conf_init() calls network_set_proxy() */
  72. + if (!proxy) {
  73. + proxy = soup_uri_new (proxyname);
  74. + }
  75.  
  76. - if (!proxy) {
  77. - proxy = soup_uri_new (proxyname);
  78. - }
  79. + soup_uri_set_host (proxy, proxyname);
  80. + soup_uri_set_port (proxy, proxyport);
  81.  
  82. - /* If newProxyName was "", soup_uri_new will return NULL */
  83. - if (proxy) {
  84. - soup_uri_set_host (proxy, proxyname);
  85. - soup_uri_set_port (proxy, proxyport);
  86. - }
  87. + g_object_set (session,
  88. + SOUP_SESSION_PROXY_URI, proxy,
  89. + NULL);
  90.  
  91. - g_object_set (session,
  92. - SOUP_SESSION_PROXY_URI, proxy,
  93. - NULL);
  94. + g_object_set (session_no_cookies,
  95. + SOUP_SESSION_PROXY_URI, proxy,
  96. + NULL);
  97.  
  98. - g_object_set (session_no_cookies,
  99. - SOUP_SESSION_PROXY_URI, proxy,
  100. - NULL);
  101. - }
  102. -
  103. liferea_htmlview_update_proxy ();
  104. }
  105.  
  106. @@ -318,28 +295,17 @@
  107. proxyusername = newProxyUsername;
  108. proxypassword = newProxyPassword;
  109.  
  110. - /* If session is NULL, network_init() hasn't been called yet
  111. - * and when it's called it will set the proxy */
  112. - if (session) {
  113. - SoupURI *proxy;
  114. - g_object_get (session,
  115. - SOUP_SESSION_PROXY_URI, &proxy,
  116. - NULL);
  117. + g_assert (proxy);
  118.  
  119. - /* There may be no proxy if there was no proxy before we went
  120. - * to the proxy tab and clicked on "proxy auth" */
  121. - if (proxy) {
  122. - soup_uri_set_user (proxy, proxyusername);
  123. - soup_uri_set_password (proxy, proxypassword);
  124. + soup_uri_set_user (proxy, proxyusername);
  125. + soup_uri_set_password (proxy, proxypassword);
  126.  
  127. - g_object_set (session,
  128. - SOUP_SESSION_PROXY_URI, proxy,
  129. - NULL);
  130. - g_object_set (session_no_cookies,
  131. - SOUP_SESSION_PROXY_URI, proxy,
  132. - NULL);
  133. - }
  134. - }
  135. + g_object_set (session,
  136. + SOUP_SESSION_PROXY_URI, proxy,
  137. + NULL);
  138. + g_object_set (session_no_cookies,
  139. + SOUP_SESSION_PROXY_URI, proxy,
  140. + NULL);
  141.  
  142. liferea_htmlview_update_proxy ();
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement