diff options
Diffstat (limited to 'src/trg-trackers-model.c')
-rw-r--r-- | src/trg-trackers-model.c | 135 |
1 files changed, 76 insertions, 59 deletions
diff --git a/src/trg-trackers-model.c b/src/trg-trackers-model.c index bfe8490..d86ed7a 100644 --- a/src/trg-trackers-model.c +++ b/src/trg-trackers-model.c @@ -49,8 +49,8 @@ gint64 trg_trackers_model_get_torrent_id(TrgTrackersModel * model) } void trg_trackers_model_update(TrgTrackersModel * model, - gint64 updateSerial, JsonObject * t, - gint mode) + gint64 updateSerial, JsonObject * t, + gint mode) { TrgTrackersModelPrivate *priv = TRG_TRACKERS_MODEL_GET_PRIVATE(model); @@ -62,76 +62,93 @@ void trg_trackers_model_update(TrgTrackersModel * model, const gchar *scrape; if (mode == TORRENT_GET_MODE_FIRST) { - gtk_list_store_clear(GTK_LIST_STORE(model)); - priv->torrentId = torrent_get_id(t); - priv->accept = TRUE; + gtk_list_store_clear(GTK_LIST_STORE(model)); + priv->torrentId = torrent_get_id(t); + priv->accept = TRUE; } else if (!priv->accept) { - return; + return; } 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_stats_get_id(tracker); - announce = tracker_stats_get_announce(tracker); - scrape = tracker_stats_get_scrape(tracker); + tracker = json_node_get_object((JsonNode *) li->data); + 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), - TRACKERCOL_ID, trackerId, - &trackIter) == FALSE) - gtk_list_store_append(GTK_LIST_STORE(model), &trackIter); + if (mode == TORRENT_GET_MODE_FIRST + || find_existing_model_item(GTK_TREE_MODEL(model), + TRACKERCOL_ID, trackerId, + &trackIter) == FALSE) + gtk_list_store_append(GTK_LIST_STORE(model), &trackIter); #ifdef DEBUG - 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_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, - TRACKERCOL_SCRAPE, scrape, -1); - gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, - 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_LAST_SCRAPE_TIME, tracker_stats_get_last_scrape_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); + 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_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, + TRACKERCOL_SCRAPE, scrape, -1); + gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, + 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_LAST_SCRAPE_TIME, + tracker_stats_get_last_scrape_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_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_SCRAPE_TIME, tracker_stats_get_last_scrape_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); + gtk_list_store_set(GTK_LIST_STORE(model), &trackIter, + TRACKERCOL_ICON, GTK_STOCK_NETWORK, + TRACKERCOL_ID, trackerId, + TRACKERCOL_UPDATESERIAL, updateSerial, + 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_SCRAPE_TIME, + tracker_stats_get_last_scrape_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 } g_list_free(trackers); trg_model_remove_removed(GTK_LIST_STORE(model), - TRACKERCOL_UPDATESERIAL, updateSerial); + TRACKERCOL_UPDATESERIAL, updateSerial); } static void trg_trackers_model_class_init(TrgTrackersModelClass * klass) @@ -140,7 +157,7 @@ static void trg_trackers_model_class_init(TrgTrackersModelClass * klass) } void trg_trackers_model_set_accept(TrgTrackersModel * model, - gboolean accept) + gboolean accept) { TrgTrackersModelPrivate *priv = TRG_TRACKERS_MODEL_GET_PRIVATE(model); priv->accept = accept; @@ -170,7 +187,7 @@ static void trg_trackers_model_init(TrgTrackersModel * self) priv->torrentId = -1; gtk_list_store_set_column_types(GTK_LIST_STORE(self), - TRACKERCOL_COLUMNS, column_types); + TRACKERCOL_COLUMNS, column_types); } TrgTrackersModel *trg_trackers_model_new(void) |