Tue, 06 Apr 2004 02:28:01 +0000
[gaim-migrate @ 9342]
Alright, I had to get my tooltip construction deuglification on.
I removed the \n between the core's tooltip and the prpl's tooltip.
prpl's should PREpend a \n to each line they add to the tooltip
instead of APpending. This way you don't have to worry about
removing trailing newline... it makes a lot more sense to me.
I also changed oscar and trepia to use g_strings instead of
g_strdup_printf and g_strconcat. G strings are sexy.
And I apologize to the translators for changing some strings
(separated some html and some text).
| 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 | #include "account.h" |
| 24 | #include "accountopt.h" | |
| 25 | #include "debug.h" | |
| 26 | #include "message.h" | |
| 27 | #include "multi.h" | |
| 7072 | 28 | #include "notify.h" |
| 7014 | 29 | #include "prpl.h" |
| 7072 | 30 | #include "request.h" |
| 7014 | 31 | #include "server.h" |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
32 | #include "util.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
33 | |
| 7014 | 34 | #include "auth.h" |
| 35 | #include "buddy.h" | |
| 36 | #include "chat.h" | |
| 8312 | 37 | #include "disco.h" |
| 7014 | 38 | #include "iq.h" |
| 39 | #include "jutil.h" | |
| 40 | #include "message.h" | |
| 41 | #include "parser.h" | |
| 42 | #include "presence.h" | |
| 43 | #include "jabber.h" | |
| 44 | #include "roster.h" | |
| 7923 | 45 | #include "xdata.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
46 | |
| 7014 | 47 | #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5) |
| 2086 | 48 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
49 | static GaimPlugin *my_protocol = NULL; |
|
4249
62583b5d3663
[gaim-migrate @ 4499]
Robert McQueen <robot101@debian.org>
parents:
4245
diff
changeset
|
50 | |
| 7014 | 51 | static void jabber_stream_init(JabberStream *js) |
| 52 | { | |
| 53 | char *open_stream; | |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
54 | |
| 7014 | 55 | open_stream = g_strdup_printf("<stream:stream to='%s' " |
| 56 | "xmlns='jabber:client' " | |
| 7395 | 57 | "xmlns:stream='http://etherx.jabber.org/streams' " |
| 58 | "version='1.0'>", | |
| 7291 | 59 | js->user->domain); |
| 3311 | 60 | |
| 7642 | 61 | jabber_send_raw(js, open_stream, -1); |
| 2086 | 62 | |
| 7014 | 63 | g_free(open_stream); |
| 2086 | 64 | } |
| 65 | ||
| 7395 | 66 | static void |
| 67 | jabber_session_initialized_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
| 3311 | 68 | { |
| 7014 | 69 | const char *type = xmlnode_get_attrib(packet, "type"); |
| 70 | if(type && !strcmp(type, "result")) { | |
| 71 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
| 72 | } else { | |
| 73 | gaim_connection_error(js->gc, _("Error initializing session")); | |
| 3311 | 74 | } |
| 75 | } | |
| 76 | ||
| 7014 | 77 | static void jabber_session_init(JabberStream *js) |
| 3311 | 78 | { |
| 7014 | 79 | JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); |
| 80 | xmlnode *session; | |
| 3311 | 81 | |
| 7395 | 82 | jabber_iq_set_callback(iq, jabber_session_initialized_cb, NULL); |
| 3311 | 83 | |
| 7014 | 84 | session = xmlnode_new_child(iq->node, "session"); |
| 85 | xmlnode_set_attrib(session, "xmlns", "urn:ietf:params:xml:ns:xmpp-session"); | |
| 3311 | 86 | |
| 7014 | 87 | jabber_iq_send(iq); |
| 3311 | 88 | } |
| 89 | ||
| 7395 | 90 | static void jabber_bind_result_cb(JabberStream *js, xmlnode *packet, |
| 91 | gpointer data) | |
| 92 | { | |
| 8401 | 93 | const char *type = xmlnode_get_attrib(packet, "type"); |
| 94 | xmlnode *bind; | |
| 95 | ||
| 96 | if(type && !strcmp(type, "result") && | |
| 97 | (bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) { | |
| 98 | xmlnode *jid; | |
| 99 | char *full_jid; | |
| 100 | if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) { | |
| 101 | jabber_id_free(js->user); | |
| 102 | if(!(js->user = jabber_id_new(full_jid))) { | |
| 103 | gaim_connection_error(js->gc, _("Invalid response from server.")); | |
| 104 | } | |
| 105 | } | |
| 106 | } else { | |
| 107 | char *msg = jabber_parse_error(js, packet); | |
| 108 | gaim_connection_error(js->gc, msg); | |
| 109 | g_free(msg); | |
| 110 | } | |
| 7395 | 111 | |
| 112 | jabber_session_init(js); | |
| 113 | } | |
| 114 | ||
| 115 | static void jabber_stream_features_parse(JabberStream *js, xmlnode *packet) | |
| 116 | { | |
| 8296 | 117 | if(xmlnode_get_child(packet, "starttls")) { |
| 118 | if(jabber_process_starttls(js, packet)) | |
| 119 | return; | |
| 120 | } | |
| 121 | ||
| 7395 | 122 | if(xmlnode_get_child(packet, "mechanisms")) { |
| 123 | jabber_auth_start(js, packet); | |
| 124 | } else if(xmlnode_get_child(packet, "bind")) { | |
| 125 | xmlnode *bind, *resource; | |
| 126 | JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); | |
| 127 | bind = xmlnode_new_child(iq->node, "bind"); | |
| 128 | xmlnode_set_attrib(bind, "xmlns", "urn:ietf:params:xml:ns:xmpp-bind"); | |
| 129 | resource = xmlnode_new_child(bind, "resource"); | |
| 130 | xmlnode_insert_data(resource, js->user->resource, -1); | |
| 131 | ||
| 132 | jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL); | |
| 133 | ||
| 134 | jabber_iq_send(iq); | |
| 8296 | 135 | } else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ { |
| 136 | /* If we get an empty stream:features packet, or we explicitly get | |
| 137 | * an auth feature with namespace http://jabber.org/features/iq-auth | |
| 138 | * we should revert back to iq:auth authentication, even though we're | |
| 139 | * connecting to an XMPP server. */ | |
| 140 | js->auth_type = JABBER_AUTH_IQ_AUTH; | |
| 141 | jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING); | |
| 7395 | 142 | } |
| 143 | } | |
| 144 | ||
| 7014 | 145 | static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet) |
| 3311 | 146 | { |
| 8401 | 147 | char *msg = jabber_parse_error(js, packet); |
| 3311 | 148 | |
| 8401 | 149 | gaim_connection_error(js->gc, msg); |
| 150 | g_free(msg); | |
| 2086 | 151 | } |
| 152 | ||
| 7014 | 153 | static void tls_init(JabberStream *js); |
| 2086 | 154 | |
| 7014 | 155 | void jabber_process_packet(JabberStream *js, xmlnode *packet) |
| 2086 | 156 | { |
| 7014 | 157 | if(!strcmp(packet->name, "iq")) { |
| 7395 | 158 | jabber_iq_parse(js, packet); |
| 7014 | 159 | } else if(!strcmp(packet->name, "presence")) { |
| 160 | jabber_presence_parse(js, packet); | |
| 161 | } else if(!strcmp(packet->name, "message")) { | |
| 162 | jabber_message_parse(js, packet); | |
| 163 | } else if(!strcmp(packet->name, "stream:features")) { | |
| 7395 | 164 | jabber_stream_features_parse(js, packet); |
| 7014 | 165 | } else if(!strcmp(packet->name, "stream:error")) { |
| 166 | jabber_stream_handle_error(js, packet); | |
| 167 | } else if(!strcmp(packet->name, "challenge")) { | |
| 168 | if(js->state == JABBER_STREAM_AUTHENTICATING) | |
| 169 | jabber_auth_handle_challenge(js, packet); | |
| 170 | } else if(!strcmp(packet->name, "success")) { | |
| 171 | if(js->state == JABBER_STREAM_AUTHENTICATING) | |
| 172 | jabber_auth_handle_success(js, packet); | |
| 173 | } else if(!strcmp(packet->name, "failure")) { | |
| 174 | if(js->state == JABBER_STREAM_AUTHENTICATING) | |
| 175 | jabber_auth_handle_failure(js, packet); | |
| 176 | } else if(!strcmp(packet->name, "proceed")) { | |
| 177 | if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc) | |
| 178 | tls_init(js); | |
| 179 | } else { | |
| 180 | gaim_debug(GAIM_DEBUG_WARNING, "jabber", "Unknown packet: %s\n", | |
| 181 | packet->name); | |
| 2086 | 182 | } |
| 183 | } | |
| 184 | ||
| 7642 | 185 | void jabber_send_raw(JabberStream *js, const char *data, int len) |
| 2086 | 186 | { |
| 7014 | 187 | int ret; |
| 2086 | 188 | |
| 7014 | 189 | /* because printing a tab to debug every minute gets old */ |
| 190 | if(strcmp(data, "\t")) | |
| 8401 | 191 | gaim_debug(GAIM_DEBUG_MISC, "jabber", "Sending%s: %s\n", |
| 7014 | 192 | js->gsc ? " (ssl)" : "", data); |
| 2086 | 193 | |
| 7014 | 194 | if(js->gsc) { |
| 7642 | 195 | ret = gaim_ssl_write(js->gsc, data, len == -1 ? strlen(data) : len); |
| 7014 | 196 | } else { |
|
8013
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
197 | if(js->fd < 0) |
|
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
198 | return; |
| 7642 | 199 | ret = write(js->fd, data, len == -1 ? strlen(data) : len); |
|
2814
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
200 | } |
|
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
201 | |
| 7014 | 202 | if(ret < 0) |
| 203 | gaim_connection_error(js->gc, _("Write error")); | |
| 204 | ||
|
2814
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
205 | } |
|
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
206 | |
| 7014 | 207 | void jabber_send(JabberStream *js, xmlnode *packet) |
| 2086 | 208 | { |
| 7014 | 209 | char *txt; |
| 7642 | 210 | int len; |
| 2086 | 211 | |
| 7642 | 212 | txt = xmlnode_to_str(packet, &len); |
| 213 | jabber_send_raw(js, txt, len); | |
| 7014 | 214 | g_free(txt); |
| 2086 | 215 | } |
| 216 | ||
| 7014 | 217 | static void jabber_keepalive(GaimConnection *gc) |
| 2086 | 218 | { |
| 7642 | 219 | jabber_send_raw(gc->proto_data, "\t", -1); |
| 2086 | 220 | } |
| 221 | ||
| 7014 | 222 | static void |
| 223 | jabber_recv_cb_ssl(gpointer data, GaimSslConnection *gsc, | |
| 6764 | 224 | GaimInputCondition cond) |
| 225 | { | |
| 7014 | 226 | GaimConnection *gc = data; |
| 227 | JabberStream *js = gc->proto_data; | |
| 6764 | 228 | int len; |
| 7014 | 229 | static char buf[4096]; |
| 6768 | 230 | |
| 7014 | 231 | if(!g_list_find(gaim_connections_get_all(), gc)) { |
| 6768 | 232 | gaim_ssl_close(gsc); |
| 233 | return; | |
| 234 | } | |
| 235 | ||
| 7014 | 236 | if((len = gaim_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) { |
| 6764 | 237 | buf[len] = '\0'; |
| 7014 | 238 | gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf); |
| 239 | jabber_parser_process(js, buf, len); | |
| 7177 | 240 | } else { |
| 241 | gaim_connection_error(gc, _("Read Error")); | |
| 2086 | 242 | } |
| 243 | } | |
| 244 | ||
| 7014 | 245 | static void |
| 246 | jabber_recv_cb(gpointer data, gint source, GaimInputCondition condition) | |
| 2086 | 247 | { |
| 5572 | 248 | GaimConnection *gc = data; |
| 7014 | 249 | JabberStream *js = gc->proto_data; |
| 250 | int len; | |
| 251 | static char buf[4096]; | |
| 2086 | 252 | |
| 7014 | 253 | if(!g_list_find(gaim_connections_get_all(), gc)) |
| 254 | return; | |
| 2956 | 255 | |
| 7014 | 256 | if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) { |
| 257 | buf[len] = '\0'; | |
| 258 | gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf); | |
| 259 | jabber_parser_process(js, buf, len); | |
| 7177 | 260 | } else { |
| 261 | gaim_connection_error(gc, _("Read Error")); | |
| 7014 | 262 | } |
| 2086 | 263 | } |
| 264 | ||
| 7014 | 265 | static void |
| 266 | jabber_login_callback_ssl(gpointer data, GaimSslConnection *gsc, | |
| 6764 | 267 | GaimInputCondition cond) |
| 268 | { | |
| 269 | GaimConnection *gc = data; | |
| 7014 | 270 | JabberStream *js = gc->proto_data; |
| 6764 | 271 | |
| 7014 | 272 | if(!g_list_find(gaim_connections_get_all(), gc)) { |
| 6764 | 273 | gaim_ssl_close(gsc); |
| 274 | return; | |
| 275 | } | |
| 276 | ||
| 7014 | 277 | js->gsc = gsc; |
| 6764 | 278 | |
| 7014 | 279 | if(js->state == JABBER_STREAM_CONNECTING) |
| 7642 | 280 | jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
| 6764 | 281 | |
| 7014 | 282 | jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
| 283 | gaim_ssl_input_add(gsc, jabber_recv_cb_ssl, gc); | |
| 6764 | 284 | } |
| 285 | ||
| 7014 | 286 | |
| 287 | static void | |
| 288 | jabber_login_callback(gpointer data, gint source, GaimInputCondition cond) | |
| 6764 | 289 | { |
| 5572 | 290 | GaimConnection *gc = data; |
| 7014 | 291 | JabberStream *js = gc->proto_data; |
| 2086 | 292 | |
| 7014 | 293 | if(!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 294 | close(source); |
| 295 | return; | |
| 296 | } | |
| 297 | ||
| 7014 | 298 | js->fd = source; |
| 2956 | 299 | |
| 7014 | 300 | if(js->state == JABBER_STREAM_CONNECTING) |
| 7642 | 301 | jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
|
2300
06a3c10f4918
[gaim-migrate @ 2310]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2289
diff
changeset
|
302 | |
| 7014 | 303 | jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
| 304 | gc->inpa = gaim_input_add(js->fd, GAIM_INPUT_READ, jabber_recv_cb, gc); | |
| 305 | } | |
| 2086 | 306 | |
| 7014 | 307 | static void |
| 7426 | 308 | jabber_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, |
| 309 | gpointer data) | |
| 310 | { | |
| 311 | GaimConnection *gc = data; | |
| 8360 | 312 | JabberStream *js = gc->proto_data; |
| 7426 | 313 | |
| 314 | switch(error) { | |
| 8362 | 315 | case GAIM_SSL_CONNECT_FAILED: |
| 316 | gaim_connection_error(gc, _("Connection Failed")); | |
| 317 | break; | |
| 7426 | 318 | case GAIM_SSL_HANDSHAKE_FAILED: |
| 319 | gaim_connection_error(gc, _("SSL Handshake Failed")); | |
| 320 | break; | |
| 321 | } | |
| 8360 | 322 | |
| 323 | js->gsc = NULL; | |
| 7426 | 324 | } |
| 325 | ||
| 7427 | 326 | static void tls_init(JabberStream *js) |
| 327 | { | |
| 328 | gaim_input_remove(js->gc->inpa); | |
| 329 | js->gc->inpa = 0; | |
| 330 | js->gsc = gaim_ssl_connect_fd(js->gc->account, js->fd, | |
| 331 | jabber_login_callback_ssl, jabber_ssl_connect_failure, js->gc); | |
| 332 | } | |
| 333 | ||
| 334 | ||
| 7426 | 335 | static void |
| 7014 | 336 | jabber_login(GaimAccount *account) |
| 2086 | 337 | { |
| 7014 | 338 | int rc; |
| 339 | GaimConnection *gc = gaim_account_get_connection(account); | |
| 340 | const char *connect_server = gaim_account_get_string(account, | |
| 341 | "connect_server", ""); | |
| 5572 | 342 | const char *server; |
| 7014 | 343 | JabberStream *js; |
| 2086 | 344 | |
| 7014 | 345 | gc->flags |= GAIM_CONNECTION_HTML; |
| 346 | js = gc->proto_data = g_new0(JabberStream, 1); | |
| 347 | js->gc = gc; | |
|
8013
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
348 | js->fd = -1; |
| 8312 | 349 | js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 350 | g_free, g_free); | |
| 351 | js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 7395 | 352 | g_free, g_free); |
| 7014 | 353 | js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 7116 | 354 | g_free, (GDestroyNotify)jabber_buddy_free); |
| 7014 | 355 | js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 8396 | 356 | g_free, (GDestroyNotify)jabber_chat_free); |
| 8043 | 357 | js->chat_servers = g_list_append(NULL, g_strdup("conference.jabber.org")); |
| 7014 | 358 | js->user = jabber_id_new(gaim_account_get_username(account)); |
| 7322 | 359 | js->next_id = g_random_int(); |
| 5613 | 360 | |
| 7310 | 361 | if(!js->user) { |
| 362 | gaim_connection_error(gc, _("Invalid Jabber ID")); | |
| 363 | return; | |
| 364 | } | |
| 365 | ||
| 7147 | 366 | if(!js->user->resource) { |
| 367 | char *me; | |
| 368 | js->user->resource = g_strdup("Gaim"); | |
| 369 | if(!js->user->node) { | |
| 370 | js->user->node = js->user->domain; | |
| 371 | js->user->domain = g_strdup("jabber.org"); | |
| 372 | } | |
| 373 | me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
| 374 | js->user->resource); | |
| 375 | gaim_account_set_username(account, me); | |
| 376 | g_free(me); | |
| 7145 | 377 | } |
| 378 | ||
| 7014 | 379 | server = connect_server[0] ? connect_server : js->user->domain; |
| 2086 | 380 | |
| 7014 | 381 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); |
| 2956 | 382 | |
| 7630 | 383 | |
| 384 | if(gaim_account_get_bool(account, "old_ssl", FALSE)) { | |
| 385 | if(gaim_ssl_is_supported()) { | |
| 386 | js->gsc = gaim_ssl_connect(account, server, | |
| 387 | gaim_account_get_int(account, "port", 5222), | |
| 388 | jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); | |
| 389 | } else { | |
| 390 | gaim_connection_error(gc, _("SSL support unavailable")); | |
| 391 | } | |
| 3311 | 392 | } |
| 3770 | 393 | |
| 7014 | 394 | if(!js->gsc) { |
| 395 | rc = gaim_proxy_connect(account, server, | |
| 396 | gaim_account_get_int(account, "port", 5222), | |
| 397 | jabber_login_callback, gc); | |
| 2086 | 398 | |
| 7014 | 399 | if (rc != 0) |
| 400 | gaim_connection_error(gc, _("Unable to create socket")); | |
| 2956 | 401 | } |
| 2086 | 402 | } |
| 403 | ||
| 7072 | 404 | static gboolean |
| 405 | conn_close_cb(gpointer data) | |
| 406 | { | |
| 407 | JabberStream *js = data; | |
| 408 | gaim_connection_destroy(js->gc); | |
| 409 | return FALSE; | |
| 410 | } | |
| 411 | ||
| 412 | static void | |
| 413 | jabber_connection_schedule_close(JabberStream *js) | |
| 414 | { | |
| 8273 | 415 | gaim_timeout_add(0, conn_close_cb, js); |
| 7072 | 416 | } |
| 417 | ||
| 418 | static void | |
| 7395 | 419 | jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
| 7072 | 420 | { |
| 421 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 422 | char *buf; | |
| 423 | ||
| 424 | if(!strcmp(type, "result")) { | |
| 425 | buf = g_strdup_printf(_("Registration of %s@%s successful"), | |
| 426 | js->user->node, js->user->domain); | |
| 427 | gaim_notify_info(NULL, _("Registration Successful"), | |
| 428 | _("Registration Successful"), buf); | |
| 429 | g_free(buf); | |
| 430 | } else { | |
| 8401 | 431 | char *msg = jabber_parse_error(js, packet); |
| 7072 | 432 | |
| 8401 | 433 | if(!msg) |
| 434 | msg = g_strdup(_("Unknown Error")); | |
| 7072 | 435 | |
| 436 | gaim_notify_error(NULL, _("Registration Failed"), | |
| 8401 | 437 | _("Registration Failed"), msg); |
| 438 | g_free(msg); | |
| 7072 | 439 | } |
| 440 | jabber_connection_schedule_close(js); | |
| 441 | } | |
| 442 | ||
| 443 | static void | |
| 444 | jabber_register_cb(JabberStream *js, GaimRequestFields *fields) | |
| 445 | { | |
| 446 | GList *groups, *flds; | |
| 447 | xmlnode *query, *y; | |
| 448 | JabberIq *iq; | |
| 7264 | 449 | char *username; |
| 7072 | 450 | |
| 451 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 452 | query = xmlnode_get_child(iq->node, "query"); | |
| 453 | ||
| 454 | for(groups = gaim_request_fields_get_groups(fields); groups; | |
| 455 | groups = groups->next) { | |
| 456 | for(flds = gaim_request_field_group_get_fields(groups->data); | |
| 457 | flds; flds = flds->next) { | |
| 458 | GaimRequestField *field = flds->data; | |
| 459 | const char *id = gaim_request_field_get_id(field); | |
| 460 | const char *value = gaim_request_field_string_get_value(field); | |
| 461 | ||
| 462 | if(!strcmp(id, "username")) { | |
| 463 | y = xmlnode_new_child(query, "username"); | |
| 464 | } else if(!strcmp(id, "password")) { | |
| 465 | y = xmlnode_new_child(query, "password"); | |
| 466 | } else if(!strcmp(id, "name")) { | |
| 467 | y = xmlnode_new_child(query, "name"); | |
| 468 | } else if(!strcmp(id, "email")) { | |
| 469 | y = xmlnode_new_child(query, "email"); | |
| 470 | } else if(!strcmp(id, "nick")) { | |
| 471 | y = xmlnode_new_child(query, "nick"); | |
| 472 | } else if(!strcmp(id, "first")) { | |
| 473 | y = xmlnode_new_child(query, "first"); | |
| 474 | } else if(!strcmp(id, "last")) { | |
| 475 | y = xmlnode_new_child(query, "last"); | |
| 476 | } else if(!strcmp(id, "address")) { | |
| 477 | y = xmlnode_new_child(query, "address"); | |
| 478 | } else if(!strcmp(id, "city")) { | |
| 479 | y = xmlnode_new_child(query, "city"); | |
| 480 | } else if(!strcmp(id, "state")) { | |
| 481 | y = xmlnode_new_child(query, "state"); | |
| 482 | } else if(!strcmp(id, "zip")) { | |
| 483 | y = xmlnode_new_child(query, "zip"); | |
| 484 | } else if(!strcmp(id, "phone")) { | |
| 485 | y = xmlnode_new_child(query, "phone"); | |
| 486 | } else if(!strcmp(id, "url")) { | |
| 487 | y = xmlnode_new_child(query, "url"); | |
| 488 | } else if(!strcmp(id, "date")) { | |
| 489 | y = xmlnode_new_child(query, "date"); | |
| 490 | } else { | |
| 491 | continue; | |
| 492 | } | |
| 493 | xmlnode_insert_data(y, value, -1); | |
| 7264 | 494 | if(!strcmp(id, "username")) { |
| 495 | if(js->user->node) | |
| 496 | g_free(js->user->node); | |
| 497 | js->user->node = g_strdup(value); | |
| 498 | } | |
| 7072 | 499 | } |
| 500 | } | |
| 501 | ||
| 7264 | 502 | username = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, |
| 503 | js->user->resource); | |
| 504 | gaim_account_set_username(js->gc->account, username); | |
| 505 | g_free(username); | |
| 506 | ||
| 7395 | 507 | jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); |
| 7072 | 508 | |
| 509 | jabber_iq_send(iq); | |
| 510 | ||
| 511 | } | |
| 512 | ||
| 513 | static void | |
| 514 | jabber_register_cancel_cb(JabberStream *js, GaimRequestFields *fields) | |
| 515 | { | |
| 516 | jabber_connection_schedule_close(js); | |
| 517 | } | |
| 518 | ||
| 7923 | 519 | static void jabber_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
| 520 | { | |
| 521 | xmlnode *query; | |
| 522 | JabberIq *iq; | |
| 523 | ||
| 524 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 525 | query = xmlnode_get_child(iq->node, "query"); | |
| 526 | ||
| 527 | xmlnode_insert_child(query, result); | |
| 528 | ||
| 529 | jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); | |
| 530 | jabber_iq_send(iq); | |
| 531 | } | |
| 532 | ||
| 7072 | 533 | void jabber_register_parse(JabberStream *js, xmlnode *packet) |
| 534 | { | |
| 535 | if(js->registration) { | |
| 536 | GaimRequestFields *fields; | |
| 537 | GaimRequestFieldGroup *group; | |
| 538 | GaimRequestField *field; | |
| 7923 | 539 | xmlnode *query, *x, *y; |
| 7072 | 540 | char *instructions; |
| 541 | ||
| 542 | /* get rid of the login thingy */ | |
| 543 | gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
| 544 | ||
| 545 | query = xmlnode_get_child(packet, "query"); | |
| 546 | ||
| 547 | if(xmlnode_get_child(query, "registered")) { | |
| 548 | gaim_notify_error(NULL, _("Already Registered"), | |
| 549 | _("Already Registered"), NULL); | |
| 550 | jabber_connection_schedule_close(js); | |
| 551 | return; | |
| 552 | } | |
| 553 | ||
| 8398 | 554 | if((x = xmlnode_get_child_with_namespace(packet, "x", |
| 555 | "jabber:x:data"))) { | |
| 556 | jabber_x_data_request(js, x, jabber_register_x_data_cb, NULL); | |
| 557 | return; | |
| 558 | } else if((x = xmlnode_get_child_with_namespace(packet, "x", | |
| 559 | "jabber:x:oob"))) { | |
| 560 | xmlnode *url; | |
| 7923 | 561 | |
| 8398 | 562 | if((url = xmlnode_get_child(x, "url"))) { |
| 563 | char *href; | |
| 564 | if((href = xmlnode_get_data(url))) { | |
| 565 | gaim_notify_uri(NULL, href); | |
| 566 | g_free(href); | |
| 567 | js->gc->wants_to_die = TRUE; | |
| 568 | jabber_connection_schedule_close(js); | |
| 569 | return; | |
| 570 | } | |
| 7923 | 571 | } |
| 572 | } | |
| 573 | ||
| 574 | /* as a last resort, use the old jabber:iq:register syntax */ | |
| 575 | ||
| 7072 | 576 | fields = gaim_request_fields_new(); |
| 577 | group = gaim_request_field_group_new(NULL); | |
| 578 | gaim_request_fields_add_group(fields, group); | |
| 579 | ||
| 580 | field = gaim_request_field_string_new("username", _("Username"), | |
| 581 | js->user->node, FALSE); | |
| 582 | gaim_request_field_group_add_field(group, field); | |
| 583 | ||
| 584 | field = gaim_request_field_string_new("password", _("Password"), | |
| 585 | gaim_account_get_password(js->gc->account), FALSE); | |
| 586 | gaim_request_field_string_set_masked(field, TRUE); | |
| 587 | gaim_request_field_group_add_field(group, field); | |
| 588 | ||
| 589 | if(xmlnode_get_child(query, "name")) { | |
| 590 | field = gaim_request_field_string_new("name", _("Name"), | |
| 591 | gaim_account_get_alias(js->gc->account), FALSE); | |
| 592 | gaim_request_field_group_add_field(group, field); | |
| 593 | } | |
| 594 | if(xmlnode_get_child(query, "email")) { | |
| 595 | field = gaim_request_field_string_new("email", _("E-Mail"), | |
| 596 | NULL, FALSE); | |
| 597 | gaim_request_field_group_add_field(group, field); | |
| 598 | } | |
| 599 | if(xmlnode_get_child(query, "nick")) { | |
| 600 | field = gaim_request_field_string_new("nick", _("Nickname"), | |
| 601 | NULL, FALSE); | |
| 602 | gaim_request_field_group_add_field(group, field); | |
| 603 | } | |
| 604 | if(xmlnode_get_child(query, "first")) { | |
| 605 | field = gaim_request_field_string_new("first", _("First Name"), | |
| 606 | NULL, FALSE); | |
| 607 | gaim_request_field_group_add_field(group, field); | |
| 608 | } | |
| 609 | if(xmlnode_get_child(query, "last")) { | |
| 610 | field = gaim_request_field_string_new("last", _("Last Name"), | |
| 611 | NULL, FALSE); | |
| 612 | gaim_request_field_group_add_field(group, field); | |
| 613 | } | |
| 614 | if(xmlnode_get_child(query, "address")) { | |
| 615 | field = gaim_request_field_string_new("address", _("Address"), | |
| 616 | NULL, FALSE); | |
| 617 | gaim_request_field_group_add_field(group, field); | |
| 618 | } | |
| 619 | if(xmlnode_get_child(query, "city")) { | |
| 620 | field = gaim_request_field_string_new("city", _("City"), | |
| 621 | NULL, FALSE); | |
| 622 | gaim_request_field_group_add_field(group, field); | |
| 623 | } | |
| 624 | if(xmlnode_get_child(query, "state")) { | |
| 625 | field = gaim_request_field_string_new("state", _("State"), | |
| 626 | NULL, FALSE); | |
| 627 | gaim_request_field_group_add_field(group, field); | |
| 628 | } | |
| 629 | if(xmlnode_get_child(query, "zip")) { | |
| 630 | field = gaim_request_field_string_new("zip", _("Postal Code"), | |
| 631 | NULL, FALSE); | |
| 632 | gaim_request_field_group_add_field(group, field); | |
| 633 | } | |
| 634 | if(xmlnode_get_child(query, "phone")) { | |
| 635 | field = gaim_request_field_string_new("phone", _("Phone"), | |
| 636 | NULL, FALSE); | |
| 637 | gaim_request_field_group_add_field(group, field); | |
| 638 | } | |
| 639 | if(xmlnode_get_child(query, "url")) { | |
| 640 | field = gaim_request_field_string_new("url", _("URL"), | |
| 641 | NULL, FALSE); | |
| 642 | gaim_request_field_group_add_field(group, field); | |
| 643 | } | |
| 644 | if(xmlnode_get_child(query, "date")) { | |
| 645 | field = gaim_request_field_string_new("date", _("Date"), | |
| 646 | NULL, FALSE); | |
| 647 | gaim_request_field_group_add_field(group, field); | |
| 648 | } | |
| 649 | ||
| 650 | if((y = xmlnode_get_child(query, "instructions"))) | |
| 651 | instructions = xmlnode_get_data(y); | |
| 652 | else | |
| 653 | instructions = g_strdup(_("Please fill out the information below " | |
| 654 | "to register your new account.")); | |
| 655 | ||
| 656 | gaim_request_fields(js->gc, _("Register New Jabber Account"), | |
| 657 | _("Register New Jabber Account"), instructions, fields, | |
| 658 | _("Register"), G_CALLBACK(jabber_register_cb), | |
| 659 | _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); | |
| 660 | } | |
| 661 | } | |
| 662 | ||
| 8016 | 663 | void jabber_register_start(JabberStream *js) |
| 7072 | 664 | { |
| 665 | JabberIq *iq; | |
| 666 | ||
| 667 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); | |
| 668 | jabber_iq_send(iq); | |
| 669 | } | |
| 670 | ||
| 671 | static void jabber_register_account(GaimAccount *account) | |
| 672 | { | |
| 673 | GaimConnection *gc = gaim_account_get_connection(account); | |
| 674 | JabberStream *js; | |
| 675 | const char *connect_server = gaim_account_get_string(account, | |
| 676 | "connect_server", ""); | |
| 677 | const char *server; | |
| 678 | int rc; | |
| 679 | ||
| 680 | js = gc->proto_data = g_new0(JabberStream, 1); | |
| 681 | js->gc = gc; | |
| 682 | js->registration = TRUE; | |
| 8312 | 683 | js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 684 | g_free, g_free); | |
| 685 | js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 7395 | 686 | g_free, g_free); |
| 7072 | 687 | js->user = jabber_id_new(gaim_account_get_username(account)); |
| 7322 | 688 | js->next_id = g_random_int(); |
| 7072 | 689 | |
| 7310 | 690 | if(!js->user) { |
| 691 | gaim_connection_error(gc, _("Invalid Jabber ID")); | |
| 692 | return; | |
| 693 | } | |
| 694 | ||
| 7147 | 695 | if(!js->user->resource) { |
| 696 | char *me; | |
| 697 | js->user->resource = g_strdup("Gaim"); | |
| 698 | if(!js->user->node) { | |
| 699 | js->user->node = js->user->domain; | |
| 700 | js->user->domain = g_strdup("jabber.org"); | |
| 701 | } | |
| 702 | me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
| 703 | js->user->resource); | |
| 704 | gaim_account_set_username(account, me); | |
| 705 | g_free(me); | |
| 706 | } | |
| 707 | ||
| 7072 | 708 | server = connect_server[0] ? connect_server : js->user->domain; |
| 709 | ||
| 710 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); | |
| 711 | ||
| 7630 | 712 | if(gaim_account_get_bool(account, "old_ssl", FALSE)) { |
| 713 | if(gaim_ssl_is_supported()) { | |
| 714 | js->gsc = gaim_ssl_connect(account, server, | |
| 715 | gaim_account_get_int(account, "port", 5222), | |
| 716 | jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); | |
| 717 | } else { | |
| 718 | gaim_connection_error(gc, _("SSL support unavailable")); | |
| 719 | } | |
| 7072 | 720 | } |
| 721 | ||
| 722 | if(!js->gsc) { | |
| 723 | rc = gaim_proxy_connect(account, server, | |
| 724 | gaim_account_get_int(account, "port", 5222), | |
| 725 | jabber_login_callback, gc); | |
| 726 | ||
| 727 | if (rc != 0) | |
| 728 | gaim_connection_error(gc, _("Unable to create socket")); | |
| 729 | } | |
| 730 | } | |
| 731 | ||
| 5572 | 732 | static void jabber_close(GaimConnection *gc) |
| 2086 | 733 | { |
| 7014 | 734 | JabberStream *js = gc->proto_data; |
| 2956 | 735 | |
| 7642 | 736 | jabber_send_raw(js, "</stream:stream>", -1); |
| 3311 | 737 | |
| 7014 | 738 | if(js->gsc) { |
| 739 | gaim_ssl_close(js->gsc); | |
| 8360 | 740 | } else if (js->fd > 0) { |
| 7072 | 741 | if(js->gc->inpa) |
| 742 | gaim_input_remove(js->gc->inpa); | |
| 7014 | 743 | close(js->fd); |
| 744 | } | |
| 3311 | 745 | |
| 7587 | 746 | if(js->context) |
| 747 | g_markup_parse_context_free(js->context); | |
| 8312 | 748 | if(js->iq_callbacks) |
| 749 | g_hash_table_destroy(js->iq_callbacks); | |
| 750 | if(js->disco_callbacks) | |
| 751 | g_hash_table_destroy(js->disco_callbacks); | |
| 7072 | 752 | if(js->buddies) |
| 753 | g_hash_table_destroy(js->buddies); | |
| 754 | if(js->chats) | |
| 755 | g_hash_table_destroy(js->chats); | |
| 8043 | 756 | while(js->chat_servers) { |
| 757 | g_free(js->chat_servers->data); | |
| 758 | js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers); | |
| 759 | } | |
| 7014 | 760 | if(js->stream_id) |
| 761 | g_free(js->stream_id); | |
| 7587 | 762 | if(js->user) |
| 763 | jabber_id_free(js->user); | |
| 7014 | 764 | g_free(js); |
| 5093 | 765 | } |
| 766 | ||
| 7014 | 767 | void jabber_stream_set_state(JabberStream *js, JabberStreamState state) |
|
3105
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
768 | { |
| 7014 | 769 | js->state = state; |
| 770 | switch(state) { | |
| 771 | case JABBER_STREAM_OFFLINE: | |
| 772 | break; | |
| 773 | case JABBER_STREAM_CONNECTING: | |
| 774 | gaim_connection_update_progress(js->gc, _("Connecting"), 1, | |
| 775 | JABBER_CONNECT_STEPS); | |
| 776 | break; | |
| 777 | case JABBER_STREAM_INITIALIZING: | |
| 778 | gaim_connection_update_progress(js->gc, _("Initializing Stream"), | |
| 779 | js->gsc ? 5 : 2, JABBER_CONNECT_STEPS); | |
| 780 | jabber_stream_init(js); | |
| 781 | jabber_parser_setup(js); | |
| 782 | break; | |
| 783 | case JABBER_STREAM_AUTHENTICATING: | |
| 784 | gaim_connection_update_progress(js->gc, _("Authenticating"), | |
| 785 | js->gsc ? 6 : 3, JABBER_CONNECT_STEPS); | |
| 8296 | 786 | if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) { |
| 787 | jabber_register_start(js); | |
| 788 | } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) { | |
| 789 | jabber_auth_start_old(js); | |
| 8016 | 790 | } |
| 7014 | 791 | break; |
| 792 | case JABBER_STREAM_REINITIALIZING: | |
| 793 | gaim_connection_update_progress(js->gc, _("Re-initializing Stream"), | |
| 794 | 6, JABBER_CONNECT_STEPS); | |
| 795 | jabber_stream_init(js); | |
| 796 | break; | |
| 797 | case JABBER_STREAM_CONNECTED: | |
| 798 | gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
| 799 | jabber_roster_request(js); | |
| 800 | jabber_presence_send(js->gc, js->gc->away_state, js->gc->away); | |
| 8312 | 801 | jabber_disco_items_server(js); |
| 7014 | 802 | serv_finish_login(js->gc); |
| 803 | break; | |
|
3105
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
804 | } |
|
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
805 | } |
|
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
806 | |
| 7014 | 807 | char *jabber_get_next_id(JabberStream *js) |
| 2086 | 808 | { |
| 7322 | 809 | return g_strdup_printf("gaim%x", js->next_id++); |
| 2086 | 810 | } |
| 811 | ||
| 7923 | 812 | |
| 813 | static void jabber_idle_set(GaimConnection *gc, int idle) | |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
814 | { |
| 7014 | 815 | JabberStream *js = gc->proto_data; |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
816 | |
| 7014 | 817 | js->idle = idle ? time(NULL) - idle : idle; |
|
3314
12fa45677717
[gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3311
diff
changeset
|
818 | } |
|
12fa45677717
[gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3311
diff
changeset
|
819 | |
| 6695 | 820 | static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) |
| 2086 | 821 | { |
| 4687 | 822 | return "jabber"; |
| 823 | } | |
| 4916 | 824 | |
| 7014 | 825 | static void jabber_list_emblems(GaimBuddy *b, char **se, char **sw, |
| 826 | char **nw, char **ne) | |
| 4916 | 827 | { |
| 7014 | 828 | JabberStream *js; |
| 829 | JabberBuddy *jb; | |
| 830 | ||
| 831 | if(!b->account->gc) | |
| 832 | return; | |
| 833 | js = b->account->gc->proto_data; | |
| 834 | jb = jabber_buddy_find(js, b->name, FALSE); | |
| 5135 | 835 | |
| 836 | if(!GAIM_BUDDY_IS_ONLINE(b)) { | |
| 7014 | 837 | if(jb && jb->error_msg) |
| 4927 | 838 | *nw = "error"; |
| 5135 | 839 | |
| 7014 | 840 | if(jb && (jb->subscription & JABBER_SUB_PENDING || |
| 841 | !(jb->subscription & JABBER_SUB_TO))) | |
| 5135 | 842 | *se = "notauthorized"; |
| 843 | else | |
| 844 | *se = "offline"; | |
| 4916 | 845 | } else { |
| 846 | switch (b->uc) { | |
| 7014 | 847 | case JABBER_STATE_AWAY: |
| 848 | *se = "away"; | |
| 849 | break; | |
| 850 | case JABBER_STATE_CHAT: | |
| 851 | *se = "chat"; | |
| 852 | break; | |
| 853 | case JABBER_STATE_XA: | |
| 854 | *se = "extendedaway"; | |
| 855 | break; | |
| 856 | case JABBER_STATE_DND: | |
| 8193 | 857 | *se = "dnd"; |
| 7014 | 858 | break; |
| 859 | case JABBER_STATE_ERROR: | |
| 860 | *se = "error"; | |
| 861 | break; | |
| 4916 | 862 | } |
| 2086 | 863 | } |
| 4916 | 864 | } |
| 2086 | 865 | |
| 7014 | 866 | static char *jabber_status_text(GaimBuddy *b) |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
867 | { |
| 7014 | 868 | JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
| 869 | FALSE); | |
| 870 | char *ret = NULL; | |
| 5234 | 871 | |
| 7014 | 872 | if(jb && !GAIM_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { |
| 873 | ret = g_strdup(_("Not Authorized")); | |
| 874 | } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
| 875 | ret = g_strdup(jb->error_msg); | |
| 2956 | 876 | } else { |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
877 | char *stripped; |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
878 | |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
879 | stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)); |
| 2956 | 880 | |
| 7014 | 881 | if(!stripped && b->uc & UC_UNAVAILABLE) |
| 882 | stripped = g_strdup(jabber_get_state_string(b->uc)); | |
| 2086 | 883 | |
| 7014 | 884 | if(stripped) { |
| 885 | ret = g_markup_escape_text(stripped, -1); | |
| 886 | g_free(stripped); | |
| 887 | } | |
| 2086 | 888 | } |
| 889 | ||
| 7014 | 890 | return ret; |
| 2956 | 891 | } |
| 892 | ||
| 6695 | 893 | static char *jabber_tooltip_text(GaimBuddy *b) |
| 4744 | 894 | { |
| 7014 | 895 | JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
| 896 | FALSE); | |
| 8194 | 897 | GString *ret = g_string_new(""); |
| 7014 | 898 | |
| 8194 | 899 | if(jb) { |
| 900 | JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL); | |
| 901 | const char *sub; | |
| 902 | if(jb->subscription & JABBER_SUB_FROM) { | |
| 903 | if(jb->subscription & JABBER_SUB_TO) | |
| 904 | sub = _("Both"); | |
| 905 | else if(jb->subscription & JABBER_SUB_PENDING) | |
| 906 | sub = _("From (To pending)"); | |
| 907 | else | |
| 908 | sub = _("From"); | |
| 909 | } else { | |
| 910 | if(jb->subscription & JABBER_SUB_TO) | |
| 911 | sub = _("To"); | |
| 912 | else if(jb->subscription & JABBER_SUB_PENDING) | |
| 913 | sub = _("None (To pending)"); | |
| 914 | else | |
| 915 | sub = _("None"); | |
| 916 | } | |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
917 | g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Subscription"), sub); |
| 8194 | 918 | |
| 919 | if(jbr) { | |
| 920 | char *text = NULL; | |
| 921 | if(jbr->status) { | |
| 922 | char *stripped; | |
| 923 | stripped = gaim_markup_strip_html(jbr->status); | |
| 924 | text = g_markup_escape_text(stripped, -1); | |
| 925 | g_free(stripped); | |
| 926 | } | |
| 927 | ||
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
928 | g_string_append_printf(ret, "\n<b>%s:</b> %s%s%s", |
| 8194 | 929 | _("Status"), |
| 930 | jabber_get_state_string(jbr->state), | |
| 931 | text ? ": " : "", | |
| 932 | text ? text : ""); | |
| 933 | if(text) | |
| 934 | g_free(text); | |
| 935 | } else if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
936 | g_string_append_printf(ret, "\n<b>%s:</b> %s", |
| 8194 | 937 | _("Error"), jb->error_msg); |
| 938 | } | |
| 4745 | 939 | } |
| 4744 | 940 | |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
941 | return g_string_free(ret, FALSE); |
| 4732 | 942 | } |
| 943 | ||
| 7014 | 944 | static GList *jabber_away_states(GaimConnection *gc) |
| 945 | { | |
| 8166 | 946 | JabberStream *js = gc->proto_data; |
| 2086 | 947 | GList *m = NULL; |
| 948 | ||
| 4982 | 949 | m = g_list_append(m, _("Online")); |
| 950 | m = g_list_append(m, _("Chatty")); | |
| 951 | m = g_list_append(m, _("Away")); | |
| 952 | m = g_list_append(m, _("Extended Away")); | |
| 953 | m = g_list_append(m, _("Do Not Disturb")); | |
| 8166 | 954 | if(js->protocol_version == JABBER_PROTO_0_9) |
| 955 | m = g_list_append(m, _("Invisible")); | |
|
4110
481c7ea9e258
[gaim-migrate @ 4325]
Robert McQueen <robot101@debian.org>
parents:
4074
diff
changeset
|
956 | m = g_list_append(m, GAIM_AWAY_CUSTOM); |
| 2086 | 957 | |
| 958 | return m; | |
| 959 | } | |
| 960 | ||
| 7395 | 961 | static void |
| 962 | jabber_password_change_result_cb(JabberStream *js, xmlnode *packet, | |
| 963 | gpointer data) | |
| 7124 | 964 | { |
| 965 | const char *type; | |
| 966 | ||
| 967 | type = xmlnode_get_attrib(packet, "type"); | |
| 968 | ||
| 969 | if(!strcmp(type, "result")) { | |
| 970 | gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"), | |
| 971 | _("Your password has been changed.")); | |
| 972 | } else { | |
| 8401 | 973 | char *msg = jabber_parse_error(js, packet); |
| 7124 | 974 | |
| 8401 | 975 | gaim_notify_error(js->gc, _("Error changing password"), |
| 976 | _("Error changing password"), msg); | |
| 977 | g_free(msg); | |
| 7124 | 978 | } |
| 979 | } | |
| 980 | ||
| 981 | static void jabber_password_change_cb(JabberStream *js, | |
| 982 | GaimRequestFields *fields) | |
| 983 | { | |
| 984 | const char *p1, *p2; | |
| 985 | JabberIq *iq; | |
| 986 | xmlnode *query, *y; | |
| 987 | ||
| 988 | p1 = gaim_request_fields_get_string(fields, "password1"); | |
| 989 | p2 = gaim_request_fields_get_string(fields, "password2"); | |
| 990 | ||
| 991 | if(strcmp(p1, p2)) { | |
| 992 | gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); | |
| 993 | return; | |
| 994 | } | |
| 995 | ||
| 996 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 997 | ||
| 998 | xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
| 999 | ||
| 1000 | query = xmlnode_get_child(iq->node, "query"); | |
| 1001 | ||
| 1002 | y = xmlnode_new_child(query, "username"); | |
| 1003 | xmlnode_insert_data(y, js->user->node, -1); | |
| 1004 | y = xmlnode_new_child(query, "password"); | |
| 1005 | xmlnode_insert_data(y, p1, -1); | |
| 1006 | ||
| 7395 | 1007 | jabber_iq_set_callback(iq, jabber_password_change_result_cb, NULL); |
| 7124 | 1008 | |
| 1009 | jabber_iq_send(iq); | |
| 1010 | ||
| 1011 | gaim_account_set_password(js->gc->account, p1); | |
| 1012 | } | |
| 1013 | ||
| 1014 | static void jabber_password_change(GaimConnection *gc) | |
| 1015 | { | |
| 1016 | JabberStream *js = gc->proto_data; | |
| 1017 | GaimRequestFields *fields; | |
| 1018 | GaimRequestFieldGroup *group; | |
| 1019 | GaimRequestField *field; | |
| 1020 | ||
| 1021 | fields = gaim_request_fields_new(); | |
| 1022 | group = gaim_request_field_group_new(NULL); | |
| 1023 | gaim_request_fields_add_group(fields, group); | |
| 1024 | ||
| 1025 | field = gaim_request_field_string_new("password1", _("Password"), | |
| 1026 | "", FALSE); | |
| 1027 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1028 | gaim_request_field_group_add_field(group, field); | |
| 1029 | ||
| 1030 | field = gaim_request_field_string_new("password2", _("Password (again)"), | |
| 1031 | "", FALSE); | |
| 1032 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1033 | gaim_request_field_group_add_field(group, field); | |
| 1034 | ||
| 1035 | gaim_request_fields(js->gc, _("Change Jabber Password"), | |
| 1036 | _("Change Jabber Password"), _("Please enter your new password"), | |
| 1037 | fields, _("OK"), G_CALLBACK(jabber_password_change_cb), | |
| 1038 | _("Cancel"), NULL, js); | |
| 1039 | } | |
| 1040 | ||
| 5572 | 1041 | static GList *jabber_actions(GaimConnection *gc) |
| 2956 | 1042 | { |
| 1043 | GList *m = NULL; | |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1044 | struct proto_actions_menu *pam; |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1045 | |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1046 | pam = g_new0(struct proto_actions_menu, 1); |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1047 | pam->label = _("Set User Info"); |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1048 | pam->callback = jabber_setup_set_info; |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1049 | pam->gc = gc; |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1050 | m = g_list_append(m, pam); |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1051 | |
| 8296 | 1052 | /* if (js->protocol_options & CHANGE_PASSWORD) { */ |
| 7124 | 1053 | pam = g_new0(struct proto_actions_menu, 1); |
| 1054 | pam->label = _("Change Password"); | |
| 1055 | pam->callback = jabber_password_change; | |
| 1056 | pam->gc = gc; | |
| 1057 | m = g_list_append(m, pam); | |
| 8296 | 1058 | /* } */ |
| 2956 | 1059 | |
| 1060 | return m; | |
| 1061 | } | |
| 1062 | ||
| 7999 | 1063 | static GaimChat *jabber_find_blist_chat(GaimAccount *account, const char *name) |
| 1064 | { | |
| 1065 | GaimBlistNode *gnode, *cnode; | |
| 1066 | JabberID *jid; | |
| 1067 | ||
| 1068 | if(!(jid = jabber_id_new(name))) | |
| 1069 | return NULL; | |
| 1070 | ||
| 1071 | for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
| 1072 | for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
| 1073 | GaimChat *chat = (GaimChat*)cnode; | |
| 1074 | const char *room, *server; | |
| 1075 | if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
| 1076 | continue; | |
| 1077 | ||
| 1078 | if(chat->account != account) | |
| 8011 | 1079 | continue; |
| 7999 | 1080 | |
| 1081 | if(!(room = g_hash_table_lookup(chat->components, "room"))) | |
| 1082 | continue; | |
| 1083 | if(!(server = g_hash_table_lookup(chat->components, "server"))) | |
| 1084 | continue; | |
| 1085 | ||
| 8158 | 1086 | if(jid->node && jid->domain && |
| 1087 | !g_utf8_collate(room, jid->node) && !g_utf8_collate(server, jid->domain)) { | |
| 7999 | 1088 | jabber_id_free(jid); |
| 1089 | return chat; | |
| 1090 | } | |
| 1091 | } | |
| 1092 | } | |
| 1093 | jabber_id_free(jid); | |
| 1094 | return NULL; | |
| 1095 | } | |
| 1096 | ||
| 8400 | 1097 | static void jabber_convo_closed(GaimConnection *gc, const char *who) |
| 1098 | { | |
| 1099 | JabberStream *js = gc->proto_data; | |
| 1100 | JabberID *jid; | |
| 1101 | JabberBuddy *jb; | |
| 1102 | JabberBuddyResource *jbr; | |
| 1103 | ||
| 1104 | if(!(jid = jabber_id_new(who))) | |
| 1105 | return; | |
| 1106 | ||
| 1107 | if((jb = jabber_buddy_find(js, who, TRUE)) && | |
| 1108 | (jbr = jabber_buddy_find_resource(jb, jid->resource))) { | |
| 1109 | if(jbr->thread_id) { | |
| 1110 | g_free(jbr->thread_id); | |
| 1111 | jbr->thread_id = NULL; | |
| 1112 | } | |
| 1113 | } | |
| 1114 | ||
| 1115 | jabber_id_free(jid); | |
| 1116 | } | |
| 1117 | ||
| 8401 | 1118 | |
| 1119 | char *jabber_parse_error(JabberStream *js, xmlnode *packet) | |
| 1120 | { | |
| 1121 | xmlnode *error; | |
| 1122 | const char *code = NULL, *text = NULL; | |
| 1123 | const char *xmlns = xmlnode_get_attrib(packet, "xmlns"); | |
| 1124 | char *cdata = NULL; | |
| 1125 | ||
| 1126 | if((error = xmlnode_get_child(packet, "error"))) { | |
| 1127 | cdata = xmlnode_get_data(error); | |
| 1128 | code = xmlnode_get_attrib(error, "code"); | |
| 1129 | ||
| 1130 | /* Stanza errors */ | |
| 1131 | if(xmlnode_get_child(error, "bad-request")) { | |
| 1132 | text = _("Bad Request"); | |
| 1133 | } else if(xmlnode_get_child(error, "conflict")) { | |
| 1134 | text = _("Conflict"); | |
| 1135 | } else if(xmlnode_get_child(error, "feature-not-implemented")) { | |
| 1136 | text = _("Feature Not Implemented"); | |
| 1137 | } else if(xmlnode_get_child(error, "forbidden")) { | |
| 1138 | text = _("Forbidden"); | |
| 1139 | } else if(xmlnode_get_child(error, "gone")) { | |
| 1140 | text = _("Gone"); | |
| 1141 | } else if(xmlnode_get_child(error, "internal-server-error")) { | |
| 1142 | text = _("Internal Server Error"); | |
| 1143 | } else if(xmlnode_get_child(error, "item-not-found")) { | |
| 1144 | text = _("Item Not Found"); | |
| 1145 | } else if(xmlnode_get_child(error, "jid-malformed")) { | |
| 1146 | text = _("Malformed Jabber ID"); | |
| 1147 | } else if(xmlnode_get_child(error, "not-acceptable")) { | |
| 1148 | text = _("Not Acceptable"); | |
| 1149 | } else if(xmlnode_get_child(error, "not-allowed")) { | |
| 1150 | text = _("Not Allowed"); | |
| 1151 | } else if(xmlnode_get_child(error, "not-authorized")) { | |
| 1152 | text = _("Not Authorized"); | |
| 1153 | } else if(xmlnode_get_child(error, "payment-required")) { | |
| 1154 | text = _("Payment Required"); | |
| 1155 | } else if(xmlnode_get_child(error, "recipient-unavailable")) { | |
| 1156 | text = _("Recipient Unavailable"); | |
| 1157 | } else if(xmlnode_get_child(error, "redirect")) { | |
| 1158 | /* XXX */ | |
| 1159 | } else if(xmlnode_get_child(error, "registration-required")) { | |
| 1160 | text = _("Registration Required"); | |
| 1161 | } else if(xmlnode_get_child(error, "remote-server-not-found")) { | |
| 1162 | text = _("Remote Server Not Found"); | |
| 1163 | } else if(xmlnode_get_child(error, "remote-server-timeout")) { | |
| 1164 | text = _("Remote Server Timeout"); | |
| 1165 | } else if(xmlnode_get_child(error, "resource-constraint")) { | |
| 1166 | text = _("Server Overloaded"); | |
| 1167 | } else if(xmlnode_get_child(error, "service-unavailable")) { | |
| 1168 | text = _("Service Unavailable"); | |
| 1169 | } else if(xmlnode_get_child(error, "subscription-required")) { | |
| 1170 | text = _("Subscription Required"); | |
| 1171 | } else if(xmlnode_get_child(error, "unexpected-request")) { | |
| 1172 | text = _("Unexpected Request"); | |
| 1173 | } else if(xmlnode_get_child(error, "undefined-condition")) { | |
| 1174 | text = _("Unknown Error"); | |
| 1175 | } | |
| 1176 | } else if(xmlns && !strcmp(xmlns, "urn:ietf:params:xml:ns:xmpp-sasl")) { | |
| 1177 | if(xmlnode_get_child(packet, "aborted")) { | |
| 1178 | js->gc->wants_to_die = TRUE; | |
| 1179 | text = _("Authorization Aborted"); | |
| 1180 | } else if(xmlnode_get_child(error, "incorrect-encoding")) { | |
| 1181 | text = _("Incorrect encoding in authorization"); | |
| 1182 | } else if(xmlnode_get_child(error, "invalid-authzid")) { | |
| 1183 | js->gc->wants_to_die = TRUE; | |
| 1184 | text = _("Invalid authzid"); | |
| 1185 | } else if(xmlnode_get_child(error, "invalid-mechanism")) { | |
| 1186 | js->gc->wants_to_die = TRUE; | |
| 1187 | text = _("Invalid Authorization Mechanism"); | |
| 1188 | } else if(xmlnode_get_child(error, "mechanism-too-weak")) { | |
| 1189 | js->gc->wants_to_die = TRUE; | |
| 1190 | text = _("Authorization mechanism too weak"); | |
| 1191 | } else if(xmlnode_get_child(error, "not-authorized")) { | |
| 1192 | js->gc->wants_to_die = TRUE; | |
| 1193 | text = _("Not Authorized"); | |
| 1194 | } else if(xmlnode_get_child(error, "temporary-auth-failure")) { | |
| 1195 | text = _("Temporary Authentication Failure"); | |
| 1196 | } else { | |
| 1197 | text = _("Authentication Failure"); | |
| 1198 | } | |
| 8402 | 1199 | } else if(!strcmp(packet->name, "stream:error")) { |
| 1200 | if(xmlnode_get_child(packet, "bad-format")) { | |
| 1201 | text = _("Bad Format"); | |
| 1202 | } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) { | |
| 1203 | text = _("Bad Namespace Prefix"); | |
| 1204 | } else if(xmlnode_get_child(packet, "conflict")) { | |
| 1205 | js->gc->wants_to_die = TRUE; | |
| 1206 | text = _("Resource Conflict"); | |
| 1207 | } else if(xmlnode_get_child(packet, "connection-timeout")) { | |
| 1208 | text = _("Connection Timeout"); | |
| 1209 | } else if(xmlnode_get_child(packet, "host-gone")) { | |
| 1210 | text = _("Host Gone"); | |
| 1211 | } else if(xmlnode_get_child(packet, "host-unknown")) { | |
| 1212 | text = _("Host Unknown"); | |
| 1213 | } else if(xmlnode_get_child(packet, "improper-addressing")) { | |
| 1214 | text = _("Improper Addressing"); | |
| 1215 | } else if(xmlnode_get_child(packet, "internal-server-error")) { | |
| 1216 | text = _("Internal Server Error"); | |
| 1217 | } else if(xmlnode_get_child(packet, "invalid-id")) { | |
| 1218 | text = _("Invalid ID"); | |
| 1219 | } else if(xmlnode_get_child(packet, "invalid-namespace")) { | |
| 1220 | text = _("Invalid Namespace"); | |
| 1221 | } else if(xmlnode_get_child(packet, "invalid-xml")) { | |
| 1222 | text = _("Invalid XML"); | |
| 1223 | } else if(xmlnode_get_child(packet, "nonmatching-hosts")) { | |
| 1224 | text = _("Non-matching Hosts"); | |
| 1225 | } else if(xmlnode_get_child(packet, "not-authorized")) { | |
| 1226 | text = _("Not Authorized"); | |
| 1227 | } else if(xmlnode_get_child(packet, "policy-violation")) { | |
| 1228 | text = _("Policy Violation"); | |
| 1229 | } else if(xmlnode_get_child(packet, "remote-connection-failed")) { | |
| 1230 | text = _("Remote Connection Failed"); | |
| 1231 | } else if(xmlnode_get_child(packet, "resource-constraint")) { | |
| 1232 | text = _("Resource Constraint"); | |
| 1233 | } else if(xmlnode_get_child(packet, "restricted-xml")) { | |
| 1234 | text = _("Restricted XML"); | |
| 1235 | } else if(xmlnode_get_child(packet, "see-other-host")) { | |
| 1236 | text = _("See Other Host"); | |
| 1237 | } else if(xmlnode_get_child(packet, "system-shutdown")) { | |
| 1238 | text = _("System Shutdown"); | |
| 1239 | } else if(xmlnode_get_child(packet, "undefined-condition")) { | |
| 1240 | text = _("Undefined Condition"); | |
| 1241 | } else if(xmlnode_get_child(packet, "unsupported-encoding")) { | |
| 1242 | text = _("Unsupported Encoding"); | |
| 1243 | } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) { | |
| 1244 | text = _("Unsupported Stanza Type"); | |
| 1245 | } else if(xmlnode_get_child(packet, "unsupported-version")) { | |
| 1246 | text = _("Unsupported Version"); | |
| 1247 | } else if(xmlnode_get_child(packet, "xml-not-well-formed")) { | |
| 1248 | text = _("XML Not Well Formed"); | |
| 1249 | } else { | |
| 1250 | text = _("Stream Error"); | |
| 1251 | } | |
| 8401 | 1252 | } |
| 1253 | ||
| 1254 | if(text || cdata) { | |
| 1255 | char *ret = g_strdup_printf("%s%s%s", code ? code : "", | |
| 1256 | code ? ": " : "", text ? text : cdata); | |
| 1257 | g_free(cdata); | |
| 1258 | return ret; | |
| 1259 | } else { | |
| 1260 | return NULL; | |
| 1261 | } | |
| 1262 | } | |
| 1263 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1264 | static GaimPluginProtocolInfo prpl_info = |
| 2086 | 1265 | { |
| 7014 | 1266 | OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1267 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1268 | NULL, |
| 8170 | 1269 | NULL, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1270 | jabber_list_icon, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1271 | jabber_list_emblems, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1272 | jabber_status_text, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1273 | jabber_tooltip_text, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1274 | jabber_away_states, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1275 | jabber_actions, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1276 | jabber_buddy_menu, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1277 | jabber_chat_info, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1278 | jabber_login, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1279 | jabber_close, |
| 7014 | 1280 | jabber_message_send_im, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1281 | jabber_set_info, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1282 | jabber_send_typing, |
| 7014 | 1283 | jabber_buddy_get_info, |
| 1284 | jabber_presence_send, | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1285 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1286 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1287 | NULL, |
| 7014 | 1288 | jabber_idle_set, |
| 7514 | 1289 | NULL, |
| 7014 | 1290 | jabber_roster_add_buddy, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1291 | NULL, |
| 7014 | 1292 | jabber_roster_remove_buddy, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1293 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1294 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1295 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1296 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1297 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1298 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1299 | NULL, |
| 7014 | 1300 | jabber_chat_join, |
|
8562
7e73676d1772
[gaim-migrate @ 9306]
Christopher O'Brien <siege@pidgin.im>
parents:
8402
diff
changeset
|
1301 | NULL, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1302 | jabber_chat_invite, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1303 | jabber_chat_leave, |
| 7400 | 1304 | NULL, |
| 7014 | 1305 | jabber_message_send_chat, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1306 | jabber_keepalive, |
| 7072 | 1307 | jabber_register_account, |
| 7014 | 1308 | jabber_buddy_get_info_chat, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1309 | NULL, |
| 7014 | 1310 | jabber_roster_alias_change, |
| 1311 | jabber_roster_group_change, | |
| 1312 | jabber_roster_group_rename, | |
| 1313 | NULL, | |
| 8400 | 1314 | jabber_convo_closed, |
| 7398 | 1315 | jabber_normalize, |
| 1316 | NULL, /* set_buddy_icon */ | |
| 1317 | NULL, /* remove_group */ | |
| 7971 | 1318 | jabber_chat_buddy_real_name, |
| 7999 | 1319 | jabber_chat_set_topic, |
| 8113 | 1320 | jabber_find_blist_chat, |
| 1321 | jabber_roomlist_get_list, | |
| 1322 | jabber_roomlist_cancel, | |
|
8586
c8c7a19da549
[gaim-migrate @ 9336]
Pekka Riikonen <priikone@silcnet.org>
parents:
8568
diff
changeset
|
1323 | NULL, |
|
8589
21b3d99bb8e7
[gaim-migrate @ 9340]
Mark Doliner <markdoliner@pidgin.im>
parents:
8586
diff
changeset
|
1324 | NULL |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1325 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1326 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1327 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1328 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1329 | 2, /**< api_version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1330 | GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1331 | NULL, /**< ui_requirement */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1332 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1333 | NULL, /**< dependencies */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1334 | GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1335 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1336 | "prpl-jabber", /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1337 | "Jabber", /**< name */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1338 | VERSION, /**< version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1339 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1340 | N_("Jabber Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1341 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1342 | N_("Jabber Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1343 | NULL, /**< author */ |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
1344 | GAIM_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1345 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1346 | NULL, /**< load */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1347 | NULL, /**< unload */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1348 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1349 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1350 | NULL, /**< ui_info */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1351 | &prpl_info /**< extra_info */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1352 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1353 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1354 | static void |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1355 | init_plugin(GaimPlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1356 | { |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1357 | GaimAccountUserSplit *split; |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1358 | GaimAccountOption *option; |
| 8170 | 1359 | struct proto_pref *ppref; |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1360 | |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1361 | split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1362 | 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
|
1363 | |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1364 | split = gaim_account_user_split_new(_("Resource"), "Gaim", '/'); |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1365 | 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
|
1366 | |
| 7630 | 1367 | option = gaim_account_option_bool_new(_("Use TLS if available"), "use_tls", |
| 1368 | TRUE); | |
| 1369 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 1370 | option); | |
| 1371 | ||
| 1372 | option = gaim_account_option_bool_new(_("Force old SSL"), "old_ssl", FALSE); | |
| 7124 | 1373 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 1374 | option); | |
| 6764 | 1375 | |
| 8086 | 1376 | option = gaim_account_option_bool_new( |
| 1377 | _("Allow plaintext auth over unencrypted streams"), | |
| 1378 | "auth_plain_in_clear", FALSE); | |
| 1379 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 1380 | option); | |
| 1381 | ||
| 7014 | 1382 | option = gaim_account_option_int_new(_("Port"), "port", 5222); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1383 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 7014 | 1384 | option); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1385 | |
|
5685
2523e4143d74
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1386 | option = gaim_account_option_string_new(_("Connect server"), |
| 7014 | 1387 | "connect_server", NULL); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1388 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 7014 | 1389 | option); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1390 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1391 | my_protocol = plugin; |
| 7014 | 1392 | |
| 1393 | gaim_prefs_add_none("/plugins/prpl/jabber"); | |
| 1394 | gaim_prefs_add_bool("/plugins/prpl/jabber/hide_os", FALSE); | |
| 8170 | 1395 | |
| 1396 | ppref = g_new0(struct proto_pref, 1); | |
| 1397 | ppref->key = NULL; | |
| 1398 | ppref->label = _("Privacy"); | |
| 1399 | prpl_info.protocol_prefs = g_list_append(prpl_info.protocol_prefs, ppref); | |
| 1400 | ||
| 1401 | ppref = g_new0(struct proto_pref, 1); | |
| 1402 | ppref->key = "/plugins/prpl/jabber/hide_os"; | |
| 8401 | 1403 | ppref->label = _("Hide Operating System"); |
| 8170 | 1404 | prpl_info.protocol_prefs = g_list_append(prpl_info.protocol_prefs, ppref); |
| 2086 | 1405 | } |
| 1406 | ||
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1407 | GAIM_INIT_PLUGIN(jabber, init_plugin, info); |