Changeset 1991be6
- Timestamp:
- 2006-10-18T17:47:08Z (18 years ago)
- Branches:
- master
- Children:
- f920d9e
- Parents:
- e727608
- Location:
- protocols/jabber
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/iq.c
re727608 r1991be6 321 321 } 322 322 323 static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig ); 324 325 int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid ) 326 { 327 struct xt_node *node; 328 329 if( strchr( bare_jid, '/' ) ) 330 return 1; /* This was an error, but return 0 should only be done if the connection died... */ 331 332 node = xt_new_node( "vCard", NULL, NULL ); 333 xt_add_attr( node, "xmlns", "vcard-temp" ); 334 node = jabber_make_packet( "iq", "get", bare_jid, node ); 335 336 jabber_cache_add( gc, node, jabber_iq_display_vcard ); 337 return jabber_write_packet( gc, node ); 338 } 339 340 static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig ) 341 { 342 struct xt_node *vc, *c, *sc; /* subchild, gc is already in use ;-) */ 343 GString *reply; 344 char *s; 345 346 if( ( s = xt_find_attr( node, "type" ) ) == NULL || 347 strcmp( s, "result" ) != 0 || 348 ( vc = xt_find_node( node->children, "vCard" ) ) == NULL ) 349 { 350 s = xt_find_attr( orig, "to" ); /* If this returns NULL something's wrong.. */ 351 serv_got_crap( gc, "Could not retrieve vCard of %s", s ? s : "(NULL)" ); 352 return XT_HANDLED; 353 } 354 355 s = xt_find_attr( orig, "to" ); 356 reply = g_string_new( "vCard information for " ); 357 reply = g_string_append( reply, s ? s : "(NULL)" ); 358 reply = g_string_append( reply, ":\n" ); 359 360 /* I hate this format, I really do... */ 361 362 if( ( c = xt_find_node( vc->children, "FN" ) ) && c->text_len ) 363 g_string_append_printf( reply, "Name: %s\n", c->text ); 364 365 if( ( c = xt_find_node( vc->children, "N" ) ) && c->children ) 366 { 367 reply = g_string_append( reply, "Full name:" ); 368 369 if( ( sc = xt_find_node( c->children, "PREFIX" ) ) && sc->text_len ) 370 g_string_append_printf( reply, " %s", sc->text ); 371 if( ( sc = xt_find_node( c->children, "GIVEN" ) ) && sc->text_len ) 372 g_string_append_printf( reply, " %s", sc->text ); 373 if( ( sc = xt_find_node( c->children, "MIDDLE" ) ) && sc->text_len ) 374 g_string_append_printf( reply, " %s", sc->text ); 375 if( ( sc = xt_find_node( c->children, "FAMILY" ) ) && sc->text_len ) 376 g_string_append_printf( reply, " %s", sc->text ); 377 if( ( sc = xt_find_node( c->children, "SUFFIX" ) ) && sc->text_len ) 378 g_string_append_printf( reply, " %s", sc->text ); 379 380 reply = g_string_append_c( reply, '\n' ); 381 } 382 383 if( ( c = xt_find_node( vc->children, "NICKNAME" ) ) && c->text_len ) 384 g_string_append_printf( reply, "Nickname: %s\n", c->text ); 385 386 if( ( c = xt_find_node( vc->children, "BDAY" ) ) && c->text_len ) 387 g_string_append_printf( reply, "Date of birth: %s\n", c->text ); 388 389 /* Slightly alternative use of for... ;-) */ 390 for( c = vc->children; ( c = xt_find_node( c, "EMAIL" ) ); c = c->next ) 391 { 392 if( ( sc = xt_find_node( c->children, "USERID" ) ) == NULL || sc->text_len == 0 ) 393 continue; 394 395 if( xt_find_node( c->children, "HOME" ) ) 396 s = "Home"; 397 else if( xt_find_node( c->children, "WORK" ) ) 398 s = "Work"; 399 else 400 s = "Misc."; 401 402 g_string_append_printf( reply, "%s e-mail address: %s\n", s, sc->text ); 403 } 404 405 if( ( c = xt_find_node( vc->children, "URL" ) ) && c->text_len ) 406 g_string_append_printf( reply, "Homepage: %s\n", c->text ); 407 408 /* Slightly alternative use of for... ;-) */ 409 for( c = vc->children; ( c = xt_find_node( c, "ADR" ) ); c = c->next ) 410 { 411 if( xt_find_node( c->children, "HOME" ) ) 412 s = "Home"; 413 else if( xt_find_node( c->children, "WORK" ) ) 414 s = "Work"; 415 else 416 s = "Misc."; 417 418 g_string_append_printf( reply, "%s address: ", s ); 419 420 if( ( sc = xt_find_node( c->children, "STREET" ) ) && sc->text_len ) 421 g_string_append_printf( reply, "%s ", sc->text ); 422 if( ( sc = xt_find_node( c->children, "EXTADR" ) ) && sc->text_len ) 423 g_string_append_printf( reply, "%s, ", sc->text ); 424 if( ( sc = xt_find_node( c->children, "PCODE" ) ) && sc->text_len ) 425 g_string_append_printf( reply, "%s, ", sc->text ); 426 if( ( sc = xt_find_node( c->children, "LOCALITY" ) ) && sc->text_len ) 427 g_string_append_printf( reply, "%s, ", sc->text ); 428 if( ( sc = xt_find_node( c->children, "REGION" ) ) && sc->text_len ) 429 g_string_append_printf( reply, "%s, ", sc->text ); 430 if( ( sc = xt_find_node( c->children, "CTRY" ) ) && sc->text_len ) 431 g_string_append_printf( reply, "%s", sc->text ); 432 433 if( reply->str[reply->len-2] == ',' ) 434 reply = g_string_truncate( reply, reply->len-2 ); 435 436 reply = g_string_append_c( reply, '\n' ); 437 } 438 439 for( c = vc->children; ( c = xt_find_node( c, "TEL" ) ); c = c->next ) 440 { 441 if( ( sc = xt_find_node( c->children, "NUMBER" ) ) == NULL || sc->text_len == 0 ) 442 continue; 443 444 if( xt_find_node( c->children, "HOME" ) ) 445 s = "Home"; 446 else if( xt_find_node( c->children, "WORK" ) ) 447 s = "Work"; 448 else 449 s = "Misc."; 450 451 g_string_append_printf( reply, "%s phone number: %s\n", s, sc->text ); 452 } 453 454 if( ( c = xt_find_node( vc->children, "DESC" ) ) && c->text_len ) 455 g_string_append_printf( reply, "Other information:\n%s", c->text ); 456 457 /* *sigh* */ 458 459 serv_got_crap( gc, reply->str ); 460 g_string_free( reply, TRUE ); 461 462 return XT_HANDLED; 463 } 464 323 465 int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name ) 324 466 { -
protocols/jabber/jabber.c
re727608 r1991be6 202 202 bud = bud->next; 203 203 } 204 205 jabber_get_vcard( gc, bud ? bud->handle : who ); 204 206 } 205 207 -
protocols/jabber/jabber.h
re727608 r1991be6 112 112 xt_status jabber_pkt_bind_sess( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig ); 113 113 int jabber_get_roster( struct gaim_connection *gc ); 114 int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid ); 114 115 int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name ); 115 116 int jabber_remove_from_roster( struct gaim_connection *gc, char *handle );
Note: See TracChangeset
for help on using the changeset viewer.