diff options
author | 2011-08-31 13:34:00 +0000 | |
---|---|---|
committer | 2011-08-31 13:34:00 +0000 | |
commit | 8eef0e7576d67d14efe305ba4d73cee374c57220 (patch) | |
tree | 8b91467113da91d39c67217514ae530538cfd3ac | |
parent | 7bf25fa4ac9b91d8249a3e43e35f4e11e28c1ef4 (diff) |
switch from using the trackers struct to trackerstats - and add some of the new columns into the trackers model and treeview
-rw-r--r-- | debian/control | 4 | ||||
-rw-r--r-- | src/protocol-constants.h | 16 | ||||
-rw-r--r-- | src/requests.c | 2 | ||||
-rw-r--r-- | src/torrent.c | 64 | ||||
-rw-r--r-- | src/torrent.h | 21 | ||||
-rw-r--r-- | src/trg-client.c | 24 | ||||
-rw-r--r-- | src/trg-client.h | 2 | ||||
-rw-r--r-- | src/trg-state-selector.c | 4 | ||||
-rw-r--r-- | src/trg-trackers-model.c | 42 | ||||
-rw-r--r-- | src/trg-trackers-model.h | 28 | ||||
-rw-r--r-- | src/trg-trackers-tree-view.c | 12 |
11 files changed, 153 insertions, 66 deletions
diff --git a/debian/control b/debian/control index 44a9ec6..8f0ff47 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: transmission-remote-gtk Section: net Priority: optional Maintainer: Alan Fitton <alan@eth0.org.uk> -Build-Depends: debhelper (>= 7.0.50~), autotools-dev, libcurl4-openssl-dev, libgtk2.0-dev (>= 2.16~), libglib2.0-dev (>= 2.22~), libproxy-dev, libnotify-dev, libunique-dev, libjson-glib-dev, libgconf2-dev +Build-Depends: debhelper (>= 7.0.50~), autotools-dev, libcurl4-openssl-dev, libgtk2.0-dev (>= 2.16~), libglib2.0-dev (>= 2.22~), libproxy-dev, libnotify-dev, libunique-dev, libjson-glib-dev Standards-Version: 3.8.4 Homepage: http://code.google.com/p/transmission-remote-gtk/ Vcs-Svn: http://transmission-remote-gtk.googlecode.com/svn/trunk/ @@ -10,7 +10,7 @@ Vcs-Browser: http://code.google.com/p/transmission-remote-gtk/source/browse/ Package: transmission-remote-gtk Architecture: any -Depends: libgtk2.0-0 (>= 2.16~), libglib2.0-0 (>= 2.22~), libunique-1.0-0, libgconf2-4, gconf2, libnotify1, libproxy0, libjson-glib-1.0-0 (>= 0.8~), ${shlibs:Depends}, ${misc:Depends} +Depends: libgtk2.0-0 (>= 2.16~), libglib2.0-0 (>= 2.22~), libunique-1.0-0, libnotify1, libproxy0, libjson-glib-1.0-0 (>= 0.8~), ${shlibs:Depends}, ${misc:Depends} Description: GTK remote control for the Transmission BitTorrent client transmission-remote-gtk is a GTK application for remote management of the Transmission BitTorrent client via its RPC interface. diff --git a/src/protocol-constants.h b/src/protocol-constants.h index e61ca50..d0d8f49 100644 --- a/src/protocol-constants.h +++ b/src/protocol-constants.h @@ -35,7 +35,8 @@ #define FIELD_TOTAL_SIZE "totalSize" #define FIELD_DONE_DATE "doneDate" #define FIELD_ADDED_DATE "addedDate" -#define FIELD_TRACKERS "trackers" +//#define FIELD_TRACKERS "trackers" +#define FIELD_TRACKER_STATS "trackerStats" #define FIELD_DOWNLOAD_DIR "downloadDir" #define FIELD_HASH_STRING "hashString" #define FIELD_SWARM_SPEED "swarmSpeed" @@ -53,7 +54,6 @@ #define FIELD_HAVEVALID "haveValid" #define FIELD_HAVEUNCHECKED "haveUnchecked" #define FIELD_PERCENTDONE "percentDone" -#define FIELD_TRACKERS "trackers" #define FIELD_PEERS "peers" #define FIELD_FILES "files" #define FIELD_WANTED "wanted" @@ -82,9 +82,15 @@ /* trackers */ -#define FIELD_TIER "tier" -#define FIELD_ANNOUNCE "announce" -#define FIELD_SCRAPE "scrape" +#define FIELD_TIER "tier" +#define FIELD_ANNOUNCE "announce" +#define FIELD_SCRAPE "scrape" +#define FIELD_LAST_ANNOUNCE_PEER_COUNT "lastAnnouncePeerCount" +#define FIELD_LAST_ANNOUNCE_TIME "lastAnnounceTime" +#define FIELD_SEEDERCOUNT "seederCount" +#define FIELD_LEECHERCOUNT "leecherCount" +#define FIELD_HOST "host" +#define FIELD_LAST_ANNOUNCE_RESULT "lastAnnounceResult" /* methods */ diff --git a/src/requests.c b/src/requests.c index 0f56a8d..a38e3ef 100644 --- a/src/requests.c +++ b/src/requests.c @@ -147,7 +147,7 @@ JsonNode *torrent_get(gint64 id) json_array_add_string_element(fields, FIELD_ANNOUNCE_URL); json_array_add_string_element(fields, FIELD_ERROR_STRING); json_array_add_string_element(fields, FIELD_SWARM_SPEED); - json_array_add_string_element(fields, FIELD_TRACKERS); + json_array_add_string_element(fields, FIELD_TRACKER_STATS); json_array_add_string_element(fields, FIELD_DOWNLOAD_DIR); json_array_add_string_element(fields, FIELD_HASH_STRING); json_array_add_string_element(fields, FIELD_DONE_DATE); diff --git a/src/torrent.c b/src/torrent.c index 1d3d247..2b04129 100644 --- a/src/torrent.c +++ b/src/torrent.c @@ -41,9 +41,9 @@ JsonArray *torrent_get_priorities(JsonObject * t) return json_object_get_array_member(t, FIELD_PRIORITIES); } -JsonArray *torrent_get_trackers(JsonObject * t) +JsonArray *torrent_get_tracker_stats(JsonObject * t) { - return json_object_get_array_member(t, FIELD_TRACKERS); + return json_object_get_array_member(t, FIELD_TRACKER_STATS); } gint64 torrent_get_id(JsonObject * t) @@ -222,13 +222,13 @@ gchar *torrent_get_status_string(gint64 value) gboolean torrent_has_tracker(JsonObject * t, GRegex * rx, gchar * search) { - GList *trackers = json_array_get_elements(torrent_get_trackers(t)); + GList *trackers = json_array_get_elements(torrent_get_tracker_stats(t)); gboolean ret = FALSE; GList *li; for (li = trackers; li; li = g_list_next(li)) { JsonObject *tracker = json_node_get_object((JsonNode *) li->data); - const gchar *trackerAnnounce = tracker_get_announce(tracker); + const gchar *trackerAnnounce = tracker_stats_get_announce(tracker); gchar *trackerAnnounceHost = trg_gregex_get_first(rx, trackerAnnounce); int cmpResult = g_strcmp0(trackerAnnounceHost, search); @@ -244,27 +244,17 @@ gboolean torrent_has_tracker(JsonObject * t, GRegex * rx, gchar * search) return ret; } -gint64 tracker_get_id(JsonObject * t) -{ - return json_object_get_int_member(t, FIELD_ID); -} - -gint64 tracker_get_tier(JsonObject * t) -{ - return json_object_get_int_member(t, FIELD_TIER); -} - gint64 torrent_get_left_until_done(JsonObject * t) { return json_object_get_int_member(t, FIELD_LEFTUNTILDONE); } -const gchar *tracker_get_announce(JsonObject * t) +const gchar *tracker_stats_get_announce(JsonObject * t) { return json_object_get_string_member(t, FIELD_ANNOUNCE); } -const gchar *tracker_get_scrape(JsonObject * t) +const gchar *tracker_stats_get_scrape(JsonObject * t) { return json_object_get_string_member(t, FIELD_SCRAPE); } @@ -286,3 +276,45 @@ JsonArray *torrent_get_files(JsonObject * args) { return json_object_get_array_member(args, FIELD_FILES); } + +/* tracker stats */ + +gint64 tracker_stats_get_id(JsonObject * t) +{ + return json_object_get_int_member(t, FIELD_ID); +} + +gint64 tracker_stats_get_tier(JsonObject * t) +{ + return json_object_get_int_member(t, FIELD_TIER); +} + +gint64 tracker_stats_get_last_announce_peer_count(JsonObject *t) +{ + return json_object_get_int_member(t, FIELD_LAST_ANNOUNCE_PEER_COUNT); +} + +gint64 tracker_stats_get_last_announce_time(JsonObject *t) +{ + return json_object_get_int_member(t, FIELD_LAST_ANNOUNCE_TIME); +} + +gint64 tracker_stats_get_seeder_count(JsonObject *t) +{ + return json_object_get_int_member(t, FIELD_SEEDERCOUNT); +} + +gint64 tracker_stats_get_leecher_count(JsonObject *t) +{ + return json_object_get_int_member(t, FIELD_LEECHERCOUNT); +} + +const gchar *tracker_stats_get_announce_result(JsonObject *t) +{ + return json_object_get_string_member(t, FIELD_LAST_ANNOUNCE_RESULT); +} + +const gchar *tracker_stats_get_host(JsonObject *t) +{ + return json_object_get_string_member(t, FIELD_HOST); +} diff --git a/src/torrent.h b/src/torrent.h index 77a3004..775b305 100644 --- a/src/torrent.h +++ b/src/torrent.h @@ -52,14 +52,10 @@ gint64 torrent_get_status(JsonObject * t); gchar *torrent_get_status_string(gint64 value); gchar *torrent_get_status_icon(guint flags); JsonArray *torrent_get_peers(JsonObject * t); -JsonArray *torrent_get_trackers(JsonObject * t); +JsonArray *torrent_get_tracker_stats(JsonObject * t); JsonArray *torrent_get_wanted(JsonObject * t); JsonArray *torrent_get_priorities(JsonObject * t); gint64 torrent_get_id(JsonObject * t); -gint64 tracker_get_tier(JsonObject * t); -gint64 tracker_get_id(JsonObject * t); -const gchar *tracker_get_announce(JsonObject * t); -const gchar *tracker_get_scrape(JsonObject * t); JsonArray *torrent_get_files(JsonObject * args); gdouble torrent_get_percent_done(JsonObject * t); gint64 torrent_get_left_until_done(JsonObject * t); @@ -77,7 +73,22 @@ gint64 torrent_get_seed_ratio_mode(JsonObject * t); gint64 torrent_get_peer_limit(JsonObject * t); gboolean torrent_has_tracker(JsonObject * t, GRegex * rx, gchar * search); +/* outer response object */ + JsonArray *get_torrents(JsonObject * response); JsonArray *get_torrents_removed(JsonObject * response); +/* tracker stats */ + +const gchar *tracker_stats_get_announce(JsonObject * t); +const gchar *tracker_stats_get_scrape(JsonObject * t); +gint64 tracker_stats_get_tier(JsonObject * t); +gint64 tracker_stats_get_id(JsonObject * t); +gint64 tracker_stats_get_last_announce_peer_count(JsonObject *t); +gint64 tracker_stats_get_last_announce_time(JsonObject *t); +gint64 tracker_stats_get_seeder_count(JsonObject *t); +gint64 tracker_stats_get_leecher_count(JsonObject *t); +const gchar *tracker_stats_get_announce_result(JsonObject *t); +const gchar *tracker_stats_get_host(JsonObject *t); + #endif /* TORRENT_H_ */ diff --git a/src/trg-client.c b/src/trg-client.c index e302c9c..713de55 100644 --- a/src/trg-client.c +++ b/src/trg-client.c @@ -34,14 +34,6 @@ #include "dispatch.h" #include "trg-client.h" -enum { - CLIENT_SIGNAL_PROFILE_CHANGE, - CLIENT_SIGNAL_PROFILE_NEW, - CLIENT_SIGNAL_COUNT -}; - -static guint signals[CLIENT_SIGNAL_COUNT] = { 0 }; - G_DEFINE_TYPE (TrgClient, trg_client, G_TYPE_OBJECT) #define TRG_CLIENT_GET_PRIVATE(o) \ @@ -105,22 +97,6 @@ trg_client_class_init (TrgClientClass *klass) object_class->get_property = trg_client_get_property; object_class->set_property = trg_client_set_property; object_class->dispose = trg_client_dispose; - - signals[CLIENT_SIGNAL_PROFILE_CHANGE] = - gtk_signal_new ("client-profile-changed", - GTK_RUN_LAST, - G_TYPE_FROM_CLASS(object_class), - GTK_SIGNAL_OFFSET (TrgClientClass, client_profile_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - signals[CLIENT_SIGNAL_PROFILE_NEW] = - gtk_signal_new ("client-profile-new", - GTK_RUN_LAST, - G_TYPE_FROM_CLASS(object_class), - GTK_SIGNAL_OFFSET (TrgClientClass, client_profile_new), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); } static void diff --git a/src/trg-client.h b/src/trg-client.h index bb06e37..e737afb 100644 --- a/src/trg-client.h +++ b/src/trg-client.h @@ -62,8 +62,6 @@ typedef struct { typedef struct { GObjectClass parent_class; - void (*client_profile_changed) (TrgClient * client, gpointer data); - void (*client_profile_new) (TrgClient * client, gpointer data); } TrgClientClass; GType trg_client_get_type (void); diff --git a/src/trg-state-selector.c b/src/trg-state-selector.c index fa34516..aa39f8f 100644 --- a/src/trg-state-selector.c +++ b/src/trg-state-selector.c @@ -297,12 +297,12 @@ void trg_state_selector_update(TrgStateSelector * s) if (priv->showTrackers) { trackersList = - json_array_get_elements(torrent_get_trackers(t)); + json_array_get_elements(torrent_get_tracker_stats(t)); for (trackerItem = trackersList; trackerItem; trackerItem = g_list_next(trackerItem)) { JsonObject *tracker = json_node_get_object((JsonNode *) trackerItem->data); - const gchar *announceUrl = tracker_get_announce(tracker); + const gchar *announceUrl = tracker_stats_get_announce(tracker); gchar *announceHost = trg_gregex_get_first(priv->urlHostRegex, announceUrl); diff --git a/src/trg-trackers-model.c b/src/trg-trackers-model.c index 28f7ea1..5ec588a 100644 --- a/src/trg-trackers-model.c +++ b/src/trg-trackers-model.c @@ -69,13 +69,13 @@ void trg_trackers_model_update(TrgTrackersModel * model, return; } - trackers = json_array_get_elements(torrent_get_trackers(t)); + trackers = json_array_get_elements(torrent_get_tracker_stats(t)); for (li = trackers; li; li = g_list_next(li)) { tracker = json_node_get_object((JsonNode *) li->data); - trackerId = tracker_get_id(tracker); - announce = tracker_get_announce(tracker); - scrape = tracker_get_scrape(tracker); + trackerId = tracker_stats_get_id(tracker); + announce = tracker_stats_get_announce(tracker); + scrape = tracker_stats_get_scrape(tracker); if (mode == TORRENT_GET_MODE_FIRST || find_existing_model_item(GTK_TREE_MODEL(model), @@ -87,7 +87,7 @@ void trg_trackers_model_update(TrgTrackersModel * model, gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, TRACKERCOL_ICON, GTK_STOCK_NETWORK, -1); gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, - TRACKERCOL_TIER, tracker_get_tier(tracker), -1); + TRACKERCOL_TIER, tracker_stats_get_tier(tracker), -1); gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, TRACKERCOL_ANNOUNCE, announce, -1); gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, @@ -96,15 +96,33 @@ void trg_trackers_model_update(TrgTrackersModel * model, TRACKERCOL_ID, trackerId, -1); gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, TRACKERCOL_UPDATESERIAL, updateSerial, -1); + gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, + TRACKERCOL_LAST_ANNOUNCE_RESULT, tracker_stats_get_announce_result(tracker), -1); + gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, + TRACKERCOL_LAST_ANNOUNCE_TIME, tracker_stats_get_last_announce_time(tracker), -1); + gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, + TRACKERCOL_HOST, tracker_stats_get_host(tracker), -1); + gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, + TRACKERCOL_LAST_ANNOUNCE_PEER_COUNT, tracker_stats_get_last_announce_peer_count(tracker), -1); + gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, + TRACKERCOL_LEECHERCOUNT, tracker_stats_get_leecher_count(tracker), -1); + gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, + TRACKERCOL_SEEDERCOUNT, tracker_stats_get_seeder_count(tracker), -1); #else gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, TRACKERCOL_ICON, GTK_STOCK_NETWORK, TRACKERCOL_ID, trackerId, TRACKERCOL_UPDATESERIAL, updateSerial, - TRACKERCOL_TIER, - tracker_get_tier(tracker), - TRACKERCOL_ANNOUNCE, - announce, TRACKERCOL_SCRAPE, scrape, -1); + TRACKERCOL_TIER, tracker_stats_get_tier(tracker), + TRACKERCOL_ANNOUNCE, announce, + TRACKERCOL_SCRAPE, scrape, + TRACKERCOL_HOST, tracker_stats_get_host(tracker), + TRACKERCOL_LAST_ANNOUNCE_RESULT, tracker_stats_get_announce_result(tracker), + TRACKERCOL_LAST_ANNOUNCE_TIME, tracker_stats_get_last_announce_time(tracker), + TRACKERCOL_LAST_ANNOUNCE_PEER_COUNT, tracker_stats_get_last_announce_peer_count(tracker), + TRACKERCOL_LEECHERCOUNT, tracker_stats_get_leecher_count(tracker), + TRACKERCOL_SEEDERCOUNT, tracker_stats_get_seeder_count(tracker), + -1); #endif } @@ -136,6 +154,12 @@ static void trg_trackers_model_init(TrgTrackersModel * self) column_types[TRACKERCOL_ANNOUNCE] = G_TYPE_STRING; column_types[TRACKERCOL_SCRAPE] = G_TYPE_STRING; column_types[TRACKERCOL_ID] = G_TYPE_INT64; + column_types[TRACKERCOL_LAST_ANNOUNCE_PEER_COUNT] = G_TYPE_INT64; + column_types[TRACKERCOL_LAST_ANNOUNCE_TIME] = G_TYPE_INT64; + column_types[TRACKERCOL_SEEDERCOUNT] = G_TYPE_INT64; + column_types[TRACKERCOL_LEECHERCOUNT] = G_TYPE_INT64; + column_types[TRACKERCOL_HOST] = G_TYPE_STRING; + column_types[TRACKERCOL_LAST_ANNOUNCE_RESULT] = G_TYPE_STRING; column_types[TRACKERCOL_UPDATESERIAL] = G_TYPE_INT64; priv->accept = TRUE; diff --git a/src/trg-trackers-model.h b/src/trg-trackers-model.h index c360e95..5219dba 100644 --- a/src/trg-trackers-model.h +++ b/src/trg-trackers-model.h @@ -56,12 +56,40 @@ void trg_trackers_model_set_accept(TrgTrackersModel * model, gint64 trg_trackers_model_get_torrent_id(TrgTrackersModel * model); void trg_trackers_model_set_no_selection(TrgTrackersModel * model); +typedef enum +{ + /* we won't (announce,scrape) this torrent to this tracker because + * the torrent is stopped, or because of an error, or whatever */ + TR_TRACKER_INACTIVE = 0, + + /* we will (announce,scrape) this torrent to this tracker, and are + * waiting for enough time to pass to satisfy the tracker's interval */ + TR_TRACKER_WAITING = 1, + + /* it's time to (announce,scrape) this torrent, and we're waiting on a + * a free slot to open up in the announce manager */ + TR_TRACKER_QUEUED = 2, + + /* we're (announcing,scraping) this torrent right now */ + TR_TRACKER_ACTIVE = 3 +} +tr_tracker_state; + enum { + /* trackers */ TRACKERCOL_ICON, TRACKERCOL_TIER, TRACKERCOL_ANNOUNCE, TRACKERCOL_SCRAPE, TRACKERCOL_ID, + /* trackerstats */ + TRACKERCOL_LAST_ANNOUNCE_PEER_COUNT, + TRACKERCOL_LAST_ANNOUNCE_TIME, + TRACKERCOL_SEEDERCOUNT, + TRACKERCOL_LEECHERCOUNT, + TRACKERCOL_HOST, + TRACKERCOL_LAST_ANNOUNCE_RESULT, + /* other */ TRACKERCOL_UPDATESERIAL, TRACKERCOL_COLUMNS }; diff --git a/src/trg-trackers-tree-view.c b/src/trg-trackers-tree-view.c index 4364e52..e0a458e 100644 --- a/src/trg-trackers-tree-view.c +++ b/src/trg-trackers-tree-view.c @@ -183,6 +183,18 @@ static void trg_trackers_tree_view_init(TrgTrackersTreeView * self) trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, TRACKERCOL_SCRAPE, _("Scrape URL"), "scrape-url", 0); + trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO, TRACKERCOL_LAST_ANNOUNCE_PEER_COUNT, + _("Peer Count"), "last-announce-peer-count", 0); + trg_tree_view_reg_column(ttv, TRG_COLTYPE_EPOCH, TRACKERCOL_LAST_ANNOUNCE_TIME, + _("Last Announce"), "last-announce-time", 0); + trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO, TRACKERCOL_SEEDERCOUNT, + _("Seeder Count"), "seeder-count", 0); + trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTZERO, TRACKERCOL_LEECHERCOUNT, + _("Leecher Count"), "leecher-count", 0); + trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, TRACKERCOL_HOST, + _("Host"), "host", 0); + trg_tree_view_reg_column(ttv, TRG_COLTYPE_TEXT, TRACKERCOL_LAST_ANNOUNCE_RESULT, + _("Last Result"), "last-result", 0); } static void add_tracker(GtkWidget * w, gpointer data) |