Index: configure.in
===================================================================
--- configure.in	(revision 2627)
+++ configure.in	(working copy)
@@ -166,7 +166,31 @@
 AC_SUBST(DEPENDENT_WITH_XML_AND_GTK_LIBS)
 AC_SUBST(DEPENDENT_WITH_XML_AND_GTK_CFLAGS)
 
+AC_ARG_ENABLE(defaults-service,
+              [AC_HELP_STRING([--enable-defaults-service],
+                              [build the defaults DBus service [default=auto]])],
+              [enable_defaults_service="$enableval"],
+              [enable_defaults_service=auto])
+if test "x$enable_defaults_service" != "xno" ; then
+  PKG_CHECK_MODULES(DEFAULTS, glib-2.0 gobject-2.0 dbus-1 dbus-glib-1 polkit-dbus, HAVE_POLKIT=yes, HAVE_POLKIT=no)
+  if test "x$HAVE_POLKIT" = "xno"; then
+    if test "x$enable_defaults_service" = "xyes" ; then
+      AC_MSG_ERROR([[
+*** Could not find PolicyKit.]])
+    else
+      enable_defaults_service=no
+    fi
+  else
+    enable_defaults_service=yes
+  fi
+fi
 
+if test "x$enable_defaults_service" != "xno" ; then
+  AC_DEFINE(ENABLE_DEFAULTS_SERVICE, 1, [enable defaults DBus service])
+fi
+
+AM_CONDITIONAL(ENABLE_DEFAULTS_SERVICE, [test "x$enable_defaults_service" != "xno"])
+
 ORBIT_IDL="`$PKG_CONFIG --variable=orbit_idl ORBit-2.0`"
 AC_SUBST(ORBIT_IDL)
 
@@ -261,6 +285,7 @@
 doc/gconf/Makefile
 examples/Makefile
 tests/Makefile
+defaults/Makefile
 gconf-2.0.pc
 ])
 
Index: gconf/gconfd.c
===================================================================
--- gconf/gconfd.c	(revision 2627)
+++ gconf/gconfd.c	(working copy)
@@ -521,7 +521,7 @@
 static DBusHandlerResult
 bus_message_handler (DBusConnection *connection,
                      DBusMessage    *message,
-                     GMainLoop      *loop)
+                     void           *user_data)
 {
   DBusMessage *reply;
 
@@ -617,6 +617,102 @@
   return connection;
 }
 
+#ifdef ENABLE_DEFAULTS_SERVICE
+/* listen on system bus for defaults changes */
+
+static DBusHandlerResult
+system_bus_message_handler (DBusConnection *connection,
+			    DBusMessage    *message,
+			    void           *user_data)
+{
+  DBusMessage *reply;
+
+  reply = NULL;
+
+  if (dbus_message_is_signal (message,
+			      "org.gnome.GConf.Defaults",
+                              "SystemSet"))
+    {
+      DBusError bus_error;
+      char **keys;
+      int n_keys;
+
+      dbus_error_init (&bus_error);
+      if (dbus_message_get_args (message, &bus_error,
+				 DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &keys, &n_keys,
+				 DBUS_TYPE_INVALID))
+	{
+	  char **key;
+	  GConfSources *system_sources;
+	  GSList addresses;
+
+	  gconf_log (GCL_DEBUG, "System defaults changed.  Notifying.");
+
+	  addresses.data = "xml:merged:/etc/gconf/gconf.xml.system";
+	  addresses.next = NULL;
+	  system_sources = gconf_sources_new_from_addresses (&addresses, NULL);
+
+	  gconfd_clear_cache_for_sources (system_sources);
+
+	  for (key = keys; *key; key++)
+	    gconfd_notify_other_listeners (NULL, system_sources, *key);
+
+	  gconf_sources_free (system_sources);
+
+	  dbus_free_string_array (keys);
+	}
+      else
+        {
+	  gconf_log (GCL_DEBUG, "SystemSet signal received, but error getting message: %s", bus_error.message);
+	}
+      dbus_error_free (&bus_error);
+
+      return DBUS_HANDLER_RESULT_HANDLED;
+    }
+
+  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static DBusConnection *
+get_on_system_bus (void)
+{
+  DBusConnection *connection;
+  DBusError bus_error;
+  int result;
+
+  dbus_error_init (&bus_error);
+  connection = dbus_bus_get (DBUS_BUS_SYSTEM, &bus_error);
+
+  if (dbus_error_is_set (&bus_error))
+    {
+      gconf_log (GCL_ERR, _("Could not connect to system bus: %s"), bus_error.message);
+      dbus_error_free (&bus_error);
+      return NULL;
+    }
+
+  dbus_connection_setup_with_g_main (connection, NULL);
+
+  dbus_bus_add_match (connection, "type='signal',interface='org.gnome.GConf.Defaults'", &bus_error);
+  dbus_connection_flush(connection);
+  if (dbus_error_is_set (&bus_error))
+    {
+      gconf_log (GCL_DEBUG, "Failed to add signal match to system bus: %s", bus_error.message);
+      dbus_connection_unref (connection);
+      return NULL;
+    }
+
+  if (!dbus_connection_add_filter (connection, (DBusHandleMessageFunction)
+                                   system_bus_message_handler, NULL, NULL))
+    {
+      gconf_log (GCL_DEBUG, "Failed to add message filter to system bus.");
+      dbus_connection_unref (connection);
+      return NULL;
+    }
+
+  return connection;
+}
+#endif  /* ENABLE_DEFAULTS_SERVICE */
+
 int 
 main(int argc, char** argv)
 {
@@ -778,7 +874,11 @@
 
   /* Read saved log file, if any */
   logfile_read ();
-  
+ 
+#ifdef ENABLE_DEFAULTS_SERVICE 
+  get_on_system_bus ();
+#endif
+
   gconf_main ();
 
   if (in_shutdown)
@@ -1207,6 +1307,22 @@
     }
 }
 
+void
+gconfd_clear_cache_for_sources (GConfSources *sources)
+{
+  GList *tmp;
+
+  tmp = db_list;
+  while (tmp != NULL)
+    {
+      GConfDatabase *db = tmp->data;
+
+      gconf_database_clear_cache_for_sources (db, sources, NULL);
+
+      tmp = tmp->next;
+    }
+}
+
 /*
  * Cleanup
  */
Index: gconf/gconf-sources.c
===================================================================
--- gconf/gconf-sources.c	(revision 2627)
+++ gconf/gconf-sources.c	(working copy)
@@ -34,6 +34,8 @@
 #include <errno.h>
 #include <ctype.h>
 
+static const char * get_address_resource (const char *address);
+
 /* 
  *  Sources
  */
@@ -487,6 +489,44 @@
     }
 }
 
+void
+gconf_sources_clear_cache_for_sources (GConfSources  *sources,
+				       GConfSources  *affected)
+{
+  GList* tmp;
+
+  tmp = sources->sources;
+
+  while (tmp != NULL)
+    {
+      GConfSource* source = tmp->data;
+      const char *source_resource = get_address_resource (source->address);
+
+      GList* tmp2;
+
+      if (source->backend->vtable.clear_cache == NULL)
+        continue;
+
+      tmp2 = affected->sources;
+
+      while (tmp2 != NULL)
+	{
+	  GConfSource* affected_source = tmp2->data;
+
+	  if (source->backend == affected_source->backend &&
+	      strcmp (source_resource, get_address_resource (affected_source->address)) == 0)
+	    {
+	      if (source->backend->vtable.clear_cache)
+		(*source->backend->vtable.clear_cache)(source);
+	    }
+
+	  tmp2 = g_list_next(tmp2);
+	}
+      
+      tmp = g_list_next(tmp);
+    }
+}
+
 GConfValue*   
 gconf_sources_query_value (GConfSources* sources, 
                            const gchar* key,
Index: gconf/gconf-sources.h
===================================================================
--- gconf/gconf-sources.h	(revision 2627)
+++ gconf/gconf-sources.h	(working copy)
@@ -82,6 +82,8 @@
 GConfSources* gconf_sources_new_from_source    (GConfSource   *source);
 void          gconf_sources_free               (GConfSources  *sources);
 void          gconf_sources_clear_cache        (GConfSources  *sources);
+void          gconf_sources_clear_cache_for_sources (GConfSources  *sources,
+						     GConfSources  *affected);
 GConfValue*   gconf_sources_query_value        (GConfSources  *sources,
                                                 const gchar   *key,
                                                 const gchar  **locales,
Index: gconf/gconf-database.c
===================================================================
--- gconf/gconf-database.c	(revision 2627)
+++ gconf/gconf-database.c	(working copy)
@@ -1722,6 +1722,18 @@
   gconf_sources_clear_cache(db->sources);
 }
 
+void
+gconf_database_clear_cache_for_sources (GConfDatabase  *db,
+					GConfSources   *sources,
+					GError        **err)
+{
+  g_assert(db->listeners != NULL);
+
+  db->last_access = time(NULL);
+
+  gconf_sources_clear_cache_for_sources(db->sources, sources);
+}
+
 const gchar *
 gconf_database_get_persistent_name (GConfDatabase *db)
 {
Index: gconf/gconf-database.h
===================================================================
--- gconf/gconf-database.h	(revision 2627)
+++ gconf/gconf-database.h	(working copy)
@@ -133,6 +133,9 @@
                                           GError    **err);
 void     gconf_database_clear_cache      (GConfDatabase  *db,
                                           GError    **err);
+void     gconf_database_clear_cache_for_sources (GConfDatabase  *db,
+						 GConfSources   *sources,
+						 GError        **err);
 
 
 void gconfd_locale_cache_expire (void);
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 2627)
+++ Makefile.am	(working copy)
@@ -1,7 +1,11 @@
 
-SUBDIRS = gconf backends po doc examples
-DIST_SUBDIRS=tests $(SUBDIRS)
+SUBDIRS = gconf backends po doc examples 
+DIST_SUBDIRS=tests defaults $(SUBDIRS) 
 
+if ENABLE_DEFAULTS_SERVICE
+SUBDIRS += defaults
+endif
+
 EXTRA_DIST =                \
 	TODO                \
 	gtk-doc.make        \
Index: po/POTFILES.in
===================================================================
--- po/POTFILES.in	(revision 2627)
+++ po/POTFILES.in	(working copy)
@@ -9,6 +9,7 @@
 backends/xml-cache.c
 backends/xml-dir.c
 backends/xml-entry.c
+defaults/org.gnome.gconf.defaults.policy.in
 gconf/gconf-backend.c
 gconf/gconf-client.c
 gconf/gconf-database.c
