Changeset 3e57660
- Timestamp:
- 2010-04-07T03:59:01Z (15 years ago)
- Branches:
- master
- Children:
- 123cac7
- Parents:
- d4efddf
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/user-guide/commands.xml
rd4efddf r3e57660 839 839 </bitlbee-setting> 840 840 841 <bitlbee-setting name="timezone" type="string" scope="global"> 842 <default>local</default> 843 <possible-values>local, utc, gmt, timezone-spec</possible-values> 844 845 <description> 846 <para> 847 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. 848 </para> 849 850 <para> 851 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. 852 </para> 853 </description> 854 </bitlbee-setting> 855 841 856 <bitlbee-setting name="tls" type="boolean" scope="account"> 842 857 <default>try</default> -
irc.c
rd4efddf r3e57660 199 199 s->flags |= SET_NULL_OK; 200 200 s = set_add( &irc->set, "strip_html", "true", NULL, irc ); 201 s = set_add( &irc->set, "timezone", "local", set_eval_timezone, irc ); 201 202 s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc ); 202 203 s = set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc ); -
protocols/nogaim.c
rd4efddf r3e57660 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; … … 718 719 { 719 720 irc_t *irc = ic->irc; 720 char *wrapped ;721 char *wrapped, *ts; 721 722 user_t *u; 722 723 … … 760 761 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 761 762 strip_html( msg ); 762 763 764 if( ( ts = format_timestamp( irc, sent_at ) ) ) 765 { 766 char *new = g_strconcat( ts, msg, NULL ); 767 g_free( ts ); 768 ts = msg = new; 769 } 770 763 771 wrapped = word_wrap( msg, 425 ); 764 772 irc_msgfrom( irc, u->nick, wrapped ); 765 773 g_free( wrapped ); 774 g_free( ts ); 766 775 } 767 776 … … 867 876 if( c && u ) 868 877 { 869 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); 878 char *ts = format_timestamp( ic->irc, sent_at ); 879 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped ); 880 g_free( ts ); 870 881 } 871 882 else … … 1061 1072 } 1062 1073 1063 1064 1074 char *set_eval_timezone( set_t *set, char *value ) 1075 { 1076 char *s; 1077 1078 if( strcmp( value, "local" ) == 0 || 1079 strcmp( value, "gmt" ) == 0 || strcmp( value, "utc" ) == 0 ) 1080 return value; 1081 1082 /* Otherwise: +/- at the beginning optional, then one or more numbers, 1083 possibly followed by a colon and more numbers. Don't bother bound- 1084 checking them since users are free to shoot themselves in the foot. */ 1085 s = value; 1086 if( *s == '+' || *s == '-' ) 1087 s ++; 1088 1089 /* \d+ */ 1090 if( !isdigit( *s ) ) 1091 return SET_INVALID; 1092 while( *s && isdigit( *s ) ) s ++; 1093 1094 /* EOS? */ 1095 if( *s == '\0' ) 1096 return value; 1097 1098 /* Otherwise, colon */ 1099 if( *s != ':' ) 1100 return SET_INVALID; 1101 s ++; 1102 1103 /* \d+ */ 1104 if( !isdigit( *s ) ) 1105 return SET_INVALID; 1106 while( *s && isdigit( *s ) ) s ++; 1107 1108 /* EOS */ 1109 return *s == '\0' ? value : SET_INVALID; 1110 } 1111 1112 static char *format_timestamp( irc_t *irc, time_t msg_ts ) 1113 { 1114 time_t now_ts = time( NULL ); 1115 struct tm now, msg; 1116 char *set; 1117 1118 /* If the timestamp is <= 0 or less than a minute ago, discard it as 1119 it doesn't seem to add to much useful info and/or might be noise. */ 1120 if( msg_ts <= 0 || msg_ts > now_ts - 60 ) 1121 return NULL; 1122 1123 set = set_getstr( &irc->set, "timezone" ); 1124 if( strcmp( set, "local" ) == 0 ) 1125 { 1126 localtime_r( &now_ts, &now ); 1127 localtime_r( &msg_ts, &msg ); 1128 } 1129 else 1130 { 1131 int hr, min = 0, sign = 60; 1132 1133 if( set[0] == '-' ) 1134 { 1135 sign *= -1; 1136 set ++; 1137 } 1138 else if( set[0] == '+' ) 1139 { 1140 set ++; 1141 } 1142 1143 if( sscanf( set, "%d:%d", &hr, &min ) >= 1 ) 1144 { 1145 msg_ts += sign * ( hr * 60 + min ); 1146 now_ts += sign * ( hr * 60 + min ); 1147 } 1148 1149 gmtime_r( &now_ts, &now ); 1150 gmtime_r( &msg_ts, &msg ); 1151 } 1152 1153 if( msg.tm_year == now.tm_year && msg.tm_yday == now.tm_yday ) 1154 return g_strdup_printf( "\x02[\x02\x02\x02%02d:%02d:%02d\x02]\x02 ", 1155 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1156 else 1157 return g_strdup_printf( "\x02[\x02\x02\x02%04d-%02d-%02d " 1158 "%02d:%02d:%02d\x02]\x02 ", 1159 msg.tm_year + 1900, msg.tm_mon, msg.tm_mday, 1160 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1161 } 1065 1162 1066 1163 /* The plan is to not allow straight calls to prpl functions anymore, but do -
protocols/nogaim.h
rd4efddf r3e57660 324 324 325 325 /* Misc. stuff */ 326 char *set_eval_timezone( set_t *set, char *value ); 326 327 char *set_eval_away_devoice( set_t *set, char *value ); 327 328 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond );
Note: See TracChangeset
for help on using the changeset viewer.