[f06894d] | 1 | /***************************************************************************\ |
---|
| 2 | * * |
---|
| 3 | * BitlBee - An IRC to IM gateway * |
---|
| 4 | * Jabber module - IQ packets * |
---|
| 5 | * * |
---|
| 6 | * Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net> * |
---|
| 7 | * * |
---|
| 8 | * This program is free software; you can redistribute it and/or modify * |
---|
| 9 | * it under the terms of the GNU General Public License as published by * |
---|
| 10 | * the Free Software Foundation; either version 2 of the License, or * |
---|
| 11 | * (at your option) any later version. * |
---|
| 12 | * * |
---|
| 13 | * This program is distributed in the hope that it will be useful, * |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
| 16 | * GNU General Public License for more details. * |
---|
| 17 | * * |
---|
| 18 | * You should have received a copy of the GNU General Public License along * |
---|
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., * |
---|
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * |
---|
| 21 | * * |
---|
| 22 | \***************************************************************************/ |
---|
| 23 | |
---|
| 24 | #include "jabber.h" |
---|
[77bfd07] | 25 | #include "sha1.h" |
---|
[f06894d] | 26 | |
---|
[0da65d5] | 27 | static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); |
---|
| 28 | static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); |
---|
[abbd8ed] | 29 | |
---|
[f06894d] | 30 | xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) |
---|
| 31 | { |
---|
[0da65d5] | 32 | struct im_connection *ic = data; |
---|
[58b5f62] | 33 | struct xt_node *c, *reply = NULL; |
---|
[861c199] | 34 | char *type, *s; |
---|
[259edd4] | 35 | int st, pack = 1; |
---|
[21167d2] | 36 | |
---|
[70f6aab8] | 37 | type = xt_find_attr( node, "type" ); |
---|
[f06894d] | 38 | |
---|
[70f6aab8] | 39 | if( !type ) |
---|
[861c199] | 40 | { |
---|
[84b045d] | 41 | imcb_error( ic, "Received IQ packet without type." ); |
---|
[c2fb3809] | 42 | imc_logout( ic, TRUE ); |
---|
[861c199] | 43 | return XT_ABORT; |
---|
| 44 | } |
---|
[21167d2] | 45 | |
---|
[58b5f62] | 46 | if( strcmp( type, "result" ) == 0 || strcmp( type, "error" ) == 0 ) |
---|
[861c199] | 47 | { |
---|
[4306d8b] | 48 | return jabber_cache_handle_packet( ic, node ); |
---|
[861c199] | 49 | } |
---|
[58b5f62] | 50 | else if( strcmp( type, "get" ) == 0 ) |
---|
| 51 | { |
---|
[eded1f7] | 52 | if( !( ( c = xt_find_node( node->children, "query" ) ) || |
---|
[74349eb] | 53 | ( c = xt_find_node( node->children, "ping" ) ) ) || |
---|
[58b5f62] | 54 | !( s = xt_find_attr( c, "xmlns" ) ) ) |
---|
| 55 | { |
---|
[74349eb] | 56 | /* Sigh. Who decided to suddenly invent new elements |
---|
| 57 | instead of just sticking with <query/>? */ |
---|
[58b5f62] | 58 | return XT_HANDLED; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | reply = xt_new_node( "query", NULL, NULL ); |
---|
| 62 | xt_add_attr( reply, "xmlns", s ); |
---|
| 63 | |
---|
| 64 | /* Of course this is a very essential query to support. ;-) */ |
---|
[47d3ac4] | 65 | if( strcmp( s, XMLNS_VERSION ) == 0 ) |
---|
[58b5f62] | 66 | { |
---|
| 67 | xt_add_child( reply, xt_new_node( "name", "BitlBee", NULL ) ); |
---|
| 68 | xt_add_child( reply, xt_new_node( "version", BITLBEE_VERSION, NULL ) ); |
---|
| 69 | xt_add_child( reply, xt_new_node( "os", ARCH, NULL ) ); |
---|
| 70 | } |
---|
[47d3ac4] | 71 | else if( strcmp( s, XMLNS_TIME ) == 0 ) |
---|
[a4effbf] | 72 | { |
---|
| 73 | time_t time_ep; |
---|
| 74 | char buf[1024]; |
---|
| 75 | |
---|
| 76 | buf[sizeof(buf)-1] = 0; |
---|
| 77 | time_ep = time( NULL ); |
---|
| 78 | |
---|
| 79 | strftime( buf, sizeof( buf ) - 1, "%Y%m%dT%H:%M:%S", gmtime( &time_ep ) ); |
---|
| 80 | xt_add_child( reply, xt_new_node( "utc", buf, NULL ) ); |
---|
| 81 | |
---|
| 82 | strftime( buf, sizeof( buf ) - 1, "%Z", localtime( &time_ep ) ); |
---|
| 83 | xt_add_child( reply, xt_new_node( "tz", buf, NULL ) ); |
---|
| 84 | } |
---|
[eded1f7] | 85 | else if( strcmp( s, XMLNS_PING ) == 0 ) |
---|
| 86 | { |
---|
| 87 | xt_free_node( reply ); |
---|
| 88 | reply = jabber_make_packet( "iq", "result", xt_find_attr( node, "from" ), NULL ); |
---|
| 89 | if( ( s = xt_find_attr( node, "id" ) ) ) |
---|
| 90 | xt_add_attr( reply, "id", s ); |
---|
| 91 | pack = 0; |
---|
| 92 | } |
---|
[dc0ba9c] | 93 | else if( strcmp( s, XMLNS_DISCO_INFO ) == 0 ) |
---|
[58b5f62] | 94 | { |
---|
[1ba7e8f] | 95 | const char *features[] = { XMLNS_DISCO_INFO, |
---|
[8c1eb80] | 96 | XMLNS_VERSION, |
---|
[40ef702] | 97 | XMLNS_TIME, |
---|
| 98 | XMLNS_CHATSTATES, |
---|
| 99 | XMLNS_MUC, |
---|
[eded1f7] | 100 | XMLNS_PING, |
---|
[1c3008a] | 101 | XMLNS_SI, |
---|
| 102 | XMLNS_BYTESTREAMS, |
---|
| 103 | XMLNS_FILETRANSFER, |
---|
[40ef702] | 104 | NULL }; |
---|
| 105 | const char **f; |
---|
| 106 | |
---|
[58b5f62] | 107 | c = xt_new_node( "identity", NULL, NULL ); |
---|
| 108 | xt_add_attr( c, "category", "client" ); |
---|
| 109 | xt_add_attr( c, "type", "pc" ); |
---|
| 110 | xt_add_attr( c, "name", "BitlBee" ); |
---|
| 111 | xt_add_child( reply, c ); |
---|
| 112 | |
---|
[40ef702] | 113 | for( f = features; *f; f ++ ) |
---|
| 114 | { |
---|
| 115 | c = xt_new_node( "feature", NULL, NULL ); |
---|
| 116 | xt_add_attr( c, "var", *f ); |
---|
| 117 | xt_add_child( reply, c ); |
---|
| 118 | } |
---|
[58b5f62] | 119 | } |
---|
| 120 | else |
---|
| 121 | { |
---|
| 122 | xt_free_node( reply ); |
---|
[2c2df7d] | 123 | reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel", NULL ); |
---|
[259edd4] | 124 | pack = 0; |
---|
[58b5f62] | 125 | } |
---|
[259edd4] | 126 | } |
---|
| 127 | else if( strcmp( type, "set" ) == 0 ) |
---|
| 128 | { |
---|
[1c3008a] | 129 | if( ( c = xt_find_node( node->children, "si" ) ) && |
---|
[aed152f] | 130 | ( s = xt_find_attr( c, "xmlns" ) ) && |
---|
| 131 | ( strcmp( s, XMLNS_SI ) == 0 ) ) |
---|
[2c2df7d] | 132 | { |
---|
| 133 | return jabber_si_handle_request( ic, node, c ); |
---|
[1c3008a] | 134 | } |
---|
| 135 | else if( !( c = xt_find_node( node->children, "query" ) ) || |
---|
| 136 | !( s = xt_find_attr( c, "xmlns" ) ) ) |
---|
[dfa41a4] | 137 | { |
---|
| 138 | return XT_HANDLED; |
---|
[1c3008a] | 139 | } |
---|
| 140 | else if( strcmp( s, XMLNS_ROSTER ) == 0 ) |
---|
[2c2df7d] | 141 | { |
---|
[9bcbe48] | 142 | /* This is a roster push. XMPP servers send this when someone |
---|
| 143 | was added to (or removed from) the buddy list. AFAIK they're |
---|
| 144 | sent even if we added this buddy in our own session. */ |
---|
[0da65d5] | 145 | int bare_len = strlen( ic->acc->user ); |
---|
[abbd8ed] | 146 | |
---|
| 147 | if( ( s = xt_find_attr( node, "from" ) ) == NULL || |
---|
[0da65d5] | 148 | ( strncmp( s, ic->acc->user, bare_len ) == 0 && |
---|
[abbd8ed] | 149 | ( s[bare_len] == 0 || s[bare_len] == '/' ) ) ) |
---|
| 150 | { |
---|
[0da65d5] | 151 | jabber_parse_roster( ic, node, NULL ); |
---|
[abbd8ed] | 152 | |
---|
| 153 | /* Should we generate a reply here? Don't think it's |
---|
| 154 | very important... */ |
---|
| 155 | } |
---|
| 156 | else |
---|
| 157 | { |
---|
[43462708] | 158 | imcb_log( ic, "Warning: %s tried to fake a roster push!", s ? s : "(unknown)" ); |
---|
[abbd8ed] | 159 | |
---|
| 160 | xt_free_node( reply ); |
---|
[2c2df7d] | 161 | reply = jabber_make_error_packet( node, "not-allowed", "cancel", NULL ); |
---|
[abbd8ed] | 162 | pack = 0; |
---|
| 163 | } |
---|
[1c3008a] | 164 | } |
---|
| 165 | else if( strcmp( s, XMLNS_BYTESTREAMS ) == 0 ) |
---|
[2c2df7d] | 166 | { |
---|
[1c3008a] | 167 | /* Bytestream Request (stage 2 of file transfer) */ |
---|
[2ff2076] | 168 | return jabber_bs_recv_request( ic, node, c ); |
---|
[1c3008a] | 169 | } |
---|
| 170 | else |
---|
[dfa41a4] | 171 | { |
---|
| 172 | xt_free_node( reply ); |
---|
[2c2df7d] | 173 | reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel", NULL ); |
---|
[dfa41a4] | 174 | pack = 0; |
---|
| 175 | } |
---|
[259edd4] | 176 | } |
---|
| 177 | |
---|
| 178 | /* If we recognized the xmlns and managed to generate a reply, |
---|
| 179 | finish and send it. */ |
---|
| 180 | if( reply ) |
---|
| 181 | { |
---|
| 182 | /* Normally we still have to pack it into an iq-result |
---|
| 183 | packet, but for errors, for example, we don't. */ |
---|
| 184 | if( pack ) |
---|
[58b5f62] | 185 | { |
---|
| 186 | reply = jabber_make_packet( "iq", "result", xt_find_attr( node, "from" ), reply ); |
---|
| 187 | if( ( s = xt_find_attr( node, "id" ) ) ) |
---|
| 188 | xt_add_attr( reply, "id", s ); |
---|
| 189 | } |
---|
[259edd4] | 190 | |
---|
[0da65d5] | 191 | st = jabber_write_packet( ic, reply ); |
---|
[259edd4] | 192 | xt_free_node( reply ); |
---|
| 193 | if( !st ) |
---|
| 194 | return XT_ABORT; |
---|
[58b5f62] | 195 | } |
---|
[70f6aab8] | 196 | |
---|
[861c199] | 197 | return XT_HANDLED; |
---|
| 198 | } |
---|
| 199 | |
---|
[0da65d5] | 200 | static xt_status jabber_do_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); |
---|
| 201 | static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); |
---|
[861c199] | 202 | |
---|
[0da65d5] | 203 | int jabber_init_iq_auth( struct im_connection *ic ) |
---|
[861c199] | 204 | { |
---|
[0da65d5] | 205 | struct jabber_data *jd = ic->proto_data; |
---|
[861c199] | 206 | struct xt_node *node; |
---|
| 207 | int st; |
---|
[fe7a554] | 208 | |
---|
[861c199] | 209 | node = xt_new_node( "query", NULL, xt_new_node( "username", jd->username, NULL ) ); |
---|
[47d3ac4] | 210 | xt_add_attr( node, "xmlns", XMLNS_AUTH ); |
---|
[861c199] | 211 | node = jabber_make_packet( "iq", "get", NULL, node ); |
---|
| 212 | |
---|
[0da65d5] | 213 | jabber_cache_add( ic, node, jabber_do_iq_auth ); |
---|
| 214 | st = jabber_write_packet( ic, node ); |
---|
[861c199] | 215 | |
---|
| 216 | return st; |
---|
| 217 | } |
---|
| 218 | |
---|
[0da65d5] | 219 | static xt_status jabber_do_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) |
---|
[861c199] | 220 | { |
---|
[0da65d5] | 221 | struct jabber_data *jd = ic->proto_data; |
---|
[861c199] | 222 | struct xt_node *reply, *query; |
---|
| 223 | xt_status st; |
---|
| 224 | char *s; |
---|
| 225 | |
---|
[9bcbe48] | 226 | if( !( query = xt_find_node( node->children, "query" ) ) ) |
---|
| 227 | { |
---|
[43462708] | 228 | imcb_log( ic, "Warning: Received incomplete IQ packet while authenticating" ); |
---|
[c2fb3809] | 229 | imc_logout( ic, FALSE ); |
---|
[9bcbe48] | 230 | return XT_HANDLED; |
---|
| 231 | } |
---|
[861c199] | 232 | |
---|
| 233 | /* Time to authenticate ourselves! */ |
---|
| 234 | reply = xt_new_node( "query", NULL, NULL ); |
---|
[47d3ac4] | 235 | xt_add_attr( reply, "xmlns", XMLNS_AUTH ); |
---|
[861c199] | 236 | xt_add_child( reply, xt_new_node( "username", jd->username, NULL ) ); |
---|
[0da65d5] | 237 | xt_add_child( reply, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) ); |
---|
[861c199] | 238 | |
---|
| 239 | if( xt_find_node( query->children, "digest" ) && ( s = xt_find_attr( jd->xt->root, "id" ) ) ) |
---|
[21167d2] | 240 | { |
---|
[861c199] | 241 | /* We can do digest authentication, it seems, and of |
---|
| 242 | course we prefer that. */ |
---|
[77bfd07] | 243 | sha1_state_t sha; |
---|
[e727608] | 244 | char hash_hex[41]; |
---|
[861c199] | 245 | unsigned char hash[20]; |
---|
| 246 | int i; |
---|
[21167d2] | 247 | |
---|
[77bfd07] | 248 | sha1_init( &sha ); |
---|
| 249 | sha1_append( &sha, (unsigned char*) s, strlen( s ) ); |
---|
| 250 | sha1_append( &sha, (unsigned char*) ic->acc->pass, strlen( ic->acc->pass ) ); |
---|
| 251 | sha1_finish( &sha, hash ); |
---|
[21167d2] | 252 | |
---|
[861c199] | 253 | for( i = 0; i < 20; i ++ ) |
---|
| 254 | sprintf( hash_hex + i * 2, "%02x", hash[i] ); |
---|
[21167d2] | 255 | |
---|
[861c199] | 256 | xt_add_child( reply, xt_new_node( "digest", hash_hex, NULL ) ); |
---|
[21167d2] | 257 | } |
---|
[861c199] | 258 | else if( xt_find_node( query->children, "password" ) ) |
---|
[0b4a0db] | 259 | { |
---|
[861c199] | 260 | /* We'll have to stick with plaintext. Let's hope we're using SSL/TLS... */ |
---|
[0da65d5] | 261 | xt_add_child( reply, xt_new_node( "password", ic->acc->pass, NULL ) ); |
---|
[0b4a0db] | 262 | } |
---|
[861c199] | 263 | else |
---|
[70f6aab8] | 264 | { |
---|
[861c199] | 265 | xt_free_node( reply ); |
---|
[995913b] | 266 | |
---|
[84b045d] | 267 | imcb_error( ic, "Can't find suitable authentication method" ); |
---|
[c2fb3809] | 268 | imc_logout( ic, FALSE ); |
---|
[861c199] | 269 | return XT_ABORT; |
---|
[70f6aab8] | 270 | } |
---|
[861c199] | 271 | |
---|
| 272 | reply = jabber_make_packet( "iq", "set", NULL, reply ); |
---|
[0da65d5] | 273 | jabber_cache_add( ic, reply, jabber_finish_iq_auth ); |
---|
| 274 | st = jabber_write_packet( ic, reply ); |
---|
[861c199] | 275 | |
---|
| 276 | return st ? XT_HANDLED : XT_ABORT; |
---|
| 277 | } |
---|
| 278 | |
---|
[0da65d5] | 279 | static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) |
---|
[861c199] | 280 | { |
---|
[0da65d5] | 281 | struct jabber_data *jd = ic->proto_data; |
---|
[9bcbe48] | 282 | char *type; |
---|
| 283 | |
---|
| 284 | if( !( type = xt_find_attr( node, "type" ) ) ) |
---|
| 285 | { |
---|
[43462708] | 286 | imcb_log( ic, "Warning: Received incomplete IQ packet while authenticating" ); |
---|
[c2fb3809] | 287 | imc_logout( ic, FALSE ); |
---|
[9bcbe48] | 288 | return XT_HANDLED; |
---|
| 289 | } |
---|
[861c199] | 290 | |
---|
| 291 | if( strcmp( type, "error" ) == 0 ) |
---|
[70f6aab8] | 292 | { |
---|
[84b045d] | 293 | imcb_error( ic, "Authentication failure" ); |
---|
[c2fb3809] | 294 | imc_logout( ic, FALSE ); |
---|
[861c199] | 295 | return XT_ABORT; |
---|
| 296 | } |
---|
| 297 | else if( strcmp( type, "result" ) == 0 ) |
---|
| 298 | { |
---|
| 299 | /* This happens when we just successfully authenticated the |
---|
| 300 | old (non-SASL) way. */ |
---|
| 301 | jd->flags |= JFLAG_AUTHENTICATED; |
---|
[0da65d5] | 302 | if( !jabber_get_roster( ic ) ) |
---|
[70f6aab8] | 303 | return XT_ABORT; |
---|
| 304 | } |
---|
[f06894d] | 305 | |
---|
| 306 | return XT_HANDLED; |
---|
| 307 | } |
---|
| 308 | |
---|
[0da65d5] | 309 | xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) |
---|
[21167d2] | 310 | { |
---|
[0da65d5] | 311 | struct jabber_data *jd = ic->proto_data; |
---|
[8fb1263] | 312 | struct xt_node *c, *reply = NULL; |
---|
[861c199] | 313 | char *s; |
---|
[21167d2] | 314 | |
---|
[8fb1263] | 315 | if( node && ( c = xt_find_node( node->children, "bind" ) ) ) |
---|
[861c199] | 316 | { |
---|
| 317 | c = xt_find_node( c->children, "jid" ); |
---|
| 318 | if( c && c->text_len && ( s = strchr( c->text, '/' ) ) && |
---|
[0da65d5] | 319 | strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 ) |
---|
[84b045d] | 320 | imcb_log( ic, "Server changed session resource string to `%s'", s + 1 ); |
---|
[861c199] | 321 | } |
---|
[21167d2] | 322 | |
---|
[8fb1263] | 323 | if( jd->flags & JFLAG_WANT_BIND ) |
---|
| 324 | { |
---|
| 325 | reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) ); |
---|
| 326 | xt_add_attr( reply, "xmlns", XMLNS_BIND ); |
---|
[315dd4c] | 327 | jd->flags &= ~JFLAG_WANT_BIND; |
---|
[8fb1263] | 328 | } |
---|
| 329 | else if( jd->flags & JFLAG_WANT_SESSION ) |
---|
[861c199] | 330 | { |
---|
[8fb1263] | 331 | reply = xt_new_node( "session", NULL, NULL ); |
---|
| 332 | xt_add_attr( reply, "xmlns", XMLNS_SESSION ); |
---|
[315dd4c] | 333 | jd->flags &= ~JFLAG_WANT_SESSION; |
---|
[861c199] | 334 | } |
---|
[21167d2] | 335 | |
---|
[8fb1263] | 336 | if( reply != NULL ) |
---|
| 337 | { |
---|
| 338 | reply = jabber_make_packet( "iq", "set", NULL, reply ); |
---|
| 339 | jabber_cache_add( ic, reply, jabber_pkt_bind_sess ); |
---|
| 340 | |
---|
| 341 | if( !jabber_write_packet( ic, reply ) ) |
---|
| 342 | return XT_ABORT; |
---|
| 343 | } |
---|
| 344 | else if( ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 ) |
---|
[861c199] | 345 | { |
---|
[0da65d5] | 346 | if( !jabber_get_roster( ic ) ) |
---|
[861c199] | 347 | return XT_ABORT; |
---|
| 348 | } |
---|
[21167d2] | 349 | |
---|
[861c199] | 350 | return XT_HANDLED; |
---|
[21167d2] | 351 | } |
---|
[70f6aab8] | 352 | |
---|
[0da65d5] | 353 | int jabber_get_roster( struct im_connection *ic ) |
---|
[70f6aab8] | 354 | { |
---|
| 355 | struct xt_node *node; |
---|
| 356 | int st; |
---|
| 357 | |
---|
[84b045d] | 358 | imcb_log( ic, "Authenticated, requesting buddy list" ); |
---|
[70f6aab8] | 359 | |
---|
| 360 | node = xt_new_node( "query", NULL, NULL ); |
---|
[47d3ac4] | 361 | xt_add_attr( node, "xmlns", XMLNS_ROSTER ); |
---|
[70f6aab8] | 362 | node = jabber_make_packet( "iq", "get", NULL, node ); |
---|
| 363 | |
---|
[0da65d5] | 364 | jabber_cache_add( ic, node, jabber_parse_roster ); |
---|
| 365 | st = jabber_write_packet( ic, node ); |
---|
[70f6aab8] | 366 | |
---|
| 367 | return st; |
---|
| 368 | } |
---|
[cfbb3a6] | 369 | |
---|
[0da65d5] | 370 | static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) |
---|
[861c199] | 371 | { |
---|
| 372 | struct xt_node *query, *c; |
---|
[abbd8ed] | 373 | int initial = ( orig != NULL ); |
---|
[861c199] | 374 | |
---|
[9bcbe48] | 375 | if( !( query = xt_find_node( node->children, "query" ) ) ) |
---|
| 376 | { |
---|
[43462708] | 377 | imcb_log( ic, "Warning: Received NULL roster packet" ); |
---|
[9bcbe48] | 378 | return XT_HANDLED; |
---|
| 379 | } |
---|
[861c199] | 380 | |
---|
| 381 | c = query->children; |
---|
| 382 | while( ( c = xt_find_node( c, "item" ) ) ) |
---|
| 383 | { |
---|
[dcd16c5] | 384 | struct xt_node *group = xt_find_node( c->children, "group" ); |
---|
[861c199] | 385 | char *jid = xt_find_attr( c, "jid" ); |
---|
| 386 | char *name = xt_find_attr( c, "name" ); |
---|
| 387 | char *sub = xt_find_attr( c, "subscription" ); |
---|
| 388 | |
---|
[f0cb961] | 389 | if( jid && sub ) |
---|
[abbd8ed] | 390 | { |
---|
| 391 | if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) ) |
---|
| 392 | { |
---|
[f5d87ea] | 393 | imcb_add_buddy( ic, jid, ( group && group->text_len ) ? |
---|
| 394 | group->text : NULL ); |
---|
[f0cb961] | 395 | |
---|
[d06eabf] | 396 | if( name ) |
---|
| 397 | imcb_rename_buddy( ic, jid, name ); |
---|
[abbd8ed] | 398 | } |
---|
| 399 | else if( strcmp( sub, "remove" ) == 0 ) |
---|
| 400 | { |
---|
[0da65d5] | 401 | jabber_buddy_remove_bare( ic, jid ); |
---|
[998b103] | 402 | imcb_remove_buddy( ic, jid, NULL ); |
---|
[abbd8ed] | 403 | } |
---|
| 404 | } |
---|
[861c199] | 405 | |
---|
| 406 | c = c->next; |
---|
| 407 | } |
---|
| 408 | |
---|
[abbd8ed] | 409 | if( initial ) |
---|
[84b045d] | 410 | imcb_connected( ic ); |
---|
[861c199] | 411 | |
---|
| 412 | return XT_HANDLED; |
---|
| 413 | } |
---|
| 414 | |
---|
[0da65d5] | 415 | int jabber_get_vcard( struct im_connection *ic, char *bare_jid ) |
---|
[1991be6] | 416 | { |
---|
| 417 | struct xt_node *node; |
---|
| 418 | |
---|
| 419 | if( strchr( bare_jid, '/' ) ) |
---|
| 420 | return 1; /* This was an error, but return 0 should only be done if the connection died... */ |
---|
| 421 | |
---|
| 422 | node = xt_new_node( "vCard", NULL, NULL ); |
---|
[47d3ac4] | 423 | xt_add_attr( node, "xmlns", XMLNS_VCARD ); |
---|
[1991be6] | 424 | node = jabber_make_packet( "iq", "get", bare_jid, node ); |
---|
| 425 | |
---|
[0da65d5] | 426 | jabber_cache_add( ic, node, jabber_iq_display_vcard ); |
---|
| 427 | return jabber_write_packet( ic, node ); |
---|
[1991be6] | 428 | } |
---|
| 429 | |
---|
[0da65d5] | 430 | static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) |
---|
[1991be6] | 431 | { |
---|
[0da65d5] | 432 | struct xt_node *vc, *c, *sc; /* subchild, ic is already in use ;-) */ |
---|
[1991be6] | 433 | GString *reply; |
---|
| 434 | char *s; |
---|
| 435 | |
---|
| 436 | if( ( s = xt_find_attr( node, "type" ) ) == NULL || |
---|
| 437 | strcmp( s, "result" ) != 0 || |
---|
| 438 | ( vc = xt_find_node( node->children, "vCard" ) ) == NULL ) |
---|
| 439 | { |
---|
| 440 | s = xt_find_attr( orig, "to" ); /* If this returns NULL something's wrong.. */ |
---|
[84b045d] | 441 | imcb_log( ic, "Could not retrieve vCard of %s", s ? s : "(NULL)" ); |
---|
[1991be6] | 442 | return XT_HANDLED; |
---|
| 443 | } |
---|
| 444 | |
---|
| 445 | s = xt_find_attr( orig, "to" ); |
---|
| 446 | reply = g_string_new( "vCard information for " ); |
---|
| 447 | reply = g_string_append( reply, s ? s : "(NULL)" ); |
---|
| 448 | reply = g_string_append( reply, ":\n" ); |
---|
| 449 | |
---|
| 450 | /* I hate this format, I really do... */ |
---|
| 451 | |
---|
| 452 | if( ( c = xt_find_node( vc->children, "FN" ) ) && c->text_len ) |
---|
| 453 | g_string_append_printf( reply, "Name: %s\n", c->text ); |
---|
| 454 | |
---|
| 455 | if( ( c = xt_find_node( vc->children, "N" ) ) && c->children ) |
---|
| 456 | { |
---|
| 457 | reply = g_string_append( reply, "Full name:" ); |
---|
| 458 | |
---|
| 459 | if( ( sc = xt_find_node( c->children, "PREFIX" ) ) && sc->text_len ) |
---|
| 460 | g_string_append_printf( reply, " %s", sc->text ); |
---|
| 461 | if( ( sc = xt_find_node( c->children, "GIVEN" ) ) && sc->text_len ) |
---|
| 462 | g_string_append_printf( reply, " %s", sc->text ); |
---|
| 463 | if( ( sc = xt_find_node( c->children, "MIDDLE" ) ) && sc->text_len ) |
---|
| 464 | g_string_append_printf( reply, " %s", sc->text ); |
---|
| 465 | if( ( sc = xt_find_node( c->children, "FAMILY" ) ) && sc->text_len ) |
---|
| 466 | g_string_append_printf( reply, " %s", sc->text ); |
---|
| 467 | if( ( sc = xt_find_node( c->children, "SUFFIX" ) ) && sc->text_len ) |
---|
| 468 | g_string_append_printf( reply, " %s", sc->text ); |
---|
| 469 | |
---|
| 470 | reply = g_string_append_c( reply, '\n' ); |
---|
| 471 | } |
---|
| 472 | |
---|
| 473 | if( ( c = xt_find_node( vc->children, "NICKNAME" ) ) && c->text_len ) |
---|
| 474 | g_string_append_printf( reply, "Nickname: %s\n", c->text ); |
---|
| 475 | |
---|
| 476 | if( ( c = xt_find_node( vc->children, "BDAY" ) ) && c->text_len ) |
---|
| 477 | g_string_append_printf( reply, "Date of birth: %s\n", c->text ); |
---|
| 478 | |
---|
| 479 | /* Slightly alternative use of for... ;-) */ |
---|
| 480 | for( c = vc->children; ( c = xt_find_node( c, "EMAIL" ) ); c = c->next ) |
---|
| 481 | { |
---|
| 482 | if( ( sc = xt_find_node( c->children, "USERID" ) ) == NULL || sc->text_len == 0 ) |
---|
| 483 | continue; |
---|
| 484 | |
---|
| 485 | if( xt_find_node( c->children, "HOME" ) ) |
---|
| 486 | s = "Home"; |
---|
| 487 | else if( xt_find_node( c->children, "WORK" ) ) |
---|
| 488 | s = "Work"; |
---|
| 489 | else |
---|
| 490 | s = "Misc."; |
---|
| 491 | |
---|
| 492 | g_string_append_printf( reply, "%s e-mail address: %s\n", s, sc->text ); |
---|
| 493 | } |
---|
| 494 | |
---|
| 495 | if( ( c = xt_find_node( vc->children, "URL" ) ) && c->text_len ) |
---|
| 496 | g_string_append_printf( reply, "Homepage: %s\n", c->text ); |
---|
| 497 | |
---|
| 498 | /* Slightly alternative use of for... ;-) */ |
---|
| 499 | for( c = vc->children; ( c = xt_find_node( c, "ADR" ) ); c = c->next ) |
---|
| 500 | { |
---|
| 501 | if( xt_find_node( c->children, "HOME" ) ) |
---|
| 502 | s = "Home"; |
---|
| 503 | else if( xt_find_node( c->children, "WORK" ) ) |
---|
| 504 | s = "Work"; |
---|
| 505 | else |
---|
| 506 | s = "Misc."; |
---|
| 507 | |
---|
| 508 | g_string_append_printf( reply, "%s address: ", s ); |
---|
| 509 | |
---|
| 510 | if( ( sc = xt_find_node( c->children, "STREET" ) ) && sc->text_len ) |
---|
| 511 | g_string_append_printf( reply, "%s ", sc->text ); |
---|
| 512 | if( ( sc = xt_find_node( c->children, "EXTADR" ) ) && sc->text_len ) |
---|
| 513 | g_string_append_printf( reply, "%s, ", sc->text ); |
---|
| 514 | if( ( sc = xt_find_node( c->children, "PCODE" ) ) && sc->text_len ) |
---|
| 515 | g_string_append_printf( reply, "%s, ", sc->text ); |
---|
| 516 | if( ( sc = xt_find_node( c->children, "LOCALITY" ) ) && sc->text_len ) |
---|
| 517 | g_string_append_printf( reply, "%s, ", sc->text ); |
---|
| 518 | if( ( sc = xt_find_node( c->children, "REGION" ) ) && sc->text_len ) |
---|
| 519 | g_string_append_printf( reply, "%s, ", sc->text ); |
---|
| 520 | if( ( sc = xt_find_node( c->children, "CTRY" ) ) && sc->text_len ) |
---|
| 521 | g_string_append_printf( reply, "%s", sc->text ); |
---|
| 522 | |
---|
| 523 | if( reply->str[reply->len-2] == ',' ) |
---|
| 524 | reply = g_string_truncate( reply, reply->len-2 ); |
---|
| 525 | |
---|
| 526 | reply = g_string_append_c( reply, '\n' ); |
---|
| 527 | } |
---|
| 528 | |
---|
| 529 | for( c = vc->children; ( c = xt_find_node( c, "TEL" ) ); c = c->next ) |
---|
| 530 | { |
---|
| 531 | if( ( sc = xt_find_node( c->children, "NUMBER" ) ) == NULL || sc->text_len == 0 ) |
---|
| 532 | continue; |
---|
| 533 | |
---|
| 534 | if( xt_find_node( c->children, "HOME" ) ) |
---|
| 535 | s = "Home"; |
---|
| 536 | else if( xt_find_node( c->children, "WORK" ) ) |
---|
| 537 | s = "Work"; |
---|
| 538 | else |
---|
| 539 | s = "Misc."; |
---|
| 540 | |
---|
| 541 | g_string_append_printf( reply, "%s phone number: %s\n", s, sc->text ); |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | if( ( c = xt_find_node( vc->children, "DESC" ) ) && c->text_len ) |
---|
| 545 | g_string_append_printf( reply, "Other information:\n%s", c->text ); |
---|
| 546 | |
---|
| 547 | /* *sigh* */ |
---|
| 548 | |
---|
[84b045d] | 549 | imcb_log( ic, "%s", reply->str ); |
---|
[1991be6] | 550 | g_string_free( reply, TRUE ); |
---|
| 551 | |
---|
| 552 | return XT_HANDLED; |
---|
| 553 | } |
---|
| 554 | |
---|
[a73e91a] | 555 | static xt_status jabber_add_to_roster_callback( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); |
---|
| 556 | |
---|
[0da65d5] | 557 | int jabber_add_to_roster( struct im_connection *ic, char *handle, char *name ) |
---|
[cfbb3a6] | 558 | { |
---|
| 559 | struct xt_node *node; |
---|
| 560 | int st; |
---|
| 561 | |
---|
| 562 | /* Build the item entry */ |
---|
| 563 | node = xt_new_node( "item", NULL, NULL ); |
---|
| 564 | xt_add_attr( node, "jid", handle ); |
---|
| 565 | if( name ) |
---|
| 566 | xt_add_attr( node, "name", name ); |
---|
| 567 | |
---|
| 568 | /* And pack it into a roster-add packet */ |
---|
| 569 | node = xt_new_node( "query", NULL, node ); |
---|
[47d3ac4] | 570 | xt_add_attr( node, "xmlns", XMLNS_ROSTER ); |
---|
[cfbb3a6] | 571 | node = jabber_make_packet( "iq", "set", NULL, node ); |
---|
[a73e91a] | 572 | jabber_cache_add( ic, node, jabber_add_to_roster_callback ); |
---|
[cfbb3a6] | 573 | |
---|
[0da65d5] | 574 | st = jabber_write_packet( ic, node ); |
---|
[cfbb3a6] | 575 | |
---|
| 576 | return st; |
---|
| 577 | } |
---|
| 578 | |
---|
[a73e91a] | 579 | static xt_status jabber_add_to_roster_callback( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) |
---|
| 580 | { |
---|
| 581 | char *s, *jid = NULL; |
---|
| 582 | struct xt_node *c; |
---|
| 583 | |
---|
| 584 | if( ( c = xt_find_node( orig->children, "query" ) ) && |
---|
| 585 | ( c = xt_find_node( c->children, "item" ) ) && |
---|
| 586 | ( jid = xt_find_attr( c, "jid" ) ) && |
---|
| 587 | ( s = xt_find_attr( node, "type" ) ) && |
---|
| 588 | strcmp( s, "result" ) == 0 ) |
---|
| 589 | { |
---|
[17a6ee9] | 590 | if( bee_user_by_handle( ic->bee, ic, jid ) == NULL ) |
---|
[a73e91a] | 591 | imcb_add_buddy( ic, jid, NULL ); |
---|
| 592 | } |
---|
| 593 | else |
---|
| 594 | { |
---|
| 595 | imcb_log( ic, "Error while adding `%s' to your contact list.", |
---|
| 596 | jid ? jid : "(unknown handle)" ); |
---|
| 597 | } |
---|
| 598 | |
---|
| 599 | return XT_HANDLED; |
---|
| 600 | } |
---|
| 601 | |
---|
[0da65d5] | 602 | int jabber_remove_from_roster( struct im_connection *ic, char *handle ) |
---|
[cfbb3a6] | 603 | { |
---|
| 604 | struct xt_node *node; |
---|
| 605 | int st; |
---|
| 606 | |
---|
| 607 | /* Build the item entry */ |
---|
| 608 | node = xt_new_node( "item", NULL, NULL ); |
---|
| 609 | xt_add_attr( node, "jid", handle ); |
---|
| 610 | xt_add_attr( node, "subscription", "remove" ); |
---|
| 611 | |
---|
| 612 | /* And pack it into a roster-add packet */ |
---|
| 613 | node = xt_new_node( "query", NULL, node ); |
---|
[47d3ac4] | 614 | xt_add_attr( node, "xmlns", XMLNS_ROSTER ); |
---|
[cfbb3a6] | 615 | node = jabber_make_packet( "iq", "set", NULL, node ); |
---|
| 616 | |
---|
[0da65d5] | 617 | st = jabber_write_packet( ic, node ); |
---|
[cfbb3a6] | 618 | |
---|
| 619 | xt_free_node( node ); |
---|
| 620 | return st; |
---|
| 621 | } |
---|
[dc0ba9c] | 622 | |
---|
| 623 | xt_status jabber_iq_parse_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); |
---|
| 624 | |
---|
| 625 | xt_status jabber_iq_query_features( struct im_connection *ic, char *bare_jid ) |
---|
| 626 | { |
---|
| 627 | struct xt_node *node, *query; |
---|
| 628 | struct jabber_buddy *bud; |
---|
| 629 | |
---|
| 630 | if( ( bud = jabber_buddy_by_jid( ic, bare_jid , 0 ) ) == NULL ) |
---|
| 631 | { |
---|
| 632 | /* Who cares about the unknown... */ |
---|
[4358b10] | 633 | imcb_log( ic, "Couldn't find buddy: %s", bare_jid); |
---|
[54a2014] | 634 | return XT_HANDLED; |
---|
[dc0ba9c] | 635 | } |
---|
| 636 | |
---|
| 637 | if( bud->features ) /* been here already */ |
---|
| 638 | return XT_HANDLED; |
---|
| 639 | |
---|
| 640 | node = xt_new_node( "query", NULL, NULL ); |
---|
| 641 | xt_add_attr( node, "xmlns", XMLNS_DISCO_INFO ); |
---|
| 642 | |
---|
| 643 | if( !( query = jabber_make_packet( "iq", "get", bare_jid, node ) ) ) |
---|
| 644 | { |
---|
| 645 | imcb_log( ic, "WARNING: Couldn't generate feature query" ); |
---|
| 646 | xt_free_node( node ); |
---|
[54a2014] | 647 | return XT_HANDLED; |
---|
[dc0ba9c] | 648 | } |
---|
| 649 | |
---|
| 650 | jabber_cache_add( ic, query, jabber_iq_parse_features ); |
---|
| 651 | |
---|
[54a2014] | 652 | return jabber_write_packet( ic, query ) ? XT_HANDLED : XT_ABORT; |
---|
[dc0ba9c] | 653 | } |
---|
| 654 | |
---|
| 655 | xt_status jabber_iq_parse_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) |
---|
| 656 | { |
---|
| 657 | struct xt_node *c; |
---|
| 658 | struct jabber_buddy *bud; |
---|
[c1a3c27] | 659 | char *feature, *xmlns, *from; |
---|
[dc0ba9c] | 660 | |
---|
[699376f7] | 661 | if( !( from = xt_find_attr( node, "from" ) ) || |
---|
| 662 | !( c = xt_find_node( node->children, "query" ) ) || |
---|
[c1a3c27] | 663 | !( xmlns = xt_find_attr( c, "xmlns" ) ) || |
---|
| 664 | !( strcmp( xmlns, XMLNS_DISCO_INFO ) == 0 ) ) |
---|
[dc0ba9c] | 665 | { |
---|
| 666 | imcb_log( ic, "WARNING: Received incomplete IQ-result packet for discover" ); |
---|
| 667 | return XT_HANDLED; |
---|
| 668 | } |
---|
[c1a3c27] | 669 | if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) == NULL ) |
---|
[dc0ba9c] | 670 | { |
---|
| 671 | /* Who cares about the unknown... */ |
---|
[c1a3c27] | 672 | imcb_log( ic, "Couldn't find buddy: %s", from ); |
---|
[54a2014] | 673 | return XT_HANDLED; |
---|
[dc0ba9c] | 674 | } |
---|
| 675 | |
---|
| 676 | c = c->children; |
---|
[1c3008a] | 677 | while( ( c = xt_find_node( c, "feature" ) ) ) |
---|
| 678 | { |
---|
[dc0ba9c] | 679 | feature = xt_find_attr( c, "var" ); |
---|
[c1a3c27] | 680 | if( feature ) |
---|
| 681 | bud->features = g_slist_append( bud->features, g_strdup( feature ) ); |
---|
[dc0ba9c] | 682 | c = c->next; |
---|
| 683 | } |
---|
| 684 | |
---|
| 685 | return XT_HANDLED; |
---|
| 686 | } |
---|
| 687 | |
---|
| 688 | xt_status jabber_iq_parse_server_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); |
---|
| 689 | |
---|
| 690 | xt_status jabber_iq_query_server( struct im_connection *ic, char *jid, char *xmlns ) |
---|
| 691 | { |
---|
| 692 | struct xt_node *node, *query; |
---|
| 693 | struct jabber_data *jd = ic->proto_data; |
---|
| 694 | |
---|
| 695 | node = xt_new_node( "query", NULL, NULL ); |
---|
| 696 | xt_add_attr( node, "xmlns", xmlns ); |
---|
| 697 | |
---|
| 698 | if( !( query = jabber_make_packet( "iq", "get", jid, node ) ) ) |
---|
| 699 | { |
---|
| 700 | imcb_log( ic, "WARNING: Couldn't generate server query" ); |
---|
| 701 | xt_free_node( node ); |
---|
| 702 | } |
---|
| 703 | |
---|
| 704 | jd->have_streamhosts--; |
---|
| 705 | jabber_cache_add( ic, query, jabber_iq_parse_server_features ); |
---|
| 706 | |
---|
[54a2014] | 707 | return jabber_write_packet( ic, query ) ? XT_HANDLED : XT_ABORT; |
---|
[dc0ba9c] | 708 | } |
---|
| 709 | |
---|
| 710 | /* |
---|
| 711 | * Query the server for "items", query each "item" for identities, query each "item" that's a proxy for it's bytestream info |
---|
| 712 | */ |
---|
| 713 | xt_status jabber_iq_parse_server_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) |
---|
| 714 | { |
---|
| 715 | struct xt_node *c; |
---|
| 716 | struct jabber_data *jd = ic->proto_data; |
---|
[c1a3c27] | 717 | char *xmlns, *from; |
---|
[dc0ba9c] | 718 | |
---|
| 719 | if( !( c = xt_find_node( node->children, "query" ) ) || |
---|
[c1a3c27] | 720 | !( from = xt_find_attr( node, "from" ) ) || |
---|
| 721 | !( xmlns = xt_find_attr( c, "xmlns" ) ) ) |
---|
[dc0ba9c] | 722 | { |
---|
| 723 | imcb_log( ic, "WARNING: Received incomplete IQ-result packet for discover" ); |
---|
| 724 | return XT_HANDLED; |
---|
| 725 | } |
---|
| 726 | |
---|
| 727 | jd->have_streamhosts++; |
---|
| 728 | |
---|
[c1a3c27] | 729 | if( strcmp( xmlns, XMLNS_DISCO_ITEMS ) == 0 ) |
---|
[dc0ba9c] | 730 | { |
---|
[c1a3c27] | 731 | char *itemjid; |
---|
[dc0ba9c] | 732 | |
---|
| 733 | /* answer from server */ |
---|
| 734 | |
---|
| 735 | c = c->children; |
---|
| 736 | while( ( c = xt_find_node( c, "item" ) ) ) |
---|
| 737 | { |
---|
| 738 | itemjid = xt_find_attr( c, "jid" ); |
---|
[c1a3c27] | 739 | |
---|
| 740 | if( itemjid ) |
---|
| 741 | jabber_iq_query_server( ic, itemjid, XMLNS_DISCO_INFO ); |
---|
[dc0ba9c] | 742 | |
---|
| 743 | c = c->next; |
---|
| 744 | } |
---|
[1c3008a] | 745 | } |
---|
[42fc5b6] | 746 | else if( strcmp( xmlns, XMLNS_DISCO_INFO ) == 0 ) |
---|
[dc0ba9c] | 747 | { |
---|
| 748 | char *category, *type; |
---|
| 749 | |
---|
| 750 | /* answer from potential proxy */ |
---|
| 751 | |
---|
| 752 | c = c->children; |
---|
| 753 | while( ( c = xt_find_node( c, "identity" ) ) ) |
---|
| 754 | { |
---|
| 755 | category = xt_find_attr( c, "category" ); |
---|
| 756 | type = xt_find_attr( c, "type" ); |
---|
| 757 | |
---|
| 758 | if( type && ( strcmp( type, "bytestreams" ) == 0 ) && |
---|
| 759 | category && ( strcmp( category, "proxy" ) == 0 ) ) |
---|
[c1a3c27] | 760 | jabber_iq_query_server( ic, from, XMLNS_BYTESTREAMS ); |
---|
[dc0ba9c] | 761 | |
---|
| 762 | c = c->next; |
---|
| 763 | } |
---|
[1c3008a] | 764 | } |
---|
[42fc5b6] | 765 | else if( strcmp( xmlns, XMLNS_BYTESTREAMS ) == 0 ) |
---|
[dc0ba9c] | 766 | { |
---|
[c1a3c27] | 767 | char *host, *jid, *port_s; |
---|
[dc0ba9c] | 768 | int port; |
---|
| 769 | |
---|
| 770 | /* answer from proxy */ |
---|
| 771 | |
---|
| 772 | if( ( c = xt_find_node( c->children, "streamhost" ) ) && |
---|
| 773 | ( host = xt_find_attr( c, "host" ) ) && |
---|
[c1a3c27] | 774 | ( port_s = xt_find_attr( c, "port" ) ) && |
---|
| 775 | ( sscanf( port_s, "%d", &port ) == 1 ) && |
---|
[dc0ba9c] | 776 | ( jid = xt_find_attr( c, "jid" ) ) ) |
---|
| 777 | { |
---|
| 778 | jabber_streamhost_t *sh = g_new0( jabber_streamhost_t, 1 ); |
---|
[c1a3c27] | 779 | |
---|
[dc0ba9c] | 780 | sh->jid = g_strdup( jid ); |
---|
| 781 | sh->host = g_strdup( host ); |
---|
[c1a3c27] | 782 | g_snprintf( sh->port, sizeof( sh->port ), "%u", port ); |
---|
[dc0ba9c] | 783 | |
---|
| 784 | imcb_log( ic, "Proxy found: jid %s host %s port %u", jid, host, port ); |
---|
| 785 | jd->streamhosts = g_slist_append( jd->streamhosts, sh ); |
---|
| 786 | } |
---|
| 787 | } |
---|
| 788 | |
---|
| 789 | if( jd->have_streamhosts == 0 ) |
---|
| 790 | jd->have_streamhosts++; |
---|
[1c3008a] | 791 | |
---|
[dc0ba9c] | 792 | return XT_HANDLED; |
---|
| 793 | } |
---|