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