From 78b168dbc30d9540b96254b77cfeaef3619b540c Mon Sep 17 00:00:00 2001 From: Alan Fitton Date: Fri, 11 Feb 2011 23:44:45 +0000 Subject: ssl support --- src/http.c | 3 ++- src/transmission-remote-gtk.schemas | 13 +++++++++++++ src/trg-client.c | 5 ++++- src/trg-client.h | 1 + src/trg-preferences-dialog.c | 6 +++++- src/trg-preferences.h | 1 + 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/http.c b/src/http.c index b4595ea..e8609fd 100644 --- a/src/http.c +++ b/src/http.c @@ -76,7 +76,8 @@ static struct http_response *trg_http_perform_inner(trg_client * tc, curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, &header_callback); curl_easy_setopt(handle, CURLOPT_WRITEHEADER, (void *) tc); curl_easy_setopt(handle, CURLOPT_POSTFIELDS, req); - /*curl_easy_setopt(handle, CURLOPT_VERBOSE, 1); */ + if (tc->ssl) + curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0); if (tc->session_id != NULL) { headers = curl_slist_append(headers, tc->session_id); diff --git a/src/transmission-remote-gtk.schemas b/src/transmission-remote-gtk.schemas index dbd08aa..a4df4e0 100644 --- a/src/transmission-remote-gtk.schemas +++ b/src/transmission-remote-gtk.schemas @@ -27,6 +27,19 @@ + + /schemas/apps/transmission-remote-gtk/ssl + /apps/transmission-remote-gtk/ssl + transmission-remote-gtk + bool + 0 + + + SSL + SSL + + + /schemas/apps/transmission-remote-gtk/system-tray /apps/transmission-remote-gtk/system-tray diff --git a/src/trg-client.c b/src/trg-client.c index 35915b4..b7ac4fd 100644 --- a/src/trg-client.c +++ b/src/trg-client.c @@ -61,7 +61,10 @@ int trg_client_populate_with_settings(trg_client * tc, if (!host || strlen(host) < 1) return TRG_NO_HOSTNAME_SET; - tc->url = g_strdup_printf("http://%s:%d/transmission/rpc", host, port); + tc->ssl = gconf_client_get_bool(gconf, TRG_GCONF_KEY_SSL, &error); + check_for_error(error); + + tc->url = g_strdup_printf("%s://%s:%d/transmission/rpc", tc->ssl ? "https" : "http", host, port); g_free(host); tc->username = diff --git a/src/trg-client.h b/src/trg-client.h index 082f4d3..4d98420 100644 --- a/src/trg-client.h +++ b/src/trg-client.h @@ -33,6 +33,7 @@ typedef struct { gint failCount; gint64 updateSerial; JsonObject *session; + gboolean ssl; char *url; char *username; char *password; diff --git a/src/trg-preferences-dialog.c b/src/trg-preferences-dialog.c index 70c3465..e94f5c8 100644 --- a/src/trg-preferences-dialog.c +++ b/src/trg-preferences-dialog.c @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -238,6 +238,10 @@ static GtkWidget *trg_prefs_serverPage(GConfClient * gconf) TRG_GCONF_KEY_AUTO_CONNECT); hig_workarea_add_wide_control(t, &row, w); + w = new_check_button(gconf, "SSL", + TRG_GCONF_KEY_SSL); + hig_workarea_add_wide_control(t, &row, w); + hig_workarea_add_section_divider(t, &row); hig_workarea_add_section_title(t, &row, "Authentication"); diff --git a/src/trg-preferences.h b/src/trg-preferences.h index 7c01cf6..bb52bca 100644 --- a/src/trg-preferences.h +++ b/src/trg-preferences.h @@ -25,6 +25,7 @@ #define TRG_GCONF_KEY_USERNAME "/apps/transmission-remote-gtk/username" #define TRG_GCONF_KEY_PASSWORD "/apps/transmission-remote-gtk/password" #define TRG_GCONF_KEY_AUTO_CONNECT "/apps/transmission-remote-gtk/auto-connect" +#define TRG_GCONF_KEY_SSL "/apps/transmission-remote-gtk/ssl" #define TRG_GCONF_KEY_WINDOW_WIDTH "/apps/transmission-remote-gtk/window-width" #define TRG_GCONF_KEY_WINDOW_HEIGHT "/apps/transmission-remote-gtk/window-height" #define TRG_GCONF_KEY_SYSTEM_TRAY "/apps/transmission-remote-gtk/system-tray" -- cgit v1.2.3