diff options
author | Alan Fitton <ajf@eth0.org.uk> | 2011-08-27 22:24:12 +0000 |
---|---|---|
committer | Alan Fitton <ajf@eth0.org.uk> | 2011-08-27 22:24:12 +0000 |
commit | ed3cec7420b188b85a1585479215f519a301fc37 (patch) | |
tree | 2e9cc02b7361e5f70e88f7f7809d7ff37dab0735 /src/requests.c | |
parent | 7020a3a7db7ce7e192e7b84e0f359b85584fe1a4 (diff) |
issue 58
Diffstat (limited to 'src/requests.c')
-rw-r--r-- | src/requests.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/requests.c b/src/requests.c index 252a1dd..0f56a8d 100644 --- a/src/requests.c +++ b/src/requests.c @@ -19,12 +19,14 @@ #include <stdio.h> +#include <glib/gstdio.h> #include <glib-object.h> #include <json-glib/json-glib.h> #include "protocol-constants.h" #include "base64.h" #include "json.h" +#include "torrent.h" #include "requests.h" static JsonNode *base_request(gchar * method); @@ -33,7 +35,7 @@ JsonNode *generic_request(gchar * method, JsonArray * ids) { JsonNode *root = base_request(method); - if (ids != NULL) + if (ids) json_object_set_array_member(node_get_arguments(root), PARAM_IDS, ids); @@ -174,15 +176,19 @@ JsonNode *torrent_add_url(const gchar * url, gboolean paused) return root; } -JsonNode *torrent_add(gchar * filename, gboolean paused) +JsonNode *torrent_add(gchar * filename, gint flags) { JsonNode *root = base_request(METHOD_TORRENT_ADD); JsonObject *args = node_get_arguments(root); gchar *encodedFile = base64encode(filename); if (encodedFile) json_object_set_string_member(args, PARAM_METAINFO, encodedFile); - json_object_set_boolean_member(args, PARAM_PAUSED, paused); + json_object_set_boolean_member(args, PARAM_PAUSED, (flags & TORRENT_ADD_FLAG_PAUSED) == TORRENT_ADD_FLAG_PAUSED); g_free(encodedFile); + + if ((flags & TORRENT_ADD_FLAG_DELETE)) + g_unlink(filename); + return root; } |