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