Mercurial > pidgin.yaz
annotate src/protocols/jabber/jabber.c @ 13942:b14fdab68eac
[gaim-migrate @ 16478]
It would be wise to fix the comments
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 10 Jul 2006 18:08:11 +0000 |
parents | 46be62b128c7 |
children | 6fc412e59214 |
rev | line source |
---|---|
2086 | 1 /* |
7014 | 2 * gaim - Jabber Protocol Plugin |
2086 | 3 * |
7014 | 4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> |
2086 | 5 * |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
7014 | 10 * |
2086 | 11 * This program is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
21 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
22 |
7014 | 23 #include "account.h" |
24 #include "accountopt.h" | |
9030 | 25 #include "blist.h" |
9130 | 26 #include "cmds.h" |
10740 | 27 #include "connection.h" |
7014 | 28 #include "debug.h" |
11387 | 29 #include "dnssrv.h" |
7014 | 30 #include "message.h" |
7072 | 31 #include "notify.h" |
8713 | 32 #include "pluginpref.h" |
7014 | 33 #include "prpl.h" |
7072 | 34 #include "request.h" |
7014 | 35 #include "server.h" |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
36 #include "util.h" |
9943 | 37 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
38 |
7014 | 39 #include "auth.h" |
40 #include "buddy.h" | |
41 #include "chat.h" | |
8312 | 42 #include "disco.h" |
7014 | 43 #include "iq.h" |
44 #include "jutil.h" | |
45 #include "message.h" | |
46 #include "parser.h" | |
47 #include "presence.h" | |
48 #include "jabber.h" | |
49 #include "roster.h" | |
9466 | 50 #include "si.h" |
7923 | 51 #include "xdata.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
52 |
7014 | 53 #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5) |
2086 | 54 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
55 static GaimPlugin *my_protocol = NULL; |
4249 | 56 |
7014 | 57 static void jabber_stream_init(JabberStream *js) |
58 { | |
59 char *open_stream; | |
3340 | 60 |
7014 | 61 open_stream = g_strdup_printf("<stream:stream to='%s' " |
62 "xmlns='jabber:client' " | |
7395 | 63 "xmlns:stream='http://etherx.jabber.org/streams' " |
64 "version='1.0'>", | |
7291 | 65 js->user->domain); |
13806 | 66 /* setup the parser fresh for each stream */ |
67 jabber_parser_setup(js); | |
7642 | 68 jabber_send_raw(js, open_stream, -1); |
7014 | 69 g_free(open_stream); |
2086 | 70 } |
71 | |
7395 | 72 static void |
73 jabber_session_initialized_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
3311 | 74 { |
7014 | 75 const char *type = xmlnode_get_attrib(packet, "type"); |
76 if(type && !strcmp(type, "result")) { | |
77 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
78 } else { | |
79 gaim_connection_error(js->gc, _("Error initializing session")); | |
3311 | 80 } |
81 } | |
82 | |
7014 | 83 static void jabber_session_init(JabberStream *js) |
3311 | 84 { |
7014 | 85 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); |
86 xmlnode *session; | |
3311 | 87 |
7395 | 88 jabber_iq_set_callback(iq, jabber_session_initialized_cb, NULL); |
3311 | 89 |
7014 | 90 session = xmlnode_new_child(iq->node, "session"); |
13806 | 91 xmlnode_set_namespace(session, "urn:ietf:params:xml:ns:xmpp-session"); |
3311 | 92 |
7014 | 93 jabber_iq_send(iq); |
3311 | 94 } |
95 | |
7395 | 96 static void jabber_bind_result_cb(JabberStream *js, xmlnode *packet, |
97 gpointer data) | |
98 { | |
8401 | 99 const char *type = xmlnode_get_attrib(packet, "type"); |
100 xmlnode *bind; | |
101 | |
102 if(type && !strcmp(type, "result") && | |
103 (bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) { | |
104 xmlnode *jid; | |
105 char *full_jid; | |
106 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) { | |
10289 | 107 JabberBuddy *my_jb = NULL; |
8401 | 108 jabber_id_free(js->user); |
109 if(!(js->user = jabber_id_new(full_jid))) { | |
110 gaim_connection_error(js->gc, _("Invalid response from server.")); | |
111 } | |
10289 | 112 if((my_jb = jabber_buddy_find(js, full_jid, TRUE))) |
113 my_jb->subscription |= JABBER_SUB_BOTH; | |
10504 | 114 g_free(full_jid); |
8401 | 115 } |
116 } else { | |
117 char *msg = jabber_parse_error(js, packet); | |
118 gaim_connection_error(js->gc, msg); | |
119 g_free(msg); | |
120 } | |
7395 | 121 |
122 jabber_session_init(js); | |
123 } | |
124 | |
125 static void jabber_stream_features_parse(JabberStream *js, xmlnode *packet) | |
126 { | |
8296 | 127 if(xmlnode_get_child(packet, "starttls")) { |
128 if(jabber_process_starttls(js, packet)) | |
129 return; | |
130 } | |
131 | |
10988 | 132 if(js->registration) { |
133 jabber_register_start(js); | |
134 } else if(xmlnode_get_child(packet, "mechanisms")) { | |
7395 | 135 jabber_auth_start(js, packet); |
136 } else if(xmlnode_get_child(packet, "bind")) { | |
137 xmlnode *bind, *resource; | |
138 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); | |
139 bind = xmlnode_new_child(iq->node, "bind"); | |
13806 | 140 xmlnode_set_namespace(bind, "urn:ietf:params:xml:ns:xmpp-bind"); |
7395 | 141 resource = xmlnode_new_child(bind, "resource"); |
142 xmlnode_insert_data(resource, js->user->resource, -1); | |
143 | |
144 jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL); | |
145 | |
146 jabber_iq_send(iq); | |
8296 | 147 } else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ { |
148 /* If we get an empty stream:features packet, or we explicitly get | |
149 * an auth feature with namespace http://jabber.org/features/iq-auth | |
150 * we should revert back to iq:auth authentication, even though we're | |
151 * connecting to an XMPP server. */ | |
152 js->auth_type = JABBER_AUTH_IQ_AUTH; | |
153 jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING); | |
7395 | 154 } |
155 } | |
156 | |
7014 | 157 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet) |
3311 | 158 { |
8401 | 159 char *msg = jabber_parse_error(js, packet); |
3311 | 160 |
8401 | 161 gaim_connection_error(js->gc, msg); |
162 g_free(msg); | |
2086 | 163 } |
164 | |
7014 | 165 static void tls_init(JabberStream *js); |
2086 | 166 |
7014 | 167 void jabber_process_packet(JabberStream *js, xmlnode *packet) |
2086 | 168 { |
7014 | 169 if(!strcmp(packet->name, "iq")) { |
7395 | 170 jabber_iq_parse(js, packet); |
7014 | 171 } else if(!strcmp(packet->name, "presence")) { |
172 jabber_presence_parse(js, packet); | |
173 } else if(!strcmp(packet->name, "message")) { | |
174 jabber_message_parse(js, packet); | |
175 } else if(!strcmp(packet->name, "stream:features")) { | |
7395 | 176 jabber_stream_features_parse(js, packet); |
13806 | 177 } else if (!strcmp(packet->name, "features") && |
178 !strcmp(xmlnode_get_namespace(packet), "http://etherx.jabber.org/streams")) { | |
179 jabber_stream_features_parse(js, packet); | |
7014 | 180 } else if(!strcmp(packet->name, "stream:error")) { |
181 jabber_stream_handle_error(js, packet); | |
13806 | 182 } else if (!strcmp(packet->name, "error") && |
183 !strcmp(xmlnode_get_namespace(packet), "http://etherx.jabber.org/streams")) { | |
184 jabber_stream_handle_error(js, packet); | |
7014 | 185 } else if(!strcmp(packet->name, "challenge")) { |
186 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
187 jabber_auth_handle_challenge(js, packet); | |
188 } else if(!strcmp(packet->name, "success")) { | |
189 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
190 jabber_auth_handle_success(js, packet); | |
191 } else if(!strcmp(packet->name, "failure")) { | |
192 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
193 jabber_auth_handle_failure(js, packet); | |
194 } else if(!strcmp(packet->name, "proceed")) { | |
195 if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc) | |
196 tls_init(js); | |
197 } else { | |
198 gaim_debug(GAIM_DEBUG_WARNING, "jabber", "Unknown packet: %s\n", | |
199 packet->name); | |
2086 | 200 } |
201 } | |
202 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
203 static int jabber_do_send(JabberStream *js, const char *data, int len) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
204 { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
205 int ret; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
206 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
207 if (js->gsc) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
208 ret = gaim_ssl_write(js->gsc, data, len); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
209 else |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
210 ret = write(js->fd, data, len); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
211 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
212 return ret; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
213 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
214 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
215 static void jabber_send_cb(gpointer data, gint source, GaimInputCondition cond) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
216 { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
217 JabberStream *js = data; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
218 int ret, writelen; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
219 writelen = gaim_circ_buffer_get_max_read(js->write_buffer); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
220 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
221 if (writelen == 0) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
222 gaim_input_remove(js->writeh); |
13744 | 223 js->writeh = 0; |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
224 return; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
225 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
226 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
227 ret = jabber_do_send(js, js->write_buffer->outptr, writelen); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
228 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
229 if (ret < 0 && errno == EAGAIN) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
230 return; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
231 else if (ret <= 0) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
232 gaim_connection_error(js->gc, _("Write error")); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
233 return; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
234 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
235 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
236 gaim_circ_buffer_mark_read(js->write_buffer, ret); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
237 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
238 |
7642 | 239 void jabber_send_raw(JabberStream *js, const char *data, int len) |
2086 | 240 { |
7014 | 241 int ret; |
2086 | 242 |
7014 | 243 /* because printing a tab to debug every minute gets old */ |
244 if(strcmp(data, "\t")) | |
8401 | 245 gaim_debug(GAIM_DEBUG_MISC, "jabber", "Sending%s: %s\n", |
7014 | 246 js->gsc ? " (ssl)" : "", data); |
2086 | 247 |
12508 | 248 /* If we've got a security layer, we need to encode the data, |
249 * splitting it on the maximum buffer length negotiated */ | |
250 | |
251 #ifdef HAVE_CYRUS_SASL | |
252 if (js->sasl_maxbuf>0) { | |
253 int pos; | |
254 | |
255 if (!js->gsc && js->fd<0) | |
256 return; | |
257 pos = 0; | |
258 if (len == -1) | |
259 len = strlen(data); | |
260 while (pos < len) { | |
261 int towrite; | |
262 const char *out; | |
263 unsigned olen; | |
264 | |
265 if ((len - pos) < js->sasl_maxbuf) | |
266 towrite = len - pos; | |
267 else | |
268 towrite = js->sasl_maxbuf; | |
269 | |
270 sasl_encode(js->sasl, &data[pos], towrite, &out, &olen); | |
271 pos += towrite; | |
272 | |
13744 | 273 if (js->writeh > 0) |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
274 ret = jabber_do_send(js, out, olen); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
275 else { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
276 ret = -1; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
277 errno = EAGAIN; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
278 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
279 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
280 if (ret < 0 && errno != EAGAIN) |
12508 | 281 gaim_connection_error(js->gc, _("Write error")); |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
282 else if (ret < olen) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
283 if (ret < 0) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
284 ret = 0; |
13744 | 285 if (js->writeh == 0) |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
286 js->writeh = gaim_input_add( |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
287 js->gsc ? js->gsc->fd : js->fd, |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
288 GAIM_INPUT_WRITE, |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
289 jabber_send_cb, js); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
290 gaim_circ_buffer_append(js->write_buffer, |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
291 out + ret, olen - ret); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
292 } |
12508 | 293 } |
294 return; | |
295 } | |
296 #endif | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
297 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
298 if (len == -1) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
299 len = strlen(data); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
300 |
13744 | 301 if (js->writeh == 0) |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
302 ret = jabber_do_send(js, data, len); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
303 else { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
304 ret = -1; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
305 errno = EAGAIN; |
2814
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
306 } |
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
307 |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
308 if (ret < 0 && errno != EAGAIN) |
7014 | 309 gaim_connection_error(js->gc, _("Write error")); |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
310 else if (ret < len) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
311 if (ret < 0) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
312 ret = 0; |
13744 | 313 if (js->writeh == 0) |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
314 js->writeh = gaim_input_add( |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
315 js->gsc ? js->gsc->fd : js->fd, |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
316 GAIM_INPUT_WRITE, jabber_send_cb, js); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
317 gaim_circ_buffer_append(js->write_buffer, |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
318 data + ret, len - ret); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
319 } |
7014 | 320 |
2814
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
321 } |
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
322 |
7014 | 323 void jabber_send(JabberStream *js, xmlnode *packet) |
2086 | 324 { |
7014 | 325 char *txt; |
7642 | 326 int len; |
2086 | 327 |
7642 | 328 txt = xmlnode_to_str(packet, &len); |
329 jabber_send_raw(js, txt, len); | |
7014 | 330 g_free(txt); |
2086 | 331 } |
332 | |
7014 | 333 static void jabber_keepalive(GaimConnection *gc) |
2086 | 334 { |
7642 | 335 jabber_send_raw(gc->proto_data, "\t", -1); |
2086 | 336 } |
337 | |
7014 | 338 static void |
339 jabber_recv_cb_ssl(gpointer data, GaimSslConnection *gsc, | |
6764 | 340 GaimInputCondition cond) |
341 { | |
7014 | 342 GaimConnection *gc = data; |
343 JabberStream *js = gc->proto_data; | |
6764 | 344 int len; |
7014 | 345 static char buf[4096]; |
6768 | 346 |
7014 | 347 if(!g_list_find(gaim_connections_get_all(), gc)) { |
6768 | 348 gaim_ssl_close(gsc); |
349 return; | |
350 } | |
351 | |
13279
0c50401679d3
[gaim-migrate @ 15645]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13274
diff
changeset
|
352 while((len = gaim_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) { |
6764 | 353 buf[len] = '\0'; |
7014 | 354 gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf); |
355 jabber_parser_process(js, buf, len); | |
13279
0c50401679d3
[gaim-migrate @ 15645]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13274
diff
changeset
|
356 } |
0c50401679d3
[gaim-migrate @ 15645]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13274
diff
changeset
|
357 |
0c50401679d3
[gaim-migrate @ 15645]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13274
diff
changeset
|
358 if(errno == EAGAIN) |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
359 return; |
13279
0c50401679d3
[gaim-migrate @ 15645]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13274
diff
changeset
|
360 else |
7177 | 361 gaim_connection_error(gc, _("Read Error")); |
2086 | 362 } |
363 | |
7014 | 364 static void |
365 jabber_recv_cb(gpointer data, gint source, GaimInputCondition condition) | |
2086 | 366 { |
5572 | 367 GaimConnection *gc = data; |
7014 | 368 JabberStream *js = gc->proto_data; |
369 int len; | |
370 static char buf[4096]; | |
2086 | 371 |
7014 | 372 if(!g_list_find(gaim_connections_get_all(), gc)) |
373 return; | |
2956 | 374 |
7014 | 375 if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) { |
12508 | 376 #ifdef HAVE_CYRUS_SASL |
377 if (js->sasl_maxbuf>0) { | |
378 const char *out; | |
379 int olen; | |
380 sasl_decode(js->sasl, buf, len, &out, &olen); | |
381 if (olen>0) { | |
382 gaim_debug(GAIM_DEBUG_INFO, "jabber", "RecvSASL (%d): %s\n", olen, out); | |
383 jabber_parser_process(js,out,olen); | |
384 } | |
385 return; | |
386 } | |
387 #endif | |
7014 | 388 buf[len] = '\0'; |
389 gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf); | |
390 jabber_parser_process(js, buf, len); | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
391 } else if(errno == EAGAIN) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
392 return; |
7177 | 393 } else { |
394 gaim_connection_error(gc, _("Read Error")); | |
7014 | 395 } |
2086 | 396 } |
397 | |
7014 | 398 static void |
399 jabber_login_callback_ssl(gpointer data, GaimSslConnection *gsc, | |
6764 | 400 GaimInputCondition cond) |
401 { | |
402 GaimConnection *gc = data; | |
7014 | 403 JabberStream *js = gc->proto_data; |
6764 | 404 |
7014 | 405 if(!g_list_find(gaim_connections_get_all(), gc)) { |
6764 | 406 gaim_ssl_close(gsc); |
407 return; | |
408 } | |
409 | |
7014 | 410 js->gsc = gsc; |
6764 | 411 |
7014 | 412 if(js->state == JABBER_STREAM_CONNECTING) |
7642 | 413 jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
7014 | 414 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
415 gaim_ssl_input_add(gsc, jabber_recv_cb_ssl, gc); | |
6764 | 416 } |
417 | |
7014 | 418 |
419 static void | |
420 jabber_login_callback(gpointer data, gint source, GaimInputCondition cond) | |
6764 | 421 { |
5572 | 422 GaimConnection *gc = data; |
7014 | 423 JabberStream *js = gc->proto_data; |
2086 | 424 |
8783 | 425 if (source < 0) { |
426 gaim_connection_error(gc, _("Couldn't connect to host")); | |
427 return; | |
428 } | |
429 | |
7014 | 430 if(!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 431 close(source); |
432 return; | |
433 } | |
434 | |
7014 | 435 js->fd = source; |
2956 | 436 |
7014 | 437 if(js->state == JABBER_STREAM_CONNECTING) |
7642 | 438 jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
2300
d2686f757d6e
[gaim-migrate @ 2310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
439 |
7014 | 440 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
441 gc->inpa = gaim_input_add(js->fd, GAIM_INPUT_READ, jabber_recv_cb, gc); | |
442 } | |
2086 | 443 |
7014 | 444 static void |
7426 | 445 jabber_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, |
446 gpointer data) | |
447 { | |
448 GaimConnection *gc = data; | |
8360 | 449 JabberStream *js = gc->proto_data; |
7426 | 450 |
451 switch(error) { | |
8362 | 452 case GAIM_SSL_CONNECT_FAILED: |
453 gaim_connection_error(gc, _("Connection Failed")); | |
454 break; | |
7426 | 455 case GAIM_SSL_HANDSHAKE_FAILED: |
456 gaim_connection_error(gc, _("SSL Handshake Failed")); | |
457 break; | |
458 } | |
8360 | 459 |
460 js->gsc = NULL; | |
7426 | 461 } |
462 | |
7427 | 463 static void tls_init(JabberStream *js) |
464 { | |
465 gaim_input_remove(js->gc->inpa); | |
466 js->gc->inpa = 0; | |
467 js->gsc = gaim_ssl_connect_fd(js->gc->account, js->fd, | |
468 jabber_login_callback_ssl, jabber_ssl_connect_failure, js->gc); | |
469 } | |
470 | |
11387 | 471 static void jabber_login_connect(JabberStream *js, const char *server, int port) |
472 { | |
473 int rc; | |
474 | |
475 rc = gaim_proxy_connect(js->gc->account, server, | |
476 port, jabber_login_callback, js->gc); | |
477 | |
478 if (rc != 0) | |
479 gaim_connection_error(js->gc, _("Unable to create socket")); | |
480 } | |
481 | |
12686
5f65a0cca87c
[gaim-migrate @ 15029]
Richard Laager <rlaager@wiktel.com>
parents:
12658
diff
changeset
|
482 static void srv_resolved_cb(GaimSrvResponse *resp, int results, gpointer data) |
11387 | 483 { |
13894 | 484 GaimConnection *gc; |
485 JabberStream *js; | |
486 | |
487 gc = data; | |
488 if (!g_list_find(gaim_connections_get_all(), gc)) | |
489 { | |
490 /* This connection has been closed */ | |
491 g_free(resp); | |
492 return; | |
493 } | |
494 | |
495 js = (JabberStream*)gc->proto_data; | |
11387 | 496 |
497 if(results) { | |
12810
b0ede7907dd0
[gaim-migrate @ 15158]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12686
diff
changeset
|
498 jabber_login_connect(js, resp->hostname, resp->port); |
11387 | 499 g_free(resp); |
500 } else { | |
12810
b0ede7907dd0
[gaim-migrate @ 15158]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12686
diff
changeset
|
501 jabber_login_connect(js, js->user->domain, |
b0ede7907dd0
[gaim-migrate @ 15158]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12686
diff
changeset
|
502 gaim_account_get_int(js->gc->account, "port", 0)); |
11387 | 503 } |
504 } | |
505 | |
506 | |
7427 | 507 |
7426 | 508 static void |
11837 | 509 jabber_login(GaimAccount *account) |
2086 | 510 { |
7014 | 511 GaimConnection *gc = gaim_account_get_connection(account); |
512 const char *connect_server = gaim_account_get_string(account, | |
513 "connect_server", ""); | |
514 JabberStream *js; | |
10289 | 515 JabberBuddy *my_jb = NULL; |
2086 | 516 |
7014 | 517 gc->flags |= GAIM_CONNECTION_HTML; |
518 js = gc->proto_data = g_new0(JabberStream, 1); | |
519 js->gc = gc; | |
8013 | 520 js->fd = -1; |
8312 | 521 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
522 g_free, g_free); | |
523 js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
7395 | 524 g_free, g_free); |
7014 | 525 js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, |
7116 | 526 g_free, (GDestroyNotify)jabber_buddy_free); |
7014 | 527 js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, |
8396 | 528 g_free, (GDestroyNotify)jabber_chat_free); |
8043 | 529 js->chat_servers = g_list_append(NULL, g_strdup("conference.jabber.org")); |
7014 | 530 js->user = jabber_id_new(gaim_account_get_username(account)); |
7322 | 531 js->next_id = g_random_int(); |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
532 js->write_buffer = gaim_circ_buffer_new(512); |
5613 | 533 |
7310 | 534 if(!js->user) { |
535 gaim_connection_error(gc, _("Invalid Jabber ID")); | |
536 return; | |
537 } | |
538 | |
7147 | 539 if(!js->user->resource) { |
540 char *me; | |
11939
85c25a32bb48
[gaim-migrate @ 14230]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11837
diff
changeset
|
541 js->user->resource = g_strdup("Home"); |
7147 | 542 if(!js->user->node) { |
543 js->user->node = js->user->domain; | |
544 js->user->domain = g_strdup("jabber.org"); | |
545 } | |
546 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
547 js->user->resource); | |
548 gaim_account_set_username(account, me); | |
549 g_free(me); | |
7145 | 550 } |
551 | |
10289 | 552 if((my_jb = jabber_buddy_find(js, gaim_account_get_username(account), TRUE))) |
553 my_jb->subscription |= JABBER_SUB_BOTH; | |
554 | |
7014 | 555 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); |
2956 | 556 |
11387 | 557 /* if they've got old-ssl mode going, we probably want to ignore SRV lookups */ |
558 if(gaim_account_get_bool(js->gc->account, "old_ssl", FALSE)) { | |
7630 | 559 if(gaim_ssl_is_supported()) { |
11387 | 560 js->gsc = gaim_ssl_connect(js->gc->account, |
561 connect_server[0] ? connect_server : js->user->domain, | |
562 gaim_account_get_int(account, "port", 5223), jabber_login_callback_ssl, | |
563 jabber_ssl_connect_failure, js->gc); | |
7630 | 564 } else { |
11387 | 565 gaim_connection_error(js->gc, _("SSL support unavailable")); |
7630 | 566 } |
3311 | 567 } |
3770 | 568 |
11387 | 569 /* no old-ssl, so if they've specified a connect server, we'll use that, otherwise we'll |
570 * invoke the magic of SRV lookups, to figure out host and port */ | |
7014 | 571 if(!js->gsc) { |
11387 | 572 if(connect_server[0]) { |
573 jabber_login_connect(js, connect_server, gaim_account_get_int(account, "port", 5222)); | |
574 } else { | |
13894 | 575 gaim_srv_resolve("xmpp-client", "tcp", js->user->domain, srv_resolved_cb, gc); |
11387 | 576 } |
2956 | 577 } |
2086 | 578 } |
579 | |
11387 | 580 |
7072 | 581 static gboolean |
582 conn_close_cb(gpointer data) | |
583 { | |
584 JabberStream *js = data; | |
10740 | 585 GaimAccount *account = gaim_connection_get_account(js->gc); |
586 | |
587 gaim_account_disconnect(account); | |
588 | |
7072 | 589 return FALSE; |
590 } | |
591 | |
592 static void | |
593 jabber_connection_schedule_close(JabberStream *js) | |
594 { | |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8194
diff
changeset
|
595 gaim_timeout_add(0, conn_close_cb, js); |
7072 | 596 } |
597 | |
598 static void | |
7395 | 599 jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
7072 | 600 { |
601 const char *type = xmlnode_get_attrib(packet, "type"); | |
602 char *buf; | |
603 | |
604 if(!strcmp(type, "result")) { | |
605 buf = g_strdup_printf(_("Registration of %s@%s successful"), | |
606 js->user->node, js->user->domain); | |
607 gaim_notify_info(NULL, _("Registration Successful"), | |
608 _("Registration Successful"), buf); | |
609 g_free(buf); | |
610 } else { | |
8401 | 611 char *msg = jabber_parse_error(js, packet); |
7072 | 612 |
8401 | 613 if(!msg) |
614 msg = g_strdup(_("Unknown Error")); | |
7072 | 615 |
616 gaim_notify_error(NULL, _("Registration Failed"), | |
8401 | 617 _("Registration Failed"), msg); |
618 g_free(msg); | |
7072 | 619 } |
620 jabber_connection_schedule_close(js); | |
621 } | |
622 | |
623 static void | |
624 jabber_register_cb(JabberStream *js, GaimRequestFields *fields) | |
625 { | |
626 GList *groups, *flds; | |
627 xmlnode *query, *y; | |
628 JabberIq *iq; | |
7264 | 629 char *username; |
7072 | 630 |
631 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
632 query = xmlnode_get_child(iq->node, "query"); | |
633 | |
634 for(groups = gaim_request_fields_get_groups(fields); groups; | |
635 groups = groups->next) { | |
636 for(flds = gaim_request_field_group_get_fields(groups->data); | |
637 flds; flds = flds->next) { | |
638 GaimRequestField *field = flds->data; | |
639 const char *id = gaim_request_field_get_id(field); | |
640 const char *value = gaim_request_field_string_get_value(field); | |
641 | |
642 if(!strcmp(id, "username")) { | |
643 y = xmlnode_new_child(query, "username"); | |
644 } else if(!strcmp(id, "password")) { | |
645 y = xmlnode_new_child(query, "password"); | |
646 } else if(!strcmp(id, "name")) { | |
647 y = xmlnode_new_child(query, "name"); | |
648 } else if(!strcmp(id, "email")) { | |
649 y = xmlnode_new_child(query, "email"); | |
650 } else if(!strcmp(id, "nick")) { | |
651 y = xmlnode_new_child(query, "nick"); | |
652 } else if(!strcmp(id, "first")) { | |
653 y = xmlnode_new_child(query, "first"); | |
654 } else if(!strcmp(id, "last")) { | |
655 y = xmlnode_new_child(query, "last"); | |
656 } else if(!strcmp(id, "address")) { | |
657 y = xmlnode_new_child(query, "address"); | |
658 } else if(!strcmp(id, "city")) { | |
659 y = xmlnode_new_child(query, "city"); | |
660 } else if(!strcmp(id, "state")) { | |
661 y = xmlnode_new_child(query, "state"); | |
662 } else if(!strcmp(id, "zip")) { | |
663 y = xmlnode_new_child(query, "zip"); | |
664 } else if(!strcmp(id, "phone")) { | |
665 y = xmlnode_new_child(query, "phone"); | |
666 } else if(!strcmp(id, "url")) { | |
667 y = xmlnode_new_child(query, "url"); | |
668 } else if(!strcmp(id, "date")) { | |
669 y = xmlnode_new_child(query, "date"); | |
670 } else { | |
671 continue; | |
672 } | |
673 xmlnode_insert_data(y, value, -1); | |
7264 | 674 if(!strcmp(id, "username")) { |
675 if(js->user->node) | |
676 g_free(js->user->node); | |
677 js->user->node = g_strdup(value); | |
678 } | |
7072 | 679 } |
680 } | |
681 | |
7264 | 682 username = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, |
683 js->user->resource); | |
684 gaim_account_set_username(js->gc->account, username); | |
685 g_free(username); | |
686 | |
7395 | 687 jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); |
7072 | 688 |
689 jabber_iq_send(iq); | |
690 | |
691 } | |
692 | |
693 static void | |
694 jabber_register_cancel_cb(JabberStream *js, GaimRequestFields *fields) | |
695 { | |
696 jabber_connection_schedule_close(js); | |
697 } | |
698 | |
7923 | 699 static void jabber_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
700 { | |
701 xmlnode *query; | |
702 JabberIq *iq; | |
703 | |
704 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
705 query = xmlnode_get_child(iq->node, "query"); | |
706 | |
707 xmlnode_insert_child(query, result); | |
708 | |
709 jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); | |
710 jabber_iq_send(iq); | |
711 } | |
712 | |
7072 | 713 void jabber_register_parse(JabberStream *js, xmlnode *packet) |
714 { | |
715 if(js->registration) { | |
716 GaimRequestFields *fields; | |
717 GaimRequestFieldGroup *group; | |
718 GaimRequestField *field; | |
7923 | 719 xmlnode *query, *x, *y; |
7072 | 720 char *instructions; |
721 | |
722 /* get rid of the login thingy */ | |
723 gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
724 | |
725 query = xmlnode_get_child(packet, "query"); | |
726 | |
727 if(xmlnode_get_child(query, "registered")) { | |
728 gaim_notify_error(NULL, _("Already Registered"), | |
729 _("Already Registered"), NULL); | |
730 jabber_connection_schedule_close(js); | |
731 return; | |
732 } | |
733 | |
8398 | 734 if((x = xmlnode_get_child_with_namespace(packet, "x", |
735 "jabber:x:data"))) { | |
736 jabber_x_data_request(js, x, jabber_register_x_data_cb, NULL); | |
737 return; | |
738 } else if((x = xmlnode_get_child_with_namespace(packet, "x", | |
739 "jabber:x:oob"))) { | |
740 xmlnode *url; | |
7923 | 741 |
8398 | 742 if((url = xmlnode_get_child(x, "url"))) { |
743 char *href; | |
744 if((href = xmlnode_get_data(url))) { | |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10216
diff
changeset
|
745 gaim_notify_uri(NULL, href); |
8398 | 746 g_free(href); |
747 js->gc->wants_to_die = TRUE; | |
748 jabber_connection_schedule_close(js); | |
749 return; | |
750 } | |
7923 | 751 } |
752 } | |
753 | |
754 /* as a last resort, use the old jabber:iq:register syntax */ | |
755 | |
7072 | 756 fields = gaim_request_fields_new(); |
757 group = gaim_request_field_group_new(NULL); | |
758 gaim_request_fields_add_group(fields, group); | |
759 | |
760 field = gaim_request_field_string_new("username", _("Username"), | |
761 js->user->node, FALSE); | |
762 gaim_request_field_group_add_field(group, field); | |
763 | |
764 field = gaim_request_field_string_new("password", _("Password"), | |
10740 | 765 gaim_connection_get_password(js->gc), FALSE); |
7072 | 766 gaim_request_field_string_set_masked(field, TRUE); |
767 gaim_request_field_group_add_field(group, field); | |
768 | |
769 if(xmlnode_get_child(query, "name")) { | |
770 field = gaim_request_field_string_new("name", _("Name"), | |
771 gaim_account_get_alias(js->gc->account), FALSE); | |
772 gaim_request_field_group_add_field(group, field); | |
773 } | |
774 if(xmlnode_get_child(query, "email")) { | |
13545
cfc2f7fcb3dd
[gaim-migrate @ 15922]
Richard Laager <rlaager@wiktel.com>
parents:
13485
diff
changeset
|
775 field = gaim_request_field_string_new("email", _("E-mail"), |
7072 | 776 NULL, FALSE); |
777 gaim_request_field_group_add_field(group, field); | |
778 } | |
779 if(xmlnode_get_child(query, "nick")) { | |
780 field = gaim_request_field_string_new("nick", _("Nickname"), | |
781 NULL, FALSE); | |
782 gaim_request_field_group_add_field(group, field); | |
783 } | |
784 if(xmlnode_get_child(query, "first")) { | |
13545
cfc2f7fcb3dd
[gaim-migrate @ 15922]
Richard Laager <rlaager@wiktel.com>
parents:
13485
diff
changeset
|
785 field = gaim_request_field_string_new("first", _("First name"), |
7072 | 786 NULL, FALSE); |
787 gaim_request_field_group_add_field(group, field); | |
788 } | |
789 if(xmlnode_get_child(query, "last")) { | |
13545
cfc2f7fcb3dd
[gaim-migrate @ 15922]
Richard Laager <rlaager@wiktel.com>
parents:
13485
diff
changeset
|
790 field = gaim_request_field_string_new("last", _("Last name"), |
7072 | 791 NULL, FALSE); |
792 gaim_request_field_group_add_field(group, field); | |
793 } | |
794 if(xmlnode_get_child(query, "address")) { | |
795 field = gaim_request_field_string_new("address", _("Address"), | |
796 NULL, FALSE); | |
797 gaim_request_field_group_add_field(group, field); | |
798 } | |
799 if(xmlnode_get_child(query, "city")) { | |
800 field = gaim_request_field_string_new("city", _("City"), | |
801 NULL, FALSE); | |
802 gaim_request_field_group_add_field(group, field); | |
803 } | |
804 if(xmlnode_get_child(query, "state")) { | |
805 field = gaim_request_field_string_new("state", _("State"), | |
806 NULL, FALSE); | |
807 gaim_request_field_group_add_field(group, field); | |
808 } | |
809 if(xmlnode_get_child(query, "zip")) { | |
13545
cfc2f7fcb3dd
[gaim-migrate @ 15922]
Richard Laager <rlaager@wiktel.com>
parents:
13485
diff
changeset
|
810 field = gaim_request_field_string_new("zip", _("Postal code"), |
7072 | 811 NULL, FALSE); |
812 gaim_request_field_group_add_field(group, field); | |
813 } | |
814 if(xmlnode_get_child(query, "phone")) { | |
815 field = gaim_request_field_string_new("phone", _("Phone"), | |
816 NULL, FALSE); | |
817 gaim_request_field_group_add_field(group, field); | |
818 } | |
819 if(xmlnode_get_child(query, "url")) { | |
820 field = gaim_request_field_string_new("url", _("URL"), | |
821 NULL, FALSE); | |
822 gaim_request_field_group_add_field(group, field); | |
823 } | |
824 if(xmlnode_get_child(query, "date")) { | |
825 field = gaim_request_field_string_new("date", _("Date"), | |
826 NULL, FALSE); | |
827 gaim_request_field_group_add_field(group, field); | |
828 } | |
829 | |
830 if((y = xmlnode_get_child(query, "instructions"))) | |
831 instructions = xmlnode_get_data(y); | |
832 else | |
833 instructions = g_strdup(_("Please fill out the information below " | |
834 "to register your new account.")); | |
835 | |
836 gaim_request_fields(js->gc, _("Register New Jabber Account"), | |
837 _("Register New Jabber Account"), instructions, fields, | |
838 _("Register"), G_CALLBACK(jabber_register_cb), | |
839 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); | |
840 } | |
841 } | |
842 | |
8016 | 843 void jabber_register_start(JabberStream *js) |
7072 | 844 { |
845 JabberIq *iq; | |
846 | |
847 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); | |
848 jabber_iq_send(iq); | |
849 } | |
850 | |
851 static void jabber_register_account(GaimAccount *account) | |
852 { | |
853 GaimConnection *gc = gaim_account_get_connection(account); | |
854 JabberStream *js; | |
10289 | 855 JabberBuddy *my_jb = NULL; |
7072 | 856 const char *connect_server = gaim_account_get_string(account, |
857 "connect_server", ""); | |
858 const char *server; | |
859 int rc; | |
860 | |
861 js = gc->proto_data = g_new0(JabberStream, 1); | |
862 js->gc = gc; | |
863 js->registration = TRUE; | |
8312 | 864 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
865 g_free, g_free); | |
866 js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
7395 | 867 g_free, g_free); |
7072 | 868 js->user = jabber_id_new(gaim_account_get_username(account)); |
7322 | 869 js->next_id = g_random_int(); |
7072 | 870 |
7310 | 871 if(!js->user) { |
872 gaim_connection_error(gc, _("Invalid Jabber ID")); | |
873 return; | |
874 } | |
875 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
876 js->write_buffer = gaim_circ_buffer_new(512); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
877 |
7147 | 878 if(!js->user->resource) { |
879 char *me; | |
11939
85c25a32bb48
[gaim-migrate @ 14230]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11837
diff
changeset
|
880 js->user->resource = g_strdup("Home"); |
7147 | 881 if(!js->user->node) { |
882 js->user->node = js->user->domain; | |
883 js->user->domain = g_strdup("jabber.org"); | |
884 } | |
885 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
886 js->user->resource); | |
887 gaim_account_set_username(account, me); | |
888 g_free(me); | |
889 } | |
890 | |
10289 | 891 if((my_jb = jabber_buddy_find(js, gaim_account_get_username(account), TRUE))) |
892 my_jb->subscription |= JABBER_SUB_BOTH; | |
893 | |
7072 | 894 server = connect_server[0] ? connect_server : js->user->domain; |
895 | |
896 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); | |
897 | |
7630 | 898 if(gaim_account_get_bool(account, "old_ssl", FALSE)) { |
899 if(gaim_ssl_is_supported()) { | |
900 js->gsc = gaim_ssl_connect(account, server, | |
901 gaim_account_get_int(account, "port", 5222), | |
902 jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); | |
903 } else { | |
904 gaim_connection_error(gc, _("SSL support unavailable")); | |
905 } | |
7072 | 906 } |
907 | |
908 if(!js->gsc) { | |
909 rc = gaim_proxy_connect(account, server, | |
910 gaim_account_get_int(account, "port", 5222), | |
911 jabber_login_callback, gc); | |
912 | |
913 if (rc != 0) | |
914 gaim_connection_error(gc, _("Unable to create socket")); | |
915 } | |
916 } | |
917 | |
5572 | 918 static void jabber_close(GaimConnection *gc) |
2086 | 919 { |
7014 | 920 JabberStream *js = gc->proto_data; |
2956 | 921 |
13942 | 922 /* Don't perform any actions on the ssl connection |
923 * if we were forcibly disconnected because it will crash | |
924 * on some SSL backends. | |
13153
caee920323e2
[gaim-migrate @ 15516]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13051
diff
changeset
|
925 */ |
caee920323e2
[gaim-migrate @ 15516]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13051
diff
changeset
|
926 if (!gc->disconnect_timeout) |
13941 | 927 jabber_send_raw(js, "</stream:stream>", -1); |
3311 | 928 |
7014 | 929 if(js->gsc) { |
13242
cdd107258f11
[gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13237
diff
changeset
|
930 #ifdef HAVE_OPENSSL |
cdd107258f11
[gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13237
diff
changeset
|
931 if (!gc->disconnect_timeout) |
13384 | 932 #endif |
13242
cdd107258f11
[gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13237
diff
changeset
|
933 gaim_ssl_close(js->gsc); |
8360 | 934 } else if (js->fd > 0) { |
7072 | 935 if(js->gc->inpa) |
936 gaim_input_remove(js->gc->inpa); | |
7014 | 937 close(js->fd); |
938 } | |
13806 | 939 #ifndef HAVE_LIBXML |
7587 | 940 if(js->context) |
941 g_markup_parse_context_free(js->context); | |
13806 | 942 #endif |
8312 | 943 if(js->iq_callbacks) |
944 g_hash_table_destroy(js->iq_callbacks); | |
945 if(js->disco_callbacks) | |
946 g_hash_table_destroy(js->disco_callbacks); | |
7072 | 947 if(js->buddies) |
948 g_hash_table_destroy(js->buddies); | |
949 if(js->chats) | |
950 g_hash_table_destroy(js->chats); | |
8043 | 951 while(js->chat_servers) { |
952 g_free(js->chat_servers->data); | |
953 js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers); | |
954 } | |
11675 | 955 while(js->user_directories) { |
956 g_free(js->user_directories->data); | |
957 js->user_directories = g_list_delete_link(js->user_directories, js->user_directories); | |
958 } | |
7014 | 959 if(js->stream_id) |
960 g_free(js->stream_id); | |
7587 | 961 if(js->user) |
962 jabber_id_free(js->user); | |
10189 | 963 if(js->avatar_hash) |
964 g_free(js->avatar_hash); | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
965 gaim_circ_buffer_destroy(js->write_buffer); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
966 if(js->writeh) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
967 gaim_input_remove(js->writeh); |
12508 | 968 #ifdef HAVE_CYRUS_SASL |
969 if(js->sasl) | |
970 sasl_dispose(&js->sasl); | |
971 if(js->sasl_mechs) | |
972 g_string_free(js->sasl_mechs, TRUE); | |
973 if(js->sasl_cb) | |
974 g_free(js->sasl_cb); | |
975 #endif | |
7014 | 976 g_free(js); |
11389 | 977 |
978 gc->proto_data = NULL; | |
5093 | 979 } |
980 | |
7014 | 981 void jabber_stream_set_state(JabberStream *js, JabberStreamState state) |
3105 | 982 { |
9954 | 983 GaimPresence *gpresence; |
984 GaimStatus *status; | |
985 | |
7014 | 986 js->state = state; |
987 switch(state) { | |
988 case JABBER_STREAM_OFFLINE: | |
989 break; | |
990 case JABBER_STREAM_CONNECTING: | |
991 gaim_connection_update_progress(js->gc, _("Connecting"), 1, | |
992 JABBER_CONNECT_STEPS); | |
993 break; | |
994 case JABBER_STREAM_INITIALIZING: | |
995 gaim_connection_update_progress(js->gc, _("Initializing Stream"), | |
996 js->gsc ? 5 : 2, JABBER_CONNECT_STEPS); | |
997 jabber_stream_init(js); | |
998 break; | |
999 case JABBER_STREAM_AUTHENTICATING: | |
1000 gaim_connection_update_progress(js->gc, _("Authenticating"), | |
1001 js->gsc ? 6 : 3, JABBER_CONNECT_STEPS); | |
8296 | 1002 if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) { |
1003 jabber_register_start(js); | |
1004 } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) { | |
1005 jabber_auth_start_old(js); | |
8016 | 1006 } |
7014 | 1007 break; |
1008 case JABBER_STREAM_REINITIALIZING: | |
1009 gaim_connection_update_progress(js->gc, _("Re-initializing Stream"), | |
1010 6, JABBER_CONNECT_STEPS); | |
1011 jabber_stream_init(js); | |
1012 break; | |
1013 case JABBER_STREAM_CONNECTED: | |
1014 jabber_roster_request(js); | |
9954 | 1015 gpresence = gaim_account_get_presence(js->gc->account); |
1016 status = gaim_presence_get_active_status(gpresence); | |
10216 | 1017 jabber_presence_send(js->gc->account, status); |
10941 | 1018 gaim_connection_set_state(js->gc, GAIM_CONNECTED); |
8312 | 1019 jabber_disco_items_server(js); |
7014 | 1020 break; |
3105 | 1021 } |
1022 } | |
1023 | |
7014 | 1024 char *jabber_get_next_id(JabberStream *js) |
2086 | 1025 { |
7322 | 1026 return g_strdup_printf("gaim%x", js->next_id++); |
2086 | 1027 } |
1028 | |
7923 | 1029 |
1030 static void jabber_idle_set(GaimConnection *gc, int idle) | |
3340 | 1031 { |
7014 | 1032 JabberStream *js = gc->proto_data; |
3340 | 1033 |
7014 | 1034 js->idle = idle ? time(NULL) - idle : idle; |
3314 | 1035 } |
1036 | |
6695 | 1037 static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) |
2086 | 1038 { |
4687 | 1039 return "jabber"; |
1040 } | |
4916 | 1041 |
9954 | 1042 static void jabber_list_emblems(GaimBuddy *b, const char **se, const char **sw, |
1043 const char **nw, const char **ne) | |
4916 | 1044 { |
7014 | 1045 JabberStream *js; |
13485
9ad3d85fffeb
[gaim-migrate @ 15861]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13384
diff
changeset
|
1046 JabberBuddy *jb = NULL; |
7014 | 1047 |
1048 if(!b->account->gc) | |
1049 return; | |
1050 js = b->account->gc->proto_data; | |
13485
9ad3d85fffeb
[gaim-migrate @ 15861]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13384
diff
changeset
|
1051 if(js) |
9ad3d85fffeb
[gaim-migrate @ 15861]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13384
diff
changeset
|
1052 jb = jabber_buddy_find(js, b->name, FALSE); |
5135 | 1053 |
1054 if(!GAIM_BUDDY_IS_ONLINE(b)) { | |
7014 | 1055 if(jb && jb->error_msg) |
4927 | 1056 *nw = "error"; |
5135 | 1057 |
7014 | 1058 if(jb && (jb->subscription & JABBER_SUB_PENDING || |
1059 !(jb->subscription & JABBER_SUB_TO))) | |
5135 | 1060 *se = "notauthorized"; |
1061 else | |
1062 *se = "offline"; | |
4916 | 1063 } else { |
9954 | 1064 GaimStatusType *status_type = gaim_status_get_type(gaim_presence_get_active_status(gaim_buddy_get_presence(b))); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1065 GaimStatusPrimitive primitive = gaim_status_type_get_primitive(status_type); |
9954 | 1066 |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1067 if(primitive > GAIM_STATUS_AVAILABLE) { |
9954 | 1068 *se = gaim_status_type_get_id(status_type); |
4916 | 1069 } |
2086 | 1070 } |
4916 | 1071 } |
2086 | 1072 |
7014 | 1073 static char *jabber_status_text(GaimBuddy *b) |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1074 { |
7014 | 1075 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
1076 FALSE); | |
1077 char *ret = NULL; | |
5234 | 1078 |
7014 | 1079 if(jb && !GAIM_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { |
1080 ret = g_strdup(_("Not Authorized")); | |
1081 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
1082 ret = g_strdup(jb->error_msg); | |
2956 | 1083 } else { |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
1084 char *stripped; |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
1085 |
9954 | 1086 if(!(stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)))) { |
1087 GaimStatus *status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
2956 | 1088 |
9954 | 1089 if(!gaim_status_is_available(status)) |
1090 stripped = g_strdup(gaim_status_get_name(status)); | |
1091 } | |
2086 | 1092 |
7014 | 1093 if(stripped) { |
1094 ret = g_markup_escape_text(stripped, -1); | |
1095 g_free(stripped); | |
1096 } | |
2086 | 1097 } |
1098 | |
7014 | 1099 return ret; |
2956 | 1100 } |
1101 | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1102 static void jabber_tooltip_text(GaimBuddy *b, GString *str, gboolean full) |
4744 | 1103 { |
11609 | 1104 JabberBuddy *jb; |
1105 | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1106 g_return_if_fail(b != NULL); |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1107 g_return_if_fail(b->account != NULL); |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1108 g_return_if_fail(b->account->gc != NULL); |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1109 g_return_if_fail(b->account->gc->proto_data != NULL); |
11609 | 1110 |
1111 jb = jabber_buddy_find(b->account->gc->proto_data, b->name, | |
7014 | 1112 FALSE); |
1113 | |
8194 | 1114 if(jb) { |
11609 | 1115 JabberBuddyResource *jbr = NULL; |
8194 | 1116 const char *sub; |
11609 | 1117 GList *l; |
1118 | |
12948
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1119 if (full) { |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1120 if(jb->subscription & JABBER_SUB_FROM) { |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1121 if(jb->subscription & JABBER_SUB_TO) |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1122 sub = _("Both"); |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1123 else if(jb->subscription & JABBER_SUB_PENDING) |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1124 sub = _("From (To pending)"); |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1125 else |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1126 sub = _("From"); |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1127 } else { |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1128 if(jb->subscription & JABBER_SUB_TO) |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1129 sub = _("To"); |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1130 else if(jb->subscription & JABBER_SUB_PENDING) |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1131 sub = _("None (To pending)"); |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1132 else |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1133 sub = _("None"); |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1134 } |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1135 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Subscription"), sub); |
8194 | 1136 } |
1137 | |
11609 | 1138 for(l=jb->resources; l; l = l->next) { |
8194 | 1139 char *text = NULL; |
11609 | 1140 char *res = NULL; |
12944
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1141 const char *state; |
11609 | 1142 |
1143 jbr = l->data; | |
1144 | |
8194 | 1145 if(jbr->status) { |
11646 | 1146 char *tmp; |
1147 text = gaim_strreplace(jbr->status, "\n", "<br />\n"); | |
1148 tmp = gaim_markup_strip_html(text); | |
1149 g_free(text); | |
1150 text = g_markup_escape_text(tmp, -1); | |
1151 g_free(tmp); | |
8194 | 1152 } |
1153 | |
11609 | 1154 if(jbr->name) |
11610 | 1155 res = g_strdup_printf(" (%s)", jbr->name); |
11609 | 1156 |
12944
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1157 state = jabber_buddy_state_get_name(jbr->state); |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1158 if (text != NULL && !gaim_utf8_strcasecmp(state, text)) { |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1159 g_free(text); |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1160 text = NULL; |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1161 } |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1162 |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1163 g_string_append_printf(str, "\n<b>%s%s:</b> %s%s%s", |
8194 | 1164 _("Status"), |
11609 | 1165 res ? res : "", |
12944
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1166 state, |
8194 | 1167 text ? ": " : "", |
1168 text ? text : ""); | |
12944
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1169 |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1170 g_free(text); |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1171 g_free(res); |
11609 | 1172 } |
1173 | |
1174 if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1175 g_string_append_printf(str, "\n<b>%s:</b> %s", |
8194 | 1176 _("Error"), jb->error_msg); |
1177 } | |
4745 | 1178 } |
4732 | 1179 } |
1180 | |
9954 | 1181 static GList *jabber_status_types(GaimAccount *account) |
7014 | 1182 { |
9954 | 1183 GaimStatusType *type; |
1184 GList *types = NULL; | |
11568 | 1185 GaimValue *priority_value; |
9954 | 1186 |
11568 | 1187 priority_value = gaim_value_new(GAIM_TYPE_INT); |
11569 | 1188 gaim_value_set_int(priority_value, 1); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1189 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1190 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1191 NULL, TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1192 "priority", _("Priority"), priority_value, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1193 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1194 NULL); |
9980 | 1195 types = g_list_append(types, type); |
1196 | |
11568 | 1197 priority_value = gaim_value_new(GAIM_TYPE_INT); |
11569 | 1198 gaim_value_set_int(priority_value, 1); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1199 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1200 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1201 _("Chatty"), TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1202 "priority", _("Priority"), priority_value, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1203 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1204 NULL); |
9954 | 1205 types = g_list_append(types, type); |
2086 | 1206 |
11568 | 1207 priority_value = gaim_value_new(GAIM_TYPE_INT); |
11569 | 1208 gaim_value_set_int(priority_value, 0); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1209 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1210 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1211 NULL, TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1212 "priority", _("Priority"), priority_value, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1213 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1214 NULL); |
9954 | 1215 types = g_list_append(types, type); |
1216 | |
11568 | 1217 priority_value = gaim_value_new(GAIM_TYPE_INT); |
11569 | 1218 gaim_value_set_int(priority_value, 0); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1219 type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1220 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1221 NULL, TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1222 "priority", _("Priority"), priority_value, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1223 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1224 NULL); |
9954 | 1225 types = g_list_append(types, type); |
1226 | |
11568 | 1227 priority_value = gaim_value_new(GAIM_TYPE_INT); |
11569 | 1228 gaim_value_set_int(priority_value, 0); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1229 type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1230 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_DND), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1231 _("Do Not Disturb"), TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1232 "priority", _("Priority"), priority_value, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1233 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1234 NULL); |
9954 | 1235 types = g_list_append(types, type); |
1236 | |
1237 /* | |
8166 | 1238 if(js->protocol_version == JABBER_PROTO_0_9) |
1239 m = g_list_append(m, _("Invisible")); | |
10009 | 1240 */ |
2086 | 1241 |
12658 | 1242 type = gaim_status_type_new_with_attrs(GAIM_STATUS_OFFLINE, |
1243 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE), | |
1244 NULL, FALSE, TRUE, FALSE, | |
1245 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), | |
1246 NULL); | |
1247 types = g_list_append(types, type); | |
1248 | |
9954 | 1249 return types; |
2086 | 1250 } |
1251 | |
7395 | 1252 static void |
1253 jabber_password_change_result_cb(JabberStream *js, xmlnode *packet, | |
1254 gpointer data) | |
7124 | 1255 { |
1256 const char *type; | |
1257 | |
1258 type = xmlnode_get_attrib(packet, "type"); | |
1259 | |
9414 | 1260 if(type && !strcmp(type, "result")) { |
7124 | 1261 gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"), |
1262 _("Your password has been changed.")); | |
1263 } else { | |
8401 | 1264 char *msg = jabber_parse_error(js, packet); |
7124 | 1265 |
8401 | 1266 gaim_notify_error(js->gc, _("Error changing password"), |
1267 _("Error changing password"), msg); | |
1268 g_free(msg); | |
7124 | 1269 } |
1270 } | |
1271 | |
1272 static void jabber_password_change_cb(JabberStream *js, | |
1273 GaimRequestFields *fields) | |
1274 { | |
1275 const char *p1, *p2; | |
1276 JabberIq *iq; | |
1277 xmlnode *query, *y; | |
1278 | |
1279 p1 = gaim_request_fields_get_string(fields, "password1"); | |
1280 p2 = gaim_request_fields_get_string(fields, "password2"); | |
1281 | |
1282 if(strcmp(p1, p2)) { | |
1283 gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); | |
1284 return; | |
1285 } | |
1286 | |
1287 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
1288 | |
1289 xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
1290 | |
1291 query = xmlnode_get_child(iq->node, "query"); | |
1292 | |
1293 y = xmlnode_new_child(query, "username"); | |
1294 xmlnode_insert_data(y, js->user->node, -1); | |
1295 y = xmlnode_new_child(query, "password"); | |
1296 xmlnode_insert_data(y, p1, -1); | |
1297 | |
7395 | 1298 jabber_iq_set_callback(iq, jabber_password_change_result_cb, NULL); |
7124 | 1299 |
1300 jabber_iq_send(iq); | |
1301 | |
1302 gaim_account_set_password(js->gc->account, p1); | |
1303 } | |
1304 | |
9015 | 1305 static void jabber_password_change(GaimPluginAction *action) |
7124 | 1306 { |
9015 | 1307 |
1308 GaimConnection *gc = (GaimConnection *) action->context; | |
7124 | 1309 JabberStream *js = gc->proto_data; |
1310 GaimRequestFields *fields; | |
1311 GaimRequestFieldGroup *group; | |
1312 GaimRequestField *field; | |
1313 | |
1314 fields = gaim_request_fields_new(); | |
1315 group = gaim_request_field_group_new(NULL); | |
1316 gaim_request_fields_add_group(fields, group); | |
1317 | |
1318 field = gaim_request_field_string_new("password1", _("Password"), | |
1319 "", FALSE); | |
1320 gaim_request_field_string_set_masked(field, TRUE); | |
1321 gaim_request_field_group_add_field(group, field); | |
1322 | |
1323 field = gaim_request_field_string_new("password2", _("Password (again)"), | |
1324 "", FALSE); | |
1325 gaim_request_field_string_set_masked(field, TRUE); | |
1326 gaim_request_field_group_add_field(group, field); | |
1327 | |
1328 gaim_request_fields(js->gc, _("Change Jabber Password"), | |
1329 _("Change Jabber Password"), _("Please enter your new password"), | |
1330 fields, _("OK"), G_CALLBACK(jabber_password_change_cb), | |
1331 _("Cancel"), NULL, js); | |
1332 } | |
1333 | |
9015 | 1334 static GList *jabber_actions(GaimPlugin *plugin, gpointer context) |
2956 | 1335 { |
1336 GList *m = NULL; | |
9015 | 1337 GaimPluginAction *act; |
4333 | 1338 |
12243
d3cb077caf3e
[gaim-migrate @ 14545]
Richard Laager <rlaager@wiktel.com>
parents:
12143
diff
changeset
|
1339 act = gaim_plugin_action_new(_("Set User Info..."), |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12284
diff
changeset
|
1340 jabber_setup_set_info); |
9015 | 1341 m = g_list_append(m, act); |
4333 | 1342 |
8296 | 1343 /* if (js->protocol_options & CHANGE_PASSWORD) { */ |
12243
d3cb077caf3e
[gaim-migrate @ 14545]
Richard Laager <rlaager@wiktel.com>
parents:
12143
diff
changeset
|
1344 act = gaim_plugin_action_new(_("Change Password..."), |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12284
diff
changeset
|
1345 jabber_password_change); |
9015 | 1346 m = g_list_append(m, act); |
8296 | 1347 /* } */ |
2956 | 1348 |
12243
d3cb077caf3e
[gaim-migrate @ 14545]
Richard Laager <rlaager@wiktel.com>
parents:
12143
diff
changeset
|
1349 act = gaim_plugin_action_new(_("Search for Users..."), |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12284
diff
changeset
|
1350 jabber_user_search_begin); |
11675 | 1351 m = g_list_append(m, act); |
1352 | |
2956 | 1353 return m; |
1354 } | |
1355 | |
7999 | 1356 static GaimChat *jabber_find_blist_chat(GaimAccount *account, const char *name) |
1357 { | |
1358 GaimBlistNode *gnode, *cnode; | |
1359 JabberID *jid; | |
1360 | |
1361 if(!(jid = jabber_id_new(name))) | |
1362 return NULL; | |
1363 | |
1364 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
1365 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
1366 GaimChat *chat = (GaimChat*)cnode; | |
1367 const char *room, *server; | |
1368 if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
1369 continue; | |
1370 | |
1371 if(chat->account != account) | |
8011 | 1372 continue; |
7999 | 1373 |
1374 if(!(room = g_hash_table_lookup(chat->components, "room"))) | |
1375 continue; | |
1376 if(!(server = g_hash_table_lookup(chat->components, "server"))) | |
1377 continue; | |
1378 | |
8158 | 1379 if(jid->node && jid->domain && |
1380 !g_utf8_collate(room, jid->node) && !g_utf8_collate(server, jid->domain)) { | |
7999 | 1381 jabber_id_free(jid); |
1382 return chat; | |
1383 } | |
1384 } | |
1385 } | |
1386 jabber_id_free(jid); | |
1387 return NULL; | |
1388 } | |
1389 | |
8400 | 1390 static void jabber_convo_closed(GaimConnection *gc, const char *who) |
1391 { | |
1392 JabberStream *js = gc->proto_data; | |
1393 JabberID *jid; | |
1394 JabberBuddy *jb; | |
1395 JabberBuddyResource *jbr; | |
1396 | |
1397 if(!(jid = jabber_id_new(who))) | |
1398 return; | |
1399 | |
1400 if((jb = jabber_buddy_find(js, who, TRUE)) && | |
1401 (jbr = jabber_buddy_find_resource(jb, jid->resource))) { | |
1402 if(jbr->thread_id) { | |
1403 g_free(jbr->thread_id); | |
1404 jbr->thread_id = NULL; | |
1405 } | |
1406 } | |
1407 | |
1408 jabber_id_free(jid); | |
1409 } | |
1410 | |
8401 | 1411 |
1412 char *jabber_parse_error(JabberStream *js, xmlnode *packet) | |
1413 { | |
1414 xmlnode *error; | |
1415 const char *code = NULL, *text = NULL; | |
13806 | 1416 const char *xmlns = xmlnode_get_namespace(packet); |
8401 | 1417 char *cdata = NULL; |
1418 | |
1419 if((error = xmlnode_get_child(packet, "error"))) { | |
1420 cdata = xmlnode_get_data(error); | |
1421 code = xmlnode_get_attrib(error, "code"); | |
1422 | |
1423 /* Stanza errors */ | |
1424 if(xmlnode_get_child(error, "bad-request")) { | |
1425 text = _("Bad Request"); | |
1426 } else if(xmlnode_get_child(error, "conflict")) { | |
1427 text = _("Conflict"); | |
1428 } else if(xmlnode_get_child(error, "feature-not-implemented")) { | |
1429 text = _("Feature Not Implemented"); | |
1430 } else if(xmlnode_get_child(error, "forbidden")) { | |
1431 text = _("Forbidden"); | |
1432 } else if(xmlnode_get_child(error, "gone")) { | |
1433 text = _("Gone"); | |
1434 } else if(xmlnode_get_child(error, "internal-server-error")) { | |
1435 text = _("Internal Server Error"); | |
1436 } else if(xmlnode_get_child(error, "item-not-found")) { | |
1437 text = _("Item Not Found"); | |
1438 } else if(xmlnode_get_child(error, "jid-malformed")) { | |
1439 text = _("Malformed Jabber ID"); | |
1440 } else if(xmlnode_get_child(error, "not-acceptable")) { | |
1441 text = _("Not Acceptable"); | |
1442 } else if(xmlnode_get_child(error, "not-allowed")) { | |
1443 text = _("Not Allowed"); | |
1444 } else if(xmlnode_get_child(error, "not-authorized")) { | |
1445 text = _("Not Authorized"); | |
1446 } else if(xmlnode_get_child(error, "payment-required")) { | |
1447 text = _("Payment Required"); | |
1448 } else if(xmlnode_get_child(error, "recipient-unavailable")) { | |
1449 text = _("Recipient Unavailable"); | |
1450 } else if(xmlnode_get_child(error, "redirect")) { | |
1451 /* XXX */ | |
1452 } else if(xmlnode_get_child(error, "registration-required")) { | |
1453 text = _("Registration Required"); | |
1454 } else if(xmlnode_get_child(error, "remote-server-not-found")) { | |
1455 text = _("Remote Server Not Found"); | |
1456 } else if(xmlnode_get_child(error, "remote-server-timeout")) { | |
1457 text = _("Remote Server Timeout"); | |
1458 } else if(xmlnode_get_child(error, "resource-constraint")) { | |
1459 text = _("Server Overloaded"); | |
1460 } else if(xmlnode_get_child(error, "service-unavailable")) { | |
1461 text = _("Service Unavailable"); | |
1462 } else if(xmlnode_get_child(error, "subscription-required")) { | |
1463 text = _("Subscription Required"); | |
1464 } else if(xmlnode_get_child(error, "unexpected-request")) { | |
1465 text = _("Unexpected Request"); | |
1466 } else if(xmlnode_get_child(error, "undefined-condition")) { | |
1467 text = _("Unknown Error"); | |
1468 } | |
1469 } else if(xmlns && !strcmp(xmlns, "urn:ietf:params:xml:ns:xmpp-sasl")) { | |
1470 if(xmlnode_get_child(packet, "aborted")) { | |
1471 js->gc->wants_to_die = TRUE; | |
1472 text = _("Authorization Aborted"); | |
13804 | 1473 } else if(xmlnode_get_child(packet, "incorrect-encoding")) { |
8401 | 1474 text = _("Incorrect encoding in authorization"); |
13804 | 1475 } else if(xmlnode_get_child(packet, "invalid-authzid")) { |
8401 | 1476 js->gc->wants_to_die = TRUE; |
1477 text = _("Invalid authzid"); | |
13804 | 1478 } else if(xmlnode_get_child(packet, "invalid-mechanism")) { |
8401 | 1479 js->gc->wants_to_die = TRUE; |
1480 text = _("Invalid Authorization Mechanism"); | |
13804 | 1481 } else if(xmlnode_get_child(packet, "mechanism-too-weak")) { |
8401 | 1482 js->gc->wants_to_die = TRUE; |
1483 text = _("Authorization mechanism too weak"); | |
13804 | 1484 } else if(xmlnode_get_child(packet, "not-authorized")) { |
8401 | 1485 js->gc->wants_to_die = TRUE; |
1486 text = _("Not Authorized"); | |
13804 | 1487 } else if(xmlnode_get_child(packet, "temporary-auth-failure")) { |
8401 | 1488 text = _("Temporary Authentication Failure"); |
1489 } else { | |
13051 | 1490 js->gc->wants_to_die = TRUE; |
8401 | 1491 text = _("Authentication Failure"); |
1492 } | |
8402 | 1493 } else if(!strcmp(packet->name, "stream:error")) { |
1494 if(xmlnode_get_child(packet, "bad-format")) { | |
1495 text = _("Bad Format"); | |
1496 } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) { | |
1497 text = _("Bad Namespace Prefix"); | |
1498 } else if(xmlnode_get_child(packet, "conflict")) { | |
1499 js->gc->wants_to_die = TRUE; | |
1500 text = _("Resource Conflict"); | |
1501 } else if(xmlnode_get_child(packet, "connection-timeout")) { | |
1502 text = _("Connection Timeout"); | |
1503 } else if(xmlnode_get_child(packet, "host-gone")) { | |
1504 text = _("Host Gone"); | |
1505 } else if(xmlnode_get_child(packet, "host-unknown")) { | |
1506 text = _("Host Unknown"); | |
1507 } else if(xmlnode_get_child(packet, "improper-addressing")) { | |
1508 text = _("Improper Addressing"); | |
1509 } else if(xmlnode_get_child(packet, "internal-server-error")) { | |
1510 text = _("Internal Server Error"); | |
1511 } else if(xmlnode_get_child(packet, "invalid-id")) { | |
1512 text = _("Invalid ID"); | |
1513 } else if(xmlnode_get_child(packet, "invalid-namespace")) { | |
1514 text = _("Invalid Namespace"); | |
1515 } else if(xmlnode_get_child(packet, "invalid-xml")) { | |
1516 text = _("Invalid XML"); | |
1517 } else if(xmlnode_get_child(packet, "nonmatching-hosts")) { | |
1518 text = _("Non-matching Hosts"); | |
1519 } else if(xmlnode_get_child(packet, "not-authorized")) { | |
1520 text = _("Not Authorized"); | |
1521 } else if(xmlnode_get_child(packet, "policy-violation")) { | |
1522 text = _("Policy Violation"); | |
1523 } else if(xmlnode_get_child(packet, "remote-connection-failed")) { | |
1524 text = _("Remote Connection Failed"); | |
1525 } else if(xmlnode_get_child(packet, "resource-constraint")) { | |
1526 text = _("Resource Constraint"); | |
1527 } else if(xmlnode_get_child(packet, "restricted-xml")) { | |
1528 text = _("Restricted XML"); | |
1529 } else if(xmlnode_get_child(packet, "see-other-host")) { | |
1530 text = _("See Other Host"); | |
1531 } else if(xmlnode_get_child(packet, "system-shutdown")) { | |
1532 text = _("System Shutdown"); | |
1533 } else if(xmlnode_get_child(packet, "undefined-condition")) { | |
1534 text = _("Undefined Condition"); | |
1535 } else if(xmlnode_get_child(packet, "unsupported-encoding")) { | |
1536 text = _("Unsupported Encoding"); | |
1537 } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) { | |
1538 text = _("Unsupported Stanza Type"); | |
1539 } else if(xmlnode_get_child(packet, "unsupported-version")) { | |
1540 text = _("Unsupported Version"); | |
1541 } else if(xmlnode_get_child(packet, "xml-not-well-formed")) { | |
1542 text = _("XML Not Well Formed"); | |
1543 } else { | |
1544 text = _("Stream Error"); | |
1545 } | |
8401 | 1546 } |
1547 | |
1548 if(text || cdata) { | |
1549 char *ret = g_strdup_printf("%s%s%s", code ? code : "", | |
1550 code ? ": " : "", text ? text : cdata); | |
1551 g_free(cdata); | |
1552 return ret; | |
1553 } else { | |
1554 return NULL; | |
1555 } | |
1556 } | |
1557 | |
9130 | 1558 static GaimCmdRet jabber_cmd_chat_config(GaimConversation *conv, |
9597 | 1559 const char *cmd, char **args, char **error, void *data) |
9130 | 1560 { |
1561 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1562 jabber_chat_request_room_configure(chat); | |
1563 return GAIM_CMD_RET_OK; | |
1564 } | |
1565 | |
1566 static GaimCmdRet jabber_cmd_chat_register(GaimConversation *conv, | |
9597 | 1567 const char *cmd, char **args, char **error, void *data) |
9130 | 1568 { |
1569 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1570 jabber_chat_register(chat); | |
1571 return GAIM_CMD_RET_OK; | |
1572 } | |
1573 | |
1574 static GaimCmdRet jabber_cmd_chat_topic(GaimConversation *conv, | |
9597 | 1575 const char *cmd, char **args, char **error, void *data) |
9130 | 1576 { |
1577 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1578 jabber_chat_change_topic(chat, args ? args[0] : NULL); | |
1579 return GAIM_CMD_RET_OK; | |
1580 } | |
1581 | |
1582 static GaimCmdRet jabber_cmd_chat_nick(GaimConversation *conv, | |
9597 | 1583 const char *cmd, char **args, char **error, void *data) |
9130 | 1584 { |
1585 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1586 | |
1587 if(!args || !args[0]) | |
1588 return GAIM_CMD_RET_FAILED; | |
1589 | |
1590 jabber_chat_change_nick(chat, args[0]); | |
1591 return GAIM_CMD_RET_OK; | |
1592 } | |
1593 | |
1594 static GaimCmdRet jabber_cmd_chat_part(GaimConversation *conv, | |
9597 | 1595 const char *cmd, char **args, char **error, void *data) |
9130 | 1596 { |
1597 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1598 jabber_chat_part(chat, args ? args[0] : NULL); | |
1599 return GAIM_CMD_RET_OK; | |
1600 } | |
1601 | |
9152 | 1602 static GaimCmdRet jabber_cmd_chat_ban(GaimConversation *conv, |
9597 | 1603 const char *cmd, char **args, char **error, void *data) |
9152 | 1604 { |
1605 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1606 | |
1607 if(!args || !args[0]) | |
1608 return GAIM_CMD_RET_FAILED; | |
1609 | |
1610 if(!jabber_chat_ban_user(chat, args[0], args[1])) { | |
1611 *error = g_strdup_printf(_("Unable to ban user %s"), args[0]); | |
1612 return GAIM_CMD_RET_FAILED; | |
1613 } | |
1614 | |
1615 return GAIM_CMD_RET_OK; | |
1616 } | |
1617 | |
11393 | 1618 static GaimCmdRet jabber_cmd_chat_affiliate(GaimConversation *conv, |
1619 const char *cmd, char **args, char **error, void *data) | |
1620 { | |
1621 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1622 | |
1623 if (!args || !args[0] || !args[1]) | |
1624 return GAIM_CMD_RET_FAILED; | |
1625 | |
13237
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1626 if (strcmp(args[1], "owner") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1627 strcmp(args[1], "admin") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1628 strcmp(args[1], "member") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1629 strcmp(args[1], "outcast") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1630 strcmp(args[1], "none") != 0) { |
11393 | 1631 *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[1]); |
1632 return GAIM_CMD_RET_FAILED; | |
1633 } | |
1634 | |
1635 if (!jabber_chat_affiliate_user(chat, args[0], args[1])) { | |
1636 *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), args[0], args[1]); | |
1637 return GAIM_CMD_RET_FAILED; | |
1638 } | |
1639 | |
1640 return GAIM_CMD_RET_OK; | |
1641 } | |
1642 | |
13237
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1643 static GaimCmdRet jabber_cmd_chat_role(GaimConversation *conv, |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1644 const char *cmd, char **args, char **error, void *data) |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1645 { |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1646 JabberChat *chat; |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1647 |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1648 if (!args || !args[0] || !args[1]) |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1649 return GAIM_CMD_RET_FAILED; |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1650 |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1651 if (strcmp(args[1], "moderator") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1652 strcmp(args[1], "participant") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1653 strcmp(args[1], "visitor") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1654 strcmp(args[1], "none") != 0) { |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1655 *error = g_strdup_printf(_("Unknown role: \"%s\""), args[1]); |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1656 return GAIM_CMD_RET_FAILED; |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1657 } |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1658 |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1659 chat = jabber_chat_find_by_conv(conv); |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1660 |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1661 if (!jabber_chat_role_user(chat, args[0], args[1])) { |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1662 *error = g_strdup_printf(_("Unable to set role \"%s\" for user: %s"), |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1663 args[1], args[0]); |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1664 return GAIM_CMD_RET_FAILED; |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1665 } |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1666 |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1667 return GAIM_CMD_RET_OK; |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1668 } |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1669 |
9152 | 1670 static GaimCmdRet jabber_cmd_chat_invite(GaimConversation *conv, |
9597 | 1671 const char *cmd, char **args, char **error, void *data) |
9152 | 1672 { |
1673 if(!args || !args[0]) | |
1674 return GAIM_CMD_RET_FAILED; | |
1675 | |
1676 jabber_chat_invite(gaim_conversation_get_gc(conv), | |
1677 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), args[1] ? args[1] : "", | |
1678 args[0]); | |
1679 | |
1680 return GAIM_CMD_RET_OK; | |
1681 } | |
1682 | |
1683 static GaimCmdRet jabber_cmd_chat_join(GaimConversation *conv, | |
9597 | 1684 const char *cmd, char **args, char **error, void *data) |
9152 | 1685 { |
1686 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1687 GHashTable *components; | |
1688 | |
1689 if(!args || !args[0]) | |
1690 return GAIM_CMD_RET_FAILED; | |
1691 | |
1692 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); | |
1693 | |
1694 g_hash_table_replace(components, "room", args[0]); | |
1695 g_hash_table_replace(components, "server", chat->server); | |
1696 g_hash_table_replace(components, "handle", chat->handle); | |
1697 if(args[1]) | |
1698 g_hash_table_replace(components, "password", args[1]); | |
1699 | |
1700 jabber_chat_join(gaim_conversation_get_gc(conv), components); | |
1701 | |
1702 g_hash_table_destroy(components); | |
1703 return GAIM_CMD_RET_OK; | |
1704 } | |
1705 | |
1706 static GaimCmdRet jabber_cmd_chat_kick(GaimConversation *conv, | |
9597 | 1707 const char *cmd, char **args, char **error, void *data) |
9152 | 1708 { |
1709 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1710 | |
1711 if(!args || !args[0]) | |
1712 return GAIM_CMD_RET_FAILED; | |
1713 | |
1714 if(!jabber_chat_kick_user(chat, args[0], args[1])) { | |
1715 *error = g_strdup_printf(_("Unable to kick user %s"), args[0]); | |
1716 return GAIM_CMD_RET_FAILED; | |
1717 } | |
1718 | |
1719 return GAIM_CMD_RET_OK; | |
1720 } | |
1721 | |
1722 static GaimCmdRet jabber_cmd_chat_msg(GaimConversation *conv, | |
9597 | 1723 const char *cmd, char **args, char **error, void *data) |
9152 | 1724 { |
1725 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1726 char *who; | |
1727 | |
1728 who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]); | |
1729 | |
1730 jabber_message_send_im(gaim_conversation_get_gc(conv), who, args[1], 0); | |
1731 | |
1732 g_free(who); | |
1733 return GAIM_CMD_RET_OK; | |
1734 } | |
1735 | |
12646
5c5e03b9aed6
[gaim-migrate @ 14984]
Richard Laager <rlaager@wiktel.com>
parents:
12645
diff
changeset
|
1736 static gboolean jabber_offline_message(const GaimBuddy *buddy) |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1737 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1738 return TRUE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1739 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1740 |
9130 | 1741 static void jabber_register_commands(void) |
1742 { | |
1743 gaim_cmd_register("config", "", GAIM_CMD_P_PRPL, | |
9597 | 1744 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1745 "prpl-jabber", jabber_cmd_chat_config, | |
1746 _("config: Configure a chat room."), NULL); | |
9130 | 1747 gaim_cmd_register("configure", "", GAIM_CMD_P_PRPL, |
9597 | 1748 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1749 "prpl-jabber", jabber_cmd_chat_config, | |
1750 _("configure: Configure a chat room."), NULL); | |
9130 | 1751 gaim_cmd_register("nick", "s", GAIM_CMD_P_PRPL, |
9597 | 1752 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1753 "prpl-jabber", jabber_cmd_chat_nick, | |
1754 _("nick <new nickname>: Change your nickname."), | |
1755 NULL); | |
9130 | 1756 gaim_cmd_register("part", "s", GAIM_CMD_P_PRPL, |
9597 | 1757 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1758 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1759 jabber_cmd_chat_part, _("part [room]: Leave the room."), | |
1760 NULL); | |
9130 | 1761 gaim_cmd_register("register", "", GAIM_CMD_P_PRPL, |
9597 | 1762 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1763 "prpl-jabber", jabber_cmd_chat_register, | |
1764 _("register: Register with a chat room."), NULL); | |
9130 | 1765 /* XXX: there needs to be a core /topic cmd, methinks */ |
1766 gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL, | |
9597 | 1767 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1768 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1769 jabber_cmd_chat_topic, | |
1770 _("topic [new topic]: View or change the topic."), | |
1771 NULL); | |
9152 | 1772 gaim_cmd_register("ban", "ws", GAIM_CMD_P_PRPL, |
9597 | 1773 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1774 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1775 jabber_cmd_chat_ban, | |
1776 _("ban <user> [room]: Ban a user from the room."), | |
1777 NULL); | |
11393 | 1778 gaim_cmd_register("affiliate", "ws", GAIM_CMD_P_PRPL, |
13237
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1779 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1780 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1781 jabber_cmd_chat_affiliate, |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1782 _("affiliate <user> <owner|admin|member|outcast|none>: Set a user's affiliation with the room."), |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1783 NULL); |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1784 gaim_cmd_register("role", "ws", GAIM_CMD_P_PRPL, |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1785 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1786 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1787 jabber_cmd_chat_role, |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1788 _("role <user> <moderator|participant|visitor|none>: Set a user's role in the room."), |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1789 NULL); |
9152 | 1790 gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL, |
9597 | 1791 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1792 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1793 jabber_cmd_chat_invite, | |
11158
2c930d591492
[gaim-migrate @ 13245]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11033
diff
changeset
|
1794 _("invite <user> [message]: Invite a user to the room."), |
9597 | 1795 NULL); |
9152 | 1796 gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL, |
9597 | 1797 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1798 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1799 jabber_cmd_chat_join, | |
1800 _("join: <room> [server]: Join a chat on this server."), | |
1801 NULL); | |
9152 | 1802 gaim_cmd_register("kick", "ws", GAIM_CMD_P_PRPL, |
9597 | 1803 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1804 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1805 jabber_cmd_chat_kick, | |
1806 _("kick <user> [room]: Kick a user from the room."), | |
1807 NULL); | |
9152 | 1808 gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL, |
9597 | 1809 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1810 "prpl-jabber", jabber_cmd_chat_msg, | |
1811 _("msg <user> <message>: Send a private message to another user."), | |
1812 NULL); | |
9130 | 1813 } |
1814 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1815 static GaimPluginProtocolInfo prpl_info = |
2086 | 1816 { |
12554 | 1817 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME, |
9475 | 1818 NULL, /* user_splits */ |
1819 NULL, /* protocol_options */ | |
10189 | 1820 {"jpeg,gif,png", 0, 0, 96, 96, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ |
9475 | 1821 jabber_list_icon, /* list_icon */ |
1822 jabber_list_emblems, /* list_emblems */ | |
1823 jabber_status_text, /* status_text */ | |
1824 jabber_tooltip_text, /* tooltip_text */ | |
9954 | 1825 jabber_status_types, /* status_types */ |
9475 | 1826 jabber_blist_node_menu, /* blist_node_menu */ |
1827 jabber_chat_info, /* chat_info */ | |
9754 | 1828 jabber_chat_info_defaults, /* chat_info_defaults */ |
9475 | 1829 jabber_login, /* login */ |
1830 jabber_close, /* close */ | |
1831 jabber_message_send_im, /* send_im */ | |
1832 jabber_set_info, /* set_info */ | |
1833 jabber_send_typing, /* send_typing */ | |
1834 jabber_buddy_get_info, /* get_info */ | |
10216 | 1835 jabber_presence_send, /* set_away */ |
9475 | 1836 jabber_idle_set, /* set_idle */ |
1837 NULL, /* change_passwd */ | |
1838 jabber_roster_add_buddy, /* add_buddy */ | |
1839 NULL, /* add_buddies */ | |
1840 jabber_roster_remove_buddy, /* remove_buddy */ | |
1841 NULL, /* remove_buddies */ | |
1842 NULL, /* add_permit */ | |
1843 NULL, /* add_deny */ | |
1844 NULL, /* rem_permit */ | |
1845 NULL, /* rem_deny */ | |
1846 NULL, /* set_permit_deny */ | |
1847 jabber_chat_join, /* join_chat */ | |
1848 NULL, /* reject_chat */ | |
9917 | 1849 jabber_get_chat_name, /* get_chat_name */ |
9475 | 1850 jabber_chat_invite, /* chat_invite */ |
1851 jabber_chat_leave, /* chat_leave */ | |
1852 NULL, /* chat_whisper */ | |
1853 jabber_message_send_chat, /* chat_send */ | |
1854 jabber_keepalive, /* keepalive */ | |
1855 jabber_register_account, /* register_user */ | |
1856 jabber_buddy_get_info_chat, /* get_cb_info */ | |
1857 NULL, /* get_cb_away */ | |
1858 jabber_roster_alias_change, /* alias_buddy */ | |
1859 jabber_roster_group_change, /* group_buddy */ | |
1860 jabber_roster_group_rename, /* rename_group */ | |
1861 NULL, /* buddy_free */ | |
1862 jabber_convo_closed, /* convo_closed */ | |
1863 jabber_normalize, /* normalize */ | |
10189 | 1864 jabber_set_buddy_icon, /* set_buddy_icon */ |
9475 | 1865 NULL, /* remove_group */ |
1866 jabber_chat_buddy_real_name, /* get_cb_real_name */ | |
1867 jabber_chat_set_topic, /* set_chat_topic */ | |
1868 jabber_find_blist_chat, /* find_blist_chat */ | |
1869 jabber_roomlist_get_list, /* roomlist_get_list */ | |
1870 jabber_roomlist_cancel, /* roomlist_cancel */ | |
1871 NULL, /* roomlist_expand_category */ | |
1872 NULL, /* can_receive_file */ | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11939
diff
changeset
|
1873 jabber_si_xfer_send, /* send_file */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11939
diff
changeset
|
1874 jabber_si_new_xfer, /* new_xfer */ |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1875 jabber_offline_message, /* offline_message */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
1876 NULL, /* whiteboard_prpl_ops */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1877 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1878 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1879 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1880 { |
9943 | 1881 GAIM_PLUGIN_MAGIC, |
1882 GAIM_MAJOR_VERSION, | |
1883 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1884 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1885 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1886 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1887 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1888 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1889 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1890 "prpl-jabber", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1891 "Jabber", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1892 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1893 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1894 N_("Jabber Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1895 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1896 N_("Jabber Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1897 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
1898 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1899 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1900 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1901 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1902 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1903 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1904 NULL, /**< ui_info */ |
8993 | 1905 &prpl_info, /**< extra_info */ |
10487 | 1906 NULL, /**< prefs_info */ |
9015 | 1907 jabber_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1908 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1909 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1910 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1911 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1912 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1913 GaimAccountUserSplit *split; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1914 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1915 |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1916 split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1917 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1918 |
11939
85c25a32bb48
[gaim-migrate @ 14230]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11837
diff
changeset
|
1919 split = gaim_account_user_split_new(_("Resource"), "Home", '/'); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1920 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1921 |
7630 | 1922 option = gaim_account_option_bool_new(_("Use TLS if available"), "use_tls", |
1923 TRUE); | |
1924 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1925 option); | |
1926 | |
10941 | 1927 option = gaim_account_option_bool_new(_("Require TLS"), "require_tls", TRUE); |
1928 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1929 | |
1930 option = gaim_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE); | |
7124 | 1931 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
1932 option); | |
6764 | 1933 |
8086 | 1934 option = gaim_account_option_bool_new( |
1935 _("Allow plaintext auth over unencrypted streams"), | |
1936 "auth_plain_in_clear", FALSE); | |
1937 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1938 option); | |
1939 | |
11387 | 1940 option = gaim_account_option_int_new(_("Connect port"), "port", 5222); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1941 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
7014 | 1942 option); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1943 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1944 option = gaim_account_option_string_new(_("Connect server"), |
7014 | 1945 "connect_server", NULL); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1946 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
7014 | 1947 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1948 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1949 my_protocol = plugin; |
7014 | 1950 |
10487 | 1951 gaim_prefs_remove("/plugins/prpl/jabber"); |
9130 | 1952 |
12508 | 1953 /* XXX - If any other plugin wants SASL this won't be good ... */ |
1954 #ifdef HAVE_CYRUS_SASL | |
1955 sasl_client_init(NULL); | |
1956 #endif | |
9130 | 1957 jabber_register_commands(); |
2086 | 1958 } |
1959 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1960 GAIM_INIT_PLUGIN(jabber, init_plugin, info); |