Fri, 23 Apr 2004 21:50:17 +0000
[gaim-migrate @ 9540]
(17:44:08) Faceprint: ping
(17:44:17) Me: semi-pong
(17:44:26) Faceprint: in a position to commit, or not?
(17:44:40) Me: more or less
(17:44:48) Me: not in a possition to think though
(17:44:56) Faceprint: no real thought required
(17:45:29) Faceprint: jabber.c, in jabber_login_callback, before the check to see if gc is in gaim_connections_get_all(), please add:
(17:45:32) Faceprint:
if (source < 0) {
gaim_connection_error(gc, _("Couldn't connect to host"));
return;
}
(17:45:53) Faceprint: and change the if statement in irc_login_cb in irc.c to be the same
oh and vi automatically tabbing sucks and sometime i ran make dist
committer: Luke Schierer <lschiere@pidgin.im>
| 2086 | 1 | /* |
| 7014 | 2 | * gaim - Jabber Protocol Plugin |
| 2086 | 3 | * |
| 7014 | 4 | * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> |
| 2086 | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify | |
| 7 | * it under the terms of the GNU General Public License as published by | |
| 8 | * the Free Software Foundation; either version 2 of the License, or | |
| 9 | * (at your option) any later version. | |
| 7014 | 10 | * |
| 2086 | 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 | * | |
| 20 | */ | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
21 | #include "internal.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
22 | |
| 7014 | 23 | #include "account.h" |
| 24 | #include "accountopt.h" | |
| 25 | #include "debug.h" | |
| 26 | #include "message.h" | |
| 27 | #include "multi.h" | |
| 7072 | 28 | #include "notify.h" |
| 8713 | 29 | #include "pluginpref.h" |
| 7014 | 30 | #include "prpl.h" |
| 7072 | 31 | #include "request.h" |
| 7014 | 32 | #include "server.h" |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
33 | #include "util.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
34 | |
| 7014 | 35 | #include "auth.h" |
| 36 | #include "buddy.h" | |
| 37 | #include "chat.h" | |
| 8312 | 38 | #include "disco.h" |
| 7014 | 39 | #include "iq.h" |
| 40 | #include "jutil.h" | |
| 41 | #include "message.h" | |
| 42 | #include "parser.h" | |
| 43 | #include "presence.h" | |
| 44 | #include "jabber.h" | |
| 45 | #include "roster.h" | |
| 7923 | 46 | #include "xdata.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
47 | |
| 7014 | 48 | #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5) |
| 2086 | 49 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
50 | static GaimPlugin *my_protocol = NULL; |
|
4249
62583b5d3663
[gaim-migrate @ 4499]
Robert McQueen <robot101@debian.org>
parents:
4245
diff
changeset
|
51 | |
| 7014 | 52 | static void jabber_stream_init(JabberStream *js) |
| 53 | { | |
| 54 | char *open_stream; | |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
55 | |
| 7014 | 56 | open_stream = g_strdup_printf("<stream:stream to='%s' " |
| 57 | "xmlns='jabber:client' " | |
| 7395 | 58 | "xmlns:stream='http://etherx.jabber.org/streams' " |
| 59 | "version='1.0'>", | |
| 7291 | 60 | js->user->domain); |
| 3311 | 61 | |
| 7642 | 62 | jabber_send_raw(js, open_stream, -1); |
| 2086 | 63 | |
| 7014 | 64 | g_free(open_stream); |
| 2086 | 65 | } |
| 66 | ||
| 7395 | 67 | static void |
| 68 | jabber_session_initialized_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
| 3311 | 69 | { |
| 7014 | 70 | const char *type = xmlnode_get_attrib(packet, "type"); |
| 71 | if(type && !strcmp(type, "result")) { | |
| 72 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
| 73 | } else { | |
| 74 | gaim_connection_error(js->gc, _("Error initializing session")); | |
| 3311 | 75 | } |
| 76 | } | |
| 77 | ||
| 7014 | 78 | static void jabber_session_init(JabberStream *js) |
| 3311 | 79 | { |
| 7014 | 80 | JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); |
| 81 | xmlnode *session; | |
| 3311 | 82 | |
| 7395 | 83 | jabber_iq_set_callback(iq, jabber_session_initialized_cb, NULL); |
| 3311 | 84 | |
| 7014 | 85 | session = xmlnode_new_child(iq->node, "session"); |
| 86 | xmlnode_set_attrib(session, "xmlns", "urn:ietf:params:xml:ns:xmpp-session"); | |
| 3311 | 87 | |
| 7014 | 88 | jabber_iq_send(iq); |
| 3311 | 89 | } |
| 90 | ||
| 7395 | 91 | static void jabber_bind_result_cb(JabberStream *js, xmlnode *packet, |
| 92 | gpointer data) | |
| 93 | { | |
| 8401 | 94 | const char *type = xmlnode_get_attrib(packet, "type"); |
| 95 | xmlnode *bind; | |
| 96 | ||
| 97 | if(type && !strcmp(type, "result") && | |
| 98 | (bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) { | |
| 99 | xmlnode *jid; | |
| 100 | char *full_jid; | |
| 101 | if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) { | |
| 102 | jabber_id_free(js->user); | |
| 103 | if(!(js->user = jabber_id_new(full_jid))) { | |
| 104 | gaim_connection_error(js->gc, _("Invalid response from server.")); | |
| 105 | } | |
| 106 | } | |
| 107 | } else { | |
| 108 | char *msg = jabber_parse_error(js, packet); | |
| 109 | gaim_connection_error(js->gc, msg); | |
| 110 | g_free(msg); | |
| 111 | } | |
| 7395 | 112 | |
| 113 | jabber_session_init(js); | |
| 114 | } | |
| 115 | ||
| 116 | static void jabber_stream_features_parse(JabberStream *js, xmlnode *packet) | |
| 117 | { | |
| 8296 | 118 | if(xmlnode_get_child(packet, "starttls")) { |
| 119 | if(jabber_process_starttls(js, packet)) | |
| 120 | return; | |
| 121 | } | |
| 122 | ||
| 7395 | 123 | if(xmlnode_get_child(packet, "mechanisms")) { |
| 124 | jabber_auth_start(js, packet); | |
| 125 | } else if(xmlnode_get_child(packet, "bind")) { | |
| 126 | xmlnode *bind, *resource; | |
| 127 | JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); | |
| 128 | bind = xmlnode_new_child(iq->node, "bind"); | |
| 129 | xmlnode_set_attrib(bind, "xmlns", "urn:ietf:params:xml:ns:xmpp-bind"); | |
| 130 | resource = xmlnode_new_child(bind, "resource"); | |
| 131 | xmlnode_insert_data(resource, js->user->resource, -1); | |
| 132 | ||
| 133 | jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL); | |
| 134 | ||
| 135 | jabber_iq_send(iq); | |
| 8296 | 136 | } else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ { |
| 137 | /* If we get an empty stream:features packet, or we explicitly get | |
| 138 | * an auth feature with namespace http://jabber.org/features/iq-auth | |
| 139 | * we should revert back to iq:auth authentication, even though we're | |
| 140 | * connecting to an XMPP server. */ | |
| 141 | js->auth_type = JABBER_AUTH_IQ_AUTH; | |
| 142 | jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING); | |
| 7395 | 143 | } |
| 144 | } | |
| 145 | ||
| 7014 | 146 | static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet) |
| 3311 | 147 | { |
| 8401 | 148 | char *msg = jabber_parse_error(js, packet); |
| 3311 | 149 | |
| 8401 | 150 | gaim_connection_error(js->gc, msg); |
| 151 | g_free(msg); | |
| 2086 | 152 | } |
| 153 | ||
| 7014 | 154 | static void tls_init(JabberStream *js); |
| 2086 | 155 | |
| 7014 | 156 | void jabber_process_packet(JabberStream *js, xmlnode *packet) |
| 2086 | 157 | { |
| 7014 | 158 | if(!strcmp(packet->name, "iq")) { |
| 7395 | 159 | jabber_iq_parse(js, packet); |
| 7014 | 160 | } else if(!strcmp(packet->name, "presence")) { |
| 161 | jabber_presence_parse(js, packet); | |
| 162 | } else if(!strcmp(packet->name, "message")) { | |
| 163 | jabber_message_parse(js, packet); | |
| 164 | } else if(!strcmp(packet->name, "stream:features")) { | |
| 7395 | 165 | jabber_stream_features_parse(js, packet); |
| 7014 | 166 | } else if(!strcmp(packet->name, "stream:error")) { |
| 167 | jabber_stream_handle_error(js, packet); | |
| 168 | } else if(!strcmp(packet->name, "challenge")) { | |
| 169 | if(js->state == JABBER_STREAM_AUTHENTICATING) | |
| 170 | jabber_auth_handle_challenge(js, packet); | |
| 171 | } else if(!strcmp(packet->name, "success")) { | |
| 172 | if(js->state == JABBER_STREAM_AUTHENTICATING) | |
| 173 | jabber_auth_handle_success(js, packet); | |
| 174 | } else if(!strcmp(packet->name, "failure")) { | |
| 175 | if(js->state == JABBER_STREAM_AUTHENTICATING) | |
| 176 | jabber_auth_handle_failure(js, packet); | |
| 177 | } else if(!strcmp(packet->name, "proceed")) { | |
| 178 | if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc) | |
| 179 | tls_init(js); | |
| 180 | } else { | |
| 181 | gaim_debug(GAIM_DEBUG_WARNING, "jabber", "Unknown packet: %s\n", | |
| 182 | packet->name); | |
| 2086 | 183 | } |
| 184 | } | |
| 185 | ||
| 7642 | 186 | void jabber_send_raw(JabberStream *js, const char *data, int len) |
| 2086 | 187 | { |
| 7014 | 188 | int ret; |
| 2086 | 189 | |
| 7014 | 190 | /* because printing a tab to debug every minute gets old */ |
| 191 | if(strcmp(data, "\t")) | |
| 8401 | 192 | gaim_debug(GAIM_DEBUG_MISC, "jabber", "Sending%s: %s\n", |
| 7014 | 193 | js->gsc ? " (ssl)" : "", data); |
| 2086 | 194 | |
| 7014 | 195 | if(js->gsc) { |
| 7642 | 196 | ret = gaim_ssl_write(js->gsc, data, len == -1 ? strlen(data) : len); |
| 7014 | 197 | } else { |
|
8013
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
198 | if(js->fd < 0) |
|
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
199 | return; |
| 7642 | 200 | ret = write(js->fd, data, len == -1 ? strlen(data) : len); |
|
2814
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
201 | } |
|
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
202 | |
| 7014 | 203 | if(ret < 0) |
| 204 | gaim_connection_error(js->gc, _("Write error")); | |
| 205 | ||
|
2814
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
206 | } |
|
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
207 | |
| 7014 | 208 | void jabber_send(JabberStream *js, xmlnode *packet) |
| 2086 | 209 | { |
| 7014 | 210 | char *txt; |
| 7642 | 211 | int len; |
| 2086 | 212 | |
| 7642 | 213 | txt = xmlnode_to_str(packet, &len); |
| 214 | jabber_send_raw(js, txt, len); | |
| 7014 | 215 | g_free(txt); |
| 2086 | 216 | } |
| 217 | ||
| 7014 | 218 | static void jabber_keepalive(GaimConnection *gc) |
| 2086 | 219 | { |
| 7642 | 220 | jabber_send_raw(gc->proto_data, "\t", -1); |
| 2086 | 221 | } |
| 222 | ||
| 7014 | 223 | static void |
| 224 | jabber_recv_cb_ssl(gpointer data, GaimSslConnection *gsc, | |
| 6764 | 225 | GaimInputCondition cond) |
| 226 | { | |
| 7014 | 227 | GaimConnection *gc = data; |
| 228 | JabberStream *js = gc->proto_data; | |
| 6764 | 229 | int len; |
| 7014 | 230 | static char buf[4096]; |
| 6768 | 231 | |
| 7014 | 232 | if(!g_list_find(gaim_connections_get_all(), gc)) { |
| 6768 | 233 | gaim_ssl_close(gsc); |
| 234 | return; | |
| 235 | } | |
| 236 | ||
| 7014 | 237 | if((len = gaim_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) { |
| 6764 | 238 | buf[len] = '\0'; |
| 7014 | 239 | gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf); |
| 240 | jabber_parser_process(js, buf, len); | |
| 7177 | 241 | } else { |
| 242 | gaim_connection_error(gc, _("Read Error")); | |
| 2086 | 243 | } |
| 244 | } | |
| 245 | ||
| 7014 | 246 | static void |
| 247 | jabber_recv_cb(gpointer data, gint source, GaimInputCondition condition) | |
| 2086 | 248 | { |
| 5572 | 249 | GaimConnection *gc = data; |
| 7014 | 250 | JabberStream *js = gc->proto_data; |
| 251 | int len; | |
| 252 | static char buf[4096]; | |
| 2086 | 253 | |
| 7014 | 254 | if(!g_list_find(gaim_connections_get_all(), gc)) |
| 255 | return; | |
| 2956 | 256 | |
| 7014 | 257 | if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) { |
| 258 | buf[len] = '\0'; | |
| 259 | gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf); | |
| 260 | jabber_parser_process(js, buf, len); | |
| 7177 | 261 | } else { |
| 262 | gaim_connection_error(gc, _("Read Error")); | |
| 7014 | 263 | } |
| 2086 | 264 | } |
| 265 | ||
| 7014 | 266 | static void |
| 267 | jabber_login_callback_ssl(gpointer data, GaimSslConnection *gsc, | |
| 6764 | 268 | GaimInputCondition cond) |
| 269 | { | |
| 270 | GaimConnection *gc = data; | |
| 7014 | 271 | JabberStream *js = gc->proto_data; |
| 6764 | 272 | |
| 8778 | 273 | if (source < 0) { |
| 274 | gaim_connection_error(gc, _("Couldn't connect to host")); | |
| 275 | return; | |
| 276 | } | |
| 277 | ||
| 7014 | 278 | if(!g_list_find(gaim_connections_get_all(), gc)) { |
| 6764 | 279 | gaim_ssl_close(gsc); |
| 280 | return; | |
| 281 | } | |
| 282 | ||
| 7014 | 283 | js->gsc = gsc; |
| 6764 | 284 | |
| 7014 | 285 | if(js->state == JABBER_STREAM_CONNECTING) |
| 7642 | 286 | jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
| 6764 | 287 | |
| 7014 | 288 | jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
| 289 | gaim_ssl_input_add(gsc, jabber_recv_cb_ssl, gc); | |
| 6764 | 290 | } |
| 291 | ||
| 7014 | 292 | |
| 293 | static void | |
| 294 | jabber_login_callback(gpointer data, gint source, GaimInputCondition cond) | |
| 6764 | 295 | { |
| 5572 | 296 | GaimConnection *gc = data; |
| 7014 | 297 | JabberStream *js = gc->proto_data; |
| 2086 | 298 | |
| 7014 | 299 | if(!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 300 | close(source); |
| 301 | return; | |
| 302 | } | |
| 303 | ||
| 7014 | 304 | js->fd = source; |
| 2956 | 305 | |
| 7014 | 306 | if(js->state == JABBER_STREAM_CONNECTING) |
| 7642 | 307 | jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
|
2300
06a3c10f4918
[gaim-migrate @ 2310]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2289
diff
changeset
|
308 | |
| 7014 | 309 | jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
| 310 | gc->inpa = gaim_input_add(js->fd, GAIM_INPUT_READ, jabber_recv_cb, gc); | |
| 311 | } | |
| 2086 | 312 | |
| 7014 | 313 | static void |
| 7426 | 314 | jabber_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, |
| 315 | gpointer data) | |
| 316 | { | |
| 317 | GaimConnection *gc = data; | |
| 8360 | 318 | JabberStream *js = gc->proto_data; |
| 7426 | 319 | |
| 320 | switch(error) { | |
| 8362 | 321 | case GAIM_SSL_CONNECT_FAILED: |
| 322 | gaim_connection_error(gc, _("Connection Failed")); | |
| 323 | break; | |
| 7426 | 324 | case GAIM_SSL_HANDSHAKE_FAILED: |
| 325 | gaim_connection_error(gc, _("SSL Handshake Failed")); | |
| 326 | break; | |
| 327 | } | |
| 8360 | 328 | |
| 329 | js->gsc = NULL; | |
| 7426 | 330 | } |
| 331 | ||
| 7427 | 332 | static void tls_init(JabberStream *js) |
| 333 | { | |
| 334 | gaim_input_remove(js->gc->inpa); | |
| 335 | js->gc->inpa = 0; | |
| 336 | js->gsc = gaim_ssl_connect_fd(js->gc->account, js->fd, | |
| 337 | jabber_login_callback_ssl, jabber_ssl_connect_failure, js->gc); | |
| 338 | } | |
| 339 | ||
| 340 | ||
| 7426 | 341 | static void |
| 7014 | 342 | jabber_login(GaimAccount *account) |
| 2086 | 343 | { |
| 7014 | 344 | int rc; |
| 345 | GaimConnection *gc = gaim_account_get_connection(account); | |
| 346 | const char *connect_server = gaim_account_get_string(account, | |
| 347 | "connect_server", ""); | |
| 5572 | 348 | const char *server; |
| 7014 | 349 | JabberStream *js; |
| 2086 | 350 | |
| 7014 | 351 | gc->flags |= GAIM_CONNECTION_HTML; |
| 352 | js = gc->proto_data = g_new0(JabberStream, 1); | |
| 353 | js->gc = gc; | |
|
8013
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
354 | js->fd = -1; |
| 8312 | 355 | js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 356 | g_free, g_free); | |
| 357 | js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 7395 | 358 | g_free, g_free); |
| 7014 | 359 | js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 7116 | 360 | g_free, (GDestroyNotify)jabber_buddy_free); |
| 7014 | 361 | js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 8396 | 362 | g_free, (GDestroyNotify)jabber_chat_free); |
| 8043 | 363 | js->chat_servers = g_list_append(NULL, g_strdup("conference.jabber.org")); |
| 7014 | 364 | js->user = jabber_id_new(gaim_account_get_username(account)); |
| 7322 | 365 | js->next_id = g_random_int(); |
| 5613 | 366 | |
| 7310 | 367 | if(!js->user) { |
| 368 | gaim_connection_error(gc, _("Invalid Jabber ID")); | |
| 369 | return; | |
| 370 | } | |
| 371 | ||
| 7147 | 372 | if(!js->user->resource) { |
| 373 | char *me; | |
| 374 | js->user->resource = g_strdup("Gaim"); | |
| 375 | if(!js->user->node) { | |
| 376 | js->user->node = js->user->domain; | |
| 377 | js->user->domain = g_strdup("jabber.org"); | |
| 378 | } | |
| 379 | me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
| 380 | js->user->resource); | |
| 381 | gaim_account_set_username(account, me); | |
| 382 | g_free(me); | |
| 7145 | 383 | } |
| 384 | ||
| 7014 | 385 | server = connect_server[0] ? connect_server : js->user->domain; |
| 2086 | 386 | |
| 7014 | 387 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); |
| 2956 | 388 | |
| 7630 | 389 | |
| 390 | if(gaim_account_get_bool(account, "old_ssl", FALSE)) { | |
| 391 | if(gaim_ssl_is_supported()) { | |
| 392 | js->gsc = gaim_ssl_connect(account, server, | |
| 393 | gaim_account_get_int(account, "port", 5222), | |
| 394 | jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); | |
| 395 | } else { | |
| 396 | gaim_connection_error(gc, _("SSL support unavailable")); | |
| 397 | } | |
| 3311 | 398 | } |
| 3770 | 399 | |
| 7014 | 400 | if(!js->gsc) { |
| 401 | rc = gaim_proxy_connect(account, server, | |
| 402 | gaim_account_get_int(account, "port", 5222), | |
| 403 | jabber_login_callback, gc); | |
| 2086 | 404 | |
| 7014 | 405 | if (rc != 0) |
| 406 | gaim_connection_error(gc, _("Unable to create socket")); | |
| 2956 | 407 | } |
| 2086 | 408 | } |
| 409 | ||
| 7072 | 410 | static gboolean |
| 411 | conn_close_cb(gpointer data) | |
| 412 | { | |
| 413 | JabberStream *js = data; | |
| 414 | gaim_connection_destroy(js->gc); | |
| 415 | return FALSE; | |
| 416 | } | |
| 417 | ||
| 418 | static void | |
| 419 | jabber_connection_schedule_close(JabberStream *js) | |
| 420 | { | |
| 8273 | 421 | gaim_timeout_add(0, conn_close_cb, js); |
| 7072 | 422 | } |
| 423 | ||
| 424 | static void | |
| 7395 | 425 | jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
| 7072 | 426 | { |
| 427 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 428 | char *buf; | |
| 429 | ||
| 430 | if(!strcmp(type, "result")) { | |
| 431 | buf = g_strdup_printf(_("Registration of %s@%s successful"), | |
| 432 | js->user->node, js->user->domain); | |
| 433 | gaim_notify_info(NULL, _("Registration Successful"), | |
| 434 | _("Registration Successful"), buf); | |
| 435 | g_free(buf); | |
| 436 | } else { | |
| 8401 | 437 | char *msg = jabber_parse_error(js, packet); |
| 7072 | 438 | |
| 8401 | 439 | if(!msg) |
| 440 | msg = g_strdup(_("Unknown Error")); | |
| 7072 | 441 | |
| 442 | gaim_notify_error(NULL, _("Registration Failed"), | |
| 8401 | 443 | _("Registration Failed"), msg); |
| 444 | g_free(msg); | |
| 7072 | 445 | } |
| 446 | jabber_connection_schedule_close(js); | |
| 447 | } | |
| 448 | ||
| 449 | static void | |
| 450 | jabber_register_cb(JabberStream *js, GaimRequestFields *fields) | |
| 451 | { | |
| 452 | GList *groups, *flds; | |
| 453 | xmlnode *query, *y; | |
| 454 | JabberIq *iq; | |
| 7264 | 455 | char *username; |
| 7072 | 456 | |
| 457 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 458 | query = xmlnode_get_child(iq->node, "query"); | |
| 459 | ||
| 460 | for(groups = gaim_request_fields_get_groups(fields); groups; | |
| 461 | groups = groups->next) { | |
| 462 | for(flds = gaim_request_field_group_get_fields(groups->data); | |
| 463 | flds; flds = flds->next) { | |
| 464 | GaimRequestField *field = flds->data; | |
| 465 | const char *id = gaim_request_field_get_id(field); | |
| 466 | const char *value = gaim_request_field_string_get_value(field); | |
| 467 | ||
| 468 | if(!strcmp(id, "username")) { | |
| 469 | y = xmlnode_new_child(query, "username"); | |
| 470 | } else if(!strcmp(id, "password")) { | |
| 471 | y = xmlnode_new_child(query, "password"); | |
| 472 | } else if(!strcmp(id, "name")) { | |
| 473 | y = xmlnode_new_child(query, "name"); | |
| 474 | } else if(!strcmp(id, "email")) { | |
| 475 | y = xmlnode_new_child(query, "email"); | |
| 476 | } else if(!strcmp(id, "nick")) { | |
| 477 | y = xmlnode_new_child(query, "nick"); | |
| 478 | } else if(!strcmp(id, "first")) { | |
| 479 | y = xmlnode_new_child(query, "first"); | |
| 480 | } else if(!strcmp(id, "last")) { | |
| 481 | y = xmlnode_new_child(query, "last"); | |
| 482 | } else if(!strcmp(id, "address")) { | |
| 483 | y = xmlnode_new_child(query, "address"); | |
| 484 | } else if(!strcmp(id, "city")) { | |
| 485 | y = xmlnode_new_child(query, "city"); | |
| 486 | } else if(!strcmp(id, "state")) { | |
| 487 | y = xmlnode_new_child(query, "state"); | |
| 488 | } else if(!strcmp(id, "zip")) { | |
| 489 | y = xmlnode_new_child(query, "zip"); | |
| 490 | } else if(!strcmp(id, "phone")) { | |
| 491 | y = xmlnode_new_child(query, "phone"); | |
| 492 | } else if(!strcmp(id, "url")) { | |
| 493 | y = xmlnode_new_child(query, "url"); | |
| 494 | } else if(!strcmp(id, "date")) { | |
| 495 | y = xmlnode_new_child(query, "date"); | |
| 496 | } else { | |
| 497 | continue; | |
| 498 | } | |
| 499 | xmlnode_insert_data(y, value, -1); | |
| 7264 | 500 | if(!strcmp(id, "username")) { |
| 501 | if(js->user->node) | |
| 502 | g_free(js->user->node); | |
| 503 | js->user->node = g_strdup(value); | |
| 504 | } | |
| 7072 | 505 | } |
| 506 | } | |
| 507 | ||
| 7264 | 508 | username = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, |
| 509 | js->user->resource); | |
| 510 | gaim_account_set_username(js->gc->account, username); | |
| 511 | g_free(username); | |
| 512 | ||
| 7395 | 513 | jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); |
| 7072 | 514 | |
| 515 | jabber_iq_send(iq); | |
| 516 | ||
| 517 | } | |
| 518 | ||
| 519 | static void | |
| 520 | jabber_register_cancel_cb(JabberStream *js, GaimRequestFields *fields) | |
| 521 | { | |
| 522 | jabber_connection_schedule_close(js); | |
| 523 | } | |
| 524 | ||
| 7923 | 525 | static void jabber_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
| 526 | { | |
| 527 | xmlnode *query; | |
| 528 | JabberIq *iq; | |
| 529 | ||
| 530 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 531 | query = xmlnode_get_child(iq->node, "query"); | |
| 532 | ||
| 533 | xmlnode_insert_child(query, result); | |
| 534 | ||
| 535 | jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); | |
| 536 | jabber_iq_send(iq); | |
| 537 | } | |
| 538 | ||
| 7072 | 539 | void jabber_register_parse(JabberStream *js, xmlnode *packet) |
| 540 | { | |
| 541 | if(js->registration) { | |
| 542 | GaimRequestFields *fields; | |
| 543 | GaimRequestFieldGroup *group; | |
| 544 | GaimRequestField *field; | |
| 7923 | 545 | xmlnode *query, *x, *y; |
| 7072 | 546 | char *instructions; |
| 547 | ||
| 548 | /* get rid of the login thingy */ | |
| 549 | gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
| 550 | ||
| 551 | query = xmlnode_get_child(packet, "query"); | |
| 552 | ||
| 553 | if(xmlnode_get_child(query, "registered")) { | |
| 554 | gaim_notify_error(NULL, _("Already Registered"), | |
| 555 | _("Already Registered"), NULL); | |
| 556 | jabber_connection_schedule_close(js); | |
| 557 | return; | |
| 558 | } | |
| 559 | ||
| 8398 | 560 | if((x = xmlnode_get_child_with_namespace(packet, "x", |
| 561 | "jabber:x:data"))) { | |
| 562 | jabber_x_data_request(js, x, jabber_register_x_data_cb, NULL); | |
| 563 | return; | |
| 564 | } else if((x = xmlnode_get_child_with_namespace(packet, "x", | |
| 565 | "jabber:x:oob"))) { | |
| 566 | xmlnode *url; | |
| 7923 | 567 | |
| 8398 | 568 | if((url = xmlnode_get_child(x, "url"))) { |
| 569 | char *href; | |
| 570 | if((href = xmlnode_get_data(url))) { | |
| 571 | gaim_notify_uri(NULL, href); | |
| 572 | g_free(href); | |
| 573 | js->gc->wants_to_die = TRUE; | |
| 574 | jabber_connection_schedule_close(js); | |
| 575 | return; | |
| 576 | } | |
| 7923 | 577 | } |
| 578 | } | |
| 579 | ||
| 580 | /* as a last resort, use the old jabber:iq:register syntax */ | |
| 581 | ||
| 7072 | 582 | fields = gaim_request_fields_new(); |
| 583 | group = gaim_request_field_group_new(NULL); | |
| 584 | gaim_request_fields_add_group(fields, group); | |
| 585 | ||
| 586 | field = gaim_request_field_string_new("username", _("Username"), | |
| 587 | js->user->node, FALSE); | |
| 588 | gaim_request_field_group_add_field(group, field); | |
| 589 | ||
| 590 | field = gaim_request_field_string_new("password", _("Password"), | |
| 591 | gaim_account_get_password(js->gc->account), FALSE); | |
| 592 | gaim_request_field_string_set_masked(field, TRUE); | |
| 593 | gaim_request_field_group_add_field(group, field); | |
| 594 | ||
| 595 | if(xmlnode_get_child(query, "name")) { | |
| 596 | field = gaim_request_field_string_new("name", _("Name"), | |
| 597 | gaim_account_get_alias(js->gc->account), FALSE); | |
| 598 | gaim_request_field_group_add_field(group, field); | |
| 599 | } | |
| 600 | if(xmlnode_get_child(query, "email")) { | |
| 601 | field = gaim_request_field_string_new("email", _("E-Mail"), | |
| 602 | NULL, FALSE); | |
| 603 | gaim_request_field_group_add_field(group, field); | |
| 604 | } | |
| 605 | if(xmlnode_get_child(query, "nick")) { | |
| 606 | field = gaim_request_field_string_new("nick", _("Nickname"), | |
| 607 | NULL, FALSE); | |
| 608 | gaim_request_field_group_add_field(group, field); | |
| 609 | } | |
| 610 | if(xmlnode_get_child(query, "first")) { | |
| 611 | field = gaim_request_field_string_new("first", _("First Name"), | |
| 612 | NULL, FALSE); | |
| 613 | gaim_request_field_group_add_field(group, field); | |
| 614 | } | |
| 615 | if(xmlnode_get_child(query, "last")) { | |
| 616 | field = gaim_request_field_string_new("last", _("Last Name"), | |
| 617 | NULL, FALSE); | |
| 618 | gaim_request_field_group_add_field(group, field); | |
| 619 | } | |
| 620 | if(xmlnode_get_child(query, "address")) { | |
| 621 | field = gaim_request_field_string_new("address", _("Address"), | |
| 622 | NULL, FALSE); | |
| 623 | gaim_request_field_group_add_field(group, field); | |
| 624 | } | |
| 625 | if(xmlnode_get_child(query, "city")) { | |
| 626 | field = gaim_request_field_string_new("city", _("City"), | |
| 627 | NULL, FALSE); | |
| 628 | gaim_request_field_group_add_field(group, field); | |
| 629 | } | |
| 630 | if(xmlnode_get_child(query, "state")) { | |
| 631 | field = gaim_request_field_string_new("state", _("State"), | |
| 632 | NULL, FALSE); | |
| 633 | gaim_request_field_group_add_field(group, field); | |
| 634 | } | |
| 635 | if(xmlnode_get_child(query, "zip")) { | |
| 636 | field = gaim_request_field_string_new("zip", _("Postal Code"), | |
| 637 | NULL, FALSE); | |
| 638 | gaim_request_field_group_add_field(group, field); | |
| 639 | } | |
| 640 | if(xmlnode_get_child(query, "phone")) { | |
| 641 | field = gaim_request_field_string_new("phone", _("Phone"), | |
| 642 | NULL, FALSE); | |
| 643 | gaim_request_field_group_add_field(group, field); | |
| 644 | } | |
| 645 | if(xmlnode_get_child(query, "url")) { | |
| 646 | field = gaim_request_field_string_new("url", _("URL"), | |
| 647 | NULL, FALSE); | |
| 648 | gaim_request_field_group_add_field(group, field); | |
| 649 | } | |
| 650 | if(xmlnode_get_child(query, "date")) { | |
| 651 | field = gaim_request_field_string_new("date", _("Date"), | |
| 652 | NULL, FALSE); | |
| 653 | gaim_request_field_group_add_field(group, field); | |
| 654 | } | |
| 655 | ||
| 656 | if((y = xmlnode_get_child(query, "instructions"))) | |
| 657 | instructions = xmlnode_get_data(y); | |
| 658 | else | |
| 659 | instructions = g_strdup(_("Please fill out the information below " | |
| 660 | "to register your new account.")); | |
| 661 | ||
| 662 | gaim_request_fields(js->gc, _("Register New Jabber Account"), | |
| 663 | _("Register New Jabber Account"), instructions, fields, | |
| 664 | _("Register"), G_CALLBACK(jabber_register_cb), | |
| 665 | _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); | |
| 666 | } | |
| 667 | } | |
| 668 | ||
| 8016 | 669 | void jabber_register_start(JabberStream *js) |
| 7072 | 670 | { |
| 671 | JabberIq *iq; | |
| 672 | ||
| 673 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); | |
| 674 | jabber_iq_send(iq); | |
| 675 | } | |
| 676 | ||
| 677 | static void jabber_register_account(GaimAccount *account) | |
| 678 | { | |
| 679 | GaimConnection *gc = gaim_account_get_connection(account); | |
| 680 | JabberStream *js; | |
| 681 | const char *connect_server = gaim_account_get_string(account, | |
| 682 | "connect_server", ""); | |
| 683 | const char *server; | |
| 684 | int rc; | |
| 685 | ||
| 686 | js = gc->proto_data = g_new0(JabberStream, 1); | |
| 687 | js->gc = gc; | |
| 688 | js->registration = TRUE; | |
| 8312 | 689 | js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 690 | g_free, g_free); | |
| 691 | js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 7395 | 692 | g_free, g_free); |
| 7072 | 693 | js->user = jabber_id_new(gaim_account_get_username(account)); |
| 7322 | 694 | js->next_id = g_random_int(); |
| 7072 | 695 | |
| 7310 | 696 | if(!js->user) { |
| 697 | gaim_connection_error(gc, _("Invalid Jabber ID")); | |
| 698 | return; | |
| 699 | } | |
| 700 | ||
| 7147 | 701 | if(!js->user->resource) { |
| 702 | char *me; | |
| 703 | js->user->resource = g_strdup("Gaim"); | |
| 704 | if(!js->user->node) { | |
| 705 | js->user->node = js->user->domain; | |
| 706 | js->user->domain = g_strdup("jabber.org"); | |
| 707 | } | |
| 708 | me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
| 709 | js->user->resource); | |
| 710 | gaim_account_set_username(account, me); | |
| 711 | g_free(me); | |
| 712 | } | |
| 713 | ||
| 7072 | 714 | server = connect_server[0] ? connect_server : js->user->domain; |
| 715 | ||
| 716 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); | |
| 717 | ||
| 7630 | 718 | if(gaim_account_get_bool(account, "old_ssl", FALSE)) { |
| 719 | if(gaim_ssl_is_supported()) { | |
| 720 | js->gsc = gaim_ssl_connect(account, server, | |
| 721 | gaim_account_get_int(account, "port", 5222), | |
| 722 | jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); | |
| 723 | } else { | |
| 724 | gaim_connection_error(gc, _("SSL support unavailable")); | |
| 725 | } | |
| 7072 | 726 | } |
| 727 | ||
| 728 | if(!js->gsc) { | |
| 729 | rc = gaim_proxy_connect(account, server, | |
| 730 | gaim_account_get_int(account, "port", 5222), | |
| 731 | jabber_login_callback, gc); | |
| 732 | ||
| 733 | if (rc != 0) | |
| 734 | gaim_connection_error(gc, _("Unable to create socket")); | |
| 735 | } | |
| 736 | } | |
| 737 | ||
| 5572 | 738 | static void jabber_close(GaimConnection *gc) |
| 2086 | 739 | { |
| 7014 | 740 | JabberStream *js = gc->proto_data; |
| 2956 | 741 | |
| 7642 | 742 | jabber_send_raw(js, "</stream:stream>", -1); |
| 3311 | 743 | |
| 7014 | 744 | if(js->gsc) { |
| 745 | gaim_ssl_close(js->gsc); | |
| 8360 | 746 | } else if (js->fd > 0) { |
| 7072 | 747 | if(js->gc->inpa) |
| 748 | gaim_input_remove(js->gc->inpa); | |
| 7014 | 749 | close(js->fd); |
| 750 | } | |
| 3311 | 751 | |
| 7587 | 752 | if(js->context) |
| 753 | g_markup_parse_context_free(js->context); | |
| 8312 | 754 | if(js->iq_callbacks) |
| 755 | g_hash_table_destroy(js->iq_callbacks); | |
| 756 | if(js->disco_callbacks) | |
| 757 | g_hash_table_destroy(js->disco_callbacks); | |
| 7072 | 758 | if(js->buddies) |
| 759 | g_hash_table_destroy(js->buddies); | |
| 760 | if(js->chats) | |
| 761 | g_hash_table_destroy(js->chats); | |
| 8043 | 762 | while(js->chat_servers) { |
| 763 | g_free(js->chat_servers->data); | |
| 764 | js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers); | |
| 765 | } | |
| 7014 | 766 | if(js->stream_id) |
| 767 | g_free(js->stream_id); | |
| 7587 | 768 | if(js->user) |
| 769 | jabber_id_free(js->user); | |
| 7014 | 770 | g_free(js); |
| 5093 | 771 | } |
| 772 | ||
| 7014 | 773 | void jabber_stream_set_state(JabberStream *js, JabberStreamState state) |
|
3105
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
774 | { |
| 7014 | 775 | js->state = state; |
| 776 | switch(state) { | |
| 777 | case JABBER_STREAM_OFFLINE: | |
| 778 | break; | |
| 779 | case JABBER_STREAM_CONNECTING: | |
| 780 | gaim_connection_update_progress(js->gc, _("Connecting"), 1, | |
| 781 | JABBER_CONNECT_STEPS); | |
| 782 | break; | |
| 783 | case JABBER_STREAM_INITIALIZING: | |
| 784 | gaim_connection_update_progress(js->gc, _("Initializing Stream"), | |
| 785 | js->gsc ? 5 : 2, JABBER_CONNECT_STEPS); | |
| 786 | jabber_stream_init(js); | |
| 787 | jabber_parser_setup(js); | |
| 788 | break; | |
| 789 | case JABBER_STREAM_AUTHENTICATING: | |
| 790 | gaim_connection_update_progress(js->gc, _("Authenticating"), | |
| 791 | js->gsc ? 6 : 3, JABBER_CONNECT_STEPS); | |
| 8296 | 792 | if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) { |
| 793 | jabber_register_start(js); | |
| 794 | } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) { | |
| 795 | jabber_auth_start_old(js); | |
| 8016 | 796 | } |
| 7014 | 797 | break; |
| 798 | case JABBER_STREAM_REINITIALIZING: | |
| 799 | gaim_connection_update_progress(js->gc, _("Re-initializing Stream"), | |
| 800 | 6, JABBER_CONNECT_STEPS); | |
| 801 | jabber_stream_init(js); | |
| 802 | break; | |
| 803 | case JABBER_STREAM_CONNECTED: | |
| 804 | gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
| 805 | jabber_roster_request(js); | |
| 806 | jabber_presence_send(js->gc, js->gc->away_state, js->gc->away); | |
| 8312 | 807 | jabber_disco_items_server(js); |
| 7014 | 808 | serv_finish_login(js->gc); |
| 809 | break; | |
|
3105
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
810 | } |
|
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
811 | } |
|
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
812 | |
| 7014 | 813 | char *jabber_get_next_id(JabberStream *js) |
| 2086 | 814 | { |
| 7322 | 815 | return g_strdup_printf("gaim%x", js->next_id++); |
| 2086 | 816 | } |
| 817 | ||
| 7923 | 818 | |
| 819 | static void jabber_idle_set(GaimConnection *gc, int idle) | |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
820 | { |
| 7014 | 821 | JabberStream *js = gc->proto_data; |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
822 | |
| 7014 | 823 | js->idle = idle ? time(NULL) - idle : idle; |
|
3314
12fa45677717
[gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3311
diff
changeset
|
824 | } |
|
12fa45677717
[gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3311
diff
changeset
|
825 | |
| 6695 | 826 | static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) |
| 2086 | 827 | { |
| 4687 | 828 | return "jabber"; |
| 829 | } | |
| 4916 | 830 | |
| 7014 | 831 | static void jabber_list_emblems(GaimBuddy *b, char **se, char **sw, |
| 832 | char **nw, char **ne) | |
| 4916 | 833 | { |
| 7014 | 834 | JabberStream *js; |
| 835 | JabberBuddy *jb; | |
| 836 | ||
| 837 | if(!b->account->gc) | |
| 838 | return; | |
| 839 | js = b->account->gc->proto_data; | |
| 840 | jb = jabber_buddy_find(js, b->name, FALSE); | |
| 5135 | 841 | |
| 842 | if(!GAIM_BUDDY_IS_ONLINE(b)) { | |
| 7014 | 843 | if(jb && jb->error_msg) |
| 4927 | 844 | *nw = "error"; |
| 5135 | 845 | |
| 7014 | 846 | if(jb && (jb->subscription & JABBER_SUB_PENDING || |
| 847 | !(jb->subscription & JABBER_SUB_TO))) | |
| 5135 | 848 | *se = "notauthorized"; |
| 849 | else | |
| 850 | *se = "offline"; | |
| 4916 | 851 | } else { |
| 852 | switch (b->uc) { | |
| 7014 | 853 | case JABBER_STATE_AWAY: |
| 854 | *se = "away"; | |
| 855 | break; | |
| 856 | case JABBER_STATE_CHAT: | |
| 857 | *se = "chat"; | |
| 858 | break; | |
| 859 | case JABBER_STATE_XA: | |
| 860 | *se = "extendedaway"; | |
| 861 | break; | |
| 862 | case JABBER_STATE_DND: | |
| 8193 | 863 | *se = "dnd"; |
| 7014 | 864 | break; |
| 865 | case JABBER_STATE_ERROR: | |
| 866 | *se = "error"; | |
| 867 | break; | |
| 4916 | 868 | } |
| 2086 | 869 | } |
| 4916 | 870 | } |
| 2086 | 871 | |
| 7014 | 872 | static char *jabber_status_text(GaimBuddy *b) |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
873 | { |
| 7014 | 874 | JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
| 875 | FALSE); | |
| 876 | char *ret = NULL; | |
| 5234 | 877 | |
| 7014 | 878 | if(jb && !GAIM_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { |
| 879 | ret = g_strdup(_("Not Authorized")); | |
| 880 | } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
| 881 | ret = g_strdup(jb->error_msg); | |
| 2956 | 882 | } else { |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
883 | char *stripped; |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
884 | |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
885 | stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)); |
| 2956 | 886 | |
| 7014 | 887 | if(!stripped && b->uc & UC_UNAVAILABLE) |
| 888 | stripped = g_strdup(jabber_get_state_string(b->uc)); | |
| 2086 | 889 | |
| 7014 | 890 | if(stripped) { |
| 891 | ret = g_markup_escape_text(stripped, -1); | |
| 892 | g_free(stripped); | |
| 893 | } | |
| 2086 | 894 | } |
| 895 | ||
| 7014 | 896 | return ret; |
| 2956 | 897 | } |
| 898 | ||
| 6695 | 899 | static char *jabber_tooltip_text(GaimBuddy *b) |
| 4744 | 900 | { |
| 7014 | 901 | JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
| 902 | FALSE); | |
| 8194 | 903 | GString *ret = g_string_new(""); |
| 7014 | 904 | |
| 8194 | 905 | if(jb) { |
| 906 | JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL); | |
| 907 | const char *sub; | |
| 908 | if(jb->subscription & JABBER_SUB_FROM) { | |
| 909 | if(jb->subscription & JABBER_SUB_TO) | |
| 910 | sub = _("Both"); | |
| 911 | else if(jb->subscription & JABBER_SUB_PENDING) | |
| 912 | sub = _("From (To pending)"); | |
| 913 | else | |
| 914 | sub = _("From"); | |
| 915 | } else { | |
| 916 | if(jb->subscription & JABBER_SUB_TO) | |
| 917 | sub = _("To"); | |
| 918 | else if(jb->subscription & JABBER_SUB_PENDING) | |
| 919 | sub = _("None (To pending)"); | |
| 920 | else | |
| 921 | sub = _("None"); | |
| 922 | } | |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
923 | g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Subscription"), sub); |
| 8194 | 924 | |
| 925 | if(jbr) { | |
| 926 | char *text = NULL; | |
| 927 | if(jbr->status) { | |
| 928 | char *stripped; | |
| 929 | stripped = gaim_markup_strip_html(jbr->status); | |
| 930 | text = g_markup_escape_text(stripped, -1); | |
| 931 | g_free(stripped); | |
| 932 | } | |
| 933 | ||
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
934 | g_string_append_printf(ret, "\n<b>%s:</b> %s%s%s", |
| 8194 | 935 | _("Status"), |
| 936 | jabber_get_state_string(jbr->state), | |
| 937 | text ? ": " : "", | |
| 938 | text ? text : ""); | |
| 939 | if(text) | |
| 940 | g_free(text); | |
| 941 | } else if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
942 | g_string_append_printf(ret, "\n<b>%s:</b> %s", |
| 8194 | 943 | _("Error"), jb->error_msg); |
| 944 | } | |
| 4745 | 945 | } |
| 4744 | 946 | |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
947 | return g_string_free(ret, FALSE); |
| 4732 | 948 | } |
| 949 | ||
| 7014 | 950 | static GList *jabber_away_states(GaimConnection *gc) |
| 951 | { | |
| 8166 | 952 | JabberStream *js = gc->proto_data; |
| 2086 | 953 | GList *m = NULL; |
| 954 | ||
| 4982 | 955 | m = g_list_append(m, _("Online")); |
| 956 | m = g_list_append(m, _("Chatty")); | |
| 957 | m = g_list_append(m, _("Away")); | |
| 958 | m = g_list_append(m, _("Extended Away")); | |
| 959 | m = g_list_append(m, _("Do Not Disturb")); | |
| 8166 | 960 | if(js->protocol_version == JABBER_PROTO_0_9) |
| 961 | m = g_list_append(m, _("Invisible")); | |
|
4110
481c7ea9e258
[gaim-migrate @ 4325]
Robert McQueen <robot101@debian.org>
parents:
4074
diff
changeset
|
962 | m = g_list_append(m, GAIM_AWAY_CUSTOM); |
| 2086 | 963 | |
| 964 | return m; | |
| 965 | } | |
| 966 | ||
| 7395 | 967 | static void |
| 968 | jabber_password_change_result_cb(JabberStream *js, xmlnode *packet, | |
| 969 | gpointer data) | |
| 7124 | 970 | { |
| 971 | const char *type; | |
| 972 | ||
| 973 | type = xmlnode_get_attrib(packet, "type"); | |
| 974 | ||
| 975 | if(!strcmp(type, "result")) { | |
| 976 | gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"), | |
| 977 | _("Your password has been changed.")); | |
| 978 | } else { | |
| 8401 | 979 | char *msg = jabber_parse_error(js, packet); |
| 7124 | 980 | |
| 8401 | 981 | gaim_notify_error(js->gc, _("Error changing password"), |
| 982 | _("Error changing password"), msg); | |
| 983 | g_free(msg); | |
| 7124 | 984 | } |
| 985 | } | |
| 986 | ||
| 987 | static void jabber_password_change_cb(JabberStream *js, | |
| 988 | GaimRequestFields *fields) | |
| 989 | { | |
| 990 | const char *p1, *p2; | |
| 991 | JabberIq *iq; | |
| 992 | xmlnode *query, *y; | |
| 993 | ||
| 994 | p1 = gaim_request_fields_get_string(fields, "password1"); | |
| 995 | p2 = gaim_request_fields_get_string(fields, "password2"); | |
| 996 | ||
| 997 | if(strcmp(p1, p2)) { | |
| 998 | gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); | |
| 999 | return; | |
| 1000 | } | |
| 1001 | ||
| 1002 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 1003 | ||
| 1004 | xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
| 1005 | ||
| 1006 | query = xmlnode_get_child(iq->node, "query"); | |
| 1007 | ||
| 1008 | y = xmlnode_new_child(query, "username"); | |
| 1009 | xmlnode_insert_data(y, js->user->node, -1); | |
| 1010 | y = xmlnode_new_child(query, "password"); | |
| 1011 | xmlnode_insert_data(y, p1, -1); | |
| 1012 | ||
| 7395 | 1013 | jabber_iq_set_callback(iq, jabber_password_change_result_cb, NULL); |
| 7124 | 1014 | |
| 1015 | jabber_iq_send(iq); | |
| 1016 | ||
| 1017 | gaim_account_set_password(js->gc->account, p1); | |
| 1018 | } | |
| 1019 | ||
| 1020 | static void jabber_password_change(GaimConnection *gc) | |
| 1021 | { | |
| 1022 | JabberStream *js = gc->proto_data; | |
| 1023 | GaimRequestFields *fields; | |
| 1024 | GaimRequestFieldGroup *group; | |
| 1025 | GaimRequestField *field; | |
| 1026 | ||
| 1027 | fields = gaim_request_fields_new(); | |
| 1028 | group = gaim_request_field_group_new(NULL); | |
| 1029 | gaim_request_fields_add_group(fields, group); | |
| 1030 | ||
| 1031 | field = gaim_request_field_string_new("password1", _("Password"), | |
| 1032 | "", FALSE); | |
| 1033 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1034 | gaim_request_field_group_add_field(group, field); | |
| 1035 | ||
| 1036 | field = gaim_request_field_string_new("password2", _("Password (again)"), | |
| 1037 | "", FALSE); | |
| 1038 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1039 | gaim_request_field_group_add_field(group, field); | |
| 1040 | ||
| 1041 | gaim_request_fields(js->gc, _("Change Jabber Password"), | |
| 1042 | _("Change Jabber Password"), _("Please enter your new password"), | |
| 1043 | fields, _("OK"), G_CALLBACK(jabber_password_change_cb), | |
| 1044 | _("Cancel"), NULL, js); | |
| 1045 | } | |
| 1046 | ||
| 5572 | 1047 | static GList *jabber_actions(GaimConnection *gc) |
| 2956 | 1048 | { |
| 1049 | GList *m = NULL; | |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1050 | struct proto_actions_menu *pam; |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1051 | |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1052 | pam = g_new0(struct proto_actions_menu, 1); |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1053 | pam->label = _("Set User Info"); |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1054 | pam->callback = jabber_setup_set_info; |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1055 | pam->gc = gc; |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1056 | m = g_list_append(m, pam); |
|
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1057 | |
| 8296 | 1058 | /* if (js->protocol_options & CHANGE_PASSWORD) { */ |
| 7124 | 1059 | pam = g_new0(struct proto_actions_menu, 1); |
| 1060 | pam->label = _("Change Password"); | |
| 1061 | pam->callback = jabber_password_change; | |
| 1062 | pam->gc = gc; | |
| 1063 | m = g_list_append(m, pam); | |
| 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 | ||
| 8713 | 1270 | static GaimPluginPrefFrame * |
| 1271 | get_plugin_pref_frame(GaimPlugin *plugin) { | |
| 1272 | GaimPluginPrefFrame *frame; | |
| 1273 | GaimPluginPref *ppref; | |
| 1274 | ||
| 1275 | frame = gaim_plugin_pref_frame_new(); | |
| 1276 | ||
| 1277 | ppref = gaim_plugin_pref_new_with_label(_("Privacy")); | |
| 1278 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 1279 | ||
| 1280 | ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/jabber/hide_os", | |
| 1281 | _("Hide Operating System")); | |
| 1282 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 1283 | ||
| 1284 | return frame; | |
| 1285 | } | |
| 1286 | ||
| 1287 | static GaimPluginUiInfo prefs_info = { | |
| 1288 | get_plugin_pref_frame | |
| 1289 | }; | |
| 1290 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1291 | static GaimPluginProtocolInfo prpl_info = |
| 2086 | 1292 | { |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8713
diff
changeset
|
1293 | GAIM_PRPL_API_VERSION, |
| 7014 | 1294 | OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1295 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1296 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1297 | jabber_list_icon, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1298 | jabber_list_emblems, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1299 | jabber_status_text, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1300 | jabber_tooltip_text, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1301 | jabber_away_states, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1302 | jabber_actions, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1303 | jabber_buddy_menu, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1304 | jabber_chat_info, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1305 | jabber_login, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1306 | jabber_close, |
| 7014 | 1307 | jabber_message_send_im, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1308 | jabber_set_info, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1309 | jabber_send_typing, |
| 7014 | 1310 | jabber_buddy_get_info, |
| 1311 | jabber_presence_send, | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1312 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1313 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1314 | NULL, |
| 7014 | 1315 | jabber_idle_set, |
| 7514 | 1316 | NULL, |
| 7014 | 1317 | jabber_roster_add_buddy, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1318 | NULL, |
| 7014 | 1319 | jabber_roster_remove_buddy, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1320 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1321 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1322 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1323 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1324 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1325 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1326 | NULL, |
| 7014 | 1327 | jabber_chat_join, |
|
8562
7e73676d1772
[gaim-migrate @ 9306]
Christopher O'Brien <siege@pidgin.im>
parents:
8402
diff
changeset
|
1328 | NULL, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1329 | jabber_chat_invite, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1330 | jabber_chat_leave, |
| 7400 | 1331 | NULL, |
| 7014 | 1332 | jabber_message_send_chat, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1333 | jabber_keepalive, |
| 7072 | 1334 | jabber_register_account, |
| 7014 | 1335 | jabber_buddy_get_info_chat, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1336 | NULL, |
| 7014 | 1337 | jabber_roster_alias_change, |
| 1338 | jabber_roster_group_change, | |
| 1339 | jabber_roster_group_rename, | |
| 1340 | NULL, | |
| 8400 | 1341 | jabber_convo_closed, |
| 7398 | 1342 | jabber_normalize, |
| 1343 | NULL, /* set_buddy_icon */ | |
| 1344 | NULL, /* remove_group */ | |
| 7971 | 1345 | jabber_chat_buddy_real_name, |
| 7999 | 1346 | jabber_chat_set_topic, |
| 8113 | 1347 | jabber_find_blist_chat, |
| 1348 | jabber_roomlist_get_list, | |
| 1349 | jabber_roomlist_cancel, | |
|
8586
c8c7a19da549
[gaim-migrate @ 9336]
Pekka Riikonen <priikone@silcnet.org>
parents:
8568
diff
changeset
|
1350 | NULL, |
|
8589
21b3d99bb8e7
[gaim-migrate @ 9340]
Mark Doliner <markdoliner@pidgin.im>
parents:
8586
diff
changeset
|
1351 | NULL |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1352 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1353 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1354 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1355 | { |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8713
diff
changeset
|
1356 | GAIM_PLUGIN_API_VERSION, /**< api_version */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1357 | GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1358 | NULL, /**< ui_requirement */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1359 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1360 | NULL, /**< dependencies */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1361 | GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1362 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1363 | "prpl-jabber", /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1364 | "Jabber", /**< name */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1365 | VERSION, /**< version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1366 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1367 | N_("Jabber Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1368 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1369 | N_("Jabber Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1370 | NULL, /**< author */ |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
1371 | GAIM_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1372 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1373 | NULL, /**< load */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1374 | NULL, /**< unload */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1375 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1376 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1377 | NULL, /**< ui_info */ |
| 8713 | 1378 | &prpl_info, /**< extra_info */ |
| 1379 | &prefs_info /**< prefs_info */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1380 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1381 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1382 | static void |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1383 | init_plugin(GaimPlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1384 | { |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1385 | GaimAccountUserSplit *split; |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1386 | GaimAccountOption *option; |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1387 | |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1388 | split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1389 | 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
|
1390 | |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1391 | split = gaim_account_user_split_new(_("Resource"), "Gaim", '/'); |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1392 | 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
|
1393 | |
| 7630 | 1394 | option = gaim_account_option_bool_new(_("Use TLS if available"), "use_tls", |
| 1395 | TRUE); | |
| 1396 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 1397 | option); | |
| 1398 | ||
| 1399 | option = gaim_account_option_bool_new(_("Force old SSL"), "old_ssl", FALSE); | |
| 7124 | 1400 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 1401 | option); | |
| 6764 | 1402 | |
| 8086 | 1403 | option = gaim_account_option_bool_new( |
| 1404 | _("Allow plaintext auth over unencrypted streams"), | |
| 1405 | "auth_plain_in_clear", FALSE); | |
| 1406 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 1407 | option); | |
| 1408 | ||
| 7014 | 1409 | option = gaim_account_option_int_new(_("Port"), "port", 5222); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1410 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 7014 | 1411 | option); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1412 | |
|
5685
2523e4143d74
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1413 | option = gaim_account_option_string_new(_("Connect server"), |
| 7014 | 1414 | "connect_server", NULL); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1415 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 7014 | 1416 | option); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1417 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1418 | my_protocol = plugin; |
| 7014 | 1419 | |
| 1420 | gaim_prefs_add_none("/plugins/prpl/jabber"); | |
| 1421 | gaim_prefs_add_bool("/plugins/prpl/jabber/hide_os", FALSE); | |
| 2086 | 1422 | } |
| 1423 | ||
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1424 | GAIM_INIT_PLUGIN(jabber, init_plugin, info); |