diff options
-rw-r--r-- | aclocal.m4 | 4 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/base64.c | 45 | ||||
-rw-r--r-- | src/base64.h | 25 | ||||
-rw-r--r-- | src/requests.c | 4 | ||||
-rw-r--r-- | src/util.c | 19 | ||||
-rw-r--r-- | src/util.h | 1 |
7 files changed, 24 insertions, 75 deletions
@@ -13,8 +13,8 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],, -[m4_warning([this file was generated for autoconf 2.67. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, +[m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) diff --git a/src/Makefile.am b/src/Makefile.am index 660a59e..fbd1bb0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,7 +33,6 @@ endif transmission_remote_gtk_SOURCES = main.c \ requests.c \ - base64.c \ json.c \ trg-main-window.c \ util.c \ diff --git a/src/base64.c b/src/base64.c deleted file mode 100644 index 55002ff..0000000 --- a/src/base64.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * transmission-remote-gtk - A GTK RPC client to Transmission - * Copyright (C) 2011 Alan Fitton - - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <stdlib.h> -#include <string.h> - -#include <glib.h> -#include <glib/gstdio.h> - -#include "base64.h" - -gchar *base64encode(const gchar *filename) -{ - GError *error = NULL; - GMappedFile *mf = g_mapped_file_new(filename, FALSE, &error); - gchar *b64out = NULL; - - if (error) - { - g_error("%s",error->message); - g_error_free(error); - } else { - b64out = g_base64_encode((guchar*)g_mapped_file_get_contents(mf), g_mapped_file_get_length(mf)); - } - - g_mapped_file_unref(mf); - - return b64out; -} diff --git a/src/base64.h b/src/base64.h deleted file mode 100644 index ab84071..0000000 --- a/src/base64.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * transmission-remote-gtk - A GTK RPC client to Transmission - * Copyright (C) 2011 Alan Fitton - - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef BASE64_H_ -#define BASE64_H_ - -gchar *base64encode(const gchar *filename); - -#endif /* BASE64_H_ */ diff --git a/src/requests.c b/src/requests.c index 5deb94e..1923102 100644 --- a/src/requests.c +++ b/src/requests.c @@ -24,9 +24,9 @@ #include <json-glib/json-glib.h> #include "protocol-constants.h" -#include "base64.h" #include "json.h" #include "torrent.h" +#include "util.h" #include "requests.h" static JsonNode *base_request(gchar * method); @@ -213,7 +213,7 @@ JsonNode *torrent_add(gchar * filename, gint flags) { JsonNode *root = base_request(METHOD_TORRENT_ADD); JsonObject *args = node_get_arguments(root); - gchar *encodedFile = base64encode(filename); + gchar *encodedFile = trg_base64encode(filename); if (encodedFile) json_object_set_string_member(args, PARAM_METAINFO, encodedFile); json_object_set_boolean_member(args, PARAM_PAUSED, (flags & TORRENT_ADD_FLAG_PAUSED) == TORRENT_ADD_FLAG_PAUSED); @@ -373,3 +373,22 @@ gdouble json_double_to_progress(JsonNode *n) return 0.0; } } + +gchar *trg_base64encode(const gchar *filename) +{ + GError *error = NULL; + GMappedFile *mf = g_mapped_file_new(filename, FALSE, &error); + gchar *b64out = NULL; + + if (error) + { + g_error("%s",error->message); + g_error_free(error); + } else { + b64out = g_base64_encode((guchar*)g_mapped_file_get_contents(mf), g_mapped_file_get_length(mf)); + } + + g_mapped_file_unref(mf); + + return b64out; +} @@ -66,5 +66,6 @@ int evutil_vsnprintf(char *buf, size_t buflen, const char *format, void rm_trailing_slashes(gchar *str); void trg_widget_set_visible(GtkWidget * w, gboolean visible); gdouble json_double_to_progress(JsonNode *n); +gchar *trg_base64encode(const gchar *filename); #endif /* UTIL_H_ */ |