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