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