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