Index: configure.in
===================================================================
--- configure.in	(revision 9232)
+++ configure.in	(working copy)
@@ -203,11 +203,15 @@
   PKG_CHECK_MODULES(LIBEBOOK, [libebook-1.2 >= 1.7.90],
                     [AC_DEFINE([HAVE_LIBEBOOK], 1,
                     [Define if evolution-data-server libebook-1.2 is available])])
-  dnl PolicyKit-gnome is optional
+  dnl PolicyKit-gnome and libsoup are optional
   PKG_CHECK_MODULES(POLKIT_GNOME, [polkit-gnome],
   		    [AC_DEFINE([HAVE_POLKIT], 1,
   		    [Define if PolicyKit-gnome is available])],
   		    has_polkit=false)
+  PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4],
+                    [AC_DEFINE([HAVE_LIBSOUP], 1,
+                    [Define if libsoup-2.4 is available])],
+                    has_libsoup=false)
 fi
 
 AM_CONDITIONAL(BUILD_ABOUTME, test "x$enable_aboutme" = "xyes")
Index: capplets/about-me/gnome-about-me.c
===================================================================
--- capplets/about-me/gnome-about-me.c	(revision 9232)
+++ capplets/about-me/gnome-about-me.c	(working copy)
@@ -40,6 +40,10 @@
 #include <polkit-gnome/polkit-gnome.h>
 #endif
 
+#ifdef HAVE_LIBSOUP
+#include <libsoup/soup.h>
+#endif /* HAVE_LIBSOUP */
+
 #include "e-image-chooser.h"
 #include "gnome-about-me-password.h"
 #include "gnome-about-me-fingerprint.h"
@@ -52,6 +56,8 @@
 
 #define EMAIL_SLOTS 4
 
+#define GCONF_GRAVATAR_KEY  "/desktop/gnome/interface/gravatar_email_address"
+
 typedef struct {
 	EContact 	*contact;
 	EBook    	*book;
@@ -151,8 +157,10 @@
 #define ATTRIBUTE_OTHER "OTHER"
 
 static void about_me_set_address_field (EContactAddress *, guint, gchar *);
+#ifdef HAVE_LIBSOUP
+static void download_gravatar (guint email_index, SoupSession *session);
+#endif /* HAVE_LIBSOUP */
 
-
 /*** Utility functions ***/
 static void
 about_me_error (GtkWindow *parent, gchar *str)
@@ -565,13 +573,14 @@
 }
 
 static void
-about_me_update_photo (GnomeAboutMe *me)
+about_me_update_photo (GnomeAboutMe *me, const gchar *gravatar_email_address)
 {
 	GtkWidget     *widget;
 	GladeXML      *dialog;
 	EContactPhoto *photo;
 	gchar         *file;
 	GError        *error;
+	GConfClient   *gconf_client;
 
 	guchar 	      *data;
 	gsize 	       length;
@@ -661,6 +670,19 @@
 		g_free (file);
 	}
 
+	/* Save the Gravatar e-mail address so gnome-settings-daemon can regularly update from it */
+	gconf_client = gconf_client_get_default ();
+	if (gravatar_email_address != NULL)
+		gconf_client_set_string (gconf_client, GCONF_GRAVATAR_KEY, gravatar_email_address, &error);
+	else
+		gconf_client_unset (gconf_client, GCONF_GRAVATAR_KEY, &error);
+
+	if (error != NULL) {
+		g_warning ("Could not update %s GConf key: %s", GCONF_GRAVATAR_KEY, error->message);
+		g_error_free (error);
+	}
+	g_object_unref (gconf_client);
+
 	about_me_commit (me);
 }
 
@@ -757,7 +779,92 @@
 	gtk_file_chooser_set_preview_widget_active (chooser, TRUE);
 }
 
+#ifdef HAVE_LIBSOUP
 static void
+download_gravatar_cb (SoupSession *session, SoupMessage *message, gpointer user_data)
+{
+	GladeXML *dialog;
+	GtkWidget *image_chooser;
+	guint email_index = GPOINTER_TO_UINT (user_data);
+
+	dialog = me->dialog;
+	image_chooser = WID ("image-chooser");
+
+	if (SOUP_STATUS_IS_REDIRECTION (message->status_code)) {
+		/* Gravatar doesn't exist for this e-mail address;
+		 * move on to the next one */
+		download_gravatar (email_index + 1, session);
+		return;
+	}
+
+	me->have_image = TRUE;
+	me->image_changed = TRUE;
+	e_image_chooser_set_image_data (E_IMAGE_CHOOSER (image_chooser),
+					(char*) message->response_body->data,
+					message->response_body->length);
+	about_me_update_photo (me, me->email[email_index]);
+
+	g_object_unref (session);
+}
+
+static void
+download_gravatar (guint email_index, SoupSession *session)
+{
+	gchar *uri, *email_md5;
+	SoupMessage *message;
+
+	if (email_index >= EMAIL_SLOTS) {
+		/* We've run out of e-mail addresses without any hits */
+		GtkWidget *message_dialog, *image_chooser;
+		GladeXML *dialog = me->dialog;
+
+		message_dialog = gtk_message_dialog_new (GTK_WINDOW (WID ("about-me-dialog")), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
+							 GTK_BUTTONS_OK, _("Gravatar Not Found"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
+							  _("No Gravatar could be found for any of your e-mail addresses."));
+		gtk_dialog_run (GTK_DIALOG (message_dialog));
+		gtk_widget_destroy (message_dialog);
+
+		/* Set the user's face image to nothing */
+		image_chooser = WID ("image-chooser");
+
+		me->have_image = FALSE;
+		me->image_changed = TRUE;
+		e_image_chooser_set_from_file (E_IMAGE_CHOOSER (image_chooser), me->person);
+		about_me_update_photo (me, NULL);
+
+		if (session != NULL)
+			g_object_unref (session);
+
+		return;
+	}
+
+	if (me->email[email_index] == NULL) {
+		/* No e-mail address in this slot, so move on to the next */
+		download_gravatar (email_index + 1, session);
+		return;
+	}
+
+	/* Build the avatar URI (see http://en.gravatar.com/site/implement/url).
+	 * We set http://example.com as the default Gravatar so we can catch the
+	 * redirect to determine that an e-mail address doesn't have a Gravatar. */
+	email_md5 = g_compute_checksum_for_string (G_CHECKSUM_MD5, me->email[email_index], -1);
+	uri = g_strdup_printf ("http://www.gravatar.com/avatar/%s?s=%u&d=http%%3A%%2F%%2Fexample.com", email_md5, MAX_WIDTH);
+	g_free (email_md5);
+
+	if (session == NULL)
+		session = soup_session_async_new ();
+	message = soup_message_new ("GET", uri);
+	soup_message_set_flags (message, SOUP_MESSAGE_NO_REDIRECT);
+	g_free (uri);
+
+	soup_session_queue_message (session, message, download_gravatar_cb, GUINT_TO_POINTER (email_index));
+}
+#endif /* HAVE_LIBSOUP */
+
+#define GRAVATAR_RESPONSE 1
+
+static void
 about_me_image_clicked_cb (GtkWidget *button, GnomeAboutMe *me)
 {
 	GtkFileChooser *chooser_dialog;
@@ -775,6 +882,9 @@
 	chooser_dialog = GTK_FILE_CHOOSER (
 			 gtk_file_chooser_dialog_new (_("Select Image"), GTK_WINDOW (WID ("about-me-dialog")),
 							GTK_FILE_CHOOSER_ACTION_OPEN,
+#ifdef HAVE_LIBSOUP
+							_("Use Gravatar"), GRAVATAR_RESPONSE,
+#endif /* HAVE_LIBSOUP */
 							_("No Image"), GTK_RESPONSE_NO,
 							GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 							GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
@@ -822,12 +932,17 @@
 
 		e_image_chooser_set_from_file (E_IMAGE_CHOOSER (image_chooser), filename);
 		g_free (filename);
-		about_me_update_photo (me);
+		about_me_update_photo (me, NULL);
 	} else if (response == GTK_RESPONSE_NO) {
 		me->have_image = FALSE;
 		me->image_changed = TRUE;
 		e_image_chooser_set_from_file (E_IMAGE_CHOOSER (image_chooser), me->person);
-		about_me_update_photo (me);
+		about_me_update_photo (me, NULL);
+#ifdef HAVE_LIBSOUP
+	} else if (response == GRAVATAR_RESPONSE) {
+		/* Start checking our e-mail addresses to see if we have a Gravatar */
+		download_gravatar (0, NULL);
+#endif /* HAVE_LIBSOUP */
 	}
 
 	gtk_widget_destroy (GTK_WIDGET (chooser_dialog));
@@ -838,7 +953,7 @@
 {
 	me->have_image = TRUE;
 	me->image_changed = TRUE;
-	about_me_update_photo (me);
+	about_me_update_photo (me, NULL);
 }
 
 /* About Me Dialog Callbacks */
Index: capplets/about-me/gnome-about-me.schemas.in
===================================================================
--- capplets/about-me/gnome-about-me.schemas.in	(revision 0)
+++ capplets/about-me/gnome-about-me.schemas.in	(revision 0)
@@ -0,0 +1,15 @@
+<gconfschemafile>
+	<schemalist>
+		<schema>
+			<key>/schemas/desktop/gnome/interface/gravatar_email_address</key>
+			<applyto>/desktop/gnome/interface/gravatar_email_address</applyto>
+			<owner>gnome-control-center</owner>
+			<type>string</type>
+			<default></default>
+			<locale name="C">
+				<short>Gravatar e-mail address</short>
+				<long>The e-mail address of the Gravatar used as the user's photo by the about-me capplet. Gravatar isn't in use if this is empty.</long>
+			</locale>
+		</schema>
+	</schemalist>
+</gconfschemafile>
Index: capplets/about-me/Makefile.am
===================================================================
--- capplets/about-me/Makefile.am	(revision 9232)
+++ capplets/about-me/Makefile.am	(working copy)
@@ -28,7 +28,7 @@
 pixmapdir = $(pkgdatadir)/pixmaps
 pixmap_DATA = $(pixmap_files)
 
-gnome_about_me_LDADD = $(GNOMECC_CAPPLETS_LIBS) $(LIBEBOOK_LIBS) $(POLKIT_GNOME_LIBS)
+gnome_about_me_LDADD = $(GNOMECC_CAPPLETS_LIBS) $(LIBEBOOK_LIBS) $(POLKIT_GNOME_LIBS) $(LIBSOUP_LIBS)
 gnome_about_me_LDFLAGS = -export-dynamic
 
 @INTLTOOL_DESKTOP_RULE@
@@ -36,6 +36,23 @@
 desktopdir = $(datadir)/applications
 desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
 
+@INTLTOOL_SCHEMAS_RULE@
+
+schemasdir = $(GCONF_SCHEMA_FILE_DIR)
+schemas_in_files = gnome-about-me.schemas.in
+schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
+
+install-data-local:
+if GCONF_SCHEMAS_INSTALL
+	@GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) gconftool-2 \
+		--makefile-install-rule $(schemas_DATA) || \
+		(echo ;\
+		echo "*****************************************************"; \
+		echo "Installation of schemas failed: install them manually"; \
+		echo "*****************************************************";)
+	@true
+endif
+
 gladedir   = $(pkgdatadir)/glade
 glade_DATA = $(glade_files)
 
@@ -43,6 +60,7 @@
 	$(GNOMECC_CAPPLETS_CFLAGS) \
 	$(LIBEBOOK_CFLAGS) \
 	$(POLKIT_GNOME_CFLAGS) \
+	$(LIBSOUP_CFLAGS) \
 	-DDATADIR="\"$(datadir)\"" \
 	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
 	-DGNOMECC_GLADE_DIR="\"$(gladedir)\"" \
Index: po/POTFILES.in
===================================================================
--- po/POTFILES.in	(revision 9232)
+++ po/POTFILES.in	(working copy)
@@ -6,6 +6,7 @@
 capplets/about-me/fingerprint-strings.h
 capplets/about-me/gnome-about-me.c
 capplets/about-me/gnome-about-me.desktop.in.in
+capplets/about-me/gnome-about-me.schemas.in
 capplets/about-me/gnome-about-me-fingerprint.c
 capplets/about-me/gnome-about-me-fingerprint.glade
 capplets/about-me/gnome-about-me.glade
