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