summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-09-16 19:50:41 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-09-16 19:50:41 +0000
commit0e6f23ff833b5f0eb5c5594961176b7b7abaf6a1 (patch)
tree60772ed65730db8e1fa3ed783fd09ab31d55ffee
parent17f7587fe8c34034d1cc1d22c7d8be15ef03afb3 (diff)
issue 106
-rw-r--r--src/dispatch.c2
-rw-r--r--src/json.c2
-rw-r--r--src/trg-client.c6
-rw-r--r--src/trg-client.h2
-rw-r--r--src/trg-main-window.c16
5 files changed, 21 insertions, 7 deletions
diff --git a/src/dispatch.c b/src/dispatch.c
index e92cb34..03a1755 100644
--- a/src/dispatch.c
+++ b/src/dispatch.c
@@ -42,7 +42,7 @@ JsonObject *dispatch(TrgClient * client, JsonNode * req, int *status)
json_node_free(req);
#ifdef DEBUG
if (g_getenv("TRG_SHOW_OUTGOING"))
- g_debug("=>(outgoing)=>\n%s", serialized);
+ g_debug("=>(OUTgoing)=>: %s", serialized);
#endif
response = trg_http_perform(client, serialized);
g_free(serialized);
diff --git a/src/json.c b/src/json.c
index 6d74b24..fce3954 100644
--- a/src/json.c
+++ b/src/json.c
@@ -57,7 +57,7 @@ JsonObject *trg_deserialize(trg_http_response * response,
root = json_parser_get_root(parser);
#ifdef DEBUG
if (g_getenv("TRG_SHOW_INCOMING") != NULL) {
- g_debug("<=(incoming)<=:\n%s", response->data);
+ g_debug("<=(INcoming)<=: %s", response->data);
} else if (g_getenv("TRG_SHOW_INCOMING_PRETTY") != NULL) {
JsonGenerator *pg;
gsize len;
diff --git a/src/trg-client.c b/src/trg-client.c
index f83b0e4..3dbcea1 100644
--- a/src/trg-client.c
+++ b/src/trg-client.c
@@ -138,7 +138,6 @@ trg_client_new (void)
priv->updateMutex = g_mutex_new();
priv->configMutex = g_mutex_new();
- priv->configSerial = 0;
priv->pool = dispatch_init_pool(tc);
priv->tlsKey = g_private_new(NULL);
@@ -220,7 +219,7 @@ int trg_client_populate_with_settings(TrgClient * tc)
priv->url =
g_strdup_printf("%s://%s:%d/transmission/rpc",
- priv->ssl ? "https" : "http", host, port);
+ priv->ssl ? HTTPS_URI_PREFIX : HTTP_URI_PREFIX, host, port);
g_free(host);
priv->interval =
@@ -252,7 +251,7 @@ int trg_client_populate_with_settings(TrgClient * tc)
int i;
for (i = 0; proxies[i]; i++) {
- if (g_str_has_prefix(proxies[i], "http")) {
+ if (g_str_has_prefix(proxies[i], HTTP_URI_PREFIX)) {
g_free(priv->proxy);
priv->proxy = proxies[i];
} else {
@@ -311,6 +310,7 @@ void trg_client_set_session_id(TrgClient *tc, gchar *session_id)
void trg_client_status_change(TrgClient *tc, gboolean connected)
{
TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc);
+
if (!connected) {
json_object_unref(priv->session);
priv->session = NULL;
diff --git a/src/trg-client.h b/src/trg-client.h
index 8c5e358..a35b9cb 100644
--- a/src/trg-client.h
+++ b/src/trg-client.h
@@ -47,6 +47,8 @@
#include "trg-prefs.h"
#include "session-get.h"
+#define HTTP_URI_PREFIX "http"
+#define HTTPS_URI_PREFIX "https"
#define HTTP_OK 200
#define HTTP_CONFLICT 409
diff --git a/src/trg-main-window.c b/src/trg-main-window.c
index 89a7123..08bdc18 100644
--- a/src/trg-main-window.c
+++ b/src/trg-main-window.c
@@ -210,6 +210,7 @@ struct _TrgMainWindowPrivate {
GtkWidget *filterEntry, *filterEntryClearButton;
gint width, height;
+ guint timerId;
gboolean min_on_start;
gboolean queuesEnabled;
};
@@ -889,7 +890,7 @@ static void on_torrent_get(JsonObject * response, int mode, int status,
trg_status_bar_push_connection_msg(priv->statusBar, statusBarMsg);
g_free(msg);
g_free(statusBarMsg);
- g_timeout_add_seconds(interval, trg_update_torrents_timerfunc, data);
+ priv->timerId = g_timeout_add_seconds(interval, trg_update_torrents_timerfunc, data);
}
gdk_threads_leave();
trg_client_updateunlock(client);
@@ -913,7 +914,7 @@ static void on_torrent_get(JsonObject * response, int mode, int status,
trg_torrent_graph_set_speed(priv->graph, &stats);
if (mode != TORRENT_GET_MODE_INTERACTION)
- g_timeout_add_seconds(interval, trg_update_torrents_timerfunc, data);
+ priv->timerId = g_timeout_add_seconds(interval, trg_update_torrents_timerfunc, data);
gdk_threads_leave();
trg_client_updateunlock(client);
@@ -1188,6 +1189,8 @@ void trg_main_window_conn_changed(TrgMainWindow * win, gboolean connected) {
trg_torrent_graph_set_nothing(priv->graph);
trg_torrent_model_remove_all(priv->torrentModel);
+
+ priv->timerId = 0;
}
trg_client_status_change(tc, connected);
@@ -1307,8 +1310,17 @@ static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow * win) {
}
static void status_icon_activated(GtkStatusIcon * icon G_GNUC_UNUSED, gpointer data) {
+ TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(data);
+
gtk_window_deiconify(GTK_WINDOW(data));
gtk_window_present(GTK_WINDOW(data));
+
+ if (priv->timerId > 0)
+ {
+ g_source_remove(priv->timerId);
+ dispatch_async(priv->client, torrent_get(-1),
+ on_torrent_get_first, data);
+ }
}
static void clear_filter_entry_cb(GtkWidget * w, gpointer data G_GNUC_UNUSED) {