- Timestamp:
- 2010-06-03T11:00:45Z (14 years ago)
- Branches:
- master
- Children:
- a6b2f13
- Parents:
- 5f8ab6a9 (diff), f4bcc22 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- protocols
- Files:
-
- 7 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
r5f8ab6a9 r814aa52 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
r5f8ab6a9 r814aa52 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
r5f8ab6a9 r814aa52 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 … … 656 667 time_t jabber_get_timestamp( struct xt_node *xt ) 657 668 { 658 struct tm tp, utc;659 669 struct xt_node *c; 660 time_t res, tres;661 670 char *s = NULL; 671 struct tm tp; 662 672 663 673 for( c = xt->children; ( c = xt_find_node( c, "x" ) ); c = c->next ) … … 677 687 tp.tm_year -= 1900; 678 688 tp.tm_mon --; 679 tp.tm_isdst = -1; /* GRRRRRRRRRRR */ 680 681 res = mktime( &tp ); 682 /* Problem is, mktime() just gave us the GMT timestamp for the 683 given local time... While the given time WAS NOT local. So 684 we should fix this now. 685 686 Now I could choose between messing with environment variables 687 (kludgy) or using timegm() (not portable)... Or doing the 688 following, which I actually prefer... */ 689 gmtime_r( &res, &utc ); 690 utc.tm_isdst = -1; /* Once more: GRRRRRRRRRRRRRRRRRR!!! */ 691 if( utc.tm_hour == tp.tm_hour && utc.tm_min == tp.tm_min ) 692 /* Sweet! We're in UTC right now... */ 693 return res; 694 695 tres = mktime( &utc ); 696 res += res - tres; 697 698 /* Yes, this is a hack. And it will go wrong around DST changes. 699 BUT this is more likely to be threadsafe than messing with 700 environment variables, and possibly more portable... */ 701 702 return res; 689 690 return mktime_utc( &tp ); 703 691 } 704 692 -
protocols/jabber/message.c
r5f8ab6a9 r814aa52 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 } … … 80 80 if( type && strcmp( type, "headline" ) == 0 ) 81 81 { 82 c = xt_find_node( node->children, "subject" );83 g_string_append_printf( fullmsg, "Headline: %s\n", c && c->text_len > 0 ? c->text : "");82 if( ( c = xt_find_node( node->children, "subject" ) ) && c->text_len > 0 ) 83 g_string_append_printf( fullmsg, "Headline: %s\n", c->text ); 84 84 85 85 /* <x xmlns="jabber:x:oob"><url>http://....</url></x> can contain a URL, it seems. */ -
protocols/jabber/presence.c
r5f8ab6a9 r814aa52 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 -
protocols/msn/msn.c
r5f8ab6a9 r814aa52 31 31 GSList *msn_switchboards; 32 32 33 static char * msn_set_display_name( set_t *set, char *value );33 static char *set_eval_display_name( set_t *set, char *value ); 34 34 35 35 static void msn_init( account_t *acc ) 36 36 { 37 set_t *s; 38 39 s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc ); 40 s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; 41 42 s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 37 set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc ); 38 set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc ); 39 set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 40 set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc ); 43 41 } 44 42 … … 167 165 static void msn_set_my_name( struct im_connection *ic, char *info ) 168 166 { 169 msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info );167 msn_set_display_name( ic, info ); 170 168 } 171 169 … … 283 281 } 284 282 285 static char * msn_set_display_name( set_t *set, char *value )283 static char *set_eval_display_name( set_t *set, char *value ) 286 284 { 287 285 account_t *acc = set->data; 288 286 struct im_connection *ic = acc->ic; 289 struct msn_data *md; 290 char buf[1024], *fn; 291 292 /* Double-check. */ 287 288 /* Allow any name if we're offline. */ 293 289 if( ic == NULL ) 294 return NULL; 295 296 md = ic->proto_data; 290 return value; 297 291 298 292 if( strlen( value ) > 129 ) … … 301 295 return NULL; 302 296 } 303 304 fn = msn_http_encode( value );305 306 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn );307 msn_write( ic, buf, strlen( buf ) );308 g_free( fn );309 297 310 298 /* Returning NULL would be better, because the server still has to 311 299 confirm the name change. However, it looks a bit confusing to the 312 300 user. */ 313 return value;301 return msn_set_display_name( ic, value ) ? value : NULL; 314 302 } 315 303 -
protocols/msn/msn.h
r5f8ab6a9 r814aa52 31 31 #define TYPING_NOTIFICATION_MESSAGE "\r\r\rBEWARE, ME R TYPINK MESSAGE!!!!\r\r\r" 32 32 #define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r" 33 #define SB_KEEPALIVE_MESSAGE "\r\r\rDONT HANG UP ON ME!\r\r\r" 33 34 34 35 #ifdef DEBUG_MSN … … 53 54 "TypingUser: %s\r\n" \ 54 55 "\r\n\r\n" 56 57 #define SB_KEEPALIVE_HEADERS "MIME-Version: 1.0\r\n" \ 58 "Content-Type: text/x-ping\r\n" \ 59 "\r\n\r\n" 55 60 56 61 #define PROFILE_URL "http://members.msn.com/" … … 83 88 gint inp; 84 89 struct msn_handler_data *handler; 90 gint keepalive; 85 91 86 92 int trId; … … 161 167 char *msn_http_encode( const char *input ); 162 168 void msn_msgq_purge( struct im_connection *ic, GSList **list ); 169 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname ); 163 170 164 171 /* tables.c */ … … 179 186 gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ); 180 187 int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m ); 188 void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial ); 189 void msn_sb_stop_keepalives( struct msn_switchboard *sb ); 181 190 182 191 #endif //_MSN_H -
protocols/msn/msn_util.c
r5f8ab6a9 r814aa52 38 38 imcb_error( ic, "Short write() to main server" ); 39 39 imc_logout( ic, TRUE ); 40 return ( 0 );41 } 42 43 return ( 1 );40 return 0; 41 } 42 43 return 1; 44 44 } 45 45 … … 377 377 g_string_free( ret, TRUE ); 378 378 } 379 380 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname ) 381 { 382 char *fn = msn_http_encode( rawname ); 383 struct msn_data *md = ic->proto_data; 384 char buf[1024]; 385 386 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn ); 387 g_free( fn ); 388 389 return msn_write( ic, buf, strlen( buf ) ) != 0; 390 } -
protocols/msn/ns.c
r5f8ab6a9 r814aa52 35 35 36 36 static void msn_auth_got_passport_token( struct msn_auth_data *mad ); 37 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ); 37 38 38 39 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) … … 231 232 else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 ) 232 233 { 233 set_t *s;234 235 234 if( num_parts == 7 ) 236 { 237 http_decode( cmd[4] ); 238 239 strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); 240 ic->displayname[sizeof(ic->displayname)-1] = 0; 241 242 if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) 243 { 244 g_free( s->value ); 245 s->value = g_strdup( cmd[4] ); 246 } 247 } 235 msn_ns_got_display_name( ic, cmd[4] ); 248 236 else 249 {250 237 imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); 251 }252 238 253 239 imcb_log( ic, "Authenticated, getting buddy list" ); … … 422 408 else if( strcmp( cmd[0], "FLN" ) == 0 ) 423 409 { 424 if( cmd[1] ) 425 imcb_buddy_status( ic, cmd[1], 0, NULL, NULL ); 410 if( cmd[1] == NULL ) 411 return 1; 412 413 imcb_buddy_status( ic, cmd[1], 0, NULL, NULL ); 414 415 msn_sb_start_keepalives( msn_sb_by_handle( ic, cmd[1] ), TRUE ); 426 416 } 427 417 else if( strcmp( cmd[0], "NLN" ) == 0 ) … … 449 439 ( st != msn_away_state_list ? OPT_AWAY : 0 ), 450 440 st->name, NULL ); 441 442 msn_sb_stop_keepalives( msn_sb_by_handle( ic, cmd[2] ) ); 451 443 } 452 444 else if( strcmp( cmd[0], "RNG" ) == 0 ) … … 553 545 return( 0 ); 554 546 } 547 #if 0 548 /* Discard this one completely for now since I don't care about the ack 549 and since MSN servers can apparently screw up the formatting. */ 555 550 else if( strcmp( cmd[0], "REA" ) == 0 ) 556 551 { … … 583 578 } 584 579 } 580 #endif 585 581 else if( strcmp( cmd[0], "IPG" ) == 0 ) 586 582 { … … 732 728 } 733 729 } 730 731 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ) 732 { 733 set_t *s; 734 735 if( ( s = set_find( &ic->acc->set, "display_name" ) ) == NULL ) 736 return FALSE; /* Shouldn't happen.. */ 737 738 http_decode( name ); 739 740 if( s->value && strcmp( s->value, name ) == 0 ) 741 { 742 return TRUE; 743 /* The names match, nothing to worry about. */ 744 } 745 else if( s->value != NULL && 746 ( strcmp( name, ic->acc->user ) == 0 || 747 set_getbool( &ic->acc->set, "local_display_name" ) ) ) 748 { 749 /* The server thinks our display name is our e-mail address 750 which is probably wrong, or the user *wants* us to do this: 751 Always use the locally set display_name. */ 752 return msn_set_display_name( ic, s->value ); 753 } 754 else 755 { 756 if( s->value && *s->value ) 757 imcb_log( ic, "BitlBee thinks your display name is `%s' but " 758 "the MSN server says it's `%s'. Using the MSN " 759 "server's name. Set local_display_name to true " 760 "to use the local name.", s->value, name ); 761 762 if( g_utf8_validate( name, -1, NULL ) ) 763 { 764 g_free( s->value ); 765 s->value = g_strdup( name ); 766 } 767 else 768 { 769 imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); 770 } 771 772 return TRUE; 773 } 774 } -
protocols/msn/sb.c
r5f8ab6a9 r814aa52 168 168 169 169 /* Build the message. Convert LF to CR-LF for normal messages. */ 170 if( strcmp( text, TYPING_NOTIFICATION_MESSAGE ) != 0 ) 170 if( strcmp( text, TYPING_NOTIFICATION_MESSAGE ) == 0 ) 171 { 172 i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->ic->acc->user ); 173 buf = g_new0( char, i ); 174 i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->ic->acc->user ); 175 } 176 else if( strcmp( text, SB_KEEPALIVE_MESSAGE ) == 0 ) 177 { 178 buf = g_strdup( SB_KEEPALIVE_HEADERS ); 179 i = strlen( buf ); 180 } 181 else 171 182 { 172 183 buf = g_new0( char, sizeof( MSN_MESSAGE_HEADERS ) + strlen( text ) * 2 + 1 ); … … 182 193 } 183 194 } 184 else185 {186 i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->ic->acc->user );187 buf = g_new0( char, i );188 i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->ic->acc->user );189 }190 195 191 196 /* Build the final packet (MSG command + the message). */ … … 250 255 251 256 msn_msgq_purge( ic, &sb->msgq ); 257 msn_sb_stop_keepalives( sb ); 252 258 253 259 if( sb->key ) g_free( sb->key ); … … 471 477 472 478 sb->ready = 1; 479 480 msn_sb_start_keepalives( sb, FALSE ); 473 481 } 474 482 else if( strcmp( cmd[0], "CAL" ) == 0 ) … … 520 528 } 521 529 530 msn_sb_start_keepalives( sb, FALSE ); 531 522 532 return( st ); 523 533 } … … 581 591 if( sb->who ) 582 592 { 593 msn_sb_stop_keepalives( sb ); 594 583 595 /* This is a single-person chat, and the other person is leaving. */ 584 596 g_free( sb->who ); … … 764 776 return( 1 ); 765 777 } 778 779 static gboolean msn_sb_keepalive( gpointer data, gint source, b_input_condition cond ) 780 { 781 struct msn_switchboard *sb = data; 782 return sb->ready && msn_sb_sendmessage( sb, SB_KEEPALIVE_MESSAGE ); 783 } 784 785 void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial ) 786 { 787 struct buddy *b; 788 789 if( sb && sb->who && sb->keepalive == 0 && 790 ( b = imcb_find_buddy( sb->ic, sb->who ) ) && !b->present && 791 set_getbool( &sb->ic->acc->set, "switchboard_keepalives" ) ) 792 { 793 if( initial ) 794 msn_sb_keepalive( sb, 0, 0 ); 795 796 sb->keepalive = b_timeout_add( 20000, msn_sb_keepalive, sb ); 797 } 798 } 799 800 void msn_sb_stop_keepalives( struct msn_switchboard *sb ) 801 { 802 if( sb && sb->keepalive > 0 ) 803 { 804 b_event_remove( sb->keepalive ); 805 sb->keepalive = 0; 806 } 807 } -
protocols/nogaim.c
r5f8ab6a9 r814aa52 39 39 40 40 static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ); 41 static char *format_timestamp( irc_t *irc, time_t msg_ts ); 41 42 42 43 GSList *connections; … … 132 133 extern void byahoo_initmodule(); 133 134 extern void jabber_initmodule(); 135 extern void twitter_initmodule(); 134 136 135 137 #ifdef WITH_MSN … … 147 149 #ifdef WITH_JABBER 148 150 jabber_initmodule(); 151 #endif 152 153 #ifdef WITH_TWITTER 154 twitter_initmodule(); 149 155 #endif 150 156 … … 727 733 { 728 734 irc_t *irc = ic->irc; 729 char *wrapped ;735 char *wrapped, *ts = NULL; 730 736 user_t *u; 731 737 … … 776 782 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 777 783 strip_html( msg ); 778 784 785 if( set_getbool( &ic->irc->set, "display_timestamps" ) && 786 ( ts = format_timestamp( irc, sent_at ) ) ) 787 { 788 char *new = g_strconcat( ts, msg, NULL ); 789 g_free( ts ); 790 ts = msg = new; 791 } 792 779 793 wrapped = word_wrap( msg, 425 ); 780 794 irc_msgfrom( irc, u->nick, wrapped ); 781 795 g_free( wrapped ); 782 796 g_free( msg ); 797 g_free( ts ); 783 798 } 784 799 … … 822 837 823 838 return c; 839 } 840 841 void imcb_chat_name_hint( struct groupchat *c, const char *name ) 842 { 843 if( !c->joined ) 844 { 845 struct im_connection *ic = c->ic; 846 char stripped[MAX_NICK_LENGTH+1], *full_name; 847 848 strncpy( stripped, name, MAX_NICK_LENGTH ); 849 stripped[MAX_NICK_LENGTH] = '\0'; 850 nick_strip( stripped ); 851 if( set_getbool( &ic->irc->set, "lcnicks" ) ) 852 nick_lc( stripped ); 853 854 full_name = g_strdup_printf( "&%s", stripped ); 855 856 if( stripped[0] && 857 nick_cmp( stripped, ic->irc->channel + 1 ) != 0 && 858 irc_chat_by_channel( ic->irc, full_name ) == NULL ) 859 { 860 g_free( c->channel ); 861 c->channel = full_name; 862 } 863 else 864 { 865 g_free( full_name ); 866 } 867 } 824 868 } 825 869 … … 884 928 if( c && u ) 885 929 { 886 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); 930 char *ts = NULL; 931 if( set_getbool( &ic->irc->set, "display_timestamps" ) ) 932 ts = format_timestamp( ic->irc, sent_at ); 933 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped ); 934 g_free( ts ); 887 935 } 888 936 else … … 1021 1069 1022 1070 1071 /* Misc. BitlBee stuff which shouldn't really be here */ 1072 1073 char *set_eval_timezone( set_t *set, char *value ) 1074 { 1075 char *s; 1076 1077 if( strcmp( value, "local" ) == 0 || 1078 strcmp( value, "gmt" ) == 0 || strcmp( value, "utc" ) == 0 ) 1079 return value; 1080 1081 /* Otherwise: +/- at the beginning optional, then one or more numbers, 1082 possibly followed by a colon and more numbers. Don't bother bound- 1083 checking them since users are free to shoot themselves in the foot. */ 1084 s = value; 1085 if( *s == '+' || *s == '-' ) 1086 s ++; 1087 1088 /* \d+ */ 1089 if( !isdigit( *s ) ) 1090 return SET_INVALID; 1091 while( *s && isdigit( *s ) ) s ++; 1092 1093 /* EOS? */ 1094 if( *s == '\0' ) 1095 return value; 1096 1097 /* Otherwise, colon */ 1098 if( *s != ':' ) 1099 return SET_INVALID; 1100 s ++; 1101 1102 /* \d+ */ 1103 if( !isdigit( *s ) ) 1104 return SET_INVALID; 1105 while( *s && isdigit( *s ) ) s ++; 1106 1107 /* EOS */ 1108 return *s == '\0' ? value : SET_INVALID; 1109 } 1110 1111 static char *format_timestamp( irc_t *irc, time_t msg_ts ) 1112 { 1113 time_t now_ts = time( NULL ); 1114 struct tm now, msg; 1115 char *set; 1116 1117 /* If the timestamp is <= 0 or less than a minute ago, discard it as 1118 it doesn't seem to add to much useful info and/or might be noise. */ 1119 if( msg_ts <= 0 || msg_ts > now_ts - 60 ) 1120 return NULL; 1121 1122 set = set_getstr( &irc->set, "timezone" ); 1123 if( strcmp( set, "local" ) == 0 ) 1124 { 1125 localtime_r( &now_ts, &now ); 1126 localtime_r( &msg_ts, &msg ); 1127 } 1128 else 1129 { 1130 int hr, min = 0, sign = 60; 1131 1132 if( set[0] == '-' ) 1133 { 1134 sign *= -1; 1135 set ++; 1136 } 1137 else if( set[0] == '+' ) 1138 { 1139 set ++; 1140 } 1141 1142 if( sscanf( set, "%d:%d", &hr, &min ) >= 1 ) 1143 { 1144 msg_ts += sign * ( hr * 60 + min ); 1145 now_ts += sign * ( hr * 60 + min ); 1146 } 1147 1148 gmtime_r( &now_ts, &now ); 1149 gmtime_r( &msg_ts, &msg ); 1150 } 1151 1152 if( msg.tm_year == now.tm_year && msg.tm_yday == now.tm_yday ) 1153 return g_strdup_printf( "\x02[\x02\x02\x02%02d:%02d:%02d\x02]\x02 ", 1154 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1155 else 1156 return g_strdup_printf( "\x02[\x02\x02\x02%04d-%02d-%02d " 1157 "%02d:%02d:%02d\x02]\x02 ", 1158 msg.tm_year + 1900, msg.tm_mon, msg.tm_mday, 1159 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1160 } 1161 1023 1162 /* The plan is to not allow straight calls to prpl functions anymore, but do 1024 1163 them all from some wrappers. We'll start to define some down here: */ … … 1063 1202 { 1064 1203 char *away, *msg = NULL; 1204 1205 if( ic->acc->prpl->away_states == NULL || 1206 ic->acc->prpl->set_away == NULL ) 1207 return 0; 1065 1208 1066 1209 away = set_getstr( &ic->acc->set, "away" ) ? -
protocols/nogaim.h
r5f8ab6a9 r814aa52 306 306 * user, too. */ 307 307 G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle ); 308 G_MODULE_EXPORT void imcb_chat_name_hint( struct groupchat *c, const char *name ); 308 309 G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, const char *handle ); 309 310 /* To remove a handle from a group chat. Reason can be NULL. */ … … 328 329 329 330 /* Misc. stuff */ 331 char *set_eval_timezone( set_t *set, char *value ); 330 332 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ); 331 333 void cancel_auto_reconnect( struct account *a ); -
protocols/oscar/oscar.c
r5f8ab6a9 r814aa52 373 373 set_t *s; 374 374 375 s = set_add( &acc->set, "server", AIM_DEFAULT_LOGIN_SERVER, set_eval_account, acc ); 375 if (isdigit(acc->user[0])) { 376 set_add(&acc->set, "ignore_auth_requests", "false", set_eval_bool, acc); 377 } 378 379 s = set_add(&acc->set, "server", AIM_DEFAULT_LOGIN_SERVER, set_eval_account, acc); 376 380 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 377 381 378 if 379 s = set_add( &acc->set, "web_aware", "false", set_eval_bool, acc);382 if(isdigit(acc->user[0])) { 383 s = set_add(&acc->set, "web_aware", "false", set_eval_bool, acc); 380 384 s->flags |= ACC_SET_OFFLINE_ONLY; 381 385 } … … 1212 1216 */ 1213 1217 static void gaim_icq_authask(struct im_connection *ic, guint32 uin, char *msg) { 1214 struct icq_auth *data = g_new(struct icq_auth, 1);1218 struct icq_auth *data; 1215 1219 char *reason = NULL; 1216 1220 char *dialog_msg; 1217 1221 1222 if (set_getbool(&ic->acc->set, "ignore_auth_requests")) 1223 return; 1224 1225 data = g_new(struct icq_auth, 1); 1226 1218 1227 if (strlen(msg) > 6) 1219 1228 reason = msg + 6;
Note: See TracChangeset
for help on using the changeset viewer.