Fix bug 4325 "Following redirects when retrieving image"
[claws.git] / src / plugins / libravatar / libravatar_prefs.c
index 86f8732029e193b1d4ba5be70f0b45a65ee7683d..3a097001b54a14c84a6f8a623614abdb4c43ecd6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2014-2015 Ricardo Mones and the Claws Mail Team
+ * Copyright (C) 2014-2016 Ricardo Mones and the Claws Mail Team
  *
  * 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
@@ -58,7 +58,7 @@ struct LibravatarPrefsPage
        GtkWidget *defm_radio[NUM_DEF_BUTTONS];
        GtkWidget *defm_url_text;
        GtkWidget *allow_redirects_check;
-#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+#if defined USE_GNUTLS
        GtkWidget *allow_federated_check;
 #endif
        GtkWidget *timeout;
@@ -85,7 +85,7 @@ static PrefParam param[] = {
        { "allow_redirects", "TRUE",
          &libravatarprefs.allow_redirects,
           P_BOOL, NULL, NULL, NULL },
-#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+#if defined USE_GNUTLS
        { "allow_federated", "TRUE",
          &libravatarprefs.allow_federated,
           P_BOOL, NULL, NULL, NULL },
@@ -93,6 +93,15 @@ static PrefParam param[] = {
        { "timeout", "0",
          &libravatarprefs.timeout,
           P_INT, NULL, NULL, NULL },
+       { "max_redirects_url", "7",
+         &libravatarprefs.max_redirects_url,
+          P_INT, NULL, NULL, NULL },
+       { "max_redirects_mm", "5",
+         &libravatarprefs.max_redirects_mm,
+          P_INT, NULL, NULL, NULL },
+       { "max_redirects", "3",
+         &libravatarprefs.max_redirects,
+          P_INT, NULL, NULL, NULL },
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 
@@ -163,16 +172,16 @@ static void cache_clean_button_clicked_cb(GtkButton *button, gpointer data)
 
        val = alertpanel_full(_("Clear icon cache"),
                        _("Are you sure you want to remove all cached avatar icons?"),
-                       GTK_STOCK_NO, GTK_STOCK_YES, NULL, FALSE,
-                       NULL, ALERT_WARNING, G_ALERTDEFAULT);
+                       GTK_STOCK_NO, GTK_STOCK_YES, NULL, ALERTFOCUS_FIRST, FALSE,
+                       NULL, ALERT_WARNING);
        if (val != G_ALERTALTERNATE)
                return;
 
-       debug_print("cleaning missing cache");
+       debug_print("cleaning missing cache\n");
        misses = g_hash_table_size(libravatarmisses);
        g_hash_table_remove_all(libravatarmisses);
 
-       debug_print("cleaning disk cache");
+       debug_print("cleaning disk cache\n");
        acr = libravatar_cache_clean();
        if (acr == NULL) {
                alertpanel_error(_("Not enough memory for operation"));
@@ -373,7 +382,7 @@ static GtkWidget *p_create_frame_network(struct LibravatarPrefsPage *page)
 {
        GtkWidget *vbox, *chk_redirects, *spinner, *hbox;
        GtkAdjustment *adj;
-#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+#if defined USE_GNUTLS
        GtkWidget *chk_federated;
 #endif
 
@@ -388,7 +397,7 @@ static GtkWidget *p_create_frame_network(struct LibravatarPrefsPage *page)
        page->allow_redirects_check = chk_redirects;
        gtk_box_pack_start(GTK_BOX(vbox), chk_redirects, FALSE, FALSE, 0);
 
-#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+#if defined USE_GNUTLS
        chk_federated = create_checkbox(_("_Enable federated servers"),
                                _("Try to get avatar from sender's domain "
                                  "libravatar server"));
@@ -526,7 +535,7 @@ static void libravatar_prefs_save_func(PrefsPage * _page)
        libravatarprefs.allow_redirects = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->allow_redirects_check));
        /* federation */
-#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+#if defined USE_GNUTLS
        libravatarprefs.allow_federated = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->allow_federated_check));
 #endif