summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/torrent.c4
-rw-r--r--src/tpeer.c3
-rw-r--r--src/util.c2
-rw-r--r--src/util.h2
4 files changed, 6 insertions, 5 deletions
diff --git a/src/torrent.c b/src/torrent.c
index 7376c15..b848629 100644
--- a/src/torrent.c
+++ b/src/torrent.c
@@ -169,12 +169,12 @@ gboolean torrent_get_is_finished(JsonObject * t)
gdouble torrent_get_percent_done(JsonObject * t)
{
- return json_int_or_double_to_double(json_object_get_member(t, FIELD_PERCENTDONE));
+ return json_double_to_progress(json_object_get_member(t, FIELD_PERCENTDONE));
}
gdouble torrent_get_recheck_progress(JsonObject * t)
{
- return json_int_or_double_to_double(json_object_get_member(t, FIELD_RECHECK_PROGRESS));
+ return json_double_to_progress(json_object_get_member(t, FIELD_RECHECK_PROGRESS));
}
guint32 torrent_get_flags(JsonObject * t, gint64 rpcv, gint64 status, gint64 downRate, gint64 upRate)
diff --git a/src/tpeer.c b/src/tpeer.c
index a0cbe6c..22db1fb 100644
--- a/src/tpeer.c
+++ b/src/tpeer.c
@@ -22,6 +22,7 @@
#include "tpeer.h"
#include "protocol-constants.h"
+#include "util.h"
const gchar *peer_get_address(JsonObject * p) {
return json_object_get_string_member(p, TPEER_ADDRESS);
@@ -48,7 +49,7 @@ gboolean peer_get_is_downloading_from(JsonObject * p) {
}
gdouble peer_get_progress(JsonObject * p) {
- return json_object_get_double_member(p, TPEER_PROGRESS) * 100.0;
+ return json_double_to_progress(json_object_get_member(p, TPEER_PROGRESS));
}
gint64 peer_get_rate_to_client(JsonObject * p) {
diff --git a/src/util.c b/src/util.c
index 07a6440..932ef25 100644
--- a/src/util.c
+++ b/src/util.c
@@ -368,7 +368,7 @@ void trg_widget_set_visible(GtkWidget * w, gboolean visible) {
gtk_widget_hide(w);
}
-gdouble json_int_or_double_to_double(JsonNode *n)
+gdouble json_double_to_progress(JsonNode *n)
{
GValue a = { 0 };
json_node_get_value(n, &a);
diff --git a/src/util.h b/src/util.h
index 3250e88..046075f 100644
--- a/src/util.h
+++ b/src/util.h
@@ -67,6 +67,6 @@ int evutil_vsnprintf(char *buf, size_t buflen, const char *format,
va_list ap);
void rm_trailing_slashes(gchar *str);
void trg_widget_set_visible(GtkWidget * w, gboolean visible);
-gdouble json_int_or_double_to_double(JsonNode *n);
+gdouble json_double_to_progress(JsonNode *n);
#endif /* UTIL_H_ */