Mercurial > pidgin
annotate src/protocols/jabber/jabber.c @ 7274:448e39ace278
[gaim-migrate @ 7851]
Added a parameter to gaim_ssl_connect() to specify an optional error
callback. MSN takes advantage of it, but since I can't reproduce the errors
here, I'm not positive it works. It should though! Famous last words.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 15 Oct 2003 06:32:13 +0000 |
parents | deab8d8bbb4e |
children | 632cee95cc5c |
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, | |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7264
diff
changeset
|
340 jabber_login_callback_ssl, NULL, 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), | |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7264
diff
changeset
|
385 jabber_login_callback_ssl, NULL, 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; | |
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 | |
7072 | 508 jabber_iq_set_callback(iq, jabber_registration_result_cb); |
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 | |
520 void jabber_register_parse(JabberStream *js, xmlnode *packet) | |
521 { | |
522 if(js->registration) { | |
523 GaimRequestFields *fields; | |
524 GaimRequestFieldGroup *group; | |
525 GaimRequestField *field; | |
526 xmlnode *query, *y; | |
527 char *instructions; | |
528 | |
529 /* get rid of the login thingy */ | |
530 gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
531 | |
532 query = xmlnode_get_child(packet, "query"); | |
533 | |
534 if(xmlnode_get_child(query, "registered")) { | |
535 gaim_notify_error(NULL, _("Already Registered"), | |
536 _("Already Registered"), NULL); | |
537 jabber_connection_schedule_close(js); | |
538 return; | |
539 } | |
540 | |
541 fields = gaim_request_fields_new(); | |
542 group = gaim_request_field_group_new(NULL); | |
543 gaim_request_fields_add_group(fields, group); | |
544 | |
545 field = gaim_request_field_string_new("username", _("Username"), | |
546 js->user->node, FALSE); | |
547 gaim_request_field_group_add_field(group, field); | |
548 | |
549 field = gaim_request_field_string_new("password", _("Password"), | |
550 gaim_account_get_password(js->gc->account), FALSE); | |
551 gaim_request_field_string_set_masked(field, TRUE); | |
552 gaim_request_field_group_add_field(group, field); | |
553 | |
554 if(xmlnode_get_child(query, "name")) { | |
555 field = gaim_request_field_string_new("name", _("Name"), | |
556 gaim_account_get_alias(js->gc->account), FALSE); | |
557 gaim_request_field_group_add_field(group, field); | |
558 } | |
559 if(xmlnode_get_child(query, "email")) { | |
560 field = gaim_request_field_string_new("email", _("E-Mail"), | |
561 NULL, FALSE); | |
562 gaim_request_field_group_add_field(group, field); | |
563 } | |
564 if(xmlnode_get_child(query, "nick")) { | |
565 field = gaim_request_field_string_new("nick", _("Nickname"), | |
566 NULL, FALSE); | |
567 gaim_request_field_group_add_field(group, field); | |
568 } | |
569 if(xmlnode_get_child(query, "first")) { | |
570 field = gaim_request_field_string_new("first", _("First Name"), | |
571 NULL, FALSE); | |
572 gaim_request_field_group_add_field(group, field); | |
573 } | |
574 if(xmlnode_get_child(query, "last")) { | |
575 field = gaim_request_field_string_new("last", _("Last Name"), | |
576 NULL, FALSE); | |
577 gaim_request_field_group_add_field(group, field); | |
578 } | |
579 if(xmlnode_get_child(query, "address")) { | |
580 field = gaim_request_field_string_new("address", _("Address"), | |
581 NULL, FALSE); | |
582 gaim_request_field_group_add_field(group, field); | |
583 } | |
584 if(xmlnode_get_child(query, "city")) { | |
585 field = gaim_request_field_string_new("city", _("City"), | |
586 NULL, FALSE); | |
587 gaim_request_field_group_add_field(group, field); | |
588 } | |
589 if(xmlnode_get_child(query, "state")) { | |
590 field = gaim_request_field_string_new("state", _("State"), | |
591 NULL, FALSE); | |
592 gaim_request_field_group_add_field(group, field); | |
593 } | |
594 if(xmlnode_get_child(query, "zip")) { | |
595 field = gaim_request_field_string_new("zip", _("Postal Code"), | |
596 NULL, FALSE); | |
597 gaim_request_field_group_add_field(group, field); | |
598 } | |
599 if(xmlnode_get_child(query, "phone")) { | |
600 field = gaim_request_field_string_new("phone", _("Phone"), | |
601 NULL, FALSE); | |
602 gaim_request_field_group_add_field(group, field); | |
603 } | |
604 if(xmlnode_get_child(query, "url")) { | |
605 field = gaim_request_field_string_new("url", _("URL"), | |
606 NULL, FALSE); | |
607 gaim_request_field_group_add_field(group, field); | |
608 } | |
609 if(xmlnode_get_child(query, "date")) { | |
610 field = gaim_request_field_string_new("date", _("Date"), | |
611 NULL, FALSE); | |
612 gaim_request_field_group_add_field(group, field); | |
613 } | |
614 | |
615 if((y = xmlnode_get_child(query, "instructions"))) | |
616 instructions = xmlnode_get_data(y); | |
617 else | |
618 instructions = g_strdup(_("Please fill out the information below " | |
619 "to register your new account.")); | |
620 | |
621 gaim_request_fields(js->gc, _("Register New Jabber Account"), | |
622 _("Register New Jabber Account"), instructions, fields, | |
623 _("Register"), G_CALLBACK(jabber_register_cb), | |
624 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); | |
625 } | |
626 } | |
627 | |
628 static void jabber_register_start(JabberStream *js) | |
629 { | |
630 JabberIq *iq; | |
631 | |
632 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); | |
633 jabber_iq_send(iq); | |
634 } | |
635 | |
636 static void jabber_register_account(GaimAccount *account) | |
637 { | |
638 GaimConnection *gc = gaim_account_get_connection(account); | |
639 JabberStream *js; | |
640 const char *connect_server = gaim_account_get_string(account, | |
641 "connect_server", ""); | |
642 const char *server; | |
643 int rc; | |
644 | |
645 js = gc->proto_data = g_new0(JabberStream, 1); | |
646 js->gc = gc; | |
647 js->registration = TRUE; | |
648 js->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
649 g_free, NULL); | |
650 js->user = jabber_id_new(gaim_account_get_username(account)); | |
651 | |
7147 | 652 if(!js->user->resource) { |
653 char *me; | |
654 js->user->resource = g_strdup("Gaim"); | |
655 if(!js->user->node) { | |
656 js->user->node = js->user->domain; | |
657 js->user->domain = g_strdup("jabber.org"); | |
658 } | |
659 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
660 js->user->resource); | |
661 gaim_account_set_username(account, me); | |
662 g_free(me); | |
663 } | |
664 | |
7072 | 665 server = connect_server[0] ? connect_server : js->user->domain; |
666 | |
667 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); | |
668 | |
669 if(gaim_account_get_bool(account, "old_ssl", FALSE) | |
670 && gaim_ssl_is_supported()) { | |
671 js->gsc = gaim_ssl_connect(account, server, | |
672 gaim_account_get_int(account, "port", 5222), | |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7264
diff
changeset
|
673 jabber_login_callback_ssl, NULL, gc); |
7072 | 674 } |
675 | |
676 if(!js->gsc) { | |
677 rc = gaim_proxy_connect(account, server, | |
678 gaim_account_get_int(account, "port", 5222), | |
679 jabber_login_callback, gc); | |
680 | |
681 if (rc != 0) | |
682 gaim_connection_error(gc, _("Unable to create socket")); | |
683 } | |
684 } | |
685 | |
5572 | 686 static void jabber_close(GaimConnection *gc) |
2086 | 687 { |
7014 | 688 JabberStream *js = gc->proto_data; |
2956 | 689 |
7014 | 690 jabber_send_raw(js, "</stream:stream>"); |
3311 | 691 |
7014 | 692 if(js->gsc) { |
693 gaim_ssl_close(js->gsc); | |
694 } else { | |
7072 | 695 if(js->gc->inpa) |
696 gaim_input_remove(js->gc->inpa); | |
7014 | 697 close(js->fd); |
698 } | |
3311 | 699 |
7014 | 700 g_markup_parse_context_free(js->context); |
5093 | 701 |
7072 | 702 if(js->callbacks) |
703 g_hash_table_destroy(js->callbacks); | |
704 if(js->buddies) | |
705 g_hash_table_destroy(js->buddies); | |
706 if(js->chats) | |
707 g_hash_table_destroy(js->chats); | |
7014 | 708 if(js->stream_id) |
709 g_free(js->stream_id); | |
710 jabber_id_free(js->user); | |
711 g_free(js); | |
5093 | 712 } |
713 | |
7014 | 714 void jabber_stream_set_state(JabberStream *js, JabberStreamState state) |
3105 | 715 { |
7014 | 716 js->state = state; |
717 switch(state) { | |
718 case JABBER_STREAM_OFFLINE: | |
719 break; | |
720 case JABBER_STREAM_CONNECTING: | |
721 gaim_connection_update_progress(js->gc, _("Connecting"), 1, | |
722 JABBER_CONNECT_STEPS); | |
723 break; | |
724 case JABBER_STREAM_INITIALIZING: | |
725 gaim_connection_update_progress(js->gc, _("Initializing Stream"), | |
726 js->gsc ? 5 : 2, JABBER_CONNECT_STEPS); | |
727 jabber_stream_init(js); | |
728 jabber_parser_setup(js); | |
729 break; | |
730 case JABBER_STREAM_AUTHENTICATING: | |
731 gaim_connection_update_progress(js->gc, _("Authenticating"), | |
732 js->gsc ? 6 : 3, JABBER_CONNECT_STEPS); | |
7072 | 733 if(js->registration) |
734 jabber_register_start(js); | |
735 else if(js->protocol_version == JABBER_PROTO_0_9) | |
7014 | 736 jabber_auth_start_old(js); |
737 break; | |
738 case JABBER_STREAM_REINITIALIZING: | |
739 gaim_connection_update_progress(js->gc, _("Re-initializing Stream"), | |
740 6, JABBER_CONNECT_STEPS); | |
741 jabber_stream_init(js); | |
742 break; | |
743 case JABBER_STREAM_CONNECTED: | |
744 gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
745 jabber_roster_request(js); | |
746 jabber_presence_send(js->gc, js->gc->away_state, js->gc->away); | |
747 serv_finish_login(js->gc); | |
748 break; | |
3105 | 749 } |
750 } | |
751 | |
7014 | 752 char *jabber_get_next_id(JabberStream *js) |
2086 | 753 { |
7014 | 754 return g_strdup_printf("gaim%d", js->next_id++); |
2086 | 755 } |
756 | |
7014 | 757 void jabber_idle_set(GaimConnection *gc, int idle) |
3340 | 758 { |
7014 | 759 JabberStream *js = gc->proto_data; |
3340 | 760 |
7014 | 761 js->idle = idle ? time(NULL) - idle : idle; |
3314 | 762 } |
763 | |
6695 | 764 static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) |
2086 | 765 { |
4687 | 766 return "jabber"; |
767 } | |
4916 | 768 |
7014 | 769 static void jabber_list_emblems(GaimBuddy *b, char **se, char **sw, |
770 char **nw, char **ne) | |
4916 | 771 { |
7014 | 772 JabberStream *js; |
773 JabberBuddy *jb; | |
774 | |
775 if(!b->account->gc) | |
776 return; | |
777 js = b->account->gc->proto_data; | |
778 jb = jabber_buddy_find(js, b->name, FALSE); | |
5135 | 779 |
780 if(!GAIM_BUDDY_IS_ONLINE(b)) { | |
7014 | 781 if(jb && jb->error_msg) |
4927 | 782 *nw = "error"; |
5135 | 783 |
7014 | 784 if(jb && (jb->subscription & JABBER_SUB_PENDING || |
785 !(jb->subscription & JABBER_SUB_TO))) | |
5135 | 786 *se = "notauthorized"; |
787 else | |
788 *se = "offline"; | |
4916 | 789 } else { |
790 switch (b->uc) { | |
7014 | 791 case JABBER_STATE_AWAY: |
792 *se = "away"; | |
793 break; | |
794 case JABBER_STATE_CHAT: | |
795 *se = "chat"; | |
796 break; | |
797 case JABBER_STATE_XA: | |
798 *se = "extendedaway"; | |
799 break; | |
800 case JABBER_STATE_DND: | |
801 *se = "extendedaway"; | |
802 break; | |
803 case JABBER_STATE_ERROR: | |
804 *se = "error"; | |
805 break; | |
4916 | 806 } |
2086 | 807 } |
4916 | 808 } |
2086 | 809 |
7014 | 810 static char *jabber_status_text(GaimBuddy *b) |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
811 { |
7014 | 812 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
813 FALSE); | |
814 char *ret = NULL; | |
5234 | 815 |
7014 | 816 if(jb && !GAIM_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { |
817 ret = g_strdup(_("Not Authorized")); | |
818 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
819 ret = g_strdup(jb->error_msg); | |
2956 | 820 } else { |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
821 char *stripped; |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
822 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
823 stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)); |
2956 | 824 |
7014 | 825 if(!stripped && b->uc & UC_UNAVAILABLE) |
826 stripped = g_strdup(jabber_get_state_string(b->uc)); | |
2086 | 827 |
7014 | 828 if(stripped) { |
829 ret = g_markup_escape_text(stripped, -1); | |
830 g_free(stripped); | |
831 } | |
2086 | 832 } |
833 | |
7014 | 834 return ret; |
2956 | 835 } |
836 | |
6695 | 837 static char *jabber_tooltip_text(GaimBuddy *b) |
4744 | 838 { |
7014 | 839 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
840 FALSE); | |
841 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL); | |
5135 | 842 char *ret = NULL; |
7014 | 843 |
844 if(jbr) { | |
4777 | 845 char *text = NULL; |
7014 | 846 if(jbr->status) { |
847 char *stripped; | |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
848 stripped = gaim_markup_strip_html(jbr->status); |
7014 | 849 text = g_markup_escape_text(stripped, -1); |
850 g_free(stripped); | |
851 } | |
852 | |
5236 | 853 ret = g_strdup_printf("<b>%s:</b> %s%s%s", |
854 _("Status"), | |
7014 | 855 jabber_get_state_string(jbr->state), |
856 text ? ": " : "", | |
4745 | 857 text ? text : ""); |
7014 | 858 if(text) |
4745 | 859 g_free(text); |
7014 | 860 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { |
861 ret = g_strdup_printf("<b>%s:</b> %s", | |
862 _("Error"), jb->error_msg); | |
863 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && | |
864 (jb->subscription & JABBER_SUB_PENDING || | |
865 !(jb->subscription & JABBER_SUB_TO))) { | |
866 ret = g_strdup_printf("<b>%s:</b> %s", | |
867 _("Status"), _("Not Authorized")); | |
4745 | 868 } |
4744 | 869 |
5135 | 870 return ret; |
4732 | 871 } |
872 | |
7014 | 873 static GList *jabber_away_states(GaimConnection *gc) |
874 { | |
2086 | 875 GList *m = NULL; |
876 | |
4982 | 877 m = g_list_append(m, _("Online")); |
878 m = g_list_append(m, _("Chatty")); | |
879 m = g_list_append(m, _("Away")); | |
880 m = g_list_append(m, _("Extended Away")); | |
881 m = g_list_append(m, _("Do Not Disturb")); | |
882 m = g_list_append(m, _("Invisible")); | |
4110 | 883 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
2086 | 884 |
885 return m; | |
886 } | |
887 | |
7124 | 888 static void jabber_password_change_result_cb(JabberStream *js, xmlnode *packet) |
889 { | |
890 const char *type; | |
891 | |
892 type = xmlnode_get_attrib(packet, "type"); | |
893 | |
894 if(!strcmp(type, "result")) { | |
895 gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"), | |
896 _("Your password has been changed.")); | |
897 } else { | |
898 xmlnode *error; | |
899 char *buf, *error_txt = NULL; | |
900 | |
901 | |
902 if((error = xmlnode_get_child(packet, "error"))) | |
903 error_txt = xmlnode_get_data(error); | |
904 | |
905 if(error_txt) { | |
906 buf = g_strdup_printf(_("Error changing password: %s"), | |
907 error_txt); | |
908 g_free(error_txt); | |
909 } else { | |
910 buf = g_strdup(_("Unknown error occurred changing password")); | |
911 } | |
912 | |
913 gaim_notify_error(js->gc, _("Error"), _("Error"), buf); | |
914 g_free(buf); | |
915 } | |
916 } | |
917 | |
918 static void jabber_password_change_cb(JabberStream *js, | |
919 GaimRequestFields *fields) | |
920 { | |
921 const char *p1, *p2; | |
922 JabberIq *iq; | |
923 xmlnode *query, *y; | |
924 | |
925 p1 = gaim_request_fields_get_string(fields, "password1"); | |
926 p2 = gaim_request_fields_get_string(fields, "password2"); | |
927 | |
928 if(strcmp(p1, p2)) { | |
929 gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); | |
930 return; | |
931 } | |
932 | |
933 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
934 | |
935 xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
936 | |
937 query = xmlnode_get_child(iq->node, "query"); | |
938 | |
939 y = xmlnode_new_child(query, "username"); | |
940 xmlnode_insert_data(y, js->user->node, -1); | |
941 y = xmlnode_new_child(query, "password"); | |
942 xmlnode_insert_data(y, p1, -1); | |
943 | |
944 jabber_iq_set_callback(iq, jabber_password_change_result_cb); | |
945 | |
946 jabber_iq_send(iq); | |
947 | |
948 gaim_account_set_password(js->gc->account, p1); | |
949 } | |
950 | |
951 static void jabber_password_change(GaimConnection *gc) | |
952 { | |
953 JabberStream *js = gc->proto_data; | |
954 GaimRequestFields *fields; | |
955 GaimRequestFieldGroup *group; | |
956 GaimRequestField *field; | |
957 | |
958 fields = gaim_request_fields_new(); | |
959 group = gaim_request_field_group_new(NULL); | |
960 gaim_request_fields_add_group(fields, group); | |
961 | |
962 field = gaim_request_field_string_new("password1", _("Password"), | |
963 "", FALSE); | |
964 gaim_request_field_string_set_masked(field, TRUE); | |
965 gaim_request_field_group_add_field(group, field); | |
966 | |
967 field = gaim_request_field_string_new("password2", _("Password (again)"), | |
968 "", FALSE); | |
969 gaim_request_field_string_set_masked(field, TRUE); | |
970 gaim_request_field_group_add_field(group, field); | |
971 | |
972 gaim_request_fields(js->gc, _("Change Jabber Password"), | |
973 _("Change Jabber Password"), _("Please enter your new password"), | |
974 fields, _("OK"), G_CALLBACK(jabber_password_change_cb), | |
975 _("Cancel"), NULL, js); | |
976 } | |
977 | |
5572 | 978 static GList *jabber_actions(GaimConnection *gc) |
2956 | 979 { |
7124 | 980 JabberStream *js = gc->proto_data; |
2956 | 981 GList *m = NULL; |
4333 | 982 struct proto_actions_menu *pam; |
983 | |
984 pam = g_new0(struct proto_actions_menu, 1); | |
985 pam->label = _("Set User Info"); | |
986 pam->callback = jabber_setup_set_info; | |
987 pam->gc = gc; | |
988 m = g_list_append(m, pam); | |
989 | |
7124 | 990 if(js->protocol_version == JABBER_PROTO_0_9) { |
991 pam = g_new0(struct proto_actions_menu, 1); | |
992 pam->label = _("Change Password"); | |
993 pam->callback = jabber_password_change; | |
994 pam->gc = gc; | |
995 m = g_list_append(m, pam); | |
996 } | |
2956 | 997 |
998 return m; | |
999 } | |
1000 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1001 static GaimPluginProtocolInfo prpl_info = |
2086 | 1002 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1003 GAIM_PROTO_JABBER, |
7014 | 1004 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1005 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1006 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1007 jabber_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1008 jabber_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1009 jabber_status_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1010 jabber_tooltip_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1011 jabber_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1012 jabber_actions, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1013 jabber_buddy_menu, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1014 jabber_chat_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1015 jabber_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1016 jabber_close, |
7014 | 1017 jabber_message_send_im, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1018 jabber_set_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1019 jabber_send_typing, |
7014 | 1020 jabber_buddy_get_info, |
1021 jabber_presence_send, | |
5205
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, |
7014 | 1026 jabber_idle_set, |
1027 NULL, /* change_passwd */ /* XXX */ | |
1028 jabber_roster_add_buddy, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1029 NULL, |
7014 | 1030 jabber_roster_remove_buddy, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1031 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1032 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1033 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1034 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1035 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1036 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1037 NULL, |
7014 | 1038 jabber_chat_join, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1039 jabber_chat_invite, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1040 jabber_chat_leave, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1041 jabber_chat_whisper, |
7014 | 1042 jabber_message_send_chat, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1043 jabber_keepalive, |
7072 | 1044 jabber_register_account, |
7014 | 1045 jabber_buddy_get_info_chat, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1046 NULL, |
7014 | 1047 jabber_roster_alias_change, |
1048 jabber_roster_group_change, | |
1049 jabber_roster_group_rename, | |
1050 NULL, | |
1051 NULL, /* convo_closed */ /* XXX: thread_ids */ | |
7261 | 1052 jabber_normalize /* normalize */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1053 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1054 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1055 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1056 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1057 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1058 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1059 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1060 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1061 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1062 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1063 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1064 "prpl-jabber", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1065 "Jabber", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1066 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1067 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1068 N_("Jabber Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1069 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1070 N_("Jabber Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1071 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
1072 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1073 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1074 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1075 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1076 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1077 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1078 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1079 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1080 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1081 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1082 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1083 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1084 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1085 GaimAccountUserSplit *split; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1086 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1087 |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1088 split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1089 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
|
1090 |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1091 split = gaim_account_user_split_new(_("Resource"), "Gaim", '/'); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1092 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
|
1093 |
7124 | 1094 option = gaim_account_option_bool_new(_("Force Old SSL"), "old_ssl", FALSE); |
1095 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1096 option); | |
6764 | 1097 |
7014 | 1098 option = gaim_account_option_int_new(_("Port"), "port", 5222); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1099 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
7014 | 1100 option); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1101 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1102 option = gaim_account_option_string_new(_("Connect server"), |
7014 | 1103 "connect_server", NULL); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1104 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
7014 | 1105 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1106 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1107 my_protocol = plugin; |
7014 | 1108 |
1109 gaim_prefs_add_none("/plugins/prpl/jabber"); | |
1110 gaim_prefs_add_bool("/plugins/prpl/jabber/hide_os", FALSE); | |
2086 | 1111 } |
1112 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1113 GAIM_INIT_PLUGIN(jabber, init_plugin, info); |