Changeset 814aa52 for protocols/nogaim.c
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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" ) ?
Note: See TracChangeset
for help on using the changeset viewer.