summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@x61.localdomain>2008-12-19 21:18:25 -0500
committerDavid Zeuthen <davidz@x61.localdomain>2008-12-19 21:18:25 -0500
commitfd3762284a58a7b102c65b6f53efd98f382cfb04 (patch)
tree570b966ef14149f119513111a6f95712e3407e1e
parentc25ac004efb9eeb79c596c2f2e68a12beac88354 (diff)
first stab at refactoring EggDBus to use new collection classes
-rw-r--r--docs/eggdbus/eggdbus-sections.txt81
-rw-r--r--src/eggdbus/Makefile.am10
-rw-r--r--src/eggdbus/eggdbus.h8
-rw-r--r--src/eggdbus/eggdbusarray.c166
-rw-r--r--src/eggdbus/eggdbusarray.h47
-rw-r--r--src/eggdbus/eggdbusarrayseq.c89
-rw-r--r--src/eggdbus/eggdbusbindingtool.c50
-rw-r--r--src/eggdbus/eggdbusconnection.c40
-rw-r--r--src/eggdbus/eggdbushashtable.c297
-rw-r--r--src/eggdbus/eggdbushashtable.h58
-rw-r--r--src/eggdbus/eggdbusinterfaceproxy.c59
-rw-r--r--src/eggdbus/eggdbuslist.c300
-rw-r--r--src/eggdbus/eggdbuslist.h46
-rw-r--r--src/eggdbus/eggdbusmessage.c520
-rw-r--r--src/eggdbus/eggdbusmessage.h27
-rw-r--r--src/eggdbus/eggdbusobjectproxy.c8
-rw-r--r--src/eggdbus/eggdbusprivate.h2
-rw-r--r--src/eggdbus/eggdbusstructure.c10
-rw-r--r--src/eggdbus/eggdbustypes.c3
-rw-r--r--src/eggdbus/eggdbustypes.h6
-rw-r--r--src/eggdbus/eggdbusutils.c19
-rw-r--r--src/eggdbus/eggdbusutils.h2
-rw-r--r--src/eggdbus/eggdbusvariant.c223
-rw-r--r--src/eggdbus/eggdbusvariant.h66
-rw-r--r--src/eggdbus/interface.c33
-rw-r--r--src/tests/testclient.c70
-rw-r--r--src/tests/testfrobimpl.c171
-rw-r--r--src/tests/testsubject.c43
-rw-r--r--src/tests/testtweakimpl.c14
-rw-r--r--src/tests/testtwiddleimpl.c16
30 files changed, 660 insertions, 1824 deletions
diff --git a/docs/eggdbus/eggdbus-sections.txt b/docs/eggdbus/eggdbus-sections.txt
index ef9dbab..0c308f8 100644
--- a/docs/eggdbus/eggdbus-sections.txt
+++ b/docs/eggdbus/eggdbus-sections.txt
@@ -2,11 +2,11 @@
<FILE>eggdbusvariant</FILE>
<TITLE>EggDBusVariant</TITLE>
EggDBusVariant
-egg_dbus_variant_get_variant_signature
egg_dbus_variant_print
egg_dbus_variant_new
egg_dbus_variant_new_for_gvalue
egg_dbus_variant_get_gvalue
+egg_dbus_variant_get_variant_signature
egg_dbus_variant_new_for_string
egg_dbus_variant_new_for_object_path
egg_dbus_variant_new_for_signature
@@ -22,9 +22,8 @@ egg_dbus_variant_new_for_int64
egg_dbus_variant_new_for_uint64
egg_dbus_variant_new_for_boolean
egg_dbus_variant_new_for_double
-egg_dbus_variant_new_for_array
-egg_dbus_variant_new_for_list
-egg_dbus_variant_new_for_hash_table
+egg_dbus_variant_new_for_seq
+egg_dbus_variant_new_for_map
egg_dbus_variant_new_for_structure
egg_dbus_variant_set_string
egg_dbus_variant_set_object_path
@@ -41,9 +40,8 @@ egg_dbus_variant_set_int64
egg_dbus_variant_set_uint64
egg_dbus_variant_set_boolean
egg_dbus_variant_set_double
-egg_dbus_variant_set_array
-egg_dbus_variant_set_list
-egg_dbus_variant_set_hash_table
+egg_dbus_variant_set_seq
+egg_dbus_variant_set_map
egg_dbus_variant_set_structure
egg_dbus_variant_get_string
egg_dbus_variant_get_object_path
@@ -60,9 +58,8 @@ egg_dbus_variant_get_int64
egg_dbus_variant_get_uint64
egg_dbus_variant_get_boolean
egg_dbus_variant_get_double
-egg_dbus_variant_get_array
-egg_dbus_variant_get_list
-egg_dbus_variant_get_hash_table
+egg_dbus_variant_get_seq
+egg_dbus_variant_get_map
egg_dbus_variant_get_structure
egg_dbus_variant_is_unset
egg_dbus_variant_is_string
@@ -80,16 +77,9 @@ egg_dbus_variant_is_int64
egg_dbus_variant_is_uint64
egg_dbus_variant_is_boolean
egg_dbus_variant_is_double
-egg_dbus_variant_is_array
-egg_dbus_variant_is_list
-egg_dbus_variant_is_hash_table
+egg_dbus_variant_is_seq
+egg_dbus_variant_is_map
egg_dbus_variant_is_structure
-egg_dbus_variant_new_for_array_with_signature
-egg_dbus_variant_new_for_list_with_signature
-egg_dbus_variant_new_for_hash_table_with_signature
-egg_dbus_variant_set_array_with_signature
-egg_dbus_variant_set_list_with_signature
-egg_dbus_variant_set_hash_table_with_signature
<SUBSECTION Standard>
EGG_DBUS_VARIANT
EGG_DBUS_IS_VARIANT
@@ -269,9 +259,8 @@ egg_dbus_message_append_int64
egg_dbus_message_append_uint64
egg_dbus_message_append_boolean
egg_dbus_message_append_double
-egg_dbus_message_append_array
-egg_dbus_message_append_list
-egg_dbus_message_append_hash_table
+egg_dbus_message_append_seq
+egg_dbus_message_append_map
egg_dbus_message_append_structure
egg_dbus_message_append_variant
egg_dbus_message_append_gvalue
@@ -290,9 +279,8 @@ egg_dbus_message_extract_int64
egg_dbus_message_extract_uint64
egg_dbus_message_extract_boolean
egg_dbus_message_extract_double
-egg_dbus_message_extract_array
-egg_dbus_message_extract_list
-egg_dbus_message_extract_hash_table
+egg_dbus_message_extract_seq
+egg_dbus_message_extract_map
egg_dbus_message_extract_structure
egg_dbus_message_extract_variant
egg_dbus_message_extract_gvalue
@@ -640,9 +628,6 @@ EggDBusStartServiceByNameReply
<SECTION>
<FILE>eggdbustypes</FILE>
-EggDBusArray
-EggDBusList
-EggDBusHashTable
EggDBusConnection
EggDBusObjectProxy
EggDBusInterfaceProxy
@@ -719,35 +704,6 @@ egg_dbus_signature_array_get_type
</SECTION>
<SECTION>
-<FILE>eggdbusarray</FILE>
-EGG_DBUS_TYPE_ARRAY
-egg_dbus_array_get_type
-egg_dbus_array_get_elem_signature
-egg_dbus_array_set_elem_signature
-egg_dbus_array_free
-egg_dbus_array_copy
-egg_dbus_array_print
-</SECTION>
-
-<SECTION>
-<FILE>eggdbushashtable</FILE>
-EGG_DBUS_TYPE_HASH_TABLE
-egg_dbus_hash_table_get_type
-egg_dbus_hash_table_get_key_signature
-egg_dbus_hash_table_get_value_signature
-egg_dbus_hash_table_set_signature
-egg_dbus_hash_table_ref
-egg_dbus_hash_table_unref
-egg_dbus_hash_table_print
-egg_dbus_int64_hash
-egg_dbus_int64_equal
-egg_dbus_uint64_hash
-egg_dbus_uint64_equal
-egg_dbus_double_hash
-egg_dbus_double_equal
-</SECTION>
-
-<SECTION>
<FILE>eggdbusobjectpath</FILE>
EGG_DBUS_TYPE_OBJECT_PATH
EGG_DBUS_TYPE_OBJECT_PATH_ARRAY
@@ -783,17 +739,6 @@ eggdbus_marshal_VOID__STRING_STRING
</SECTION>
<SECTION>
-<FILE>eggdbuslist</FILE>
-EGG_DBUS_TYPE_LIST
-egg_dbus_list_get_type
-egg_dbus_list_get_elem_signature
-egg_dbus_list_set_elem_signature
-egg_dbus_list_free
-egg_dbus_list_copy
-egg_dbus_list_print
-</SECTION>
-
-<SECTION>
<FILE>eggdbusutils</FILE>
egg_dbus_utils_camel_case_to_uscore
egg_dbus_utils_camel_case_to_hyphen
diff --git a/src/eggdbus/Makefile.am b/src/eggdbus/Makefile.am
index 7302b0f..40bd751 100644
--- a/src/eggdbus/Makefile.am
+++ b/src/eggdbus/Makefile.am
@@ -27,10 +27,9 @@ noinst_LTLIBRARIES = libeggdbus-common.la
libeggdbus_common_la_SOURCES = \
eggdbus.h \
eggdbusprivate.h \
- eggdbusarray.h eggdbusarray.c \
+ eggdbusarrayseq.h eggdbusarrayseq.c \
+ eggdbushashmap.h eggdbushashmap.c \
eggdbuserror.h eggdbuserror.c \
- eggdbushashtable.h eggdbushashtable.c \
- eggdbuslist.h eggdbuslist.c \
eggdbusmisctypes.h eggdbusmisctypes.c \
eggdbuobjectpath.h eggdbusobjectpath.c \
eggdbussignature.h eggdbussignature.c \
@@ -101,12 +100,9 @@ eggdbus_binding_tool_LDADD = \
eggdbus_headers = \
eggdbus.h \
- eggdbusarray.h \
eggdbusarrayseq.h \
eggdbushashmap.h \
eggdbuserror.h \
- eggdbushashtable.h \
- eggdbuslist.h \
eggdbusmessage.h \
eggdbusobjectproxy.h \
eggdbusinterfaceproxy.h \
@@ -208,8 +204,6 @@ libeggdbus_1include_HEADERS = \
libeggdbus_1_la_SOURCES = \
$(EGG_DBUS_BUILT_SOURCES) \
- eggdbusarrayseq.h eggdbusarrayseq.c \
- eggdbushashmap.h eggdbushashmap.c \
eggdbusconnection.h eggdbusconnection.c \
eggdbusmessage.h eggdbusmessage.c \
eggdbusobjectproxy.h eggdbusobjectproxy.c \
diff --git a/src/eggdbus/eggdbus.h b/src/eggdbus/eggdbus.h
index 39e36c4..1ea3d9e 100644
--- a/src/eggdbus/eggdbus.h
+++ b/src/eggdbus/eggdbus.h
@@ -31,16 +31,12 @@
#include <eggdbus/eggdbusutils.h>
#include <eggdbus/eggdbuserror.h>
-#include <eggdbus/eggdbusarray.h>
-#include <eggdbus/eggdbuslist.h>
-#include <eggdbus/eggdbushashtable.h>
+#include <eggdbus/eggdbusarrayseq.h>
+#include <eggdbus/eggdbushashmap.h>
#include <eggdbus/eggdbusstructure.h>
#include <eggdbus/eggdbusvariant.h>
#include <eggdbus/eggdbusinterface.h>
-#include <eggdbus/eggdbusarrayseq.h>
-#include <eggdbus/eggdbushashmap.h>
-
#include <eggdbus/eggdbusconnection.h>
#include <eggdbus/eggdbusmessage.h>
#include <eggdbus/eggdbusobjectproxy.h>
diff --git a/src/eggdbus/eggdbusarray.c b/src/eggdbus/eggdbusarray.c
deleted file mode 100644
index a624578..0000000
--- a/src/eggdbus/eggdbusarray.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2008 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- *
- * Author: David Zeuthen <davidz@redhat.com>
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <string.h>
-#include <dbus/dbus.h>
-#include <eggdbus/eggdbusarray.h>
-#include <eggdbus/eggdbusprivate.h>
-
-GArray *
-_egg_dbus_array_copy_without_signature_copy (GArray *array)
-{
- /* Copied from glib source until we have g_array_copy() or similar */
- typedef struct
- {
- guint8 *data;
- guint len;
- guint alloc;
- guint elt_size;
- guint zero_terminated : 1;
- guint clear : 1;
- } GRealArray;
- GRealArray *real_array;
- GRealArray *new_array;
-
- real_array = (GRealArray *) array;
- new_array = g_slice_new (GRealArray);
- *new_array = *real_array;
- new_array->data = g_memdup (real_array->data, real_array->alloc);
-
- return (EggDBusArray *) new_array;
-}
-
-EggDBusArray *
-egg_dbus_array_copy (EggDBusArray *array)
-{
- GArray *new_array;
- new_array = _egg_dbus_array_copy_without_signature_copy (array);
- egg_dbus_array_set_elem_signature ((EggDBusArray *) new_array, egg_dbus_array_get_elem_signature (array));
- return new_array;
-}
-
-void
-egg_dbus_array_free (EggDBusArray *array)
-{
- egg_dbus_array_set_elem_signature (array, NULL);
- g_array_free (array, TRUE);
-}
-
-
-GType
-egg_dbus_array_get_type (void)
-{
- static GType g_array_type = 0;
-
- if (g_array_type != 0)
- return g_array_type;
-
- if (g_array_type == 0)
- {
- g_array_type = g_boxed_type_register_static ("EggDBusArray",
- (GBoxedCopyFunc) egg_dbus_array_copy,
- (GBoxedFreeFunc) egg_dbus_array_free);
- }
-
- return g_array_type;
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-const gchar *
-egg_dbus_array_get_elem_signature (EggDBusArray *array)
-{
- return _get_element_signature (array, "EggDBusArray");
-}
-
-void
-egg_dbus_array_set_elem_signature (GArray *array,
- const gchar *elem_signature)
-{
- _set_element_signature (array, elem_signature, "EggDBusArray");
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-void
-egg_dbus_array_print (EggDBusArray *array,
- guint indent)
-{
- guint n;
- const gchar *elem_signature;
-
- elem_signature = egg_dbus_array_get_elem_signature (array);
-
- if (elem_signature == NULL)
- return;
-
- g_print ("[");
- for (n = 0; n < array->len; n++)
- {
- if (n != 0)
- g_print (", ");
- switch (elem_signature[0])
- {
- case DBUS_TYPE_BYTE:
- g_print ("0x%02x", g_array_index (array, guint8, n));
- break;
-
- case DBUS_TYPE_INT16:
- g_print ("%" G_GINT16_FORMAT, g_array_index (array, gint16, n));
- break;
-
- case DBUS_TYPE_UINT16:
- g_print ("%" G_GUINT16_FORMAT, g_array_index (array, guint16, n));
- break;
-
- case DBUS_TYPE_INT32:
- g_print ("%" G_GINT32_FORMAT, g_array_index (array, gint32, n));
- break;
-
- case DBUS_TYPE_UINT32:
- g_print ("%" G_GUINT32_FORMAT, g_array_index (array, guint32, n));
- break;
-
- case DBUS_TYPE_INT64:
- g_print ("%" G_GINT64_FORMAT, g_array_index (array, gint64, n));
- break;
-
- case DBUS_TYPE_UINT64:
- g_print ("%" G_GUINT64_FORMAT, g_array_index (array, guint64, n));
- break;
-
- case DBUS_TYPE_DOUBLE:
- g_print ("%g", g_array_index (array, gdouble, n));
- break;
-
- case DBUS_TYPE_BOOLEAN:
- g_print ("%s", g_array_index (array, gboolean, n) ? "True" : "False");
- break;
-
- default:
- g_assert_not_reached ();
- }
- }
- g_print ("]\n");
-}
-
diff --git a/src/eggdbus/eggdbusarray.h b/src/eggdbus/eggdbusarray.h
deleted file mode 100644
index 7614cfe..0000000
--- a/src/eggdbus/eggdbusarray.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2008 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- *
- * Author: David Zeuthen <davidz@redhat.com>
- */
-
-#if !defined (_EGG_DBUS_COMPILATION) && !defined(_EGG_DBUS_INSIDE_EGG_DBUS_H)
-#error "Only <eggdbus/eggdbus.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __EGG_DBUS_ARRAY_H
-#define __EGG_DBUS_ARRAY_H
-
-#include <eggdbus/eggdbustypes.h>
-
-G_BEGIN_DECLS
-
-#define EGG_DBUS_TYPE_ARRAY (egg_dbus_array_get_type ())
-
-GType egg_dbus_array_get_type (void) G_GNUC_CONST;
-const gchar *egg_dbus_array_get_elem_signature (EggDBusArray *array);
-void egg_dbus_array_set_elem_signature (GArray *array,
- const gchar *signature);
-void egg_dbus_array_free (EggDBusArray *array);
-EggDBusArray *egg_dbus_array_copy (EggDBusArray *array);
-void egg_dbus_array_print (EggDBusArray *array,
- guint indent);
-
-
-G_END_DECLS
-
-#endif /* __EGG_DBUS_ARRAY_H */
diff --git a/src/eggdbus/eggdbusarrayseq.c b/src/eggdbus/eggdbusarrayseq.c
index 2df4876..6ba0403 100644
--- a/src/eggdbus/eggdbusarrayseq.c
+++ b/src/eggdbus/eggdbusarrayseq.c
@@ -76,6 +76,9 @@ typedef struct
/* cached value to determine if it's a fixed size array */
gboolean element_type_is_fixed_size;
+
+ /* cached value for C convenience functions */
+ GType element_fundamental_type;
} EggDBusArraySeqPrivate;
#define EGG_DBUS_ARRAY_SEQ_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_DBUS_TYPE_ARRAY_SEQ, EggDBusArraySeqPrivate))
@@ -170,6 +173,33 @@ IMPL_EQUAL_FUNC (glong);
IMPL_EQUAL_FUNC (gfloat);
IMPL_EQUAL_FUNC (gint16);
+#if 0
+/* TODO: use this on G_TYPE_STRV and derived types */
+static gboolean
+_strv_equal (gchar **a, gchar **b)
+{
+ guint n;
+ guint len;
+
+ if (a == NULL && b == NULL)
+ return TRUE;
+ if (a == NULL || b == NULL)
+ return FALSE;
+
+ len = g_strv_length (a);
+ if (g_strv_length (b) != len)
+ return FALSE;
+
+ for (n = 0; n < len; n++)
+ {
+ if (strcmp (a[n], b[n]) != 0)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+#endif
+
/* ---------------------------------------------------------------------------------------------------- */
static void
@@ -298,7 +328,6 @@ egg_dbus_array_seq_new (GType element_type,
GBoxedCopyFunc copy_func,
GEqualFunc equal_func)
{
- GType fundamental_type;
EggDBusArraySeq *array_seq;
EggDBusArraySeqPrivate *priv;
gboolean not_supported;
@@ -314,10 +343,10 @@ egg_dbus_array_seq_new (GType element_type,
not_supported = FALSE;
- fundamental_type = G_TYPE_FUNDAMENTAL (array_seq->element_type);
+ priv->element_fundamental_type = G_TYPE_FUNDAMENTAL (array_seq->element_type);
/* first compute copy_func, free_func, element_size and equal_func */
- switch (fundamental_type)
+ switch (priv->element_fundamental_type)
{
case G_TYPE_OBJECT:
case G_TYPE_INTERFACE:
@@ -1050,8 +1079,11 @@ egg_dbus_array_seq_add_fixed (EggDBusArraySeq *array_seq,
guint16 v_int16;
guint v_int;
gulong v_long;
+ EggDBusArraySeqPrivate *priv;
- switch (array_seq->element_type)
+ priv = EGG_DBUS_ARRAY_SEQ_GET_PRIVATE (array_seq);
+
+ switch (priv->element_fundamental_type)
{
case G_TYPE_UCHAR:
case G_TYPE_CHAR:
@@ -1059,6 +1091,9 @@ egg_dbus_array_seq_add_fixed (EggDBusArraySeq *array_seq,
egg_dbus_array_seq_add (array_seq, &v_byte);
break;
+ case G_TYPE_BOOLEAN:
+ case G_TYPE_ENUM:
+ case G_TYPE_FLAGS:
case G_TYPE_INT:
case G_TYPE_UINT:
v_int = value;
@@ -1083,7 +1118,7 @@ egg_dbus_array_seq_add_fixed (EggDBusArraySeq *array_seq,
array_seq->element_type == EGG_DBUS_TYPE_UINT16)
{
v_int16 = value;
- egg_dbus_array_seq_add (array_seq, &v_byte);
+ egg_dbus_array_seq_add (array_seq, &v_int16);
}
else
{
@@ -1112,8 +1147,11 @@ egg_dbus_array_seq_add_float (EggDBusArraySeq *array_seq,
gdouble value)
{
gfloat v_float;
+ EggDBusArraySeqPrivate *priv;
- switch (array_seq->element_type)
+ priv = EGG_DBUS_ARRAY_SEQ_GET_PRIVATE (array_seq);
+
+ switch (priv->element_fundamental_type)
{
case G_TYPE_FLOAT:
v_float = value;
@@ -1152,8 +1190,11 @@ egg_dbus_array_seq_set_fixed (EggDBusArraySeq *array_seq,
guint16 v_int16;
guint v_int;
gulong v_long;
+ EggDBusArraySeqPrivate *priv;
- switch (array_seq->element_type)
+ priv = EGG_DBUS_ARRAY_SEQ_GET_PRIVATE (array_seq);
+
+ switch (priv->element_fundamental_type)
{
case G_TYPE_UCHAR:
case G_TYPE_CHAR:
@@ -1161,6 +1202,9 @@ egg_dbus_array_seq_set_fixed (EggDBusArraySeq *array_seq,
egg_dbus_array_seq_set (array_seq, index, &v_byte);
break;
+ case G_TYPE_BOOLEAN:
+ case G_TYPE_ENUM:
+ case G_TYPE_FLAGS:
case G_TYPE_INT:
case G_TYPE_UINT:
v_int = value;
@@ -1212,8 +1256,11 @@ egg_dbus_array_seq_set_float (EggDBusArraySeq *array_seq,
gdouble value)
{
gfloat v_float;
+ EggDBusArraySeqPrivate *priv;
- switch (array_seq->element_type)
+ priv = EGG_DBUS_ARRAY_SEQ_GET_PRIVATE (array_seq);
+
+ switch (priv->element_fundamental_type)
{
case G_TYPE_FLOAT:
v_float = value;
@@ -1251,8 +1298,11 @@ egg_dbus_array_seq_insert_fixed (EggDBusArraySeq *array_seq,
guint16 v_int16;
guint v_int;
gulong v_long;
+ EggDBusArraySeqPrivate *priv;
+
+ priv = EGG_DBUS_ARRAY_SEQ_GET_PRIVATE (array_seq);
- switch (array_seq->element_type)
+ switch (priv->element_fundamental_type)
{
case G_TYPE_UCHAR:
case G_TYPE_CHAR:
@@ -1260,6 +1310,9 @@ egg_dbus_array_seq_insert_fixed (EggDBusArraySeq *array_seq,
egg_dbus_array_seq_insert (array_seq, index, &v_byte);
break;
+ case G_TYPE_BOOLEAN:
+ case G_TYPE_ENUM:
+ case G_TYPE_FLAGS:
case G_TYPE_INT:
case G_TYPE_UINT:
v_int = value;
@@ -1312,8 +1365,11 @@ egg_dbus_array_seq_insert_float (EggDBusArraySeq *array_seq,
gdouble value)
{
gfloat v_float;
+ EggDBusArraySeqPrivate *priv;
+
+ priv = EGG_DBUS_ARRAY_SEQ_GET_PRIVATE (array_seq);
- switch (array_seq->element_type)
+ switch (priv->element_fundamental_type)
{
case G_TYPE_FLOAT:
v_float = value;
@@ -1349,16 +1405,22 @@ egg_dbus_array_seq_get_fixed (EggDBusArraySeq *array_seq,
{
gpointer elem;
guint64 val;
+ EggDBusArraySeqPrivate *priv;
+
+ priv = EGG_DBUS_ARRAY_SEQ_GET_PRIVATE (array_seq);
elem = egg_dbus_array_seq_get (array_seq, index);
- switch (array_seq->element_type)
+ switch (priv->element_fundamental_type)
{
case G_TYPE_UCHAR:
case G_TYPE_CHAR:
val = *((guchar *) elem);
break;
+ case G_TYPE_BOOLEAN:
+ case G_TYPE_ENUM:
+ case G_TYPE_FLAGS:
case G_TYPE_INT:
case G_TYPE_UINT:
val = *((gint *) elem);
@@ -1410,10 +1472,13 @@ egg_dbus_array_seq_get_float (EggDBusArraySeq *array_seq,
{
gpointer elem;
gdouble val;
+ EggDBusArraySeqPrivate *priv;
+
+ priv = EGG_DBUS_ARRAY_SEQ_GET_PRIVATE (array_seq);
elem = egg_dbus_array_seq_get (array_seq, index);
- switch (array_seq->element_type)
+ switch (priv->element_fundamental_type)
{
case G_TYPE_FLOAT:
val = *((gfloat *) elem);
diff --git a/src/eggdbus/eggdbusbindingtool.c b/src/eggdbus/eggdbusbindingtool.c
index 9aaeb27..55e45d8 100644
--- a/src/eggdbus/eggdbusbindingtool.c
+++ b/src/eggdbus/eggdbusbindingtool.c
@@ -524,12 +524,12 @@ get_type_names_for_signature (const gchar *signature,
if (signature[1] == DBUS_STRUCT_BEGIN_CHAR)
{
if (is_in)
- ret = g_strdup ("GList *");
+ ret = g_strdup ("EggDBusArraySeq *");
else
- ret = g_strdup ("EggDBusList *");
- free_function_name = "egg_dbus_list_free";
- gvalue_set_func_name = "g_value_set_boxed";
- gtype_name = g_strdup ("EGG_DBUS_TYPE_LIST");
+ ret = g_strdup ("EggDBusArraySeq *");
+ free_function_name = "g_object_unref";
+ gvalue_set_func_name = "g_value_set_object";
+ gtype_name = g_strdup ("EGG_DBUS_TYPE_ARRAY_SEQ");
}
else if (signature[1] == DBUS_TYPE_STRING)
{
@@ -563,42 +563,42 @@ get_type_names_for_signature (const gchar *signature,
signature[1] == DBUS_TYPE_BOOLEAN)
{
if (is_in)
- ret = g_strdup ("GArray *");
+ ret = g_strdup ("EggDBusArraySeq *");
else
- ret = g_strdup ("EggDBusArray *");
- free_function_name = "egg_dbus_array_free";
- gvalue_set_func_name = "g_value_set_boxed";
- gtype_name = g_strdup ("EGG_DBUS_TYPE_ARRAY");
+ ret = g_strdup ("EggDBusArraySeq *");
+ free_function_name = "g_object_unref";
+ gvalue_set_func_name = "g_value_set_object";
+ gtype_name = g_strdup ("EGG_DBUS_TYPE_ARRAY_SEQ");
}
else if (signature[1] == DBUS_DICT_ENTRY_BEGIN_CHAR)
{
if (is_in)
- ret = g_strdup ("GHashTable *");
+ ret = g_strdup ("EggDBusHashMap *");
else
- ret = g_strdup ("EggDBusHashTable *");
- free_function_name = "egg_dbus_hash_table_unref";
- gvalue_set_func_name = "g_value_set_boxed";
- gtype_name = g_strdup ("EGG_DBUS_TYPE_HASH_TABLE");
+ ret = g_strdup ("EggDBusHashMap *");
+ free_function_name = "g_object_unref";
+ gvalue_set_func_name = "g_value_set_object";
+ gtype_name = g_strdup ("EGG_DBUS_TYPE_HASH_MAP");
}
else if (signature[1] == DBUS_TYPE_ARRAY)
{
if (is_in)
- ret = g_strdup ("GList *");
+ ret = g_strdup ("EggDBusArraySeq *");
else
- ret = g_strdup ("EggDBusList *");
- free_function_name = "egg_dbus_list_free";
- gvalue_set_func_name = "g_value_set_boxed";
- gtype_name = g_strdup ("EGG_DBUS_TYPE_LIST");
+ ret = g_strdup ("EggDBusArraySeq *");
+ free_function_name = "g_object_unref";
+ gvalue_set_func_name = "g_value_set_object";
+ gtype_name = g_strdup ("EGG_DBUS_TYPE_ARRAY_SEQ");
}
else if (signature[1] == DBUS_TYPE_VARIANT)
{
if (is_in)
- ret = g_strdup ("GList *");
+ ret = g_strdup ("EggDBusArraySeq *");
else
- ret = g_strdup ("EggDBusList *");
- free_function_name = "egg_dbus_list_free";
- gvalue_set_func_name = "g_value_set_boxed";
- gtype_name = g_strdup ("EGG_DBUS_TYPE_LIST");
+ ret = g_strdup ("EggDBusArraySeq *");
+ free_function_name = "g_object_unref";
+ gvalue_set_func_name = "g_value_set_object";
+ gtype_name = g_strdup ("EGG_DBUS_TYPE_ARRAY_SEQ");
}
else
{
diff --git a/src/eggdbus/eggdbusconnection.c b/src/eggdbus/eggdbusconnection.c
index ef4b3dd..7f33f66 100644
--- a/src/eggdbus/eggdbusconnection.c
+++ b/src/eggdbus/eggdbusconnection.c
@@ -29,12 +29,12 @@
#include <eggdbus/eggdbusbus.h>
#include <eggdbus/eggdbuserror.h>
#include <eggdbus/eggdbusbusnametracker.h>
-#include <eggdbus/eggdbushashtable.h>
#include <eggdbus/eggdbusvariant.h>
#include <eggdbus/eggdbusmessage.h>
#include <eggdbus/eggdbusproperties.h>
#include <eggdbus/eggdbusintrospectable.h>
#include <eggdbus/eggdbuspeer.h>
+#include <eggdbus/eggdbushashmap.h>
#include <eggdbus/eggdbusprivate.h>
/**
@@ -1029,13 +1029,13 @@ marshal_property_change_onto_dbus (GObject *object,
InterfaceExportData *interface_data)
{
EggDBusVariant *variant;
- EggDBusHashTable *hash_table;
+ EggDBusHashMap *hash_map;
const EggDBusInterfacePropertyInfo *property_info;
EggDBusMessage *signal_message;
GError *error;
variant = NULL;
- hash_table = NULL;
+ hash_map = NULL;
signal_message = NULL;
error = NULL;
@@ -1063,12 +1063,12 @@ marshal_property_change_onto_dbus (GObject *object,
* comes first
*/
- hash_table = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
- egg_dbus_hash_table_set_signature (hash_table, "s", "v");
+ hash_map = egg_dbus_hash_map_new (G_TYPE_STRING, NULL,
+ EGG_DBUS_TYPE_VARIANT, g_object_unref);
variant = egg_dbus_variant_new_for_gvalue (&value, property_info->signature);
- g_hash_table_insert (hash_table, (gpointer) property_info->name, g_object_ref (variant));
+ egg_dbus_hash_map_insert (hash_map, (gpointer) property_info->name, g_object_ref (variant));
g_value_unset (&value);
signal_message = egg_dbus_connection_new_message_for_signal (interface_data->export_data->connection,
@@ -1087,13 +1087,11 @@ marshal_property_change_onto_dbus (GObject *object,
goto out;
}
- if (!egg_dbus_message_append_hash_table (signal_message,
- hash_table,
- "s",
- "v",
- &error))
+ if (!egg_dbus_message_append_map (signal_message,
+ hash_map, "s", "v",
+ &error))
{
- g_warning ("Error appending hash table for EggDBusChanged signal: %s", error->message);
+ g_warning ("Error appending hash map for EggDBusChanged signal: %s", error->message);
g_error_free (error);
goto out;
}
@@ -1109,8 +1107,8 @@ marshal_property_change_onto_dbus (GObject *object,
out:
if (variant != NULL)
g_object_unref (variant);
- if (hash_table != NULL)
- egg_dbus_hash_table_unref (hash_table);
+ if (hash_map != NULL)
+ g_object_unref (hash_map);
if (signal_message != NULL)
g_object_unref (signal_message);
}
@@ -1919,7 +1917,7 @@ handle_get_all_properties (EggDBusConnection *connection,
GError *error;
gchar *interface_name;
InterfaceExportData *interface_data;
- EggDBusHashTable *hash_from_string_to_variant;
+ EggDBusHashMap *hash_from_string_to_variant;
guint n;
reply = NULL;
@@ -1928,8 +1926,6 @@ handle_get_all_properties (EggDBusConnection *connection,
hash_from_string_to_variant = NULL;
result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- egg_dbus_hash_table_set_signature (hash_from_string_to_variant, "s", "v");
-
if (!egg_dbus_message_extract_string (message, &interface_name, &error))
{
g_warning ("%s: Cannot extract interface name: %s", G_STRFUNC, error->message);
@@ -1950,7 +1946,8 @@ handle_get_all_properties (EggDBusConnection *connection,
/* TODO: handle interface_name being the empty string (spec requires handling this) */
- hash_from_string_to_variant = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
+ hash_from_string_to_variant = egg_dbus_hash_map_new (G_TYPE_STRING, NULL,
+ EGG_DBUS_TYPE_VARIANT, g_object_unref);
for (n = 0; n < interface_data->interface_info->num_properties; n++)
{
@@ -1981,13 +1978,14 @@ handle_get_all_properties (EggDBusConnection *connection,
variant = egg_dbus_variant_new_for_gvalue (&value, property_info->signature);
g_value_unset (&value);
- g_hash_table_insert (hash_from_string_to_variant, (gpointer) property_info->name, variant);
+ egg_dbus_hash_map_insert (hash_from_string_to_variant, (gpointer) property_info->name, variant);
}
reply = egg_dbus_message_new_for_method_reply (message);
- if (!egg_dbus_message_append_hash_table (reply, hash_from_string_to_variant, "s", "v", &error))
+ g_debug ("%p %s", hash_from_string_to_variant, g_type_name (G_TYPE_FROM_INSTANCE (hash_from_string_to_variant)));
+ if (!egg_dbus_message_append_map (reply, hash_from_string_to_variant, "s", "v", &error))
{
g_warning ("%s: Error appending hash table: %s", G_STRFUNC, error->message);
g_error_free (error);
@@ -2003,7 +2001,7 @@ handle_get_all_properties (EggDBusConnection *connection,
out:
g_free (interface_name);
if (hash_from_string_to_variant != NULL)
- egg_dbus_hash_table_unref (hash_from_string_to_variant);
+ g_object_unref (hash_from_string_to_variant);
if (reply != NULL)
g_object_unref (reply);
return result;
diff --git a/src/eggdbus/eggdbushashtable.c b/src/eggdbus/eggdbushashtable.c
deleted file mode 100644
index 0bb2a1d..0000000
--- a/src/eggdbus/eggdbushashtable.c
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright (C) 2008 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- *
- * Author: David Zeuthen <davidz@redhat.com>
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <string.h>
-#include <dbus/dbus.h>
-#include <eggdbus/eggdbusstructure.h>
-#include <eggdbus/eggdbushashtable.h>
-#include <eggdbus/eggdbusarray.h>
-#include <eggdbus/eggdbuslist.h>
-#include <eggdbus/eggdbushashtable.h>
-#include <eggdbus/eggdbusvariant.h>
-#include <eggdbus/eggdbustypes.h>
-#include <eggdbus/eggdbusutils.h>
-#include <eggdbus/eggdbusprivate.h>
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-guint
-egg_dbus_int64_hash (gconstpointer v)
-{
- return (guint) *((const gint64 *) v);
-}
-
-gboolean
-egg_dbus_int64_equal (gconstpointer v1, gconstpointer v2)
-{
- return (*((const gint64 *) v1)) == (*((const gint64 *) v2));
-}
-
-guint
-egg_dbus_uint64_hash (gconstpointer v)
-{
- return (guint) *((const guint64 *) v);
-}
-
-gboolean
-egg_dbus_uint64_equal (gconstpointer v1, gconstpointer v2)
-{
- return (*((const guint64 *) v1)) == (*((const guint64 *) v2));
-}
-
-guint
-egg_dbus_double_hash (gconstpointer v)
-{
- /* TODO: this is not really a good hash function... */
- return (guint) *((const gdouble *) v);
-}
-
-gboolean
-egg_dbus_double_equal (gconstpointer v1, gconstpointer v2)
-{
- return (*((const gdouble *) v1)) == (*((const gdouble *) v2));
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-const gchar *
-egg_dbus_hash_table_get_key_signature (EggDBusHashTable *hash_table)
-{
- return _get_element_signature (hash_table, "EggDBusHashTable");
-}
-
-const gchar *
-egg_dbus_hash_table_get_value_signature (EggDBusHashTable *hash_table)
-{
- return _get_element_signature (((char *) hash_table) + 1, "EggDBusHashTable");
-}
-
-void
-egg_dbus_hash_table_set_signature (GHashTable *hash_table,
- const gchar *key_signature,
- const gchar *value_signature)
-{
- _set_element_signature (hash_table, key_signature, "EggDBusHashTable");
- _set_element_signature (((char *)hash_table) + 1, value_signature, "EggDBusHashTable");
-}
-
-EggDBusHashTable *
-egg_dbus_hash_table_ref (EggDBusHashTable *hash_table)
-{
- g_hash_table_ref (hash_table);
- _ref_element_signature (hash_table, "EggDBusHashTable");
- _ref_element_signature (((char *)hash_table) + 1, "EggDBusHashTable");
- return hash_table;
-}
-
-void
-egg_dbus_hash_table_unref (EggDBusHashTable *hash_table)
-{
- _set_element_signature (hash_table, NULL, "EggDBusHashTable");
- _set_element_signature (((char *)hash_table) + 1, NULL, "EggDBusHashTable");
- g_hash_table_unref (hash_table);
-}
-
-GType
-egg_dbus_hash_table_get_type (void)
-{
- static GType _type = 0;
-
- if (_type != 0)
- goto out;
-
- /* Can't use G_TYPE_HASH_TABLE because we need our own unref method to clean up the signature */
-
- _type = g_boxed_type_register_static ("EggDBusHashTable",
- (GBoxedCopyFunc) egg_dbus_hash_table_ref,
- (GBoxedFreeFunc) egg_dbus_hash_table_unref);
-
- out:
- return _type;
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-void
-egg_dbus_hash_table_print (EggDBusHashTable *hash_table,
- guint indent)
-{
- const gchar *key_signature;
- const gchar *value_signature;
- GHashTableIter iter;
- gpointer key;
- gpointer val;
- GType value_type;
-
- key_signature = egg_dbus_hash_table_get_key_signature (hash_table);
- value_signature = egg_dbus_hash_table_get_value_signature (hash_table);
-
- if (key_signature == NULL || value_signature == NULL)
- return;
-
- value_type = egg_dbus_get_type_for_signature (value_signature);
-
- g_print ("dict {\n");
-
- g_hash_table_iter_init (&iter, hash_table);
- while (g_hash_table_iter_next (&iter, &key, &val))
- {
- g_print ("%*s", indent + 2, "");
-
- switch (key_signature[0])
- {
- case DBUS_TYPE_BYTE:
- g_print ("0x%02x", GPOINTER_TO_INT (key));
- break;
-
- case DBUS_TYPE_INT16:
- g_print ("%" G_GINT16_FORMAT, GPOINTER_TO_INT (key));
- break;
-
- case DBUS_TYPE_UINT16:
- g_print ("%" G_GUINT16_FORMAT, GPOINTER_TO_INT (key));
- break;
-
- case DBUS_TYPE_INT32:
- g_print ("%" G_GINT32_FORMAT, GPOINTER_TO_INT (key));
- break;
-
- case DBUS_TYPE_UINT32:
- g_print ("%" G_GUINT32_FORMAT, GPOINTER_TO_INT (key));
- break;
-
- case DBUS_TYPE_INT64:
- g_print ("%" G_GINT64_FORMAT, *((gint64*) key));
- break;
-
- case DBUS_TYPE_UINT64:
- g_print ("%" G_GUINT64_FORMAT, *((guint64*) key));
- break;
-
- case DBUS_TYPE_DOUBLE:
- g_print ("%g", *((gdouble*) key));
- break;
-
- case DBUS_TYPE_BOOLEAN:
- g_print ("%s", GPOINTER_TO_INT (key) ? "True" : "False");
- break;
-
- case DBUS_TYPE_STRING:
- g_print ("\"%s\"", (const gchar *) key);
- break;
-
- case DBUS_TYPE_OBJECT_PATH:
- g_print ("\"%s\"", (const gchar *) key);
- break;
-
- case DBUS_TYPE_SIGNATURE:
- g_print ("\"%s\"", (const gchar *) key);
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- g_print (" ->");
-
- switch (value_signature[0])
- {
- case DBUS_TYPE_BYTE:
- g_print (" 0x%02x\n", GPOINTER_TO_INT (val));
- break;
-
- case DBUS_TYPE_INT16:
- g_print (" %" G_GINT16_FORMAT "\n", GPOINTER_TO_INT (val));
- break;
-
- case DBUS_TYPE_UINT16:
- g_print (" %" G_GUINT16_FORMAT "\n", GPOINTER_TO_INT (val));
- break;
-
- case DBUS_TYPE_INT32:
- g_print (" %" G_GINT32_FORMAT "\n", GPOINTER_TO_INT (val));
- break;
-
- case DBUS_TYPE_UINT32:
- g_print (" %" G_GUINT32_FORMAT "\n", GPOINTER_TO_INT (val));
- break;
-
- case DBUS_TYPE_INT64:
- g_print (" %" G_GINT64_FORMAT "\n", *((gint64*) val));
- break;
-
- case DBUS_TYPE_UINT64:
- g_print (" %" G_GUINT64_FORMAT "\n", *((guint64*) val));
- break;
-
- case DBUS_TYPE_DOUBLE:
- g_print (" %g\n", *((gdouble*) val));
- break;
-
- case DBUS_TYPE_BOOLEAN:
- g_print (" %s\n", GPOINTER_TO_INT (val) ? "True" : "False");
- break;
-
- case DBUS_TYPE_STRING:
- g_print (" \"%s\"\n", (const gchar *) val);
- break;
-
- case DBUS_TYPE_OBJECT_PATH:
- g_print (" \"%s\"\n", (const gchar *) val);
- break;
-
- default:
- {
- GValue val_gvalue = {0};
- gboolean simple;
-
- g_value_init (&val_gvalue, value_type);
- if (value_signature[0] == DBUS_STRUCT_BEGIN_CHAR ||
- value_signature[0] == DBUS_TYPE_VARIANT)
- g_value_take_object (&val_gvalue, val);
- else
- g_value_take_boxed (&val_gvalue, val);
-
- /* simple types can be printed on the same line */
- simple = TRUE;
- if (value_type == EGG_DBUS_TYPE_LIST ||
- value_type == EGG_DBUS_TYPE_HASH_TABLE ||
- g_type_is_a (value_type, EGG_DBUS_TYPE_STRUCTURE) ||
- value_type == EGG_DBUS_TYPE_VARIANT)
- simple = FALSE;
-
- if (simple)
- g_print (" ");
- else
- g_print ("\n%*s", indent + 4, "");
-
- egg_dbus_utils_print_gvalue (&val_gvalue, value_signature, indent + 4);
- }
- break;
- }
-
- }
-
- g_print ("%*s}\n", indent, "");
-}
-
diff --git a/src/eggdbus/eggdbushashtable.h b/src/eggdbus/eggdbushashtable.h
deleted file mode 100644
index 01e9ce1..0000000
--- a/src/eggdbus/eggdbushashtable.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2008 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- *
- * Author: David Zeuthen <davidz@redhat.com>
- */
-
-#if !defined (_EGG_DBUS_COMPILATION) && !defined(_EGG_DBUS_INSIDE_EGG_DBUS_H)
-#error "Only <eggdbus/eggdbus.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __EGG_DBUS_HASH_TABLE_H
-#define __EGG_DBUS_HASH_TABLE_H
-
-#include <eggdbus/eggdbustypes.h>
-
-G_BEGIN_DECLS
-
-#define EGG_DBUS_TYPE_HASH_TABLE (egg_dbus_hash_table_get_type ())
-
-GType egg_dbus_hash_table_get_type (void) G_GNUC_CONST;
-const gchar *egg_dbus_hash_table_get_key_signature (EggDBusHashTable *hash_table);
-const gchar *egg_dbus_hash_table_get_value_signature (EggDBusHashTable *hash_table);
-void egg_dbus_hash_table_set_signature (GHashTable *hash_table,
- const gchar *key_signature,
- const gchar *value_signature);
-EggDBusHashTable *egg_dbus_hash_table_ref (EggDBusHashTable *hash_table);
-void egg_dbus_hash_table_unref (EggDBusHashTable *hash_table);
-void egg_dbus_hash_table_print (EggDBusHashTable *hash_table,
- guint indent);
-
-guint egg_dbus_int64_hash (gconstpointer v);
-gboolean egg_dbus_int64_equal (gconstpointer v1,
- gconstpointer v2);
-guint egg_dbus_uint64_hash (gconstpointer v);
-gboolean egg_dbus_uint64_equal (gconstpointer v1,
- gconstpointer v2);
-guint egg_dbus_double_hash (gconstpointer v);
-gboolean egg_dbus_double_equal (gconstpointer v1,
- gconstpointer v2);
-
-G_END_DECLS
-
-#endif /* __EGG_DBUS_HASH_TABLE_H */
diff --git a/src/eggdbus/eggdbusinterfaceproxy.c b/src/eggdbus/eggdbusinterfaceproxy.c
index 6b5cb46..8099de7 100644
--- a/src/eggdbus/eggdbusinterfaceproxy.c
+++ b/src/eggdbus/eggdbusinterfaceproxy.c
@@ -33,10 +33,10 @@
#include <eggdbus/eggdbuspeer.h>
#include <eggdbus/eggdbusbus.h>
#include <eggdbus/eggdbusproperties.h>
-#include <eggdbus/eggdbushashtable.h>
#include <eggdbus/eggdbusvariant.h>
#include <eggdbus/eggdbusstructure.h>
#include <eggdbus/eggdbusintrospectable.h>
+#include <eggdbus/eggdbushashmap.h>
/**
* SECTION:eggdbusinterfaceproxy
@@ -58,7 +58,7 @@ typedef struct
* of EggDBusVariant; it is retrieved using GetAll() on the interface
* org.freedesktop.Properties (e.g. egg_dbus_properties_get_all()).
*/
- GHashTable *property_bag;
+ EggDBusHashMap *property_bag;
} EggDBusInterfaceProxyPrivate;
@@ -84,18 +84,18 @@ egg_dbus_interface_proxy_finalize (GObject *object)
priv = EGG_DBUS_INTERFACE_PROXY_GET_PRIVATE (interface_proxy);
if (priv->property_bag != NULL)
- g_hash_table_unref (priv->property_bag);
+ g_object_unref (priv->property_bag);
G_OBJECT_CLASS (egg_dbus_interface_proxy_parent_class)->finalize (object);
}
/* returns a rewritten property_bag (and frees the given property bag) */
-static EggDBusHashTable *
+static EggDBusHashMap *
rewrite_properties (EggDBusInterfaceProxy *interface_proxy,
- EggDBusHashTable *property_bag)
+ EggDBusHashMap *property_bag)
{
EggDBusInterfaceProxyPrivate *priv;
- EggDBusHashTable *rewritten_property_bag;
+ EggDBusHashMap *rewritten_property_bag;
GHashTableIter property_bag_iter;
gchar *camel_cased_name;
EggDBusVariant *variant;
@@ -103,12 +103,9 @@ rewrite_properties (EggDBusInterfaceProxy *interface_proxy,
priv = EGG_DBUS_INTERFACE_PROXY_GET_PRIVATE (interface_proxy);
/* rewrite names in property bag so we store the g-name-of-property intead of GNameOfProperty */
- rewritten_property_bag = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- NULL,
- (GDestroyNotify) g_object_unref);
- egg_dbus_hash_table_set_signature (rewritten_property_bag, "s", "v");
- g_hash_table_iter_init (&property_bag_iter, property_bag);
+ rewritten_property_bag = egg_dbus_hash_map_new (G_TYPE_STRING, NULL,
+ EGG_DBUS_TYPE_VARIANT, g_object_unref);
+ g_hash_table_iter_init (&property_bag_iter, property_bag->data);
while (g_hash_table_iter_next (&property_bag_iter, (gpointer) &camel_cased_name, (gpointer) &variant))
{
const EggDBusInterfacePropertyInfo *property_info;
@@ -120,9 +117,9 @@ rewrite_properties (EggDBusInterfaceProxy *interface_proxy,
property_info = egg_dbus_interface_info_lookup_property_for_name (priv->interface_info, camel_cased_name);
if (property_info != NULL)
{
- g_hash_table_insert (rewritten_property_bag,
- (gpointer) property_info->g_name,
- g_object_ref (variant));
+ egg_dbus_hash_map_insert (rewritten_property_bag,
+ (gpointer) property_info->g_name,
+ g_object_ref (variant));
}
else
{
@@ -133,7 +130,7 @@ rewrite_properties (EggDBusInterfaceProxy *interface_proxy,
}
}
- egg_dbus_hash_table_unref (property_bag);
+ g_object_unref (property_bag);
return rewritten_property_bag;
}
@@ -145,15 +142,15 @@ rewrite_properties (EggDBusInterfaceProxy *interface_proxy,
*
* Retrieves all properties for the D-Bus interface.
*
- * Returns: A #EggDBusHashTable. Returns %NULL only if @no_block is
+ * Returns: A #EggDBusHashMap. Returns %NULL only if @no_block is
* %TRUE and we don't have the properties yet.
**/
-static EggDBusHashTable *
+static EggDBusHashMap *
ensure_properties (EggDBusInterfaceProxy *interface_proxy,
gboolean no_block)
{
EggDBusInterfaceProxyPrivate *priv;
- EggDBusHashTable *property_bag;
+ EggDBusHashMap *property_bag;
GError *error;
priv = EGG_DBUS_INTERFACE_PROXY_GET_PRIVATE (interface_proxy);
@@ -202,7 +199,7 @@ egg_dbus_interface_proxy_get_property (GObject *object,
{
EggDBusInterfaceProxy *interface_proxy;
EggDBusInterfaceProxyPrivate *priv;
- EggDBusHashTable *property_bag;
+ EggDBusHashMap *property_bag;
EggDBusVariant *variant;
interface_proxy = EGG_DBUS_INTERFACE_PROXY (object);
@@ -212,7 +209,7 @@ egg_dbus_interface_proxy_get_property (GObject *object,
property_bag = ensure_properties (interface_proxy, FALSE);
if (property_bag != NULL)
- variant = g_hash_table_lookup (property_bag, pspec->name);
+ variant = egg_dbus_hash_map_lookup (property_bag, pspec->name);
if (variant != NULL)
{
@@ -302,7 +299,7 @@ egg_dbus_interface_proxy_set_property (GObject *object,
priv->property_bag = ensure_properties (interface_proxy, TRUE);
if (priv->property_bag != NULL)
{
- g_hash_table_insert (priv->property_bag, (gpointer) property_info->g_name, variant);
+ egg_dbus_hash_map_insert (priv->property_bag, (gpointer) property_info->g_name, variant);
variant = NULL;
}
@@ -320,7 +317,7 @@ _egg_dbus_interface_proxy_invalidate_properties (EggDBusInterfaceProxy *interfac
if (priv->property_bag != NULL)
{
- g_hash_table_unref (priv->property_bag);
+ g_object_unref (priv->property_bag);
priv->property_bag = NULL;
}
@@ -328,26 +325,26 @@ _egg_dbus_interface_proxy_invalidate_properties (EggDBusInterfaceProxy *interfac
void
_egg_dbus_interface_proxy_handle_property_changed (EggDBusInterfaceProxy *interface_proxy,
- EggDBusHashTable *changed_properties)
+ EggDBusHashMap *changed_properties)
{
EggDBusInterfaceProxyPrivate *priv;
GHashTableIter change_property_bag_iter;
const gchar *prop_g_name;
EggDBusVariant *variant;
- GHashTable *existing_property_bag;
- GHashTable *rewritten_properties;
+ EggDBusHashMap *existing_property_bag;
+ EggDBusHashMap *rewritten_properties;
GObjectClass *gobject_class;
priv = EGG_DBUS_INTERFACE_PROXY_GET_PRIVATE (interface_proxy);
rewritten_properties = rewrite_properties (interface_proxy,
- egg_dbus_hash_table_ref (changed_properties));
+ g_object_ref (changed_properties));
existing_property_bag = ensure_properties (interface_proxy, TRUE);
gobject_class = G_OBJECT_GET_CLASS (interface_proxy);
- g_hash_table_iter_init (&change_property_bag_iter, rewritten_properties);
+ g_hash_table_iter_init (&change_property_bag_iter, rewritten_properties->data);
while (g_hash_table_iter_next (&change_property_bag_iter, (gpointer) &prop_g_name, (gpointer) &variant))
{
GParamSpec *pspec;
@@ -371,9 +368,9 @@ _egg_dbus_interface_proxy_handle_property_changed (EggDBusInterfaceProxy *interf
if (existing_property_bag != NULL)
{
//g_debug ("updating %s", prop_g_name);
- g_hash_table_insert (existing_property_bag,
- (gpointer) prop_g_name,
- g_object_ref (variant));
+ egg_dbus_hash_map_insert (existing_property_bag,
+ (gpointer) prop_g_name,
+ g_object_ref (variant));
}
g_object_notify (G_OBJECT (interface_proxy), prop_g_name);
diff --git a/src/eggdbus/eggdbuslist.c b/src/eggdbus/eggdbuslist.c
deleted file mode 100644
index 0d66fd1..0000000
--- a/src/eggdbus/eggdbuslist.c
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2008 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- *
- * Author: David Zeuthen <davidz@redhat.com>
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <string.h>
-#include <dbus/dbus.h>
-#include <eggdbus/eggdbusarray.h>
-#include <eggdbus/eggdbuslist.h>
-#include <eggdbus/eggdbushashtable.h>
-#include <eggdbus/eggdbusstructure.h>
-#include <eggdbus/eggdbusvariant.h>
-#include <eggdbus/eggdbustypes.h>
-#include <eggdbus/eggdbusutils.h>
-#include <eggdbus/eggdbusprivate.h>
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static EggDBusList *
-_array_list_copy (EggDBusList *list)
-{
- EggDBusList *ret, *l;
- ret = NULL;
- for (l = list; l != NULL; l = l->next)
- ret = g_list_prepend (ret, egg_dbus_array_copy ((GArray *) l->data));
- ret = g_list_reverse (ret);
- return ret;
-}
-
-static void
-_array_list_free (EggDBusList *list)
-{
- EggDBusList *l;
- for (l = list; l != NULL; l = l->next)
- egg_dbus_array_free ((GArray *) l->data);
- g_list_free (list);
-}
-
-static EggDBusList *
-_strv_list_copy (EggDBusList *list)
-{
- EggDBusList *ret, *l;
- ret = NULL;
- for (l = list; l != NULL; l = l->next)
- {
- ret = g_list_prepend (ret, g_strdupv ((char **) l->data));
- }
- ret = g_list_reverse (ret);
- return ret;
-}
-
-static void
-_strv_list_free (EggDBusList *list)
-{
- g_list_foreach (list, (GFunc) g_strfreev, NULL);
- g_list_free (list);
-}
-
-static EggDBusList *
-_object_list_copy (EggDBusList *list)
-{
- EggDBusList *ret;
- ret = g_list_copy (list);
- g_list_foreach (ret, (GFunc) g_object_ref, NULL);
- return ret;
-}
-
-static void
-_object_list_free (EggDBusList *list)
-{
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
-}
-
-static EggDBusList *
-_hash_table_list_copy (EggDBusList *list)
-{
- EggDBusList *ret;
- ret = g_list_copy (list);
- g_list_foreach (ret, (GFunc) egg_dbus_hash_table_ref, NULL);
- return ret;
-}
-
-static void
-_hash_table_list_free (EggDBusList *list)
-{
- g_list_foreach (list, (GFunc) egg_dbus_hash_table_unref, NULL);
- g_list_free (list);
-}
-
-static EggDBusList *
-_list_list_copy (EggDBusList *list)
-{
- EggDBusList *ret, *l;
- ret = NULL;
- for (l = list; l != NULL; l = l->next)
- {
- EggDBusList *list_elem = (EggDBusList *) l->data;
- EggDBusList *list_elem_copy;
-
- list_elem_copy = _list_list_copy (list_elem);
- ret = g_list_prepend (ret, list_elem_copy);
- }
- ret = g_list_reverse (ret);
- return ret;
-}
-
-static void
-_list_list_free (EggDBusList *list)
-{
- EggDBusList *l;
- for (l = list; l != NULL; l = l->next)
- {
- EggDBusList *list_elem = (EggDBusList *) l->data;
- egg_dbus_list_free (list_elem);
- }
- g_list_free (list);
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-EggDBusList *
-egg_dbus_list_copy (EggDBusList *list)
-{
- EggDBusList *ret;
- GType elem_type;
- const gchar *elem_signature;
-
- elem_signature = egg_dbus_list_get_elem_signature (list);
-
- elem_type = egg_dbus_get_type_for_signature (elem_signature);
-
- if (elem_type == EGG_DBUS_TYPE_ARRAY)
- {
- ret = _array_list_copy (list);
- }
- else if (elem_type == G_TYPE_STRV)
- {
- ret = _strv_list_copy (list);
- }
- else if (elem_type == EGG_DBUS_TYPE_LIST)
- {
- ret = _list_list_copy (list);
- }
- else if (elem_type == EGG_DBUS_TYPE_HASH_TABLE ||
- elem_type == G_TYPE_HASH_TABLE)
- {
- ret = _hash_table_list_copy (list);
- }
- else if (g_type_is_a (elem_type, G_TYPE_OBJECT))
- {
- ret = _object_list_copy (list);
- }
- else
- {
- /* fall back shallow copy, but do warn since this is a programming error */
- ret = g_list_copy (list);
- g_warning ("_list_copy() called on list %p with unknown element GType %s (%d). Doing shallow copy.",
- list,
- g_type_name (elem_type),
- (int) elem_type);
- }
-
- egg_dbus_list_set_elem_signature (ret, elem_signature);
- return ret;
-}
-
-void
-egg_dbus_list_free (EggDBusList *list)
-{
- GType elem_type;
- const gchar *elem_signature;
-
- elem_signature = egg_dbus_list_get_elem_signature (list);
-
- elem_type = egg_dbus_get_type_for_signature (elem_signature);
-
- if (elem_type == EGG_DBUS_TYPE_ARRAY)
- {
- _array_list_free (list);
- }
- else if (elem_type == G_TYPE_STRV)
- {
- _strv_list_free (list);
- }
- else if (elem_type == EGG_DBUS_TYPE_LIST)
- {
- _list_list_free (list);
- }
- else if (elem_type == EGG_DBUS_TYPE_HASH_TABLE ||
- elem_type == G_TYPE_HASH_TABLE)
- {
- _hash_table_list_free (list);
- }
- else if (g_type_is_a (elem_type, G_TYPE_OBJECT))
- {
- _object_list_free (list);
- }
- else
- {
- /* fall back to just freeing the list. Do warn since this is a programming error */
- g_list_free (list);
- g_warning ("_list_free() called on list %p with unknown element GType %s (%d). Not freeing elements.",
- list,
- g_type_name (elem_type),
- (int) elem_type);
- }
-
- egg_dbus_list_set_elem_signature (list, NULL);
-}
-
-GType
-egg_dbus_list_get_type (void)
-{
- static GType _type = 0;
-
- if (_type != 0)
- goto out;
-
- _type = g_boxed_type_register_static ("EggDBusList",
- (GBoxedCopyFunc) egg_dbus_list_copy,
- (GBoxedFreeFunc) egg_dbus_list_free);
-
- out:
- return _type;
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-const gchar *
-egg_dbus_list_get_elem_signature (EggDBusList *list)
-{
- return _get_element_signature (list, "EggDBusList");
-}
-
-void
-egg_dbus_list_set_elem_signature (GList *list,
- const gchar *elem_signature)
-{
- _set_element_signature (list, elem_signature, "EggDBusList");
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-void
-egg_dbus_list_print (EggDBusList *list,
- guint indent)
-{
- EggDBusList *l;
- const gchar *elem_signature;
- GType elem_type;
-
- elem_signature = egg_dbus_list_get_elem_signature (list);
- if (elem_signature == NULL)
- return;
-
- elem_type = egg_dbus_get_type_for_signature (elem_signature);
-
- g_print ("array [\n");
- for (l = list; l != NULL; l = l->next)
- {
- g_print ("%*s", indent + 2, "");
-
- if (elem_type == EGG_DBUS_TYPE_ARRAY)
- egg_dbus_array_print ((GArray *) l->data, indent + 2);
- else if (elem_type == EGG_DBUS_TYPE_LIST)
- egg_dbus_list_print ((EggDBusList *) l->data, indent + 2);
- else if (elem_type == EGG_DBUS_TYPE_HASH_TABLE ||
- elem_type == G_TYPE_HASH_TABLE)
- egg_dbus_hash_table_print ((GHashTable *) l->data, indent + 2);
- else if (g_type_is_a (elem_type, EGG_DBUS_TYPE_VARIANT))
- egg_dbus_variant_print (EGG_DBUS_VARIANT (l->data), indent + 2);
- else if (g_type_is_a (elem_type, EGG_DBUS_TYPE_STRUCTURE))
- egg_dbus_structure_print (EGG_DBUS_STRUCTURE (l->data), indent + 2);
- else
- g_assert_not_reached ();
-
- }
- g_print ("%*s]\n", indent, "");
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/eggdbus/eggdbuslist.h b/src/eggdbus/eggdbuslist.h
deleted file mode 100644
index 643985b..0000000
--- a/src/eggdbus/eggdbuslist.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2008 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- *
- * Author: David Zeuthen <davidz@redhat.com>
- */
-
-#if !defined (_EGG_DBUS_COMPILATION) && !defined(_EGG_DBUS_INSIDE_EGG_DBUS_H)
-#error "Only <eggdbus/eggdbus.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __EGG_DBUS_LIST_H
-#define __EGG_DBUS_LIST_H
-
-#include <eggdbus/eggdbustypes.h>
-
-G_BEGIN_DECLS
-
-#define EGG_DBUS_TYPE_LIST (egg_dbus_list_get_type ())
-
-GType egg_dbus_list_get_type (void) G_GNUC_CONST;
-const gchar *egg_dbus_list_get_elem_signature (EggDBusList *list);
-void egg_dbus_list_set_elem_signature (GList *list,
- const gchar *elem_signature);
-void egg_dbus_list_free (EggDBusList *list);
-EggDBusList *egg_dbus_list_copy (EggDBusList *list);
-void egg_dbus_list_print (EggDBusList *list,
- guint indent);
-
-G_END_DECLS
-
-#endif /* __EGG_DBUS_LIST_H */
diff --git a/src/eggdbus/eggdbusmessage.c b/src/eggdbus/eggdbusmessage.c
index 5646863..7d79bbe 100644
--- a/src/eggdbus/eggdbusmessage.c
+++ b/src/eggdbus/eggdbusmessage.c
@@ -29,10 +29,9 @@
#include <eggdbus/eggdbussignature.h>
#include <eggdbus/eggdbuserror.h>
#include <eggdbus/eggdbusutils.h>
-#include <eggdbus/eggdbusarray.h>
+#include <eggdbus/eggdbusarrayseq.h>
+#include <eggdbus/eggdbushashmap.h>
#include <eggdbus/eggdbusstructure.h>
-#include <eggdbus/eggdbushashtable.h>
-#include <eggdbus/eggdbuslist.h>
#include <eggdbus/eggdbusvariant.h>
#include <eggdbus/eggdbusconnection.h>
#include <eggdbus/eggdbusprivate.h>
@@ -80,13 +79,13 @@ enum
};
static gboolean egg_dbus_get_value_from_iter (DBusMessageIter *iter,
- GValue *out_value,
- GError **error);
+ GValue *out_value,
+ GError **error);
static gboolean egg_dbus_append_value_to_iter (DBusMessageIter *iter,
- const gchar *signature,
- const GValue *value,
- GError **error);
+ const gchar *signature,
+ const GValue *value,
+ GError **error);
#define EGG_DBUS_MESSAGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_DBUS_TYPE_MESSAGE, EggDBusMessagePrivate))
@@ -688,7 +687,7 @@ egg_dbus_message_append_string (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, G_TYPE_STRING);
g_value_set_static_string (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "s", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_STRING_AS_STRING, error);
}
gboolean
@@ -699,7 +698,7 @@ egg_dbus_message_append_object_path (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, EGG_DBUS_TYPE_OBJECT_PATH);
g_value_set_static_boxed (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "o", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_OBJECT_PATH_AS_STRING, error);
}
gboolean
@@ -710,7 +709,7 @@ egg_dbus_message_append_signature (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, EGG_DBUS_TYPE_SIGNATURE);
g_value_set_static_boxed (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "g", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_SIGNATURE_AS_STRING, error);
}
gboolean
@@ -721,7 +720,7 @@ egg_dbus_message_append_string_array (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, G_TYPE_STRV);
g_value_take_boxed (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "as", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING, error);
}
gboolean
@@ -732,7 +731,7 @@ egg_dbus_message_append_object_path_array (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, EGG_DBUS_TYPE_OBJECT_PATH_ARRAY);
g_value_take_boxed (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "ao", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING, error);
}
gboolean
@@ -743,7 +742,7 @@ egg_dbus_message_append_signature_array (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, EGG_DBUS_TYPE_SIGNATURE_ARRAY);
g_value_take_boxed (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "ag", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_SIGNATURE_AS_STRING, error);
}
gboolean
@@ -754,7 +753,7 @@ egg_dbus_message_append_byte (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, G_TYPE_UCHAR);
g_value_set_uchar (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "y", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_BYTE_AS_STRING, error);
}
gboolean
@@ -765,7 +764,7 @@ egg_dbus_message_append_int16 (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, EGG_DBUS_TYPE_INT16);
egg_dbus_value_set_int16 (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "n", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_INT16_AS_STRING, error);
}
gboolean
@@ -776,7 +775,7 @@ egg_dbus_message_append_uint16 (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, EGG_DBUS_TYPE_UINT16);
egg_dbus_value_set_uint16 (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "q", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_UINT16_AS_STRING, error);
}
gboolean
@@ -787,7 +786,7 @@ egg_dbus_message_append_int32 (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, G_TYPE_INT);
g_value_set_int (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "i", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_INT32_AS_STRING, error);
}
gboolean
@@ -798,7 +797,7 @@ egg_dbus_message_append_uint32 (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, G_TYPE_UINT);
g_value_set_uint (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "u", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_UINT32_AS_STRING, error);
}
gboolean
@@ -809,7 +808,7 @@ egg_dbus_message_append_int64 (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, G_TYPE_INT64);
g_value_set_int64 (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "x", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_INT64_AS_STRING, error);
}
gboolean
@@ -820,7 +819,7 @@ egg_dbus_message_append_uint64 (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, G_TYPE_UINT64);
g_value_set_uint64 (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "t", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_UINT64_AS_STRING, error);
}
gboolean
@@ -831,7 +830,7 @@ egg_dbus_message_append_boolean (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, G_TYPE_BOOLEAN);
g_value_set_boolean (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "b", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_BOOLEAN_AS_STRING, error);
}
gboolean
@@ -842,55 +841,38 @@ egg_dbus_message_append_double (EggDBusMessage *message,
GValue val = {0};
g_value_init (&val, G_TYPE_DOUBLE);
g_value_set_double (&val, value);
- return egg_dbus_message_append_gvalue (message, &val, "d", error);
+ return egg_dbus_message_append_gvalue (message, &val, DBUS_TYPE_DOUBLE_AS_STRING, error);
}
gboolean
-egg_dbus_message_append_array (EggDBusMessage *message,
- GArray *array,
- const gchar *elem_signature,
- GError **error)
+egg_dbus_message_append_seq (EggDBusMessage *message,
+ EggDBusArraySeq *seq,
+ const gchar *element_signature,
+ GError **error)
{
GValue val = {0};
gboolean ret;
- char *sig;
- g_value_init (&val, EGG_DBUS_TYPE_ARRAY);
- g_value_take_boxed (&val, array);
- sig = g_strdup_printf ("a%s", elem_signature);
+ gchar *sig;
+ g_value_init (&val, EGG_DBUS_TYPE_ARRAY_SEQ);
+ g_value_take_object (&val, seq);
+ sig = g_strdup_printf ("a%s", element_signature);
ret = egg_dbus_message_append_gvalue (message, &val, sig, error);
g_free (sig);
return ret;
}
gboolean
-egg_dbus_message_append_list (EggDBusMessage *message,
- GList *list,
- const gchar *elem_signature,
- GError **error)
+egg_dbus_message_append_map (EggDBusMessage *message,
+ EggDBusHashMap *map,
+ const gchar *key_signature,
+ const gchar *value_signature,
+ GError **error)
{
GValue val = {0};
gboolean ret;
- char *sig;
- g_value_init (&val, EGG_DBUS_TYPE_LIST);
- g_value_take_boxed (&val, list);
- sig = g_strdup_printf ("a%s", elem_signature);
- ret = egg_dbus_message_append_gvalue (message, &val, sig, error);
- g_free (sig);
- return ret;
-}
-
-gboolean
-egg_dbus_message_append_hash_table (EggDBusMessage *message,
- GHashTable *hash_table,
- const gchar *key_signature,
- const gchar *value_signature,
- GError **error)
-{
- GValue val = {0};
- gboolean ret;
- char *sig;
- g_value_init (&val, EGG_DBUS_TYPE_HASH_TABLE);
- g_value_take_boxed (&val, hash_table);
+ gchar *sig;
+ g_value_init (&val, EGG_DBUS_TYPE_HASH_MAP);
+ g_value_take_object (&val, map);
sig = g_strdup_printf ("a{%s%s}", key_signature, value_signature);
ret = egg_dbus_message_append_gvalue (message, &val, sig, error);
g_free (sig);
@@ -898,7 +880,7 @@ egg_dbus_message_append_hash_table (EggDBusMessage *message,
}
gboolean
-egg_dbus_message_append_structure (EggDBusMessage *message,
+egg_dbus_message_append_structure (EggDBusMessage *message,
EggDBusStructure *structure,
GError **error)
{
@@ -906,9 +888,9 @@ egg_dbus_message_append_structure (EggDBusMessage *message,
g_value_init (&val, EGG_DBUS_TYPE_STRUCTURE);
g_value_take_object (&val, structure);
return egg_dbus_message_append_gvalue (message,
- &val,
- egg_dbus_structure_get_signature (structure),
- error);
+ &val,
+ egg_dbus_structure_get_signature (structure),
+ error);
}
gboolean
@@ -920,17 +902,17 @@ egg_dbus_message_append_variant (EggDBusMessage *message,
g_value_init (&val, EGG_DBUS_TYPE_VARIANT);
g_value_take_object (&val, variant);
return egg_dbus_message_append_gvalue (message,
- &val,
- "v",
- error);
+ &val,
+ DBUS_TYPE_VARIANT_AS_STRING,
+ error);
}
gboolean
egg_dbus_message_append_gvalue (EggDBusMessage *message,
- const GValue *value,
- const gchar *signature,
- GError **error)
+ const GValue *value,
+ const gchar *signature,
+ GError **error)
{
EggDBusMessagePrivate *priv;
@@ -941,17 +923,17 @@ egg_dbus_message_append_gvalue (EggDBusMessage *message,
ensure_write_iter (message);
return egg_dbus_append_value_to_iter (&(priv->message_write_iter),
- signature,
- value,
- error);
+ signature,
+ value,
+ error);
}
/* ---------------------------------------------------------------------------------------------------- */
gboolean
egg_dbus_message_extract_string (EggDBusMessage *message,
- gchar **out_value,
- GError **error)
+ gchar **out_value,
+ GError **error)
{
GValue val = {0};
if (!egg_dbus_message_extract_gvalue (message, &val, error))
@@ -1184,47 +1166,30 @@ egg_dbus_message_extract_double (EggDBusMessage *message,
gboolean
-egg_dbus_message_extract_array (EggDBusMessage *message,
- EggDBusArray **out_array,
- GError **error)
-{
- GValue val = {0};
- if (!egg_dbus_message_extract_gvalue (message, &val, error))
- return FALSE;
- if (out_array != NULL)
- *out_array = (EggDBusArray *) g_value_get_boxed (&val);
- else
- g_value_unset (&val);
- return TRUE;
-}
-
-
-gboolean
-egg_dbus_message_extract_list (EggDBusMessage *message,
- EggDBusList **out_list,
- GError **error)
+egg_dbus_message_extract_seq (EggDBusMessage *message,
+ EggDBusArraySeq **out_seq,
+ GError **error)
{
GValue val = {0};
if (!egg_dbus_message_extract_gvalue (message, &val, error))
return FALSE;
- if (out_list != NULL)
- *out_list = (EggDBusList *) g_value_get_boxed (&val);
+ if (out_seq != NULL)
+ *out_seq = (EggDBusArraySeq *) g_value_get_object (&val);
else
g_value_unset (&val);
return TRUE;
}
-
gboolean
-egg_dbus_message_extract_hash_table (EggDBusMessage *message,
- EggDBusHashTable **out_hash_table,
- GError **error)
+egg_dbus_message_extract_map (EggDBusMessage *message,
+ EggDBusHashMap **out_map,
+ GError **error)
{
GValue val = {0};
if (!egg_dbus_message_extract_gvalue (message, &val, error))
return FALSE;
- if (out_hash_table != NULL)
- *out_hash_table = (EggDBusHashTable *) g_value_get_boxed (&val);
+ if (out_map != NULL)
+ *out_map = (EggDBusHashMap *) g_value_get_object (&val);
else
g_value_unset (&val);
return TRUE;
@@ -1233,8 +1198,8 @@ egg_dbus_message_extract_hash_table (EggDBusMessage *message,
gboolean
egg_dbus_message_extract_structure (EggDBusMessage *message,
- EggDBusStructure **out_structure,
- GError **error)
+ EggDBusStructure **out_structure,
+ GError **error)
{
GValue val = {0};
if (!egg_dbus_message_extract_gvalue (message, &val, error))
@@ -1249,8 +1214,8 @@ egg_dbus_message_extract_structure (EggDBusMessage *message,
gboolean
egg_dbus_message_extract_variant (EggDBusMessage *message,
- EggDBusVariant **out_variant,
- GError **error)
+ EggDBusVariant **out_variant,
+ GError **error)
{
GValue val = {0};
if (!egg_dbus_message_extract_gvalue (message, &val, error))
@@ -1265,8 +1230,8 @@ egg_dbus_message_extract_variant (EggDBusMessage *message,
gboolean
egg_dbus_message_extract_gvalue (EggDBusMessage *message,
- GValue *out_value,
- GError **error)
+ GValue *out_value,
+ GError **error)
{
EggDBusMessagePrivate *priv;
gboolean ret;
@@ -1278,8 +1243,8 @@ egg_dbus_message_extract_gvalue (EggDBusMessage *message,
ensure_read_iter (message);
ret = egg_dbus_get_value_from_iter (&(priv->message_read_iter),
- out_value,
- error);
+ out_value,
+ error);
dbus_message_iter_next (&(priv->message_read_iter));
return ret;
}
@@ -1289,8 +1254,8 @@ egg_dbus_message_extract_gvalue (EggDBusMessage *message,
static gboolean
egg_dbus_get_value_from_iter (DBusMessageIter *iter,
- GValue *out_value,
- GError **error)
+ GValue *out_value,
+ GError **error)
{
int arg_type;
int array_arg_type;
@@ -1469,132 +1434,134 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
array_arg_type == DBUS_TYPE_BOOLEAN ||
array_arg_type == DBUS_TYPE_DOUBLE)
{
- GArray *a;
+ EggDBusArraySeq *a;
DBusMessageIter array_iter;
char *elem_signature;
- int elem_size;
+ GType elem_type;
switch (array_arg_type)
{
case DBUS_TYPE_BYTE:
- elem_size = sizeof (guchar);
- break;
-
- case DBUS_TYPE_UINT16:
- elem_size = sizeof (dbus_uint16_t);
+ elem_type = G_TYPE_UCHAR;
break;
case DBUS_TYPE_INT16:
- elem_size = sizeof (dbus_int16_t);
+ elem_type = EGG_DBUS_TYPE_INT16;
break;
- case DBUS_TYPE_UINT32:
- elem_size = sizeof (dbus_uint32_t);
+ case DBUS_TYPE_UINT16:
+ elem_type = EGG_DBUS_TYPE_UINT16;
break;
case DBUS_TYPE_INT32:
- elem_size = sizeof (dbus_int32_t);
+ elem_type = G_TYPE_UINT;
break;
- case DBUS_TYPE_UINT64:
- elem_size = sizeof (dbus_uint64_t);
+ case DBUS_TYPE_UINT32:
+ elem_type = G_TYPE_INT;
break;
case DBUS_TYPE_INT64:
- elem_size = sizeof (dbus_int64_t);
+ elem_type = G_TYPE_INT64;
+ break;
+
+ case DBUS_TYPE_UINT64:
+ elem_type = G_TYPE_UINT64;
break;
case DBUS_TYPE_BOOLEAN:
- elem_size = sizeof (dbus_bool_t);
+ elem_type = G_TYPE_BOOLEAN;
break;
case DBUS_TYPE_DOUBLE:
- elem_size = sizeof (double);
+ elem_type = G_TYPE_DOUBLE;
break;
default:
g_assert_not_reached ();
+ break;
}
dbus_message_iter_recurse (iter, &array_iter);
elem_signature = dbus_message_iter_get_signature (&array_iter);
- a = g_array_new (FALSE, FALSE, elem_size);
+ a = egg_dbus_array_seq_new (elem_type, NULL, NULL, NULL);
while (dbus_message_iter_get_arg_type (&array_iter) != DBUS_TYPE_INVALID)
{
switch (array_arg_type)
{
case DBUS_TYPE_BYTE:
dbus_message_iter_get_basic (&array_iter, &uint8_val);
- g_array_append_val (a, uint8_val);
+ egg_dbus_array_seq_add_fixed (a, uint8_val);
break;
case DBUS_TYPE_INT16:
dbus_message_iter_get_basic (&array_iter, &int16_val);
- g_array_append_val (a, int16_val);
+ egg_dbus_array_seq_add_fixed (a, int16_val);
break;
case DBUS_TYPE_UINT16:
dbus_message_iter_get_basic (&array_iter, &uint16_val);
- g_array_append_val (a, uint16_val);
+ egg_dbus_array_seq_add_fixed (a, uint16_val);
break;
case DBUS_TYPE_INT32:
dbus_message_iter_get_basic (&array_iter, &int32_val);
- g_array_append_val (a, int32_val);
+ egg_dbus_array_seq_add_fixed (a, int32_val);
break;
case DBUS_TYPE_UINT32:
dbus_message_iter_get_basic (&array_iter, &uint32_val);
- g_array_append_val (a, uint32_val);
+ egg_dbus_array_seq_add_fixed (a, uint32_val);
break;
case DBUS_TYPE_INT64:
dbus_message_iter_get_basic (&array_iter, &int64_val);
- g_array_append_val (a, int64_val);
+ egg_dbus_array_seq_add_fixed (a, int64_val);
break;
case DBUS_TYPE_UINT64:
dbus_message_iter_get_basic (&array_iter, &uint64_val);
- g_array_append_val (a, uint64_val);
+ egg_dbus_array_seq_add_fixed (a, uint64_val);
break;
case DBUS_TYPE_BOOLEAN:
dbus_message_iter_get_basic (&array_iter, &bool_val);
- g_array_append_val (a, bool_val);
+ egg_dbus_array_seq_add_fixed (a, bool_val);
break;
case DBUS_TYPE_DOUBLE:
dbus_message_iter_get_basic (&array_iter, &double_val);
- g_array_append_val (a, double_val);
+ egg_dbus_array_seq_add_float (a, double_val);
break;
default:
g_assert_not_reached ();
+ break;
}
dbus_message_iter_next (&array_iter);
}
- egg_dbus_array_set_elem_signature (a, elem_signature);
- g_value_init (out_value, EGG_DBUS_TYPE_ARRAY);
- g_value_take_boxed (out_value, a);
+ g_value_init (out_value, EGG_DBUS_TYPE_ARRAY_SEQ);
+ g_value_take_object (out_value, a);
dbus_free (elem_signature);
}
else if (array_arg_type == DBUS_TYPE_STRUCT)
{
DBusMessageIter array_iter;
char *struct_signature;
- GList *list;
+ EggDBusArraySeq *seq;
- list = NULL;
+ seq = egg_dbus_array_seq_new (EGG_DBUS_TYPE_STRUCTURE,
+ g_object_unref,
+ NULL,
+ NULL); /* TODO: have equal_func for structures */
dbus_message_iter_recurse (iter, &array_iter);
struct_signature = dbus_message_iter_get_signature (&array_iter);
- /* now collect all the elements in the structure. These are
- * GObject derived types implementing the EggDBusStructure
- * interface
+ /* now collect all the elements in the structure.
*/
while (dbus_message_iter_get_arg_type (&array_iter) != DBUS_TYPE_INVALID)
{
@@ -1604,34 +1571,31 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
if (!egg_dbus_get_value_from_iter (&array_iter, &elem_value, error))
{
dbus_free (struct_signature);
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ g_object_unref (seq);
goto out;
}
- list = g_list_append (list, g_value_get_object (&elem_value));
+ egg_dbus_array_seq_add (seq, g_value_get_object (&elem_value));
dbus_message_iter_next (&array_iter);
}
- egg_dbus_list_set_elem_signature (list, struct_signature);
-
- g_value_init (out_value, EGG_DBUS_TYPE_LIST);
- g_value_take_boxed (out_value, list);
+ g_value_init (out_value, EGG_DBUS_TYPE_ARRAY_SEQ);
+ g_value_take_object (out_value, seq);
dbus_free (struct_signature);
}
else if (array_arg_type == DBUS_TYPE_DICT_ENTRY)
{
DBusMessageIter array_iter;
- GHashTable *hash_table;
+ EggDBusHashMap *hash_map;
char key_sig[2];
char *val_sig;
char *array_sig;
- GHashFunc key_hash_func;
- GEqualFunc key_equal_func;
GDestroyNotify key_free_func;
GDestroyNotify val_free_func;
+ GType key_type;
+ GType val_type;
dbus_message_iter_recurse (iter, &array_iter);
@@ -1644,6 +1608,9 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
val_sig = g_strdup (array_sig + 2);
val_sig[strlen (val_sig) - 1] = '\0';
+ key_type = egg_dbus_get_type_for_signature (key_sig);
+ val_type = egg_dbus_get_type_for_signature (val_sig);
+
//g_warning ("key_type=%c val_sig='%s'", key_type, val_sig);
/* set up the hash table */
@@ -1656,34 +1623,15 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
case DBUS_TYPE_UINT16:
case DBUS_TYPE_INT32:
case DBUS_TYPE_UINT32:
- key_hash_func = g_direct_hash;
- key_equal_func = g_direct_equal;
- key_free_func = NULL;
- break;
-
case DBUS_TYPE_INT64:
- key_hash_func = egg_dbus_int64_hash;
- key_equal_func = egg_dbus_int64_equal;
- key_free_func = g_free;
- break;
-
case DBUS_TYPE_UINT64:
- key_hash_func = egg_dbus_uint64_hash;
- key_equal_func = egg_dbus_uint64_equal;
- key_free_func = g_free;
- break;
-
case DBUS_TYPE_DOUBLE:
- key_hash_func = egg_dbus_double_hash;
- key_equal_func = egg_dbus_double_equal;
- key_free_func = g_free;
+ key_free_func = NULL;
break;
case DBUS_TYPE_STRING:
case DBUS_TYPE_OBJECT_PATH:
case DBUS_TYPE_SIGNATURE:
- key_hash_func = g_str_hash;
- key_equal_func = g_str_equal;
key_free_func = g_free;
break;
@@ -1700,12 +1648,12 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
case DBUS_TYPE_UINT16:
case DBUS_TYPE_INT32:
case DBUS_TYPE_UINT32:
- val_free_func = NULL;
- break;
-
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
case DBUS_TYPE_DOUBLE:
+ val_free_func = NULL;
+ break;
+
case DBUS_TYPE_STRING:
case DBUS_TYPE_OBJECT_PATH:
case DBUS_TYPE_SIGNATURE:
@@ -1716,6 +1664,7 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
switch (val_sig[1])
{
case DBUS_TYPE_STRING:
+ case DBUS_TYPE_OBJECT_PATH:
case DBUS_TYPE_SIGNATURE:
val_free_func = (GDestroyNotify) g_strfreev;
break;
@@ -1729,15 +1678,9 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
case DBUS_TYPE_DOUBLE:
- val_free_func = (GDestroyNotify) egg_dbus_array_free;
- break;
-
case DBUS_STRUCT_BEGIN_CHAR:
- val_free_func = (GDestroyNotify) egg_dbus_list_free;
- break;
-
case DBUS_DICT_ENTRY_BEGIN_CHAR:
- val_free_func = (GDestroyNotify) egg_dbus_hash_table_unref;
+ val_free_func = (GDestroyNotify) g_object_unref;
break;
default:
@@ -1759,8 +1702,8 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
break;
}
- hash_table = g_hash_table_new_full (key_hash_func, key_equal_func, key_free_func, val_free_func);
- egg_dbus_hash_table_set_signature (hash_table, key_sig, val_sig);
+ hash_map = egg_dbus_hash_map_new (key_type, key_free_func,
+ val_type, val_free_func);
while (dbus_message_iter_get_arg_type (&array_iter) != DBUS_TYPE_INVALID)
{
@@ -1804,20 +1747,17 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
case DBUS_TYPE_INT64:
dbus_message_iter_get_basic (&hash_iter, &int64_val);
- key = g_new (gint64, 1);
- * ((gint64 *) key) = int64_val;
+ key = g_memdup (&int64_val, sizeof (gint64));
break;
case DBUS_TYPE_UINT64:
dbus_message_iter_get_basic (&hash_iter, &uint64_val);
- key = g_new (guint64, 1);
- * ((gint64 *) key) = uint64_val;
+ key = g_memdup (&uint64_val, sizeof (guint64));
break;
case DBUS_TYPE_DOUBLE:
dbus_message_iter_get_basic (&hash_iter, &double_val);
- key = g_new (gdouble, 1);
- * ((double *) key) = double_val;
+ key = g_memdup (&double_val, sizeof (gdouble));
break;
case DBUS_TYPE_STRING:
@@ -1871,20 +1811,17 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
case DBUS_TYPE_INT64:
dbus_message_iter_get_basic (&hash_iter, &int64_val);
- value = g_new (gint64, 1);
- * ((gint64 *) value) = int64_val;
+ value = g_memdup (&int64_val, sizeof (gint64));
break;
case DBUS_TYPE_UINT64:
dbus_message_iter_get_basic (&hash_iter, &uint64_val);
- value = g_new (guint64, 1);
- * ((gint64 *) value) = uint64_val;
+ value = g_memdup (&uint64_val, sizeof (guint64));
break;
case DBUS_TYPE_DOUBLE:
dbus_message_iter_get_basic (&hash_iter, &double_val);
- value = g_new (gdouble, 1);
- * ((double *) value) = double_val;
+ value = g_memdup (&double_val, sizeof (gdouble));
break;
case DBUS_TYPE_UINT32:
@@ -1924,16 +1861,20 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
case DBUS_TYPE_DOUBLE:
+ case DBUS_STRUCT_BEGIN_CHAR:
+ case DBUS_DICT_ENTRY_BEGIN_CHAR:
+ value = g_value_get_object (&array_val);
+ break;
+
case DBUS_TYPE_STRING:
case DBUS_TYPE_OBJECT_PATH:
case DBUS_TYPE_SIGNATURE:
- case DBUS_STRUCT_BEGIN_CHAR:
- case DBUS_DICT_ENTRY_BEGIN_CHAR:
value = g_value_get_boxed (&array_val);
break;
default:
g_assert_not_reached ();
+ break;
}
}
break;
@@ -1963,13 +1904,13 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
break;
}
- g_hash_table_insert (hash_table, key, value);
+ egg_dbus_hash_map_insert (hash_map, key, value);
dbus_message_iter_next (&array_iter);
}
- g_value_init (out_value, EGG_DBUS_TYPE_HASH_TABLE);
- g_value_take_boxed (out_value, hash_table);
+ g_value_init (out_value, EGG_DBUS_TYPE_HASH_MAP);
+ g_value_take_object (out_value, hash_map);
dbus_free (array_sig);
g_free (val_sig);
@@ -1977,19 +1918,21 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
}
else if (array_arg_type == DBUS_TYPE_ARRAY)
{
- GList *list;
+ EggDBusArraySeq *seq;
DBusMessageIter array_iter;
char *elem_signature;
+ GType elem_type;
+ GDestroyNotify elem_free_func;
/* handling array of arrays, e.g.
*
- * - aas: GList of GStrv (char **)
- * - aao: GList of EggDBusObjectPath (char **)
- * - aao: GList of EggDBusSignature (char **)
- * - aai: GList of GArray
- * - aa{ss}: GList of GHashTable
- * - aa(ii): GList of GList containg GObject-derived type
- * - aaas: GList of GList of char**
+ * - aas: EggDBusArraySeq of GStrv (gchar **)
+ * - aao: EggDBusArraySeq of EggDBusObjectPathArray (gchar **)
+ * - aao: EggDBusArraySeq of EggDBusSignatureArray (gchar **)
+ * - aa{ss}: EggDBusArraySeq of EggDBusHashMap
+ * - aai: EggDBusArraySeq of EggDBusArraySeq
+ * - aa(ii): EggDBusArraySeq of EggDBusArraySeq containg GObject-derived type
+ * - aaas: EggDBusArraySeq of EggDBusArraySeq of gchar**
*
*/
@@ -1997,7 +1940,29 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
elem_signature = dbus_message_iter_get_signature (&array_iter);
- list = NULL;
+ elem_type = egg_dbus_get_type_for_signature (elem_signature);
+ if (elem_type == G_TYPE_STRING ||
+ elem_type == EGG_DBUS_TYPE_OBJECT_PATH ||
+ elem_type == EGG_DBUS_TYPE_SIGNATURE)
+ {
+ elem_free_func = g_free;
+ }
+ else if (elem_type == G_TYPE_STRV ||
+ elem_type == EGG_DBUS_TYPE_OBJECT_PATH_ARRAY ||
+ elem_type == EGG_DBUS_TYPE_SIGNATURE_ARRAY)
+ {
+ elem_free_func = (GDestroyNotify) g_strfreev;
+ }
+ else
+ {
+ elem_free_func = g_object_unref;
+ }
+
+ seq = egg_dbus_array_seq_new (elem_type,
+ elem_free_func,
+ NULL, /* use default copy_func */
+ NULL); /* use default equal_func */
+
while (dbus_message_iter_get_arg_type (&array_iter) != DBUS_TYPE_INVALID)
{
GValue elem_val = {0};
@@ -2006,21 +1971,34 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
if (!egg_dbus_get_value_from_iter (&array_iter, &elem_val, error))
goto out;
- list = g_list_append (list, g_value_get_boxed (&elem_val));
+ if (elem_type == G_TYPE_STRING)
+ {
+ egg_dbus_array_seq_add (seq, g_value_get_string (&elem_val));
+ }
+ else if (elem_type == EGG_DBUS_TYPE_OBJECT_PATH ||
+ elem_type == EGG_DBUS_TYPE_SIGNATURE ||
+ elem_type == G_TYPE_STRV ||
+ elem_type == EGG_DBUS_TYPE_OBJECT_PATH_ARRAY ||
+ elem_type == EGG_DBUS_TYPE_SIGNATURE_ARRAY)
+ {
+ egg_dbus_array_seq_add (seq, g_value_get_boxed (&elem_val));
+ }
+ else
+ {
+ egg_dbus_array_seq_add (seq, g_value_get_object (&elem_val));
+ }
dbus_message_iter_next (&array_iter);
} /* for all elements in array */
- egg_dbus_list_set_elem_signature (list, elem_signature);
-
- g_value_init (out_value, EGG_DBUS_TYPE_LIST);
- g_value_take_boxed (out_value, list);
+ g_value_init (out_value, EGG_DBUS_TYPE_ARRAY_SEQ);
+ g_value_take_object (out_value, seq);
dbus_free (elem_signature);
}
else if (array_arg_type == DBUS_TYPE_VARIANT)
{
- GList *list;
+ EggDBusArraySeq *seq;
DBusMessageIter array_iter;
char *elem_signature;
@@ -2030,7 +2008,11 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
elem_signature = dbus_message_iter_get_signature (&array_iter);
- list = NULL;
+ seq = egg_dbus_array_seq_new (EGG_DBUS_TYPE_VARIANT,
+ g_object_unref,
+ NULL,
+ NULL); /* TODO: equal_func */
+
while (dbus_message_iter_get_arg_type (&array_iter) != DBUS_TYPE_INVALID)
{
GValue elem_val = {0};
@@ -2039,15 +2021,13 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
if (!egg_dbus_get_value_from_iter (&array_iter, &elem_val, error))
goto out;
- list = g_list_append (list, g_value_get_object (&elem_val));
+ egg_dbus_array_seq_add (seq, g_value_get_object (&elem_val));
dbus_message_iter_next (&array_iter);
} /* for all elements in array */
- egg_dbus_list_set_elem_signature (list, elem_signature);
-
- g_value_init (out_value, EGG_DBUS_TYPE_LIST);
- g_value_take_boxed (out_value, list);
+ g_value_init (out_value, EGG_DBUS_TYPE_ARRAY_SEQ);
+ g_value_take_object (out_value, seq);
dbus_free (elem_signature);
}
@@ -2113,9 +2093,9 @@ egg_dbus_get_value_from_iter (DBusMessageIter *iter,
static gboolean
egg_dbus_append_value_to_iter (DBusMessageIter *iter,
- const gchar *signature,
- const GValue *value,
- GError **error)
+ const gchar *signature,
+ const GValue *value,
+ GError **error)
{
gboolean ret;
@@ -2196,9 +2176,11 @@ egg_dbus_append_value_to_iter (DBusMessageIter *iter,
signature[1] == DBUS_TYPE_BOOLEAN)
{
DBusMessageIter array_iter;
- GArray *array = g_value_get_boxed (value);
+ EggDBusArraySeq *seq;
+
+ seq = EGG_DBUS_ARRAY_SEQ (g_value_get_object (value));
dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, signature + 1, &array_iter);
- dbus_message_iter_append_fixed_array (&array_iter, signature[1], &(array->data), array->len);
+ dbus_message_iter_append_fixed_array (&array_iter, signature[1], &(seq->data.data), seq->size);
dbus_message_iter_close_container (iter, &array_iter);
}
else if (signature[1] == DBUS_TYPE_STRING ||
@@ -2206,8 +2188,10 @@ egg_dbus_append_value_to_iter (DBusMessageIter *iter,
signature[1] == DBUS_TYPE_SIGNATURE)
{
DBusMessageIter array_iter;
- char **strv = g_value_get_boxed (value);
- int n;
+ gchar **strv;
+ guint n;
+
+ strv = (gchar **) g_value_get_boxed (value);
dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, signature + 1, &array_iter);
for (n = 0; strv[n] != NULL; n++)
dbus_message_iter_append_basic (&array_iter, signature[1], &(strv[n]));
@@ -2216,14 +2200,16 @@ egg_dbus_append_value_to_iter (DBusMessageIter *iter,
else if (signature[1] == DBUS_STRUCT_BEGIN_CHAR)
{
DBusMessageIter array_iter;
- GList *list = g_value_get_boxed (value);
- GList *l;
+ EggDBusArraySeq *seq;
+ guint n;
+
+ seq = EGG_DBUS_ARRAY_SEQ (g_value_get_object (value));
dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, signature + 1, &array_iter);
- for (l = list; l != NULL; l = l->next)
+ for (n = 0; n < seq->size; n++)
{
GValue val = {0};
- g_value_init (&val, G_TYPE_OBJECT);
- g_value_take_object (&val, G_OBJECT (l->data));
+ g_value_init (&val, EGG_DBUS_TYPE_STRUCTURE);
+ g_value_take_object (&val, EGG_DBUS_STRUCTURE (seq->data.v_ptr[n]));
/* recursive dance */
if (!egg_dbus_append_value_to_iter (&array_iter, signature + 1, &val, error))
goto out;
@@ -2233,21 +2219,25 @@ egg_dbus_append_value_to_iter (DBusMessageIter *iter,
else if (signature[1] == DBUS_DICT_ENTRY_BEGIN_CHAR)
{
DBusMessageIter array_iter;
- GHashTable *hash_table = g_value_get_boxed (value);
+ EggDBusHashMap *hash_map;
+ GHashTable *hash_table;
GHashTableIter hash_iter;
- gpointer key;
- gpointer value;
+ gpointer hash_key;
+ gpointer hash_value;
char *value_signature;
value_signature = g_strdup (signature + 3);
value_signature[strlen (value_signature) - 1] = '\0';
+ hash_map = EGG_DBUS_HASH_MAP (g_value_get_object (value));
+ hash_table = hash_map->data;
+
//g_warning ("value_signature='%s'", value_signature);
dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, signature + 1, &array_iter);
g_hash_table_iter_init (&hash_iter, hash_table);
/* TODO: handle passing in NULL for an empty hash table */
- while (g_hash_table_iter_next (&hash_iter, &key, &value))
+ while (g_hash_table_iter_next (&hash_iter, &hash_key, &hash_value))
{
GValue val = {0};
DBusMessageIter dict_iter;
@@ -2267,17 +2257,17 @@ egg_dbus_append_value_to_iter (DBusMessageIter *iter,
case DBUS_TYPE_UINT16:
case DBUS_TYPE_INT32:
case DBUS_TYPE_UINT32:
- dbus_message_iter_append_basic (&dict_iter, signature[2], &key);
+ dbus_message_iter_append_basic (&dict_iter, signature[2], &hash_key);
break;
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
case DBUS_TYPE_DOUBLE:
- dbus_message_iter_append_basic (&dict_iter, signature[2], key);
+ dbus_message_iter_append_basic (&dict_iter, signature[2], hash_key);
break;
default:
- /* the D-Bus spec says the key must be a basic type */
+ /* the D-Bus spec says the hash_key must be a basic type */
g_assert_not_reached ();
break;
}
@@ -2293,18 +2283,18 @@ egg_dbus_append_value_to_iter (DBusMessageIter *iter,
case DBUS_TYPE_UINT16:
case DBUS_TYPE_INT32:
case DBUS_TYPE_UINT32:
- dbus_message_iter_append_basic (&dict_iter, signature[2], &value);
+ dbus_message_iter_append_basic (&dict_iter, signature[2], &hash_value);
break;
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
case DBUS_TYPE_DOUBLE:
- dbus_message_iter_append_basic (&dict_iter, signature[2], value);
+ dbus_message_iter_append_basic (&dict_iter, signature[2], hash_value);
break;
case DBUS_STRUCT_BEGIN_CHAR:
g_value_init (&val, G_TYPE_OBJECT);
- g_value_take_object (&val, G_OBJECT (value));
+ g_value_take_object (&val, G_OBJECT (hash_value));
/* recursive dance */
if (!egg_dbus_append_value_to_iter (&dict_iter, value_signature, &val, error))
goto out;
@@ -2321,8 +2311,8 @@ egg_dbus_append_value_to_iter (DBusMessageIter *iter,
value_signature[1] == DBUS_TYPE_BOOLEAN ||
value_signature[1] == DBUS_TYPE_DOUBLE)
{
- g_value_init (&val, EGG_DBUS_TYPE_ARRAY);
- g_value_set_static_boxed (&val, value);
+ g_value_init (&val, EGG_DBUS_TYPE_ARRAY_SEQ);
+ g_value_take_object (&val, hash_value);
/* recurse */
if (!egg_dbus_append_value_to_iter (&dict_iter, value_signature, &val, error))
goto out;
@@ -2341,31 +2331,31 @@ egg_dbus_append_value_to_iter (DBusMessageIter *iter,
boxed_type = EGG_DBUS_TYPE_SIGNATURE_ARRAY;
g_value_init (&val, boxed_type);
- g_value_set_static_boxed (&val, value);
+ g_value_set_static_boxed (&val, hash_value);
/* recurse */
if (!egg_dbus_append_value_to_iter (&dict_iter, value_signature, &val, error))
goto out;
}
else if (value_signature[1] == DBUS_STRUCT_BEGIN_CHAR)
{
- g_value_init (&val, EGG_DBUS_TYPE_LIST);
- g_value_set_static_boxed (&val, value);
+ g_value_init (&val, EGG_DBUS_TYPE_ARRAY_SEQ);
+ g_value_take_object (&val, hash_value);
/* recurse */
if (!egg_dbus_append_value_to_iter (&dict_iter, value_signature, &val, error))
goto out;
}
else if (value_signature[1] == DBUS_DICT_ENTRY_BEGIN_CHAR)
{
- g_value_init (&val, EGG_DBUS_TYPE_LIST);
- g_value_set_static_boxed (&val, value);
+ g_value_init (&val, EGG_DBUS_TYPE_ARRAY_SEQ);
+ g_value_take_object (&val, hash_value);
/* recurse */
if (!egg_dbus_append_value_to_iter (&dict_iter, value_signature, &val, error))
goto out;
}
else if (value_signature[1] == DBUS_TYPE_VARIANT)
{
- g_value_init (&val, EGG_DBUS_TYPE_LIST);
- g_value_set_static_boxed (&val, value);
+ g_value_init (&val, EGG_DBUS_TYPE_ARRAY_SEQ);
+ g_value_take_object (&val, hash_value);
/* recurse */
if (!egg_dbus_append_value_to_iter (&dict_iter, value_signature, &val, error))
goto out;
@@ -2378,7 +2368,7 @@ egg_dbus_append_value_to_iter (DBusMessageIter *iter,
case DBUS_TYPE_VARIANT:
g_value_init (&val, EGG_DBUS_TYPE_VARIANT);
- g_value_take_object (&val, value);
+ g_value_take_object (&val, hash_value);
/* recurse */
if (!egg_dbus_append_value_to_iter (&dict_iter, value_signature, &val, error))
goto out;
@@ -2398,16 +2388,17 @@ egg_dbus_append_value_to_iter (DBusMessageIter *iter,
else if (signature[1] == DBUS_TYPE_ARRAY) /* array of an array */
{
DBusMessageIter array_iter;
- GList *list = g_value_get_boxed (value);
- GList *l;
- dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, signature + 1, &array_iter);
+ EggDBusArraySeq *seq;
+ guint n;
- for (l = list; l != NULL; l = l->next)
+ seq = EGG_DBUS_ARRAY_SEQ (g_value_get_object (value));
+ dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, signature + 1, &array_iter);
+ for (n = 0; n < seq->size; n++)
{
GValue val = {0};
g_value_init (&val, egg_dbus_get_type_for_signature (signature + 1));
- g_value_set_static_boxed (&val, l->data);
+ g_value_set_static_boxed (&val, seq->data.v_ptr[n]);
/* recursive dance */
if (!egg_dbus_append_value_to_iter (&array_iter, signature + 1, &val, error))
@@ -2419,16 +2410,17 @@ egg_dbus_append_value_to_iter (DBusMessageIter *iter,
else if (signature[1] == DBUS_TYPE_VARIANT ) /* array of variants */
{
DBusMessageIter array_iter;
- GList *list = g_value_get_boxed (value);
- GList *l;
- dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, signature + 1, &array_iter);
+ EggDBusArraySeq *seq;
+ guint n;
- for (l = list; l != NULL; l = l->next)
+ seq = EGG_DBUS_ARRAY_SEQ (g_value_get_object (value));
+ dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, signature + 1, &array_iter);
+ for (n = 0; n < seq->size; n++)
{
GValue val = {0};
g_value_init (&val, EGG_DBUS_TYPE_VARIANT);
- g_value_take_object (&val, l->data);
+ g_value_take_object (&val, seq->data.v_ptr[n]);
/* recursive dance */
if (!egg_dbus_append_value_to_iter (&array_iter, signature + 1, &val, error))
diff --git a/src/eggdbus/eggdbusmessage.h b/src/eggdbus/eggdbusmessage.h
index a8daa23..625ba60 100644
--- a/src/eggdbus/eggdbusmessage.h
+++ b/src/eggdbus/eggdbusmessage.h
@@ -159,18 +159,13 @@ gboolean egg_dbus_message_append_double (EggDBusMessage *mes
gdouble value,
GError **error);
-gboolean egg_dbus_message_append_array (EggDBusMessage *message,
- GArray *array,
- const gchar *elem_signature,
+gboolean egg_dbus_message_append_seq (EggDBusMessage *message,
+ EggDBusArraySeq *seq,
+ const gchar *element_signature,
GError **error);
-gboolean egg_dbus_message_append_list (EggDBusMessage *message,
- GList *list,
- const gchar *elem_signature,
- GError **error);
-
-gboolean egg_dbus_message_append_hash_table (EggDBusMessage *message,
- GHashTable *hash_table,
+gboolean egg_dbus_message_append_map (EggDBusMessage *message,
+ EggDBusHashMap *map,
const gchar *key_signature,
const gchar *value_signature,
GError **error);
@@ -250,16 +245,12 @@ gboolean egg_dbus_message_extract_double (EggDBusMessage *m
gdouble *out_value,
GError **error);
-gboolean egg_dbus_message_extract_array (EggDBusMessage *message,
- EggDBusArray **out_array,
+gboolean egg_dbus_message_extract_seq (EggDBusMessage *message,
+ EggDBusArraySeq **out_seq,
GError **error);
-gboolean egg_dbus_message_extract_list (EggDBusMessage *message,
- EggDBusList **out_list,
- GError **error);
-
-gboolean egg_dbus_message_extract_hash_table (EggDBusMessage *message,
- EggDBusHashTable **out_hash_table,
+gboolean egg_dbus_message_extract_map (EggDBusMessage *message,
+ EggDBusHashMap **out_map,
GError **error);
gboolean egg_dbus_message_extract_structure (EggDBusMessage *message,
diff --git a/src/eggdbus/eggdbusobjectproxy.c b/src/eggdbus/eggdbusobjectproxy.c
index ea712f4..2afaadd 100644
--- a/src/eggdbus/eggdbusobjectproxy.c
+++ b/src/eggdbus/eggdbusobjectproxy.c
@@ -33,9 +33,9 @@
#include <eggdbus/eggdbuspeer.h>
#include <eggdbus/eggdbusbus.h>
#include <eggdbus/eggdbusproperties.h>
-#include <eggdbus/eggdbushashtable.h>
#include <eggdbus/eggdbusvariant.h>
#include <eggdbus/eggdbusintrospectable.h>
+#include <eggdbus/eggdbushashmap.h>
/**
* SECTION:eggdbusobjectproxy
@@ -244,7 +244,7 @@ _egg_dbus_object_proxy_handle_message (EggDBusObjectProxy *object_proxy,
strcmp (signal_name, "EggDBusChanged") == 0)
{
gchar *prop_interface_name;
- EggDBusHashTable *changed_properties;
+ EggDBusHashMap *changed_properties;
GError *error;
signal_message = egg_dbus_connection_new_message_for_signal (priv->connection,
@@ -270,7 +270,7 @@ _egg_dbus_object_proxy_handle_message (EggDBusObjectProxy *object_proxy,
goto prop_extract_failed;
}
- if (!egg_dbus_message_extract_hash_table (signal_message, &changed_properties, &error))
+ if (!egg_dbus_message_extract_map (signal_message, &changed_properties, &error))
{
g_warning ("Error extracting interface name when handling EggDBusChanged() on "
"org.freedesktop.DBus.Properties: %s", error->message);
@@ -297,7 +297,7 @@ _egg_dbus_object_proxy_handle_message (EggDBusObjectProxy *object_proxy,
}
g_free (prop_interface_name);
- egg_dbus_hash_table_unref (changed_properties);
+ g_object_unref (changed_properties);
prop_extract_failed:
diff --git a/src/eggdbus/eggdbusprivate.h b/src/eggdbus/eggdbusprivate.h
index 871debe..b4ddee7 100644
--- a/src/eggdbus/eggdbusprivate.h
+++ b/src/eggdbus/eggdbusprivate.h
@@ -75,7 +75,7 @@ void _egg_dbus_error_set_remote_exception (GError **error,
...) G_GNUC_PRINTF (5, 6);
void _egg_dbus_interface_proxy_handle_property_changed (EggDBusInterfaceProxy *interface_proxy,
- EggDBusHashTable *changed_properties);
+ EggDBusHashMap *changed_properties);
void _egg_dbus_interface_proxy_invalidate_properties (EggDBusInterfaceProxy *interface_proxy);
diff --git a/src/eggdbus/eggdbusstructure.c b/src/eggdbus/eggdbusstructure.c
index 9cb8ed1..d558520 100644
--- a/src/eggdbus/eggdbusstructure.c
+++ b/src/eggdbus/eggdbusstructure.c
@@ -26,10 +26,10 @@
#include <gobject/gvaluecollector.h>
#include <eggdbus/eggdbusstructure.h>
#include <eggdbus/eggdbusutils.h>
-#include <eggdbus/eggdbuslist.h>
-#include <eggdbus/eggdbushashtable.h>
#include <eggdbus/eggdbusvariant.h>
#include <eggdbus/eggdbustypes.h>
+#include <eggdbus/eggdbusarrayseq.h>
+#include <eggdbus/eggdbushashmap.h>
/**
* SECTION:eggdbusstructure
@@ -670,6 +670,7 @@ egg_dbus_structure_get_signature_for_element (EggDBusStructure *structure,
return priv->elem_signatures[elem_number];
}
+#if 0
void
egg_dbus_structure_print (EggDBusStructure *structure,
guint indent)
@@ -703,8 +704,8 @@ egg_dbus_structure_print (EggDBusStructure *structure,
/* simple types can be printed on the same line */
simple = TRUE;
- if (G_VALUE_HOLDS (&value, EGG_DBUS_TYPE_LIST) ||
- G_VALUE_HOLDS (&value, EGG_DBUS_TYPE_HASH_TABLE) ||
+ if (G_VALUE_HOLDS (&value, EGG_DBUS_TYPE_ARRAY_SEQ) ||
+ G_VALUE_HOLDS (&value, EGG_DBUS_TYPE_HASH_MAP) ||
G_VALUE_HOLDS (&value, EGG_DBUS_TYPE_STRUCTURE) ||
G_VALUE_HOLDS (&value, EGG_DBUS_TYPE_VARIANT))
simple = FALSE;
@@ -721,6 +722,7 @@ egg_dbus_structure_print (EggDBusStructure *structure,
g_free (name);
}
}
+#endif
gpointer
egg_dbus_structure_type_check_instance_cast (gpointer instance,
diff --git a/src/eggdbus/eggdbustypes.c b/src/eggdbus/eggdbustypes.c
index 8f6c4af..597ea83 100644
--- a/src/eggdbus/eggdbustypes.c
+++ b/src/eggdbus/eggdbustypes.c
@@ -25,9 +25,6 @@
#include <dbus/dbus.h>
#include <eggdbus/eggdbustypes.h>
#include <eggdbus/eggdbusprivate.h>
-#include <eggdbus/eggdbusarray.h>
-#include <eggdbus/eggdbuslist.h>
-#include <eggdbus/eggdbushashtable.h>
#include <eggdbus/eggdbusvariant.h>
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/eggdbus/eggdbustypes.h b/src/eggdbus/eggdbustypes.h
index f04f0ff..9414417 100644
--- a/src/eggdbus/eggdbustypes.h
+++ b/src/eggdbus/eggdbustypes.h
@@ -32,12 +32,6 @@
G_BEGIN_DECLS
-typedef GArray EggDBusArray;
-
-typedef GList EggDBusList;
-
-typedef GHashTable EggDBusHashTable;
-
typedef struct _EggDBusConnection EggDBusConnection;
typedef struct _EggDBusObjectProxy EggDBusObjectProxy;
diff --git a/src/eggdbus/eggdbusutils.c b/src/eggdbus/eggdbusutils.c
index 8ad68df..990cc47 100644
--- a/src/eggdbus/eggdbusutils.c
+++ b/src/eggdbus/eggdbusutils.c
@@ -27,11 +27,10 @@
#include <eggdbus/eggdbusobjectpath.h>
#include <eggdbus/eggdbussignature.h>
#include <eggdbus/eggdbusutils.h>
-#include <eggdbus/eggdbusarray.h>
-#include <eggdbus/eggdbuslist.h>
-#include <eggdbus/eggdbushashtable.h>
#include <eggdbus/eggdbusstructure.h>
#include <eggdbus/eggdbusvariant.h>
+#include <eggdbus/eggdbusarrayseq.h>
+#include <eggdbus/eggdbushashmap.h>
/* ---------------------------------------------------------------------------------------------------- */
@@ -231,7 +230,7 @@ egg_dbus_param_spec_for_signature (const gchar *name,
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
case DBUS_TYPE_DOUBLE:
- pspec = g_param_spec_boxed (name, nick, blurb, EGG_DBUS_TYPE_ARRAY, flags);
+ pspec = g_param_spec_object (name, nick, blurb, EGG_DBUS_TYPE_ARRAY_SEQ, flags);
break;
case DBUS_TYPE_STRING:
@@ -247,12 +246,12 @@ egg_dbus_param_spec_for_signature (const gchar *name,
break;
case DBUS_DICT_ENTRY_BEGIN_CHAR:
- pspec = g_param_spec_boxed (name, nick, blurb, EGG_DBUS_TYPE_HASH_TABLE, flags);
+ pspec = g_param_spec_object (name, nick, blurb, EGG_DBUS_TYPE_HASH_MAP, flags);
break;
case DBUS_TYPE_ARRAY:
case DBUS_STRUCT_BEGIN_CHAR:
- pspec = g_param_spec_boxed (name, nick, blurb, EGG_DBUS_TYPE_LIST, flags);
+ pspec = g_param_spec_object (name, nick, blurb, EGG_DBUS_TYPE_ARRAY_SEQ, flags);
break;
default:
@@ -367,6 +366,7 @@ print_simple (const GValue *value, const gchar *signature, guint indent)
g_free (str_value);
}
+#if 0
void
egg_dbus_utils_print_gvalue (const GValue *value,
const gchar *signature,
@@ -398,6 +398,7 @@ egg_dbus_utils_print_gvalue (const GValue *value,
print_simple (value, signature, indent);
}
}
+#endif
/* ---------------------------------------------------------------------------------------------------- */
@@ -447,7 +448,7 @@ egg_dbus_get_type_for_signature (const gchar *signature)
signature[1] == DBUS_TYPE_UINT64 ||
signature[1] == DBUS_TYPE_DOUBLE ||
signature[1] == DBUS_TYPE_BOOLEAN)
- type = EGG_DBUS_TYPE_ARRAY;
+ type = EGG_DBUS_TYPE_ARRAY_SEQ;
else if (signature[1] == DBUS_TYPE_STRING)
type = G_TYPE_STRV;
else if (signature[1] == DBUS_TYPE_OBJECT_PATH)
@@ -455,9 +456,9 @@ egg_dbus_get_type_for_signature (const gchar *signature)
else if (signature[1] == DBUS_TYPE_SIGNATURE)
type = EGG_DBUS_TYPE_SIGNATURE_ARRAY;
else if (signature[1] == DBUS_DICT_ENTRY_BEGIN_CHAR)
- type = EGG_DBUS_TYPE_HASH_TABLE;
+ type = EGG_DBUS_TYPE_HASH_MAP;
else
- type = EGG_DBUS_TYPE_LIST;
+ type = EGG_DBUS_TYPE_ARRAY_SEQ;
}
if (type == G_TYPE_INVALID)
diff --git a/src/eggdbus/eggdbusutils.h b/src/eggdbus/eggdbusutils.h
index 3098098..132a04c 100644
--- a/src/eggdbus/eggdbusutils.h
+++ b/src/eggdbus/eggdbusutils.h
@@ -46,7 +46,7 @@ GParamSpec *egg_dbus_param_spec_for_signature (const gchar *signature,
const gchar *blurb,
GParamFlags flags);
-GType egg_dbus_get_type_for_signature (const gchar *signature);
+GType egg_dbus_get_type_for_signature (const gchar *signature);
G_END_DECLS
diff --git a/src/eggdbus/eggdbusvariant.c b/src/eggdbus/eggdbusvariant.c
index 84f8b57..ee113ee 100644
--- a/src/eggdbus/eggdbusvariant.c
+++ b/src/eggdbus/eggdbusvariant.c
@@ -30,9 +30,8 @@
#include <eggdbus/eggdbusstructure.h>
#include <eggdbus/eggdbusutils.h>
#include <eggdbus/eggdbustypes.h>
-#include <eggdbus/eggdbusarray.h>
-#include <eggdbus/eggdbuslist.h>
-#include <eggdbus/eggdbushashtable.h>
+#include <eggdbus/eggdbusarrayseq.h>
+#include <eggdbus/eggdbushashmap.h>
#include <eggdbus/eggdbusvariant.h>
#include <eggdbus/eggdbusprivate.h>
@@ -154,6 +153,7 @@ egg_dbus_variant_get_variant_signature (EggDBusVariant *variant)
return priv->signature;
}
+#if 0
void
egg_dbus_variant_print (EggDBusVariant *variant,
guint indent)
@@ -173,8 +173,8 @@ egg_dbus_variant_print (EggDBusVariant *variant,
/* simple types can be printed on the same line */
simple = TRUE;
- if (G_VALUE_HOLDS (&priv->value, EGG_DBUS_TYPE_LIST) ||
- G_VALUE_HOLDS (&priv->value, EGG_DBUS_TYPE_HASH_TABLE) ||
+ if (G_VALUE_HOLDS (&priv->value, EGG_DBUS_TYPE_ARRAY_SEQ) ||
+ G_VALUE_HOLDS (&priv->value, EGG_DBUS_TYPE_HASH_MAP) ||
G_VALUE_HOLDS (&priv->value, EGG_DBUS_TYPE_STRUCTURE) ||
G_VALUE_HOLDS (&priv->value, EGG_DBUS_TYPE_VARIANT))
simple = FALSE;
@@ -188,7 +188,7 @@ egg_dbus_variant_print (EggDBusVariant *variant,
priv->signature,
indent + 4);
}
-
+#endif
static void
set_signature (EggDBusVariant *variant,
@@ -263,7 +263,7 @@ egg_dbus_variant_new (void)
EggDBusVariant *
egg_dbus_variant_new_for_gvalue (const GValue *value,
- const gchar *signature)
+ const gchar *signature)
{
EggDBusVariant *variant;
EggDBusVariantPrivate *priv;
@@ -416,29 +416,23 @@ egg_dbus_variant_new_for_double (gdouble value)
}
EggDBusVariant *
-egg_dbus_variant_new_for_array (EggDBusArray *array)
-{
- EggDBusVariant *variant;
- variant = egg_dbus_variant_new ();
- egg_dbus_variant_set_array (variant, array);
- return variant;
-}
-
-EggDBusVariant *
-egg_dbus_variant_new_for_list (EggDBusList *list)
+egg_dbus_variant_new_for_seq (EggDBusArraySeq *seq,
+ const gchar *element_signature)
{
EggDBusVariant *variant;
variant = egg_dbus_variant_new ();
- egg_dbus_variant_set_list (variant, list);
+ egg_dbus_variant_set_seq (variant, seq, element_signature);
return variant;
}
EggDBusVariant *
-egg_dbus_variant_new_for_hash_table (EggDBusHashTable *hash_table)
+egg_dbus_variant_new_for_map (EggDBusHashMap *hash_map,
+ const gchar *key_signature,
+ const gchar *value_signature)
{
EggDBusVariant *variant;
variant = egg_dbus_variant_new ();
- egg_dbus_variant_set_hash_table (variant, hash_table);
+ egg_dbus_variant_set_map (variant, hash_map, key_signature, value_signature);
return variant;
}
@@ -650,52 +644,41 @@ egg_dbus_variant_set_double (EggDBusVariant *variant,
}
void
-egg_dbus_variant_set_array (EggDBusVariant *variant,
- EggDBusArray *array)
+egg_dbus_variant_set_seq (EggDBusVariant *variant,
+ EggDBusArraySeq *seq,
+ const gchar *element_signature)
{
EggDBusVariantPrivate *priv;
g_return_if_fail (EGG_DBUS_IS_VARIANT (variant));
priv = EGG_DBUS_VARIANT_GET_PRIVATE (variant);
if (priv->signature != NULL)
g_value_unset (&priv->value);
- g_value_init (&priv->value, EGG_DBUS_TYPE_ARRAY);
- g_value_set_boxed (&priv->value, array);
- set_signature_for_array (variant, egg_dbus_array_get_elem_signature (array));
+ g_value_init (&priv->value, EGG_DBUS_TYPE_ARRAY_SEQ);
+ g_value_set_object (&priv->value, seq);
+ set_signature_for_array (variant, element_signature);
}
void
-egg_dbus_variant_set_list (EggDBusVariant *variant,
- EggDBusList *list)
+egg_dbus_variant_set_map (EggDBusVariant *variant,
+ EggDBusHashMap *map,
+ const gchar *key_signature,
+ const gchar *value_signature)
{
EggDBusVariantPrivate *priv;
g_return_if_fail (EGG_DBUS_IS_VARIANT (variant));
priv = EGG_DBUS_VARIANT_GET_PRIVATE (variant);
if (priv->signature != NULL)
g_value_unset (&priv->value);
- g_value_init (&priv->value, EGG_DBUS_TYPE_LIST);
- g_value_set_boxed (&priv->value, list);
- set_signature_for_array (variant, egg_dbus_list_get_elem_signature (list));
-}
-
-void
-egg_dbus_variant_set_hash_table (EggDBusVariant *variant,
- EggDBusHashTable *hash_table)
-{
- EggDBusVariantPrivate *priv;
- g_return_if_fail (EGG_DBUS_IS_VARIANT (variant));
- priv = EGG_DBUS_VARIANT_GET_PRIVATE (variant);
- if (priv->signature != NULL)
- g_value_unset (&priv->value);
- g_value_init (&priv->value, EGG_DBUS_TYPE_HASH_TABLE);
- g_value_set_boxed (&priv->value, hash_table);
+ g_value_init (&priv->value, EGG_DBUS_TYPE_HASH_MAP);
+ g_value_set_object (&priv->value, map);
set_signature_for_hash_table (variant,
- egg_dbus_hash_table_get_key_signature (hash_table),
- egg_dbus_hash_table_get_value_signature (hash_table));
+ key_signature,
+ value_signature);
}
void
-egg_dbus_variant_set_structure (EggDBusVariant *variant,
- EggDBusStructure *structure)
+egg_dbus_variant_set_structure (EggDBusVariant *variant,
+ EggDBusStructure *structure)
{
EggDBusVariantPrivate *priv;
g_return_if_fail (EGG_DBUS_IS_VARIANT (variant));
@@ -835,31 +818,22 @@ egg_dbus_variant_get_double (EggDBusVariant *variant)
return g_value_get_double (&priv->value);
}
-EggDBusArray *
-egg_dbus_variant_get_array (EggDBusVariant *variant)
+EggDBusArraySeq *
+egg_dbus_variant_get_seq (EggDBusVariant *variant)
{
EggDBusVariantPrivate *priv;
- g_return_val_if_fail (EGG_DBUS_IS_VARIANT (variant) && egg_dbus_variant_is_array (variant), NULL);
+ g_return_val_if_fail (EGG_DBUS_IS_VARIANT (variant) && egg_dbus_variant_is_seq (variant), NULL);
priv = EGG_DBUS_VARIANT_GET_PRIVATE (variant);
- return g_value_get_boxed (&priv->value);
-}
-
-EggDBusList *
-egg_dbus_variant_get_list (EggDBusVariant *variant)
-{
- EggDBusVariantPrivate *priv;
- g_return_val_if_fail (EGG_DBUS_IS_VARIANT (variant) && egg_dbus_variant_is_list (variant), NULL);
- priv = EGG_DBUS_VARIANT_GET_PRIVATE (variant);
- return g_value_get_boxed (&priv->value);
+ return g_value_get_object (&priv->value);
}
-EggDBusHashTable *
-egg_dbus_variant_get_hash_table (EggDBusVariant *variant)
+EggDBusHashMap *
+egg_dbus_variant_get_map (EggDBusVariant *variant)
{
EggDBusVariantPrivate *priv;
- g_return_val_if_fail (EGG_DBUS_IS_VARIANT (variant) && egg_dbus_variant_is_hash_table (variant), NULL);
+ g_return_val_if_fail (EGG_DBUS_IS_VARIANT (variant) && egg_dbus_variant_is_map (variant), NULL);
priv = EGG_DBUS_VARIANT_GET_PRIVATE (variant);
- return g_value_get_boxed (&priv->value);
+ return g_value_get_object (&priv->value);
}
EggDBusStructure *
@@ -1040,7 +1014,7 @@ egg_dbus_variant_is_double (EggDBusVariant *variant)
}
gboolean
-egg_dbus_variant_is_array (EggDBusVariant *variant)
+egg_dbus_variant_is_seq (EggDBusVariant *variant)
{
EggDBusVariantPrivate *priv;
priv = EGG_DBUS_VARIANT_GET_PRIVATE (variant);
@@ -1055,25 +1029,14 @@ egg_dbus_variant_is_array (EggDBusVariant *variant)
priv->signature[1] == 'x' ||
priv->signature[1] == 't' ||
priv->signature[1] == 'd' ||
- priv->signature[1] == 'b');
-}
-
-gboolean
-egg_dbus_variant_is_list (EggDBusVariant *variant)
-{
- EggDBusVariantPrivate *priv;
- priv = EGG_DBUS_VARIANT_GET_PRIVATE (variant);
- g_return_val_if_fail (EGG_DBUS_IS_VARIANT (variant), FALSE);
- return
- priv->signature != NULL &&
- priv->signature[0] == 'a' &&
- (priv->signature[1] == 'a' ||
+ priv->signature[1] == 'b' ||
+ priv->signature[1] == 'a' ||
priv->signature[1] == 'v' ||
priv->signature[1] == '(');
}
gboolean
-egg_dbus_variant_is_hash_table (EggDBusVariant *variant)
+egg_dbus_variant_is_map (EggDBusVariant *variant)
{
EggDBusVariantPrivate *priv;
priv = EGG_DBUS_VARIANT_GET_PRIVATE (variant);
@@ -1096,105 +1059,3 @@ egg_dbus_variant_is_structure (EggDBusVariant *variant)
}
/* ---------------------------------------------------------------------------------------------------- */
-
-EggDBusVariant *
-egg_dbus_variant_new_for_array_with_signature (GArray *array,
- const gchar *elem_signature)
-{
- EggDBusVariant *variant;
- variant = egg_dbus_variant_new ();
- egg_dbus_variant_set_array_with_signature (variant, array, elem_signature);
- return variant;
-}
-
-EggDBusVariant *
-egg_dbus_variant_new_for_list_with_signature (EggDBusList *list,
- const gchar *elem_signature)
-{
- EggDBusVariant *variant;
- variant = egg_dbus_variant_new ();
- egg_dbus_variant_set_list_with_signature (variant, list, elem_signature);
- return variant;
-}
-
-EggDBusVariant *
-egg_dbus_variant_new_for_hash_table_with_signature (EggDBusHashTable *hash_table,
- const gchar *key_signature,
- const gchar *value_signature)
-{
- EggDBusVariant *variant;
- variant = egg_dbus_variant_new ();
- egg_dbus_variant_set_hash_table_with_signature (variant, hash_table, key_signature, value_signature);
- return variant;
-}
-
-void
-egg_dbus_variant_set_array_with_signature (EggDBusVariant *variant,
- GArray *array,
- const gchar *elem_signature)
-{
- EggDBusVariantPrivate *priv;
-
- g_return_if_fail (EGG_DBUS_IS_VARIANT (variant));
-
- priv = EGG_DBUS_VARIANT_GET_PRIVATE (variant);
- if (priv->signature != NULL)
- g_value_unset (&priv->value);
- g_value_init (&priv->value, EGG_DBUS_TYPE_ARRAY);
-
- egg_dbus_array_set_elem_signature (array, elem_signature);
-
- g_value_set_boxed (&priv->value, array);
- set_signature_for_array (variant, elem_signature);
-
- egg_dbus_array_set_elem_signature (array, NULL);
-}
-
-void
-egg_dbus_variant_set_list_with_signature (EggDBusVariant *variant,
- GList *list,
- const gchar *elem_signature)
-{
- EggDBusVariantPrivate *priv;
-
- g_return_if_fail (EGG_DBUS_IS_VARIANT (variant));
-
- priv = EGG_DBUS_VARIANT_GET_PRIVATE (variant);
- if (priv->signature != NULL)
- g_value_unset (&priv->value);
- g_value_init (&priv->value, EGG_DBUS_TYPE_LIST);
-
- egg_dbus_list_set_elem_signature (list, elem_signature);
-
- g_value_take_boxed (&priv->value, list);
- set_signature_for_array (variant, elem_signature);
-
- egg_dbus_list_set_elem_signature (list, NULL);
-}
-
-void
-egg_dbus_variant_set_hash_table_with_signature (EggDBusVariant *variant,
- GHashTable *hash_table,
- const gchar *key_signature,
- const gchar *value_signature)
-{
- EggDBusVariantPrivate *priv;
-
- g_return_if_fail (EGG_DBUS_IS_VARIANT (variant));
-
- priv = EGG_DBUS_VARIANT_GET_PRIVATE (variant);
- if (priv->signature != NULL)
- g_value_unset (&priv->value);
- g_value_init (&priv->value, EGG_DBUS_TYPE_HASH_TABLE);
-
- egg_dbus_hash_table_set_signature (hash_table, key_signature, value_signature);
-
- g_value_set_boxed (&priv->value, hash_table);
- set_signature_for_hash_table (variant,
- key_signature,
- value_signature);
-
- egg_dbus_hash_table_set_signature (hash_table, NULL, NULL);
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/eggdbus/eggdbusvariant.h b/src/eggdbus/eggdbusvariant.h
index 0b6606f..0aa2b32 100644
--- a/src/eggdbus/eggdbusvariant.h
+++ b/src/eggdbus/eggdbusvariant.h
@@ -60,19 +60,19 @@ struct _EggDBusVariantClass
void (*_g_reserved7) (void);
};
-GType egg_dbus_variant_get_type (void) G_GNUC_CONST;
+GType egg_dbus_variant_get_type (void) G_GNUC_CONST;
-const gchar *egg_dbus_variant_get_variant_signature (EggDBusVariant *variant);
-
-void egg_dbus_variant_print (EggDBusVariant *variant,
- guint indent);
+void egg_dbus_variant_print (EggDBusVariant *variant,
+ guint indent);
EggDBusVariant *egg_dbus_variant_new (void);
EggDBusVariant *egg_dbus_variant_new_for_gvalue (const GValue *value,
- const gchar *signature);
+ const gchar *signature);
+
+const GValue *egg_dbus_variant_get_gvalue (EggDBusVariant *variant);
-const GValue *egg_dbus_variant_get_gvalue (EggDBusVariant *variant);
+const gchar *egg_dbus_variant_get_variant_signature (EggDBusVariant *variant);
/* ---------------------------------------------------------------------------------------------------- */
@@ -91,9 +91,11 @@ EggDBusVariant *egg_dbus_variant_new_for_int64 (gint64
EggDBusVariant *egg_dbus_variant_new_for_uint64 (guint64 value);
EggDBusVariant *egg_dbus_variant_new_for_boolean (gboolean value);
EggDBusVariant *egg_dbus_variant_new_for_double (gdouble value);
-EggDBusVariant *egg_dbus_variant_new_for_array (EggDBusArray *array);
-EggDBusVariant *egg_dbus_variant_new_for_list (EggDBusList *list);
-EggDBusVariant *egg_dbus_variant_new_for_hash_table (EggDBusHashTable *hash_table);
+EggDBusVariant *egg_dbus_variant_new_for_seq (EggDBusArraySeq *seq,
+ const gchar *element_signature);
+EggDBusVariant *egg_dbus_variant_new_for_map (EggDBusHashMap *map,
+ const gchar *key_signature,
+ const gchar *value_signature);
EggDBusVariant *egg_dbus_variant_new_for_structure (EggDBusStructure *structure);
/* ---------------------------------------------------------------------------------------------------- */
@@ -128,12 +130,13 @@ void egg_dbus_variant_set_boolean (EggDBusVariant *v
gboolean value);
void egg_dbus_variant_set_double (EggDBusVariant *variant,
gdouble value);
-void egg_dbus_variant_set_array (EggDBusVariant *variant,
- EggDBusArray *array);
-void egg_dbus_variant_set_list (EggDBusVariant *variant,
- EggDBusList *list);
-void egg_dbus_variant_set_hash_table (EggDBusVariant *variant,
- EggDBusHashTable *hash_table);
+void egg_dbus_variant_set_seq (EggDBusVariant *variant,
+ EggDBusArraySeq *seq,
+ const gchar *element_signature);
+void egg_dbus_variant_set_map (EggDBusVariant *variant,
+ EggDBusHashMap *map,
+ const gchar *key_signature,
+ const gchar *value_signature);
void egg_dbus_variant_set_structure (EggDBusVariant *variant,
EggDBusStructure *structure);
@@ -154,9 +157,8 @@ gint64 egg_dbus_variant_get_int64 (EggDBusVariant *va
guint64 egg_dbus_variant_get_uint64 (EggDBusVariant *variant);
gboolean egg_dbus_variant_get_boolean (EggDBusVariant *variant);
gdouble egg_dbus_variant_get_double (EggDBusVariant *variant);
-EggDBusArray *egg_dbus_variant_get_array (EggDBusVariant *variant);
-EggDBusList *egg_dbus_variant_get_list (EggDBusVariant *variant);
-EggDBusHashTable *egg_dbus_variant_get_hash_table (EggDBusVariant *variant);
+EggDBusArraySeq *egg_dbus_variant_get_seq (EggDBusVariant *variant);
+EggDBusHashMap *egg_dbus_variant_get_map (EggDBusVariant *variant);
EggDBusStructure *egg_dbus_variant_get_structure (EggDBusVariant *variant);
/* ---------------------------------------------------------------------------------------------------- */
@@ -177,34 +179,12 @@ gboolean egg_dbus_variant_is_int64 (EggDBusVariant *variant);
gboolean egg_dbus_variant_is_uint64 (EggDBusVariant *variant);
gboolean egg_dbus_variant_is_boolean (EggDBusVariant *variant);
gboolean egg_dbus_variant_is_double (EggDBusVariant *variant);
-gboolean egg_dbus_variant_is_array (EggDBusVariant *variant);
-gboolean egg_dbus_variant_is_list (EggDBusVariant *variant);
-gboolean egg_dbus_variant_is_hash_table (EggDBusVariant *variant);
+gboolean egg_dbus_variant_is_seq (EggDBusVariant *variant);
+gboolean egg_dbus_variant_is_map (EggDBusVariant *variant);
gboolean egg_dbus_variant_is_structure (EggDBusVariant *variant);
/* ---------------------------------------------------------------------------------------------------- */
-EggDBusVariant *egg_dbus_variant_new_for_array_with_signature (GArray *array,
- const gchar *elem_signature);
-EggDBusVariant *egg_dbus_variant_new_for_list_with_signature (EggDBusList *list,
- const gchar *elem_signature);
-EggDBusVariant *egg_dbus_variant_new_for_hash_table_with_signature (EggDBusHashTable *hash_table,
- const gchar *key_signature,
- const gchar *value_signature);
-
-void egg_dbus_variant_set_array_with_signature (EggDBusVariant *variant,
- GArray *array,
- const gchar *elem_signature);
-void egg_dbus_variant_set_list_with_signature (EggDBusVariant *variant,
- GList *list,
- const gchar *elem_signature);
-void egg_dbus_variant_set_hash_table_with_signature (EggDBusVariant *variant,
- GHashTable *hash_table,
- const gchar *key_signature,
- const gchar *value_signature);
-
-/* ---------------------------------------------------------------------------------------------------- */
-
G_END_DECLS
#endif /* __EGG_DBUS_STRUCTURE_H */
diff --git a/src/eggdbus/interface.c b/src/eggdbus/interface.c
index 74c2ce5..1ed1cfb 100644
--- a/src/eggdbus/interface.c
+++ b/src/eggdbus/interface.c
@@ -1164,7 +1164,7 @@ append_args (const EggDBusInterfaceArgInfo *args,
{
if (do_extract)
{
- g_print ("%s_array (%s, %s, %s)",
+ g_print ("%s_seq (%s, %s, %s)",
operation_str,
message_name,
arg_str,
@@ -1172,7 +1172,7 @@ append_args (const EggDBusInterfaceArgInfo *args,
}
else
{
- g_print ("%s_array (%s, %s, \"%s\", %s)",
+ g_print ("%s_seq (%s, %s, \"%s\", %s)",
operation_str,
message_name,
arg_str,
@@ -1210,7 +1210,7 @@ append_args (const EggDBusInterfaceArgInfo *args,
{
if (do_extract)
{
- g_print ("%s_list (%s, %s, %s)",
+ g_print ("%s_seq (%s, %s, %s)",
operation_str,
message_name,
arg_str,
@@ -1218,7 +1218,7 @@ append_args (const EggDBusInterfaceArgInfo *args,
}
else
{
- g_print ("%s_list (%s, %s, \"%s\", %s)",
+ g_print ("%s_seq (%s, %s, \"%s\", %s)",
operation_str,
message_name,
arg_str,
@@ -1235,7 +1235,7 @@ append_args (const EggDBusInterfaceArgInfo *args,
if (do_extract)
{
- g_print ("%s_hash_table (%s, %s, %s)",
+ g_print ("%s_map (%s, %s, %s)",
operation_str,
message_name,
arg_str,
@@ -1243,7 +1243,7 @@ append_args (const EggDBusInterfaceArgInfo *args,
}
else
{
- g_print ("%s_hash_table (%s, %s, \"%c\", \"%s\", %s)",
+ g_print ("%s_map (%s, %s, \"%c\", \"%s\", %s)",
operation_str,
message_name,
arg_str,
@@ -2107,23 +2107,10 @@ interface_generate_iface_c_file (const EggDBusInterfaceInfo *interface,
goto out;
}
- if (strcmp (gtype_name, "EGG_DBUS_TYPE_ARRAY") == 0 ||
- strcmp (gtype_name, "EGG_DBUS_TYPE_LIST") == 0 ||
- strcmp (gtype_name, "EGG_DBUS_TYPE_HASH_TABLE") == 0)
- {
- g_string_append_printf (s,
- ",\n"
- /* TODO: remove STATIC_SCOPE when we've got rid of boxed container types */
- " %s | G_SIGNAL_TYPE_STATIC_SCOPE",
- gtype_name);
- }
- else
- {
- g_string_append_printf (s,
- ",\n"
- " %s",
- gtype_name);
- }
+ g_string_append_printf (s,
+ ",\n"
+ " %s",
+ gtype_name);
g_free (gtype_name);
}
diff --git a/src/tests/testclient.c b/src/tests/testclient.c
index eaa87ec..b39c942 100644
--- a/src/tests/testclient.c
+++ b/src/tests/testclient.c
@@ -489,6 +489,7 @@ test_primitive_types (void)
/* ---------------------------------------------------------------------------------------------------- */
+#if 0
static void
test_array_of_primitive_types (void)
{
@@ -2127,6 +2128,7 @@ test_pass_variant2 (void)
" dbus.Int64(42L)), signature=None)");
g_free (as_string);
}
+#endif
/* ---------------------------------------------------------------------------------------------------- */
@@ -2192,12 +2194,12 @@ test_properties (void)
GError *error;
TestPoint *test_point;
TestPair *test_pair;
- GArray *array;
+ EggDBusArraySeq *array;
char *s;
gboolean received_async_reply;
gboolean got_foo_notify_event;
EggDBusVariant *variant;
- EggDBusHashTable *property_bag;
+ EggDBusHashMap *property_bag;
error = NULL;
@@ -2233,10 +2235,10 @@ test_properties (void)
g_free (s);
array = test_tweak_get_bar (TEST_QUERY_INTERFACE_TWEAK (object_proxy));
- g_assert_cmpuint (array->len, ==, 2);
- g_assert_cmpint (g_array_index (array, gint, 0), ==, 1);
- g_assert_cmpint (g_array_index (array, gint, 1), ==, 2);
- egg_dbus_array_free (array);
+ g_assert_cmpuint (array->size, ==, 2);
+ g_assert_cmpint (egg_dbus_array_seq_get_fixed (array, 0), ==, 1);
+ g_assert_cmpint (egg_dbus_array_seq_get_fixed (array, 1), ==, 2);
+ g_object_unref (array);
test_point = test_tweak_get_baz (TEST_QUERY_INTERFACE_TWEAK (object_proxy));
g_assert (TEST_IS_POINT (test_point));
@@ -2434,8 +2436,8 @@ frob_signal_with_primitive_types_cb (TestFrob *instance,
static void
frob_signal_with_array_of_primitive_types_cb (TestFrob *instance,
- EggDBusArray *array_byte,
- EggDBusArray *array_int32,
+ EggDBusArraySeq *array_byte,
+ EggDBusArraySeq *array_int32,
gchar **array_string,
gchar **array_objpath,
gchar **array_sig,
@@ -2443,13 +2445,13 @@ frob_signal_with_array_of_primitive_types_cb (TestFrob *instance,
{
gboolean *b = user_data;
- g_assert_cmpuint (array_byte->len, ==, 2);
- g_assert_cmpint (g_array_index (array_byte, guint8, 0), ==, 1);
- g_assert_cmpint (g_array_index (array_byte, guint8, 1), ==, 11);
+ g_assert_cmpuint (array_byte->size, ==, 2);
+ g_assert_cmpint (egg_dbus_array_seq_get_fixed (array_byte, 0), ==, 1);
+ g_assert_cmpint (egg_dbus_array_seq_get_fixed (array_byte, 1), ==, 11);
- g_assert_cmpuint (array_int32->len, ==, 2);
- g_assert_cmpint (g_array_index (array_int32, gint32, 0), ==, 4);
- g_assert_cmpint (g_array_index (array_int32, gint32, 1), ==, 14);
+ g_assert_cmpuint (array_int32->size, ==, 2);
+ g_assert_cmpint (egg_dbus_array_seq_get_fixed (array_int32, 0), ==, 4);
+ g_assert_cmpint (egg_dbus_array_seq_get_fixed (array_int32, 1), ==, 14);
g_assert (g_strv_length (array_string) == 2);
g_assert_cmpstr (array_string[0], ==, "signalfoo");
@@ -2472,8 +2474,8 @@ static void
frob_signal_with_struct_and_hash_cb (TestFrob *instance,
TestPoint *point,
TestDescribedPoint *dpoint,
- EggDBusHashTable *hash_of_string_to_string,
- EggDBusHashTable *hash_of_string_to_point,
+ EggDBusHashMap *hash_of_string_to_string,
+ EggDBusHashMap *hash_of_string_to_point,
gpointer user_data)
{
gboolean *b = user_data;
@@ -2489,16 +2491,16 @@ frob_signal_with_struct_and_hash_cb (TestFrob *instance,
g_assert_cmpint (test_point_get_x (point2), ==, 42);
g_assert_cmpint (test_point_get_y (point2), ==, 43);
- g_assert_cmpint (g_hash_table_size (hash_of_string_to_string), ==, 3);
- g_assert_cmpstr (g_hash_table_lookup (hash_of_string_to_string, "secret"), ==, "emerald");
- g_assert_cmpstr (g_hash_table_lookup (hash_of_string_to_string, "top-secret"), ==, "stuff");
- g_assert_cmpstr (g_hash_table_lookup (hash_of_string_to_string, "ultra-top-secret"), ==, "Rupert");
+ g_assert_cmpint (egg_dbus_hash_map_get_size (hash_of_string_to_string), ==, 3);
+ g_assert_cmpstr (egg_dbus_hash_map_lookup (hash_of_string_to_string, "secret"), ==, "emerald");
+ g_assert_cmpstr (egg_dbus_hash_map_lookup (hash_of_string_to_string, "top-secret"), ==, "stuff");
+ g_assert_cmpstr (egg_dbus_hash_map_lookup (hash_of_string_to_string, "ultra-top-secret"), ==, "Rupert");
- g_assert_cmpint (g_hash_table_size (hash_of_string_to_point), ==, 2);
- point2 = g_hash_table_lookup (hash_of_string_to_point, "site59");
+ g_assert_cmpint (egg_dbus_hash_map_get_size (hash_of_string_to_point), ==, 2);
+ point2 = egg_dbus_hash_map_lookup (hash_of_string_to_point, "site59");
g_assert_cmpint (test_point_get_x (point2), ==, 20);
g_assert_cmpint (test_point_get_y (point2), ==, 21);
- point2 = g_hash_table_lookup (hash_of_string_to_point, "site60");
+ point2 = egg_dbus_hash_map_lookup (hash_of_string_to_point, "site60");
g_assert_cmpint (test_point_get_x (point2), ==, 22);
g_assert_cmpint (test_point_get_y (point2), ==, 23);
@@ -3181,7 +3183,7 @@ test_user_supplied_structs (void)
{
GError *error;
TestSubject *subject;
- EggDBusList *list;
+ EggDBusArraySeq *list;
error = NULL;
@@ -3207,37 +3209,37 @@ test_user_supplied_structs (void)
NULL,
&error));
g_assert_no_error (error);
- g_assert_cmpint (g_list_length (list), ==, 4);
+ g_assert_cmpint (list->size, ==, 4);
- subject = TEST_SUBJECT (g_list_nth_data (list, 0));
+ subject = TEST_SUBJECT (egg_dbus_array_seq_get (list, 0));
g_assert (TEST_IS_SUBJECT (subject));
g_assert_cmpint (test_subject_get_kind (subject), ==, TEST_SUBJECT_KIND_DEITY);
g_assert_cmpstr (test_subject_get_name (subject), ==, "God");
g_assert_cmpstr (test_subject_get_favorite_food (subject), ==, "deity-snacks");
g_assert_cmpstr (test_subject_get_favorite_color (subject), ==, "infrared");
- subject = TEST_SUBJECT (g_list_nth_data (list, 1));
+ subject = TEST_SUBJECT (egg_dbus_array_seq_get (list, 1));
g_assert (TEST_IS_SUBJECT (subject));
g_assert_cmpint (test_subject_get_kind (subject), ==, TEST_SUBJECT_KIND_HUMAN);
g_assert_cmpstr (test_subject_get_name (subject), ==, "David"); /* that's me */
g_assert_cmpstr (test_subject_get_favorite_food (subject), ==, "buffalo chicken pizza");
g_assert_cmpstr (test_subject_get_favorite_color (subject), ==, "blue");
- subject = TEST_SUBJECT (g_list_nth_data (list, 2));
+ subject = TEST_SUBJECT (egg_dbus_array_seq_get (list, 2));
g_assert (TEST_IS_SUBJECT (subject));
g_assert_cmpint (test_subject_get_kind (subject), ==, TEST_SUBJECT_KIND_CYLON);
g_assert_cmpstr (test_subject_get_name (subject), ==, "Caprica-Six");
g_assert_cmpstr (test_subject_get_favorite_food (subject), ==, "baltar-snacks"); /* should be davidz-snacks! */
g_assert_cmpstr (test_subject_get_favorite_color (subject), ==, "red");
- subject = TEST_SUBJECT (g_list_nth_data (list, 3));
+ subject = TEST_SUBJECT (egg_dbus_array_seq_get (list, 3));
g_assert (TEST_IS_SUBJECT (subject));
g_assert_cmpint (test_subject_get_kind (subject), ==, TEST_SUBJECT_KIND_HUMAN);
g_assert_cmpstr (test_subject_get_name (subject), ==, "Divad"); /* my evil twin */
g_assert_cmpstr (test_subject_get_favorite_food (subject), ==, "oysters");
g_assert_cmpstr (test_subject_get_favorite_color (subject), ==, "black");
- egg_dbus_list_free (list); /* deep free FTW! */
+ g_object_unref (list); /* deep free FTW! */
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -4312,8 +4314,8 @@ main (int argc, char *argv[])
*/
/* Test collection classes */
- test_egg_dbus_array_seq ();
- test_egg_dbus_hash_map ();
+ //test_egg_dbus_array_seq ();
+ //test_egg_dbus_hash_map ();
/* Tests for code generator
*
@@ -4323,7 +4325,7 @@ main (int argc, char *argv[])
/* Tests for collection classes.
*
*/
- test_egg_dbus_structure ();
+ //test_egg_dbus_structure ();
/* The life-cycle test suite requires that none of our test services
* are on the bus. So we start with that.
@@ -4344,7 +4346,7 @@ main (int argc, char *argv[])
test_low_level ();
test_hello_world ();
test_primitive_types ();
- //test_array_of_primitive_types ();
+ /*test_array_of_primitive_types ();*/
/*test_structure_types ();*/
/*test_array_of_structure_types ();*/
/*test_hash_tables ();*/
diff --git a/src/tests/testfrobimpl.c b/src/tests/testfrobimpl.c
index f14c49e..644189b 100644
--- a/src/tests/testfrobimpl.c
+++ b/src/tests/testfrobimpl.c
@@ -75,6 +75,7 @@ test_frob_impl_get_property (GObject *object,
GParamSpec *pspec)
{
TestFrobImpl *frob_impl;
+ EggDBusArraySeq *array;
frob_impl = TEST_FROB_IMPL (object);
@@ -129,111 +130,66 @@ test_frob_impl_get_property (GObject *object,
break;
case PROP_AY:
- {
- GArray *array_byte;
- guchar byte_val;
- array_byte = g_array_new (FALSE, FALSE, sizeof (guchar));
- egg_dbus_array_set_elem_signature (array_byte, "y");
- byte_val = 1; g_array_append_val (array_byte, byte_val);
- byte_val = 11; g_array_append_val (array_byte, byte_val);
- g_value_take_boxed (value, array_byte);
- }
+ array = egg_dbus_array_seq_new (G_TYPE_UCHAR, NULL, NULL, NULL);
+ egg_dbus_array_seq_add_fixed (array, 1);
+ egg_dbus_array_seq_add_fixed (array, 11);
+ g_value_take_object (value, array);
break;
case PROP_AB:
- {
- GArray *array_bool;
- gboolean bool_val;
- array_bool = g_array_new (FALSE, FALSE, sizeof (gboolean));
- egg_dbus_array_set_elem_signature (array_bool, "b");
- bool_val = TRUE; g_array_append_val (array_bool, bool_val);
- bool_val = FALSE; g_array_append_val (array_bool, bool_val);
- g_value_take_boxed (value, array_bool);
- }
+ array = egg_dbus_array_seq_new (G_TYPE_BOOLEAN, NULL, NULL, NULL);
+ egg_dbus_array_seq_add_fixed (array, TRUE);
+ egg_dbus_array_seq_add_fixed (array, FALSE);
+ g_value_take_object (value, array);
break;
case PROP_AN:
- {
- GArray *array_int16;
- gint16 int16_val;
- array_int16 = g_array_new (FALSE, FALSE, sizeof (gint16));
- egg_dbus_array_set_elem_signature (array_int16, "n");
- int16_val = 2; g_array_append_val (array_int16, int16_val);
- int16_val = 12; g_array_append_val (array_int16, int16_val);
- g_value_take_boxed (value, array_int16);
- }
+ array = egg_dbus_array_seq_new (EGG_DBUS_TYPE_INT16, NULL, NULL, NULL);
+ egg_dbus_array_seq_add_fixed (array, 2);
+ egg_dbus_array_seq_add_fixed (array, 12);
+ g_value_take_object (value, array);
break;
case PROP_AQ:
- {
- GArray *array_uint16;
- guint16 uint16_val;
- array_uint16 = g_array_new (FALSE, FALSE, sizeof (guint16));
- egg_dbus_array_set_elem_signature (array_uint16, "q");
- uint16_val = 3; g_array_append_val (array_uint16, uint16_val);
- uint16_val = 13; g_array_append_val (array_uint16, uint16_val);
- g_value_take_boxed (value, array_uint16);
- }
+ array = egg_dbus_array_seq_new (EGG_DBUS_TYPE_UINT16, NULL, NULL, NULL);
+ egg_dbus_array_seq_add_fixed (array, 3);
+ egg_dbus_array_seq_add_fixed (array, 13);
+ g_value_take_object (value, array);
break;
case PROP_AI:
- {
- GArray *array_int32;
- gint32 int32_val;
- array_int32 = g_array_new (FALSE, FALSE, sizeof (gint32));
- egg_dbus_array_set_elem_signature (array_int32, "i");
- int32_val = 4; g_array_append_val (array_int32, int32_val);
- int32_val = 14; g_array_append_val (array_int32, int32_val);
- g_value_take_boxed (value, array_int32);
- }
+ array = egg_dbus_array_seq_new (G_TYPE_INT, NULL, NULL, NULL);
+ egg_dbus_array_seq_add_fixed (array, 4);
+ egg_dbus_array_seq_add_fixed (array, 14);
+ g_value_take_object (value, array);
break;
case PROP_AU:
- {
- GArray *array_uint32;
- guint32 uint32_val;
- array_uint32 = g_array_new (FALSE, FALSE, sizeof (guint32));
- egg_dbus_array_set_elem_signature (array_uint32, "u");
- uint32_val = 5; g_array_append_val (array_uint32, uint32_val);
- uint32_val = 15; g_array_append_val (array_uint32, uint32_val);
- g_value_take_boxed (value, array_uint32);
- }
+ array = egg_dbus_array_seq_new (G_TYPE_UINT, NULL, NULL, NULL);
+ egg_dbus_array_seq_add_fixed (array, 5);
+ egg_dbus_array_seq_add_fixed (array, 15);
+ g_value_take_object (value, array);
break;
case PROP_AX:
- {
- GArray *array_int64;
- gint64 int64_val;
- array_int64 = g_array_new (FALSE, FALSE, sizeof (gint64));
- egg_dbus_array_set_elem_signature (array_int64, "x");
- int64_val = 6; g_array_append_val (array_int64, int64_val);
- int64_val = 16; g_array_append_val (array_int64, int64_val);
- g_value_take_boxed (value, array_int64);
- }
+ array = egg_dbus_array_seq_new (G_TYPE_INT64, NULL, NULL, NULL);
+ egg_dbus_array_seq_add_fixed (array, 6);
+ egg_dbus_array_seq_add_fixed (array, 16);
+ g_value_take_object (value, array);
break;
case PROP_AT:
- {
- GArray *array_uint64;
- guint64 uint64_val;
- array_uint64 = g_array_new (FALSE, FALSE, sizeof (guint64));
- egg_dbus_array_set_elem_signature (array_uint64, "t");
- uint64_val = 7; g_array_append_val (array_uint64, uint64_val);
- uint64_val = 17; g_array_append_val (array_uint64, uint64_val);
- g_value_take_boxed (value, array_uint64);
- }
+ array = egg_dbus_array_seq_new (G_TYPE_UINT64, NULL, NULL, NULL);
+ egg_dbus_array_seq_add_fixed (array, 7);
+ egg_dbus_array_seq_add_fixed (array, 17);
+ g_value_take_object (value, array);
break;
case PROP_AD:
- {
- GArray *array_double;
- gdouble double_val;
- array_double = g_array_new (FALSE, FALSE, sizeof (gdouble));
- egg_dbus_array_set_elem_signature (array_double, "d");
- double_val = 7.5; g_array_append_val (array_double, double_val);
- double_val = 17.5; g_array_append_val (array_double, double_val);
- g_value_take_boxed (value, array_double);
- }
+ array = egg_dbus_array_seq_new (G_TYPE_DOUBLE, NULL, NULL, NULL);
+ egg_dbus_array_seq_add_float (array, 7.5);
+ egg_dbus_array_seq_add_float (array, 17.5);
+ g_value_take_object (value, array);
break;
case PROP_AS:
@@ -315,15 +271,13 @@ frob_iface_handle_emit_test_signals (TestFrob *instance,
const gchar *str_array[3];
const gchar *objpath_array[4];
const gchar *sig_array[4];
- GArray *array_int32;
- gint32 int32_val;
- GArray *array_byte;
- guchar byte_val;
+ EggDBusArraySeq *array_int32;
+ EggDBusArraySeq *array_byte;
TestPoint *point;
TestDescribedPoint *dpoint;
TestPoint *point_in_dpoint;
- GHashTable *hash_string_to_string;
- GHashTable *hash_string_to_point;
+ EggDBusHashMap *hash_string_to_string;
+ EggDBusHashMap *hash_string_to_point;
/* --- */
@@ -358,15 +312,13 @@ frob_iface_handle_emit_test_signals (TestFrob *instance,
sig_array[2] = "(sig)";
sig_array[3] = NULL;
- array_byte = g_array_new (FALSE, FALSE, sizeof (guchar));
- egg_dbus_array_set_elem_signature (array_byte, "y");
- byte_val = 1; g_array_append_val (array_byte, byte_val);
- byte_val = 11; g_array_append_val (array_byte, byte_val);
+ array_byte = egg_dbus_array_seq_new (G_TYPE_UCHAR, NULL, NULL, NULL);
+ egg_dbus_array_seq_add_fixed (array_byte, 1);
+ egg_dbus_array_seq_add_fixed (array_byte, 11);
- array_int32 = g_array_new (FALSE, FALSE, sizeof (gint32));
- egg_dbus_array_set_elem_signature (array_int32, "i");
- int32_val = 4; g_array_append_val (array_int32, int32_val);
- int32_val = 14; g_array_append_val (array_int32, int32_val);
+ array_int32 = egg_dbus_array_seq_new (G_TYPE_INT, NULL, NULL, NULL);
+ egg_dbus_array_seq_add_fixed (array_int32, 4);
+ egg_dbus_array_seq_add_fixed (array_int32, 14);
test_frob_emit_signal_signal_with_array_of_primitive_types (instance,
NULL,
@@ -376,8 +328,8 @@ frob_iface_handle_emit_test_signals (TestFrob *instance,
(gchar **) objpath_array,
(gchar **) sig_array);
- g_array_free (array_byte, TRUE);
- g_array_free (array_int32, TRUE);
+ g_object_unref (array_byte);
+ g_object_unref (array_int32);
/* --- */
@@ -387,14 +339,16 @@ frob_iface_handle_emit_test_signals (TestFrob *instance,
dpoint = test_described_point_new ("xmas", point_in_dpoint);
g_object_unref (point_in_dpoint);
- hash_string_to_string = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
- g_hash_table_insert (hash_string_to_string, "secret", "emerald");
- g_hash_table_insert (hash_string_to_string, "top-secret", "stuff");
- g_hash_table_insert (hash_string_to_string, "ultra-top-secret", "Rupert");
+ hash_string_to_string = egg_dbus_hash_map_new (G_TYPE_STRING, NULL,
+ G_TYPE_STRING, NULL);
+ egg_dbus_hash_map_insert (hash_string_to_string, "secret", "emerald");
+ egg_dbus_hash_map_insert (hash_string_to_string, "top-secret", "stuff");
+ egg_dbus_hash_map_insert (hash_string_to_string, "ultra-top-secret", "Rupert");
- hash_string_to_point = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) g_object_unref);
- g_hash_table_insert (hash_string_to_point, "site59", test_point_new (20, 21));
- g_hash_table_insert (hash_string_to_point, "site60", test_point_new (22, 23));
+ hash_string_to_point = egg_dbus_hash_map_new (G_TYPE_STRING, NULL,
+ TEST_TYPE_POINT, (GDestroyNotify) g_object_unref);
+ egg_dbus_hash_map_insert (hash_string_to_point, "site59", test_point_new (20, 21));
+ egg_dbus_hash_map_insert (hash_string_to_point, "site60", test_point_new (22, 23));
test_frob_emit_signal_signal_with_structure_and_hash (instance,
NULL,
@@ -404,11 +358,10 @@ frob_iface_handle_emit_test_signals (TestFrob *instance,
hash_string_to_point);
g_object_unref (point);
g_object_unref (dpoint);
- egg_dbus_hash_table_unref (hash_string_to_string);
- egg_dbus_hash_table_unref (hash_string_to_point);
+ g_object_unref (hash_string_to_string);
+ g_object_unref (hash_string_to_point);
test_frob_handle_emit_test_signals_finish (method_invocation);
-
}
static void
@@ -454,6 +407,7 @@ frob_iface_handle_test_primitive_types (TestFrob *instance,
g_free (sig);
}
+#if 0
static void
frob_iface_handle_test_array_of_primitive_types (TestFrob *instance,
GArray *val_byte,
@@ -563,12 +517,13 @@ frob_iface_handle_test_array_of_primitive_types (TestFrob *instance,
g_free (ret_array_objpath);
g_free (ret_array_sig);
}
+#endif
static void
test_frob_impl_frob_iface_init (TestFrobIface *iface)
{
iface->handle_hello_world = frob_iface_handle_hello_world;
iface->handle_test_primitive_types = frob_iface_handle_test_primitive_types;
- iface->handle_test_array_of_primitive_types = frob_iface_handle_test_array_of_primitive_types;
+ //iface->handle_test_array_of_primitive_types = frob_iface_handle_test_array_of_primitive_types;
iface->handle_emit_test_signals = frob_iface_handle_emit_test_signals;
}
diff --git a/src/tests/testsubject.c b/src/tests/testsubject.c
index 9a70723..c9f8bf2 100644
--- a/src/tests/testsubject.c
+++ b/src/tests/testsubject.c
@@ -66,7 +66,7 @@ test_subject_new (TestSubjectKind kind,
{
GValue *values;
const gchar *kind_str;
- EggDBusHashTable *properties;
+ EggDBusHashMap *properties;
switch (kind)
{
@@ -87,31 +87,28 @@ test_subject_new (TestSubjectKind kind,
return NULL;
}
- properties = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_object_unref);
- egg_dbus_hash_table_set_signature (properties, "s", "v");
+ properties = egg_dbus_hash_map_new (G_TYPE_STRING, (GDestroyNotify) g_free,
+ EGG_DBUS_TYPE_VARIANT, (GDestroyNotify) g_object_unref);
- g_hash_table_insert (properties,
- g_strdup ("name"),
- egg_dbus_variant_new_for_string (name));
+ egg_dbus_hash_map_insert (properties,
+ g_strdup ("name"),
+ egg_dbus_variant_new_for_string (name));
- g_hash_table_insert (properties,
- g_strdup ("favorite-food"),
- egg_dbus_variant_new_for_string (favorite_food));
+ egg_dbus_hash_map_insert (properties,
+ g_strdup ("favorite-food"),
+ egg_dbus_variant_new_for_string (favorite_food));
- g_hash_table_insert (properties,
- g_strdup ("favorite-color"),
- egg_dbus_variant_new_for_string (favorite_color));
+ egg_dbus_hash_map_insert (properties,
+ g_strdup ("favorite-color"),
+ egg_dbus_variant_new_for_string (favorite_color));
values = g_new0 (GValue, 2);
g_value_init (&(values[0]), G_TYPE_STRING);
g_value_set_string (&(values[0]), kind_str);
- g_value_init (&(values[1]), EGG_DBUS_TYPE_HASH_TABLE);
- g_value_set_boxed (&(values[1]), properties);
+ g_value_init (&(values[1]), EGG_DBUS_TYPE_HASH_MAP);
+ g_value_take_object (&(values[1]), properties);
return TEST_SUBJECT (g_object_new (TEST_TYPE_SUBJECT,
"signature", "(sa{sv})",
@@ -166,7 +163,7 @@ test_subject_get_kind (TestSubject *subject)
const gchar *
test_subject_get_name (TestSubject *subject)
{
- EggDBusHashTable *value;
+ EggDBusHashMap *value;
EggDBusVariant *variant;
const gchar *result;
@@ -176,7 +173,7 @@ test_subject_get_name (TestSubject *subject)
1, &value,
-1);
- variant = g_hash_table_lookup (value, "name");
+ variant = egg_dbus_hash_map_lookup (value, "name");
result = egg_dbus_variant_get_string (variant);
return result;
@@ -193,7 +190,7 @@ test_subject_get_name (TestSubject *subject)
const gchar *
test_subject_get_favorite_food (TestSubject *subject)
{
- EggDBusHashTable *value;
+ EggDBusHashMap *value;
EggDBusVariant *variant;
const gchar *result;
@@ -203,7 +200,7 @@ test_subject_get_favorite_food (TestSubject *subject)
1, &value,
-1);
- variant = g_hash_table_lookup (value, "favorite-food");
+ variant = egg_dbus_hash_map_lookup (value, "favorite-food");
result = egg_dbus_variant_get_string (variant);
return result;
@@ -220,7 +217,7 @@ test_subject_get_favorite_food (TestSubject *subject)
const gchar *
test_subject_get_favorite_color (TestSubject *subject)
{
- EggDBusHashTable *value;
+ EggDBusHashMap *value;
EggDBusVariant *variant;
const gchar *result;
@@ -230,7 +227,7 @@ test_subject_get_favorite_color (TestSubject *subject)
1, &value,
-1);
- variant = g_hash_table_lookup (value, "favorite-color");
+ variant = egg_dbus_hash_map_lookup (value, "favorite-color");
result = egg_dbus_variant_get_string (variant);
return result;
diff --git a/src/tests/testtweakimpl.c b/src/tests/testtweakimpl.c
index 3137717..2b22e63 100644
--- a/src/tests/testtweakimpl.c
+++ b/src/tests/testtweakimpl.c
@@ -114,6 +114,7 @@ test_tweak_impl_get_property (GObject *object,
{
TestTweakImpl *tweak_impl;
TestTweakImplPrivate *priv;
+ EggDBusArraySeq *array;
tweak_impl = TEST_TWEAK_IMPL (object);
priv = TEST_TWEAK_IMPL_GET_PRIVATE (tweak_impl);
@@ -128,15 +129,10 @@ test_tweak_impl_get_property (GObject *object,
break;
case PROP_BAR:
- {
- GArray *array_int32;
- guint32 int32_val;
- array_int32 = g_array_new (FALSE, FALSE, sizeof (gint32));
- egg_dbus_array_set_elem_signature (array_int32, "i");
- int32_val = 1; g_array_append_val (array_int32, int32_val);
- int32_val = 2; g_array_append_val (array_int32, int32_val);
- g_value_take_boxed (value, array_int32);
- }
+ array = egg_dbus_array_seq_new (G_TYPE_INT, NULL, NULL, NULL);
+ egg_dbus_array_seq_add_fixed (array, 1);
+ egg_dbus_array_seq_add_fixed (array, 2);
+ g_value_take_object (value, array);
break;
case PROP_BAZ:
diff --git a/src/tests/testtwiddleimpl.c b/src/tests/testtwiddleimpl.c
index 8d67823..dade28c 100644
--- a/src/tests/testtwiddleimpl.c
+++ b/src/tests/testtwiddleimpl.c
@@ -123,23 +123,23 @@ static void
twiddle_iface_handle_get_all_subjects (TestTwiddle *instance,
EggDBusMethodInvocation *method_invocation)
{
- GList *l;
TestTwiddleImpl *twiddle_impl;
TestTwiddleImplPrivate *priv;
+ EggDBusArraySeq *seq;
twiddle_impl = TEST_TWIDDLE_IMPL (instance);
priv = TEST_TWIDDLE_IMPL_GET_PRIVATE (twiddle_impl);
- l = NULL;
- l = g_list_prepend (l, priv->divad);
- l = g_list_prepend (l, priv->six);
- l = g_list_prepend (l, priv->david);
- l = g_list_prepend (l, priv->god);
+ seq = egg_dbus_array_seq_new (TEST_TYPE_SUBJECT, NULL, NULL, NULL);
+ egg_dbus_array_seq_add (seq, priv->god);
+ egg_dbus_array_seq_add (seq, priv->david);
+ egg_dbus_array_seq_add (seq, priv->six);
+ egg_dbus_array_seq_add (seq, priv->divad);
test_twiddle_handle_get_all_subjects_finish (method_invocation,
- l);
+ seq);
- g_list_free (l);
+ g_object_unref (seq);
}
static void