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