From 0ccef79d7e9d1b19cdb10b3a147b64b41686905d Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sat, 9 Jul 2005 01:46:51 +0000 Subject: 2005-07-08 Colin Walters * test/glib/test-service-glib.xml: * test/glib/test-service-glib.c: * test/glib/test-dbus-glib.c: Test a{sv}. * glib/examples/statemachine/statemachine.c: * glib/examples/statemachine/statemachine-server.c: * glib/examples/statemachine/statemachine-client.c: Fix some bugs, add progress bar, etc. * glib/dbus-gvalue.c (register_array, register_dict): Delete; not needed anymore due to generic array/map marshalling. (dbus_g_value_types_init): Don't register basic arrays or the string/string hash. (dbus_gtype_from_signature_iter): Don't try to recurse into variants. (dbus_gtype_to_signature): Check collection/map before type metadata. (demarshal_garray_basic): Renamed to demarshal_collection_array. (demarshal_ghashtable): Renamed to demarshal_map; fix to use new generic map creation/append functions instead of hash table specifically. (get_type_demarshaller): Handle maps. (demarshal_collection): Dispatch on collection type to either demarshal_collection_ptrarray or demarshal_collection_array. (get_type_marshaller): Handle maps. (marshal_collection): Dispatch collection type to either marshal_collection_ptrarray or marshal_collection_array. (_dbus_gvalue_test): New test. * glib/dbus-gvalue-utils.c (unset_and_free_g_value): New function. (hash_free_from_gtype): Use it to free GValues. (hashtable_append): New function. (ptrarray_append): Fix prototype. (slist_append): Ditto. (_dbus_gvalue_utils_test): Extend tests. * glib/dbus-gtype-specialized.c (dbus_g_type_specialized_init_append): Renamed from dbus_g_type_specialized_collection_init_append. Remove const from value, since we steal it. (dbus_g_type_specialized_map_append): New function. * glib/dbus-gtype-specialized.h: Update prototypes. Add DBusGTypeSpecializedMapAppendFunc. * glib/dbus-gtest.c (dbus_glib_internal_do_not_use_run_tests): Run _dbus_gvalue_test. * glib/dbus-gtest.h: Prototype it. --- glib/examples/statemachine/statemachine.c | 44 ++++++++++++++++--------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'glib/examples/statemachine/statemachine.c') diff --git a/glib/examples/statemachine/statemachine.c b/glib/examples/statemachine/statemachine.c index 2bde0058..c94e2945 100644 --- a/glib/examples/statemachine/statemachine.c +++ b/glib/examples/statemachine/statemachine.c @@ -103,8 +103,8 @@ sm_object_state_get_type (void) ENUM_ENTRY (SM_OBJECT_STATE_SHUTDOWN, "Shutdown"), ENUM_ENTRY (SM_OBJECT_STATE_INITIALIZED, "Loading"), - ENUM_ENTRY (SM_OBJECT_STATE_ACQUIRED, "Resource acquired"), - ENUM_ENTRY (SM_OBJECT_STATE_OPERATING, "Operating normally"), + ENUM_ENTRY (SM_OBJECT_STATE_ACQUIRED, "Acquired"), + ENUM_ENTRY (SM_OBJECT_STATE_OPERATING, "Operating"), { 0, 0, 0 } }; @@ -175,6 +175,21 @@ sm_object_get_property (GObject *object, } } +static const char * +state_to_string (SMObjectState state) +{ + GEnumValue *value; + GEnumClass *prop_class; + const char *ret; + + prop_class = g_type_class_ref (SM_TYPE_OBJECT_STATE); + value = g_enum_get_value (prop_class, state); + ret = value->value_nick; + + g_type_class_unref (prop_class); + return ret; +} + static void queue_task (SMObject *object, guint delay, GSourceFunc func) { @@ -188,6 +203,8 @@ idle_state_change (gpointer data) { SMObject *object = data; + g_print ("doing idle state change for %s to %s\n", + object->name, state_to_string (object->requested_state)); state_change (object, object->requested_state); return FALSE; } @@ -197,7 +214,8 @@ idle_further_acquire (gpointer data) { SMObject *object = data; - object->acquisition_progress += g_random_double_range (0.05, 0.5); + g_print ("doing idle acquisition for machine %s\n", object->name); + object->acquisition_progress += g_random_double_range (0.20, 0.7); if (object->acquisition_progress > 1.0) { object->acquisition_progress = 1.0; @@ -220,26 +238,10 @@ clear_pending_tasks (SMObject *object) object->pending_tasks = NULL; } -static const char * -state_to_string (SMObjectState state) -{ - GEnumValue *value; - GEnumClass *prop_class; - const char *ret; - - prop_class = g_type_class_ref (SM_TYPE_OBJECT_STATE); - value = g_enum_get_value (prop_class, state); - ret = value->value_nick; - - g_type_class_unref (prop_class); - return ret; -} - static void state_change (SMObject *object, SMObjectState new_state) { g_signal_emit (object, sm_object_signals[STATE_CHANGED], 0, - state_to_string (object->state), state_to_string (new_state)); clear_pending_tasks (object); @@ -288,7 +290,7 @@ sm_object_start (SMObject *object, GError **error) gboolean sm_object_shutdown (SMObject *object, GError **error) { - if (object->state != SM_OBJECT_STATE_INITIALIZED) + if (object->state == SM_OBJECT_STATE_SHUTDOWN) { g_set_error (error, SM_ERROR, @@ -321,7 +323,7 @@ sm_object_reinitialize (SMObject *object, GError **error) gboolean sm_object_reacquire (SMObject *object, GError **error) { - if (object->state != SM_OBJECT_STATE_ACQUIRED) + if (object->state == SM_OBJECT_STATE_ACQUIRED) { g_set_error (error, SM_ERROR, -- cgit