annotate src/protocols/jabber/oob.c @ 10554:0ad82505bde8

[gaim-migrate @ 11931] Buddies can be in more than one group (at least on some protocols), so we should update their status/idle/warning/etc. in all groups. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 29 Jan 2005 18:03:48 +0000
parents 9171e528d7e5
children bd8ac1d4b2f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
2 * gaim - Jabber Protocol Plugin
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 *
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 */
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
7234
cd0cedf0edd0 [gaim-migrate @ 7806]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
22 #include "debug.h"
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "ft.h"
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24 #include "util.h"
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
26 #include "jabber.h"
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 #include "iq.h"
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29 typedef struct _JabberOOBXfer {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 char *address;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31 int port;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 char *page;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34 GString *headers;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35 gboolean newline;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 char *iq_id;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39 JabberStream *js;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41 } JabberOOBXfer;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43 static void jabber_oob_xfer_init(GaimXfer *xfer)
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44 {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45 JabberOOBXfer *jox = xfer->data;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46 gaim_xfer_start(xfer, -1, jox->address, jox->port);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49 static void jabber_oob_xfer_free(GaimXfer *xfer)
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51 JabberOOBXfer *jox = xfer->data;
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7234
diff changeset
52 jox->js->oob_file_transfers = g_list_remove(jox->js->oob_file_transfers,
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7234
diff changeset
53 xfer);
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
54
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
55 g_string_free(jox->headers, TRUE);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
56 g_free(jox->address);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57 g_free(jox->page);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58 g_free(jox->iq_id);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
59 g_free(jox);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
61 xfer->data = NULL;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
63
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
64 static void jabber_oob_xfer_end(GaimXfer *xfer)
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
65 {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
66 JabberOOBXfer *jox = xfer->data;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
67 JabberIq *iq;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
68
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
69 iq = jabber_iq_new(jox->js, JABBER_IQ_RESULT);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
70 xmlnode_set_attrib(iq->node, "to", xfer->who);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71 jabber_iq_set_id(iq, jox->iq_id);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
72
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
73 jabber_iq_send(iq);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
74
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
75 jabber_oob_xfer_free(xfer);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
76 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
77
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
78 static void jabber_oob_xfer_start(GaimXfer *xfer)
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79 {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
80 JabberOOBXfer *jox = xfer->data;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
81
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
82 char *buf = g_strdup_printf("GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n",
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
83 jox->page, jox->address);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
84 write(xfer->fd, buf, strlen(buf));
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
85 g_free(buf);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
86 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
87
8231
f50c059b6384 [gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents: 7395
diff changeset
88 static ssize_t jabber_oob_xfer_read(char **buffer, GaimXfer *xfer) {
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
89 JabberOOBXfer *jox = xfer->data;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
90 char test;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
91 int size;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
92
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 if(read(xfer->fd, &test, sizeof(test)) > 0) {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94 jox->headers = g_string_append_c(jox->headers, test);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95 if(test == '\r')
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
96 return 0;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
97 if(test == '\n') {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
98 if(jox->newline) {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99 gchar *lenstr = strstr(jox->headers->str, "Content-Length: ");
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100 if(lenstr) {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101 sscanf(lenstr, "Content-Length: %d", &size);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
102 gaim_xfer_set_size(xfer, size);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
104 gaim_xfer_set_read_fnc(xfer, NULL);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
105 return 0;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106 } else
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
107 jox->newline = TRUE;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108 return 0;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
109 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
110 jox->newline = FALSE;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111 return 0;
7234
cd0cedf0edd0 [gaim-migrate @ 7806]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
112 } else {
cd0cedf0edd0 [gaim-migrate @ 7806]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
113 gaim_debug(GAIM_DEBUG_ERROR, "jabber", "Read error on oob xfer!\n");
cd0cedf0edd0 [gaim-migrate @ 7806]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
114 gaim_xfer_cancel_local(xfer);
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
115 }
7234
cd0cedf0edd0 [gaim-migrate @ 7806]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
116
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
117 return 0;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
118 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
119
8399
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
120 static void jabber_oob_xfer_recv_error(GaimXfer *xfer, const char *code) {
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
121 JabberOOBXfer *jox = xfer->data;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
122 JabberIq *iq;
8399
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
123 xmlnode *y, *z;
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
124
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
125 iq = jabber_iq_new(jox->js, JABBER_IQ_ERROR);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
126 xmlnode_set_attrib(iq->node, "to", xfer->who);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
127 jabber_iq_set_id(iq, jox->iq_id);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
128 y = xmlnode_new_child(iq->node, "error");
8399
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
129 xmlnode_set_attrib(y, "code", code);
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
130 if(!strcmp(code, "406")) {
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
131 z = xmlnode_new_child(y, "not-acceptable");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
132 xmlnode_set_attrib(y, "type", "modify");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
133 xmlnode_set_attrib(z, "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
134 } else if(!strcmp(code, "404")) {
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
135 z = xmlnode_new_child(y, "not-found");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
136 xmlnode_set_attrib(y, "type", "cancel");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
137 xmlnode_set_attrib(z, "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
138 }
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
139 jabber_iq_send(iq);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
140
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
141 jabber_oob_xfer_free(xfer);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
142 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
143
8399
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
144 static void jabber_oob_xfer_recv_denied(GaimXfer *xfer) {
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
145 jabber_oob_xfer_recv_error(xfer, "406");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
146 }
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
147
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
148 static void jabber_oob_xfer_recv_canceled(GaimXfer *xfer) {
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
149 jabber_oob_xfer_recv_error(xfer, "404");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
150 }
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
151
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
152 void jabber_oob_parse(JabberStream *js, xmlnode *packet) {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
153 JabberOOBXfer *jox;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
154 GaimXfer *xfer;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
155 char *filename;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
156 char *url;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
157 xmlnode *querynode, *urlnode;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
158
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
159 if(!(querynode = xmlnode_get_child(packet, "query")))
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
160 return;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
161
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
162 if(!(urlnode = xmlnode_get_child(querynode, "url")))
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163 return;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
165 url = xmlnode_get_data(urlnode);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
166
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
167 jox = g_new0(JabberOOBXfer, 1);
9227
9171e528d7e5 [gaim-migrate @ 10023]
Christian Hammond <chipx86@chipx86.com>
parents: 8399
diff changeset
168 gaim_url_parse(url, &jox->address, &jox->port, &jox->page, NULL, NULL);
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
169 g_free(url);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
170 jox->js = js;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
171 jox->headers = g_string_new("");
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
172 jox->iq_id = g_strdup(xmlnode_get_attrib(packet, "id"));
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
173
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174 xfer = gaim_xfer_new(js->gc->account, GAIM_XFER_RECEIVE,
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
175 xmlnode_get_attrib(packet, "from"));
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
176 xfer->data = jox;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
177
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
178 if(!(filename = g_strdup(g_strrstr(jox->page, "/"))))
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
179 filename = g_strdup(jox->page);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
180
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
181 gaim_xfer_set_filename(xfer, filename);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
182
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
183 g_free(filename);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
184
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
185 gaim_xfer_set_init_fnc(xfer, jabber_oob_xfer_init);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
186 gaim_xfer_set_end_fnc(xfer, jabber_oob_xfer_end);
8399
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
187 gaim_xfer_set_request_denied_fnc(xfer, jabber_oob_xfer_recv_denied);
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
188 gaim_xfer_set_cancel_recv_fnc(xfer, jabber_oob_xfer_recv_canceled);
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
189 gaim_xfer_set_read_fnc(xfer, jabber_oob_xfer_read);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
190 gaim_xfer_set_start_fnc(xfer, jabber_oob_xfer_start);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
191
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7234
diff changeset
192 js->oob_file_transfers = g_list_append(js->oob_file_transfers, xfer);
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
193
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
194 gaim_xfer_request(xfer);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
195 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
196
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
197