Changes in protocols/nogaim.c [449a51d:cca0692]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
r449a51d rcca0692 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" ) ?
Note: See TracChangeset
for help on using the changeset viewer.