summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@src.gnome.org>2003-03-11 02:49:14 +0000
committerAnders Carlsson <andersca@src.gnome.org>2003-03-11 02:49:14 +0000
commit73bde9de01c9bd1b08cb20e14498694594e9f304 (patch)
tree59a71e9cdb6a5fe58c26a8b7f387241a60bbfd7c
parent6f41c18385d65f9caa3df687d8bca30106f0e698 (diff)
downloadgconf-73bde9de01c9bd1b08cb20e14498694594e9f304.tar.gz
More stuff
-rw-r--r--gconf/Makefile.am7
-rw-r--r--gconf/gconf-dbus.c45
-rw-r--r--gconf/gconf-dbus.h11
-rw-r--r--gconf/gconf.h4
-rw-r--r--gconf/gconfd-dbus.c30
-rw-r--r--gconf/gconfd-dbus.h7
-rw-r--r--gconf/simple-test.c57
7 files changed, 137 insertions, 24 deletions
diff --git a/gconf/Makefile.am b/gconf/Makefile.am
index 3118e9cc..bc60a77b 100644
--- a/gconf/Makefile.am
+++ b/gconf/Makefile.am
@@ -35,6 +35,7 @@ libexec_PROGRAMS = gconfd-2 $(SANITY_CHECK)
CORBA_SOURCECODE = GConfX-common.c GConfX-skels.c GConfX-stubs.c GConfX.h
+noinst_PROGRAMS = simple-test
## not BUILT_SOURCES which seems to make a mess. fix with automake 1.5?
built_sourcecode = \
$(CORBA_SOURCECODE) \
@@ -85,10 +86,10 @@ gconfd_2_SOURCES = \
gconfd_2_LDADD = $(EFENCE) $(INTLLIBS) $(DEPENDENT_LIBS) libgconf-$(MAJOR_VERSION).la
-# gconf_testclient_SOURCES = \
-# testclient.c
+simple_test_SOURCES = \
+ simple-test.c
-# gconf_testclient_LDADD = $(GLIB_LIBS) $(OAF_LIBS) libgconf-client.la
+simple_test_LDADD = $(DEPENDENT_LIBS) libgconf-$(MAJOR_VERSION).la
gconftool_2_SOURCES = \
gconftool.c
diff --git a/gconf/gconf-dbus.c b/gconf/gconf-dbus.c
index 9c67e014..48f91dcd 100644
--- a/gconf/gconf-dbus.c
+++ b/gconf/gconf-dbus.c
@@ -49,3 +49,48 @@ gconf_dbus_fill_message_from_gconf_value (DBusMessage *message,
g_error ("unsupported gconf value type %d", value->type);
}
}
+
+GConfValue *
+gconf_dbus_create_gconf_value_from_message (DBusMessageIter *iter)
+{
+ int arg_type;
+ GConfValue *gval;
+ GConfValueType type = GCONF_VALUE_INVALID;
+
+ arg_type = dbus_message_iter_get_arg_type (iter);
+
+ switch (arg_type)
+ {
+ case DBUS_TYPE_NIL:
+ return NULL;
+ case DBUS_TYPE_STRING:
+ type = GCONF_VALUE_STRING;
+ break;
+ default:
+ g_error ("unsupported arg type %d\n",
+ arg_type);
+
+ }
+
+ g_assert(GCONF_VALUE_TYPE_VALID(type));
+
+ gval = gconf_value_new(type);
+
+ switch (gval->type)
+ {
+ case GCONF_VALUE_STRING:
+ {
+ char *str;
+ str = dbus_message_iter_get_string (iter);
+
+ gconf_value_set_string (gval, str);
+ dbus_free (str);
+ break;
+ }
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ return gval;
+}
diff --git a/gconf/gconf-dbus.h b/gconf/gconf-dbus.h
index e8bc2153..072767eb 100644
--- a/gconf/gconf-dbus.h
+++ b/gconf/gconf-dbus.h
@@ -23,6 +23,17 @@
#include <dbus/dbus-glib.h>
#include "gconf.h"
+#define GCONF_DBUS_CONFIG_SERVER "org.freedesktop.Config.Server"
+
+#define GCONF_DBUS_CONFIG_SERVER_SHUTDOWN "org.freedesktop.Config.Server.Shutdown"
+
+#define GCONF_DBUS_CONFIG_DATABASE_DIR_EXISTS "org.freedesktop.Config.Database.DirExists"
+#define GCONF_DBUS_CONFIG_DATABASE_ALL_DIRS "org.freedesktop.Config.Database.AllDirs"
+#define GCONF_DBUS_CONFIG_DATABASE_ALL_ENTRIES "org.freedesktop.Config.Database.AllEntries"
+#define GCONF_DBUS_CONFIG_DATABASE_LOOKUP "org.freedesktop.Config.Database.Lookup"
+
+
+GConfValue *gconf_dbus_create_gconf_value_from_message (DBusMessageIter *iter);
void gconf_dbus_fill_message_from_gconf_value (DBusMessage *message,
const GConfValue *value);
diff --git a/gconf/gconf.h b/gconf/gconf.h
index 7c4212b3..cec2fb34 100644
--- a/gconf/gconf.h
+++ b/gconf/gconf.h
@@ -21,11 +21,13 @@
#define GCONF_GCONF_H
#include <glib.h>
+#include <dbus/dbus-glib.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
+
#include <gconf/gconf-schema.h>
#include <gconf/gconf-engine.h>
#include <gconf/gconf-error.h>
@@ -267,6 +269,8 @@ gboolean gconf_init (int argc, char **argv, GError** err);
gboolean gconf_is_initialized (void);
#endif /* GCONF_DISABLE_DEPRECATED */
+gboolean gconf_init_dbus (DBusConnection *connection);
+
/* No, you can't use this stuff. Bad application developer. Bad. */
#ifdef GCONF_ENABLE_INTERNALS
diff --git a/gconf/gconfd-dbus.c b/gconf/gconfd-dbus.c
index 1966bca3..0fbbcf2e 100644
--- a/gconf/gconfd-dbus.c
+++ b/gconf/gconfd-dbus.c
@@ -24,15 +24,15 @@
#include "gconf-dbus.h"
static const char *config_database_messages[] = {
- GCONFD_CONFIG_DATABASE_DIR_EXISTS,
- GCONFD_CONFIG_DATABASE_ALL_DIRS,
- GCONFD_CONFIG_DATABASE_ALL_ENTRIES,
- GCONFD_CONFIG_DATABASE_LOOKUP,
+ GCONF_DBUS_CONFIG_DATABASE_DIR_EXISTS,
+ GCONF_DBUS_CONFIG_DATABASE_ALL_DIRS,
+ GCONF_DBUS_CONFIG_DATABASE_ALL_ENTRIES,
+ GCONF_DBUS_CONFIG_DATABASE_LOOKUP,
};
static const char *config_server_messages[] =
{
- GCONFD_CONFIG_SERVER_SHUTDOWN
+ GCONF_DBUS_CONFIG_SERVER_SHUTDOWN
};
static void
@@ -53,7 +53,7 @@ gconfd_config_server_handler (DBusMessageHandler *handler,
DBusMessage *message,
void *user_data)
{
- if (dbus_message_name_is (message, GCONFD_CONFIG_SERVER_SHUTDOWN))
+ if (dbus_message_name_is (message, GCONF_DBUS_CONFIG_SERVER_SHUTDOWN))
{
gconfd_shutdown (connection, message);
@@ -68,11 +68,11 @@ gconf_dbus_set_exception (DBusConnection *connection,
DBusMessage *message,
GError *error)
{
+ /* FIXME: Check GError and maybe send back an error message */
if (error)
- printf ("error: %s\n", error->message);
+ g_warning ("FIXME: Check GError and send back an error message");
- g_warning ("FIXME: Check GError and maybe send back an error message");
- /* FIXME: Check GError and maybe send back an error message */
+
return FALSE;
}
static GConfDatabase *
@@ -105,6 +105,8 @@ gconf_dbus_get_message_args (DBusConnection *connection,
if (retval != DBUS_RESULT_SUCCESS)
{
+ g_warning ("malformed message of type %s\n", dbus_message_get_name (message));
+
/* FIXME: Send error message */
return FALSE;
}
@@ -390,22 +392,22 @@ gconfd_config_database_handler (DBusMessageHandler *handler,
DBusMessage *message,
void *user_data)
{
- if (dbus_message_name_is (message, GCONFD_CONFIG_DATABASE_DIR_EXISTS))
+ if (dbus_message_name_is (message, GCONF_DBUS_CONFIG_DATABASE_DIR_EXISTS))
{
gconfd_config_database_dir_exists (connection, message);
return DBUS_HANDLER_RESULT_REMOVE_MESSAGE;
}
- else if (dbus_message_name_is (message, GCONFD_CONFIG_DATABASE_ALL_DIRS))
+ else if (dbus_message_name_is (message, GCONF_DBUS_CONFIG_DATABASE_ALL_DIRS))
{
gconfd_config_database_all_dirs (connection, message);
return DBUS_HANDLER_RESULT_REMOVE_MESSAGE;
}
- else if (dbus_message_name_is (message, GCONFD_CONFIG_DATABASE_ALL_ENTRIES))
+ else if (dbus_message_name_is (message, GCONF_DBUS_CONFIG_DATABASE_ALL_ENTRIES))
{
gconfd_config_database_all_entries (connection, message);
return DBUS_HANDLER_RESULT_REMOVE_MESSAGE;
}
- else if (dbus_message_name_is (message, GCONFD_CONFIG_DATABASE_LOOKUP))
+ else if (dbus_message_name_is (message, GCONF_DBUS_CONFIG_DATABASE_LOOKUP))
{
gconfd_config_database_lookup (connection, message);
return DBUS_HANDLER_RESULT_REMOVE_MESSAGE;
@@ -418,7 +420,7 @@ static const char *
get_dbus_address (void)
{
/* FIXME: Change this when we know how to find the message bus. */
- return g_getenv ("GCONFD_DBUS_ADDRESS");
+ return g_getenv ("GCONF_DBUS_ADDRESS");
}
gboolean
diff --git a/gconf/gconfd-dbus.h b/gconf/gconfd-dbus.h
index fc6265a4..717199f5 100644
--- a/gconf/gconfd-dbus.h
+++ b/gconf/gconfd-dbus.h
@@ -22,13 +22,6 @@
#include <dbus/dbus-glib.h>
-#define GCONFD_CONFIG_SERVER_SHUTDOWN "org.freedesktop.Config.Server.Shutdown"
-
-#define GCONFD_CONFIG_DATABASE_DIR_EXISTS "org.freedesktop.Config.Database.DirExists"
-#define GCONFD_CONFIG_DATABASE_ALL_DIRS "org.freedesktop.Config.Database.AllDirs"
-#define GCONFD_CONFIG_DATABASE_ALL_ENTRIES "org.freedesktop.Config.Database.AllEntries"
-
-#define GCONFD_CONFIG_DATABASE_LOOKUP "org.freedesktop.Config.Database.Lookup"
gboolean gconfd_dbus_init (void);
gboolean gconfd_dbus_check_in_shutdown (DBusConnection *connection,
diff --git a/gconf/simple-test.c b/gconf/simple-test.c
new file mode 100644
index 00000000..db3fd7e1
--- /dev/null
+++ b/gconf/simple-test.c
@@ -0,0 +1,57 @@
+/* GConf
+ * Copyright (C) 2003 CodeFactory AB
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include <gconf/gconf-client.h>
+
+int
+main (int argc, char **argv)
+{
+ GConfClient *client;
+ DBusConnection *connection;
+ DBusResultCode result;
+ const char *address;
+ char *name;
+
+ address = g_getenv ("GCONF_DBUS_ADDRESS");
+ connection = dbus_connection_open (address, &result);
+
+ if (!connection)
+ {
+ g_printerr ("Failed to connect to the D-BUS bus daemon: %s",
+ dbus_result_to_string (result));
+ return 1;
+ }
+
+ name = dbus_bus_register_client (connection, &result);
+ if (!name)
+ {
+ g_printerr ("Failed to register client with the D-BUS bus daemon: %s",
+ dbus_result_to_string (result));
+ return 1;
+ }
+
+ g_type_init ();
+
+ gconf_init_dbus (connection);
+
+ client = gconf_client_get_default ();
+
+ g_print ("foo: %s\n", gconf_client_get_string (client, "/desktop/gnome/interface/icon_theme", NULL));
+
+ return 0;
+}