Exemple #1
0
Fichier : ji.c Projet : placek/ji
static int
roster_hook(int x, struct xmpp *xmpp)
{
  struct xml_data *d;
  char *jid, *name, *sub;

  for (d = xml_node_data(xml_node_find(x, "query", &xmpp->xml.mem),
                         &xmpp->xml.mem);
       d; d = xml_data_next(d, &xmpp->xml.mem)) {
    if (d->type != XML_NODE)
      continue;
    jid = xml_node_find_attr(d->value, "jid", &xmpp->xml.mem);
    name = xml_node_find_attr(d->value, "name", &xmpp->xml.mem);
    sub = xml_node_find_attr(d->value, "subscription", &xmpp->xml.mem);
    print_msg(0, "", "* %s - %s - [%s]\n", name ? name : "", jid, sub);
  }
  print_msg(0, "", "End of /R list.\n");
  for (d = xml_node_data(xml_node_find(x, "query", &xmpp->xml.mem),
                         &xmpp->xml.mem);
       d; d = xml_data_next(d, &xmpp->xml.mem)) {
    if (d->type != XML_NODE)
      continue;
    jid = xml_node_find_attr(d->value, "jid", &xmpp->xml.mem);
    request_presence(xmpp, jid);
  }
  return 0;
}
Exemple #2
0
static void
roster_handler(int x, struct xmpp *xmpp)
{
    struct xml_data *d;
    char *jid, *name, *sub;
    for (d = xml_node_data(xml_node_find(x, "query", &xmpp->xml.mem),
                           &xmpp->xml.mem);
            d;
            d = xml_data_next(d, &xmpp->xml.mem)) {
        if (d->type != XML_NODE)
            continue;
        jid = xml_node_find_attr(d->value, "jid", &xmpp->xml.mem);
        name = xml_node_find_attr(d->value, "name", &xmpp->xml.mem);
        sub = xml_node_find_attr(d->value, "subscription", &xmpp->xml.mem);
        print_msg("* %s - %s - [%s]\n", name ? name : "", jid, sub);
    }
    print_msg("End of roster\n");
    for (d = xml_node_data(xml_node_find(x, "query", &xmpp->xml.mem),
                           &xmpp->xml.mem);
            d;
            d = xml_data_next(d, &xmpp->xml.mem)) {
        if (d->type != XML_NODE)
            continue;
        jid = xml_node_find_attr(d->value, "jid", &xmpp->xml.mem);
        if (jid)
            xmpp_printf(xmpp, "<presence type='probe' to='%s'/>", jid);
    }
}