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