Re: [gupnp] problem with GUPnPLastChangeParser
- From: "Zeeshan Ali (Khattak)" <zeenix gmail com>
- To: gupnp o-hand com
- Subject: Re: [gupnp] problem with GUPnPLastChangeParser
- Date: Wed, 29 Apr 2009 20:30:53 +0300
On Wed, Apr 29, 2009 at 8:00 PM, Sven Neumann <s neumann raumfeld com> wrote:
> Hi,
>
> On Wed, 2009-04-29 at 19:55 +0300, Zeeshan Ali (Khattak) wrote:
>
>> > But there's still a problem. Consider an unsigned int variable where the
>> > whole range of possible values is allowed and valid. How would I deal
>> > with such a value given the current API of GUPnPLastChangeParser?
>>
>> True but what are the chances of you needing all the possible
>> values of gint64?
>
> I can't use a gint64 variable here. If the LastChange event holds an
> UINT variable, then I need to pass a pointer to a guint variable.
>
>> Also if you are sent a value that is the same as you
>> already had, is there really a need to know if it was sent or not?
>
> That is actually a good suggestion. Initializing the variable to the
> known value solves the problem. Thanks.
np!
> The code is still buggy though and we should try to come up with a patch
> for it.
How about this patch?
--
Regards,
Zeeshan Ali (Khattak)
FSF member#5124
From 7f03d200c7235ac9c5fd12106cb2ebfaca6fe1e0 Mon Sep 17 00:00:00 2001
From: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed, 29 Apr 2009 19:03:34 +0300
Subject: [PATCH] Dont copy the value if not provided in LastChange
There is no need to set the variable if it's value is not provided in the
LastChange event.
---
libgupnp-av/gupnp-last-change-parser.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/libgupnp-av/gupnp-last-change-parser.c b/libgupnp-av/gupnp-last-change-parser.c
index 87057f1..6c53073 100644
--- a/libgupnp-av/gupnp-last-change-parser.c
+++ b/libgupnp-av/gupnp-last-change-parser.c
@@ -70,7 +70,7 @@ gupnp_last_change_parser_class_init (GUPnPLastChangeParserClass *klass)
/* Reads a value of state variable @variable_name to an initialised GValue pair
* from the InstanceID node of a LastChange xml doc */
-static void
+static gboolean
read_state_variable (const char *variable_name,
GValue *value,
xmlNode *instance_node)
@@ -83,7 +83,7 @@ read_state_variable (const char *variable_name,
variable_name,
NULL);
if (!variable_node)
- return;
+ return FALSE;
val_str = xml_util_get_attribute_content (variable_node, "val");
if (!val_str) {
@@ -91,12 +91,14 @@ read_state_variable (const char *variable_name,
"LastChange event",
variable_name);
- return;
+ return FALSE;
}
gvalue_util_set_value_from_string (value, (char *) val_str);
g_free (val_str);
+
+ return TRUE;
}
static xmlNode *
@@ -191,9 +193,13 @@ gupnp_last_change_parser_parse_last_change_valist
g_value_init (&value, variable_type);
- read_state_variable (variable_name, &value, instance_node);
-
- G_VALUE_LCOPY (&value, var_args, 0, ©_error);
+ if (read_state_variable (variable_name,
+ &value,
+ instance_node)) {
+ G_VALUE_LCOPY (&value, var_args, 0, ©_error);
+ } else {
+ va_arg (var_args, gpointer);
+ }
g_value_unset (&value);
--
1.6.2.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]