Bug 38577

Summary: Can't register handlers for stanzas of any type
Product: Wocky Reporter: Will Thompson <will>
Component: GeneralAssignee: Will Thompson <will>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium Keywords: patch
Version: unspecified   
Hardware: Other   
OS: All   
URL: http://cgit.collabora.com/git/user/wjt/wocky.git/log/?h=wildcard-handlers
Whiteboard: r+
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 38568    
Attachments: Porter: support matching STANZA_TYPE_NONE

Description Will Thompson 2011-06-22 11:38:32 UTC
So I wrote an XML console, and I quickly looked at adding a signal for incoming stanzas. According to Wocky's docs:

 * wocky_porter_register_handler_from_anyone:
 * @self: A #WockyPorter instance (passed to @callback).
 * @type: The type of stanza to be handled, or WOCKY_STANZA_TYPE_NONE to match
 *  any type of stanza.

But you can't actually pass WOCKY_STANZA_TYPE_NONE, because the implementation winds up calling wocky_stanza_new_with_sub_type() which calls check_sub_type() which asserts that type != NONE for obvious reasons: the type name is the name of the root element, so of course it needs a non-NONE one.

I suspect that the porter ought really to special-case NONE, and assert in itself that sub_type is also NONE and that the varargs are empty, and not build a stanza at all.
Comment 1 Will Thompson 2011-06-27 11:48:56 UTC
Created attachment 48480 [details] [review]
Porter: support matching STANZA_TYPE_NONE

For really specialised cases, like an XML console in Gabble, you want to
be able to match stanzas of any type. The docs claim you can do this,
but they lie.

I could be convinced that the correct way to do this is to add a fourth
method, wocky_porter_register_handler_for_any_stanza (), and that the
server/anyone/from variants are unnecessary. Thoughts?
Comment 2 Will Thompson 2011-11-18 03:03:10 UTC
hey there are a couple more patches in the referenced branch.
Comment 3 Simon McVittie 2011-11-18 03:23:41 UTC
Looks good to me
Comment 4 Will Thompson 2011-11-18 03:50:51 UTC
Cheers, merged to the master.

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.