[Bug 34864] New: Expunge lm_message_node_get_child_with_namespace()

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Mar 1 13:21:01 CET 2011


https://bugs.freedesktop.org/show_bug.cgi?id=34864

           Summary: Expunge lm_message_node_get_child_with_namespace()
           Product: Telepathy
           Version: unspecified
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: love
          Severity: normal
          Priority: medium
         Component: gabble
        AssignedTo: telepathy-bugs at lists.freedesktop.org
        ReportedBy: will.thompson at collabora.co.uk
         QAContact: telepathy-bugs at lists.freedesktop.org


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 at 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

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the telepathy-bugs mailing list