GNOME Bugzilla – Bug 696837
return -1 when upnp:totalDeletedChildCount property is not found
Last modified: 2019-02-22 05:57:49 UTC
Created attachment 240107 [details] [review] Return -1 as default value for gupnp_didl_lite_container_get_total_deleted_child_count gupnp_didl_lite_container_get_total_deleted_child_count returns 0 as default value if the property is not found. 0 is a valid value for upnp:totalDeletedChildCount. Fix the function so it behaves as gupnp_didl_lite_resource_get_update_count (res@updateCount) and return -1 when the property is not found.
I wonder if the fact that gupnp_didl_lite_resource_get_update_count can return -1 is actually a bug. As far as I can tell there are no other gupnp-av functions with a return type of guint that return -1. If this is not a bug and it is okay to do this, we should update the documentation for both functions to indicate that (guint) -1 is returned when the property is not found.
with the newly added properties we did some change in the paradigm. Previously, uint properties were made int in -av so we could return -1 on "not set" (eg res@updateCount), but that caused problems. With the newly added properties, there are "_is_set" fuctions to explicitly check for the presence of the property: gupnp_didl_lite_container_total_deleted_child_count_is_set and such
"is_set" will be the way to go when the parser will be change (using "SAX" if I well remember the bug description) and efficient, but today, we are going to parse 2 times the XML to test & get the value. res@updateCount & totalDeleteChildCount have been added to support Content Sync, and they have the "same specification" (0 is a valid value, -1, is an invalid value as it could never be reached). But these 2 functions behave differently. So if we should use "is_set" right now, res@updateCount should be fixed. But returning -1 for this function is a matter of prudence as otherwise it will return a valid value when not set.