summaryrefslogtreecommitdiff
path: root/src/torrent.c
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-03-10 14:57:38 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-03-10 14:57:38 +0000
commita1433a45c470950b3f03541257ef54c4bb48d449 (patch)
tree9e285c6bf2d0508f10b0ada60761f1bee2eb98f8 /src/torrent.c
parentce795861eeb1893e40e4476fea71986450658948 (diff)
Korean support, thanks Youn! Also filter by tracker. Adding/removing trackers from the state selector every update seems like a waste of cycles, so only refresh when a torrent is added.
Diffstat (limited to 'src/torrent.c')
-rw-r--r--src/torrent.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/torrent.c b/src/torrent.c
index def9cbc..f45cc31 100644
--- a/src/torrent.c
+++ b/src/torrent.c
@@ -23,6 +23,7 @@
#include "torrent.h"
#include "protocol-constants.h"
+#include "util.h"
JsonArray *torrent_get_peers(JsonObject * t)
{
@@ -208,6 +209,24 @@ gchar *torrent_get_status_string(gint64 value)
}
}
+gboolean torrent_has_tracker(JsonObject *t, GRegex *rx, gchar *search)
+{
+ JsonArray *trackers = torrent_get_trackers(t);
+ int i;
+
+ for (i = 0; i < json_array_get_length(trackers); i++) {
+ JsonObject *tracker = json_array_get_object_element(trackers, i);
+ const gchar *trackerAnnounce = tracker_get_announce(tracker);
+ gchar *trackerAnnounceHost = trg_uri_host_extract(rx, trackerAnnounce);
+ int cmpResult = g_strcmp0(trackerAnnounceHost, search);
+ g_free(trackerAnnounceHost);
+ if (cmpResult == 0)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
gint64 tracker_get_id(JsonObject * t)
{
return json_object_get_int_member(t, FIELD_ID);