Mercurial > pidgin
annotate src/protocols/jabber/jabber.c @ 9808:db5dddc4dd5e
[gaim-migrate @ 10676]
A bit of ChangeLog rearranging
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 21 Aug 2004 22:48:02 +0000 |
parents | 4a8bf81b82ae |
children | e74eb0d11f86 |
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" |
7014 | 27 #include "debug.h" |
28 #include "message.h" | |
7072 | 29 #include "notify.h" |
8713 | 30 #include "pluginpref.h" |
7014 | 31 #include "prpl.h" |
7072 | 32 #include "request.h" |
7014 | 33 #include "server.h" |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
34 #include "util.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
35 |
7014 | 36 #include "auth.h" |
37 #include "buddy.h" | |
38 #include "chat.h" | |
8312 | 39 #include "disco.h" |
7014 | 40 #include "iq.h" |
41 #include "jutil.h" | |
42 #include "message.h" | |
43 #include "parser.h" | |
44 #include "presence.h" | |
45 #include "jabber.h" | |
46 #include "roster.h" | |
9466 | 47 #include "si.h" |
7923 | 48 #include "xdata.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
49 |
7014 | 50 #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5) |
2086 | 51 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
52 static GaimPlugin *my_protocol = NULL; |
4249 | 53 |
7014 | 54 static void jabber_stream_init(JabberStream *js) |
55 { | |
56 char *open_stream; | |
3340 | 57 |
7014 | 58 open_stream = g_strdup_printf("<stream:stream to='%s' " |
59 "xmlns='jabber:client' " | |
7395 | 60 "xmlns:stream='http://etherx.jabber.org/streams' " |
61 "version='1.0'>", | |
7291 | 62 js->user->domain); |
3311 | 63 |
7642 | 64 jabber_send_raw(js, open_stream, -1); |
2086 | 65 |
7014 | 66 g_free(open_stream); |
2086 | 67 } |
68 | |
7395 | 69 static void |
70 jabber_session_initialized_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
3311 | 71 { |
7014 | 72 const char *type = xmlnode_get_attrib(packet, "type"); |
73 if(type && !strcmp(type, "result")) { | |
74 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
75 } else { | |
76 gaim_connection_error(js->gc, _("Error initializing session")); | |
3311 | 77 } |
78 } | |
79 | |
7014 | 80 static void jabber_session_init(JabberStream *js) |
3311 | 81 { |
7014 | 82 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); |
83 xmlnode *session; | |
3311 | 84 |
7395 | 85 jabber_iq_set_callback(iq, jabber_session_initialized_cb, NULL); |
3311 | 86 |
7014 | 87 session = xmlnode_new_child(iq->node, "session"); |
88 xmlnode_set_attrib(session, "xmlns", "urn:ietf:params:xml:ns:xmpp-session"); | |
3311 | 89 |
7014 | 90 jabber_iq_send(iq); |
3311 | 91 } |
92 | |
7395 | 93 static void jabber_bind_result_cb(JabberStream *js, xmlnode *packet, |
94 gpointer data) | |
95 { | |
8401 | 96 const char *type = xmlnode_get_attrib(packet, "type"); |
97 xmlnode *bind; | |
98 | |
99 if(type && !strcmp(type, "result") && | |
100 (bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) { | |
101 xmlnode *jid; | |
102 char *full_jid; | |
103 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) { | |
104 jabber_id_free(js->user); | |
105 if(!(js->user = jabber_id_new(full_jid))) { | |
106 gaim_connection_error(js->gc, _("Invalid response from server.")); | |
107 } | |
108 } | |
109 } else { | |
110 char *msg = jabber_parse_error(js, packet); | |
111 gaim_connection_error(js->gc, msg); | |
112 g_free(msg); | |
113 } | |
7395 | 114 |
115 jabber_session_init(js); | |
116 } | |
117 | |
118 static void jabber_stream_features_parse(JabberStream *js, xmlnode *packet) | |
119 { | |
8296 | 120 if(xmlnode_get_child(packet, "starttls")) { |
121 if(jabber_process_starttls(js, packet)) | |
122 return; | |
123 } | |
124 | |
7395 | 125 if(xmlnode_get_child(packet, "mechanisms")) { |
126 jabber_auth_start(js, packet); | |
127 } else if(xmlnode_get_child(packet, "bind")) { | |
128 xmlnode *bind, *resource; | |
129 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); | |
130 bind = xmlnode_new_child(iq->node, "bind"); | |
131 xmlnode_set_attrib(bind, "xmlns", "urn:ietf:params:xml:ns:xmpp-bind"); | |
132 resource = xmlnode_new_child(bind, "resource"); | |
133 xmlnode_insert_data(resource, js->user->resource, -1); | |
134 | |
135 jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL); | |
136 | |
137 jabber_iq_send(iq); | |
8296 | 138 } else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ { |
139 /* If we get an empty stream:features packet, or we explicitly get | |
140 * an auth feature with namespace http://jabber.org/features/iq-auth | |
141 * we should revert back to iq:auth authentication, even though we're | |
142 * connecting to an XMPP server. */ | |
143 js->auth_type = JABBER_AUTH_IQ_AUTH; | |
144 jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING); | |
7395 | 145 } |
146 } | |
147 | |
7014 | 148 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet) |
3311 | 149 { |
8401 | 150 char *msg = jabber_parse_error(js, packet); |
3311 | 151 |
8401 | 152 gaim_connection_error(js->gc, msg); |
153 g_free(msg); | |
2086 | 154 } |
155 | |
7014 | 156 static void tls_init(JabberStream *js); |
2086 | 157 |
7014 | 158 void jabber_process_packet(JabberStream *js, xmlnode *packet) |
2086 | 159 { |
7014 | 160 if(!strcmp(packet->name, "iq")) { |
7395 | 161 jabber_iq_parse(js, packet); |
7014 | 162 } else if(!strcmp(packet->name, "presence")) { |
163 jabber_presence_parse(js, packet); | |
164 } else if(!strcmp(packet->name, "message")) { | |
165 jabber_message_parse(js, packet); | |
166 } else if(!strcmp(packet->name, "stream:features")) { | |
7395 | 167 jabber_stream_features_parse(js, packet); |
7014 | 168 } else if(!strcmp(packet->name, "stream:error")) { |
169 jabber_stream_handle_error(js, packet); | |
170 } else if(!strcmp(packet->name, "challenge")) { | |
171 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
172 jabber_auth_handle_challenge(js, packet); | |
173 } else if(!strcmp(packet->name, "success")) { | |
174 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
175 jabber_auth_handle_success(js, packet); | |
176 } else if(!strcmp(packet->name, "failure")) { | |
177 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
178 jabber_auth_handle_failure(js, packet); | |
179 } else if(!strcmp(packet->name, "proceed")) { | |
180 if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc) | |
181 tls_init(js); | |
182 } else { | |
183 gaim_debug(GAIM_DEBUG_WARNING, "jabber", "Unknown packet: %s\n", | |
184 packet->name); | |
2086 | 185 } |
186 } | |
187 | |
7642 | 188 void jabber_send_raw(JabberStream *js, const char *data, int len) |
2086 | 189 { |
7014 | 190 int ret; |
2086 | 191 |
7014 | 192 /* because printing a tab to debug every minute gets old */ |
193 if(strcmp(data, "\t")) | |
8401 | 194 gaim_debug(GAIM_DEBUG_MISC, "jabber", "Sending%s: %s\n", |
7014 | 195 js->gsc ? " (ssl)" : "", data); |
2086 | 196 |
7014 | 197 if(js->gsc) { |
7642 | 198 ret = gaim_ssl_write(js->gsc, data, len == -1 ? strlen(data) : len); |
7014 | 199 } else { |
8013 | 200 if(js->fd < 0) |
201 return; | |
7642 | 202 ret = write(js->fd, data, len == -1 ? strlen(data) : len); |
2814
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
203 } |
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
204 |
7014 | 205 if(ret < 0) |
206 gaim_connection_error(js->gc, _("Write error")); | |
207 | |
2814
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
208 } |
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
209 |
7014 | 210 void jabber_send(JabberStream *js, xmlnode *packet) |
2086 | 211 { |
7014 | 212 char *txt; |
7642 | 213 int len; |
2086 | 214 |
7642 | 215 txt = xmlnode_to_str(packet, &len); |
216 jabber_send_raw(js, txt, len); | |
7014 | 217 g_free(txt); |
2086 | 218 } |
219 | |
7014 | 220 static void jabber_keepalive(GaimConnection *gc) |
2086 | 221 { |
7642 | 222 jabber_send_raw(gc->proto_data, "\t", -1); |
2086 | 223 } |
224 | |
7014 | 225 static void |
226 jabber_recv_cb_ssl(gpointer data, GaimSslConnection *gsc, | |
6764 | 227 GaimInputCondition cond) |
228 { | |
7014 | 229 GaimConnection *gc = data; |
230 JabberStream *js = gc->proto_data; | |
6764 | 231 int len; |
7014 | 232 static char buf[4096]; |
6768 | 233 |
7014 | 234 if(!g_list_find(gaim_connections_get_all(), gc)) { |
6768 | 235 gaim_ssl_close(gsc); |
236 return; | |
237 } | |
238 | |
7014 | 239 if((len = gaim_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) { |
6764 | 240 buf[len] = '\0'; |
7014 | 241 gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf); |
242 jabber_parser_process(js, buf, len); | |
7177 | 243 } else { |
244 gaim_connection_error(gc, _("Read Error")); | |
2086 | 245 } |
246 } | |
247 | |
7014 | 248 static void |
249 jabber_recv_cb(gpointer data, gint source, GaimInputCondition condition) | |
2086 | 250 { |
5572 | 251 GaimConnection *gc = data; |
7014 | 252 JabberStream *js = gc->proto_data; |
253 int len; | |
254 static char buf[4096]; | |
2086 | 255 |
7014 | 256 if(!g_list_find(gaim_connections_get_all(), gc)) |
257 return; | |
2956 | 258 |
7014 | 259 if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) { |
260 buf[len] = '\0'; | |
261 gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf); | |
262 jabber_parser_process(js, buf, len); | |
7177 | 263 } else { |
264 gaim_connection_error(gc, _("Read Error")); | |
7014 | 265 } |
2086 | 266 } |
267 | |
7014 | 268 static void |
269 jabber_login_callback_ssl(gpointer data, GaimSslConnection *gsc, | |
6764 | 270 GaimInputCondition cond) |
271 { | |
272 GaimConnection *gc = data; | |
7014 | 273 JabberStream *js = gc->proto_data; |
6764 | 274 |
7014 | 275 if(!g_list_find(gaim_connections_get_all(), gc)) { |
6764 | 276 gaim_ssl_close(gsc); |
277 return; | |
278 } | |
279 | |
7014 | 280 js->gsc = gsc; |
6764 | 281 |
7014 | 282 if(js->state == JABBER_STREAM_CONNECTING) |
7642 | 283 jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
6764 | 284 |
7014 | 285 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
286 gaim_ssl_input_add(gsc, jabber_recv_cb_ssl, gc); | |
6764 | 287 } |
288 | |
7014 | 289 |
290 static void | |
291 jabber_login_callback(gpointer data, gint source, GaimInputCondition cond) | |
6764 | 292 { |
5572 | 293 GaimConnection *gc = data; |
7014 | 294 JabberStream *js = gc->proto_data; |
2086 | 295 |
8783 | 296 if (source < 0) { |
297 gaim_connection_error(gc, _("Couldn't connect to host")); | |
298 return; | |
299 } | |
300 | |
7014 | 301 if(!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 302 close(source); |
303 return; | |
304 } | |
305 | |
7014 | 306 js->fd = source; |
2956 | 307 |
7014 | 308 if(js->state == JABBER_STREAM_CONNECTING) |
7642 | 309 jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
2300
d2686f757d6e
[gaim-migrate @ 2310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
310 |
7014 | 311 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
312 gc->inpa = gaim_input_add(js->fd, GAIM_INPUT_READ, jabber_recv_cb, gc); | |
313 } | |
2086 | 314 |
7014 | 315 static void |
7426 | 316 jabber_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, |
317 gpointer data) | |
318 { | |
319 GaimConnection *gc = data; | |
8360 | 320 JabberStream *js = gc->proto_data; |
7426 | 321 |
322 switch(error) { | |
8362 | 323 case GAIM_SSL_CONNECT_FAILED: |
324 gaim_connection_error(gc, _("Connection Failed")); | |
325 break; | |
7426 | 326 case GAIM_SSL_HANDSHAKE_FAILED: |
327 gaim_connection_error(gc, _("SSL Handshake Failed")); | |
328 break; | |
329 } | |
8360 | 330 |
331 js->gsc = NULL; | |
7426 | 332 } |
333 | |
7427 | 334 static void tls_init(JabberStream *js) |
335 { | |
336 gaim_input_remove(js->gc->inpa); | |
337 js->gc->inpa = 0; | |
338 js->gsc = gaim_ssl_connect_fd(js->gc->account, js->fd, | |
339 jabber_login_callback_ssl, jabber_ssl_connect_failure, js->gc); | |
340 } | |
341 | |
342 | |
7426 | 343 static void |
7014 | 344 jabber_login(GaimAccount *account) |
2086 | 345 { |
7014 | 346 int rc; |
347 GaimConnection *gc = gaim_account_get_connection(account); | |
348 const char *connect_server = gaim_account_get_string(account, | |
349 "connect_server", ""); | |
5572 | 350 const char *server; |
7014 | 351 JabberStream *js; |
2086 | 352 |
7014 | 353 gc->flags |= GAIM_CONNECTION_HTML; |
354 js = gc->proto_data = g_new0(JabberStream, 1); | |
355 js->gc = gc; | |
8013 | 356 js->fd = -1; |
8312 | 357 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
358 g_free, g_free); | |
359 js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
7395 | 360 g_free, g_free); |
7014 | 361 js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, |
7116 | 362 g_free, (GDestroyNotify)jabber_buddy_free); |
7014 | 363 js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, |
8396 | 364 g_free, (GDestroyNotify)jabber_chat_free); |
8043 | 365 js->chat_servers = g_list_append(NULL, g_strdup("conference.jabber.org")); |
7014 | 366 js->user = jabber_id_new(gaim_account_get_username(account)); |
7322 | 367 js->next_id = g_random_int(); |
5613 | 368 |
7310 | 369 if(!js->user) { |
370 gaim_connection_error(gc, _("Invalid Jabber ID")); | |
371 return; | |
372 } | |
373 | |
7147 | 374 if(!js->user->resource) { |
375 char *me; | |
376 js->user->resource = g_strdup("Gaim"); | |
377 if(!js->user->node) { | |
378 js->user->node = js->user->domain; | |
379 js->user->domain = g_strdup("jabber.org"); | |
380 } | |
381 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
382 js->user->resource); | |
383 gaim_account_set_username(account, me); | |
384 g_free(me); | |
7145 | 385 } |
386 | |
7014 | 387 server = connect_server[0] ? connect_server : js->user->domain; |
2086 | 388 |
7014 | 389 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); |
2956 | 390 |
7630 | 391 |
392 if(gaim_account_get_bool(account, "old_ssl", FALSE)) { | |
393 if(gaim_ssl_is_supported()) { | |
394 js->gsc = gaim_ssl_connect(account, server, | |
395 gaim_account_get_int(account, "port", 5222), | |
396 jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); | |
397 } else { | |
398 gaim_connection_error(gc, _("SSL support unavailable")); | |
399 } | |
3311 | 400 } |
3770 | 401 |
7014 | 402 if(!js->gsc) { |
403 rc = gaim_proxy_connect(account, server, | |
404 gaim_account_get_int(account, "port", 5222), | |
405 jabber_login_callback, gc); | |
2086 | 406 |
7014 | 407 if (rc != 0) |
408 gaim_connection_error(gc, _("Unable to create socket")); | |
2956 | 409 } |
2086 | 410 } |
411 | |
7072 | 412 static gboolean |
413 conn_close_cb(gpointer data) | |
414 { | |
415 JabberStream *js = data; | |
416 gaim_connection_destroy(js->gc); | |
417 return FALSE; | |
418 } | |
419 | |
420 static void | |
421 jabber_connection_schedule_close(JabberStream *js) | |
422 { | |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8194
diff
changeset
|
423 gaim_timeout_add(0, conn_close_cb, js); |
7072 | 424 } |
425 | |
426 static void | |
7395 | 427 jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
7072 | 428 { |
429 const char *type = xmlnode_get_attrib(packet, "type"); | |
430 char *buf; | |
431 | |
432 if(!strcmp(type, "result")) { | |
433 buf = g_strdup_printf(_("Registration of %s@%s successful"), | |
434 js->user->node, js->user->domain); | |
435 gaim_notify_info(NULL, _("Registration Successful"), | |
436 _("Registration Successful"), buf); | |
437 g_free(buf); | |
438 } else { | |
8401 | 439 char *msg = jabber_parse_error(js, packet); |
7072 | 440 |
8401 | 441 if(!msg) |
442 msg = g_strdup(_("Unknown Error")); | |
7072 | 443 |
444 gaim_notify_error(NULL, _("Registration Failed"), | |
8401 | 445 _("Registration Failed"), msg); |
446 g_free(msg); | |
7072 | 447 } |
448 jabber_connection_schedule_close(js); | |
449 } | |
450 | |
451 static void | |
452 jabber_register_cb(JabberStream *js, GaimRequestFields *fields) | |
453 { | |
454 GList *groups, *flds; | |
455 xmlnode *query, *y; | |
456 JabberIq *iq; | |
7264 | 457 char *username; |
7072 | 458 |
459 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
460 query = xmlnode_get_child(iq->node, "query"); | |
461 | |
462 for(groups = gaim_request_fields_get_groups(fields); groups; | |
463 groups = groups->next) { | |
464 for(flds = gaim_request_field_group_get_fields(groups->data); | |
465 flds; flds = flds->next) { | |
466 GaimRequestField *field = flds->data; | |
467 const char *id = gaim_request_field_get_id(field); | |
468 const char *value = gaim_request_field_string_get_value(field); | |
469 | |
470 if(!strcmp(id, "username")) { | |
471 y = xmlnode_new_child(query, "username"); | |
472 } else if(!strcmp(id, "password")) { | |
473 y = xmlnode_new_child(query, "password"); | |
474 } else if(!strcmp(id, "name")) { | |
475 y = xmlnode_new_child(query, "name"); | |
476 } else if(!strcmp(id, "email")) { | |
477 y = xmlnode_new_child(query, "email"); | |
478 } else if(!strcmp(id, "nick")) { | |
479 y = xmlnode_new_child(query, "nick"); | |
480 } else if(!strcmp(id, "first")) { | |
481 y = xmlnode_new_child(query, "first"); | |
482 } else if(!strcmp(id, "last")) { | |
483 y = xmlnode_new_child(query, "last"); | |
484 } else if(!strcmp(id, "address")) { | |
485 y = xmlnode_new_child(query, "address"); | |
486 } else if(!strcmp(id, "city")) { | |
487 y = xmlnode_new_child(query, "city"); | |
488 } else if(!strcmp(id, "state")) { | |
489 y = xmlnode_new_child(query, "state"); | |
490 } else if(!strcmp(id, "zip")) { | |
491 y = xmlnode_new_child(query, "zip"); | |
492 } else if(!strcmp(id, "phone")) { | |
493 y = xmlnode_new_child(query, "phone"); | |
494 } else if(!strcmp(id, "url")) { | |
495 y = xmlnode_new_child(query, "url"); | |
496 } else if(!strcmp(id, "date")) { | |
497 y = xmlnode_new_child(query, "date"); | |
498 } else { | |
499 continue; | |
500 } | |
501 xmlnode_insert_data(y, value, -1); | |
7264 | 502 if(!strcmp(id, "username")) { |
503 if(js->user->node) | |
504 g_free(js->user->node); | |
505 js->user->node = g_strdup(value); | |
506 } | |
7072 | 507 } |
508 } | |
509 | |
7264 | 510 username = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, |
511 js->user->resource); | |
512 gaim_account_set_username(js->gc->account, username); | |
513 g_free(username); | |
514 | |
7395 | 515 jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); |
7072 | 516 |
517 jabber_iq_send(iq); | |
518 | |
519 } | |
520 | |
521 static void | |
522 jabber_register_cancel_cb(JabberStream *js, GaimRequestFields *fields) | |
523 { | |
524 jabber_connection_schedule_close(js); | |
525 } | |
526 | |
7923 | 527 static void jabber_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
528 { | |
529 xmlnode *query; | |
530 JabberIq *iq; | |
531 | |
532 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
533 query = xmlnode_get_child(iq->node, "query"); | |
534 | |
535 xmlnode_insert_child(query, result); | |
536 | |
537 jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); | |
538 jabber_iq_send(iq); | |
539 } | |
540 | |
7072 | 541 void jabber_register_parse(JabberStream *js, xmlnode *packet) |
542 { | |
543 if(js->registration) { | |
544 GaimRequestFields *fields; | |
545 GaimRequestFieldGroup *group; | |
546 GaimRequestField *field; | |
7923 | 547 xmlnode *query, *x, *y; |
7072 | 548 char *instructions; |
549 | |
550 /* get rid of the login thingy */ | |
551 gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
552 | |
553 query = xmlnode_get_child(packet, "query"); | |
554 | |
555 if(xmlnode_get_child(query, "registered")) { | |
556 gaim_notify_error(NULL, _("Already Registered"), | |
557 _("Already Registered"), NULL); | |
558 jabber_connection_schedule_close(js); | |
559 return; | |
560 } | |
561 | |
8398 | 562 if((x = xmlnode_get_child_with_namespace(packet, "x", |
563 "jabber:x:data"))) { | |
564 jabber_x_data_request(js, x, jabber_register_x_data_cb, NULL); | |
565 return; | |
566 } else if((x = xmlnode_get_child_with_namespace(packet, "x", | |
567 "jabber:x:oob"))) { | |
568 xmlnode *url; | |
7923 | 569 |
8398 | 570 if((url = xmlnode_get_child(x, "url"))) { |
571 char *href; | |
572 if((href = xmlnode_get_data(url))) { | |
573 gaim_notify_uri(NULL, href); | |
574 g_free(href); | |
575 js->gc->wants_to_die = TRUE; | |
576 jabber_connection_schedule_close(js); | |
577 return; | |
578 } | |
7923 | 579 } |
580 } | |
581 | |
582 /* as a last resort, use the old jabber:iq:register syntax */ | |
583 | |
7072 | 584 fields = gaim_request_fields_new(); |
585 group = gaim_request_field_group_new(NULL); | |
586 gaim_request_fields_add_group(fields, group); | |
587 | |
588 field = gaim_request_field_string_new("username", _("Username"), | |
589 js->user->node, FALSE); | |
590 gaim_request_field_group_add_field(group, field); | |
591 | |
592 field = gaim_request_field_string_new("password", _("Password"), | |
593 gaim_account_get_password(js->gc->account), FALSE); | |
594 gaim_request_field_string_set_masked(field, TRUE); | |
595 gaim_request_field_group_add_field(group, field); | |
596 | |
597 if(xmlnode_get_child(query, "name")) { | |
598 field = gaim_request_field_string_new("name", _("Name"), | |
599 gaim_account_get_alias(js->gc->account), FALSE); | |
600 gaim_request_field_group_add_field(group, field); | |
601 } | |
602 if(xmlnode_get_child(query, "email")) { | |
603 field = gaim_request_field_string_new("email", _("E-Mail"), | |
604 NULL, FALSE); | |
605 gaim_request_field_group_add_field(group, field); | |
606 } | |
607 if(xmlnode_get_child(query, "nick")) { | |
608 field = gaim_request_field_string_new("nick", _("Nickname"), | |
609 NULL, FALSE); | |
610 gaim_request_field_group_add_field(group, field); | |
611 } | |
612 if(xmlnode_get_child(query, "first")) { | |
613 field = gaim_request_field_string_new("first", _("First Name"), | |
614 NULL, FALSE); | |
615 gaim_request_field_group_add_field(group, field); | |
616 } | |
617 if(xmlnode_get_child(query, "last")) { | |
618 field = gaim_request_field_string_new("last", _("Last Name"), | |
619 NULL, FALSE); | |
620 gaim_request_field_group_add_field(group, field); | |
621 } | |
622 if(xmlnode_get_child(query, "address")) { | |
623 field = gaim_request_field_string_new("address", _("Address"), | |
624 NULL, FALSE); | |
625 gaim_request_field_group_add_field(group, field); | |
626 } | |
627 if(xmlnode_get_child(query, "city")) { | |
628 field = gaim_request_field_string_new("city", _("City"), | |
629 NULL, FALSE); | |
630 gaim_request_field_group_add_field(group, field); | |
631 } | |
632 if(xmlnode_get_child(query, "state")) { | |
633 field = gaim_request_field_string_new("state", _("State"), | |
634 NULL, FALSE); | |
635 gaim_request_field_group_add_field(group, field); | |
636 } | |
637 if(xmlnode_get_child(query, "zip")) { | |
638 field = gaim_request_field_string_new("zip", _("Postal Code"), | |
639 NULL, FALSE); | |
640 gaim_request_field_group_add_field(group, field); | |
641 } | |
642 if(xmlnode_get_child(query, "phone")) { | |
643 field = gaim_request_field_string_new("phone", _("Phone"), | |
644 NULL, FALSE); | |
645 gaim_request_field_group_add_field(group, field); | |
646 } | |
647 if(xmlnode_get_child(query, "url")) { | |
648 field = gaim_request_field_string_new("url", _("URL"), | |
649 NULL, FALSE); | |
650 gaim_request_field_group_add_field(group, field); | |
651 } | |
652 if(xmlnode_get_child(query, "date")) { | |
653 field = gaim_request_field_string_new("date", _("Date"), | |
654 NULL, FALSE); | |
655 gaim_request_field_group_add_field(group, field); | |
656 } | |
657 | |
658 if((y = xmlnode_get_child(query, "instructions"))) | |
659 instructions = xmlnode_get_data(y); | |
660 else | |
661 instructions = g_strdup(_("Please fill out the information below " | |
662 "to register your new account.")); | |
663 | |
664 gaim_request_fields(js->gc, _("Register New Jabber Account"), | |
665 _("Register New Jabber Account"), instructions, fields, | |
666 _("Register"), G_CALLBACK(jabber_register_cb), | |
667 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); | |
668 } | |
669 } | |
670 | |
8016 | 671 void jabber_register_start(JabberStream *js) |
7072 | 672 { |
673 JabberIq *iq; | |
674 | |
675 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); | |
676 jabber_iq_send(iq); | |
677 } | |
678 | |
679 static void jabber_register_account(GaimAccount *account) | |
680 { | |
681 GaimConnection *gc = gaim_account_get_connection(account); | |
682 JabberStream *js; | |
683 const char *connect_server = gaim_account_get_string(account, | |
684 "connect_server", ""); | |
685 const char *server; | |
686 int rc; | |
687 | |
688 js = gc->proto_data = g_new0(JabberStream, 1); | |
689 js->gc = gc; | |
690 js->registration = TRUE; | |
8312 | 691 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
692 g_free, g_free); | |
693 js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
7395 | 694 g_free, g_free); |
7072 | 695 js->user = jabber_id_new(gaim_account_get_username(account)); |
7322 | 696 js->next_id = g_random_int(); |
7072 | 697 |
7310 | 698 if(!js->user) { |
699 gaim_connection_error(gc, _("Invalid Jabber ID")); | |
700 return; | |
701 } | |
702 | |
7147 | 703 if(!js->user->resource) { |
704 char *me; | |
705 js->user->resource = g_strdup("Gaim"); | |
706 if(!js->user->node) { | |
707 js->user->node = js->user->domain; | |
708 js->user->domain = g_strdup("jabber.org"); | |
709 } | |
710 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
711 js->user->resource); | |
712 gaim_account_set_username(account, me); | |
713 g_free(me); | |
714 } | |
715 | |
7072 | 716 server = connect_server[0] ? connect_server : js->user->domain; |
717 | |
718 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); | |
719 | |
7630 | 720 if(gaim_account_get_bool(account, "old_ssl", FALSE)) { |
721 if(gaim_ssl_is_supported()) { | |
722 js->gsc = gaim_ssl_connect(account, server, | |
723 gaim_account_get_int(account, "port", 5222), | |
724 jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); | |
725 } else { | |
726 gaim_connection_error(gc, _("SSL support unavailable")); | |
727 } | |
7072 | 728 } |
729 | |
730 if(!js->gsc) { | |
731 rc = gaim_proxy_connect(account, server, | |
732 gaim_account_get_int(account, "port", 5222), | |
733 jabber_login_callback, gc); | |
734 | |
735 if (rc != 0) | |
736 gaim_connection_error(gc, _("Unable to create socket")); | |
737 } | |
738 } | |
739 | |
5572 | 740 static void jabber_close(GaimConnection *gc) |
2086 | 741 { |
7014 | 742 JabberStream *js = gc->proto_data; |
2956 | 743 |
9173 | 744 jabber_presence_send(gc, "unavailable", _("Logged out")); |
7642 | 745 jabber_send_raw(js, "</stream:stream>", -1); |
3311 | 746 |
7014 | 747 if(js->gsc) { |
748 gaim_ssl_close(js->gsc); | |
8360 | 749 } else if (js->fd > 0) { |
7072 | 750 if(js->gc->inpa) |
751 gaim_input_remove(js->gc->inpa); | |
7014 | 752 close(js->fd); |
753 } | |
3311 | 754 |
7587 | 755 if(js->context) |
756 g_markup_parse_context_free(js->context); | |
8312 | 757 if(js->iq_callbacks) |
758 g_hash_table_destroy(js->iq_callbacks); | |
759 if(js->disco_callbacks) | |
760 g_hash_table_destroy(js->disco_callbacks); | |
7072 | 761 if(js->buddies) |
762 g_hash_table_destroy(js->buddies); | |
763 if(js->chats) | |
764 g_hash_table_destroy(js->chats); | |
8043 | 765 while(js->chat_servers) { |
766 g_free(js->chat_servers->data); | |
767 js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers); | |
768 } | |
7014 | 769 if(js->stream_id) |
770 g_free(js->stream_id); | |
7587 | 771 if(js->user) |
772 jabber_id_free(js->user); | |
7014 | 773 g_free(js); |
5093 | 774 } |
775 | |
7014 | 776 void jabber_stream_set_state(JabberStream *js, JabberStreamState state) |
3105 | 777 { |
7014 | 778 js->state = state; |
779 switch(state) { | |
780 case JABBER_STREAM_OFFLINE: | |
781 break; | |
782 case JABBER_STREAM_CONNECTING: | |
783 gaim_connection_update_progress(js->gc, _("Connecting"), 1, | |
784 JABBER_CONNECT_STEPS); | |
785 break; | |
786 case JABBER_STREAM_INITIALIZING: | |
787 gaim_connection_update_progress(js->gc, _("Initializing Stream"), | |
788 js->gsc ? 5 : 2, JABBER_CONNECT_STEPS); | |
789 jabber_stream_init(js); | |
790 jabber_parser_setup(js); | |
791 break; | |
792 case JABBER_STREAM_AUTHENTICATING: | |
793 gaim_connection_update_progress(js->gc, _("Authenticating"), | |
794 js->gsc ? 6 : 3, JABBER_CONNECT_STEPS); | |
8296 | 795 if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) { |
796 jabber_register_start(js); | |
797 } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) { | |
798 jabber_auth_start_old(js); | |
8016 | 799 } |
7014 | 800 break; |
801 case JABBER_STREAM_REINITIALIZING: | |
802 gaim_connection_update_progress(js->gc, _("Re-initializing Stream"), | |
803 6, JABBER_CONNECT_STEPS); | |
804 jabber_stream_init(js); | |
805 break; | |
806 case JABBER_STREAM_CONNECTED: | |
807 gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
808 jabber_roster_request(js); | |
809 jabber_presence_send(js->gc, js->gc->away_state, js->gc->away); | |
8312 | 810 jabber_disco_items_server(js); |
7014 | 811 serv_finish_login(js->gc); |
812 break; | |
3105 | 813 } |
814 } | |
815 | |
7014 | 816 char *jabber_get_next_id(JabberStream *js) |
2086 | 817 { |
7322 | 818 return g_strdup_printf("gaim%x", js->next_id++); |
2086 | 819 } |
820 | |
7923 | 821 |
822 static void jabber_idle_set(GaimConnection *gc, int idle) | |
3340 | 823 { |
7014 | 824 JabberStream *js = gc->proto_data; |
3340 | 825 |
7014 | 826 js->idle = idle ? time(NULL) - idle : idle; |
3314 | 827 } |
828 | |
6695 | 829 static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) |
2086 | 830 { |
4687 | 831 return "jabber"; |
832 } | |
4916 | 833 |
7014 | 834 static void jabber_list_emblems(GaimBuddy *b, char **se, char **sw, |
835 char **nw, char **ne) | |
4916 | 836 { |
7014 | 837 JabberStream *js; |
838 JabberBuddy *jb; | |
839 | |
840 if(!b->account->gc) | |
841 return; | |
842 js = b->account->gc->proto_data; | |
843 jb = jabber_buddy_find(js, b->name, FALSE); | |
5135 | 844 |
845 if(!GAIM_BUDDY_IS_ONLINE(b)) { | |
7014 | 846 if(jb && jb->error_msg) |
4927 | 847 *nw = "error"; |
5135 | 848 |
7014 | 849 if(jb && (jb->subscription & JABBER_SUB_PENDING || |
850 !(jb->subscription & JABBER_SUB_TO))) | |
5135 | 851 *se = "notauthorized"; |
852 else | |
853 *se = "offline"; | |
4916 | 854 } else { |
855 switch (b->uc) { | |
7014 | 856 case JABBER_STATE_AWAY: |
857 *se = "away"; | |
858 break; | |
859 case JABBER_STATE_CHAT: | |
860 *se = "chat"; | |
861 break; | |
862 case JABBER_STATE_XA: | |
863 *se = "extendedaway"; | |
864 break; | |
865 case JABBER_STATE_DND: | |
8193 | 866 *se = "dnd"; |
7014 | 867 break; |
868 case JABBER_STATE_ERROR: | |
869 *se = "error"; | |
870 break; | |
4916 | 871 } |
2086 | 872 } |
4916 | 873 } |
2086 | 874 |
7014 | 875 static char *jabber_status_text(GaimBuddy *b) |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
876 { |
7014 | 877 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
878 FALSE); | |
879 char *ret = NULL; | |
5234 | 880 |
7014 | 881 if(jb && !GAIM_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { |
882 ret = g_strdup(_("Not Authorized")); | |
883 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
884 ret = g_strdup(jb->error_msg); | |
2956 | 885 } else { |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
886 char *stripped; |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
887 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
888 stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)); |
2956 | 889 |
7014 | 890 if(!stripped && b->uc & UC_UNAVAILABLE) |
891 stripped = g_strdup(jabber_get_state_string(b->uc)); | |
2086 | 892 |
7014 | 893 if(stripped) { |
894 ret = g_markup_escape_text(stripped, -1); | |
895 g_free(stripped); | |
896 } | |
2086 | 897 } |
898 | |
7014 | 899 return ret; |
2956 | 900 } |
901 | |
6695 | 902 static char *jabber_tooltip_text(GaimBuddy *b) |
4744 | 903 { |
7014 | 904 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
905 FALSE); | |
8194 | 906 GString *ret = g_string_new(""); |
7014 | 907 |
8194 | 908 if(jb) { |
909 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL); | |
910 const char *sub; | |
911 if(jb->subscription & JABBER_SUB_FROM) { | |
912 if(jb->subscription & JABBER_SUB_TO) | |
913 sub = _("Both"); | |
914 else if(jb->subscription & JABBER_SUB_PENDING) | |
915 sub = _("From (To pending)"); | |
916 else | |
917 sub = _("From"); | |
918 } else { | |
919 if(jb->subscription & JABBER_SUB_TO) | |
920 sub = _("To"); | |
921 else if(jb->subscription & JABBER_SUB_PENDING) | |
922 sub = _("None (To pending)"); | |
923 else | |
924 sub = _("None"); | |
925 } | |
8591 | 926 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Subscription"), sub); |
8194 | 927 |
928 if(jbr) { | |
929 char *text = NULL; | |
930 if(jbr->status) { | |
931 char *stripped; | |
932 stripped = gaim_markup_strip_html(jbr->status); | |
933 text = g_markup_escape_text(stripped, -1); | |
934 g_free(stripped); | |
935 } | |
936 | |
8591 | 937 g_string_append_printf(ret, "\n<b>%s:</b> %s%s%s", |
8194 | 938 _("Status"), |
939 jabber_get_state_string(jbr->state), | |
940 text ? ": " : "", | |
941 text ? text : ""); | |
942 if(text) | |
943 g_free(text); | |
944 } else if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
8591 | 945 g_string_append_printf(ret, "\n<b>%s:</b> %s", |
8194 | 946 _("Error"), jb->error_msg); |
947 } | |
4745 | 948 } |
4744 | 949 |
8591 | 950 return g_string_free(ret, FALSE); |
4732 | 951 } |
952 | |
7014 | 953 static GList *jabber_away_states(GaimConnection *gc) |
954 { | |
8166 | 955 JabberStream *js = gc->proto_data; |
2086 | 956 GList *m = NULL; |
957 | |
4982 | 958 m = g_list_append(m, _("Online")); |
959 m = g_list_append(m, _("Chatty")); | |
960 m = g_list_append(m, _("Away")); | |
961 m = g_list_append(m, _("Extended Away")); | |
962 m = g_list_append(m, _("Do Not Disturb")); | |
8166 | 963 if(js->protocol_version == JABBER_PROTO_0_9) |
964 m = g_list_append(m, _("Invisible")); | |
4110 | 965 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
2086 | 966 |
967 return m; | |
968 } | |
969 | |
7395 | 970 static void |
971 jabber_password_change_result_cb(JabberStream *js, xmlnode *packet, | |
972 gpointer data) | |
7124 | 973 { |
974 const char *type; | |
975 | |
976 type = xmlnode_get_attrib(packet, "type"); | |
977 | |
9414 | 978 if(type && !strcmp(type, "result")) { |
7124 | 979 gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"), |
980 _("Your password has been changed.")); | |
981 } else { | |
8401 | 982 char *msg = jabber_parse_error(js, packet); |
7124 | 983 |
8401 | 984 gaim_notify_error(js->gc, _("Error changing password"), |
985 _("Error changing password"), msg); | |
986 g_free(msg); | |
7124 | 987 } |
988 } | |
989 | |
990 static void jabber_password_change_cb(JabberStream *js, | |
991 GaimRequestFields *fields) | |
992 { | |
993 const char *p1, *p2; | |
994 JabberIq *iq; | |
995 xmlnode *query, *y; | |
996 | |
997 p1 = gaim_request_fields_get_string(fields, "password1"); | |
998 p2 = gaim_request_fields_get_string(fields, "password2"); | |
999 | |
1000 if(strcmp(p1, p2)) { | |
1001 gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); | |
1002 return; | |
1003 } | |
1004 | |
1005 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
1006 | |
1007 xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
1008 | |
1009 query = xmlnode_get_child(iq->node, "query"); | |
1010 | |
1011 y = xmlnode_new_child(query, "username"); | |
1012 xmlnode_insert_data(y, js->user->node, -1); | |
1013 y = xmlnode_new_child(query, "password"); | |
1014 xmlnode_insert_data(y, p1, -1); | |
1015 | |
7395 | 1016 jabber_iq_set_callback(iq, jabber_password_change_result_cb, NULL); |
7124 | 1017 |
1018 jabber_iq_send(iq); | |
1019 | |
1020 gaim_account_set_password(js->gc->account, p1); | |
1021 } | |
1022 | |
9015 | 1023 static void jabber_password_change(GaimPluginAction *action) |
7124 | 1024 { |
9015 | 1025 |
1026 GaimConnection *gc = (GaimConnection *) action->context; | |
7124 | 1027 JabberStream *js = gc->proto_data; |
1028 GaimRequestFields *fields; | |
1029 GaimRequestFieldGroup *group; | |
1030 GaimRequestField *field; | |
1031 | |
1032 fields = gaim_request_fields_new(); | |
1033 group = gaim_request_field_group_new(NULL); | |
1034 gaim_request_fields_add_group(fields, group); | |
1035 | |
1036 field = gaim_request_field_string_new("password1", _("Password"), | |
1037 "", FALSE); | |
1038 gaim_request_field_string_set_masked(field, TRUE); | |
1039 gaim_request_field_group_add_field(group, field); | |
1040 | |
1041 field = gaim_request_field_string_new("password2", _("Password (again)"), | |
1042 "", FALSE); | |
1043 gaim_request_field_string_set_masked(field, TRUE); | |
1044 gaim_request_field_group_add_field(group, field); | |
1045 | |
1046 gaim_request_fields(js->gc, _("Change Jabber Password"), | |
1047 _("Change Jabber Password"), _("Please enter your new password"), | |
1048 fields, _("OK"), G_CALLBACK(jabber_password_change_cb), | |
1049 _("Cancel"), NULL, js); | |
1050 } | |
1051 | |
9015 | 1052 static GList *jabber_actions(GaimPlugin *plugin, gpointer context) |
2956 | 1053 { |
1054 GList *m = NULL; | |
9015 | 1055 GaimPluginAction *act; |
4333 | 1056 |
9015 | 1057 act = gaim_plugin_action_new(_("Set User Info"), |
1058 jabber_setup_set_info); | |
1059 m = g_list_append(m, act); | |
4333 | 1060 |
8296 | 1061 /* if (js->protocol_options & CHANGE_PASSWORD) { */ |
9015 | 1062 act = gaim_plugin_action_new(_("Change Password"), |
1063 jabber_password_change); | |
1064 m = g_list_append(m, act); | |
8296 | 1065 /* } */ |
2956 | 1066 |
1067 return m; | |
1068 } | |
1069 | |
7999 | 1070 static GaimChat *jabber_find_blist_chat(GaimAccount *account, const char *name) |
1071 { | |
1072 GaimBlistNode *gnode, *cnode; | |
1073 JabberID *jid; | |
1074 | |
1075 if(!(jid = jabber_id_new(name))) | |
1076 return NULL; | |
1077 | |
1078 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
1079 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
1080 GaimChat *chat = (GaimChat*)cnode; | |
1081 const char *room, *server; | |
1082 if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
1083 continue; | |
1084 | |
1085 if(chat->account != account) | |
8011 | 1086 continue; |
7999 | 1087 |
1088 if(!(room = g_hash_table_lookup(chat->components, "room"))) | |
1089 continue; | |
1090 if(!(server = g_hash_table_lookup(chat->components, "server"))) | |
1091 continue; | |
1092 | |
8158 | 1093 if(jid->node && jid->domain && |
1094 !g_utf8_collate(room, jid->node) && !g_utf8_collate(server, jid->domain)) { | |
7999 | 1095 jabber_id_free(jid); |
1096 return chat; | |
1097 } | |
1098 } | |
1099 } | |
1100 jabber_id_free(jid); | |
1101 return NULL; | |
1102 } | |
1103 | |
8400 | 1104 static void jabber_convo_closed(GaimConnection *gc, const char *who) |
1105 { | |
1106 JabberStream *js = gc->proto_data; | |
1107 JabberID *jid; | |
1108 JabberBuddy *jb; | |
1109 JabberBuddyResource *jbr; | |
1110 | |
1111 if(!(jid = jabber_id_new(who))) | |
1112 return; | |
1113 | |
1114 if((jb = jabber_buddy_find(js, who, TRUE)) && | |
1115 (jbr = jabber_buddy_find_resource(jb, jid->resource))) { | |
1116 if(jbr->thread_id) { | |
1117 g_free(jbr->thread_id); | |
1118 jbr->thread_id = NULL; | |
1119 } | |
1120 } | |
1121 | |
1122 jabber_id_free(jid); | |
1123 } | |
1124 | |
8401 | 1125 |
1126 char *jabber_parse_error(JabberStream *js, xmlnode *packet) | |
1127 { | |
1128 xmlnode *error; | |
1129 const char *code = NULL, *text = NULL; | |
1130 const char *xmlns = xmlnode_get_attrib(packet, "xmlns"); | |
1131 char *cdata = NULL; | |
1132 | |
1133 if((error = xmlnode_get_child(packet, "error"))) { | |
1134 cdata = xmlnode_get_data(error); | |
1135 code = xmlnode_get_attrib(error, "code"); | |
1136 | |
1137 /* Stanza errors */ | |
1138 if(xmlnode_get_child(error, "bad-request")) { | |
1139 text = _("Bad Request"); | |
1140 } else if(xmlnode_get_child(error, "conflict")) { | |
1141 text = _("Conflict"); | |
1142 } else if(xmlnode_get_child(error, "feature-not-implemented")) { | |
1143 text = _("Feature Not Implemented"); | |
1144 } else if(xmlnode_get_child(error, "forbidden")) { | |
1145 text = _("Forbidden"); | |
1146 } else if(xmlnode_get_child(error, "gone")) { | |
1147 text = _("Gone"); | |
1148 } else if(xmlnode_get_child(error, "internal-server-error")) { | |
1149 text = _("Internal Server Error"); | |
1150 } else if(xmlnode_get_child(error, "item-not-found")) { | |
1151 text = _("Item Not Found"); | |
1152 } else if(xmlnode_get_child(error, "jid-malformed")) { | |
1153 text = _("Malformed Jabber ID"); | |
1154 } else if(xmlnode_get_child(error, "not-acceptable")) { | |
1155 text = _("Not Acceptable"); | |
1156 } else if(xmlnode_get_child(error, "not-allowed")) { | |
1157 text = _("Not Allowed"); | |
1158 } else if(xmlnode_get_child(error, "not-authorized")) { | |
1159 text = _("Not Authorized"); | |
1160 } else if(xmlnode_get_child(error, "payment-required")) { | |
1161 text = _("Payment Required"); | |
1162 } else if(xmlnode_get_child(error, "recipient-unavailable")) { | |
1163 text = _("Recipient Unavailable"); | |
1164 } else if(xmlnode_get_child(error, "redirect")) { | |
1165 /* XXX */ | |
1166 } else if(xmlnode_get_child(error, "registration-required")) { | |
1167 text = _("Registration Required"); | |
1168 } else if(xmlnode_get_child(error, "remote-server-not-found")) { | |
1169 text = _("Remote Server Not Found"); | |
1170 } else if(xmlnode_get_child(error, "remote-server-timeout")) { | |
1171 text = _("Remote Server Timeout"); | |
1172 } else if(xmlnode_get_child(error, "resource-constraint")) { | |
1173 text = _("Server Overloaded"); | |
1174 } else if(xmlnode_get_child(error, "service-unavailable")) { | |
1175 text = _("Service Unavailable"); | |
1176 } else if(xmlnode_get_child(error, "subscription-required")) { | |
1177 text = _("Subscription Required"); | |
1178 } else if(xmlnode_get_child(error, "unexpected-request")) { | |
1179 text = _("Unexpected Request"); | |
1180 } else if(xmlnode_get_child(error, "undefined-condition")) { | |
1181 text = _("Unknown Error"); | |
1182 } | |
1183 } else if(xmlns && !strcmp(xmlns, "urn:ietf:params:xml:ns:xmpp-sasl")) { | |
1184 if(xmlnode_get_child(packet, "aborted")) { | |
1185 js->gc->wants_to_die = TRUE; | |
1186 text = _("Authorization Aborted"); | |
1187 } else if(xmlnode_get_child(error, "incorrect-encoding")) { | |
1188 text = _("Incorrect encoding in authorization"); | |
1189 } else if(xmlnode_get_child(error, "invalid-authzid")) { | |
1190 js->gc->wants_to_die = TRUE; | |
1191 text = _("Invalid authzid"); | |
1192 } else if(xmlnode_get_child(error, "invalid-mechanism")) { | |
1193 js->gc->wants_to_die = TRUE; | |
1194 text = _("Invalid Authorization Mechanism"); | |
1195 } else if(xmlnode_get_child(error, "mechanism-too-weak")) { | |
1196 js->gc->wants_to_die = TRUE; | |
1197 text = _("Authorization mechanism too weak"); | |
1198 } else if(xmlnode_get_child(error, "not-authorized")) { | |
1199 js->gc->wants_to_die = TRUE; | |
1200 text = _("Not Authorized"); | |
1201 } else if(xmlnode_get_child(error, "temporary-auth-failure")) { | |
1202 text = _("Temporary Authentication Failure"); | |
1203 } else { | |
1204 text = _("Authentication Failure"); | |
1205 } | |
8402 | 1206 } else if(!strcmp(packet->name, "stream:error")) { |
1207 if(xmlnode_get_child(packet, "bad-format")) { | |
1208 text = _("Bad Format"); | |
1209 } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) { | |
1210 text = _("Bad Namespace Prefix"); | |
1211 } else if(xmlnode_get_child(packet, "conflict")) { | |
1212 js->gc->wants_to_die = TRUE; | |
1213 text = _("Resource Conflict"); | |
1214 } else if(xmlnode_get_child(packet, "connection-timeout")) { | |
1215 text = _("Connection Timeout"); | |
1216 } else if(xmlnode_get_child(packet, "host-gone")) { | |
1217 text = _("Host Gone"); | |
1218 } else if(xmlnode_get_child(packet, "host-unknown")) { | |
1219 text = _("Host Unknown"); | |
1220 } else if(xmlnode_get_child(packet, "improper-addressing")) { | |
1221 text = _("Improper Addressing"); | |
1222 } else if(xmlnode_get_child(packet, "internal-server-error")) { | |
1223 text = _("Internal Server Error"); | |
1224 } else if(xmlnode_get_child(packet, "invalid-id")) { | |
1225 text = _("Invalid ID"); | |
1226 } else if(xmlnode_get_child(packet, "invalid-namespace")) { | |
1227 text = _("Invalid Namespace"); | |
1228 } else if(xmlnode_get_child(packet, "invalid-xml")) { | |
1229 text = _("Invalid XML"); | |
1230 } else if(xmlnode_get_child(packet, "nonmatching-hosts")) { | |
1231 text = _("Non-matching Hosts"); | |
1232 } else if(xmlnode_get_child(packet, "not-authorized")) { | |
1233 text = _("Not Authorized"); | |
1234 } else if(xmlnode_get_child(packet, "policy-violation")) { | |
1235 text = _("Policy Violation"); | |
1236 } else if(xmlnode_get_child(packet, "remote-connection-failed")) { | |
1237 text = _("Remote Connection Failed"); | |
1238 } else if(xmlnode_get_child(packet, "resource-constraint")) { | |
1239 text = _("Resource Constraint"); | |
1240 } else if(xmlnode_get_child(packet, "restricted-xml")) { | |
1241 text = _("Restricted XML"); | |
1242 } else if(xmlnode_get_child(packet, "see-other-host")) { | |
1243 text = _("See Other Host"); | |
1244 } else if(xmlnode_get_child(packet, "system-shutdown")) { | |
1245 text = _("System Shutdown"); | |
1246 } else if(xmlnode_get_child(packet, "undefined-condition")) { | |
1247 text = _("Undefined Condition"); | |
1248 } else if(xmlnode_get_child(packet, "unsupported-encoding")) { | |
1249 text = _("Unsupported Encoding"); | |
1250 } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) { | |
1251 text = _("Unsupported Stanza Type"); | |
1252 } else if(xmlnode_get_child(packet, "unsupported-version")) { | |
1253 text = _("Unsupported Version"); | |
1254 } else if(xmlnode_get_child(packet, "xml-not-well-formed")) { | |
1255 text = _("XML Not Well Formed"); | |
1256 } else { | |
1257 text = _("Stream Error"); | |
1258 } | |
8401 | 1259 } |
1260 | |
1261 if(text || cdata) { | |
1262 char *ret = g_strdup_printf("%s%s%s", code ? code : "", | |
1263 code ? ": " : "", text ? text : cdata); | |
1264 g_free(cdata); | |
1265 return ret; | |
1266 } else { | |
1267 return NULL; | |
1268 } | |
1269 } | |
1270 | |
9130 | 1271 static GaimCmdRet jabber_cmd_chat_config(GaimConversation *conv, |
9597 | 1272 const char *cmd, char **args, char **error, void *data) |
9130 | 1273 { |
1274 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1275 jabber_chat_request_room_configure(chat); | |
1276 return GAIM_CMD_RET_OK; | |
1277 } | |
1278 | |
1279 static GaimCmdRet jabber_cmd_chat_register(GaimConversation *conv, | |
9597 | 1280 const char *cmd, char **args, char **error, void *data) |
9130 | 1281 { |
1282 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1283 jabber_chat_register(chat); | |
1284 return GAIM_CMD_RET_OK; | |
1285 } | |
1286 | |
1287 static GaimCmdRet jabber_cmd_chat_topic(GaimConversation *conv, | |
9597 | 1288 const char *cmd, char **args, char **error, void *data) |
9130 | 1289 { |
1290 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1291 jabber_chat_change_topic(chat, args ? args[0] : NULL); | |
1292 return GAIM_CMD_RET_OK; | |
1293 } | |
1294 | |
1295 static GaimCmdRet jabber_cmd_chat_nick(GaimConversation *conv, | |
9597 | 1296 const char *cmd, char **args, char **error, void *data) |
9130 | 1297 { |
1298 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1299 | |
1300 if(!args || !args[0]) | |
1301 return GAIM_CMD_RET_FAILED; | |
1302 | |
1303 jabber_chat_change_nick(chat, args[0]); | |
1304 return GAIM_CMD_RET_OK; | |
1305 } | |
1306 | |
1307 static GaimCmdRet jabber_cmd_chat_part(GaimConversation *conv, | |
9597 | 1308 const char *cmd, char **args, char **error, void *data) |
9130 | 1309 { |
1310 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1311 jabber_chat_part(chat, args ? args[0] : NULL); | |
1312 return GAIM_CMD_RET_OK; | |
1313 } | |
1314 | |
9152 | 1315 static GaimCmdRet jabber_cmd_chat_ban(GaimConversation *conv, |
9597 | 1316 const char *cmd, char **args, char **error, void *data) |
9152 | 1317 { |
1318 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1319 | |
1320 if(!args || !args[0]) | |
1321 return GAIM_CMD_RET_FAILED; | |
1322 | |
1323 if(!jabber_chat_ban_user(chat, args[0], args[1])) { | |
1324 *error = g_strdup_printf(_("Unable to ban user %s"), args[0]); | |
1325 return GAIM_CMD_RET_FAILED; | |
1326 } | |
1327 | |
1328 return GAIM_CMD_RET_OK; | |
1329 } | |
1330 | |
1331 static GaimCmdRet jabber_cmd_chat_invite(GaimConversation *conv, | |
9597 | 1332 const char *cmd, char **args, char **error, void *data) |
9152 | 1333 { |
1334 if(!args || !args[0]) | |
1335 return GAIM_CMD_RET_FAILED; | |
1336 | |
1337 jabber_chat_invite(gaim_conversation_get_gc(conv), | |
1338 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), args[1] ? args[1] : "", | |
1339 args[0]); | |
1340 | |
1341 return GAIM_CMD_RET_OK; | |
1342 } | |
1343 | |
1344 static GaimCmdRet jabber_cmd_chat_join(GaimConversation *conv, | |
9597 | 1345 const char *cmd, char **args, char **error, void *data) |
9152 | 1346 { |
1347 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1348 GHashTable *components; | |
1349 | |
1350 if(!args || !args[0]) | |
1351 return GAIM_CMD_RET_FAILED; | |
1352 | |
1353 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); | |
1354 | |
1355 g_hash_table_replace(components, "room", args[0]); | |
1356 g_hash_table_replace(components, "server", chat->server); | |
1357 g_hash_table_replace(components, "handle", chat->handle); | |
1358 if(args[1]) | |
1359 g_hash_table_replace(components, "password", args[1]); | |
1360 | |
1361 jabber_chat_join(gaim_conversation_get_gc(conv), components); | |
1362 | |
1363 g_hash_table_destroy(components); | |
1364 return GAIM_CMD_RET_OK; | |
1365 } | |
1366 | |
1367 static GaimCmdRet jabber_cmd_chat_kick(GaimConversation *conv, | |
9597 | 1368 const char *cmd, char **args, char **error, void *data) |
9152 | 1369 { |
1370 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1371 | |
1372 if(!args || !args[0]) | |
1373 return GAIM_CMD_RET_FAILED; | |
1374 | |
1375 if(!jabber_chat_kick_user(chat, args[0], args[1])) { | |
1376 *error = g_strdup_printf(_("Unable to kick user %s"), args[0]); | |
1377 return GAIM_CMD_RET_FAILED; | |
1378 } | |
1379 | |
1380 return GAIM_CMD_RET_OK; | |
1381 } | |
1382 | |
1383 static GaimCmdRet jabber_cmd_chat_msg(GaimConversation *conv, | |
9597 | 1384 const char *cmd, char **args, char **error, void *data) |
9152 | 1385 { |
1386 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1387 char *who; | |
1388 | |
1389 who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]); | |
1390 | |
1391 jabber_message_send_im(gaim_conversation_get_gc(conv), who, args[1], 0); | |
1392 | |
1393 g_free(who); | |
1394 return GAIM_CMD_RET_OK; | |
1395 } | |
1396 | |
9130 | 1397 static void jabber_register_commands(void) |
1398 { | |
1399 gaim_cmd_register("config", "", GAIM_CMD_P_PRPL, | |
9597 | 1400 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1401 "prpl-jabber", jabber_cmd_chat_config, | |
1402 _("config: Configure a chat room."), NULL); | |
9130 | 1403 gaim_cmd_register("configure", "", GAIM_CMD_P_PRPL, |
9597 | 1404 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1405 "prpl-jabber", jabber_cmd_chat_config, | |
1406 _("configure: Configure a chat room."), NULL); | |
9130 | 1407 gaim_cmd_register("nick", "s", GAIM_CMD_P_PRPL, |
9597 | 1408 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1409 "prpl-jabber", jabber_cmd_chat_nick, | |
1410 _("nick <new nickname>: Change your nickname."), | |
1411 NULL); | |
9130 | 1412 gaim_cmd_register("part", "s", GAIM_CMD_P_PRPL, |
9597 | 1413 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1414 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1415 jabber_cmd_chat_part, _("part [room]: Leave the room."), | |
1416 NULL); | |
9130 | 1417 gaim_cmd_register("register", "", GAIM_CMD_P_PRPL, |
9597 | 1418 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1419 "prpl-jabber", jabber_cmd_chat_register, | |
1420 _("register: Register with a chat room."), NULL); | |
9130 | 1421 /* XXX: there needs to be a core /topic cmd, methinks */ |
1422 gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL, | |
9597 | 1423 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1424 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1425 jabber_cmd_chat_topic, | |
1426 _("topic [new topic]: View or change the topic."), | |
1427 NULL); | |
9152 | 1428 gaim_cmd_register("ban", "ws", GAIM_CMD_P_PRPL, |
9597 | 1429 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1430 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1431 jabber_cmd_chat_ban, | |
1432 _("ban <user> [room]: Ban a user from the room."), | |
1433 NULL); | |
9152 | 1434 gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL, |
9597 | 1435 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1436 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1437 jabber_cmd_chat_invite, | |
1438 _("invite <user> [room]: Invite a user to the room."), | |
1439 NULL); | |
9152 | 1440 gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL, |
9597 | 1441 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1442 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1443 jabber_cmd_chat_join, | |
1444 _("join: <room> [server]: Join a chat on this server."), | |
1445 NULL); | |
9152 | 1446 gaim_cmd_register("kick", "ws", GAIM_CMD_P_PRPL, |
9597 | 1447 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1448 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1449 jabber_cmd_chat_kick, | |
1450 _("kick <user> [room]: Kick a user from the room."), | |
1451 NULL); | |
9152 | 1452 gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL, |
9597 | 1453 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1454 "prpl-jabber", jabber_cmd_chat_msg, | |
1455 _("msg <user> <message>: Send a private message to another user."), | |
1456 NULL); | |
9130 | 1457 } |
1458 | |
8713 | 1459 static GaimPluginPrefFrame * |
1460 get_plugin_pref_frame(GaimPlugin *plugin) { | |
1461 GaimPluginPrefFrame *frame; | |
1462 GaimPluginPref *ppref; | |
1463 | |
1464 frame = gaim_plugin_pref_frame_new(); | |
1465 | |
1466 ppref = gaim_plugin_pref_new_with_label(_("Privacy")); | |
1467 gaim_plugin_pref_frame_add(frame, ppref); | |
1468 | |
1469 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/jabber/hide_os", | |
1470 _("Hide Operating System")); | |
1471 gaim_plugin_pref_frame_add(frame, ppref); | |
1472 | |
1473 return frame; | |
1474 } | |
1475 | |
1476 static GaimPluginUiInfo prefs_info = { | |
1477 get_plugin_pref_frame | |
1478 }; | |
1479 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1480 static GaimPluginProtocolInfo prpl_info = |
2086 | 1481 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8713
diff
changeset
|
1482 GAIM_PRPL_API_VERSION, |
7014 | 1483 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME, |
9475 | 1484 NULL, /* user_splits */ |
1485 NULL, /* protocol_options */ | |
1486 NO_BUDDY_ICONS, /* icon_spec */ | |
1487 jabber_list_icon, /* list_icon */ | |
1488 jabber_list_emblems, /* list_emblems */ | |
1489 jabber_status_text, /* status_text */ | |
1490 jabber_tooltip_text, /* tooltip_text */ | |
1491 jabber_away_states, /* away_states */ | |
1492 jabber_blist_node_menu, /* blist_node_menu */ | |
1493 jabber_chat_info, /* chat_info */ | |
9754 | 1494 jabber_chat_info_defaults, /* chat_info_defaults */ |
9475 | 1495 jabber_login, /* login */ |
1496 jabber_close, /* close */ | |
1497 jabber_message_send_im, /* send_im */ | |
1498 jabber_set_info, /* set_info */ | |
1499 jabber_send_typing, /* send_typing */ | |
1500 jabber_buddy_get_info, /* get_info */ | |
1501 jabber_presence_send, /* set_away */ | |
1502 jabber_idle_set, /* set_idle */ | |
1503 NULL, /* change_passwd */ | |
1504 jabber_roster_add_buddy, /* add_buddy */ | |
1505 NULL, /* add_buddies */ | |
1506 jabber_roster_remove_buddy, /* remove_buddy */ | |
1507 NULL, /* remove_buddies */ | |
1508 NULL, /* add_permit */ | |
1509 NULL, /* add_deny */ | |
1510 NULL, /* rem_permit */ | |
1511 NULL, /* rem_deny */ | |
1512 NULL, /* set_permit_deny */ | |
1513 NULL, /* warn */ | |
1514 jabber_chat_join, /* join_chat */ | |
1515 NULL, /* reject_chat */ | |
1516 jabber_chat_invite, /* chat_invite */ | |
1517 jabber_chat_leave, /* chat_leave */ | |
1518 NULL, /* chat_whisper */ | |
1519 jabber_message_send_chat, /* chat_send */ | |
1520 jabber_keepalive, /* keepalive */ | |
1521 jabber_register_account, /* register_user */ | |
1522 jabber_buddy_get_info_chat, /* get_cb_info */ | |
1523 NULL, /* get_cb_away */ | |
1524 jabber_roster_alias_change, /* alias_buddy */ | |
1525 jabber_roster_group_change, /* group_buddy */ | |
1526 jabber_roster_group_rename, /* rename_group */ | |
1527 NULL, /* buddy_free */ | |
1528 jabber_convo_closed, /* convo_closed */ | |
1529 jabber_normalize, /* normalize */ | |
1530 NULL, /* set_buddy_icon */ | |
1531 NULL, /* remove_group */ | |
1532 jabber_chat_buddy_real_name, /* get_cb_real_name */ | |
1533 jabber_chat_set_topic, /* set_chat_topic */ | |
1534 jabber_find_blist_chat, /* find_blist_chat */ | |
1535 jabber_roomlist_get_list, /* roomlist_get_list */ | |
1536 jabber_roomlist_cancel, /* roomlist_cancel */ | |
1537 NULL, /* roomlist_expand_category */ | |
1538 NULL, /* can_receive_file */ | |
1539 jabber_si_xfer_send /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1540 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1541 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1542 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1543 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8713
diff
changeset
|
1544 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1545 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1546 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1547 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1548 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1549 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1550 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1551 "prpl-jabber", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1552 "Jabber", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1553 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1554 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1555 N_("Jabber Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1556 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1557 N_("Jabber Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1558 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
1559 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1560 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1561 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1562 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1563 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1564 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1565 NULL, /**< ui_info */ |
8993 | 1566 &prpl_info, /**< extra_info */ |
1567 &prefs_info, /**< prefs_info */ | |
9015 | 1568 jabber_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1569 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1570 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1571 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1572 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1573 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1574 GaimAccountUserSplit *split; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1575 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1576 |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1577 split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1578 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
|
1579 |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1580 split = gaim_account_user_split_new(_("Resource"), "Gaim", '/'); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1581 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
|
1582 |
7630 | 1583 option = gaim_account_option_bool_new(_("Use TLS if available"), "use_tls", |
1584 TRUE); | |
1585 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1586 option); | |
1587 | |
1588 option = gaim_account_option_bool_new(_("Force old SSL"), "old_ssl", FALSE); | |
7124 | 1589 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
1590 option); | |
6764 | 1591 |
8086 | 1592 option = gaim_account_option_bool_new( |
1593 _("Allow plaintext auth over unencrypted streams"), | |
1594 "auth_plain_in_clear", FALSE); | |
1595 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1596 option); | |
1597 | |
7014 | 1598 option = gaim_account_option_int_new(_("Port"), "port", 5222); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1599 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
7014 | 1600 option); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1601 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1602 option = gaim_account_option_string_new(_("Connect server"), |
7014 | 1603 "connect_server", NULL); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1604 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
7014 | 1605 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1606 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1607 my_protocol = plugin; |
7014 | 1608 |
1609 gaim_prefs_add_none("/plugins/prpl/jabber"); | |
1610 gaim_prefs_add_bool("/plugins/prpl/jabber/hide_os", FALSE); | |
9130 | 1611 |
1612 jabber_register_commands(); | |
2086 | 1613 } |
1614 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1615 GAIM_INIT_PLUGIN(jabber, init_plugin, info); |