Bug 24146 - Move data forms code to Wocky
Summary: Move data forms code to Wocky
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: gabble (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Guillaume Desmottes
QA Contact: Telepathy bugs list
URL: http://git.collabora.co.uk/?p=user/wj...
Whiteboard: review+
Keywords: patch
Depends on:
Blocks:
 
Reported: 2009-09-25 05:26 UTC by Guillaume Desmottes
Modified: 2010-02-25 16:01 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Guillaume Desmottes 2009-09-25 05:26:59 UTC
As pubsub uses extensively data forms (XEP-0004), I refactored some data forms code from gabble and moved it to a separated object.
I focused on the form parsing and submit part as that's what I'll need for pubsub.

http://git.collabora.co.uk/?p=user/cassidy/telepathy-gabble;a=shortlog;h=refs/heads/dataforms
Comment 1 Guillaume Desmottes 2009-09-28 07:54:04 UTC
While writing unit tests for this component in Wocky I fixed some bugs. Maybe this branch should be reviewed at the same time as the Gabble one as that's really the same code:

http://git.collabora.co.uk/?p=user/cassidy/wocky;a=shortlog;h=refs/heads/dataforms
Comment 2 Will Thompson 2009-09-28 08:35:34 UTC
Taking a look.
Comment 3 Will Thompson 2009-09-28 11:01:03 UTC
Partial review up to 8fc141547d96a1ca69:

wocky_data_forms_field and wocky_data_forms_field_option should be
camel-cased.

extract_value_list() doesn't NULL-terminate the returned value. This
suggests that that code path isn't tested. :)

+      DEBUG ("Wrong field type for '%s': %s", type_str, var);

It's not a wrong type, it's an invalid type.

+          DEBUG ("No option provided for '%s'", var);

Options.

Why does wocky_data_forms_field_new() take ownership of the 'options'
list, but not of (eg) the default value?

+      if (value== NULL)

Style: add a space.

extract_search_keys_from_froms(): The last word should be "forms" :)

+          "server doesn't support any known search key");

keys plural.

+  /* list will be reveresed */

reversed.

+        if (!wocky_strdiff (value, "true"))
+          return wocky_g_value_slice_new_boolean (TRUE);
+        else if (!wocky_strdiff (value, "false"))
+          return wocky_g_value_slice_new_boolean (FALSE);
+        else
+          DEBUG ("Invalid boolean value: %s", value);
+        break;

From the footnote assigned to the boolean type in XEP-0004 §3.3:

> 10. In accordance with Section 3.2.2.1 of XML Schema Part 2:
> Datatypes, the allowable lexical representations for the xs:boolean
> datatype are the strings "0" and "false" for the concept 'false' and
> the strings "1" and "true" for the concept 'true'; implementations
> MUST support both styles of lexical representation.

Amusingly, this branch produces "0" and "1", but only accepts "false"
and "true". :)

The name of wocky_data_forms_submit() seems a bit misleading. It
doesn't actually submit the form. Obviously it doing so would be
strange... Maybe it's worth the misleading name for brevity's sake?
Comment 4 Guillaume Desmottes 2009-09-29 04:42:45 UTC
(In reply to comment #3)
> Partial review up to 8fc141547d96a1ca69:
> 
> wocky_data_forms_field and wocky_data_forms_field_option should be
> camel-cased.

done

> extract_value_list() doesn't NULL-terminate the returned value. This
> suggests that that code path isn't tested. :)

Fixed in the Wocky branch (and tested!) :)


> +      DEBUG ("Wrong field type for '%s': %s", type_str, var);
> 
> It's not a wrong type, it's an invalid type.

fixed.

> +          DEBUG ("No option provided for '%s'", var);
> 
> Options.

fixed.

> Why does wocky_data_forms_field_new() take ownership of the 'options'
> list, but not of (eg) the default value?

No good reason; fixed.


> +      if (value== NULL)
> 
> Style: add a space.

already fixed.
 
> extract_search_keys_from_froms(): The last word should be "forms" :)

fixed.

> +          "server doesn't support any known search key");
> 
> keys plural.

fixed.

> +  /* list will be reveresed */
> 
> reversed.

fixed.

> +        if (!wocky_strdiff (value, "true"))
> +          return wocky_g_value_slice_new_boolean (TRUE);
> +        else if (!wocky_strdiff (value, "false"))
> +          return wocky_g_value_slice_new_boolean (FALSE);
> +        else
> +          DEBUG ("Invalid boolean value: %s", value);
> +        break;
> 
> From the footnote assigned to the boolean type in XEP-0004 §3.3:
> 
> > 10. In accordance with Section 3.2.2.1 of XML Schema Part 2:
> > Datatypes, the allowable lexical representations for the xs:boolean
> > datatype are the strings "0" and "false" for the concept 'false' and
> > the strings "1" and "true" for the concept 'true'; implementations
> > MUST support both styles of lexical representation.
> 
> Amusingly, this branch produces "0" and "1", but only accepts "false"
> and "true". :)

Oooops, nice catch. Fixed. :)

> The name of wocky_data_forms_submit() seems a bit misleading. It
> doesn't actually submit the form. Obviously it doing so would be
> strange... Maybe it's worth the misleading name for brevity's sake?
> 

Don't know. IMHO the current name isn't that bad but I'm open to suggestions.
Comment 5 Will Thompson 2010-02-22 09:25:50 UTC
I've rebased your branch, reviewed it, and fixed the things I would have complained about. :) It's mostly just tidying and a bit of refactoring; review would be lovely!
Comment 6 Guillaume Desmottes 2010-02-23 02:36:39 UTC
Looks all good to me!
Comment 7 Simon McVittie 2010-02-25 14:10:03 UTC
review+ from cassidy, and I think this got merged? If so, please close it.
Comment 8 Will Thompson 2010-02-25 16:01:34 UTC
Yep.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.