Mercurial > pidgin
annotate src/protocols/jabber/jabber.c @ 7183:071dee25c48e
[gaim-migrate @ 7751]
fix jabber segfault on changing of topic in a chat
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 07 Oct 2003 14:20:48 +0000 |
parents | 4200828dc06c |
children | 1930e3d00ecd |
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 /* |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
24 #include "conversation.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
25 #include "ft.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
26 #include "multi.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
27 #include "notify.h" |
7014 | 28 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
29 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
30 #include "util.h" |
7014 | 31 |
32 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
33 |
7014 | 34 #include "account.h" |
35 #include "accountopt.h" | |
36 #include "debug.h" | |
37 #include "message.h" | |
38 #include "multi.h" | |
7072 | 39 #include "notify.h" |
7014 | 40 #include "prpl.h" |
7072 | 41 #include "request.h" |
7014 | 42 #include "server.h" |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
43 #include "util.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
44 |
7014 | 45 #include "auth.h" |
46 #include "buddy.h" | |
47 #include "chat.h" | |
48 #include "iq.h" | |
49 #include "jutil.h" | |
50 #include "message.h" | |
51 #include "parser.h" | |
52 #include "presence.h" | |
53 #include "jabber.h" | |
54 #include "roster.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
55 |
7014 | 56 #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5) |
2086 | 57 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
58 static GaimPlugin *my_protocol = NULL; |
4249 | 59 |
7014 | 60 static void jabber_stream_init(JabberStream *js) |
61 { | |
62 char *open_stream; | |
3340 | 63 |
7014 | 64 open_stream = g_strdup_printf("<stream:stream to='%s' " |
65 "xmlns='jabber:client' " | |
66 "xmlns:stream='http://etherx.jabber.org/streams' " | |
67 "version='1.0'>", js->user->domain); | |
3311 | 68 |
7014 | 69 jabber_send_raw(js, open_stream); |
2086 | 70 |
7014 | 71 g_free(open_stream); |
2086 | 72 } |
73 | |
7014 | 74 static void jabber_session_initialized_cb(JabberStream *js, xmlnode *packet) |
3311 | 75 { |
7014 | 76 const char *type = xmlnode_get_attrib(packet, "type"); |
77 if(type && !strcmp(type, "result")) { | |
78 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
79 } else { | |
80 gaim_connection_error(js->gc, _("Error initializing session")); | |
3311 | 81 } |
82 } | |
83 | |
7014 | 84 static void jabber_session_init(JabberStream *js) |
3311 | 85 { |
7014 | 86 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); |
87 xmlnode *session; | |
3311 | 88 |
7014 | 89 jabber_iq_set_callback(iq, jabber_session_initialized_cb); |
3311 | 90 |
7014 | 91 session = xmlnode_new_child(iq->node, "session"); |
92 xmlnode_set_attrib(session, "xmlns", "urn:ietf:params:xml:ns:xmpp-session"); | |
3311 | 93 |
7014 | 94 jabber_iq_send(iq); |
3311 | 95 } |
96 | |
7014 | 97 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet) |
3311 | 98 { |
7014 | 99 xmlnode *textnode; |
100 char *error_text = NULL; | |
101 const char *text; | |
102 char *buf; | |
3311 | 103 |
7014 | 104 if(xmlnode_get_child(packet, "bad-format")) { |
105 text = _("Bad Format"); | |
106 } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) { | |
107 text = _("Bad Namespace Prefix"); | |
108 } else if(xmlnode_get_child(packet, "conflict")) { | |
109 js->gc->wants_to_die = TRUE; | |
110 text = _("Resource Conflict"); | |
111 } else if(xmlnode_get_child(packet, "connection-timeout")) { | |
112 text = _("Connection Timeout"); | |
113 } else if(xmlnode_get_child(packet, "host-gone")) { | |
114 text = _("Host Gone"); | |
115 } else if(xmlnode_get_child(packet, "host-unknown")) { | |
116 text = _("Host Unknown"); | |
117 } else if(xmlnode_get_child(packet, "improper-addressing")) { | |
118 text = _("Improper Addressing"); | |
119 } else if(xmlnode_get_child(packet, "internal-server-error")) { | |
120 text = _("Internal Server Error"); | |
121 } else if(xmlnode_get_child(packet, "invalid-id")) { | |
122 text = _("Invalid ID"); | |
123 } else if(xmlnode_get_child(packet, "invalid-namespace")) { | |
124 text = _("Invalid Namespace"); | |
125 } else if(xmlnode_get_child(packet, "invalid-xml")) { | |
126 text = _("Invalid XML"); | |
127 } else if(xmlnode_get_child(packet, "nonmatching-hosts")) { | |
128 text = _("Non-matching Hosts"); | |
129 } else if(xmlnode_get_child(packet, "not-authorized")) { | |
130 text = _("Not Authorized"); | |
131 } else if(xmlnode_get_child(packet, "policy-violation")) { | |
132 text = _("Policy Violation"); | |
133 } else if(xmlnode_get_child(packet, "remote-connection-failed")) { | |
134 text = _("Remote Connection Failed"); | |
135 } else if(xmlnode_get_child(packet, "resource-constraint")) { | |
136 text = _("Resource Constraint"); | |
137 } else if(xmlnode_get_child(packet, "restricted-xml")) { | |
138 text = _("Restricted XML"); | |
139 } else if(xmlnode_get_child(packet, "see-other-host")) { | |
140 text = _("See Other Host"); | |
141 } else if(xmlnode_get_child(packet, "system-shutdown")) { | |
142 text = _("System Shutdown"); | |
143 } else if(xmlnode_get_child(packet, "undefined-condition")) { | |
144 text = _("Undefined Condition"); | |
145 } else if(xmlnode_get_child(packet, "unsupported-encoding")) { | |
146 text = _("Unsupported Condition"); | |
147 } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) { | |
148 text = _("Unsupported Stanza Type"); | |
149 } else if(xmlnode_get_child(packet, "unsupported-version")) { | |
150 text = _("Unsupported Version"); | |
151 } else if(xmlnode_get_child(packet, "xml-not-well-formed")) { | |
152 text = _("XML Not Well Formed"); | |
3311 | 153 } else { |
7014 | 154 text = _("Stream Error"); |
3311 | 155 } |
156 | |
7014 | 157 if((textnode = xmlnode_get_child(packet, "text"))) |
158 error_text = xmlnode_get_data(textnode); | |
2086 | 159 |
7014 | 160 buf = g_strdup_printf("%s%s%s", text, |
161 error_text ? ": " : "", | |
162 error_text ? error_text : ""); | |
163 gaim_connection_error(js->gc, buf); | |
164 g_free(buf); | |
165 if(error_text) | |
166 g_free(error_text); | |
2086 | 167 } |
168 | |
7014 | 169 static void tls_init(JabberStream *js); |
2086 | 170 |
7014 | 171 void jabber_process_packet(JabberStream *js, xmlnode *packet) |
2086 | 172 { |
7014 | 173 const char *id = xmlnode_get_attrib(packet, "id"); |
174 const char *type = xmlnode_get_attrib(packet, "type"); | |
175 JabberCallback *callback; | |
2086 | 176 |
7014 | 177 if(!strcmp(packet->name, "iq")) { |
178 if(type && (!strcmp(type, "result") || !strcmp(type, "error")) && id | |
179 && *id && (callback = g_hash_table_lookup(js->callbacks, id))) | |
180 callback(js, packet); | |
181 else | |
182 jabber_iq_parse(js, packet); | |
183 } else if(!strcmp(packet->name, "presence")) { | |
184 jabber_presence_parse(js, packet); | |
185 } else if(!strcmp(packet->name, "message")) { | |
186 jabber_message_parse(js, packet); | |
187 } else if(!strcmp(packet->name, "stream:features")) { | |
7124 | 188 if(!js->registration && js->state == JABBER_STREAM_AUTHENTICATING) { |
7014 | 189 jabber_auth_start(js, packet); |
190 } else if(js->state == JABBER_STREAM_REINITIALIZING) { | |
191 jabber_session_init(js); | |
192 } else { | |
193 gaim_debug(GAIM_DEBUG_WARNING, "jabber", | |
194 "Unexpected stream:features packet, ignoring\n", js->state); | |
6076 | 195 } |
7014 | 196 } else if(!strcmp(packet->name, "stream:error")) { |
197 jabber_stream_handle_error(js, packet); | |
198 } else if(!strcmp(packet->name, "challenge")) { | |
199 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
200 jabber_auth_handle_challenge(js, packet); | |
201 } else if(!strcmp(packet->name, "success")) { | |
202 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
203 jabber_auth_handle_success(js, packet); | |
204 } else if(!strcmp(packet->name, "failure")) { | |
205 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
206 jabber_auth_handle_failure(js, packet); | |
207 } else if(!strcmp(packet->name, "proceed")) { | |
208 if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc) | |
209 tls_init(js); | |
210 } else { | |
211 gaim_debug(GAIM_DEBUG_WARNING, "jabber", "Unknown packet: %s\n", | |
212 packet->name); | |
2086 | 213 } |
214 } | |
215 | |
7014 | 216 void jabber_send_raw(JabberStream *js, const char *data) |
2086 | 217 { |
7014 | 218 int ret; |
2086 | 219 |
7014 | 220 /* because printing a tab to debug every minute gets old */ |
221 if(strcmp(data, "\t")) | |
222 gaim_debug(GAIM_DEBUG_MISC, "jabber", "Sending%s: %s\n", | |
223 js->gsc ? " (ssl)" : "", data); | |
2086 | 224 |
7014 | 225 if(js->gsc) { |
226 ret = gaim_ssl_write(js->gsc, data, strlen(data)); | |
227 } else { | |
228 ret = write(js->fd, data, strlen(data)); | |
2814
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
229 } |
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
230 |
7014 | 231 if(ret < 0) |
232 gaim_connection_error(js->gc, _("Write error")); | |
233 | |
2814
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
234 } |
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
235 |
7014 | 236 void jabber_send(JabberStream *js, xmlnode *packet) |
2086 | 237 { |
7014 | 238 char *txt; |
2086 | 239 |
7014 | 240 txt = xmlnode_to_str(packet); |
241 jabber_send_raw(js, txt); | |
242 g_free(txt); | |
2086 | 243 } |
244 | |
7014 | 245 static void jabber_keepalive(GaimConnection *gc) |
2086 | 246 { |
7014 | 247 jabber_send_raw(gc->proto_data, "\t"); |
2086 | 248 } |
249 | |
7014 | 250 static void |
251 jabber_recv_cb_ssl(gpointer data, GaimSslConnection *gsc, | |
6764 | 252 GaimInputCondition cond) |
253 { | |
7014 | 254 GaimConnection *gc = data; |
255 JabberStream *js = gc->proto_data; | |
6764 | 256 int len; |
7014 | 257 static char buf[4096]; |
6768 | 258 |
7014 | 259 if(!g_list_find(gaim_connections_get_all(), gc)) { |
6768 | 260 gaim_ssl_close(gsc); |
261 return; | |
262 } | |
263 | |
7014 | 264 if((len = gaim_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) { |
6764 | 265 buf[len] = '\0'; |
7014 | 266 gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf); |
267 jabber_parser_process(js, buf, len); | |
7177 | 268 } else { |
269 gaim_connection_error(gc, _("Read Error")); | |
2086 | 270 } |
271 } | |
272 | |
7014 | 273 static void |
274 jabber_recv_cb(gpointer data, gint source, GaimInputCondition condition) | |
2086 | 275 { |
5572 | 276 GaimConnection *gc = data; |
7014 | 277 JabberStream *js = gc->proto_data; |
278 int len; | |
279 static char buf[4096]; | |
2086 | 280 |
7014 | 281 if(!g_list_find(gaim_connections_get_all(), gc)) |
282 return; | |
2956 | 283 |
7014 | 284 if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) { |
285 buf[len] = '\0'; | |
286 gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf); | |
287 jabber_parser_process(js, buf, len); | |
7177 | 288 } else { |
289 gaim_connection_error(gc, _("Read Error")); | |
7014 | 290 } |
2086 | 291 } |
292 | |
7014 | 293 static void |
294 jabber_login_callback_ssl(gpointer data, GaimSslConnection *gsc, | |
6764 | 295 GaimInputCondition cond) |
296 { | |
297 GaimConnection *gc = data; | |
7014 | 298 JabberStream *js = gc->proto_data; |
6764 | 299 |
7014 | 300 if(!g_list_find(gaim_connections_get_all(), gc)) { |
6764 | 301 gaim_ssl_close(gsc); |
302 return; | |
303 } | |
304 | |
7014 | 305 js->gsc = gsc; |
6764 | 306 |
7014 | 307 if(js->state == JABBER_STREAM_CONNECTING) |
308 jabber_send_raw(js, "<?xml version='1.0' ?>"); | |
6764 | 309 |
7014 | 310 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
311 gaim_ssl_input_add(gsc, jabber_recv_cb_ssl, gc); | |
6764 | 312 } |
313 | |
7014 | 314 |
315 static void | |
316 jabber_login_callback(gpointer data, gint source, GaimInputCondition cond) | |
6764 | 317 { |
5572 | 318 GaimConnection *gc = data; |
7014 | 319 JabberStream *js = gc->proto_data; |
2086 | 320 |
7014 | 321 if(!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 322 close(source); |
323 return; | |
324 } | |
325 | |
7014 | 326 js->fd = source; |
2956 | 327 |
7014 | 328 if(js->state == JABBER_STREAM_CONNECTING) |
329 jabber_send_raw(js, "<?xml version='1.0' ?>"); | |
2300
d2686f757d6e
[gaim-migrate @ 2310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
330 |
7014 | 331 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
332 gc->inpa = gaim_input_add(js->fd, GAIM_INPUT_READ, jabber_recv_cb, gc); | |
333 } | |
2086 | 334 |
7014 | 335 static void tls_init(JabberStream *js) |
336 { | |
337 gaim_input_remove(js->gc->inpa); | |
338 js->gc->inpa = 0; | |
339 js->gsc = gaim_ssl_connect_fd(js->gc->account, js->fd, | |
340 jabber_login_callback_ssl, js->gc); | |
2086 | 341 } |
342 | |
7014 | 343 static void |
344 jabber_login(GaimAccount *account) | |
2086 | 345 { |
7014 | 346 int rc; |
347 GaimConnection *gc = gaim_account_get_connection(account); | |
348 const char *connect_server = gaim_account_get_string(account, | |
349 "connect_server", ""); | |
5572 | 350 const char *server; |
7014 | 351 JabberStream *js; |
2086 | 352 |
7014 | 353 gc->flags |= GAIM_CONNECTION_HTML; |
354 js = gc->proto_data = g_new0(JabberStream, 1); | |
355 js->gc = gc; | |
356 js->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
357 g_free, NULL); | |
358 js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, | |
7116 | 359 g_free, (GDestroyNotify)jabber_buddy_free); |
7014 | 360 js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, |
361 g_free, NULL); | |
362 js->user = jabber_id_new(gaim_account_get_username(account)); | |
5613 | 363 |
7147 | 364 if(!js->user->resource) { |
365 char *me; | |
366 js->user->resource = g_strdup("Gaim"); | |
367 if(!js->user->node) { | |
368 js->user->node = js->user->domain; | |
369 js->user->domain = g_strdup("jabber.org"); | |
370 } | |
371 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
372 js->user->resource); | |
373 gaim_account_set_username(account, me); | |
374 g_free(me); | |
7145 | 375 } |
376 | |
7014 | 377 server = connect_server[0] ? connect_server : js->user->domain; |
2086 | 378 |
7014 | 379 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); |
2956 | 380 |
6880 | 381 if(gaim_account_get_bool(account, "old_ssl", FALSE) |
6764 | 382 && gaim_ssl_is_supported()) { |
7014 | 383 js->gsc = gaim_ssl_connect(account, server, |
384 gaim_account_get_int(account, "port", 5222), | |
385 jabber_login_callback_ssl, gc); | |
3311 | 386 } |
3770 | 387 |
7014 | 388 if(!js->gsc) { |
389 rc = gaim_proxy_connect(account, server, | |
390 gaim_account_get_int(account, "port", 5222), | |
391 jabber_login_callback, gc); | |
2086 | 392 |
7014 | 393 if (rc != 0) |
394 gaim_connection_error(gc, _("Unable to create socket")); | |
2956 | 395 } |
2086 | 396 } |
397 | |
7072 | 398 static gboolean |
399 conn_close_cb(gpointer data) | |
400 { | |
401 JabberStream *js = data; | |
402 gaim_connection_destroy(js->gc); | |
403 return FALSE; | |
404 } | |
405 | |
406 static void | |
407 jabber_connection_schedule_close(JabberStream *js) | |
408 { | |
409 g_timeout_add(0, conn_close_cb, js); | |
410 } | |
411 | |
412 static void | |
413 jabber_registration_result_cb(JabberStream *js, xmlnode *packet) | |
414 { | |
415 const char *type = xmlnode_get_attrib(packet, "type"); | |
416 char *buf; | |
417 | |
418 if(!strcmp(type, "result")) { | |
419 buf = g_strdup_printf(_("Registration of %s@%s successful"), | |
420 js->user->node, js->user->domain); | |
421 gaim_notify_info(NULL, _("Registration Successful"), | |
422 _("Registration Successful"), buf); | |
423 g_free(buf); | |
424 } else { | |
425 char *error; | |
426 xmlnode *y; | |
427 | |
428 if((y = xmlnode_get_child(packet, "error"))) { | |
429 error = xmlnode_get_data(y); | |
430 } else { | |
431 error = g_strdup(_("Unknown Error")); | |
432 } | |
433 | |
434 buf = g_strdup_printf(_("Registration of %s@%s failed: %s"), | |
435 js->user->node, js->user->domain, error); | |
436 gaim_notify_error(NULL, _("Registration Failed"), | |
437 _("Registration Failed"), buf); | |
438 g_free(buf); | |
439 g_free(error); | |
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; | |
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); | |
494 } | |
495 } | |
496 | |
497 jabber_iq_set_callback(iq, jabber_registration_result_cb); | |
498 | |
499 jabber_iq_send(iq); | |
500 | |
501 } | |
502 | |
503 static void | |
504 jabber_register_cancel_cb(JabberStream *js, GaimRequestFields *fields) | |
505 { | |
506 jabber_connection_schedule_close(js); | |
507 } | |
508 | |
509 void jabber_register_parse(JabberStream *js, xmlnode *packet) | |
510 { | |
511 if(js->registration) { | |
512 GaimRequestFields *fields; | |
513 GaimRequestFieldGroup *group; | |
514 GaimRequestField *field; | |
515 xmlnode *query, *y; | |
516 char *instructions; | |
517 | |
518 /* get rid of the login thingy */ | |
519 gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
520 | |
521 query = xmlnode_get_child(packet, "query"); | |
522 | |
523 if(xmlnode_get_child(query, "registered")) { | |
524 gaim_notify_error(NULL, _("Already Registered"), | |
525 _("Already Registered"), NULL); | |
526 jabber_connection_schedule_close(js); | |
527 return; | |
528 } | |
529 | |
530 fields = gaim_request_fields_new(); | |
531 group = gaim_request_field_group_new(NULL); | |
532 gaim_request_fields_add_group(fields, group); | |
533 | |
534 field = gaim_request_field_string_new("username", _("Username"), | |
535 js->user->node, FALSE); | |
536 gaim_request_field_group_add_field(group, field); | |
537 | |
538 field = gaim_request_field_string_new("password", _("Password"), | |
539 gaim_account_get_password(js->gc->account), FALSE); | |
540 gaim_request_field_string_set_masked(field, TRUE); | |
541 gaim_request_field_group_add_field(group, field); | |
542 | |
543 if(xmlnode_get_child(query, "name")) { | |
544 field = gaim_request_field_string_new("name", _("Name"), | |
545 gaim_account_get_alias(js->gc->account), FALSE); | |
546 gaim_request_field_group_add_field(group, field); | |
547 } | |
548 if(xmlnode_get_child(query, "email")) { | |
549 field = gaim_request_field_string_new("email", _("E-Mail"), | |
550 NULL, FALSE); | |
551 gaim_request_field_group_add_field(group, field); | |
552 } | |
553 if(xmlnode_get_child(query, "nick")) { | |
554 field = gaim_request_field_string_new("nick", _("Nickname"), | |
555 NULL, FALSE); | |
556 gaim_request_field_group_add_field(group, field); | |
557 } | |
558 if(xmlnode_get_child(query, "first")) { | |
559 field = gaim_request_field_string_new("first", _("First Name"), | |
560 NULL, FALSE); | |
561 gaim_request_field_group_add_field(group, field); | |
562 } | |
563 if(xmlnode_get_child(query, "last")) { | |
564 field = gaim_request_field_string_new("last", _("Last Name"), | |
565 NULL, FALSE); | |
566 gaim_request_field_group_add_field(group, field); | |
567 } | |
568 if(xmlnode_get_child(query, "address")) { | |
569 field = gaim_request_field_string_new("address", _("Address"), | |
570 NULL, FALSE); | |
571 gaim_request_field_group_add_field(group, field); | |
572 } | |
573 if(xmlnode_get_child(query, "city")) { | |
574 field = gaim_request_field_string_new("city", _("City"), | |
575 NULL, FALSE); | |
576 gaim_request_field_group_add_field(group, field); | |
577 } | |
578 if(xmlnode_get_child(query, "state")) { | |
579 field = gaim_request_field_string_new("state", _("State"), | |
580 NULL, FALSE); | |
581 gaim_request_field_group_add_field(group, field); | |
582 } | |
583 if(xmlnode_get_child(query, "zip")) { | |
584 field = gaim_request_field_string_new("zip", _("Postal Code"), | |
585 NULL, FALSE); | |
586 gaim_request_field_group_add_field(group, field); | |
587 } | |
588 if(xmlnode_get_child(query, "phone")) { | |
589 field = gaim_request_field_string_new("phone", _("Phone"), | |
590 NULL, FALSE); | |
591 gaim_request_field_group_add_field(group, field); | |
592 } | |
593 if(xmlnode_get_child(query, "url")) { | |
594 field = gaim_request_field_string_new("url", _("URL"), | |
595 NULL, FALSE); | |
596 gaim_request_field_group_add_field(group, field); | |
597 } | |
598 if(xmlnode_get_child(query, "date")) { | |
599 field = gaim_request_field_string_new("date", _("Date"), | |
600 NULL, FALSE); | |
601 gaim_request_field_group_add_field(group, field); | |
602 } | |
603 | |
604 if((y = xmlnode_get_child(query, "instructions"))) | |
605 instructions = xmlnode_get_data(y); | |
606 else | |
607 instructions = g_strdup(_("Please fill out the information below " | |
608 "to register your new account.")); | |
609 | |
610 gaim_request_fields(js->gc, _("Register New Jabber Account"), | |
611 _("Register New Jabber Account"), instructions, fields, | |
612 _("Register"), G_CALLBACK(jabber_register_cb), | |
613 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); | |
614 } | |
615 } | |
616 | |
617 static void jabber_register_start(JabberStream *js) | |
618 { | |
619 JabberIq *iq; | |
620 | |
621 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); | |
622 jabber_iq_send(iq); | |
623 } | |
624 | |
625 static void jabber_register_account(GaimAccount *account) | |
626 { | |
627 GaimConnection *gc = gaim_account_get_connection(account); | |
628 JabberStream *js; | |
629 const char *connect_server = gaim_account_get_string(account, | |
630 "connect_server", ""); | |
631 const char *server; | |
632 int rc; | |
633 | |
634 js = gc->proto_data = g_new0(JabberStream, 1); | |
635 js->gc = gc; | |
636 js->registration = TRUE; | |
637 js->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
638 g_free, NULL); | |
639 js->user = jabber_id_new(gaim_account_get_username(account)); | |
640 | |
7147 | 641 if(!js->user->resource) { |
642 char *me; | |
643 js->user->resource = g_strdup("Gaim"); | |
644 if(!js->user->node) { | |
645 js->user->node = js->user->domain; | |
646 js->user->domain = g_strdup("jabber.org"); | |
647 } | |
648 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
649 js->user->resource); | |
650 gaim_account_set_username(account, me); | |
651 g_free(me); | |
652 } | |
653 | |
7072 | 654 server = connect_server[0] ? connect_server : js->user->domain; |
655 | |
656 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); | |
657 | |
658 if(gaim_account_get_bool(account, "old_ssl", FALSE) | |
659 && gaim_ssl_is_supported()) { | |
660 js->gsc = gaim_ssl_connect(account, server, | |
661 gaim_account_get_int(account, "port", 5222), | |
662 jabber_login_callback_ssl, gc); | |
663 } | |
664 | |
665 if(!js->gsc) { | |
666 rc = gaim_proxy_connect(account, server, | |
667 gaim_account_get_int(account, "port", 5222), | |
668 jabber_login_callback, gc); | |
669 | |
670 if (rc != 0) | |
671 gaim_connection_error(gc, _("Unable to create socket")); | |
672 } | |
673 } | |
674 | |
5572 | 675 static void jabber_close(GaimConnection *gc) |
2086 | 676 { |
7014 | 677 JabberStream *js = gc->proto_data; |
2956 | 678 |
7014 | 679 jabber_send_raw(js, "</stream:stream>"); |
3311 | 680 |
7014 | 681 if(js->gsc) { |
682 gaim_ssl_close(js->gsc); | |
683 } else { | |
7072 | 684 if(js->gc->inpa) |
685 gaim_input_remove(js->gc->inpa); | |
7014 | 686 close(js->fd); |
687 } | |
3311 | 688 |
7014 | 689 g_markup_parse_context_free(js->context); |
5093 | 690 |
7072 | 691 if(js->callbacks) |
692 g_hash_table_destroy(js->callbacks); | |
693 if(js->buddies) | |
694 g_hash_table_destroy(js->buddies); | |
695 if(js->chats) | |
696 g_hash_table_destroy(js->chats); | |
7014 | 697 if(js->stream_id) |
698 g_free(js->stream_id); | |
699 jabber_id_free(js->user); | |
700 g_free(js); | |
5093 | 701 } |
702 | |
7014 | 703 void jabber_stream_set_state(JabberStream *js, JabberStreamState state) |
3105 | 704 { |
7014 | 705 js->state = state; |
706 switch(state) { | |
707 case JABBER_STREAM_OFFLINE: | |
708 break; | |
709 case JABBER_STREAM_CONNECTING: | |
710 gaim_connection_update_progress(js->gc, _("Connecting"), 1, | |
711 JABBER_CONNECT_STEPS); | |
712 break; | |
713 case JABBER_STREAM_INITIALIZING: | |
714 gaim_connection_update_progress(js->gc, _("Initializing Stream"), | |
715 js->gsc ? 5 : 2, JABBER_CONNECT_STEPS); | |
716 jabber_stream_init(js); | |
717 jabber_parser_setup(js); | |
718 break; | |
719 case JABBER_STREAM_AUTHENTICATING: | |
720 gaim_connection_update_progress(js->gc, _("Authenticating"), | |
721 js->gsc ? 6 : 3, JABBER_CONNECT_STEPS); | |
7072 | 722 if(js->registration) |
723 jabber_register_start(js); | |
724 else if(js->protocol_version == JABBER_PROTO_0_9) | |
7014 | 725 jabber_auth_start_old(js); |
726 break; | |
727 case JABBER_STREAM_REINITIALIZING: | |
728 gaim_connection_update_progress(js->gc, _("Re-initializing Stream"), | |
729 6, JABBER_CONNECT_STEPS); | |
730 jabber_stream_init(js); | |
731 break; | |
732 case JABBER_STREAM_CONNECTED: | |
733 gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
734 jabber_roster_request(js); | |
735 jabber_presence_send(js->gc, js->gc->away_state, js->gc->away); | |
736 serv_finish_login(js->gc); | |
737 break; | |
3105 | 738 } |
739 } | |
740 | |
7014 | 741 char *jabber_get_next_id(JabberStream *js) |
2086 | 742 { |
7014 | 743 return g_strdup_printf("gaim%d", js->next_id++); |
2086 | 744 } |
745 | |
7014 | 746 void jabber_idle_set(GaimConnection *gc, int idle) |
3340 | 747 { |
7014 | 748 JabberStream *js = gc->proto_data; |
3340 | 749 |
7014 | 750 js->idle = idle ? time(NULL) - idle : idle; |
3314 | 751 } |
752 | |
6695 | 753 static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) |
2086 | 754 { |
4687 | 755 return "jabber"; |
756 } | |
4916 | 757 |
7014 | 758 static void jabber_list_emblems(GaimBuddy *b, char **se, char **sw, |
759 char **nw, char **ne) | |
4916 | 760 { |
7014 | 761 JabberStream *js; |
762 JabberBuddy *jb; | |
763 | |
764 if(!b->account->gc) | |
765 return; | |
766 js = b->account->gc->proto_data; | |
767 jb = jabber_buddy_find(js, b->name, FALSE); | |
5135 | 768 |
769 if(!GAIM_BUDDY_IS_ONLINE(b)) { | |
7014 | 770 if(jb && jb->error_msg) |
4927 | 771 *nw = "error"; |
5135 | 772 |
7014 | 773 if(jb && (jb->subscription & JABBER_SUB_PENDING || |
774 !(jb->subscription & JABBER_SUB_TO))) | |
5135 | 775 *se = "notauthorized"; |
776 else | |
777 *se = "offline"; | |
4916 | 778 } else { |
779 switch (b->uc) { | |
7014 | 780 case JABBER_STATE_AWAY: |
781 *se = "away"; | |
782 break; | |
783 case JABBER_STATE_CHAT: | |
784 *se = "chat"; | |
785 break; | |
786 case JABBER_STATE_XA: | |
787 *se = "extendedaway"; | |
788 break; | |
789 case JABBER_STATE_DND: | |
790 *se = "extendedaway"; | |
791 break; | |
792 case JABBER_STATE_ERROR: | |
793 *se = "error"; | |
794 break; | |
4916 | 795 } |
2086 | 796 } |
4916 | 797 } |
2086 | 798 |
7014 | 799 static char *jabber_status_text(GaimBuddy *b) |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
800 { |
7014 | 801 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
802 FALSE); | |
803 char *ret = NULL; | |
5234 | 804 |
7014 | 805 if(jb && !GAIM_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { |
806 ret = g_strdup(_("Not Authorized")); | |
807 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
808 ret = g_strdup(jb->error_msg); | |
2956 | 809 } else { |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
810 char *stripped; |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
811 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
812 stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)); |
2956 | 813 |
7014 | 814 if(!stripped && b->uc & UC_UNAVAILABLE) |
815 stripped = g_strdup(jabber_get_state_string(b->uc)); | |
2086 | 816 |
7014 | 817 if(stripped) { |
818 ret = g_markup_escape_text(stripped, -1); | |
819 g_free(stripped); | |
820 } | |
2086 | 821 } |
822 | |
7014 | 823 return ret; |
2956 | 824 } |
825 | |
6695 | 826 static char *jabber_tooltip_text(GaimBuddy *b) |
4744 | 827 { |
7014 | 828 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
829 FALSE); | |
830 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL); | |
5135 | 831 char *ret = NULL; |
7014 | 832 |
833 if(jbr) { | |
4777 | 834 char *text = NULL; |
7014 | 835 if(jbr->status) { |
836 char *stripped; | |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
837 stripped = gaim_markup_strip_html(jbr->status); |
7014 | 838 text = g_markup_escape_text(stripped, -1); |
839 g_free(stripped); | |
840 } | |
841 | |
5236 | 842 ret = g_strdup_printf("<b>%s:</b> %s%s%s", |
843 _("Status"), | |
7014 | 844 jabber_get_state_string(jbr->state), |
845 text ? ": " : "", | |
4745 | 846 text ? text : ""); |
7014 | 847 if(text) |
4745 | 848 g_free(text); |
7014 | 849 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { |
850 ret = g_strdup_printf("<b>%s:</b> %s", | |
851 _("Error"), jb->error_msg); | |
852 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && | |
853 (jb->subscription & JABBER_SUB_PENDING || | |
854 !(jb->subscription & JABBER_SUB_TO))) { | |
855 ret = g_strdup_printf("<b>%s:</b> %s", | |
856 _("Status"), _("Not Authorized")); | |
4745 | 857 } |
4744 | 858 |
5135 | 859 return ret; |
4732 | 860 } |
861 | |
7014 | 862 static GList *jabber_away_states(GaimConnection *gc) |
863 { | |
2086 | 864 GList *m = NULL; |
865 | |
4982 | 866 m = g_list_append(m, _("Online")); |
867 m = g_list_append(m, _("Chatty")); | |
868 m = g_list_append(m, _("Away")); | |
869 m = g_list_append(m, _("Extended Away")); | |
870 m = g_list_append(m, _("Do Not Disturb")); | |
871 m = g_list_append(m, _("Invisible")); | |
4110 | 872 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
2086 | 873 |
874 return m; | |
875 } | |
876 | |
7124 | 877 static void jabber_password_change_result_cb(JabberStream *js, xmlnode *packet) |
878 { | |
879 const char *type; | |
880 | |
881 type = xmlnode_get_attrib(packet, "type"); | |
882 | |
883 if(!strcmp(type, "result")) { | |
884 gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"), | |
885 _("Your password has been changed.")); | |
886 } else { | |
887 xmlnode *error; | |
888 char *buf, *error_txt = NULL; | |
889 | |
890 | |
891 if((error = xmlnode_get_child(packet, "error"))) | |
892 error_txt = xmlnode_get_data(error); | |
893 | |
894 if(error_txt) { | |
895 buf = g_strdup_printf(_("Error changing password: %s"), | |
896 error_txt); | |
897 g_free(error_txt); | |
898 } else { | |
899 buf = g_strdup(_("Unknown error occurred changing password")); | |
900 } | |
901 | |
902 gaim_notify_error(js->gc, _("Error"), _("Error"), buf); | |
903 g_free(buf); | |
904 } | |
905 } | |
906 | |
907 static void jabber_password_change_cb(JabberStream *js, | |
908 GaimRequestFields *fields) | |
909 { | |
910 const char *p1, *p2; | |
911 JabberIq *iq; | |
912 xmlnode *query, *y; | |
913 | |
914 p1 = gaim_request_fields_get_string(fields, "password1"); | |
915 p2 = gaim_request_fields_get_string(fields, "password2"); | |
916 | |
917 if(strcmp(p1, p2)) { | |
918 gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); | |
919 return; | |
920 } | |
921 | |
922 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
923 | |
924 xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
925 | |
926 query = xmlnode_get_child(iq->node, "query"); | |
927 | |
928 y = xmlnode_new_child(query, "username"); | |
929 xmlnode_insert_data(y, js->user->node, -1); | |
930 y = xmlnode_new_child(query, "password"); | |
931 xmlnode_insert_data(y, p1, -1); | |
932 | |
933 jabber_iq_set_callback(iq, jabber_password_change_result_cb); | |
934 | |
935 jabber_iq_send(iq); | |
936 | |
937 gaim_account_set_password(js->gc->account, p1); | |
938 } | |
939 | |
940 static void jabber_password_change(GaimConnection *gc) | |
941 { | |
942 JabberStream *js = gc->proto_data; | |
943 GaimRequestFields *fields; | |
944 GaimRequestFieldGroup *group; | |
945 GaimRequestField *field; | |
946 | |
947 fields = gaim_request_fields_new(); | |
948 group = gaim_request_field_group_new(NULL); | |
949 gaim_request_fields_add_group(fields, group); | |
950 | |
951 field = gaim_request_field_string_new("password1", _("Password"), | |
952 "", FALSE); | |
953 gaim_request_field_string_set_masked(field, TRUE); | |
954 gaim_request_field_group_add_field(group, field); | |
955 | |
956 field = gaim_request_field_string_new("password2", _("Password (again)"), | |
957 "", FALSE); | |
958 gaim_request_field_string_set_masked(field, TRUE); | |
959 gaim_request_field_group_add_field(group, field); | |
960 | |
961 gaim_request_fields(js->gc, _("Change Jabber Password"), | |
962 _("Change Jabber Password"), _("Please enter your new password"), | |
963 fields, _("OK"), G_CALLBACK(jabber_password_change_cb), | |
964 _("Cancel"), NULL, js); | |
965 } | |
966 | |
5572 | 967 static GList *jabber_actions(GaimConnection *gc) |
2956 | 968 { |
7124 | 969 JabberStream *js = gc->proto_data; |
2956 | 970 GList *m = NULL; |
4333 | 971 struct proto_actions_menu *pam; |
972 | |
973 pam = g_new0(struct proto_actions_menu, 1); | |
974 pam->label = _("Set User Info"); | |
975 pam->callback = jabber_setup_set_info; | |
976 pam->gc = gc; | |
977 m = g_list_append(m, pam); | |
978 | |
7124 | 979 if(js->protocol_version == JABBER_PROTO_0_9) { |
980 pam = g_new0(struct proto_actions_menu, 1); | |
981 pam->label = _("Change Password"); | |
982 pam->callback = jabber_password_change; | |
983 pam->gc = gc; | |
984 m = g_list_append(m, pam); | |
985 } | |
2956 | 986 |
987 return m; | |
988 } | |
989 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
990 static GaimPluginProtocolInfo prpl_info = |
2086 | 991 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
992 GAIM_PROTO_JABBER, |
7014 | 993 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
994 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
995 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
996 jabber_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
997 jabber_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
998 jabber_status_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
999 jabber_tooltip_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1000 jabber_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1001 jabber_actions, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1002 jabber_buddy_menu, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1003 jabber_chat_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1004 jabber_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1005 jabber_close, |
7014 | 1006 jabber_message_send_im, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1007 jabber_set_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1008 jabber_send_typing, |
7014 | 1009 jabber_buddy_get_info, |
1010 jabber_presence_send, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1011 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1012 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1013 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1014 NULL, |
7014 | 1015 jabber_idle_set, |
1016 NULL, /* change_passwd */ /* XXX */ | |
1017 jabber_roster_add_buddy, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1018 NULL, |
7014 | 1019 jabber_roster_remove_buddy, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1020 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1021 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1022 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1023 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1024 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1025 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1026 NULL, |
7014 | 1027 jabber_chat_join, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1028 jabber_chat_invite, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1029 jabber_chat_leave, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1030 jabber_chat_whisper, |
7014 | 1031 jabber_message_send_chat, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1032 jabber_keepalive, |
7072 | 1033 jabber_register_account, |
7014 | 1034 jabber_buddy_get_info_chat, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1035 NULL, |
7014 | 1036 jabber_roster_alias_change, |
1037 jabber_roster_group_change, | |
1038 jabber_roster_group_rename, | |
1039 NULL, | |
1040 NULL, /* convo_closed */ /* XXX: thread_ids */ | |
1041 NULL /* normalize */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1042 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1043 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1044 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1045 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1046 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1047 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1048 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1049 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1050 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1051 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1052 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1053 "prpl-jabber", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1054 "Jabber", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1055 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1056 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1057 N_("Jabber Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1058 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1059 N_("Jabber Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1060 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
1061 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1062 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1063 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1064 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1065 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1066 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1067 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1068 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1069 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1070 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1071 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1072 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1073 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1074 GaimAccountUserSplit *split; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1075 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1076 |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1077 split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1078 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
|
1079 |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1080 split = gaim_account_user_split_new(_("Resource"), "Gaim", '/'); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1081 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
|
1082 |
7124 | 1083 option = gaim_account_option_bool_new(_("Force Old SSL"), "old_ssl", FALSE); |
1084 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1085 option); | |
6764 | 1086 |
7014 | 1087 option = gaim_account_option_int_new(_("Port"), "port", 5222); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1088 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
7014 | 1089 option); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1090 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1091 option = gaim_account_option_string_new(_("Connect server"), |
7014 | 1092 "connect_server", NULL); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1093 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
7014 | 1094 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1095 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1096 my_protocol = plugin; |
7014 | 1097 |
1098 gaim_prefs_add_none("/plugins/prpl/jabber"); | |
1099 gaim_prefs_add_bool("/plugins/prpl/jabber/hide_os", FALSE); | |
2086 | 1100 } |
1101 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1102 GAIM_INIT_PLUGIN(jabber, init_plugin, info); |