[ekg2-commit] ekg2: jabber_handlers.c (HEAD) [darkjames]
CVS commit
cvs w toxygen.net
Śro, 26 Gru 2007, 12:01:55 CET
Module name: ekg2
Changes by: darkjames 2007-12-26 12:01:53
Modified files:
jabber_handlers.c
Log message:
remove JABBER_HANDLER_IQ(jabber_handle_bytestreams)
Index: jabber_handlers.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/jabber/jabber_handlers.c,v
diff -d -u -r1.136 -r1.137
--- jabber_handlers.c 26 Dec 2007 09:41:00 -0000 1.136
+++ jabber_handlers.c 26 Dec 2007 11:01:53 -0000 1.137
@@ -1450,159 +1450,6 @@
}
}
-JABBER_HANDLER_IQ(jabber_handle_bytestreams) {
- jabber_private_t *j = s->priv;
-
- char *uid = jabber_unescape(from); /* jid */
- char *sid = jabber_attr(n->atts, "sid"); /* session id */
-#if 0 /* unused */
- char *smode = jabber_attr(q->atts, "mode"); /* tcp, udp */
-#endif
- dcc_t *d = NULL;
-
- if (iqtype == JABBER_IQ_TYPE_SET && (d = jabber_dcc_find(uid, NULL, sid))) {
- /* w sumie jak nie mamy nawet tego dcc.. to mozemy kontynuowac ;) */
- /* problem w tym czy user chce ten plik.. etc.. */
- /* i tak to na razie jest jeden wielki hack, trzeba sprawdzac czy to dobry typ dcc. etc, XXX */
- xmlnode_t *node;
- jabber_dcc_t *p = d->priv;
- jabber_dcc_bytestream_t *b = NULL;
-
- list_t host_list = NULL, l;
- struct jabber_streamhost_item *streamhost;
-
- if (d->type == DCC_SEND) {
- watch_write(j->send_watch,
- "<iq type=\"error\" to=\"%s\" id=\"%s\"><error code=\"406\">Declined</error></iq>", d->uid+5, id);
- return;
- }
-
- p->protocol = JABBER_DCC_PROTOCOL_BYTESTREAMS;
-
- xfree(p->req);
- p->req = xstrdup(id);
- /* XXX, set our streamhost && send them too */
- for (node = n->children; node; node = node->next) {
- if (!xstrcmp(node->name, "streamhost")) {
- struct jabber_streamhost_item *newstreamhost = xmalloc(sizeof(struct jabber_streamhost_item));
-
- newstreamhost->ip = xstrdup(jabber_attr(node->atts, "host")); /* XXX in host can be hostname */
- newstreamhost->port = atoi(jabber_attr(node->atts, "port"));
- newstreamhost->jid = xstrdup(jabber_attr(node->atts, "jid"));
- list_add(&host_list, newstreamhost, 0);
- }
- }
- l = host_list;
-find_streamhost:
- streamhost = NULL;
- for (; l; l = l->next) {
- struct jabber_streamhost_item *item = l->data;
- struct sockaddr_in sin;
- /* let's search the list for ipv4 address... for now only this we can handle */
- if ((inet_pton(AF_INET, item->ip, &(sin.sin_addr)) > 0)) {
- streamhost = host_list->data;
- break;
- }
- }
-
- if (streamhost) {
- struct sockaddr_in sin;
- int fd;
- char socks5[4];
-
- fd = socket(AF_INET, SOCK_STREAM, 0);
-
- sin.sin_family = AF_INET;
- sin.sin_port = htons(streamhost->port);
- inet_pton(AF_INET, streamhost->ip, &(sin.sin_addr));
-
- if (connect(fd, (struct sockaddr *) &sin, sizeof(struct sockaddr_in)) == -1) {
- /* let's try connect once more to another host? */
- debug_error("[jabber] dcc connecting to: %s failed (%s)\n", streamhost->ip, strerror(errno));
- goto find_streamhost;
- }
- p->sfd = fd;
-
- watch_add(&jabber_plugin, fd, WATCH_READ, jabber_dcc_handle_recv, d);
-
- p->private.bytestream = b = xmalloc(sizeof(jabber_dcc_bytestream_t));
- b->validate = JABBER_DCC_PROTOCOL_BYTESTREAMS;
- b->step = SOCKS5_CONNECT;
- b->streamlist = host_list;
- b->streamhost = streamhost;
-
- socks5[0] = 0x05; /* socks version 5 */
- socks5[1] = 0x02; /* number of methods */
- socks5[2] = 0x00; /* no auth */
- socks5[3] = 0x02; /* username */
- write(fd, (char *) &socks5, sizeof(socks5));
- } else {
- list_t l;
-
- debug_error("[jabber] We cannot connect to any streamhost with ipv4 address.. sorry, closing connection.\n");
-
- for (l = host_list; l; l = l->next) {
- struct jabber_streamhost_item *i = l->data;
-
- xfree(i->jid);
- xfree(i->ip);
- }
- list_destroy(host_list, 1);
-
- watch_write(j->send_watch,
- "<iq type=\"error\" to=\"%s\" id=\"%s\"><error code=\"404\" type=\"cancel\">"
- /* Psi: <error code='404'>Could not connect to given hosts</error> */
- "<item-not-found xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
- "</error></iq>", d->uid+5, id);
-
- print("dcc_error_refused", format_user(s, d->uid));
-
- d->active = 1; /* hack to avoid sending 403 */
- dcc_close(d); /* zamykamy dcc */
- }
- } else if (iqtype == JABBER_IQ_TYPE_RESULT) {
- xmlnode_t *used = xmlnode_find_child(n, "streamhost-used");
- jabber_dcc_t *p;
- jabber_dcc_bytestream_t *b;
- list_t l;
-
- if ((d = jabber_dcc_find(uid, id, NULL))) {
- char *usedjid = (used) ? jabber_attr(used->atts, "jid") : NULL;
- watch_t *w;
-
- p = d->priv;
- b = p->private.bytestream;
-
- for (l = b->streamlist; l; l = l->next) {
- struct jabber_streamhost_item *item = l->data;
- if (!xstrcmp(item->jid, usedjid)) {
- b->streamhost = item;
- }
- }
- debug_function("[STREAMHOST-USED] stream: 0x%x\n", b->streamhost);
- d->active = 1;
-
- w = watch_find(&jabber_plugin, p->sfd, WATCH_NONE);
-
- if (w && /* w->handler == jabber_dcc_handle_send && */ w->data == d)
- w->type = WATCH_WRITE;
- else {
- debug_error("[jabber] %s:%d WATCH BAD DATA/NOT FOUND, 0x%x 0x%x 0x%x\n", __FILE__, __LINE__, w, w ? w->handler : NULL, w ? w->data : NULL);
- /* XXX, SHOW ERROR ON __STATUS */
- dcc_close(d);
- return;
- }
-
- { /* activate stream */
- char buf[1];
- buf[0] = '\r';
- write(p->sfd, &buf[0], 1);
- }
- }
- }
- debug_function("[FILE - BYTESTREAMS] 0x%x\n", d);
-}
-
struct jabber_iq_generic_handler {
const char *name;
const char *xmlns;
Więcej informacji o liście dyskusyjnej ekg2-commit