Changes in / [bb839e8:efbc154]
- Files:
-
- 7 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
rbb839e8 refbc154 126 126 ctags: 127 127 ctags `find . -name "*.c"` `find . -name "*.h"` 128 129 # Using this as a bogus Make target to test if a GNU-compatible version of 130 # make is available. 131 helloworld: 132 @echo Hello World -
bitlbee.c
rbb839e8 refbc154 36 36 static gboolean bitlbee_io_new_client( gpointer data, gint fd, b_input_condition condition ); 37 37 38 static gboolean try_listen( struct addrinfo *res ) 39 { 40 int i; 41 42 global.listen_socket = socket( res->ai_family, res->ai_socktype, res->ai_protocol ); 43 if( global.listen_socket < 0 ) 44 { 45 log_error( "socket" ); 46 return FALSE; 47 } 48 49 #ifdef IPV6_V6ONLY 50 if( res->ai_family == AF_INET6 ) 51 { 52 i = 0; 53 setsockopt( global.listen_socket, IPPROTO_IPV6, IPV6_V6ONLY, 54 (char *) &i, sizeof( i ) ); 55 } 56 #endif 57 58 /* TIME_WAIT (?) sucks.. */ 59 i = 1; 60 setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i, sizeof( i ) ); 61 62 i = bind( global.listen_socket, res->ai_addr, res->ai_addrlen ); 63 if( i == -1 ) 64 { 65 closesocket( global.listen_socket ); 66 global.listen_socket = -1; 67 68 log_error( "bind" ); 69 return FALSE; 70 } 71 72 return TRUE; 73 } 74 38 75 int bitlbee_daemon_init() 39 76 { … … 42 79 FILE *fp; 43 80 44 log_link( LOGLVL_ERROR, LOGOUTPUT_ SYSLOG);45 log_link( LOGLVL_WARNING, LOGOUTPUT_ SYSLOG);81 log_link( LOGLVL_ERROR, LOGOUTPUT_CONSOLE ); 82 log_link( LOGLVL_WARNING, LOGOUTPUT_CONSOLE ); 46 83 47 84 memset( &hints, 0, sizeof( hints ) ); … … 63 100 64 101 global.listen_socket = -1; 65 102 103 /* Try IPv6 first (which will become an IPv6+IPv4 socket). */ 66 104 for( res = addrinfo_bind; res; res = res->ai_next ) 67 { 68 global.listen_socket = socket( res->ai_family, res->ai_socktype, res->ai_protocol ); 69 if( global.listen_socket < 0 ) 70 continue; 71 72 /* TIME_WAIT (?) sucks.. */ 73 i = 1; 74 setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i, sizeof( i ) ); 75 76 i = bind( global.listen_socket, res->ai_addr, res->ai_addrlen ); 77 if( i == -1 ) 78 { 79 log_error( "bind" ); 80 return( -1 ); 81 } 82 83 break; 84 } 85 105 if( res->ai_family == AF_INET6 && try_listen( res ) ) 106 break; 107 108 /* The rest (so IPv4, I guess). */ 109 if( res == NULL ) 110 for( res = addrinfo_bind; res; res = res->ai_next ) 111 if( res->ai_family != AF_INET6 && try_listen( res ) ) 112 break; 113 86 114 freeaddrinfo( addrinfo_bind ); 87 115 … … 107 135 exit( 0 ); 108 136 137 setsid(); 109 138 chdir( "/" ); 110 139 … … 137 166 #endif 138 167 168 if( !global.conf->nofork ) 169 { 170 log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG ); 171 log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG ); 172 } 173 139 174 return( 0 ); 140 175 } -
bitlbee.h
rbb839e8 refbc154 35 35 36 36 #define PACKAGE "BitlBee" 37 #define BITLBEE_VERSION "1.2. 5"37 #define BITLBEE_VERSION "1.2.6" 38 38 #define VERSION BITLBEE_VERSION 39 #define BITLBEE_VER(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 40 #define BITLBEE_VERSION_CODE BITLBEE_VER(1, 2, 6) 39 41 40 42 #define MAX_STRING 511 -
conf.c
rbb839e8 refbc154 79 79 } 80 80 81 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u: " ) ) >= 0 )81 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u:V" ) ) >= 0 ) 82 82 /* ^^^^ Just to make sure we skip this step from the REHASH handler. */ 83 83 { … … 145 145 " -d Specify alternative user configuration directory\n" 146 146 " -x Command-line interface to password encryption/hashing\n" 147 " -h Show this help page.\n" ); 147 " -h Show this help page.\n" 148 " -V Show version info.\n" ); 149 return NULL; 150 } 151 else if( opt == 'V' ) 152 { 153 printf( "BitlBee %s\nAPI version %06x\n", 154 BITLBEE_VERSION, BITLBEE_VERSION_CODE ); 148 155 return NULL; 149 156 } -
configure
rbb839e8 refbc154 26 26 oscar=1 27 27 yahoo=1 28 twitter=1 28 29 29 30 debug=0 … … 66 67 --oscar=0/1 Disable/enable Oscar part (ICQ, AIM) $oscar 67 68 --yahoo=0/1 Disable/enable Yahoo part $yahoo 69 --twitter=0/1 Disable/enable Twitter part $twitter 68 70 69 71 --debug=0/1 Disable/enable debugging $debug … … 267 269 detect_ldap() 268 270 { 269 TMPFILE=$(mktemp )271 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) 270 272 if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then 271 273 cat<<EOF>>Makefile.settings … … 295 297 detect_resolv_dynamic() 296 298 { 297 TMPFILE=$(mktemp )299 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) 298 300 ret=1 299 301 echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -lresolv >/dev/null 2>/dev/null … … 309 311 detect_resolv_static() 310 312 { 311 TMPFILE=$(mktemp )313 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) 312 314 ret=1 313 315 for i in $systemlibdirs; do … … 476 478 fi 477 479 480 if ! make helloworld > /dev/null 2>&1; then 481 echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles." 482 echo "BitlBee needs GNU make to build properly. On most systems GNU make is available" 483 echo "under the name 'gmake'." 484 echo 485 if gmake helloworld > /dev/null 2>&1; then 486 echo "gmake seems to be available on your machine, great." 487 echo 488 else 489 echo "gmake is not installed (or not working). Please try to install it." 490 echo 491 fi 492 fi 493 478 494 cat <<EOF>bitlbee.pc 479 495 prefix=$prefix … … 524 540 fi 525 541 542 if [ "$twitter" = 0 ]; then 543 echo '#undef WITH_TWITTER' >> config.h 544 else 545 echo '#define WITH_TWITTER' >> config.h 546 protocols=$protocols'twitter ' 547 protoobjs=$protoobjs'twitter_mod.o ' 548 fi 549 526 550 if [ "$protocols" = "PROTOCOLS = " ]; then 527 551 echo "Warning: You haven't selected any communication protocol to compile!" -
doc/CHANGES
rbb839e8 refbc154 3 3 4 4 http://bugs.bitlbee.org/bitlbee/timeline?daysback=90&changeset=on 5 6 Version 1.2.6: 7 - Native (very basic) support for Twitter, implemented by Geert Mulders. 8 Currently supported are posting tweets, reading the ones of people you 9 follow, and sending (not yet receiving!) direct messages. 10 - Fixed format of status messages in /WHOIS to improve IRC client 11 compatibility. 12 - Show timestamps of offline messages/channel backlogs. 13 - Allow saving MSN display names locally since sometimes this stuff breaks 14 server-side. (Use the local_display_name per-account setting.) 15 - Suppress empty "Headline:" messages for certain new XMPP broadcast 16 messages. 17 - Better handling of XMPP contacts with multiple resources on-line. Default 18 behaviour now is to write to wherever the last message came from, or to 19 the bare JID (usually becomes a broadcast) if there wasn't any recent msg. 20 - The usual misc. bug fixes. 21 22 Finished ... 5 23 6 24 Version 1.2.5: … … 23 41 the main client). 24 42 25 Fi xed 17 Mar 201043 Finished 17 Mar 2010 26 44 27 45 Version 1.2.4: -
doc/user-guide/commands.xml
rbb839e8 refbc154 21 21 <description> 22 22 <para> 23 Adds an account on the given server with the specified protocol, username and password to the account list. Supported protocols right now are: Jabber, MSN, OSCAR (AIM/ICQ) and Yahoo. For more information about adding an account, see <emphasis>help account add <protocol></emphasis>.23 Adds an account on the given server with the specified protocol, username and password to the account list. Supported protocols right now are: Jabber, MSN, OSCAR (AIM/ICQ), Yahoo and Twitter. For more information about adding an account, see <emphasis>help account add <protocol></emphasis>. 24 24 </para> 25 25 </description> … … 63 63 </ircexample> 64 64 </bitlbee-command> 65 66 <bitlbee-command name="twitter"> 67 <syntax>account add twitter <handle> <password></syntax> 68 69 <description> 70 <para> 71 This module gives you simple access to Twitter. Although it uses the Twitter API, only Twitter itself is supported at the moment. 72 </para> 73 74 <para> 75 By default all your Twitter contacts will come from a contact called twitter_(yourusername). You can change this behaviour using the <emphasis>mode</emphasis> setting (see <emphasis>help set mode</emphasis>). 76 </para> 77 78 <para> 79 To send tweets yourself, send them to the twitter_(yourusername) contact, or just write in the groupchat channel if you enabled that option. 80 </para> 81 </description> 82 </bitlbee-command> 65 83 66 84 <bitlbee-command name="yahoo"> … … 401 419 402 420 <bitlbee-setting name="auto_reconnect" type="boolean" scope="both"> 403 <default> false</default>421 <default>true</default> 404 422 405 423 <description> … … 556 574 <para> 557 575 With this option enabled, root will inform you when someone in your buddy list changes his/her "friendly name". 576 </para> 577 </description> 578 </bitlbee-setting> 579 580 <bitlbee-setting name="display_timestamps" type="boolean" scope="global"> 581 <default>true</default> 582 583 <description> 584 <para> 585 When incoming messages are old (i.e. offline messages and channel backlogs), BitlBee will prepend them with a timestamp. If you find them ugly or useless, you can use this setting to hide them. 558 586 </para> 559 587 </description> … … 609 637 </bitlbee-setting> 610 638 639 <bitlbee-setting name="local_display_name" type="boolean" scope="account"> 640 <default>false</default> 641 642 <description> 643 <para> 644 Mostly meant to work around a bug in MSN servers (forgetting the display name set by the user), this setting tells BitlBee to store your display name locally and set this name on the MSN servers when connecting. 645 </para> 646 </description> 647 648 </bitlbee-setting> 649 611 650 <bitlbee-setting name="mail_notifications" type="boolean" scope="account"> 612 651 <default>false</default> … … 615 654 <para> 616 655 Some protocols (MSN, Yahoo!) can notify via IM about new e-mail. Since most people use their Hotmail/Yahoo! addresses as a spam-box, this is disabled default. If you want these notifications, you can enable this setting. 656 </para> 657 </description> 658 659 </bitlbee-setting> 660 661 <bitlbee-setting name="mode" type="string" scope="account"> 662 <possible-values>one, many, chat</possible-values> 663 <default>one</default> 664 665 <description> 666 <para> 667 By default, everything from the Twitter module will come from one nick, twitter_(yourusername). If you prefer to have individual nicks for everyone, you can set this setting to "many" instead. 668 </para> 669 670 <para> 671 If you prefer to have all your Twitter things in a separate channel, you can set this setting to "chat". 672 </para> 673 674 <para> 675 In the last two modes, you can send direct messages by /msg'ing your contacts directly. Note, however, that incoming DMs are not fetched yet. 617 676 </para> 618 677 </description> … … 824 883 <para> 825 884 If BitlBee fails to detect this sometimes (most likely in AIM messages over an ICQ connection), you can set this setting to <emphasis>always</emphasis>, but this might sometimes accidentally strip non-HTML things too. 885 </para> 886 </description> 887 </bitlbee-setting> 888 889 <bitlbee-setting name="timezone" type="string" scope="global"> 890 <default>local</default> 891 <possible-values>local, utc, gmt, timezone-spec</possible-values> 892 893 <description> 894 <para> 895 If message timestamps are available for offline messages or chatroom backlogs, BitlBee will display them as part of the message. By default it will use the local timezone. If you're not in the same timezone as the BitlBee server, you can adjust the timestamps using this setting. 896 </para> 897 898 <para> 899 Values local/utc/gmt should be self-explanatory. timezone-spec is a time offset in hours:minutes, for example: -8 for Pacific Standard Time, +2 for Central European Summer Time, +5:30 for Indian Standard Time. 826 900 </para> 827 901 </description> -
irc.c
rbb839e8 refbc154 52 52 { 53 53 irc_t *irc = set->data; 54 char *test; 55 gsize test_bytes = 0; 54 56 GIConv ic, oc; 55 57 … … 57 59 value = g_strdup( "utf-8" ); 58 60 61 if( ( oc = g_iconv_open( value, "utf-8" ) ) == (GIConv) -1 ) 62 { 63 return NULL; 64 } 65 66 /* Do a test iconv to see if the user picked an IRC-compatible 67 charset (for example utf-16 goes *horribly* wrong). */ 68 if( ( test = g_convert_with_iconv( " ", 1, oc, NULL, &test_bytes, NULL ) ) == NULL || 69 test_bytes > 1 ) 70 { 71 g_free( test ); 72 g_iconv_close( oc ); 73 irc_usermsg( irc, "Unsupported character set: The IRC protocol " 74 "only supports 8-bit character sets." ); 75 return NULL; 76 } 77 g_free( test ); 78 59 79 if( ( ic = g_iconv_open( "utf-8", value ) ) == (GIConv) -1 ) 60 80 { 61 return NULL; 62 } 63 if( ( oc = g_iconv_open( value, "utf-8" ) ) == (GIConv) -1 ) 64 { 65 g_iconv_close( ic ); 81 g_iconv_close( oc ); 66 82 return NULL; 67 83 } … … 175 191 s = set_add( &irc->set, "default_target", "root", NULL, irc ); 176 192 s = set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 193 s = set_add( &irc->set, "display_timestamps", "true", set_eval_bool, irc ); 177 194 s = set_add( &irc->set, "handle_unknown", "root", NULL, irc ); 178 195 s = set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc ); … … 188 205 s->flags |= SET_NULL_OK; 189 206 s = set_add( &irc->set, "strip_html", "true", NULL, irc ); 207 s = set_add( &irc->set, "timezone", "local", set_eval_timezone, irc ); 190 208 s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc ); 191 209 s = set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc ); -
irc_commands.c
rbb839e8 refbc154 498 498 irc_reply( irc, 301, "%s :%s", u->nick, u->away ); 499 499 if( u->status_msg ) 500 irc_reply( irc, 3 33, "%s :Status:%s", u->nick, u->status_msg );500 irc_reply( irc, 320, "%s :%s", u->nick, u->status_msg ); 501 501 502 502 irc_reply( irc, 318, "%s :End of /WHOIS list", nick ); -
lib/misc.c
rbb839e8 refbc154 77 77 78 78 return mktime(&tm); 79 } 80 81 time_t mktime_utc( struct tm *tp ) 82 { 83 struct tm utc; 84 time_t res, tres; 85 86 tp->tm_isdst = -1; 87 res = mktime( tp ); 88 /* Problem is, mktime() just gave us the GMT timestamp for the 89 given local time... While the given time WAS NOT local. So 90 we should fix this now. 91 92 Now I could choose between messing with environment variables 93 (kludgy) or using timegm() (not portable)... Or doing the 94 following, which I actually prefer... 95 96 tzset() may also work but in other places I actually want to 97 use local time. 98 99 FFFFFFFFFFFFFFFFFFFFFUUUUUUUUUUUUUUUUUUUU!! */ 100 gmtime_r( &res, &utc ); 101 utc.tm_isdst = -1; 102 if( utc.tm_hour == tp->tm_hour && utc.tm_min == tp->tm_min ) 103 /* Sweet! We're in UTC right now... */ 104 return res; 105 106 tres = mktime( &utc ); 107 res += res - tres; 108 109 /* Yes, this is a hack. And it will go wrong around DST changes. 110 BUT this is more likely to be threadsafe than messing with 111 environment variables, and possibly more portable... */ 112 113 return res; 79 114 } 80 115 -
lib/misc.h
rbb839e8 refbc154 43 43 44 44 G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec ); 45 G_MODULE_EXPORT time_t mktime_utc( struct tm *tp ); 45 46 double gettime( void ); 46 47 -
log.c
rbb839e8 refbc154 172 172 fprintf(stdout, "Debug: %s\n", message); 173 173 #endif 174 /* Always log stuff in syslogs too. */ 175 log_syslog(level, message); 174 176 return; 175 177 } -
protocols/jabber/jabber_util.c
rbb839e8 refbc154 667 667 time_t jabber_get_timestamp( struct xt_node *xt ) 668 668 { 669 struct tm tp, utc;670 669 struct xt_node *c; 671 time_t res, tres;672 670 char *s = NULL; 671 struct tm tp; 673 672 674 673 for( c = xt->children; ( c = xt_find_node( c, "x" ) ); c = c->next ) … … 688 687 tp.tm_year -= 1900; 689 688 tp.tm_mon --; 690 tp.tm_isdst = -1; /* GRRRRRRRRRRR */ 691 692 res = mktime( &tp ); 693 /* Problem is, mktime() just gave us the GMT timestamp for the 694 given local time... While the given time WAS NOT local. So 695 we should fix this now. 696 697 Now I could choose between messing with environment variables 698 (kludgy) or using timegm() (not portable)... Or doing the 699 following, which I actually prefer... */ 700 gmtime_r( &res, &utc ); 701 utc.tm_isdst = -1; /* Once more: GRRRRRRRRRRRRRRRRRR!!! */ 702 if( utc.tm_hour == tp.tm_hour && utc.tm_min == tp.tm_min ) 703 /* Sweet! We're in UTC right now... */ 704 return res; 705 706 tres = mktime( &utc ); 707 res += res - tres; 708 709 /* Yes, this is a hack. And it will go wrong around DST changes. 710 BUT this is more likely to be threadsafe than messing with 711 environment variables, and possibly more portable... */ 712 713 return res; 689 690 return mktime_utc( &tp ); 714 691 } 715 692 -
protocols/msn/msn.c
rbb839e8 refbc154 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 ); 43 44 s = set_add( &acc->set, "switchboard_keepalives", "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 ); 45 41 } 46 42 … … 169 165 static void msn_set_my_name( struct im_connection *ic, char *info ) 170 166 { 171 msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info );167 msn_set_display_name( ic, info ); 172 168 } 173 169 … … 285 281 } 286 282 287 static char * msn_set_display_name( set_t *set, char *value )283 static char *set_eval_display_name( set_t *set, char *value ) 288 284 { 289 285 account_t *acc = set->data; 290 286 struct im_connection *ic = acc->ic; 291 struct msn_data *md; 292 char buf[1024], *fn; 293 294 /* Double-check. */ 287 288 /* Allow any name if we're offline. */ 295 289 if( ic == NULL ) 296 return NULL; 297 298 md = ic->proto_data; 290 return value; 299 291 300 292 if( strlen( value ) > 129 ) … … 303 295 return NULL; 304 296 } 305 306 fn = msn_http_encode( value );307 308 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn );309 msn_write( ic, buf, strlen( buf ) );310 g_free( fn );311 297 312 298 /* Returning NULL would be better, because the server still has to 313 299 confirm the name change. However, it looks a bit confusing to the 314 300 user. */ 315 return value;301 return msn_set_display_name( ic, value ) ? value : NULL; 316 302 } 317 303 -
protocols/msn/msn.h
rbb839e8 refbc154 167 167 char *msn_http_encode( const char *input ); 168 168 void msn_msgq_purge( struct im_connection *ic, GSList **list ); 169 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname ); 169 170 170 171 /* tables.c */ -
protocols/msn/msn_util.c
rbb839e8 refbc154 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
rbb839e8 refbc154 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" ); … … 573 559 return( 0 ); 574 560 } 561 #if 0 562 /* Discard this one completely for now since I don't care about the ack 563 and since MSN servers can apparently screw up the formatting. */ 575 564 else if( strcmp( cmd[0], "REA" ) == 0 ) 576 565 { … … 603 592 } 604 593 } 594 #endif 605 595 else if( strcmp( cmd[0], "IPG" ) == 0 ) 606 596 { … … 752 742 } 753 743 } 744 745 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ) 746 { 747 set_t *s; 748 749 if( ( s = set_find( &ic->acc->set, "display_name" ) ) == NULL ) 750 return FALSE; /* Shouldn't happen.. */ 751 752 http_decode( name ); 753 754 if( s->value && strcmp( s->value, name ) == 0 ) 755 { 756 return TRUE; 757 /* The names match, nothing to worry about. */ 758 } 759 else if( s->value != NULL && 760 ( strcmp( name, ic->acc->user ) == 0 || 761 set_getbool( &ic->acc->set, "local_display_name" ) ) ) 762 { 763 /* The server thinks our display name is our e-mail address 764 which is probably wrong, or the user *wants* us to do this: 765 Always use the locally set display_name. */ 766 return msn_set_display_name( ic, s->value ); 767 } 768 else 769 { 770 if( s->value && *s->value ) 771 imcb_log( ic, "BitlBee thinks your display name is `%s' but " 772 "the MSN server says it's `%s'. Using the MSN " 773 "server's name. Set local_display_name to true " 774 "to use the local name.", s->value, name ); 775 776 if( g_utf8_validate( name, -1, NULL ) ) 777 { 778 g_free( s->value ); 779 s->value = g_strdup( name ); 780 } 781 else 782 { 783 imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); 784 } 785 786 return TRUE; 787 } 788 } -
protocols/nogaim.c
rbb839e8 refbc154 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 … … 718 724 { 719 725 irc_t *irc = ic->irc; 720 char *wrapped ;726 char *wrapped, *ts = NULL; 721 727 user_t *u; 722 728 … … 760 766 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 761 767 strip_html( msg ); 762 768 769 if( set_getbool( &ic->irc->set, "display_timestamps" ) && 770 ( ts = format_timestamp( irc, sent_at ) ) ) 771 { 772 char *new = g_strconcat( ts, msg, NULL ); 773 g_free( ts ); 774 ts = msg = new; 775 } 776 763 777 wrapped = word_wrap( msg, 425 ); 764 778 irc_msgfrom( irc, u->nick, wrapped ); 765 779 g_free( wrapped ); 780 g_free( ts ); 766 781 } 767 782 … … 805 820 806 821 return c; 822 } 823 824 void imcb_chat_name_hint( struct groupchat *c, const char *name ) 825 { 826 if( !c->joined ) 827 { 828 struct im_connection *ic = c->ic; 829 char stripped[MAX_NICK_LENGTH+1], *full_name; 830 831 strncpy( stripped, name, MAX_NICK_LENGTH ); 832 stripped[MAX_NICK_LENGTH] = '\0'; 833 nick_strip( stripped ); 834 if( set_getbool( &ic->irc->set, "lcnicks" ) ) 835 nick_lc( stripped ); 836 837 full_name = g_strdup_printf( "&%s", stripped ); 838 839 if( stripped[0] && 840 nick_cmp( stripped, ic->irc->channel + 1 ) != 0 && 841 irc_chat_by_channel( ic->irc, full_name ) == NULL ) 842 { 843 g_free( c->channel ); 844 c->channel = full_name; 845 } 846 else 847 { 848 g_free( full_name ); 849 } 850 } 807 851 } 808 852 … … 867 911 if( c && u ) 868 912 { 869 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); 913 char *ts = NULL; 914 if( set_getbool( &ic->irc->set, "display_timestamps" ) ) 915 ts = format_timestamp( ic->irc, sent_at ); 916 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped ); 917 g_free( ts ); 870 918 } 871 919 else … … 1061 1109 } 1062 1110 1063 1064 1111 char *set_eval_timezone( set_t *set, char *value ) 1112 { 1113 char *s; 1114 1115 if( strcmp( value, "local" ) == 0 || 1116 strcmp( value, "gmt" ) == 0 || strcmp( value, "utc" ) == 0 ) 1117 return value; 1118 1119 /* Otherwise: +/- at the beginning optional, then one or more numbers, 1120 possibly followed by a colon and more numbers. Don't bother bound- 1121 checking them since users are free to shoot themselves in the foot. */ 1122 s = value; 1123 if( *s == '+' || *s == '-' ) 1124 s ++; 1125 1126 /* \d+ */ 1127 if( !isdigit( *s ) ) 1128 return SET_INVALID; 1129 while( *s && isdigit( *s ) ) s ++; 1130 1131 /* EOS? */ 1132 if( *s == '\0' ) 1133 return value; 1134 1135 /* Otherwise, colon */ 1136 if( *s != ':' ) 1137 return SET_INVALID; 1138 s ++; 1139 1140 /* \d+ */ 1141 if( !isdigit( *s ) ) 1142 return SET_INVALID; 1143 while( *s && isdigit( *s ) ) s ++; 1144 1145 /* EOS */ 1146 return *s == '\0' ? value : SET_INVALID; 1147 } 1148 1149 static char *format_timestamp( irc_t *irc, time_t msg_ts ) 1150 { 1151 time_t now_ts = time( NULL ); 1152 struct tm now, msg; 1153 char *set; 1154 1155 /* If the timestamp is <= 0 or less than a minute ago, discard it as 1156 it doesn't seem to add to much useful info and/or might be noise. */ 1157 if( msg_ts <= 0 || msg_ts > now_ts - 60 ) 1158 return NULL; 1159 1160 set = set_getstr( &irc->set, "timezone" ); 1161 if( strcmp( set, "local" ) == 0 ) 1162 { 1163 localtime_r( &now_ts, &now ); 1164 localtime_r( &msg_ts, &msg ); 1165 } 1166 else 1167 { 1168 int hr, min = 0, sign = 60; 1169 1170 if( set[0] == '-' ) 1171 { 1172 sign *= -1; 1173 set ++; 1174 } 1175 else if( set[0] == '+' ) 1176 { 1177 set ++; 1178 } 1179 1180 if( sscanf( set, "%d:%d", &hr, &min ) >= 1 ) 1181 { 1182 msg_ts += sign * ( hr * 60 + min ); 1183 now_ts += sign * ( hr * 60 + min ); 1184 } 1185 1186 gmtime_r( &now_ts, &now ); 1187 gmtime_r( &msg_ts, &msg ); 1188 } 1189 1190 if( msg.tm_year == now.tm_year && msg.tm_yday == now.tm_yday ) 1191 return g_strdup_printf( "\x02[\x02\x02\x02%02d:%02d:%02d\x02]\x02 ", 1192 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1193 else 1194 return g_strdup_printf( "\x02[\x02\x02\x02%04d-%02d-%02d " 1195 "%02d:%02d:%02d\x02]\x02 ", 1196 msg.tm_year + 1900, msg.tm_mon, msg.tm_mday, 1197 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1198 } 1065 1199 1066 1200 /* The plan is to not allow straight calls to prpl functions anymore, but do … … 1105 1239 { 1106 1240 char *away, *msg = NULL; 1241 1242 if( ic->acc->prpl->away_states == NULL || 1243 ic->acc->prpl->set_away == NULL ) 1244 return 0; 1107 1245 1108 1246 away = set_getstr( &ic->acc->set, "away" ) ? -
protocols/nogaim.h
rbb839e8 refbc154 302 302 * user, too. */ 303 303 G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle ); 304 G_MODULE_EXPORT void imcb_chat_name_hint( struct groupchat *c, const char *name ); 304 305 G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, const char *handle ); 305 306 /* To remove a handle from a group chat. Reason can be NULL. */ … … 324 325 325 326 /* Misc. stuff */ 327 char *set_eval_timezone( set_t *set, char *value ); 326 328 char *set_eval_away_devoice( set_t *set, char *value ); 327 329 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ); -
storage_xml.c
rbb839e8 refbc154 496 496 goto write_error; 497 497 498 fsync( fd ); 498 499 close( fd ); 499 500 -
unix.c
rbb839e8 refbc154 73 73 74 74 i = bitlbee_inetd_init(); 75 log_message( LOGLVL_INFO, "Bitl bee %s starting in inetd mode.", BITLBEE_VERSION );75 log_message( LOGLVL_INFO, "BitlBee %s starting in inetd mode.", BITLBEE_VERSION ); 76 76 77 77 } 78 78 else if( global.conf->runmode == RUNMODE_DAEMON ) 79 79 { 80 log_link( LOGLVL_ERROR, LOGOUTPUT_ SYSLOG);81 log_link( LOGLVL_WARNING, LOGOUTPUT_ SYSLOG);80 log_link( LOGLVL_ERROR, LOGOUTPUT_CONSOLE ); 81 log_link( LOGLVL_WARNING, LOGOUTPUT_CONSOLE ); 82 82 83 83 i = bitlbee_daemon_init(); 84 log_message( LOGLVL_INFO, "Bitl bee %s starting in daemon mode.", BITLBEE_VERSION );84 log_message( LOGLVL_INFO, "BitlBee %s starting in daemon mode.", BITLBEE_VERSION ); 85 85 } 86 86 else if( global.conf->runmode == RUNMODE_FORKDAEMON ) 87 87 { 88 log_link( LOGLVL_ERROR, LOGOUTPUT_CONSOLE ); 89 log_link( LOGLVL_WARNING, LOGOUTPUT_CONSOLE ); 90 88 91 /* In case the operator requests a restart, we need this. */ 89 92 old_cwd = g_malloc( 256 ); … … 96 99 97 100 i = bitlbee_daemon_init(); 98 log_message( LOGLVL_INFO, "Bitl bee %s starting in forking daemon mode.", BITLBEE_VERSION );101 log_message( LOGLVL_INFO, "BitlBee %s starting in forking daemon mode.", BITLBEE_VERSION ); 99 102 } 100 103 if( i != 0 )
Note: See TracChangeset
for help on using the changeset viewer.