diff options
author | Alan Fitton <ajf@eth0.org.uk> | 2011-09-13 20:18:22 +0000 |
---|---|---|
committer | Alan Fitton <ajf@eth0.org.uk> | 2011-09-13 20:18:22 +0000 |
commit | 53ca28eb754d1a94a0220810f9a2bd37598ef18b (patch) | |
tree | 3c347822e3d70b9d0e070e7c27aa1b333be1ba66 | |
parent | fad64fe594bf7b5c13a09f343392e5552c7a4d81 (diff) |
more windows portability
-rw-r--r-- | config.h.in | 3 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/main.c | 1 | ||||
-rw-r--r-- | src/trg-client.c | 8 | ||||
-rw-r--r-- | src/trg-client.h | 6 | ||||
-rw-r--r-- | src/trg-main-window.c | 12 | ||||
-rw-r--r-- | src/trg-preferences-dialog.c | 4 |
7 files changed, 35 insertions, 3 deletions
diff --git a/config.h.in b/config.h.in index a3a9510..ddf41fe 100644 --- a/config.h.in +++ b/config.h.in @@ -18,6 +18,9 @@ /* Define to 1 if you have a functional curl library. */ #undef HAVE_LIBCURL +/* Define if libnotify is available */ +#undef HAVE_LIBNOTIFY + /* Define if libproxy is available */ #undef HAVE_LIBPROXY diff --git a/configure.ac b/configure.ac index 625803e..32a8ef5 100644 --- a/configure.ac +++ b/configure.ac @@ -38,8 +38,8 @@ PKG_CHECK_MODULES([jsonglib], [json-glib-1.0 >= 0.8]) PKG_CHECK_MODULES([gthread], [gthread-2.0]) PKG_CHECK_MODULES([gtk], [gtk+-2.0 >= 2.16]) PKG_CHECK_MODULES([gio], [gio-2.0 >= 2.22]) -PKG_CHECK_MODULES([unique], [unique-1.0], AC_DEFINE(HAVE_LIBUNIQUE, 1, [Define if libunique is available])) -PKG_CHECK_MODULES([notify], [libnotify]) +PKG_CHECK_MODULES([unique], [unique-1.0], AC_DEFINE(HAVE_LIBUNIQUE, 1, [Define if libunique is available]), AC_MSG_WARN([libunique is required for opening torrents])) +PKG_CHECK_MODULES([notify], [libnotify], AC_DEFINE(HAVE_LIBNOTIFY, 1, [Define if libnotify is available]), AC_MSG_WARN([libnotify is required for popup desktop notifications])) PKG_CHECK_MODULES([libproxy], [libproxy-1.0], AC_DEFINE(HAVE_LIBPROXY, 1, [Define if libproxy is available]), AC_MSG_WARN([libproxy is required for HTTP proxy support])) LIBCURL_CHECK_CONFIG([yes], [7.0], [], [AC_MSG_ERROR(["libcurl not found"])]) @@ -104,7 +104,6 @@ int main(int argc, char *argv[]) gtk_init(&argc, &argv); g_set_application_name (PACKAGE_NAME); - setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, TRGLOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); diff --git a/src/trg-client.c b/src/trg-client.c index 3256bf5..55ae74e 100644 --- a/src/trg-client.c +++ b/src/trg-client.c @@ -210,7 +210,11 @@ int trg_client_populate_with_settings(TrgClient * tc) return TRG_NO_HOSTNAME_SET; } +#ifndef CURL_NO_SSL priv->ssl = trg_prefs_get_bool(prefs, TRG_PREFS_KEY_SSL, TRG_PREFS_PROFILE); +#else + priv->ssl = FALSE; +#endif priv->url = g_strdup_printf("%s://%s:%d/transmission/rpc", @@ -335,11 +339,13 @@ gint64 trg_client_get_serial(TrgClient *tc) return priv->updateSerial; } +#ifndef CURL_NO_SSL gboolean trg_client_get_ssl(TrgClient *tc) { TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc); return priv->ssl; } +#endif gchar *trg_client_get_proxy(TrgClient *tc) { @@ -483,8 +489,10 @@ static void trg_tls_update(TrgClient *tc, trg_tls *tls, gint serial) curl_easy_setopt(tls->curl, CURLOPT_USERNAME, trg_client_get_username(tc)); curl_easy_setopt(tls->curl, CURLOPT_URL, trg_client_get_url(tc)); +#ifndef CURL_NO_SSL if (trg_client_get_ssl(tc)) curl_easy_setopt(tls->curl, CURLOPT_SSL_VERIFYPEER, 0); +#endif proxy = trg_client_get_proxy(tc); if (proxy) { diff --git a/src/trg-client.h b/src/trg-client.h index 78a674d..8c5e358 100644 --- a/src/trg-client.h +++ b/src/trg-client.h @@ -34,6 +34,10 @@ #define TRG_NO_HOSTNAME_SET -2 #define SESSION_UPDATE_DIVISOR 10 +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <curl/curl.h> #include <curl/easy.h> @@ -113,7 +117,9 @@ gchar *trg_client_get_username(TrgClient *tc); gchar *trg_client_get_url(TrgClient *tc); gchar *trg_client_get_session_id(TrgClient *tc); void trg_client_set_session_id(TrgClient *tc, gchar *session_id); +#ifndef CURL_NO_SSL gboolean trg_client_get_ssl(TrgClient *tc); +#endif gchar *trg_client_get_proxy(TrgClient *tc); gint64 trg_client_get_serial(TrgClient *tc); void trg_client_thread_pool_push(TrgClient *tc, gpointer data, GError **err); diff --git a/src/trg-main-window.c b/src/trg-main-window.c index ee48abe..4f7b6df 100644 --- a/src/trg-main-window.c +++ b/src/trg-main-window.c @@ -32,7 +32,9 @@ #include <json-glib/json-glib.h> #include <gdk/gdkkeysyms.h> #include <curl/curl.h> +#ifdef HAVE_LIBNOTIFY #include <libnotify/notify.h> +#endif #include "dispatch.h" #include "trg-client.h" @@ -70,9 +72,11 @@ static void update_selected_torrent_notebook(TrgMainWindow * win, gint mode, gint64 id); +#ifdef HAVE_LIBNOTIFY static void torrent_event_notification(TrgTorrentModel * model, gchar * icon, gchar * desc, gint tmout, gchar * prefKey, GtkTreeIter * iter, gpointer data); +#endif static void on_torrent_completed(TrgTorrentModel * model, GtkTreeIter * iter, gpointer data); static void on_torrent_added(TrgTorrentModel * model, GtkTreeIter * iter, @@ -254,6 +258,7 @@ static void update_selected_torrent_notebook(TrgMainWindow * win, gint mode, priv->selectedTorrentId = id; } +#ifdef HAVE_LIBNOTIFY static void torrent_event_notification(TrgTorrentModel * model, gchar * icon, gchar * desc, gint tmout, gchar * prefKey, GtkTreeIter * iter, gpointer data) { @@ -288,13 +293,16 @@ static void torrent_event_notification(TrgTorrentModel * model, gchar * icon, notify_notification_show(notify, NULL); } +#endif static void on_torrent_completed(TrgTorrentModel * model, GtkTreeIter * iter, gpointer data) { +#ifdef HAVE_LIBNOTIFY torrent_event_notification(model, GTK_STOCK_APPLY, _("This torrent has completed."), TORRENT_COMPLETE_NOTIFY_TMOUT, TRG_PREFS_KEY_COMPLETE_NOTIFY, iter, data); +#endif } static void on_torrent_addremove(TrgTorrentModel * model, gpointer data) { @@ -304,9 +312,11 @@ static void on_torrent_addremove(TrgTorrentModel * model, gpointer data) { static void on_torrent_added(TrgTorrentModel * model, GtkTreeIter * iter, gpointer data) { +#ifdef HAVE_LIBNOTIFY torrent_event_notification(model, GTK_STOCK_ADD, _("This torrent has been added."), TORRENT_ADD_NOTIFY_TMOUT, TRG_PREFS_KEY_ADD_NOTIFY, iter, data); +#endif } static gboolean delete_event(GtkWidget * w, GdkEvent * event G_GNUC_UNUSED, gpointer data G_GNUC_UNUSED) { @@ -1745,7 +1755,9 @@ static GObject *trg_main_window_constructor(GType type, priv->icon = gtk_icon_theme_load_icon(theme, PACKAGE_NAME, 48, GTK_ICON_LOOKUP_USE_BUILTIN, NULL); +#ifdef HAVE_LIBNOTIFY notify_init(PACKAGE_NAME); +#endif if (priv->icon) gtk_window_set_default_icon(priv->icon); diff --git a/src/trg-preferences-dialog.c b/src/trg-preferences-dialog.c index ab80101..3d514ff 100644 --- a/src/trg-preferences-dialog.c +++ b/src/trg-preferences-dialog.c @@ -381,6 +381,7 @@ static GtkWidget *trg_prefs_desktopPage(TrgPreferencesDialog *dlg) { G_CALLBACK(toggle_active_arg_is_sensitive), w); hig_workarea_add_wide_control(t, &row, w); +#ifdef HAVE_LIBNOTIFY w = trgp_check_new(dlg, _("Torrent added notifications"), TRG_PREFS_KEY_ADD_NOTIFY, TRG_PREFS_GLOBAL, NULL); gtk_widget_set_sensitive(w, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON @@ -396,6 +397,7 @@ static GtkWidget *trg_prefs_desktopPage(TrgPreferencesDialog *dlg) { g_signal_connect(G_OBJECT(tray), "toggled", G_CALLBACK(toggle_active_arg_is_sensitive), w); hig_workarea_add_wide_control(t, &row, w); +#endif return t; } @@ -629,9 +631,11 @@ static GtkWidget *trg_prefs_serverPage(TrgPreferencesDialog *dlg) { TRG_PREFS_KEY_AUTO_CONNECT, TRG_PREFS_PROFILE, NULL); hig_workarea_add_wide_control(t, &row, w); +#ifndef CURL_NO_SSL w = trgp_check_new(dlg, _("SSL"), TRG_PREFS_KEY_SSL, TRG_PREFS_PROFILE, NULL); hig_workarea_add_wide_control(t, &row, w); +#endif activeOnly = w = trgp_check_new(dlg, _("Update active torrents only"), TRG_PREFS_KEY_UPDATE_ACTIVE_ONLY, TRG_PREFS_PROFILE, NULL); |