Thu, 24 Mar 2005 15:34:20 +0000
[gaim-migrate @ 12319]
i can't remember if the spec changed, or I read it wrong, but this fixes jabber chat away stuff
| 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" | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
25 | #include "blist.h" |
| 9130 | 26 | #include "cmds.h" |
| 7014 | 27 | #include "debug.h" |
| 28 | #include "message.h" | |
| 7072 | 29 | #include "notify.h" |
| 8713 | 30 | #include "pluginpref.h" |
| 7014 | 31 | #include "prpl.h" |
| 7072 | 32 | #include "request.h" |
| 7014 | 33 | #include "server.h" |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
34 | #include "util.h" |
| 9943 | 35 | #include "version.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
36 | |
| 7014 | 37 | #include "auth.h" |
| 38 | #include "buddy.h" | |
| 39 | #include "chat.h" | |
| 8312 | 40 | #include "disco.h" |
| 7014 | 41 | #include "iq.h" |
| 42 | #include "jutil.h" | |
| 43 | #include "message.h" | |
| 44 | #include "parser.h" | |
| 45 | #include "presence.h" | |
| 46 | #include "jabber.h" | |
| 47 | #include "roster.h" | |
|
9466
b6425eab60ca
[gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents:
9414
diff
changeset
|
48 | #include "si.h" |
| 7923 | 49 | #include "xdata.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
50 | |
| 7014 | 51 | #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5) |
| 2086 | 52 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
53 | static GaimPlugin *my_protocol = NULL; |
|
4249
62583b5d3663
[gaim-migrate @ 4499]
Robert McQueen <robot101@debian.org>
parents:
4245
diff
changeset
|
54 | |
| 7014 | 55 | static void jabber_stream_init(JabberStream *js) |
| 56 | { | |
| 57 | char *open_stream; | |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
58 | |
| 7014 | 59 | open_stream = g_strdup_printf("<stream:stream to='%s' " |
| 60 | "xmlns='jabber:client' " | |
| 7395 | 61 | "xmlns:stream='http://etherx.jabber.org/streams' " |
| 62 | "version='1.0'>", | |
| 7291 | 63 | js->user->domain); |
| 3311 | 64 | |
| 7642 | 65 | jabber_send_raw(js, open_stream, -1); |
| 2086 | 66 | |
| 7014 | 67 | g_free(open_stream); |
| 2086 | 68 | } |
| 69 | ||
| 7395 | 70 | static void |
| 71 | jabber_session_initialized_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
| 3311 | 72 | { |
| 7014 | 73 | const char *type = xmlnode_get_attrib(packet, "type"); |
| 74 | if(type && !strcmp(type, "result")) { | |
| 75 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
| 76 | } else { | |
| 77 | gaim_connection_error(js->gc, _("Error initializing session")); | |
| 3311 | 78 | } |
| 79 | } | |
| 80 | ||
| 7014 | 81 | static void jabber_session_init(JabberStream *js) |
| 3311 | 82 | { |
| 7014 | 83 | JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); |
| 84 | xmlnode *session; | |
| 3311 | 85 | |
| 7395 | 86 | jabber_iq_set_callback(iq, jabber_session_initialized_cb, NULL); |
| 3311 | 87 | |
| 7014 | 88 | session = xmlnode_new_child(iq->node, "session"); |
| 89 | xmlnode_set_attrib(session, "xmlns", "urn:ietf:params:xml:ns:xmpp-session"); | |
| 3311 | 90 | |
| 7014 | 91 | jabber_iq_send(iq); |
| 3311 | 92 | } |
| 93 | ||
| 7395 | 94 | static void jabber_bind_result_cb(JabberStream *js, xmlnode *packet, |
| 95 | gpointer data) | |
| 96 | { | |
| 8401 | 97 | const char *type = xmlnode_get_attrib(packet, "type"); |
| 98 | xmlnode *bind; | |
| 99 | ||
| 100 | if(type && !strcmp(type, "result") && | |
| 101 | (bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) { | |
| 102 | xmlnode *jid; | |
| 103 | char *full_jid; | |
| 104 | if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) { | |
| 10289 | 105 | JabberBuddy *my_jb = NULL; |
| 8401 | 106 | jabber_id_free(js->user); |
| 107 | if(!(js->user = jabber_id_new(full_jid))) { | |
| 108 | gaim_connection_error(js->gc, _("Invalid response from server.")); | |
| 109 | } | |
| 10289 | 110 | if((my_jb = jabber_buddy_find(js, full_jid, TRUE))) |
| 111 | my_jb->subscription |= JABBER_SUB_BOTH; | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10490
diff
changeset
|
112 | g_free(full_jid); |
| 8401 | 113 | } |
| 114 | } else { | |
| 115 | char *msg = jabber_parse_error(js, packet); | |
| 116 | gaim_connection_error(js->gc, msg); | |
| 117 | g_free(msg); | |
| 118 | } | |
| 7395 | 119 | |
| 120 | jabber_session_init(js); | |
| 121 | } | |
| 122 | ||
| 123 | static void jabber_stream_features_parse(JabberStream *js, xmlnode *packet) | |
| 124 | { | |
| 8296 | 125 | if(xmlnode_get_child(packet, "starttls")) { |
| 126 | if(jabber_process_starttls(js, packet)) | |
| 127 | return; | |
| 128 | } | |
| 129 | ||
| 7395 | 130 | if(xmlnode_get_child(packet, "mechanisms")) { |
| 131 | jabber_auth_start(js, packet); | |
| 132 | } else if(xmlnode_get_child(packet, "bind")) { | |
| 133 | xmlnode *bind, *resource; | |
| 134 | JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); | |
| 135 | bind = xmlnode_new_child(iq->node, "bind"); | |
| 136 | xmlnode_set_attrib(bind, "xmlns", "urn:ietf:params:xml:ns:xmpp-bind"); | |
| 137 | resource = xmlnode_new_child(bind, "resource"); | |
| 138 | xmlnode_insert_data(resource, js->user->resource, -1); | |
| 139 | ||
| 140 | jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL); | |
| 141 | ||
| 142 | jabber_iq_send(iq); | |
| 8296 | 143 | } else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ { |
| 144 | /* If we get an empty stream:features packet, or we explicitly get | |
| 145 | * an auth feature with namespace http://jabber.org/features/iq-auth | |
| 146 | * we should revert back to iq:auth authentication, even though we're | |
| 147 | * connecting to an XMPP server. */ | |
| 148 | js->auth_type = JABBER_AUTH_IQ_AUTH; | |
| 149 | jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING); | |
| 7395 | 150 | } |
| 151 | } | |
| 152 | ||
| 7014 | 153 | static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet) |
| 3311 | 154 | { |
| 8401 | 155 | char *msg = jabber_parse_error(js, packet); |
| 3311 | 156 | |
| 8401 | 157 | gaim_connection_error(js->gc, msg); |
| 158 | g_free(msg); | |
| 2086 | 159 | } |
| 160 | ||
| 7014 | 161 | static void tls_init(JabberStream *js); |
| 2086 | 162 | |
| 7014 | 163 | void jabber_process_packet(JabberStream *js, xmlnode *packet) |
| 2086 | 164 | { |
| 7014 | 165 | if(!strcmp(packet->name, "iq")) { |
| 7395 | 166 | jabber_iq_parse(js, packet); |
| 7014 | 167 | } else if(!strcmp(packet->name, "presence")) { |
| 168 | jabber_presence_parse(js, packet); | |
| 169 | } else if(!strcmp(packet->name, "message")) { | |
| 170 | jabber_message_parse(js, packet); | |
| 171 | } else if(!strcmp(packet->name, "stream:features")) { | |
| 7395 | 172 | jabber_stream_features_parse(js, packet); |
| 7014 | 173 | } else if(!strcmp(packet->name, "stream:error")) { |
| 174 | jabber_stream_handle_error(js, packet); | |
| 175 | } else if(!strcmp(packet->name, "challenge")) { | |
| 176 | if(js->state == JABBER_STREAM_AUTHENTICATING) | |
| 177 | jabber_auth_handle_challenge(js, packet); | |
| 178 | } else if(!strcmp(packet->name, "success")) { | |
| 179 | if(js->state == JABBER_STREAM_AUTHENTICATING) | |
| 180 | jabber_auth_handle_success(js, packet); | |
| 181 | } else if(!strcmp(packet->name, "failure")) { | |
| 182 | if(js->state == JABBER_STREAM_AUTHENTICATING) | |
| 183 | jabber_auth_handle_failure(js, packet); | |
| 184 | } else if(!strcmp(packet->name, "proceed")) { | |
| 185 | if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc) | |
| 186 | tls_init(js); | |
| 187 | } else { | |
| 188 | gaim_debug(GAIM_DEBUG_WARNING, "jabber", "Unknown packet: %s\n", | |
| 189 | packet->name); | |
| 2086 | 190 | } |
| 191 | } | |
| 192 | ||
| 7642 | 193 | void jabber_send_raw(JabberStream *js, const char *data, int len) |
| 2086 | 194 | { |
| 7014 | 195 | int ret; |
| 2086 | 196 | |
| 7014 | 197 | /* because printing a tab to debug every minute gets old */ |
| 198 | if(strcmp(data, "\t")) | |
| 8401 | 199 | gaim_debug(GAIM_DEBUG_MISC, "jabber", "Sending%s: %s\n", |
| 7014 | 200 | js->gsc ? " (ssl)" : "", data); |
| 2086 | 201 | |
| 7014 | 202 | if(js->gsc) { |
| 7642 | 203 | ret = gaim_ssl_write(js->gsc, data, len == -1 ? strlen(data) : len); |
| 7014 | 204 | } else { |
|
8013
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
205 | if(js->fd < 0) |
|
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
206 | return; |
| 7642 | 207 | ret = write(js->fd, data, len == -1 ? strlen(data) : len); |
|
2814
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
208 | } |
|
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
209 | |
| 7014 | 210 | if(ret < 0) |
| 211 | gaim_connection_error(js->gc, _("Write error")); | |
| 212 | ||
|
2814
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
213 | } |
|
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
214 | |
| 7014 | 215 | void jabber_send(JabberStream *js, xmlnode *packet) |
| 2086 | 216 | { |
| 7014 | 217 | char *txt; |
| 7642 | 218 | int len; |
| 2086 | 219 | |
| 7642 | 220 | txt = xmlnode_to_str(packet, &len); |
| 221 | jabber_send_raw(js, txt, len); | |
| 7014 | 222 | g_free(txt); |
| 2086 | 223 | } |
| 224 | ||
| 7014 | 225 | static void jabber_keepalive(GaimConnection *gc) |
| 2086 | 226 | { |
| 7642 | 227 | jabber_send_raw(gc->proto_data, "\t", -1); |
| 2086 | 228 | } |
| 229 | ||
| 7014 | 230 | static void |
| 231 | jabber_recv_cb_ssl(gpointer data, GaimSslConnection *gsc, | |
| 6764 | 232 | GaimInputCondition cond) |
| 233 | { | |
| 7014 | 234 | GaimConnection *gc = data; |
| 235 | JabberStream *js = gc->proto_data; | |
| 6764 | 236 | int len; |
| 7014 | 237 | static char buf[4096]; |
| 6768 | 238 | |
| 7014 | 239 | if(!g_list_find(gaim_connections_get_all(), gc)) { |
| 6768 | 240 | gaim_ssl_close(gsc); |
| 241 | return; | |
| 242 | } | |
| 243 | ||
| 7014 | 244 | if((len = gaim_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) { |
| 6764 | 245 | buf[len] = '\0'; |
| 7014 | 246 | gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf); |
| 247 | jabber_parser_process(js, buf, len); | |
| 7177 | 248 | } else { |
| 249 | gaim_connection_error(gc, _("Read Error")); | |
| 2086 | 250 | } |
| 251 | } | |
| 252 | ||
| 7014 | 253 | static void |
| 254 | jabber_recv_cb(gpointer data, gint source, GaimInputCondition condition) | |
| 2086 | 255 | { |
| 5572 | 256 | GaimConnection *gc = data; |
| 7014 | 257 | JabberStream *js = gc->proto_data; |
| 258 | int len; | |
| 259 | static char buf[4096]; | |
| 2086 | 260 | |
| 7014 | 261 | if(!g_list_find(gaim_connections_get_all(), gc)) |
| 262 | return; | |
| 2956 | 263 | |
| 7014 | 264 | if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) { |
| 265 | buf[len] = '\0'; | |
| 266 | gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf); | |
| 267 | jabber_parser_process(js, buf, len); | |
| 7177 | 268 | } else { |
| 269 | gaim_connection_error(gc, _("Read Error")); | |
| 7014 | 270 | } |
| 2086 | 271 | } |
| 272 | ||
| 7014 | 273 | static void |
| 274 | jabber_login_callback_ssl(gpointer data, GaimSslConnection *gsc, | |
| 6764 | 275 | GaimInputCondition cond) |
| 276 | { | |
| 277 | GaimConnection *gc = data; | |
| 7014 | 278 | JabberStream *js = gc->proto_data; |
| 6764 | 279 | |
| 7014 | 280 | if(!g_list_find(gaim_connections_get_all(), gc)) { |
| 6764 | 281 | gaim_ssl_close(gsc); |
| 282 | return; | |
| 283 | } | |
| 284 | ||
| 7014 | 285 | js->gsc = gsc; |
| 6764 | 286 | |
| 7014 | 287 | if(js->state == JABBER_STREAM_CONNECTING) |
| 7642 | 288 | jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
| 6764 | 289 | |
| 7014 | 290 | jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
| 291 | gaim_ssl_input_add(gsc, jabber_recv_cb_ssl, gc); | |
| 6764 | 292 | } |
| 293 | ||
| 7014 | 294 | |
| 295 | static void | |
| 296 | jabber_login_callback(gpointer data, gint source, GaimInputCondition cond) | |
| 6764 | 297 | { |
| 5572 | 298 | GaimConnection *gc = data; |
| 7014 | 299 | JabberStream *js = gc->proto_data; |
| 2086 | 300 | |
|
8783
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
301 | if (source < 0) { |
|
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
302 | gaim_connection_error(gc, _("Couldn't connect to host")); |
|
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
303 | return; |
|
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
304 | } |
|
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
305 | |
| 7014 | 306 | if(!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 307 | close(source); |
| 308 | return; | |
| 309 | } | |
| 310 | ||
| 7014 | 311 | js->fd = source; |
| 2956 | 312 | |
| 7014 | 313 | if(js->state == JABBER_STREAM_CONNECTING) |
| 7642 | 314 | jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
|
2300
06a3c10f4918
[gaim-migrate @ 2310]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2289
diff
changeset
|
315 | |
| 7014 | 316 | jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
| 317 | gc->inpa = gaim_input_add(js->fd, GAIM_INPUT_READ, jabber_recv_cb, gc); | |
| 318 | } | |
| 2086 | 319 | |
| 7014 | 320 | static void |
| 7426 | 321 | jabber_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, |
| 322 | gpointer data) | |
| 323 | { | |
| 324 | GaimConnection *gc = data; | |
| 8360 | 325 | JabberStream *js = gc->proto_data; |
| 7426 | 326 | |
| 327 | switch(error) { | |
| 8362 | 328 | case GAIM_SSL_CONNECT_FAILED: |
| 329 | gaim_connection_error(gc, _("Connection Failed")); | |
| 330 | break; | |
| 7426 | 331 | case GAIM_SSL_HANDSHAKE_FAILED: |
| 332 | gaim_connection_error(gc, _("SSL Handshake Failed")); | |
| 333 | break; | |
| 334 | } | |
| 8360 | 335 | |
| 336 | js->gsc = NULL; | |
| 7426 | 337 | } |
| 338 | ||
| 7427 | 339 | static void tls_init(JabberStream *js) |
| 340 | { | |
| 341 | gaim_input_remove(js->gc->inpa); | |
| 342 | js->gc->inpa = 0; | |
| 343 | js->gsc = gaim_ssl_connect_fd(js->gc->account, js->fd, | |
| 344 | jabber_login_callback_ssl, jabber_ssl_connect_failure, js->gc); | |
| 345 | } | |
| 346 | ||
| 347 | ||
| 7426 | 348 | static void |
|
10401
51ae616ff395
[gaim-migrate @ 11638]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10289
diff
changeset
|
349 | jabber_login(GaimAccount *account, GaimStatus *status) |
| 2086 | 350 | { |
| 7014 | 351 | int rc; |
| 352 | GaimConnection *gc = gaim_account_get_connection(account); | |
| 353 | const char *connect_server = gaim_account_get_string(account, | |
| 354 | "connect_server", ""); | |
| 5572 | 355 | const char *server; |
| 7014 | 356 | JabberStream *js; |
| 10289 | 357 | JabberBuddy *my_jb = NULL; |
| 2086 | 358 | |
| 7014 | 359 | gc->flags |= GAIM_CONNECTION_HTML; |
| 360 | js = gc->proto_data = g_new0(JabberStream, 1); | |
| 361 | js->gc = gc; | |
|
8013
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
362 | js->fd = -1; |
| 8312 | 363 | js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 364 | g_free, g_free); | |
| 365 | js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 7395 | 366 | g_free, g_free); |
| 7014 | 367 | js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 7116 | 368 | g_free, (GDestroyNotify)jabber_buddy_free); |
| 7014 | 369 | js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 8396 | 370 | g_free, (GDestroyNotify)jabber_chat_free); |
| 8043 | 371 | js->chat_servers = g_list_append(NULL, g_strdup("conference.jabber.org")); |
| 7014 | 372 | js->user = jabber_id_new(gaim_account_get_username(account)); |
| 7322 | 373 | js->next_id = g_random_int(); |
| 5613 | 374 | |
| 7310 | 375 | if(!js->user) { |
| 376 | gaim_connection_error(gc, _("Invalid Jabber ID")); | |
| 377 | return; | |
| 378 | } | |
| 379 | ||
| 7147 | 380 | if(!js->user->resource) { |
| 381 | char *me; | |
| 382 | js->user->resource = g_strdup("Gaim"); | |
| 383 | if(!js->user->node) { | |
| 384 | js->user->node = js->user->domain; | |
| 385 | js->user->domain = g_strdup("jabber.org"); | |
| 386 | } | |
| 387 | me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
| 388 | js->user->resource); | |
| 389 | gaim_account_set_username(account, me); | |
| 390 | g_free(me); | |
| 7145 | 391 | } |
| 392 | ||
| 10289 | 393 | if((my_jb = jabber_buddy_find(js, gaim_account_get_username(account), TRUE))) |
| 394 | my_jb->subscription |= JABBER_SUB_BOTH; | |
| 395 | ||
| 7014 | 396 | server = connect_server[0] ? connect_server : js->user->domain; |
| 2086 | 397 | |
| 7014 | 398 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); |
| 2956 | 399 | |
| 7630 | 400 | |
| 401 | if(gaim_account_get_bool(account, "old_ssl", FALSE)) { | |
| 402 | if(gaim_ssl_is_supported()) { | |
| 403 | js->gsc = gaim_ssl_connect(account, server, | |
| 404 | gaim_account_get_int(account, "port", 5222), | |
| 405 | jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); | |
| 406 | } else { | |
| 407 | gaim_connection_error(gc, _("SSL support unavailable")); | |
| 408 | } | |
| 3311 | 409 | } |
| 3770 | 410 | |
| 7014 | 411 | if(!js->gsc) { |
| 412 | rc = gaim_proxy_connect(account, server, | |
| 413 | gaim_account_get_int(account, "port", 5222), | |
| 414 | jabber_login_callback, gc); | |
| 2086 | 415 | |
| 7014 | 416 | if (rc != 0) |
| 417 | gaim_connection_error(gc, _("Unable to create socket")); | |
| 2956 | 418 | } |
| 2086 | 419 | } |
| 420 | ||
| 7072 | 421 | static gboolean |
| 422 | conn_close_cb(gpointer data) | |
| 423 | { | |
| 424 | JabberStream *js = data; | |
| 425 | gaim_connection_destroy(js->gc); | |
| 426 | return FALSE; | |
| 427 | } | |
| 428 | ||
| 429 | static void | |
| 430 | jabber_connection_schedule_close(JabberStream *js) | |
| 431 | { | |
| 8273 | 432 | gaim_timeout_add(0, conn_close_cb, js); |
| 7072 | 433 | } |
| 434 | ||
| 435 | static void | |
| 7395 | 436 | jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
| 7072 | 437 | { |
| 438 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 439 | char *buf; | |
| 440 | ||
| 441 | if(!strcmp(type, "result")) { | |
| 442 | buf = g_strdup_printf(_("Registration of %s@%s successful"), | |
| 443 | js->user->node, js->user->domain); | |
| 444 | gaim_notify_info(NULL, _("Registration Successful"), | |
| 445 | _("Registration Successful"), buf); | |
| 446 | g_free(buf); | |
| 447 | } else { | |
| 8401 | 448 | char *msg = jabber_parse_error(js, packet); |
| 7072 | 449 | |
| 8401 | 450 | if(!msg) |
| 451 | msg = g_strdup(_("Unknown Error")); | |
| 7072 | 452 | |
| 453 | gaim_notify_error(NULL, _("Registration Failed"), | |
| 8401 | 454 | _("Registration Failed"), msg); |
| 455 | g_free(msg); | |
| 7072 | 456 | } |
| 457 | jabber_connection_schedule_close(js); | |
| 458 | } | |
| 459 | ||
| 460 | static void | |
| 461 | jabber_register_cb(JabberStream *js, GaimRequestFields *fields) | |
| 462 | { | |
| 463 | GList *groups, *flds; | |
| 464 | xmlnode *query, *y; | |
| 465 | JabberIq *iq; | |
| 7264 | 466 | char *username; |
| 7072 | 467 | |
| 468 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 469 | query = xmlnode_get_child(iq->node, "query"); | |
| 470 | ||
| 471 | for(groups = gaim_request_fields_get_groups(fields); groups; | |
| 472 | groups = groups->next) { | |
| 473 | for(flds = gaim_request_field_group_get_fields(groups->data); | |
| 474 | flds; flds = flds->next) { | |
| 475 | GaimRequestField *field = flds->data; | |
| 476 | const char *id = gaim_request_field_get_id(field); | |
| 477 | const char *value = gaim_request_field_string_get_value(field); | |
| 478 | ||
| 479 | if(!strcmp(id, "username")) { | |
| 480 | y = xmlnode_new_child(query, "username"); | |
| 481 | } else if(!strcmp(id, "password")) { | |
| 482 | y = xmlnode_new_child(query, "password"); | |
| 483 | } else if(!strcmp(id, "name")) { | |
| 484 | y = xmlnode_new_child(query, "name"); | |
| 485 | } else if(!strcmp(id, "email")) { | |
| 486 | y = xmlnode_new_child(query, "email"); | |
| 487 | } else if(!strcmp(id, "nick")) { | |
| 488 | y = xmlnode_new_child(query, "nick"); | |
| 489 | } else if(!strcmp(id, "first")) { | |
| 490 | y = xmlnode_new_child(query, "first"); | |
| 491 | } else if(!strcmp(id, "last")) { | |
| 492 | y = xmlnode_new_child(query, "last"); | |
| 493 | } else if(!strcmp(id, "address")) { | |
| 494 | y = xmlnode_new_child(query, "address"); | |
| 495 | } else if(!strcmp(id, "city")) { | |
| 496 | y = xmlnode_new_child(query, "city"); | |
| 497 | } else if(!strcmp(id, "state")) { | |
| 498 | y = xmlnode_new_child(query, "state"); | |
| 499 | } else if(!strcmp(id, "zip")) { | |
| 500 | y = xmlnode_new_child(query, "zip"); | |
| 501 | } else if(!strcmp(id, "phone")) { | |
| 502 | y = xmlnode_new_child(query, "phone"); | |
| 503 | } else if(!strcmp(id, "url")) { | |
| 504 | y = xmlnode_new_child(query, "url"); | |
| 505 | } else if(!strcmp(id, "date")) { | |
| 506 | y = xmlnode_new_child(query, "date"); | |
| 507 | } else { | |
| 508 | continue; | |
| 509 | } | |
| 510 | xmlnode_insert_data(y, value, -1); | |
| 7264 | 511 | if(!strcmp(id, "username")) { |
| 512 | if(js->user->node) | |
| 513 | g_free(js->user->node); | |
| 514 | js->user->node = g_strdup(value); | |
| 515 | } | |
| 7072 | 516 | } |
| 517 | } | |
| 518 | ||
| 7264 | 519 | username = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, |
| 520 | js->user->resource); | |
| 521 | gaim_account_set_username(js->gc->account, username); | |
| 522 | g_free(username); | |
| 523 | ||
| 7395 | 524 | jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); |
| 7072 | 525 | |
| 526 | jabber_iq_send(iq); | |
| 527 | ||
| 528 | } | |
| 529 | ||
| 530 | static void | |
| 531 | jabber_register_cancel_cb(JabberStream *js, GaimRequestFields *fields) | |
| 532 | { | |
| 533 | jabber_connection_schedule_close(js); | |
| 534 | } | |
| 535 | ||
| 7923 | 536 | static void jabber_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
| 537 | { | |
| 538 | xmlnode *query; | |
| 539 | JabberIq *iq; | |
| 540 | ||
| 541 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 542 | query = xmlnode_get_child(iq->node, "query"); | |
| 543 | ||
| 544 | xmlnode_insert_child(query, result); | |
| 545 | ||
| 546 | jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); | |
| 547 | jabber_iq_send(iq); | |
| 548 | } | |
| 549 | ||
| 7072 | 550 | void jabber_register_parse(JabberStream *js, xmlnode *packet) |
| 551 | { | |
| 552 | if(js->registration) { | |
| 553 | GaimRequestFields *fields; | |
| 554 | GaimRequestFieldGroup *group; | |
| 555 | GaimRequestField *field; | |
| 7923 | 556 | xmlnode *query, *x, *y; |
| 7072 | 557 | char *instructions; |
| 558 | ||
| 559 | /* get rid of the login thingy */ | |
| 560 | gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
| 561 | ||
| 562 | query = xmlnode_get_child(packet, "query"); | |
| 563 | ||
| 564 | if(xmlnode_get_child(query, "registered")) { | |
| 565 | gaim_notify_error(NULL, _("Already Registered"), | |
| 566 | _("Already Registered"), NULL); | |
| 567 | jabber_connection_schedule_close(js); | |
| 568 | return; | |
| 569 | } | |
| 570 | ||
| 8398 | 571 | if((x = xmlnode_get_child_with_namespace(packet, "x", |
| 572 | "jabber:x:data"))) { | |
| 573 | jabber_x_data_request(js, x, jabber_register_x_data_cb, NULL); | |
| 574 | return; | |
| 575 | } else if((x = xmlnode_get_child_with_namespace(packet, "x", | |
| 576 | "jabber:x:oob"))) { | |
| 577 | xmlnode *url; | |
| 7923 | 578 | |
| 8398 | 579 | if((url = xmlnode_get_child(x, "url"))) { |
| 580 | char *href; | |
| 581 | if((href = xmlnode_get_data(url))) { | |
|
10240
09342bc554d9
[gaim-migrate @ 11377]
Herman Bloggs <herman@bluedigits.com>
parents:
10216
diff
changeset
|
582 | gaim_notify_uri(NULL, href); |
| 8398 | 583 | g_free(href); |
| 584 | js->gc->wants_to_die = TRUE; | |
| 585 | jabber_connection_schedule_close(js); | |
| 586 | return; | |
| 587 | } | |
| 7923 | 588 | } |
| 589 | } | |
| 590 | ||
| 591 | /* as a last resort, use the old jabber:iq:register syntax */ | |
| 592 | ||
| 7072 | 593 | fields = gaim_request_fields_new(); |
| 594 | group = gaim_request_field_group_new(NULL); | |
| 595 | gaim_request_fields_add_group(fields, group); | |
| 596 | ||
| 597 | field = gaim_request_field_string_new("username", _("Username"), | |
| 598 | js->user->node, FALSE); | |
| 599 | gaim_request_field_group_add_field(group, field); | |
| 600 | ||
| 601 | field = gaim_request_field_string_new("password", _("Password"), | |
| 602 | gaim_account_get_password(js->gc->account), FALSE); | |
| 603 | gaim_request_field_string_set_masked(field, TRUE); | |
| 604 | gaim_request_field_group_add_field(group, field); | |
| 605 | ||
| 606 | if(xmlnode_get_child(query, "name")) { | |
| 607 | field = gaim_request_field_string_new("name", _("Name"), | |
| 608 | gaim_account_get_alias(js->gc->account), FALSE); | |
| 609 | gaim_request_field_group_add_field(group, field); | |
| 610 | } | |
| 611 | if(xmlnode_get_child(query, "email")) { | |
| 612 | field = gaim_request_field_string_new("email", _("E-Mail"), | |
| 613 | NULL, FALSE); | |
| 614 | gaim_request_field_group_add_field(group, field); | |
| 615 | } | |
| 616 | if(xmlnode_get_child(query, "nick")) { | |
| 617 | field = gaim_request_field_string_new("nick", _("Nickname"), | |
| 618 | NULL, FALSE); | |
| 619 | gaim_request_field_group_add_field(group, field); | |
| 620 | } | |
| 621 | if(xmlnode_get_child(query, "first")) { | |
| 622 | field = gaim_request_field_string_new("first", _("First Name"), | |
| 623 | NULL, FALSE); | |
| 624 | gaim_request_field_group_add_field(group, field); | |
| 625 | } | |
| 626 | if(xmlnode_get_child(query, "last")) { | |
| 627 | field = gaim_request_field_string_new("last", _("Last Name"), | |
| 628 | NULL, FALSE); | |
| 629 | gaim_request_field_group_add_field(group, field); | |
| 630 | } | |
| 631 | if(xmlnode_get_child(query, "address")) { | |
| 632 | field = gaim_request_field_string_new("address", _("Address"), | |
| 633 | NULL, FALSE); | |
| 634 | gaim_request_field_group_add_field(group, field); | |
| 635 | } | |
| 636 | if(xmlnode_get_child(query, "city")) { | |
| 637 | field = gaim_request_field_string_new("city", _("City"), | |
| 638 | NULL, FALSE); | |
| 639 | gaim_request_field_group_add_field(group, field); | |
| 640 | } | |
| 641 | if(xmlnode_get_child(query, "state")) { | |
| 642 | field = gaim_request_field_string_new("state", _("State"), | |
| 643 | NULL, FALSE); | |
| 644 | gaim_request_field_group_add_field(group, field); | |
| 645 | } | |
| 646 | if(xmlnode_get_child(query, "zip")) { | |
| 647 | field = gaim_request_field_string_new("zip", _("Postal Code"), | |
| 648 | NULL, FALSE); | |
| 649 | gaim_request_field_group_add_field(group, field); | |
| 650 | } | |
| 651 | if(xmlnode_get_child(query, "phone")) { | |
| 652 | field = gaim_request_field_string_new("phone", _("Phone"), | |
| 653 | NULL, FALSE); | |
| 654 | gaim_request_field_group_add_field(group, field); | |
| 655 | } | |
| 656 | if(xmlnode_get_child(query, "url")) { | |
| 657 | field = gaim_request_field_string_new("url", _("URL"), | |
| 658 | NULL, FALSE); | |
| 659 | gaim_request_field_group_add_field(group, field); | |
| 660 | } | |
| 661 | if(xmlnode_get_child(query, "date")) { | |
| 662 | field = gaim_request_field_string_new("date", _("Date"), | |
| 663 | NULL, FALSE); | |
| 664 | gaim_request_field_group_add_field(group, field); | |
| 665 | } | |
| 666 | ||
| 667 | if((y = xmlnode_get_child(query, "instructions"))) | |
| 668 | instructions = xmlnode_get_data(y); | |
| 669 | else | |
| 670 | instructions = g_strdup(_("Please fill out the information below " | |
| 671 | "to register your new account.")); | |
| 672 | ||
| 673 | gaim_request_fields(js->gc, _("Register New Jabber Account"), | |
| 674 | _("Register New Jabber Account"), instructions, fields, | |
| 675 | _("Register"), G_CALLBACK(jabber_register_cb), | |
| 676 | _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); | |
| 677 | } | |
| 678 | } | |
| 679 | ||
| 8016 | 680 | void jabber_register_start(JabberStream *js) |
| 7072 | 681 | { |
| 682 | JabberIq *iq; | |
| 683 | ||
| 684 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); | |
| 685 | jabber_iq_send(iq); | |
| 686 | } | |
| 687 | ||
| 688 | static void jabber_register_account(GaimAccount *account) | |
| 689 | { | |
| 690 | GaimConnection *gc = gaim_account_get_connection(account); | |
| 691 | JabberStream *js; | |
| 10289 | 692 | JabberBuddy *my_jb = NULL; |
| 7072 | 693 | const char *connect_server = gaim_account_get_string(account, |
| 694 | "connect_server", ""); | |
| 695 | const char *server; | |
| 696 | int rc; | |
| 697 | ||
| 698 | js = gc->proto_data = g_new0(JabberStream, 1); | |
| 699 | js->gc = gc; | |
| 700 | js->registration = TRUE; | |
| 8312 | 701 | js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 702 | g_free, g_free); | |
| 703 | js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 7395 | 704 | g_free, g_free); |
| 7072 | 705 | js->user = jabber_id_new(gaim_account_get_username(account)); |
| 7322 | 706 | js->next_id = g_random_int(); |
| 7072 | 707 | |
| 7310 | 708 | if(!js->user) { |
| 709 | gaim_connection_error(gc, _("Invalid Jabber ID")); | |
| 710 | return; | |
| 711 | } | |
| 712 | ||
| 7147 | 713 | if(!js->user->resource) { |
| 714 | char *me; | |
| 715 | js->user->resource = g_strdup("Gaim"); | |
| 716 | if(!js->user->node) { | |
| 717 | js->user->node = js->user->domain; | |
| 718 | js->user->domain = g_strdup("jabber.org"); | |
| 719 | } | |
| 720 | me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
| 721 | js->user->resource); | |
| 722 | gaim_account_set_username(account, me); | |
| 723 | g_free(me); | |
| 724 | } | |
| 725 | ||
| 10289 | 726 | if((my_jb = jabber_buddy_find(js, gaim_account_get_username(account), TRUE))) |
| 727 | my_jb->subscription |= JABBER_SUB_BOTH; | |
| 728 | ||
| 7072 | 729 | server = connect_server[0] ? connect_server : js->user->domain; |
| 730 | ||
| 731 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); | |
| 732 | ||
| 7630 | 733 | if(gaim_account_get_bool(account, "old_ssl", FALSE)) { |
| 734 | if(gaim_ssl_is_supported()) { | |
| 735 | js->gsc = gaim_ssl_connect(account, server, | |
| 736 | gaim_account_get_int(account, "port", 5222), | |
| 737 | jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); | |
| 738 | } else { | |
| 739 | gaim_connection_error(gc, _("SSL support unavailable")); | |
| 740 | } | |
| 7072 | 741 | } |
| 742 | ||
| 743 | if(!js->gsc) { | |
| 744 | rc = gaim_proxy_connect(account, server, | |
| 745 | gaim_account_get_int(account, "port", 5222), | |
| 746 | jabber_login_callback, gc); | |
| 747 | ||
| 748 | if (rc != 0) | |
| 749 | gaim_connection_error(gc, _("Unable to create socket")); | |
| 750 | } | |
| 751 | } | |
| 752 | ||
| 5572 | 753 | static void jabber_close(GaimConnection *gc) |
| 2086 | 754 | { |
| 7014 | 755 | JabberStream *js = gc->proto_data; |
| 2956 | 756 | |
| 10216 | 757 | jabber_presence_send(gc->account, NULL); |
| 7642 | 758 | jabber_send_raw(js, "</stream:stream>", -1); |
| 3311 | 759 | |
| 7014 | 760 | if(js->gsc) { |
| 761 | gaim_ssl_close(js->gsc); | |
| 8360 | 762 | } else if (js->fd > 0) { |
| 7072 | 763 | if(js->gc->inpa) |
| 764 | gaim_input_remove(js->gc->inpa); | |
| 7014 | 765 | close(js->fd); |
| 766 | } | |
| 3311 | 767 | |
| 7587 | 768 | if(js->context) |
| 769 | g_markup_parse_context_free(js->context); | |
| 8312 | 770 | if(js->iq_callbacks) |
| 771 | g_hash_table_destroy(js->iq_callbacks); | |
| 772 | if(js->disco_callbacks) | |
| 773 | g_hash_table_destroy(js->disco_callbacks); | |
| 7072 | 774 | if(js->buddies) |
| 775 | g_hash_table_destroy(js->buddies); | |
| 776 | if(js->chats) | |
| 777 | g_hash_table_destroy(js->chats); | |
| 8043 | 778 | while(js->chat_servers) { |
| 779 | g_free(js->chat_servers->data); | |
| 780 | js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers); | |
| 781 | } | |
| 7014 | 782 | if(js->stream_id) |
| 783 | g_free(js->stream_id); | |
| 7587 | 784 | if(js->user) |
| 785 | jabber_id_free(js->user); | |
| 10189 | 786 | if(js->avatar_hash) |
| 787 | g_free(js->avatar_hash); | |
| 7014 | 788 | g_free(js); |
| 5093 | 789 | } |
| 790 | ||
| 7014 | 791 | void jabber_stream_set_state(JabberStream *js, JabberStreamState state) |
|
3105
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
792 | { |
| 9954 | 793 | GaimPresence *gpresence; |
| 794 | GaimStatus *status; | |
| 795 | ||
| 7014 | 796 | js->state = state; |
| 797 | switch(state) { | |
| 798 | case JABBER_STREAM_OFFLINE: | |
| 799 | break; | |
| 800 | case JABBER_STREAM_CONNECTING: | |
| 801 | gaim_connection_update_progress(js->gc, _("Connecting"), 1, | |
| 802 | JABBER_CONNECT_STEPS); | |
| 803 | break; | |
| 804 | case JABBER_STREAM_INITIALIZING: | |
| 805 | gaim_connection_update_progress(js->gc, _("Initializing Stream"), | |
| 806 | js->gsc ? 5 : 2, JABBER_CONNECT_STEPS); | |
| 807 | jabber_stream_init(js); | |
| 808 | jabber_parser_setup(js); | |
| 809 | break; | |
| 810 | case JABBER_STREAM_AUTHENTICATING: | |
| 811 | gaim_connection_update_progress(js->gc, _("Authenticating"), | |
| 812 | js->gsc ? 6 : 3, JABBER_CONNECT_STEPS); | |
| 8296 | 813 | if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) { |
| 814 | jabber_register_start(js); | |
| 815 | } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) { | |
| 816 | jabber_auth_start_old(js); | |
| 8016 | 817 | } |
| 7014 | 818 | break; |
| 819 | case JABBER_STREAM_REINITIALIZING: | |
| 820 | gaim_connection_update_progress(js->gc, _("Re-initializing Stream"), | |
| 821 | 6, JABBER_CONNECT_STEPS); | |
| 822 | jabber_stream_init(js); | |
| 823 | break; | |
| 824 | case JABBER_STREAM_CONNECTED: | |
| 825 | gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
| 826 | jabber_roster_request(js); | |
| 9954 | 827 | gpresence = gaim_account_get_presence(js->gc->account); |
| 828 | status = gaim_presence_get_active_status(gpresence); | |
| 10216 | 829 | jabber_presence_send(js->gc->account, status); |
| 8312 | 830 | jabber_disco_items_server(js); |
| 7014 | 831 | serv_finish_login(js->gc); |
| 832 | break; | |
|
3105
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
833 | } |
|
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
834 | } |
|
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
835 | |
| 7014 | 836 | char *jabber_get_next_id(JabberStream *js) |
| 2086 | 837 | { |
| 7322 | 838 | return g_strdup_printf("gaim%x", js->next_id++); |
| 2086 | 839 | } |
| 840 | ||
| 7923 | 841 | |
| 842 | static void jabber_idle_set(GaimConnection *gc, int idle) | |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
843 | { |
| 7014 | 844 | JabberStream *js = gc->proto_data; |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
845 | |
| 7014 | 846 | js->idle = idle ? time(NULL) - idle : idle; |
|
3314
12fa45677717
[gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3311
diff
changeset
|
847 | } |
|
12fa45677717
[gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3311
diff
changeset
|
848 | |
| 6695 | 849 | static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) |
| 2086 | 850 | { |
| 4687 | 851 | return "jabber"; |
| 852 | } | |
| 4916 | 853 | |
| 9954 | 854 | static void jabber_list_emblems(GaimBuddy *b, const char **se, const char **sw, |
| 855 | const char **nw, const char **ne) | |
| 4916 | 856 | { |
| 7014 | 857 | JabberStream *js; |
| 858 | JabberBuddy *jb; | |
| 859 | ||
| 860 | if(!b->account->gc) | |
| 861 | return; | |
| 862 | js = b->account->gc->proto_data; | |
| 863 | jb = jabber_buddy_find(js, b->name, FALSE); | |
| 5135 | 864 | |
| 865 | if(!GAIM_BUDDY_IS_ONLINE(b)) { | |
| 7014 | 866 | if(jb && jb->error_msg) |
| 4927 | 867 | *nw = "error"; |
| 5135 | 868 | |
| 7014 | 869 | if(jb && (jb->subscription & JABBER_SUB_PENDING || |
| 870 | !(jb->subscription & JABBER_SUB_TO))) | |
| 5135 | 871 | *se = "notauthorized"; |
| 872 | else | |
| 873 | *se = "offline"; | |
| 4916 | 874 | } else { |
| 9954 | 875 | GaimStatusType *status_type = gaim_status_get_type(gaim_presence_get_active_status(gaim_buddy_get_presence(b))); |
| 876 | ||
| 877 | if(gaim_status_type_get_primitive(status_type) > GAIM_STATUS_ONLINE) { | |
| 878 | *se = gaim_status_type_get_id(status_type); | |
| 879 | if(!strcmp(*se, "xa")) | |
| 7014 | 880 | *se = "extendedaway"; |
| 4916 | 881 | } |
| 2086 | 882 | } |
| 4916 | 883 | } |
| 2086 | 884 | |
| 7014 | 885 | static char *jabber_status_text(GaimBuddy *b) |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
886 | { |
| 7014 | 887 | JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
| 888 | FALSE); | |
| 889 | char *ret = NULL; | |
| 5234 | 890 | |
| 7014 | 891 | if(jb && !GAIM_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { |
| 892 | ret = g_strdup(_("Not Authorized")); | |
| 893 | } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
| 894 | ret = g_strdup(jb->error_msg); | |
| 2956 | 895 | } else { |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
896 | char *stripped; |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
897 | |
| 9954 | 898 | if(!(stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)))) { |
| 899 | GaimStatus *status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
| 2956 | 900 | |
| 9954 | 901 | if(!gaim_status_is_available(status)) |
| 902 | stripped = g_strdup(gaim_status_get_name(status)); | |
| 903 | } | |
| 2086 | 904 | |
| 7014 | 905 | if(stripped) { |
| 906 | ret = g_markup_escape_text(stripped, -1); | |
| 907 | g_free(stripped); | |
| 908 | } | |
| 2086 | 909 | } |
| 910 | ||
| 7014 | 911 | return ret; |
| 2956 | 912 | } |
| 913 | ||
| 6695 | 914 | static char *jabber_tooltip_text(GaimBuddy *b) |
| 4744 | 915 | { |
| 7014 | 916 | JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
| 917 | FALSE); | |
| 8194 | 918 | GString *ret = g_string_new(""); |
| 7014 | 919 | |
| 8194 | 920 | if(jb) { |
| 921 | JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL); | |
| 922 | const char *sub; | |
| 923 | if(jb->subscription & JABBER_SUB_FROM) { | |
| 924 | if(jb->subscription & JABBER_SUB_TO) | |
| 925 | sub = _("Both"); | |
| 926 | else if(jb->subscription & JABBER_SUB_PENDING) | |
| 927 | sub = _("From (To pending)"); | |
| 928 | else | |
| 929 | sub = _("From"); | |
| 930 | } else { | |
| 931 | if(jb->subscription & JABBER_SUB_TO) | |
| 932 | sub = _("To"); | |
| 933 | else if(jb->subscription & JABBER_SUB_PENDING) | |
| 934 | sub = _("None (To pending)"); | |
| 935 | else | |
| 936 | sub = _("None"); | |
| 937 | } | |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
938 | g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Subscription"), sub); |
| 8194 | 939 | |
| 940 | if(jbr) { | |
| 941 | char *text = NULL; | |
| 942 | if(jbr->status) { | |
| 943 | char *stripped; | |
| 944 | stripped = gaim_markup_strip_html(jbr->status); | |
| 945 | text = g_markup_escape_text(stripped, -1); | |
| 946 | g_free(stripped); | |
| 947 | } | |
| 948 | ||
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
949 | g_string_append_printf(ret, "\n<b>%s:</b> %s%s%s", |
| 8194 | 950 | _("Status"), |
| 9954 | 951 | jabber_buddy_state_get_name(jbr->state), |
| 8194 | 952 | text ? ": " : "", |
| 953 | text ? text : ""); | |
| 954 | if(text) | |
| 955 | g_free(text); | |
| 956 | } else if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
957 | g_string_append_printf(ret, "\n<b>%s:</b> %s", |
| 8194 | 958 | _("Error"), jb->error_msg); |
| 959 | } | |
| 4745 | 960 | } |
| 4744 | 961 | |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
962 | return g_string_free(ret, FALSE); |
| 4732 | 963 | } |
| 964 | ||
| 9954 | 965 | static GList *jabber_status_types(GaimAccount *account) |
| 7014 | 966 | { |
| 9954 | 967 | GaimStatusType *type; |
| 968 | GList *types = NULL; | |
| 969 | ||
| 9980 | 970 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_OFFLINE, "offline", |
| 971 | _("Offline"), FALSE, TRUE, FALSE, "message", _("Message"), | |
| 972 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 9954 | 973 | types = g_list_append(types, type); |
| 974 | ||
| 10490 | 975 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_ONLINE, "online", |
| 976 | _("Online"), FALSE, TRUE, FALSE, "priority", _("Priority"), | |
| 977 | gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), | |
| 978 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 10486 | 979 | types = g_list_append(types, type); |
| 980 | ||
| 981 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, "available", | |
| 982 | _("Available"), TRUE, TRUE, FALSE, "priority", _("Priority"), | |
| 9980 | 983 | gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), |
| 984 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 985 | types = g_list_append(types, type); | |
| 986 | ||
| 987 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, "chat", | |
| 988 | _("Chatty"), TRUE, TRUE, FALSE, "priority", _("Priority"), | |
| 989 | gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), | |
| 990 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 9954 | 991 | types = g_list_append(types, type); |
| 2086 | 992 | |
| 9980 | 993 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, "away", |
| 994 | _("Away"), TRUE, TRUE, FALSE, "priority", _("Priority"), | |
| 995 | gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), | |
| 996 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 9954 | 997 | types = g_list_append(types, type); |
| 998 | ||
| 9980 | 999 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, "xa", |
| 1000 | _("Extended Away"), TRUE, TRUE, FALSE, "priority", _("Priority"), | |
| 1001 | gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), | |
| 1002 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 9954 | 1003 | types = g_list_append(types, type); |
| 1004 | ||
| 9980 | 1005 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, "dnd", |
| 1006 | _("Do Not Disturb"), TRUE, TRUE, FALSE, "priority", _("Priority"), | |
| 1007 | gaim_value_new(GAIM_TYPE_INT), "message", _("Message"), | |
| 1008 | gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 9954 | 1009 | types = g_list_append(types, type); |
| 1010 | ||
| 1011 | /* | |
| 8166 | 1012 | if(js->protocol_version == JABBER_PROTO_0_9) |
| 1013 | m = g_list_append(m, _("Invisible")); | |
|
10009
8a4fcc043f47
[gaim-migrate @ 10926]
Mark Doliner <markdoliner@pidgin.im>
parents:
9980
diff
changeset
|
1014 | */ |
| 2086 | 1015 | |
| 9954 | 1016 | return types; |
| 2086 | 1017 | } |
| 1018 | ||
| 7395 | 1019 | static void |
| 1020 | jabber_password_change_result_cb(JabberStream *js, xmlnode *packet, | |
| 1021 | gpointer data) | |
| 7124 | 1022 | { |
| 1023 | const char *type; | |
| 1024 | ||
| 1025 | type = xmlnode_get_attrib(packet, "type"); | |
| 1026 | ||
| 9414 | 1027 | if(type && !strcmp(type, "result")) { |
| 7124 | 1028 | gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"), |
| 1029 | _("Your password has been changed.")); | |
| 1030 | } else { | |
| 8401 | 1031 | char *msg = jabber_parse_error(js, packet); |
| 7124 | 1032 | |
| 8401 | 1033 | gaim_notify_error(js->gc, _("Error changing password"), |
| 1034 | _("Error changing password"), msg); | |
| 1035 | g_free(msg); | |
| 7124 | 1036 | } |
| 1037 | } | |
| 1038 | ||
| 1039 | static void jabber_password_change_cb(JabberStream *js, | |
| 1040 | GaimRequestFields *fields) | |
| 1041 | { | |
| 1042 | const char *p1, *p2; | |
| 1043 | JabberIq *iq; | |
| 1044 | xmlnode *query, *y; | |
| 1045 | ||
| 1046 | p1 = gaim_request_fields_get_string(fields, "password1"); | |
| 1047 | p2 = gaim_request_fields_get_string(fields, "password2"); | |
| 1048 | ||
| 1049 | if(strcmp(p1, p2)) { | |
| 1050 | gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); | |
| 1051 | return; | |
| 1052 | } | |
| 1053 | ||
| 1054 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 1055 | ||
| 1056 | xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
| 1057 | ||
| 1058 | query = xmlnode_get_child(iq->node, "query"); | |
| 1059 | ||
| 1060 | y = xmlnode_new_child(query, "username"); | |
| 1061 | xmlnode_insert_data(y, js->user->node, -1); | |
| 1062 | y = xmlnode_new_child(query, "password"); | |
| 1063 | xmlnode_insert_data(y, p1, -1); | |
| 1064 | ||
| 7395 | 1065 | jabber_iq_set_callback(iq, jabber_password_change_result_cb, NULL); |
| 7124 | 1066 | |
| 1067 | jabber_iq_send(iq); | |
| 1068 | ||
| 1069 | gaim_account_set_password(js->gc->account, p1); | |
| 1070 | } | |
| 1071 | ||
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1072 | static void jabber_password_change(GaimPluginAction *action) |
| 7124 | 1073 | { |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1074 | |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1075 | GaimConnection *gc = (GaimConnection *) action->context; |
| 7124 | 1076 | JabberStream *js = gc->proto_data; |
| 1077 | GaimRequestFields *fields; | |
| 1078 | GaimRequestFieldGroup *group; | |
| 1079 | GaimRequestField *field; | |
| 1080 | ||
| 1081 | fields = gaim_request_fields_new(); | |
| 1082 | group = gaim_request_field_group_new(NULL); | |
| 1083 | gaim_request_fields_add_group(fields, group); | |
| 1084 | ||
| 1085 | field = gaim_request_field_string_new("password1", _("Password"), | |
| 1086 | "", FALSE); | |
| 1087 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1088 | gaim_request_field_group_add_field(group, field); | |
| 1089 | ||
| 1090 | field = gaim_request_field_string_new("password2", _("Password (again)"), | |
| 1091 | "", FALSE); | |
| 1092 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1093 | gaim_request_field_group_add_field(group, field); | |
| 1094 | ||
| 1095 | gaim_request_fields(js->gc, _("Change Jabber Password"), | |
| 1096 | _("Change Jabber Password"), _("Please enter your new password"), | |
| 1097 | fields, _("OK"), G_CALLBACK(jabber_password_change_cb), | |
| 1098 | _("Cancel"), NULL, js); | |
| 1099 | } | |
| 1100 | ||
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1101 | static GList *jabber_actions(GaimPlugin *plugin, gpointer context) |
| 2956 | 1102 | { |
| 1103 | GList *m = NULL; | |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1104 | GaimPluginAction *act; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1105 | |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1106 | act = gaim_plugin_action_new(_("Set User Info"), |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1107 | jabber_setup_set_info); |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1108 | m = g_list_append(m, act); |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1109 | |
| 8296 | 1110 | /* if (js->protocol_options & CHANGE_PASSWORD) { */ |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1111 | act = gaim_plugin_action_new(_("Change Password"), |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1112 | jabber_password_change); |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1113 | m = g_list_append(m, act); |
| 8296 | 1114 | /* } */ |
| 2956 | 1115 | |
| 1116 | return m; | |
| 1117 | } | |
| 1118 | ||
| 7999 | 1119 | static GaimChat *jabber_find_blist_chat(GaimAccount *account, const char *name) |
| 1120 | { | |
| 1121 | GaimBlistNode *gnode, *cnode; | |
| 1122 | JabberID *jid; | |
| 1123 | ||
| 1124 | if(!(jid = jabber_id_new(name))) | |
| 1125 | return NULL; | |
| 1126 | ||
| 1127 | for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
| 1128 | for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
| 1129 | GaimChat *chat = (GaimChat*)cnode; | |
| 1130 | const char *room, *server; | |
| 1131 | if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
| 1132 | continue; | |
| 1133 | ||
| 1134 | if(chat->account != account) | |
| 8011 | 1135 | continue; |
| 7999 | 1136 | |
| 1137 | if(!(room = g_hash_table_lookup(chat->components, "room"))) | |
| 1138 | continue; | |
| 1139 | if(!(server = g_hash_table_lookup(chat->components, "server"))) | |
| 1140 | continue; | |
| 1141 | ||
| 8158 | 1142 | if(jid->node && jid->domain && |
| 1143 | !g_utf8_collate(room, jid->node) && !g_utf8_collate(server, jid->domain)) { | |
| 7999 | 1144 | jabber_id_free(jid); |
| 1145 | return chat; | |
| 1146 | } | |
| 1147 | } | |
| 1148 | } | |
| 1149 | jabber_id_free(jid); | |
| 1150 | return NULL; | |
| 1151 | } | |
| 1152 | ||
| 8400 | 1153 | static void jabber_convo_closed(GaimConnection *gc, const char *who) |
| 1154 | { | |
| 1155 | JabberStream *js = gc->proto_data; | |
| 1156 | JabberID *jid; | |
| 1157 | JabberBuddy *jb; | |
| 1158 | JabberBuddyResource *jbr; | |
| 1159 | ||
| 1160 | if(!(jid = jabber_id_new(who))) | |
| 1161 | return; | |
| 1162 | ||
| 1163 | if((jb = jabber_buddy_find(js, who, TRUE)) && | |
| 1164 | (jbr = jabber_buddy_find_resource(jb, jid->resource))) { | |
| 1165 | if(jbr->thread_id) { | |
| 1166 | g_free(jbr->thread_id); | |
| 1167 | jbr->thread_id = NULL; | |
| 1168 | } | |
| 1169 | } | |
| 1170 | ||
| 1171 | jabber_id_free(jid); | |
| 1172 | } | |
| 1173 | ||
| 8401 | 1174 | |
| 1175 | char *jabber_parse_error(JabberStream *js, xmlnode *packet) | |
| 1176 | { | |
| 1177 | xmlnode *error; | |
| 1178 | const char *code = NULL, *text = NULL; | |
| 1179 | const char *xmlns = xmlnode_get_attrib(packet, "xmlns"); | |
| 1180 | char *cdata = NULL; | |
| 1181 | ||
| 1182 | if((error = xmlnode_get_child(packet, "error"))) { | |
| 1183 | cdata = xmlnode_get_data(error); | |
| 1184 | code = xmlnode_get_attrib(error, "code"); | |
| 1185 | ||
| 1186 | /* Stanza errors */ | |
| 1187 | if(xmlnode_get_child(error, "bad-request")) { | |
| 1188 | text = _("Bad Request"); | |
| 1189 | } else if(xmlnode_get_child(error, "conflict")) { | |
| 1190 | text = _("Conflict"); | |
| 1191 | } else if(xmlnode_get_child(error, "feature-not-implemented")) { | |
| 1192 | text = _("Feature Not Implemented"); | |
| 1193 | } else if(xmlnode_get_child(error, "forbidden")) { | |
| 1194 | text = _("Forbidden"); | |
| 1195 | } else if(xmlnode_get_child(error, "gone")) { | |
| 1196 | text = _("Gone"); | |
| 1197 | } else if(xmlnode_get_child(error, "internal-server-error")) { | |
| 1198 | text = _("Internal Server Error"); | |
| 1199 | } else if(xmlnode_get_child(error, "item-not-found")) { | |
| 1200 | text = _("Item Not Found"); | |
| 1201 | } else if(xmlnode_get_child(error, "jid-malformed")) { | |
| 1202 | text = _("Malformed Jabber ID"); | |
| 1203 | } else if(xmlnode_get_child(error, "not-acceptable")) { | |
| 1204 | text = _("Not Acceptable"); | |
| 1205 | } else if(xmlnode_get_child(error, "not-allowed")) { | |
| 1206 | text = _("Not Allowed"); | |
| 1207 | } else if(xmlnode_get_child(error, "not-authorized")) { | |
| 1208 | text = _("Not Authorized"); | |
| 1209 | } else if(xmlnode_get_child(error, "payment-required")) { | |
| 1210 | text = _("Payment Required"); | |
| 1211 | } else if(xmlnode_get_child(error, "recipient-unavailable")) { | |
| 1212 | text = _("Recipient Unavailable"); | |
| 1213 | } else if(xmlnode_get_child(error, "redirect")) { | |
| 1214 | /* XXX */ | |
| 1215 | } else if(xmlnode_get_child(error, "registration-required")) { | |
| 1216 | text = _("Registration Required"); | |
| 1217 | } else if(xmlnode_get_child(error, "remote-server-not-found")) { | |
| 1218 | text = _("Remote Server Not Found"); | |
| 1219 | } else if(xmlnode_get_child(error, "remote-server-timeout")) { | |
| 1220 | text = _("Remote Server Timeout"); | |
| 1221 | } else if(xmlnode_get_child(error, "resource-constraint")) { | |
| 1222 | text = _("Server Overloaded"); | |
| 1223 | } else if(xmlnode_get_child(error, "service-unavailable")) { | |
| 1224 | text = _("Service Unavailable"); | |
| 1225 | } else if(xmlnode_get_child(error, "subscription-required")) { | |
| 1226 | text = _("Subscription Required"); | |
| 1227 | } else if(xmlnode_get_child(error, "unexpected-request")) { | |
| 1228 | text = _("Unexpected Request"); | |
| 1229 | } else if(xmlnode_get_child(error, "undefined-condition")) { | |
| 1230 | text = _("Unknown Error"); | |
| 1231 | } | |
| 1232 | } else if(xmlns && !strcmp(xmlns, "urn:ietf:params:xml:ns:xmpp-sasl")) { | |
| 1233 | if(xmlnode_get_child(packet, "aborted")) { | |
| 1234 | js->gc->wants_to_die = TRUE; | |
| 1235 | text = _("Authorization Aborted"); | |
| 1236 | } else if(xmlnode_get_child(error, "incorrect-encoding")) { | |
| 1237 | text = _("Incorrect encoding in authorization"); | |
| 1238 | } else if(xmlnode_get_child(error, "invalid-authzid")) { | |
| 1239 | js->gc->wants_to_die = TRUE; | |
| 1240 | text = _("Invalid authzid"); | |
| 1241 | } else if(xmlnode_get_child(error, "invalid-mechanism")) { | |
| 1242 | js->gc->wants_to_die = TRUE; | |
| 1243 | text = _("Invalid Authorization Mechanism"); | |
| 1244 | } else if(xmlnode_get_child(error, "mechanism-too-weak")) { | |
| 1245 | js->gc->wants_to_die = TRUE; | |
| 1246 | text = _("Authorization mechanism too weak"); | |
| 1247 | } else if(xmlnode_get_child(error, "not-authorized")) { | |
| 1248 | js->gc->wants_to_die = TRUE; | |
| 1249 | text = _("Not Authorized"); | |
| 1250 | } else if(xmlnode_get_child(error, "temporary-auth-failure")) { | |
| 1251 | text = _("Temporary Authentication Failure"); | |
| 1252 | } else { | |
| 1253 | text = _("Authentication Failure"); | |
| 1254 | } | |
| 8402 | 1255 | } else if(!strcmp(packet->name, "stream:error")) { |
| 1256 | if(xmlnode_get_child(packet, "bad-format")) { | |
| 1257 | text = _("Bad Format"); | |
| 1258 | } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) { | |
| 1259 | text = _("Bad Namespace Prefix"); | |
| 1260 | } else if(xmlnode_get_child(packet, "conflict")) { | |
| 1261 | js->gc->wants_to_die = TRUE; | |
| 1262 | text = _("Resource Conflict"); | |
| 1263 | } else if(xmlnode_get_child(packet, "connection-timeout")) { | |
| 1264 | text = _("Connection Timeout"); | |
| 1265 | } else if(xmlnode_get_child(packet, "host-gone")) { | |
| 1266 | text = _("Host Gone"); | |
| 1267 | } else if(xmlnode_get_child(packet, "host-unknown")) { | |
| 1268 | text = _("Host Unknown"); | |
| 1269 | } else if(xmlnode_get_child(packet, "improper-addressing")) { | |
| 1270 | text = _("Improper Addressing"); | |
| 1271 | } else if(xmlnode_get_child(packet, "internal-server-error")) { | |
| 1272 | text = _("Internal Server Error"); | |
| 1273 | } else if(xmlnode_get_child(packet, "invalid-id")) { | |
| 1274 | text = _("Invalid ID"); | |
| 1275 | } else if(xmlnode_get_child(packet, "invalid-namespace")) { | |
| 1276 | text = _("Invalid Namespace"); | |
| 1277 | } else if(xmlnode_get_child(packet, "invalid-xml")) { | |
| 1278 | text = _("Invalid XML"); | |
| 1279 | } else if(xmlnode_get_child(packet, "nonmatching-hosts")) { | |
| 1280 | text = _("Non-matching Hosts"); | |
| 1281 | } else if(xmlnode_get_child(packet, "not-authorized")) { | |
| 1282 | text = _("Not Authorized"); | |
| 1283 | } else if(xmlnode_get_child(packet, "policy-violation")) { | |
| 1284 | text = _("Policy Violation"); | |
| 1285 | } else if(xmlnode_get_child(packet, "remote-connection-failed")) { | |
| 1286 | text = _("Remote Connection Failed"); | |
| 1287 | } else if(xmlnode_get_child(packet, "resource-constraint")) { | |
| 1288 | text = _("Resource Constraint"); | |
| 1289 | } else if(xmlnode_get_child(packet, "restricted-xml")) { | |
| 1290 | text = _("Restricted XML"); | |
| 1291 | } else if(xmlnode_get_child(packet, "see-other-host")) { | |
| 1292 | text = _("See Other Host"); | |
| 1293 | } else if(xmlnode_get_child(packet, "system-shutdown")) { | |
| 1294 | text = _("System Shutdown"); | |
| 1295 | } else if(xmlnode_get_child(packet, "undefined-condition")) { | |
| 1296 | text = _("Undefined Condition"); | |
| 1297 | } else if(xmlnode_get_child(packet, "unsupported-encoding")) { | |
| 1298 | text = _("Unsupported Encoding"); | |
| 1299 | } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) { | |
| 1300 | text = _("Unsupported Stanza Type"); | |
| 1301 | } else if(xmlnode_get_child(packet, "unsupported-version")) { | |
| 1302 | text = _("Unsupported Version"); | |
| 1303 | } else if(xmlnode_get_child(packet, "xml-not-well-formed")) { | |
| 1304 | text = _("XML Not Well Formed"); | |
| 1305 | } else { | |
| 1306 | text = _("Stream Error"); | |
| 1307 | } | |
| 8401 | 1308 | } |
| 1309 | ||
| 1310 | if(text || cdata) { | |
| 1311 | char *ret = g_strdup_printf("%s%s%s", code ? code : "", | |
| 1312 | code ? ": " : "", text ? text : cdata); | |
| 1313 | g_free(cdata); | |
| 1314 | return ret; | |
| 1315 | } else { | |
| 1316 | return NULL; | |
| 1317 | } | |
| 1318 | } | |
| 1319 | ||
| 9130 | 1320 | static GaimCmdRet jabber_cmd_chat_config(GaimConversation *conv, |
| 9597 | 1321 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 1322 | { |
| 1323 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1324 | jabber_chat_request_room_configure(chat); | |
| 1325 | return GAIM_CMD_RET_OK; | |
| 1326 | } | |
| 1327 | ||
| 1328 | static GaimCmdRet jabber_cmd_chat_register(GaimConversation *conv, | |
| 9597 | 1329 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 1330 | { |
| 1331 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1332 | jabber_chat_register(chat); | |
| 1333 | return GAIM_CMD_RET_OK; | |
| 1334 | } | |
| 1335 | ||
| 1336 | static GaimCmdRet jabber_cmd_chat_topic(GaimConversation *conv, | |
| 9597 | 1337 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 1338 | { |
| 1339 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1340 | jabber_chat_change_topic(chat, args ? args[0] : NULL); | |
| 1341 | return GAIM_CMD_RET_OK; | |
| 1342 | } | |
| 1343 | ||
| 1344 | static GaimCmdRet jabber_cmd_chat_nick(GaimConversation *conv, | |
| 9597 | 1345 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 1346 | { |
| 1347 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1348 | ||
| 1349 | if(!args || !args[0]) | |
| 1350 | return GAIM_CMD_RET_FAILED; | |
| 1351 | ||
| 1352 | jabber_chat_change_nick(chat, args[0]); | |
| 1353 | return GAIM_CMD_RET_OK; | |
| 1354 | } | |
| 1355 | ||
| 1356 | static GaimCmdRet jabber_cmd_chat_part(GaimConversation *conv, | |
| 9597 | 1357 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 1358 | { |
| 1359 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1360 | jabber_chat_part(chat, args ? args[0] : NULL); | |
| 1361 | return GAIM_CMD_RET_OK; | |
| 1362 | } | |
| 1363 | ||
| 9152 | 1364 | static GaimCmdRet jabber_cmd_chat_ban(GaimConversation *conv, |
| 9597 | 1365 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 1366 | { |
| 1367 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1368 | ||
| 1369 | if(!args || !args[0]) | |
| 1370 | return GAIM_CMD_RET_FAILED; | |
| 1371 | ||
| 1372 | if(!jabber_chat_ban_user(chat, args[0], args[1])) { | |
| 1373 | *error = g_strdup_printf(_("Unable to ban user %s"), args[0]); | |
| 1374 | return GAIM_CMD_RET_FAILED; | |
| 1375 | } | |
| 1376 | ||
| 1377 | return GAIM_CMD_RET_OK; | |
| 1378 | } | |
| 1379 | ||
| 1380 | static GaimCmdRet jabber_cmd_chat_invite(GaimConversation *conv, | |
| 9597 | 1381 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 1382 | { |
| 1383 | if(!args || !args[0]) | |
| 1384 | return GAIM_CMD_RET_FAILED; | |
| 1385 | ||
| 1386 | jabber_chat_invite(gaim_conversation_get_gc(conv), | |
| 1387 | gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), args[1] ? args[1] : "", | |
| 1388 | args[0]); | |
| 1389 | ||
| 1390 | return GAIM_CMD_RET_OK; | |
| 1391 | } | |
| 1392 | ||
| 1393 | static GaimCmdRet jabber_cmd_chat_join(GaimConversation *conv, | |
| 9597 | 1394 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 1395 | { |
| 1396 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1397 | GHashTable *components; | |
| 1398 | ||
| 1399 | if(!args || !args[0]) | |
| 1400 | return GAIM_CMD_RET_FAILED; | |
| 1401 | ||
| 1402 | components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); | |
| 1403 | ||
| 1404 | g_hash_table_replace(components, "room", args[0]); | |
| 1405 | g_hash_table_replace(components, "server", chat->server); | |
| 1406 | g_hash_table_replace(components, "handle", chat->handle); | |
| 1407 | if(args[1]) | |
| 1408 | g_hash_table_replace(components, "password", args[1]); | |
| 1409 | ||
| 1410 | jabber_chat_join(gaim_conversation_get_gc(conv), components); | |
| 1411 | ||
| 1412 | g_hash_table_destroy(components); | |
| 1413 | return GAIM_CMD_RET_OK; | |
| 1414 | } | |
| 1415 | ||
| 1416 | static GaimCmdRet jabber_cmd_chat_kick(GaimConversation *conv, | |
| 9597 | 1417 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 1418 | { |
| 1419 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1420 | ||
| 1421 | if(!args || !args[0]) | |
| 1422 | return GAIM_CMD_RET_FAILED; | |
| 1423 | ||
| 1424 | if(!jabber_chat_kick_user(chat, args[0], args[1])) { | |
| 1425 | *error = g_strdup_printf(_("Unable to kick user %s"), args[0]); | |
| 1426 | return GAIM_CMD_RET_FAILED; | |
| 1427 | } | |
| 1428 | ||
| 1429 | return GAIM_CMD_RET_OK; | |
| 1430 | } | |
| 1431 | ||
| 1432 | static GaimCmdRet jabber_cmd_chat_msg(GaimConversation *conv, | |
| 9597 | 1433 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 1434 | { |
| 1435 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1436 | char *who; | |
| 1437 | ||
| 1438 | who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]); | |
| 1439 | ||
| 1440 | jabber_message_send_im(gaim_conversation_get_gc(conv), who, args[1], 0); | |
| 1441 | ||
| 1442 | g_free(who); | |
| 1443 | return GAIM_CMD_RET_OK; | |
| 1444 | } | |
| 1445 | ||
| 9130 | 1446 | static void jabber_register_commands(void) |
| 1447 | { | |
| 1448 | gaim_cmd_register("config", "", GAIM_CMD_P_PRPL, | |
| 9597 | 1449 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
| 1450 | "prpl-jabber", jabber_cmd_chat_config, | |
| 1451 | _("config: Configure a chat room."), NULL); | |
| 9130 | 1452 | gaim_cmd_register("configure", "", GAIM_CMD_P_PRPL, |
| 9597 | 1453 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
| 1454 | "prpl-jabber", jabber_cmd_chat_config, | |
| 1455 | _("configure: Configure a chat room."), NULL); | |
| 9130 | 1456 | gaim_cmd_register("nick", "s", GAIM_CMD_P_PRPL, |
| 9597 | 1457 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
| 1458 | "prpl-jabber", jabber_cmd_chat_nick, | |
| 1459 | _("nick <new nickname>: Change your nickname."), | |
| 1460 | NULL); | |
| 9130 | 1461 | gaim_cmd_register("part", "s", GAIM_CMD_P_PRPL, |
| 9597 | 1462 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
| 1463 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1464 | jabber_cmd_chat_part, _("part [room]: Leave the room."), | |
| 1465 | NULL); | |
| 9130 | 1466 | gaim_cmd_register("register", "", GAIM_CMD_P_PRPL, |
| 9597 | 1467 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
| 1468 | "prpl-jabber", jabber_cmd_chat_register, | |
| 1469 | _("register: Register with a chat room."), NULL); | |
| 9130 | 1470 | /* XXX: there needs to be a core /topic cmd, methinks */ |
| 1471 | gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL, | |
| 9597 | 1472 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
| 1473 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1474 | jabber_cmd_chat_topic, | |
| 1475 | _("topic [new topic]: View or change the topic."), | |
| 1476 | NULL); | |
| 9152 | 1477 | gaim_cmd_register("ban", "ws", GAIM_CMD_P_PRPL, |
| 9597 | 1478 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
| 1479 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1480 | jabber_cmd_chat_ban, | |
| 1481 | _("ban <user> [room]: Ban a user from the room."), | |
| 1482 | NULL); | |
| 9152 | 1483 | gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL, |
| 9597 | 1484 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
| 1485 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1486 | jabber_cmd_chat_invite, | |
| 1487 | _("invite <user> [room]: Invite a user to the room."), | |
| 1488 | NULL); | |
| 9152 | 1489 | gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL, |
| 9597 | 1490 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
| 1491 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1492 | jabber_cmd_chat_join, | |
| 1493 | _("join: <room> [server]: Join a chat on this server."), | |
| 1494 | NULL); | |
| 9152 | 1495 | gaim_cmd_register("kick", "ws", GAIM_CMD_P_PRPL, |
| 9597 | 1496 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
| 1497 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1498 | jabber_cmd_chat_kick, | |
| 1499 | _("kick <user> [room]: Kick a user from the room."), | |
| 1500 | NULL); | |
| 9152 | 1501 | gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL, |
| 9597 | 1502 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
| 1503 | "prpl-jabber", jabber_cmd_chat_msg, | |
| 1504 | _("msg <user> <message>: Send a private message to another user."), | |
| 1505 | NULL); | |
| 9130 | 1506 | } |
| 1507 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1508 | static GaimPluginProtocolInfo prpl_info = |
| 2086 | 1509 | { |
| 7014 | 1510 | OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME, |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1511 | NULL, /* user_splits */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1512 | NULL, /* protocol_options */ |
| 10189 | 1513 | {"jpeg,gif,png", 0, 0, 96, 96, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1514 | jabber_list_icon, /* list_icon */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1515 | jabber_list_emblems, /* list_emblems */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1516 | jabber_status_text, /* status_text */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1517 | jabber_tooltip_text, /* tooltip_text */ |
| 9954 | 1518 | jabber_status_types, /* status_types */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1519 | jabber_blist_node_menu, /* blist_node_menu */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1520 | jabber_chat_info, /* chat_info */ |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9597
diff
changeset
|
1521 | jabber_chat_info_defaults, /* chat_info_defaults */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1522 | jabber_login, /* login */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1523 | jabber_close, /* close */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1524 | jabber_message_send_im, /* send_im */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1525 | jabber_set_info, /* set_info */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1526 | jabber_send_typing, /* send_typing */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1527 | jabber_buddy_get_info, /* get_info */ |
| 10216 | 1528 | jabber_presence_send, /* set_away */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1529 | jabber_idle_set, /* set_idle */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1530 | NULL, /* change_passwd */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1531 | jabber_roster_add_buddy, /* add_buddy */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1532 | NULL, /* add_buddies */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1533 | jabber_roster_remove_buddy, /* remove_buddy */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1534 | NULL, /* remove_buddies */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1535 | NULL, /* add_permit */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1536 | NULL, /* add_deny */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1537 | NULL, /* rem_permit */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1538 | NULL, /* rem_deny */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1539 | NULL, /* set_permit_deny */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1540 | NULL, /* warn */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1541 | jabber_chat_join, /* join_chat */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1542 | NULL, /* reject_chat */ |
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
1543 | jabber_get_chat_name, /* get_chat_name */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1544 | jabber_chat_invite, /* chat_invite */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1545 | jabber_chat_leave, /* chat_leave */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1546 | NULL, /* chat_whisper */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1547 | jabber_message_send_chat, /* chat_send */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1548 | jabber_keepalive, /* keepalive */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1549 | jabber_register_account, /* register_user */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1550 | jabber_buddy_get_info_chat, /* get_cb_info */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1551 | NULL, /* get_cb_away */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1552 | jabber_roster_alias_change, /* alias_buddy */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1553 | jabber_roster_group_change, /* group_buddy */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1554 | jabber_roster_group_rename, /* rename_group */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1555 | NULL, /* buddy_free */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1556 | jabber_convo_closed, /* convo_closed */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1557 | jabber_normalize, /* normalize */ |
| 10189 | 1558 | jabber_set_buddy_icon, /* set_buddy_icon */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1559 | NULL, /* remove_group */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1560 | jabber_chat_buddy_real_name, /* get_cb_real_name */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1561 | jabber_chat_set_topic, /* set_chat_topic */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1562 | jabber_find_blist_chat, /* find_blist_chat */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1563 | jabber_roomlist_get_list, /* roomlist_get_list */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1564 | jabber_roomlist_cancel, /* roomlist_cancel */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1565 | NULL, /* roomlist_expand_category */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1566 | NULL, /* can_receive_file */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1567 | jabber_si_xfer_send /* send_file */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1568 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1569 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1570 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1571 | { |
| 9943 | 1572 | GAIM_PLUGIN_MAGIC, |
| 1573 | GAIM_MAJOR_VERSION, | |
| 1574 | GAIM_MINOR_VERSION, | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1575 | GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1576 | NULL, /**< ui_requirement */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1577 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1578 | NULL, /**< dependencies */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1579 | GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1580 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1581 | "prpl-jabber", /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1582 | "Jabber", /**< name */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1583 | VERSION, /**< version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1584 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1585 | N_("Jabber Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1586 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1587 | N_("Jabber Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1588 | NULL, /**< author */ |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
1589 | GAIM_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1590 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1591 | NULL, /**< load */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1592 | NULL, /**< unload */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1593 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1594 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1595 | NULL, /**< ui_info */ |
| 8993 | 1596 | &prpl_info, /**< extra_info */ |
| 10487 | 1597 | NULL, /**< prefs_info */ |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1598 | jabber_actions |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1599 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1600 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1601 | static void |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1602 | init_plugin(GaimPlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1603 | { |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1604 | GaimAccountUserSplit *split; |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1605 | GaimAccountOption *option; |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1606 | |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1607 | split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1608 | 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
|
1609 | |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1610 | split = gaim_account_user_split_new(_("Resource"), "Gaim", '/'); |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1611 | 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
|
1612 | |
| 7630 | 1613 | option = gaim_account_option_bool_new(_("Use TLS if available"), "use_tls", |
| 1614 | TRUE); | |
| 1615 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 1616 | option); | |
| 1617 | ||
| 1618 | option = gaim_account_option_bool_new(_("Force old SSL"), "old_ssl", FALSE); | |
| 7124 | 1619 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 1620 | option); | |
| 6764 | 1621 | |
| 8086 | 1622 | option = gaim_account_option_bool_new( |
| 1623 | _("Allow plaintext auth over unencrypted streams"), | |
| 1624 | "auth_plain_in_clear", FALSE); | |
| 1625 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 1626 | option); | |
| 1627 | ||
| 7014 | 1628 | option = gaim_account_option_int_new(_("Port"), "port", 5222); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1629 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 7014 | 1630 | option); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1631 | |
|
5685
2523e4143d74
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1632 | option = gaim_account_option_string_new(_("Connect server"), |
| 7014 | 1633 | "connect_server", NULL); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1634 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 7014 | 1635 | option); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1636 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1637 | my_protocol = plugin; |
| 7014 | 1638 | |
| 10487 | 1639 | gaim_prefs_remove("/plugins/prpl/jabber"); |
| 9130 | 1640 | |
| 1641 | jabber_register_commands(); | |
| 2086 | 1642 | } |
| 1643 | ||
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1644 | GAIM_INIT_PLUGIN(jabber, init_plugin, info); |