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