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