Replace last patch with new patch that does same thing better. This new method adds xmpp_stanza_get_child_by_ns() to the API. Implementation and copyright assigned to us by Matthew Wild <mwild1@gmail.com>.
This commit is contained in:
@@ -127,7 +127,7 @@ void handler_fire_stanza(xmpp_conn_t * const conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((!item->ns || (ns && strcmp(ns, item->ns) == 0) ||
|
if ((!item->ns || (ns && strcmp(ns, item->ns) == 0) ||
|
||||||
_match_children(stanza, item->ns)) &&
|
xmpp_stanza_get_child_by_ns(stanza, item->ns)) &&
|
||||||
(!item->name || (name && strcmp(name, item->name) == 0)) &&
|
(!item->name || (name && strcmp(name, item->name) == 0)) &&
|
||||||
(!item->type || (type && strcmp(type, item->type) == 0)))
|
(!item->type || (type && strcmp(type, item->type) == 0)))
|
||||||
if (!((xmpp_handler)(item->handler))(conn, stanza, item->userdata)) {
|
if (!((xmpp_handler)(item->handler))(conn, stanza, item->userdata)) {
|
||||||
|
|||||||
26
src/stanza.c
26
src/stanza.c
@@ -706,6 +706,32 @@ xmpp_stanza_t *xmpp_stanza_get_child_by_name(xmpp_stanza_t * const stanza,
|
|||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the first child of a stanza with a given namespace.
|
||||||
|
* This function searches all the immediate children of a stanza for a child
|
||||||
|
* stanza that matches the namespace provided. The first matching child
|
||||||
|
* is returned.
|
||||||
|
*
|
||||||
|
* @param stanza a Strophe stanza object
|
||||||
|
* @param ns a string with the namespace to match
|
||||||
|
*
|
||||||
|
* @return the matching child stanza object or NULL if no match was found
|
||||||
|
*
|
||||||
|
* @ingroup Stanza
|
||||||
|
*/
|
||||||
|
xmpp_stanza_t *xmpp_stanza_get_child_by_ns(xmpp_stanza_t * const stanza,
|
||||||
|
const char * const ns)
|
||||||
|
{
|
||||||
|
xmpp_stanza_t *child;
|
||||||
|
|
||||||
|
for (child = stanza->children; child; child = child->next) {
|
||||||
|
if (xmpp_stanza_get_ns(child) &&
|
||||||
|
strcmp(ns, xmpp_stanza_get_ns(child)) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get the list of children.
|
/** Get the list of children.
|
||||||
* This function returns the first child of the stanza object. The rest
|
* This function returns the first child of the stanza object. The rest
|
||||||
* of the children can be obtained by calling xmpp_stanza_get_next() to
|
* of the children can be obtained by calling xmpp_stanza_get_next() to
|
||||||
|
|||||||
@@ -293,6 +293,8 @@ int xmpp_stanza_to_text(xmpp_stanza_t *stanza,
|
|||||||
xmpp_stanza_t *xmpp_stanza_get_children(xmpp_stanza_t * const stanza);
|
xmpp_stanza_t *xmpp_stanza_get_children(xmpp_stanza_t * const stanza);
|
||||||
xmpp_stanza_t *xmpp_stanza_get_child_by_name(xmpp_stanza_t * const stanza,
|
xmpp_stanza_t *xmpp_stanza_get_child_by_name(xmpp_stanza_t * const stanza,
|
||||||
const char * const name);
|
const char * const name);
|
||||||
|
xmpp_stanza_t *xmpp_stanza_get_child_by_ns(xmpp_stanza_t * const stanza,
|
||||||
|
const char * const ns);
|
||||||
xmpp_stanza_t *xmpp_stanza_get_next(xmpp_stanza_t * const stanza);
|
xmpp_stanza_t *xmpp_stanza_get_next(xmpp_stanza_t * const stanza);
|
||||||
char *xmpp_stanza_get_attribute(xmpp_stanza_t * const stanza,
|
char *xmpp_stanza_get_attribute(xmpp_stanza_t * const stanza,
|
||||||
const char * const name);
|
const char * const name);
|
||||||
|
|||||||
Reference in New Issue
Block a user