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