void con_room_sendwalk(gpointer key, gpointer data, gpointer arg) { xmlnode x = (xmlnode)arg; cnu to = (cnu)data; cnu from; xmlnode output; if(x == NULL || to == NULL) { log_warn(NAME, "[%s] Aborting - NULL attribute found", FZONE); return; } if (to->remote == 1) return; from = (cnu)xmlnode_get_vattrib(x,"cnu"); if(j_strcmp(xmlnode_get_name(x),"presence") == 0) { output = add_extended_presence(from, to, x, NULL, NULL, NULL); if(jid_cmp(to->realid,from->realid)==0) //own presence { add_status_code(output, STATUS_MUC_OWN_PRESENCE); } con_user_send(to, from, output); } else { con_user_send(to, from, xmlnode_dup(x)); /* Need to send duplicate */ } }
result dnsrv_deliver(instance i, dpacket p, void* args) { dns_io di = (dns_io)args; xmlnode c; int timeout = di->cache_timeout; char *ip; jid to; /* if we get a route packet, it has to be to *us* and have the child as the real packet */ if(p->type == p_ROUTE) { if(j_strcmp(p->host,i->id) != 0 || (to = jid_new(p->p,xmlnode_get_attrib(xmlnode_get_firstchild(p->x),"to"))) == NULL) return r_ERR; p->x=xmlnode_get_firstchild(p->x); p->id = to; p->host = to->server; } /* Ensure this packet doesn't already have an IP */ if(xmlnode_get_attrib(p->x, "ip") || xmlnode_get_attrib(p->x, "iperror")) { log_notice(p->host, "dropping looping dns lookup request: %s", xmlnode2str(p->x)); xmlnode_free(p->x); return r_DONE; } /* try the cache first */ if((c = xhash_get(di->cache_table, p->host)) != NULL) { /* if there's no IP, cached failed lookup, time those out 10 times faster! (weird, I know, *shrug*) */ if((ip = xmlnode_get_attrib(c,"ip")) == NULL) timeout = timeout / 10; if((time(NULL) - (int)xmlnode_get_vattrib(c,"t")) > timeout) { /* timed out of the cache, lookup again */ xmlnode_free(c); xhash_zap(di->cache_table,p->host); }else{ /* yay, send back right from the cache */ dnsrv_resend(p->x, ip, xmlnode_get_attrib(c,"to")); return r_DONE; } } dnsrv_lookup(di, p); return r_DONE; }
void con_get_affiliate_list(gpointer key, gpointer data, gpointer arg) { xmlnode node; cnr room; taffil affiliation; jid userid; char *actor; char *reason; xmlnode result = (xmlnode)arg; xmlnode item = (xmlnode)data; if(result == NULL || item == NULL) { log_warn(NAME, "[%s] Aborting: NULL attribute(s) - <%s>", FZONE, (char *) key); return; } actor = xmlnode_get_attrib(item, "actor"); reason = xmlnode_get_data(item); room = (cnr)xmlnode_get_vattrib(result ,"cnr"); node = xmlnode_insert_tag(result, "item"); userid = jid_new(xmlnode_pool(node), key); xmlnode_put_attrib(node, "jid", key); affiliation = affiliation_level(room, userid); xmlnode_put_attrib(node, "affiliation", affiliation.msg); if(reason != NULL) xmlnode_insert_cdata(xmlnode_insert_tag(node, "reason"), reason, -1); if(actor != NULL) xmlnode_insert_cdata(xmlnode_insert_tag(node, "actor"), actor, -1); }
void con_get_role_list(gpointer key, gpointer data, gpointer arg) { xmlnode node; xmlnode result; taffil affiliation; trole role; jid userid; cnr room; result = (xmlnode)arg; if(result == NULL) { log_warn(NAME, "[%s] Aborting: NULL result - <%s>", FZONE, (char*) key); return; } room = (cnr)xmlnode_get_vattrib(result ,"cnr"); if(room == NULL) { log_warn(NAME, "[%s] Aborting: NULL room - <%s>", FZONE, (char*) key); return; } node = xmlnode_insert_tag(result, "item"); userid = jid_new(xmlnode_pool(node), key); xmlnode_put_attrib(node, "jid", key); affiliation = affiliation_level(room, userid); role = role_level(room, userid); xmlnode_put_attrib(node, "role", role.msg); xmlnode_put_attrib(node, "affiliation", affiliation.msg); }