]> granicus.if.org Git - transmission/commitdiff
(trunk) update web.h's API s.t. there's an explicit function to use when downloading...
authorJordan Lee <jordan@transmissionbt.com>
Sat, 13 Apr 2013 20:25:28 +0000 (20:25 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Sat, 13 Apr 2013 20:25:28 +0000 (20:25 +0000)
cli/cli.c
gtk/favicon.c
libtransmission/announcer-http.c
libtransmission/rpcimpl.c
libtransmission/web.c
libtransmission/web.h
libtransmission/webseed.c

index 06609fb5235f42749ce9070a61d8143f6a7d3577..a1eca56d70eaf5533b759d5654304110d77e1125 100644 (file)
--- a/cli/cli.c
+++ b/cli/cli.c
@@ -294,7 +294,7 @@ main (int argc, char ** argv)
     }
   else if (!memcmp (torrentPath, "http", 4))
     {
-      tr_webRun (h, torrentPath, NULL, NULL, onTorrentFileDownloaded, ctor);
+      tr_webRun (h, torrentPath, onTorrentFileDownloaded, ctor);
       waitingOnWeb = true;
       while (waitingOnWeb)
         tr_wait_msec (1000);
index 5ead99901b56a1af0165da907f6ea0ca977e8046..ec9df77a2ced7604bc4be7f24201bf8de7e4b513 100644 (file)
@@ -111,7 +111,7 @@ favicon_web_done_idle_cb (gpointer vfav)
             fav->contents = NULL;
             fav->len = 0;
 
-            tr_webRun (fav->session, url, NULL, NULL, favicon_web_done_cb, fav);
+            tr_webRun (fav->session, url, favicon_web_done_cb, fav);
             g_free (url);
         }
     }
@@ -167,7 +167,7 @@ gtr_get_favicon (tr_session  * session,
         data->host = g_strdup (host);
         data->type = 0;
 
-        tr_webRun (session, url, NULL, NULL, favicon_web_done_cb, data);
+        tr_webRun (session, url, favicon_web_done_cb, data);
         g_free (url);
     }
 }
index 8b7d413d8ba6a94f98535c9784c48f1d9f216e4d..f0c46dc4f4f3391af40e34bfd5b4d5fce06a1103 100644 (file)
@@ -304,7 +304,7 @@ tr_tracker_http_announce (tr_session                 * session,
     tr_strlcpy (d->log_name, request->log_name, sizeof (d->log_name));
 
     dbgmsg (request->log_name, "Sending announce to libcurl: \"%s\"", url);
-    tr_webRun (session, url, NULL, NULL, on_announce_done, d);
+    tr_webRun (session, url, on_announce_done, d);
 
     tr_free (url);
 }
@@ -479,7 +479,7 @@ tr_tracker_http_scrape (tr_session               * session,
     tr_strlcpy (d->log_name, request->log_name, sizeof (d->log_name));
 
     dbgmsg (request->log_name, "Sending scrape to libcurl: \"%s\"", url);
-    tr_webRun (session, url, NULL, NULL, on_scrape_done, d);
+    tr_webRun (session, url, on_scrape_done, d);
 
     tr_free (url);
 }
index 9fb03ab7c39dc6e17140a7d7ba119931da17de2d..1b3cc052392c83d6d09b2433d15fcdbdf1b71084 100644 (file)
@@ -1400,7 +1400,7 @@ portTest (tr_session               * session,
 {
     const int port = tr_sessionGetPeerPort (session);
     char * url = tr_strdup_printf ("http://portcheck.transmissionbt.com/%d", port);
-    tr_webRun (session, url, NULL, NULL, portTested, idle_data);
+    tr_webRun (session, url, portTested, idle_data);
     tr_free (url);
     return NULL;
 }
@@ -1500,11 +1500,11 @@ gotNewBlocklist (tr_session       * session,
 
 static const char*
 blocklistUpdate (tr_session               * session,
-                 tr_variant                  * args_in UNUSED,
-                 tr_variant                  * args_out UNUSED,
+                 tr_variant               * args_in UNUSED,
+                 tr_variant               * args_out UNUSED,
                  struct tr_rpc_idle_data  * idle_data)
 {
-    tr_webRun (session, session->blocklist_url, NULL, NULL, gotNewBlocklist, idle_data);
+    tr_webRun (session, session->blocklist_url, gotNewBlocklist, idle_data);
     return NULL;
 }
 
@@ -1689,7 +1689,7 @@ torrentAdd (tr_session               * session,
             struct add_torrent_idle_data * d = tr_new0 (struct add_torrent_idle_data, 1);
             d->data = idle_data;
             d->ctor = ctor;
-            tr_webRun (session, filename, NULL, cookies, gotMetadataFromURL, d);
+            tr_webRunWithCookies (session, filename, cookies, gotMetadataFromURL, d);
         }
         else
         {
index 9fcc96f2f3a997e66615712e97986aee0ddd472d..1f546cd98cccab77cec050f036fc6ed581b59b41 100644 (file)
@@ -26,6 +26,7 @@
 #include "transmission.h"
 #include "log.h"
 #include "net.h" /* tr_address */
+#include "torrent.h"
 #include "platform.h" /* mutex */
 #include "session.h"
 #include "trevent.h" /* tr_runInEventThread () */
@@ -62,6 +63,7 @@ enum
 
 struct tr_web_task
 {
+  int torrentId;
   long code;
   long timeout_secs;
   bool did_connect;
@@ -234,29 +236,17 @@ task_finish_func (void * vtask)
 *****
 ****/
 
-struct tr_web_task *
-tr_webRun (tr_session         * session,
-           const char         * url,
-           const char         * range,
-           const char         * cookies,
-           tr_web_done_func     done_func,
-           void               * done_func_user_data)
-{
-  return tr_webRunWithBuffer (session, url, range, cookies,
-                              done_func, done_func_user_data,
-                              NULL);
-}
-
 static void tr_webThreadFunc (void * vsession);
 
-struct tr_web_task *
-tr_webRunWithBuffer (tr_session         * session,
-                     const char         * url,
-                     const char         * range,
-                     const char         * cookies,
-                     tr_web_done_func     done_func,
-                     void               * done_func_user_data,
-                     struct evbuffer    * buffer)
+static struct tr_web_task *
+tr_webRunImpl (tr_session         * session,
+               int                  torrentId,
+               const char         * url,
+               const char         * range,
+               const char         * cookies,
+               tr_web_done_func     done_func,
+               void               * done_func_user_data,
+               struct evbuffer    * buffer)
 {
   struct tr_web_task * task = NULL;
 
@@ -272,6 +262,7 @@ tr_webRunWithBuffer (tr_session         * session,
       
       task = tr_new0 (struct tr_web_task, 1);
       task->session = session;
+      task->torrentId = torrentId;
       task->url = tr_strdup (url);
       task->range = tr_strdup (range);
       task->cookies = tr_strdup (cookies);
@@ -289,6 +280,44 @@ tr_webRunWithBuffer (tr_session         * session,
   return task;
 }
 
+struct tr_web_task *
+tr_webRunWithCookies (tr_session        * session,
+                      const char        * url,
+                      const char        * cookies,
+                      tr_web_done_func    done_func,
+                      void              * done_func_user_data)
+{
+  return tr_webRunImpl (session, -1, url,
+                        NULL, cookies,
+                        done_func, done_func_user_data,
+                        NULL);
+}
+
+struct tr_web_task *
+tr_webRun (tr_session         * session,
+           const char         * url,
+           tr_web_done_func     done_func,
+           void               * done_func_user_data)
+{
+  return tr_webRunWithCookies (session, url, NULL,
+                               done_func, done_func_user_data);
+}
+
+
+struct tr_web_task *
+tr_webRunWebseed (tr_torrent        * tor,
+                  const char        * url,
+                  const char        * range,
+                  tr_web_done_func    done_func,
+                  void              * done_func_user_data,
+                  struct evbuffer   * buffer)
+{
+  return tr_webRunImpl (tor->session, tr_torrentId (tor), url,
+                        range, NULL,
+                        done_func, done_func_user_data,
+                        buffer);
+}
+
 /**
  * Portability wrapper for select ().
  *
index 59ad7c71a05845b5f2999f60f45f258f86dda5ea..dc45a59c49778d4c8c9e5d919b13ba8c04daec91 100644 (file)
@@ -51,20 +51,23 @@ const char * tr_webGetResponseStr (long response_code);
 
 struct tr_web_task * tr_webRun (tr_session        * session,
                                 const char        * url,
-                                const char        * range,
-                                const char        * cookies,
                                 tr_web_done_func    done_func,
                                 void              * done_func_user_data);
 
+struct tr_web_task * tr_webRunWithCookies (tr_session        * session,
+                                           const char        * url,
+                                           const char        * cookies,
+                                           tr_web_done_func    done_func,
+                                           void              * done_func_user_data);
+
 struct evbuffer;
 
-struct tr_web_task * tr_webRunWithBuffer (tr_session         * session,
-                                          const char         * url,
-                                          const char         * range,
-                                          const char         * cookies,
-                                          tr_web_done_func     done_func,
-                                          void               * done_func_user_data,
-                                          struct evbuffer    * buffer);
+struct tr_web_task * tr_webRunWebseed (tr_torrent        * tor,
+                                       const char        * url,
+                                       const char        * range,
+                                       tr_web_done_func    done_func,
+                                       void              * done_func_user_data,
+                                       struct evbuffer   * buffer);
 
 void tr_webGetTaskInfo (struct tr_web_task * task, tr_web_task_info info, void * dst);
 
index f3ed278e23e1b84ef54d833a5288f95d467f060f..0c904a86ef849f67ed3f0f631a94edca1db35177 100644 (file)
@@ -498,8 +498,9 @@ task_request_next_chunk (struct tr_webseed_task * t)
 
       tr_snprintf (range, sizeof range, "%"PRIu64"-%"PRIu64,
                    file_offset, file_offset + this_pass - 1);
-      t->web_task = tr_webRunWithBuffer (w->session, urls[file_index],
-                                         range, NULL, web_response_func, t, t->content);
+
+      t->web_task = tr_webRunWebseed (tor, urls[file_index], range,
+                                      web_response_func, t, t->content);
     }
 }