summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Hallendal <hallski@src.gnome.org>2003-11-27 13:29:53 +0000
committerMikael Hallendal <hallski@src.gnome.org>2003-11-27 13:29:53 +0000
commit8d2768d4b4c24b8635e2e7d2fae8bce661528c26 (patch)
treeb90e4a28e9416b790395096fe13642bc570b0f2d
parent3b48d2ff51de261bb4293f3b2c755cf1ef339d51 (diff)
downloadgconf-8d2768d4b4c24b8635e2e7d2fae8bce661528c26.tar.gz
simple notification implemented
-rw-r--r--gconf/gconf-database-dbus.c68
-rw-r--r--gconf/gconfd-dbus.c6
-rw-r--r--gconf/gconfd-dbus.h1
-rw-r--r--gconf/gconfd.c1
4 files changed, 54 insertions, 22 deletions
diff --git a/gconf/gconf-database-dbus.c b/gconf/gconf-database-dbus.c
index e70e2487..691e1a00 100644
--- a/gconf/gconf-database-dbus.c
+++ b/gconf/gconf-database-dbus.c
@@ -494,38 +494,41 @@ GConfDatabaseDBus *
gconf_database_dbus_get (DBusConnection *conn, const gchar *address,
GError **gerror)
{
- GConfDatabaseDBus *dbus_db;
+ GConfDatabaseDBus *dbus_db = NULL;
GConfDatabase *db;
gchar **path;
ensure_initialized ();
-
- if (address)
- dbus_db = g_hash_table_lookup (databases, address);
- else
- dbus_db = default_db;
-
- if (dbus_db)
- return dbus_db;
- db = gconfd_obtain_database (address, gerror);
- if (!db)
- return NULL;
+ db = gconfd_lookup_database (address);
- dbus_db = g_new0 (GConfDatabaseDBus, 1);
- dbus_db->db = db;
- dbus_db->conn = conn;
- if (address)
+ if (db)
{
- dbus_db->address = g_strdup (address);
- g_hash_table_insert (databases, dbus_db->address, dbus_db);
+ dbus_db = g_hash_table_lookup (databases,
+ gconf_database_get_persistent_name (db));
+
+ if (dbus_db)
+ return dbus_db;
+ else
+ goto register_db;
}
- else
+ else
{
- dbus_db->address = NULL;
- default_db = dbus_db;
+ db = gconfd_obtain_database (address, gerror);
+ if (!db)
+ {
+ gconf_log (GCL_WARNING, _("Database doesn't exist: %s"), address);
+ return NULL;
+ }
+ goto register_db;
}
+register_db:
+ dbus_db = g_new0 (GConfDatabaseDBus, 1);
+ dbus_db->db = db;
+ dbus_db->conn = conn;
+ dbus_db->address = g_strdup (gconf_database_get_persistent_name (db));
+ g_hash_table_insert (databases, dbus_db->address, dbus_db);
dbus_db->object_path = g_strdup_printf ("%s/%d",
DATABASE_OBJECT_PATH,
object_nr++);
@@ -577,4 +580,27 @@ gconf_database_dbus_notify_listeners (GConfDatabase *db,
gboolean is_default,
gboolean is_writable)
{
+ DBusMessage *signal;
+ GConfDatabaseDBus *dbus_db = NULL;
+
+ dbus_db = gconf_database_dbus_get (gconfd_dbus_get_connection (),
+ gconf_database_get_persistent_name (db),
+ NULL);
+
+ if (!dbus_db)
+ return;
+
+ signal = dbus_message_new_signal (dbus_db->object_path,
+ GCONF_DBUS_DATABASE_INTERFACE,
+ "Notify");
+
+ gconf_dbus_message_append_entry (signal,
+ key,
+ value,
+ is_default,
+ is_writable,
+ NULL);
+
+ dbus_connection_send (dbus_db->conn, signal, NULL);
+ dbus_message_unref (signal);
}
diff --git a/gconf/gconfd-dbus.c b/gconf/gconfd-dbus.c
index 77cebe59..f6175334 100644
--- a/gconf/gconfd-dbus.c
+++ b/gconf/gconfd-dbus.c
@@ -355,3 +355,9 @@ gconfd_dbus_check_in_shutdown (DBusConnection *connection,
return FALSE;
}
+DBusConnection *
+gconfd_dbus_get_connection (void)
+{
+ return bus_conn;
+}
+
diff --git a/gconf/gconfd-dbus.h b/gconf/gconfd-dbus.h
index 0133b6e4..fca0e76a 100644
--- a/gconf/gconfd-dbus.h
+++ b/gconf/gconfd-dbus.h
@@ -37,5 +37,6 @@ gboolean gconfd_dbus_set_exception (DBusConnection *connection,
GError **error);
gboolean gconfd_dbus_check_in_shutdown (DBusConnection *connection,
DBusMessage *message);
+DBusConnection *gconfd_dbus_get_connection (void);
#endif
diff --git a/gconf/gconfd.c b/gconf/gconfd.c
index dc903286..7df5286a 100644
--- a/gconf/gconfd.c
+++ b/gconf/gconfd.c
@@ -376,7 +376,6 @@ main(int argc, char** argv)
sigset_t empty_mask;
gchar* logname;
const gchar* username;
- guint len;
int exit_code = 0;
GError *err;
char *lock_dir;