Bug 34864 - Expunge lm_message_node_get_child_with_namespace()
Summary: Expunge lm_message_node_get_child_with_namespace()
Status: RESOLVED INVALID
Alias: None
Product: Telepathy
Classification: Unclassified
Component: gabble (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL:
Whiteboard:
Keywords: love
Depends on:
Blocks:
 
Reported: 2011-03-01 04:21 UTC by Will Thompson
Modified: 2013-09-05 13:13 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Will Thompson 2011-03-01 04:21:00 UTC
lm_message_node_get_child_with_namespace() is an incredible function that recursively searches a stanza for an element with a particular name. It's used in all kinds of places, but it really shouldn't be: the structure of stanzas does matter. This function makes us accept really malformed stanzas, making it harder to follow what's going on or—in the case of Tubes, where the most up-to-date documentation of the protocol is the code—know what the wire protocol is actually meant to look like.

This would be a good place for someone looking to get familiar with the XMPP protocols used in Gabble to get started.

Each place where lm_message_node_get_child_with_namespace() is used:

• Check whether it could be replaced by wocky_node_get_child_ns(). For example, lots of code uses this function to pull the top-level query element out of an IQ stanzas which look like this:

  <iq from='foo@bar' type='get' id='333'>
    <query xmlns='blahblahblah'>
      ...
    </query>
  </iq>

In this case, a call to lm_message_node_get_child_with_namespace (iq_node, "query", "blahblahblah") should be directly replaced by a call to wocky_node_get_child_ns (iq_node, "query", "blahblahblah").

• Otherwise, check what structure the stanza is documented to have in the relevant XEP, and traverse the structure explicitly. For example, consider this code:

  bar = lm_message_node_get_child_with_namespace (message_node, "bar", "urn:xmpp:bar");

If it's retrieving the 'bar' node from a stanza which looks like this:

  <message>
    <foo xmlns='urn:xmpp:foo'>
      <bar xmlns='urn:xmpp:bar'/>
    </foo>
  </message>

Then the corrected code would be as follows:

  WockyNode *bar = NULL;
  WockyNode *foo = wocky_node_get_child_ns (message_node, "foo", "urn:xmpp:foo");

  if (foo != NULL)
    bar = wocky_node_get_child_ns (foo, "bar", "urn:xmpp:bar");

• If it's not obvious, check the relevant XEPs and test cases to figure out what's meant to be going on, or ask on #telepathy
Comment 1 Chandni Verma 2013-09-05 12:59:14 UTC
lm_message_node_get_child_with_namespace() is no more to be found in source code. This bug is thus obsolete.
Comment 2 Will Thompson 2013-09-05 13:13:12 UTC
For what it's worth, it does still exist, albeit under a different name: after getting rid of all other uses, I moved it into conn-olpc.c http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=d8a20876 and renamed it for clarity: http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=6c68414

Thanks for clearing up the obsolete bug!


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.