annotate src/protocols/jabber/oob.c @ 12339:fdac1c5e6c68

[gaim-migrate @ 14643] Don't show offline bonjour uses as away. Of course, the only time you would ever have an offline bonjour user is if you add some random person to your buddy list committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 05 Dec 2005 03:42:48 +0000
parents 90f488e08216
children 33bef17125c2
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"
12324
90f488e08216 [gaim-migrate @ 14628]
Richard Laager <rlaager@wiktel.com>
parents: 12323
diff changeset
28 #include "oob.h"
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 typedef struct _JabberOOBXfer {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31 char *address;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 int port;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33 char *page;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35 GString *headers;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36 gboolean newline;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38 char *iq_id;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40 JabberStream *js;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42 } JabberOOBXfer;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44 static void jabber_oob_xfer_init(GaimXfer *xfer)
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45 {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46 JabberOOBXfer *jox = xfer->data;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 gaim_xfer_start(xfer, -1, jox->address, jox->port);
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
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 static void jabber_oob_xfer_free(GaimXfer *xfer)
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51 {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52 JabberOOBXfer *jox = xfer->data;
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7234
diff changeset
53 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
54 xfer);
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
55
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
56 g_string_free(jox->headers, TRUE);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57 g_free(jox->address);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58 g_free(jox->page);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
59 g_free(jox->iq_id);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60 g_free(jox);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
61
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62 xfer->data = NULL;
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
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
65 static void jabber_oob_xfer_end(GaimXfer *xfer)
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
66 {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
67 JabberOOBXfer *jox = xfer->data;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
68 JabberIq *iq;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
69
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
70 iq = jabber_iq_new(jox->js, JABBER_IQ_RESULT);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71 xmlnode_set_attrib(iq->node, "to", xfer->who);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
72 jabber_iq_set_id(iq, jox->iq_id);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
73
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
74 jabber_iq_send(iq);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
75
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
76 jabber_oob_xfer_free(xfer);
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
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79 static void jabber_oob_xfer_start(GaimXfer *xfer)
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
80 {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
81 JabberOOBXfer *jox = xfer->data;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
82
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
83 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
84 jox->page, jox->address);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
85 write(xfer->fd, buf, strlen(buf));
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
86 g_free(buf);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
87 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
88
12151
de798f2f4bf1 [gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents: 11159
diff changeset
89 static gssize jabber_oob_xfer_read(guchar **buffer, GaimXfer *xfer) {
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
90 JabberOOBXfer *jox = xfer->data;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
91 char test;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
92 int size;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94 if(read(xfer->fd, &test, sizeof(test)) > 0) {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95 jox->headers = g_string_append_c(jox->headers, test);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
96 if(test == '\r')
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
97 return 0;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
98 if(test == '\n') {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99 if(jox->newline) {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100 gchar *lenstr = strstr(jox->headers->str, "Content-Length: ");
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101 if(lenstr) {
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
102 sscanf(lenstr, "Content-Length: %d", &size);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103 gaim_xfer_set_size(xfer, size);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
104 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
105 gaim_xfer_set_read_fnc(xfer, NULL);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106 return 0;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
107 } else
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108 jox->newline = TRUE;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
109 return 0;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
110 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111 jox->newline = FALSE;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
112 return 0;
7234
cd0cedf0edd0 [gaim-migrate @ 7806]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
113 } else {
cd0cedf0edd0 [gaim-migrate @ 7806]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
114 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
115 gaim_xfer_cancel_local(xfer);
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
116 }
7234
cd0cedf0edd0 [gaim-migrate @ 7806]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
117
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
118 return 0;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
119 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
120
8399
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
121 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
122 JabberOOBXfer *jox = xfer->data;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
123 JabberIq *iq;
8399
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
124 xmlnode *y, *z;
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
125
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
126 iq = jabber_iq_new(jox->js, JABBER_IQ_ERROR);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
127 xmlnode_set_attrib(iq->node, "to", xfer->who);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
128 jabber_iq_set_id(iq, jox->iq_id);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
129 y = xmlnode_new_child(iq->node, "error");
8399
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
130 xmlnode_set_attrib(y, "code", code);
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
131 if(!strcmp(code, "406")) {
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
132 z = xmlnode_new_child(y, "not-acceptable");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
133 xmlnode_set_attrib(y, "type", "modify");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
134 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
135 } else if(!strcmp(code, "404")) {
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
136 z = xmlnode_new_child(y, "not-found");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
137 xmlnode_set_attrib(y, "type", "cancel");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
138 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
139 }
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
140 jabber_iq_send(iq);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
141
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
142 jabber_oob_xfer_free(xfer);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
143 }
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
144
8399
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
145 static void jabber_oob_xfer_recv_denied(GaimXfer *xfer) {
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
146 jabber_oob_xfer_recv_error(xfer, "406");
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
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
149 static void jabber_oob_xfer_recv_canceled(GaimXfer *xfer) {
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
150 jabber_oob_xfer_recv_error(xfer, "404");
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
151 }
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
152
12324
90f488e08216 [gaim-migrate @ 14628]
Richard Laager <rlaager@wiktel.com>
parents: 12323
diff changeset
153 void jabber_oob_parse(JabberStream *js, xmlnode *packet) {
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
154 JabberOOBXfer *jox;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
155 GaimXfer *xfer;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
156 char *filename;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
157 char *url;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
158 xmlnode *querynode, *urlnode;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
159
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
160 if(!(querynode = xmlnode_get_child(packet, "query")))
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
161 return;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
162
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163 if(!(urlnode = xmlnode_get_child(querynode, "url")))
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164 return;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
165
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
166 url = xmlnode_get_data(urlnode);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
167
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
168 jox = g_new0(JabberOOBXfer, 1);
9227
9171e528d7e5 [gaim-migrate @ 10023]
Christian Hammond <chipx86@chipx86.com>
parents: 8399
diff changeset
169 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
170 g_free(url);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
171 jox->js = js;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
172 jox->headers = g_string_new("");
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
173 jox->iq_id = g_strdup(xmlnode_get_attrib(packet, "id"));
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
175 xfer = gaim_xfer_new(js->gc->account, GAIM_XFER_RECEIVE,
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
176 xmlnode_get_attrib(packet, "from"));
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
177 xfer->data = jox;
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
178
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
179 if(!(filename = g_strdup(g_strrstr(jox->page, "/"))))
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
180 filename = g_strdup(jox->page);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
181
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
182 gaim_xfer_set_filename(xfer, filename);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
183
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
184 g_free(filename);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
185
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
186 gaim_xfer_set_init_fnc(xfer, jabber_oob_xfer_init);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
187 gaim_xfer_set_end_fnc(xfer, jabber_oob_xfer_end);
8399
681b1661ee8b [gaim-migrate @ 9128]
Nathan Walp <nwalp@pidgin.im>
parents: 8311
diff changeset
188 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
189 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
190 gaim_xfer_set_read_fnc(xfer, jabber_oob_xfer_read);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
191 gaim_xfer_set_start_fnc(xfer, jabber_oob_xfer_start);
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
192
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7234
diff changeset
193 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
194
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
195 gaim_xfer_request(xfer);
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
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
198