[dconf] proper CFLAGS, distcheck fixes



commit a3132216e7b2fd15e675fa352dfa33c03be60f7e
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun May 23 23:38:14 2010 -0400

    proper CFLAGS, distcheck fixes

 Makefile.am                      |    2 +-
 bin/Makefile.am                  |    6 +-
 bin/dconf.c                      |   23 +++----
 client/Makefile.am               |   14 ++++-
 client/dconf-client.c            |    8 +--
 client/dconf-client.h            |   16 ++++-
 common/Makefile.am               |    5 ++
 configure.ac                     |    4 +
 engine/Makefile.am               |    8 ++
 engine/dconf-engine.c            |   28 ++++++++
 engine/dconf-engine.h            |   15 ++++-
 engine/dconf-resetlist.c         |    1 +
 gsettings/Makefile.am            |   14 +++-
 gsettings/dconfsettingsbackend.c |  131 ++++++++++++++++++++++++++++++++++----
 tests/Makefile.am                |    8 ++-
 tests/paths.c                    |    4 +-
 16 files changed, 239 insertions(+), 48 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index d781160..09a356b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1 +1 @@
-SUBDIRS = gvdb service gsettings tests client bin
+SUBDIRS = gvdb service gsettings tests client bin engine common
diff --git a/bin/Makefile.am b/bin/Makefile.am
index 9f97ef2..d7f542d 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -1,4 +1,6 @@
-bin_PROGRAMS = dconf 
+AM_CFLAGS = -std=c89 -Wall -Wmissing-prototypes -Wwrite-strings
+INCLUDES = -I$(top_srcdir)/{common,engine,client} $(gio_CFLAGS)
+
+bin_PROGRAMS = dconf
 
-AM_CFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/client -I$(top_srcdir)/engine $(gio_CFLAGS)
 dconf_LDADD = ../client/libdconf.la
diff --git a/bin/dconf.c b/bin/dconf.c
index 0f81d77..c46a176 100644
--- a/bin/dconf.c
+++ b/bin/dconf.c
@@ -1,6 +1,6 @@
 #include <dconf.h>
 
-const gchar *
+static const gchar *
 shift (int *argc, char ***argv)
 {
   if (argc == 0)
@@ -10,15 +10,6 @@ shift (int *argc, char ***argv)
   return *(*argv)++;
 }
 
-const gchar *
-peek (int argc, char **argv)
-{
-  if (argc == 0)
-    return NULL;
-
-  return *argv;
-}
-
 static gboolean
 grab_args (int           argc,
            char        **argv,
@@ -40,6 +31,8 @@ grab_args (int           argc,
   while (num--)
     *va_arg (ap, gchar **) = *argv++;
   va_end (ap);
+
+  return TRUE;
 }
 
 static gboolean
@@ -146,7 +139,7 @@ do_sync_command (DConfClient  *client,
       if (!ensure ("path", path, dconf_is_path, error))
         return FALSE;
 
-      return dconf_client_set_locked (client, path, TRUE);
+      return dconf_client_set_locked (client, path, TRUE, NULL, NULL);
     }
 
   else if (g_strcmp0 (cmd, "unlock") == 0)
@@ -159,7 +152,7 @@ do_sync_command (DConfClient  *client,
       if (!ensure ("path", path, dconf_is_path, error))
         return FALSE;
 
-      return dconf_client_set_locked (client, path, FALSE);
+      return dconf_client_set_locked (client, path, FALSE, NULL, NULL);
     }
 
   else if (g_strcmp0 (cmd, "is-writable") == 0)
@@ -174,6 +167,12 @@ do_sync_command (DConfClient  *client,
 
       return dconf_client_is_writable (client, path, error);
     }
+
+  else
+    {
+      g_set_error (error, 0, 0, "unknown command");
+      return FALSE;
+    }
 }
 
 int
diff --git a/client/Makefile.am b/client/Makefile.am
index 1e976e8..7f98c85 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -1,5 +1,15 @@
+AM_CFLAGS = -std=c89 -Wall -Wmissing-prototypes -Wwrite-strings
+INCLUDES = -I$(top_srcdir)/{common,gvdb,engine} $(gio_CFLAGS)
+
 lib_LTLIBRARIES = libdconf.la
 
-AM_CFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/engine $(gio_CFLAGS) -I$(top_srcdir)/gvdb
-libdconf_la_SOURCES = dconf-client.c ../common/dconf-paths.c ../engine/dconf-engine.c ../gvdb/gvdb-reader.c
+dconfinclude_HEADERS = \
+	dconf-client.h	\
+	dconf.h
+
 libdconf_la_LIBADD = $(gio_LIBS)
+libdconf_la_SOURCES = \
+	../common/dconf-paths.c		\
+	../engine/dconf-engine.c	\
+	../gvdb/gvdb-reader.c		\
+	dconf-client.c
diff --git a/client/dconf-client.c b/client/dconf-client.c
index ca5e5af..442ad9c 100644
--- a/client/dconf-client.c
+++ b/client/dconf-client.c
@@ -218,6 +218,8 @@ dconf_client_new (const gchar          *context,
   client->watch_func = watch_func;
   client->user_data = user_data;
   client->notify = notify;
+
+  return client;
 }
 
 GVariant *
@@ -228,12 +230,6 @@ dconf_client_read (DConfClient   *client,
   return dconf_engine_read (client->engine, key, type);
 }
 
-static GDBusConnection *
-dconf_client_get_connection (guint    bus_type,
-                             GError **error)
-{
-}
-
 static gboolean
 dconf_client_call_sync (DConfClient          *client,
                         DConfEngineMessage   *dcem,
diff --git a/client/dconf-client.h b/client/dconf-client.h
index ed6698f..1c65e72 100644
--- a/client/dconf-client.h
+++ b/client/dconf-client.h
@@ -53,6 +53,21 @@ gboolean                dconf_client_write_finish                       (DConfCl
                                                                          guint64              *sequence,
                                                                          GError              **error);
 
+gboolean                dconf_client_set_locked                         (DConfClient          *client,
+                                                                         const gchar          *path,
+                                                                         gboolean              locked,
+                                                                         GCancellable         *cancellable,
+                                                                         GError              **error);
+void                    dconf_client_set_locked_async                   (DConfClient          *client,
+                                                                         const gchar          *path,
+                                                                         gboolean              locked,
+                                                                         GCancellable         *cancellable,
+                                                                         GAsyncReadyCallback   callback,
+                                                                         gpointer              user_data);
+gboolean                dconf_client_set_locked_finish                  (DConfClient          *client,
+                                                                         GAsyncResult         *result,
+                                                                         GError              **error);
+
 gboolean                dconf_client_write_many                         (DConfClient          *client,
                                                                          const gchar          *prefix,
                                                                          const gchar * const  *keys,
@@ -88,7 +103,6 @@ void                    dconf_client_unwatch_async                      (DConfCl
 gboolean                dconf_client_unwatch_finish                     (DConfClient          *client,
                                                                          GAsyncResult         *result,
                                                                          gpointer              user_data);
-
 G_END_DECLS
 
 #endif
diff --git a/common/Makefile.am b/common/Makefile.am
new file mode 100644
index 0000000..7423714
--- /dev/null
+++ b/common/Makefile.am
@@ -0,0 +1,5 @@
+dconfinclude_HEADERS = \
+	dconf-paths.h
+
+EXTRA_DIST = \
+	dconf-paths.c
diff --git a/configure.ac b/configure.ac
index 709922d..e083490 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,11 +15,15 @@ AC_SUBST(dbusservicedir)
 AC_ARG_WITH(dbus_system_service_dir, [  --with-dbus-system-service-dir=PATH choose directory for dbus system service files, [default=PREFIX/share/dbus-1/system-services]], dbussystemservicedir="$withval", dbussystemservicedir=${datadir}/dbus-1/system-services)
 AC_SUBST(dbussystemservicedir)
 
+AC_SUBST(dconfincludedir, ${includedir}/dconf)
+
 AC_PATH_PROG(gio_QUERYMODULES, gio-querymodules, no)
 
 AC_OUTPUT([
   gsettings/Makefile
   service/Makefile
+  common/Makefile
+  engine/Makefile
   client/Makefile
   tests/Makefile
   gvdb/Makefile
diff --git a/engine/Makefile.am b/engine/Makefile.am
new file mode 100644
index 0000000..c67c91f
--- /dev/null
+++ b/engine/Makefile.am
@@ -0,0 +1,8 @@
+dconfinclude_HEADERS = \
+	dconf-readtype.h	\
+	dconf-resetlist.h	\
+	dconf-engine.h
+
+EXTRA_DIST = \
+	dconf-resetlist.c	\
+	dconf-engine.c
diff --git a/engine/dconf-engine.c b/engine/dconf-engine.c
index 464b2db..54bf2ed 100644
--- a/engine/dconf-engine.c
+++ b/engine/dconf-engine.c
@@ -1,6 +1,7 @@
 
 #include "dconf-engine.h"
 #include <gvdb-reader.h>
+#include <string.h>
 
 struct _DConfEngine
 {
@@ -204,3 +205,30 @@ dconf_engine_list (DConfEngine    *engine,
 
   return list;
 }
+
+gboolean
+dconf_engine_decode_notify (DConfEngine   *engine,
+                            guint64        anti_expose,
+                            const gchar  **path,
+                            const gchar ***rels,
+                            const gchar   *iface,
+                            const gchar   *method,
+                            GVariant      *body)
+{
+  guint64 ae;
+
+  if (strcmp (iface, "ca.desrt.dconf.Writer") || strcmp (method, "Notify"))
+    return FALSE;
+
+  if (!g_variant_is_of_type (body, G_VARIANT_TYPE ("(tsas)")))
+    return FALSE;
+
+  g_variant_get_child (body, 0, "t", &ae);
+
+  if (ae == anti_expose)
+    return FALSE;
+
+  g_variant_get (body, "(t&s^a&s)", NULL, path, rels);
+
+  return TRUE;
+}
diff --git a/engine/dconf-engine.h b/engine/dconf-engine.h
index c16af84..cc44b27 100644
--- a/engine/dconf-engine.h
+++ b/engine/dconf-engine.h
@@ -47,9 +47,11 @@ gboolean                dconf_engine_write                              (DConfEn
                                                                          const gchar             *key,
                                                                          GVariant                *value,
                                                                          GError                 **error);
-gboolean                dconf_engine_write_tree                         (DConfEngine             *engine,
+gboolean                dconf_engine_write_many                         (DConfEngine             *engine,
                                                                          DConfEngineMessage      *message,
-                                                                         GTree                   *tree,
+                                                                         const gchar             *prefix,
+                                                                         const gchar * const     *keys,
+                                                                         GVariant               **values,
                                                                          GError                 **error);
 void                    dconf_engine_watch                              (DConfEngine             *engine,
                                                                          DConfEngineMessage      *message,
@@ -57,9 +59,16 @@ void                    dconf_engine_watch                              (DConfEn
 void                    dconf_engine_unwatch                            (DConfEngine             *engine,
                                                                          DConfEngineMessage      *message,
                                                                          const gchar             *name);
-void                    dconf_engine_decode_notify                      (DConfEngine             *engine,
+gboolean                dconf_engine_decode_notify                      (DConfEngine             *engine,
+                                                                         guint64                  anti_expose,
                                                                          const gchar            **prefix,
                                                                          const gchar           ***keys,
+                                                                         const gchar             *interface,
+                                                                         const gchar             *member,
                                                                          GVariant                *body);
+void                    dconf_engine_set_locked                         (DConfEngine             *engine,
+                                                                         DConfEngineMessage      *message,
+                                                                         const gchar             *path,
+                                                                         gboolean                 locked);
 
 #endif /* _dconf_engine_h_ */
diff --git a/engine/dconf-resetlist.c b/engine/dconf-resetlist.c
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/engine/dconf-resetlist.c
@@ -0,0 +1 @@
+
diff --git a/gsettings/Makefile.am b/gsettings/Makefile.am
index d32efb4..ec32de0 100644
--- a/gsettings/Makefile.am
+++ b/gsettings/Makefile.am
@@ -1,15 +1,21 @@
-AM_CFLAGS = $(gio_CFLAGS) -I$(top_srcdir)/gvdb -I$(top_srcdir)/engine -I$(top_srcdir)/common
+AM_CFLAGS = -std=c89 -Wall -Wmissing-prototypes -Wwrite-strings
+INCLUDES = -I$(top_srcdir)/{common,gvdb,engine} $(gio_CFLAGS)
 
 giomodules_LTLIBRARIES = libdconfsettings.la
 
 libdconfsettings_la_LIBADD = $(gio_LIBS)
 libdconfsettings_la_LDFLAGS = -module -avoid-version -shared
 libdconfsettings_la_SOURCES = \
-	../engine/dconf-engine.h\
-	../engine/dconf-engine.c\
-	../gvdb/gvdb-reader.c	\
+	../engine/dconf-engine.c	\
+	../gvdb/gvdb-reader.c		\
 	dconfsettingsbackend.c
 
+uninstall-hook:
+	rm -f $(DESTDIR)$(giomodulesdir)/libdconfsettings.so
+	if test -z "$(DESTDIR)" -a "$(gio_QUERYMODULES)" != "no" ; then \
+	  $(gio_QUERYMODULES) $(giomodulesdir) ;  \
+	fi
+
 install-data-hook:
 	rm -f $(DESTDIR)$(giomodulesdir)/libdconfsettings.la
 	if test -z "$(DESTDIR)" -a "$(gio_QUERYMODULES)" != "no" ; then \
diff --git a/gsettings/dconfsettingsbackend.c b/gsettings/dconfsettingsbackend.c
index b1e01e3..913f2b1 100644
--- a/gsettings/dconfsettingsbackend.c
+++ b/gsettings/dconfsettingsbackend.c
@@ -36,11 +36,15 @@ typedef struct
 
   DConfEngine *engine;
 
+  GDBusConnection *session_bus;
+  guint64 session_anti_expose;
+  GDBusConnection *system_bus;
+  guint64 system_anti_expose;
+
   Outstanding *outstanding;
-  GDBusConnection *bus;
-  guint64 anti_expose;
 } DConfSettingsBackend;
 
+static GType dconf_settings_backend_get_type (void);
 G_DEFINE_TYPE (DConfSettingsBackend,
                dconf_settings_backend,
                G_TYPE_SETTINGS_BACKEND)
@@ -241,6 +245,64 @@ dconf_settings_backend_scan_outstanding (DConfSettingsBackend  *backend,
   return found;
 }
 
+static void
+dconf_settings_backend_incoming_signal (DConfSettingsBackend *dcsb,
+                                        GDBusMessage         *message,
+                                        const guint64        *anti_expose)
+{
+  const gchar **rels;
+  const gchar *path;
+
+  if (dconf_engine_decode_notify (dcsb->engine, *anti_expose, &path, &rels,
+                                  g_dbus_message_get_interface (message),
+                                  g_dbus_message_get_member (message),
+                                  g_dbus_message_get_body (message)))
+    {
+      GSettingsBackend *backend = G_SETTINGS_BACKEND (dcsb);
+
+      if (!g_str_has_suffix (path, "/"))
+        g_settings_backend_changed (backend, path, NULL);
+
+      else if (rels[0] == NULL)
+        g_settings_backend_path_changed (backend, path, NULL);
+
+      else
+        g_settings_backend_keys_changed (backend, path, rels, NULL);
+
+      g_free (rels);
+    }
+}
+
+static gboolean
+dconf_settings_backend_filter (GDBusConnection *connection,
+                               GDBusMessage    *message,
+                               gpointer         user_data)
+{
+  DConfSettingsBackend *dcsb = user_data;
+  guint64 *ae;
+
+  if (connection == dcsb->session_bus)
+    ae = &dcsb->session_anti_expose;
+
+  else if (connection == dcsb->system_bus)
+    ae = &dcsb->system_anti_expose;
+
+  else
+    g_assert_not_reached ();
+
+  switch (g_dbus_message_get_message_type (message))
+    {
+    case G_DBUS_MESSAGE_TYPE_METHOD_RETURN:
+      return dconf_settings_backend_remove_outstanding (dcsb, message, ae);
+
+    case G_DBUS_MESSAGE_TYPE_SIGNAL:
+      dconf_settings_backend_incoming_signal (dcsb, message, ae);
+
+    default:
+      return FALSE;
+    }
+}
+
 static GVariant *
 dconf_settings_backend_read (GSettingsBackend   *backend,
                              const gchar        *key,
@@ -265,6 +327,16 @@ dconf_settings_backend_read (GSettingsBackend   *backend,
   return dconf_engine_read (dcsb->engine, key, type);
 }
 
+static gchar **
+dconf_settings_backend_list (GSettingsBackend *backend,
+                             const gchar      *dir,
+                             gsize            *length)
+{
+  DConfSettingsBackend *dcsb = (DConfSettingsBackend *) backend;
+
+  return dconf_engine_list (dcsb->engine, dir, NULL);
+}
+
 static void
 dconf_settings_backend_send (GDBusConnection    *bus,
                              DConfEngineMessage *dcem,
@@ -289,17 +361,47 @@ dconf_settings_backend_send (GDBusConnection    *bus,
 }
 
 static gboolean
-dconf_settings_backend_get_bus (GDBusConnection    **bus,
-                                DConfEngineMessage  *dcem)
+dconf_settings_backend_get_bus (DConfSettingsBackend  *dcsb,
+                                GDBusConnection      **bus,
+                                DConfEngineMessage    *dcem)
 {
   switch (dcem->bus_type)
     {
     case 'e':
-      *bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+      if (dcsb->session_bus == NULL)
+        {
+          g_static_mutex_lock (&dcsb->lock);
+          if (dcsb->session_bus == NULL)
+            {
+              dcsb->session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION,
+                                                  NULL, NULL);
+              g_dbus_connection_add_filter (dcsb->session_bus,
+                                            dconf_settings_backend_filter,
+                                            dcsb, NULL);
+            }
+
+          g_static_mutex_unlock (&dcsb->lock);
+        }
+
+      *bus = dcsb->session_bus;
       break;
 
     case 'y':
-      *bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
+      if (dcsb->system_bus == NULL)
+        {
+          g_static_mutex_lock (&dcsb->lock);
+          if (dcsb->system_bus == NULL)
+            {
+              dcsb->system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM,
+                                                  NULL, NULL);
+              g_dbus_connection_add_filter (dcsb->session_bus,
+                                            dconf_settings_backend_filter,
+                                            dcsb, NULL);
+            }
+          g_static_mutex_unlock (&dcsb->lock);
+        }
+
+      *bus = dcsb->system_bus;
       break;
 
     default:
@@ -326,7 +428,7 @@ dconf_settings_backend_write (GSettingsBackend *backend,
   if (!dconf_engine_write (dcsb->engine, &message, path_or_key, value, NULL))
     return FALSE;
 
-  if (!dconf_settings_backend_get_bus (&bus, &message))
+  if (!dconf_settings_backend_get_bus (dcsb, &bus, &message))
     return FALSE;
 
   serial = dconf_settings_backend_new_outstanding (dcsb,
@@ -337,7 +439,7 @@ dconf_settings_backend_write (GSettingsBackend *backend,
   dconf_settings_backend_send (bus, &message, serial);
 
   if (g_str_has_suffix (path_or_key, "/"))
-    g_settings_backend_changed_path (backend, path_or_key, origin_tag);
+    g_settings_backend_path_changed (backend, path_or_key, origin_tag);
   else
     g_settings_backend_changed (backend, path_or_key, origin_tag);
 
@@ -359,9 +461,10 @@ dconf_settings_backend_write_tree (GSettingsBackend *backend,
 
   g_settings_backend_flatten_tree (tree, &prefix, &keys, &values);
 
-  if (dconf_engine_write_many (dcsb->engine, &message, prefix, keys, values))
+  if (dconf_engine_write_many (dcsb->engine, &message,
+                               prefix, keys, values, NULL))
     {
-      if (dconf_settings_backend_get_bus (&bus, &message))
+      if (dconf_settings_backend_get_bus (dcsb, &bus, &message))
         {
           serial = dconf_settings_backend_new_outstanding (dcsb, NULL,
                                                            NULL, tree);
@@ -400,7 +503,7 @@ dconf_settings_backend_get_writable (GSettingsBackend *backend,
   if (!dconf_engine_is_writable (dcsb->engine, &message, name, NULL))
     return FALSE;
 
-  return dconf_settings_backend_get_bus (&bus, &message);
+  return dconf_settings_backend_get_bus (dcsb, &bus, &message);
 }
 
 static void
@@ -413,7 +516,7 @@ dconf_settings_backend_subscribe (GSettingsBackend *backend,
 
   dconf_engine_watch (dcsb->engine, &message, name);
 
-  if (dconf_settings_backend_get_bus (&bus, &message))
+  if (dconf_settings_backend_get_bus (dcsb, &bus, &message))
     dconf_settings_backend_send (bus, &message, NULL);
 }
 
@@ -427,7 +530,7 @@ dconf_settings_backend_unsubscribe (GSettingsBackend *backend,
 
   dconf_engine_unwatch (dcsb->engine, &message, name);
 
-  if (dconf_settings_backend_get_bus (&bus, &message))
+  if (dconf_settings_backend_get_bus (dcsb, &bus, &message))
     dconf_settings_backend_send (bus, &message, NULL);
 }
 
@@ -446,7 +549,7 @@ static void
 dconf_settings_backend_class_init (GSettingsBackendClass *class)
 {
   class->read = dconf_settings_backend_read;
-  // class->list = dconf_settings_backend_list;
+  class->list = dconf_settings_backend_list;
   class->write = dconf_settings_backend_write;
   class->write_keys = dconf_settings_backend_write_tree;
   class->reset = dconf_settings_backend_reset;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7014fa4..0923e45 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,9 @@
+AM_CFLAGS = -std=c89 -Wall -Wmissing-prototypes -Wwrite-strings
+INCLUDES = -I$(top_srcdir)/{common,engine,client} $(gio_CFLAGS)
+
 noinst_PROGRAMS = paths
 
-AM_CFLAGS = -I$(top_srcdir) $(gio_CFLAGS)
-paths_SOURCES = paths.c ../common/dconf-paths.c
 paths_LDADD = $(gio_LIBS)
+paths_SOURCES = \
+	../common/dconf-paths.c		\
+	paths.c
diff --git a/tests/paths.c b/tests/paths.c
index 9211cee..0b6b0ce 100644
--- a/tests/paths.c
+++ b/tests/paths.c
@@ -1,4 +1,4 @@
-#include <common/dconf-paths.h>
+#include <dconf-paths.h>
 
 static void
 test_paths (void)
@@ -95,4 +95,6 @@ int
 main (void)
 {
   test_paths ();
+
+  return 0;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]