summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--uca-net-camera.c19
-rw-r--r--uca-net-protocol.h1
-rw-r--r--ucad.c12
3 files changed, 20 insertions, 12 deletions
diff --git a/uca-net-camera.c b/uca-net-camera.c
index 39f591f..f265fc6 100644
--- a/uca-net-camera.c
+++ b/uca-net-camera.c
@@ -521,15 +521,22 @@ static void
read_property_reply (GObject *object, GInputStream *input, guint index, GError **error)
{
UcaNetMessageProperty property;
+ GParamSpec *pspec;
- if (g_input_stream_read_all (input, &property, sizeof (property), NULL, NULL, error)) {
- GParamSpec *pspec;
-
- pspec = deserialize_param_spec (&property);
+ if (!g_input_stream_read_all (input, &property, sizeof (property), NULL, NULL, error)) {
+ g_warning ("Could not read all property data");
+ return;
+ }
- if (pspec != NULL)
- g_object_class_install_property (G_OBJECT_GET_CLASS (object), N_PROPERTIES + index + 1, pspec);
+ if (!property.valid) {
+ g_warning ("Cannot install unserialized property `%s'", property.name);
+ return;
}
+
+ pspec = deserialize_param_spec (&property);
+
+ if (pspec != NULL)
+ g_object_class_install_property (G_OBJECT_GET_CLASS (object), N_PROPERTIES + index + 1, pspec);
}
static void
diff --git a/uca-net-protocol.h b/uca-net-protocol.h
index fe097db..e3a827d 100644
--- a/uca-net-protocol.h
+++ b/uca-net-protocol.h
@@ -80,6 +80,7 @@ typedef struct {
gchar name[128];
gchar nick[128];
gchar blurb[128];
+ gboolean valid;
union {
struct {
diff --git a/ucad.c b/ucad.c
index 09f075c..d2fd300 100644
--- a/ucad.c
+++ b/ucad.c
@@ -105,7 +105,7 @@ prepare_error_reply (GError *error, UcaNetErrorReply *reply)
}
}
-static gboolean
+static void
serialize_param_spec (GParamSpec *pspec, UcaNetMessageProperty *prop)
{
strncpy (prop->name, g_param_spec_get_name (pspec), sizeof (prop->name));
@@ -114,6 +114,7 @@ serialize_param_spec (GParamSpec *pspec, UcaNetMessageProperty *prop)
prop->value_type = pspec->value_type;
prop->flags = pspec->flags;
+ prop->valid = TRUE;
if (g_type_is_a (pspec->value_type, G_TYPE_ENUM)) {
GEnumClass *enum_class;
@@ -163,12 +164,11 @@ serialize_param_spec (GParamSpec *pspec, UcaNetMessageProperty *prop)
break;
default:
g_warning ("Cannot serialize property %s", prop->name);
- return FALSE;
+ prop->valid = FALSE;
+ break;
}
#undef CASE_NUMERIC
-
- return TRUE;
}
static void
@@ -186,8 +186,8 @@ handle_get_properties_request (GSocketConnection *connection, UcaCamera *camera,
for (guint i = N_BASE_PROPERTIES - 1; i < num_properties; i++) {
UcaNetMessageProperty property;
- if (serialize_param_spec (pspecs[i], &property))
- send_reply (connection, &property, sizeof (property), error);
+ serialize_param_spec (pspecs[i], &property);
+ send_reply (connection, &property, sizeof (property), error);
}
g_free (pspecs);