[Galago-commits] r2691 - in trunk/galago-daemon: . src
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Sun Apr 9 23:17:15 PDT 2006
Author: chipx86
Date: 2006-04-09 23:17:11 -0700 (Sun, 09 Apr 2006)
New Revision: 2691
Modified:
trunk/galago-daemon/ChangeLog
trunk/galago-daemon/src/account.c
trunk/galago-daemon/src/galagod.c
trunk/galago-daemon/src/meta-account.c
trunk/galago-daemon/src/meta-person.c
trunk/galago-daemon/src/person.c
trunk/galago-daemon/src/utils.c
trunk/galago-daemon/src/utils.h
Log:
- Added basic attribute merging support.
- Added support for retrieving a list of remote attributes.
Modified: trunk/galago-daemon/ChangeLog
===================================================================
--- trunk/galago-daemon/ChangeLog 2006-04-10 06:07:44 UTC (rev 2690)
+++ trunk/galago-daemon/ChangeLog 2006-04-10 06:17:11 UTC (rev 2691)
@@ -1,3 +1,15 @@
+Sun Apr 09 23:16:42 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * src/account.c:
+ * src/galagod.c:
+ * src/meta-account.c:
+ * src/meta-person.c:
+ * src/person.c:
+ * src/utils.c:
+ * src/utils.h:
+ - Added basic attribute merging support.
+ - Added support for retrieving a list of remote attributes.
+
Wed Mar 29 22:13:53 PST 2006 Christian Hammond <chipx86 at chipx86.com>
* src/account.c:
Modified: trunk/galago-daemon/src/account.c
===================================================================
--- trunk/galago-daemon/src/account.c 2006-04-10 06:07:44 UTC (rev 2690)
+++ trunk/galago-daemon/src/account.c 2006-04-10 06:17:11 UTC (rev 2691)
@@ -96,6 +96,7 @@
return common_object_set_attribute(dbus_conn, message,
GALAGO_DBUS_ACCOUNT_INTERFACE,
+ GALAGO_OBJECT(account),
GALAGO_OBJECT(main_account));
}
@@ -108,6 +109,7 @@
return common_object_remove_attribute(dbus_conn, message,
GALAGO_DBUS_ACCOUNT_INTERFACE,
+ GALAGO_OBJECT(account),
GALAGO_OBJECT(main_account));
}
@@ -123,6 +125,17 @@
}
static DBusHandlerResult
+account_get_attributes(DBusConnection *dbus_conn, DBusMessage *message,
+ GalagodCoCo *coco, GalagoAccount *account)
+{
+ GalagoAccount *main_account =
+ galagod_meta_account_get_account(GALAGOD_META_ACCOUNT(account));
+
+ return common_object_get_attributes(dbus_conn, message,
+ GALAGO_OBJECT(main_account));
+}
+
+static DBusHandlerResult
account_set_connected(DBusConnection *dbus_conn, DBusMessage *message,
GalagodCoCo *coco, GalagoAccount *account)
{
@@ -562,6 +575,7 @@
GALAGOD_COMMAND("SetAttribute", account_set_attribute),
GALAGOD_COMMAND("RemoveAttribute", account_remove_attribute),
GALAGOD_COMMAND("GetAttribute", account_get_attribute),
+ GALAGOD_COMMAND("GetAttributes", account_get_attributes),
GALAGOD_COMMAND("SetConnected", account_set_connected),
GALAGOD_COMMAND("AddContact", account_add_contact),
GALAGOD_COMMAND("RemoveContact", account_remove_contact),
Modified: trunk/galago-daemon/src/galagod.c
===================================================================
--- trunk/galago-daemon/src/galagod.c 2006-04-10 06:07:44 UTC (rev 2690)
+++ trunk/galago-daemon/src/galagod.c 2006-04-10 06:17:11 UTC (rev 2691)
@@ -133,7 +133,7 @@
loop = g_main_loop_new(NULL, FALSE);
- if (!galago_init(GALAGO_DAEMON_ID, FALSE))
+ if (!galago_init(GALAGO_DAEMON_ID, GALAGO_INIT_CLIENT))
{
g_critical("Unable to initialize Galago");
exit(1);
Modified: trunk/galago-daemon/src/meta-account.c
===================================================================
--- trunk/galago-daemon/src/meta-account.c 2006-04-10 06:07:44 UTC (rev 2690)
+++ trunk/galago-daemon/src/meta-account.c 2006-04-10 06:17:11 UTC (rev 2691)
@@ -133,8 +133,7 @@
g_return_if_fail(meta_account != NULL);
g_return_if_fail(account != NULL);
- meta_account->accounts = g_list_append(meta_account->accounts,
- account);
+ meta_account->accounts = g_list_append(meta_account->accounts, account);
g_object_set_data(G_OBJECT(account), "meta-account", meta_account);
@@ -144,6 +143,10 @@
galago_account_get_display_name(account));
}
+ common_meta_object_merge_attributes(GALAGO_OBJECT(meta_account->account),
+ GALAGO_OBJECT(account),
+ meta_account->accounts);
+
galagod_account_add_filter(account);
}
Modified: trunk/galago-daemon/src/meta-person.c
===================================================================
--- trunk/galago-daemon/src/meta-person.c 2006-04-10 06:07:44 UTC (rev 2690)
+++ trunk/galago-daemon/src/meta-person.c 2006-04-10 06:17:11 UTC (rev 2691)
@@ -169,6 +169,10 @@
meta_person);
}
+ common_meta_object_merge_attributes(GALAGO_OBJECT(meta_person->person),
+ GALAGO_OBJECT(person),
+ meta_person->people);
+
galagod_person_add_filter(person);
}
Modified: trunk/galago-daemon/src/person.c
===================================================================
--- trunk/galago-daemon/src/person.c 2006-04-10 06:07:44 UTC (rev 2690)
+++ trunk/galago-daemon/src/person.c 2006-04-10 06:17:11 UTC (rev 2691)
@@ -84,6 +84,7 @@
return common_object_set_attribute(dbus_conn, message,
GALAGO_DBUS_PERSON_INTERFACE,
+ GALAGO_OBJECT(person),
GALAGO_OBJECT(main_person));
}
@@ -96,6 +97,7 @@
return common_object_remove_attribute(dbus_conn, message,
GALAGO_DBUS_PERSON_INTERFACE,
+ GALAGO_OBJECT(person),
GALAGO_OBJECT(main_person));
}
@@ -111,6 +113,17 @@
}
static DBusHandlerResult
+person_get_attributes(DBusConnection *dbus_conn, DBusMessage *message,
+ GalagodCoCo *coco, GalagoPerson *person)
+{
+ GalagoPerson *main_person =
+ galagod_meta_person_get_person(GALAGOD_META_PERSON(person));
+
+ return common_object_get_attributes(dbus_conn, message,
+ GALAGO_OBJECT(main_person));
+}
+
+static DBusHandlerResult
person_get_account(DBusConnection *dbus_conn, DBusMessage *message,
GalagodCoCo *coco, GalagoPerson *person)
{
@@ -311,6 +324,7 @@
GALAGOD_COMMAND("SetAttribute", person_set_attribute),
GALAGOD_COMMAND("RemoveAttribute", person_remove_attribute),
GALAGOD_COMMAND("GetAttribute", person_get_attribute),
+ GALAGOD_COMMAND("GetAttributes", person_get_attributes),
GALAGOD_COMMAND("GetAccount", person_get_account),
GALAGOD_COMMAND("GetAccounts", person_get_accounts),
GALAGOD_COMMAND("GetAccountsCount", person_get_accounts_count),
Modified: trunk/galago-daemon/src/utils.c
===================================================================
--- trunk/galago-daemon/src/utils.c 2006-04-10 06:07:44 UTC (rev 2690)
+++ trunk/galago-daemon/src/utils.c 2006-04-10 06:17:11 UTC (rev 2691)
@@ -1,4 +1,3 @@
-
/**
* @file utils.c Utility functions
*
@@ -109,7 +108,8 @@
common_object_set_attribute(DBusConnection *dbus_conn,
DBusMessage *message,
const char *iface,
- GalagoObject *object)
+ GalagoObject *object,
+ GalagoObject *main_object)
{
DBusMessage *signal;
DBusMessageIter iter, value_iter;
@@ -120,7 +120,7 @@
dbus_message_iter_init(message, &iter);
- signal = dbus_message_new_signal(galago_object_get_dbus_path(object),
+ signal = dbus_message_new_signal(galago_object_get_dbus_path(main_object),
iface, "AttributeSet");
dbus_message_iter_init_append(signal, &signal_iter);
@@ -138,6 +138,7 @@
const char *value;
dbus_message_iter_get_basic(&value_iter, &value);
galago_object_set_attr_string(object, name, value);
+ galago_object_set_attr_string(main_object, name, value);
dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_VARIANT,
DBUS_TYPE_STRING_AS_STRING,
&signal_value_iter);
@@ -153,6 +154,7 @@
gboolean value;
dbus_message_iter_get_basic(&value_iter, &value);
galago_object_set_attr_bool(object, name, value);
+ galago_object_set_attr_bool(main_object, name, value);
dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_VARIANT,
DBUS_TYPE_BOOLEAN_AS_STRING,
&signal_value_iter);
@@ -168,6 +170,7 @@
dbus_uint32_t value;
dbus_message_iter_get_basic(&value_iter, &value);
galago_object_set_attr_int(object, name, value);
+ galago_object_set_attr_int(main_object, name, value);
dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_VARIANT,
DBUS_TYPE_UINT32_AS_STRING,
&signal_value_iter);
@@ -199,7 +202,8 @@
common_object_remove_attribute(DBusConnection *dbus_conn,
DBusMessage *message,
const char *iface,
- GalagoObject *object)
+ GalagoObject *object,
+ GalagoObject *main_object)
{
DBusMessage *signal;
DBusMessageIter iter;
@@ -208,11 +212,12 @@
dbus_message_iter_init(message, &iter);
dbus_message_iter_get_basic(&iter, &name);
galago_object_remove_attribute(object, name);
+ galago_object_remove_attribute(main_object, name);
galagod_dbus_send_empty_reply(dbus_conn, message);
/* Emit the signal */
- signal = dbus_message_new_signal(galago_object_get_dbus_path(object),
+ signal = dbus_message_new_signal(galago_object_get_dbus_path(main_object),
iface, "AttributeUnset");
dbus_message_iter_init_append(signal, &iter);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name);
@@ -295,3 +300,109 @@
return DBUS_HANDLER_RESULT_HANDLED;
}
+
+DBusHandlerResult
+common_object_get_attributes(DBusConnection *dbus_conn,
+ DBusMessage *message,
+ GalagoObject *object)
+{
+ DBusMessageIter iter, array_iter, struct_iter, value_iter;
+ DBusMessage *reply;
+ GList *l;
+
+ reply = dbus_message_new_method_return(message);
+ dbus_message_iter_init_append(reply, &iter);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING,
+ &array_iter);
+
+ for (l = galago_object_get_attributes(object); l != NULL; l = l->next)
+ {
+ GalagoKeyValue *key_value = (GalagoKeyValue *)l->data;
+
+ dbus_message_iter_open_container(&array_iter, DBUS_TYPE_STRUCT, NULL,
+ &struct_iter);
+
+ dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_STRING,
+ &key_value->key);
+
+ if (G_VALUE_HOLDS(key_value->value, G_TYPE_STRING))
+ {
+ const char *str = g_value_get_string(key_value->value);
+ dbus_message_iter_open_container(&struct_iter, DBUS_TYPE_VARIANT,
+ DBUS_TYPE_STRING_AS_STRING,
+ &value_iter);
+ dbus_message_iter_append_basic(&value_iter,
+ DBUS_TYPE_STRING, &str);
+ dbus_message_iter_close_container(&struct_iter, &value_iter);
+ }
+ else if (G_VALUE_HOLDS(key_value->value, G_TYPE_BOOLEAN))
+ {
+ gboolean b = g_value_get_boolean(key_value->value);
+ dbus_message_iter_open_container(&struct_iter, DBUS_TYPE_VARIANT,
+ DBUS_TYPE_BOOLEAN_AS_STRING,
+ &value_iter);
+ dbus_message_iter_append_basic(&value_iter,
+ DBUS_TYPE_BOOLEAN, &b);
+ dbus_message_iter_close_container(&struct_iter, &value_iter);
+ }
+ else if (G_VALUE_HOLDS(key_value->value, G_TYPE_INT))
+ {
+ dbus_uint32_t i = g_value_get_int(key_value->value);
+ dbus_message_iter_open_container(&struct_iter, DBUS_TYPE_VARIANT,
+ DBUS_TYPE_UINT32_AS_STRING,
+ &value_iter);
+ dbus_message_iter_append_basic(&value_iter,
+ DBUS_TYPE_UINT32, &i);
+ dbus_message_iter_close_container(&struct_iter, &value_iter);
+ }
+ else
+ {
+ /* This should never happen. */
+ g_warning("Unknown property type %s for property %s",
+ G_VALUE_TYPE_NAME(key_value->value), key_value->key);
+ }
+
+ dbus_message_iter_close_container(&array_iter, &struct_iter);
+ }
+
+ dbus_message_iter_close_container(&iter, &array_iter);
+
+ dbus_connection_send(dbus_conn, reply, NULL);
+ dbus_message_unref(reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+void
+common_meta_object_merge_attributes(GalagoObject *main_object,
+ GalagoObject *new_object,
+ GList *objects)
+{
+ GList *l;
+
+ /*
+ * TODO: This logic needs to be improved! We need to actually determine
+ * if there's a consensus on attribute values. For now, though,
+ * we're going to be cheap and just copy over attributes.
+ */
+
+ for (l = galago_object_get_attributes(new_object); l != NULL; l = l->next)
+ {
+ GalagoKeyValue *key_value = (GalagoKeyValue *)l->data;
+ GValue *new_value;
+
+ if (!strcmp(key_value->key, "uid"))
+ continue;
+
+ new_value = g_new0(GValue, 1);
+ g_value_init(new_value, G_VALUE_TYPE(key_value->value));
+ g_value_copy(key_value->value, new_value);
+
+ galago_object_set_attribute(main_object, key_value->key, new_value);
+ }
+}
Modified: trunk/galago-daemon/src/utils.h
===================================================================
--- trunk/galago-daemon/src/utils.h 2006-04-10 06:07:44 UTC (rev 2690)
+++ trunk/galago-daemon/src/utils.h 2006-04-10 06:17:11 UTC (rev 2691)
@@ -45,13 +45,22 @@
DBusHandlerResult common_object_set_attribute(DBusConnection *dbus_conn,
DBusMessage *message,
const char *iface,
- GalagoObject *object);
+ GalagoObject *object,
+ GalagoObject *main_object);
DBusHandlerResult common_object_remove_attribute(DBusConnection *dbus_conn,
DBusMessage *message,
const char *iface,
- GalagoObject *object);
+ GalagoObject *object,
+ GalagoObject *main_object);
DBusHandlerResult common_object_get_attribute(DBusConnection *dbus_conn,
DBusMessage *message,
GalagoObject *object);
+DBusHandlerResult common_object_get_attributes(DBusConnection *dbus_conn,
+ DBusMessage *message,
+ GalagoObject *object);
+void common_meta_object_merge_attributes(GalagoObject *main_object,
+ GalagoObject *new_object,
+ GList *objects);
+
#endif /* _GALAGOD_UTILS_H_ */
More information about the galago-commits
mailing list