Fix typo, thanks wwp!
[claws.git] / src / plugins / libravatar / libravatar.c
index a7f9827951e5194b0bec607967626d4104a00dbf..7870bc94db42a802a11d4bf7930d5647922eab47 100644 (file)
@@ -31,6 +31,7 @@
 #include "libravatar.h"
 #include "libravatar_prefs.h"
 #include "libravatar_missing.h"
 #include "libravatar.h"
 #include "libravatar_prefs.h"
 #include "libravatar_missing.h"
+#include "libravatar_federation.h"
 #include "prefs_common.h"
 #include "procheader.h"
 #include "procmsg.h"
 #include "prefs_common.h"
 #include "procheader.h"
 #include "procmsg.h"
@@ -76,10 +77,21 @@ static gboolean libravatar_header_update_hook(gpointer source, gpointer data)
 
 static gchar *federated_base_url_from_address(const gchar *address)
 {
 
 static gchar *federated_base_url_from_address(const gchar *address)
 {
-       /*
-          TODO: no federation supported right now
-          Details on http://wiki.libravatar.org/running_your_own/
-        */
+#if (defined USE_GNUTLS && GLIB_CHECK_VERSION(2,22,0))
+       gchar *base_url = NULL;
+
+       if (!libravatarprefs.allow_federated) {
+               debug_print("federated domains disabled by configuration\n");
+               goto default_url;
+       }
+
+       base_url = federated_url_for_address(address);
+       if (base_url != NULL) {
+               return base_url;
+       }
+
+default_url:
+#endif
        return g_strdup(libravatarprefs.base_url);
 }
 
        return g_strdup(libravatarprefs.base_url);
 }
 
@@ -147,6 +159,8 @@ static GtkWidget *image_widget_from_url(const gchar *url, const gchar *md5)
        }
        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_image_data_cb);
        }
        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_image_data_cb);
+       curl_easy_setopt(curl, CURLOPT_TIMEOUT, prefs_common_get_prefs()->io_timeout_secs);
+       curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
 
        filename = cache_name_for_md5(md5);
        file = fopen(filename, "wb");
 
        filename = cache_name_for_md5(md5);
        file = fopen(filename, "wb");
@@ -261,6 +275,7 @@ static gboolean libravatar_image_render_hook(gpointer source, gpointer data)
                        if (ar->image) /* previous plugin set one */
                                gtk_widget_destroy(ar->image);
                        ar->image = image;
                        if (ar->image) /* previous plugin set one */
                                gtk_widget_destroy(ar->image);
                        ar->image = image;
+                       ar->type  = AVATAR_LIBRAVATAR;
                        return FALSE;
                }
                /* not cached copy: try network */
                        return FALSE;
                }
                /* not cached copy: try network */
@@ -277,6 +292,7 @@ static gboolean libravatar_image_render_hook(gpointer source, gpointer data)
                                if (ar->image) /* previous plugin set one */
                                        gtk_widget_destroy(ar->image);
                                ar->image = image;
                                if (ar->image) /* previous plugin set one */
                                        gtk_widget_destroy(ar->image);
                                ar->image = image;
+                               ar->type  = AVATAR_LIBRAVATAR;
                        }
                }
                g_free(base);
                        }
                }
                g_free(base);
@@ -440,7 +456,7 @@ const gchar *plugin_desc(void)
                 "info about libravatar at http://www.libravatar.org/. If you have\n"
                 "a gravatar.com profile but not a libravatar one, those will also\n"
                 "be retrieved (when redirections are allowed in plugin config).\n"
                 "info about libravatar at http://www.libravatar.org/. If you have\n"
                 "a gravatar.com profile but not a libravatar one, those will also\n"
                 "be retrieved (when redirections are allowed in plugin config).\n"
-                "Plugin config page it's available from main window at:\n"
+                "Plugin config page is available from main window at:\n"
                 "/Configuration/Preferences/Plugins/Libravatar.\n\n"
                 "This plugin uses libcurl to retrieve images, so if you're behind a\n"
                 "proxy please refer to curl(1) manpage for details on 'http_proxy'\n"
                 "/Configuration/Preferences/Plugins/Libravatar.\n\n"
                 "This plugin uses libcurl to retrieve images, so if you're behind a\n"
                 "proxy please refer to curl(1) manpage for details on 'http_proxy'\n"