Changes in / [b788246:5fbec3d]
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
configure
rb788246 r5fbec3d 20 20 ipcsocket='/var/run/bitlbee.sock' 21 21 pcdir='$prefix/lib/pkgconfig' 22 systemlibdirs="/lib / usr/lib /usr/local/lib"22 systemlibdirs="/lib /lib64 /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64" 23 23 24 24 msn=1 … … 156 156 157 157 echo CFLAGS=$CFLAGS >> Makefile.settings 158 echo CFLAGS+=-I`pwd` - iquote`pwd`/lib -iquote`pwd`/protocols -I. >> Makefile.settings158 echo CFLAGS+=-I`pwd` -I`pwd`/lib -I`pwd`/protocols -I. >> Makefile.settings 159 159 160 160 echo CFLAGS+=-DHAVE_CONFIG_H >> Makefile.settings … … 295 295 detect_resolv_dynamic() 296 296 { 297 echo "$RESOLV_TESTCODE" | $CC -o /dev/null -x c - -lresolv >/dev/null 2>/dev/null 297 TMPFILE=$(mktemp) 298 ret=1 299 echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -lresolv >/dev/null 2>/dev/null 298 300 if [ "$?" = "0" ]; then 299 301 echo 'EFLAGS+=-lresolv' >> Makefile.settings 300 return 0 301 fi 302 303 return 1 302 ret=0 303 fi 304 305 rm -f $TMPFILE 306 return $ret 304 307 } 305 308 306 309 detect_resolv_static() 307 310 { 311 TMPFILE=$(mktemp) 312 ret=1 308 313 for i in $systemlibdirs; do 309 314 if [ -f $i/libresolv.a ]; then 310 echo "$RESOLV_TESTCODE" | $CC -o /dev/null-x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null315 echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null 311 316 if [ "$?" = "0" ]; then 312 317 echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings 313 ret urn0318 ret=0 314 319 fi 315 320 fi 316 321 done 317 322 318 return 1 323 rm -f $TMPFILE 324 return $ret 319 325 } 320 326 -
protocols/jabber/jabber.c
rb788246 r5fbec3d 57 57 set_t *s; 58 58 char str[16]; 59 60 s = set_add( &acc->set, "activity_timeout", "600", set_eval_int, acc ); 59 61 60 62 g_snprintf( str, sizeof( str ), "%d", jabber_port_list[0] ); … … 307 309 bud = jabber_buddy_by_ext_jid( ic, who, 0 ); 308 310 else 309 bud = jabber_buddy_by_jid( ic, who, 0);311 bud = jabber_buddy_by_jid( ic, who, GET_BUDDY_BARE_OK ); 310 312 311 313 node = xt_new_node( "body", message, NULL ); … … 352 354 static void jabber_get_info( struct im_connection *ic, char *who ) 353 355 { 354 struct jabber_data *jd = ic->proto_data;355 356 struct jabber_buddy *bud; 356 357 357 if( strchr( who, '/' ) ) 358 bud = jabber_buddy_by_jid( ic, who, 0 ); 359 else 360 { 361 char *s = jabber_normalize( who ); 362 bud = g_hash_table_lookup( jd->buddies, s ); 363 g_free( s ); 364 } 358 bud = jabber_buddy_by_jid( ic, who, GET_BUDDY_FIRST ); 365 359 366 360 while( bud ) -
protocols/jabber/jabber.h
rb788246 r5fbec3d 108 108 }; 109 109 110 /* Somewhat messy data structure: We have a hash table with the bare JID as 111 the key and the head of a struct jabber_buddy list as the value. The head 112 is always a bare JID. If the JID has other resources (often the case, 113 except for some transports that don't support multiple resources), those 114 follow. In that case, the bare JID at the beginning doesn't actually 115 refer to a real session and should only be used for operations that 116 support incomplete JIDs. */ 110 117 struct jabber_buddy 111 118 { … … 121 128 char *away_message; 122 129 123 time_t last_ act;130 time_t last_msg; 124 131 jabber_buddy_flags_t flags; 125 132 … … 209 216 GET_BUDDY_EXACT = 2, /* Get an exact match (only makes sense with bare JIDs). */ 210 217 GET_BUDDY_FIRST = 4, /* No selection, simply get the first resource for this JID. */ 218 GET_BUDDY_BARE = 8, /* Get the bare version of the JID (possibly inexistent). */ 219 GET_BUDDY_BARE_OK = 16, /* Allow returning a bare JID if that seems better. */ 211 220 } get_buddy_flags_t; 212 221 -
protocols/jabber/jabber_util.c
rb788246 r5fbec3d 4 4 * Jabber module - Misc. stuff * 5 5 * * 6 * Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net> *6 * Copyright 2006-2010 Wilmer van der Gaast <wilmer@gaast.net> 7 7 * * 8 8 * This program is free software; you can redistribute it and/or modify * … … 345 345 if( ( bud = g_hash_table_lookup( jd->buddies, full_jid ) ) ) 346 346 { 347 /* The first entry is always a bare JID. If there are more, we 348 should ignore the first one here. */ 349 if( bud->next ) 350 bud = bud->next; 351 347 352 /* If this is a transport buddy or whatever, it can't have more 348 353 than one instance, so this is always wrong: */ … … 379 384 else 380 385 { 381 /* Keep in mind that full_jid currently isn't really 382 a full JID... */ 383 new->bare_jid = g_strdup( full_jid ); 386 new->full_jid = new->bare_jid = g_strdup( full_jid ); 384 387 g_hash_table_insert( jd->buddies, new->bare_jid, new ); 388 389 if( s ) 390 { 391 new->next = g_new0( struct jabber_buddy, 1 ); 392 new->next->bare_jid = new->bare_jid; 393 new = new->next; 394 } 385 395 } 386 396 … … 408 418 { 409 419 struct jabber_data *jd = ic->proto_data; 410 struct jabber_buddy *bud ;420 struct jabber_buddy *bud, *head; 411 421 char *s, *jid; 412 422 … … 420 430 if( ( bud = g_hash_table_lookup( jd->buddies, jid ) ) ) 421 431 { 432 bare_exists = 1; 433 434 if( bud->next ) 435 bud = bud->next; 436 422 437 /* Just return the first one for this bare JID. */ 423 438 if( flags & GET_BUDDY_FIRST ) … … 441 456 break; 442 457 } 443 else444 {445 /* This variable tells the if down here that the bare446 JID already exists and we should feel free to add447 more resources, if the caller asked for that. */448 bare_exists = 1;449 }450 458 451 459 if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && 452 ( !bare_exists || imcb_find_buddy( ic, jid ) ) )460 ( bare_exists || imcb_find_buddy( ic, jid ) ) ) 453 461 { 454 462 *s = '/'; … … 464 472 char *set; 465 473 466 bud = g_hash_table_lookup( jd->buddies, jid ); 474 head = g_hash_table_lookup( jd->buddies, jid ); 475 bud = ( head && head->next ) ? head->next : head; 467 476 468 477 g_free( jid ); … … 481 490 /* Looks like the caller doesn't care about details. */ 482 491 return bud; 492 else if( flags & GET_BUDDY_BARE ) 493 return head; 483 494 484 495 best_prio = best_time = bud; … … 487 498 if( bud->priority > best_prio->priority ) 488 499 best_prio = bud; 489 if( bud->last_ act > best_time->last_act)500 if( bud->last_msg > best_time->last_msg ) 490 501 best_time = bud; 491 502 } … … 493 504 if( ( set = set_getstr( &ic->acc->set, "resource_select" ) ) == NULL ) 494 505 return NULL; 495 else if( strcmp( set, "activity" ) == 0 ) 506 else if( strcmp( set, "priority" ) == 0 ) 507 return best_prio; 508 else if( flags & GET_BUDDY_BARE_OK ) /* && strcmp( set, "activity" ) == 0 */ 509 { 510 if( best_time->last_msg + set_getint( &ic->acc->set, "activity_timeout" ) >= time( NULL ) ) 511 return best_time; 512 else 513 return head; 514 } 515 else 496 516 return best_time; 497 else /* if( strcmp( set, "priority" ) == 0 ) */498 return best_prio;499 517 } 500 518 } … … 538 556 { 539 557 struct jabber_data *jd = ic->proto_data; 540 struct jabber_buddy *bud, *prev , *bi;558 struct jabber_buddy *bud, *prev = NULL, *bi; 541 559 char *s, *full_jid; 542 560 … … 548 566 if( ( bud = g_hash_table_lookup( jd->buddies, full_jid ) ) ) 549 567 { 568 if( bud->next ) 569 bud = (prev=bud)->next; 570 550 571 /* If there's only one item in the list (and if the resource 551 572 matches), removing it is simple. (And the hash reference … … 555 576 ( bud->resource && s && strcmp( bud->resource, s + 1 ) == 0 ) ) ) 556 577 { 557 g_hash_table_remove( jd->buddies, bud->bare_jid ); 558 g_free( bud->bare_jid ); 559 g_free( bud->ext_jid ); 560 g_free( bud->full_jid ); 561 g_free( bud->away_message ); 562 g_free( bud ); 563 564 g_free( full_jid ); 565 566 return 1; 578 return jabber_buddy_remove_bare( ic, full_jid ); 567 579 } 568 580 else if( s == NULL || bud->resource == NULL ) … … 575 587 else 576 588 { 577 for( bi = bud , prev = NULL; bi; bi = (prev=bi)->next )589 for( bi = bud; bi; bi = (prev=bi)->next ) 578 590 if( strcmp( bi->resource, s + 1 ) == 0 ) 579 591 break; … … 586 598 prev->next = bi->next; 587 599 else 588 /* The hash table should point at the second 589 item, because we're removing the first. */ 600 /* Don't think this should ever happen anymore. */ 590 601 g_hash_table_replace( jd->buddies, bi->bare_jid, bi->next ); 591 602 -
protocols/jabber/message.c
rb788246 r5fbec3d 71 71 if( bud ) 72 72 { 73 bud->last_ act= time( NULL );73 bud->last_msg = time( NULL ); 74 74 from = bud->ext_jid ? : bud->bare_jid; 75 75 } -
protocols/jabber/presence.c
rb788246 r5fbec3d 68 68 { 69 69 bud->away_state = NULL; 70 /* Let's only set last_act if there's *no* away state,71 since it could be some auto-away thingy. */72 bud->last_act = time( NULL );73 70 } 74 71 -
tests/check_jabber_util.c
rb788246 r5fbec3d 14 14 15 15 budw1 = jabber_buddy_add( ic, "wilmer@gaast.net/BitlBee" ); 16 budw1->last_ act= time( NULL ) - 100;16 budw1->last_msg = time( NULL ) - 100; 17 17 budw2 = jabber_buddy_add( ic, "WILMER@gaast.net/Telepathy" ); 18 18 budw2->priority = 2; 19 budw2->last_ act= time( NULL );19 budw2->last_msg = time( NULL ); 20 20 budw3 = jabber_buddy_add( ic, "wilmer@GAAST.NET/bitlbee" ); 21 budw3->last_ act= time( NULL ) - 200;21 budw3->last_msg = time( NULL ) - 200; 22 22 budw3->priority = 4; 23 23 /* TODO(wilmer): Shouldn't this just return budw3? */ … … 60 60 fail_unless( jabber_buddy_remove( ic, "wilmer@gaast.net/Telepathy" ) ); 61 61 fail_unless( jabber_buddy_remove( ic, "wilmer@gaast.net/telepathy" ) ); 62 fail_unless( jabber_buddy_by_jid( ic, "wilmer@gaast.net", 0 ) == budw1 ); 62 63 /* Test activity_timeout and GET_BUDDY_BARE_OK. */ 64 fail_unless( jabber_buddy_by_jid( ic, "wilmer@gaast.net", GET_BUDDY_BARE_OK ) == budw1 ); 65 budw1->last_msg -= 50; 66 fail_unless( ( bud = jabber_buddy_by_jid( ic, "wilmer@gaast.net", GET_BUDDY_BARE_OK ) ) != NULL ); 67 fail_unless( strcmp( bud->full_jid, "wilmer@gaast.net" ) == 0 ); 63 68 64 69 fail_if( jabber_buddy_remove( ic, "wilmer@gaast.net" ) ); 65 70 fail_unless( jabber_buddy_by_jid( ic, "wilmer@gaast.net", 0 ) == budw1 ); 66 71 72 fail_if( jabber_buddy_remove( ic, "wilmer@gaast.net" ) ); 73 fail_unless( jabber_buddy_remove( ic, "wilmer@gaast.net/bitlbee" ) ); 74 fail_unless( jabber_buddy_remove( ic, "wilmer@gaast.net/BitlBee" ) ); 75 fail_if( jabber_buddy_by_jid( ic, "wilmer@gaast.net", GET_BUDDY_BARE_OK ) ); 76 67 77 /* Check if remove_bare() indeed gets rid of all. */ 78 /* disable this one for now. 68 79 fail_unless( jabber_buddy_remove_bare( ic, "wilmer@gaast.net" ) ); 69 80 fail_if( jabber_buddy_by_jid( ic, "wilmer@gaast.net", 0 ) ); 81 */ 70 82 71 83 fail_if( jabber_buddy_remove( ic, "nekkid@lamejab.net/Illegal" ) ); 72 84 fail_unless( jabber_buddy_remove( ic, "nekkid@lamejab.net" ) ); 73 85 fail_if( jabber_buddy_by_jid( ic, "nekkid@lamejab.net", 0 ) ); 86 87 /* Fixing a bug in this branch that caused information to get lost when 88 removing the first full JID from a list. */ 89 jabber_buddy_add( ic, "bugtest@google.com/A" ); 90 jabber_buddy_add( ic, "bugtest@google.com/B" ); 91 jabber_buddy_add( ic, "bugtest@google.com/C" ); 92 fail_unless( jabber_buddy_remove( ic, "bugtest@google.com/A" ) ); 93 fail_unless( jabber_buddy_remove( ic, "bugtest@google.com/B" ) ); 94 fail_unless( jabber_buddy_remove( ic, "bugtest@google.com/C" ) ); 74 95 } 75 96 … … 85 106 jd->buddies = g_hash_table_new( g_str_hash, g_str_equal ); 86 107 set_add( &ic->acc->set, "resource_select", "priority", NULL, ic->acc ); 108 set_add( &ic->acc->set, "activity_timeout", "120", NULL, ic->acc ); 87 109 88 110 suite_add_tcase (s, tc_core);
Note: See TracChangeset
for help on using the changeset viewer.