XMPP_SEND_JOIN,
XMPP_READY,
XMPP_IN_IQ,
+ XMPP_IN_VCARD,
XMPP_IN_MESSAGE,
XMPP_IN_PRESENCE,
} xmpp_state_t;
int timeout;
const char *host;
int port;
+ const char *srv;
const char *muc;
const char *nick;
const char *jid;
split_jid(jid, jid_usr, jid_srv, NULL);
snprintf(dest, JID_LEN, "%s@%s", jid_usr,
jid_srv[0] ? jid_srv :
- is_muc ? srv->muc : srv->host);
+ is_muc ? srv->muc : srv->srv);
/* Server channels */
- if (match(jid, srv->host))
+ if (match(jid, srv->srv))
return &srv->system;
/* Find existing channels */
" xml:lang='en'"
" xmlns='jabber:client'"
" xmlns:stream='http://etherx.jabber.org/streams'>",
- srv->jid, srv->host)) {
+ srv->jid, srv->srv)) {
debug("xmpp: stream -> features");
srv->state = XMPP_RECV_FEATURES;
}
"<iq id='session' type='set' to='%s'>"
"<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>"
"</iq>",
- srv->host)) {
+ srv->srv)) {
debug("xmpp: session -> presence");
srv->state = XMPP_SEND_PRESENCE;
}
srv->msg_chan->channel.name);
}
}
- if (srv->state == XMPP_IN_IQ ||
- srv->state == XMPP_IN_MESSAGE ||
- srv->state == XMPP_IN_PRESENCE) {
+ if (srv->state > XMPP_READY) {
if (srv->msg_chan && srv->msg_chan != &srv->system)
chan = srv->msg_chan;
}
}
}
+ /* vCards */
+ if (srv->state == XMPP_IN_IQ) {
+ if (match(start, "vCard")) {
+ if (chan)
+ chan_notice(chan, "vCard for %s", chan->dest);
+ srv->state = XMPP_IN_VCARD;
+ }
+ }
+ if (srv->state == XMPP_IN_VCARD) {
+ if (end && chan && data) {
+ chan_notice(chan, "%-12s -- %s", end, data);
+ }
+ if (match(end, "vCard")) {
+ srv->state = XMPP_IN_IQ;
+ }
+ }
+
/* Messages */
if (srv->state == XMPP_IN_MESSAGE) {
if (match(start, "delay")) {
if (!srv->port)
srv->port = 5222;
+ if (!srv->srv)
+ srv->srv = strcopy(srv->host);
if (!srv->jid)
error("jid is required");
if (!srv->timeout)
srv->host = get_string(value);
else if (match(key, "port"))
srv->port = get_number(value);
+ else if (match(key, "srv"))
+ srv->srv = get_string(value);
else if (match(key, "muc"))
srv->muc = get_string(value);
else if (match(key, "nick"))
"<iq id='items' type='get' from='%s' to='%s'>"
"<query xmlns='http://jabber.org/protocol/disco#items'/>"
"</iq>",
- srv->jid, arg ?: srv->host);
+ srv->jid, arg ?: srv->srv);
}
else if (prefix(text, "/info", &arg)) {
net_print(&srv->net,
"<iq id='info' type='get' from='%s' to='%s'>"
"<query xmlns='http://jabber.org/protocol/disco#info'/>"
"</iq>",
- srv->jid, arg ?: srv->host);
+ srv->jid, arg ?: srv->srv);
}
else if (prefix(text, "/names", &arg)) {
if (arg)
chan = find_dest(srv, arg, 0);
chan_notice(chan, "User: %s", arg);
}
+ else if (prefix(text, "/vcard", &arg)) {
+ if (arg)
+ chan = find_dest(srv, arg, 0);
+ if (chan)
+ net_print(&srv->net,
+ "<iq id='vcard' type='get' from='%s' to='%s'>"
+ "<vCard xmlns='vcard-temp'/>"
+ "</iq>",
+ srv->jid, chan->dest);
+ }
else {
chan_notice(chan, "Unknown command %s", text);
}