Changeset ae3dc99 for protocols/nogaim.c
- Timestamp:
- 2010-04-24T17:02:07Z (14 years ago)
- Branches:
- master
- Children:
- c521362
- Parents:
- b5b40ff (diff), f1b7711 (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
rb5b40ff rae3dc99 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; … … 135 136 extern void byahoo_initmodule(); 136 137 extern void jabber_initmodule(); 138 extern void twitter_initmodule(); 137 139 extern void purple_initmodule(); 138 140 … … 151 153 #ifdef WITH_JABBER 152 154 jabber_initmodule(); 155 #endif 156 157 #ifdef WITH_TWITTER 158 twitter_initmodule(); 153 159 #endif 154 160 … … 726 732 { 727 733 irc_t *irc = ic->irc; 728 char *wrapped ;734 char *wrapped, *ts = NULL; 729 735 user_t *u; 730 736 … … 768 774 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 769 775 strip_html( msg ); 770 776 777 if( set_getbool( &ic->irc->set, "display_timestamps" ) && 778 ( ts = format_timestamp( irc, sent_at ) ) ) 779 { 780 char *new = g_strconcat( ts, msg, NULL ); 781 g_free( ts ); 782 ts = msg = new; 783 } 784 771 785 wrapped = word_wrap( msg, 425 ); 772 786 irc_msgfrom( irc, u->nick, wrapped ); 773 787 g_free( wrapped ); 788 g_free( ts ); 774 789 } 775 790 … … 813 828 814 829 return c; 830 } 831 832 void imcb_chat_name_hint( struct groupchat *c, const char *name ) 833 { 834 if( !c->joined ) 835 { 836 struct im_connection *ic = c->ic; 837 char stripped[MAX_NICK_LENGTH+1], *full_name; 838 839 strncpy( stripped, name, MAX_NICK_LENGTH ); 840 stripped[MAX_NICK_LENGTH] = '\0'; 841 nick_strip( stripped ); 842 if( set_getbool( &ic->irc->set, "lcnicks" ) ) 843 nick_lc( stripped ); 844 845 full_name = g_strdup_printf( "&%s", stripped ); 846 847 if( stripped[0] && 848 nick_cmp( stripped, ic->irc->channel + 1 ) != 0 && 849 irc_chat_by_channel( ic->irc, full_name ) == NULL ) 850 { 851 g_free( c->channel ); 852 c->channel = full_name; 853 } 854 else 855 { 856 g_free( full_name ); 857 } 858 } 815 859 } 816 860 … … 875 919 if( c && u ) 876 920 { 877 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); 921 char *ts = NULL; 922 if( set_getbool( &ic->irc->set, "display_timestamps" ) ) 923 ts = format_timestamp( ic->irc, sent_at ); 924 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped ); 925 g_free( ts ); 878 926 } 879 927 else … … 1069 1117 } 1070 1118 1071 1072 1119 char *set_eval_timezone( set_t *set, char *value ) 1120 { 1121 char *s; 1122 1123 if( strcmp( value, "local" ) == 0 || 1124 strcmp( value, "gmt" ) == 0 || strcmp( value, "utc" ) == 0 ) 1125 return value; 1126 1127 /* Otherwise: +/- at the beginning optional, then one or more numbers, 1128 possibly followed by a colon and more numbers. Don't bother bound- 1129 checking them since users are free to shoot themselves in the foot. */ 1130 s = value; 1131 if( *s == '+' || *s == '-' ) 1132 s ++; 1133 1134 /* \d+ */ 1135 if( !isdigit( *s ) ) 1136 return SET_INVALID; 1137 while( *s && isdigit( *s ) ) s ++; 1138 1139 /* EOS? */ 1140 if( *s == '\0' ) 1141 return value; 1142 1143 /* Otherwise, colon */ 1144 if( *s != ':' ) 1145 return SET_INVALID; 1146 s ++; 1147 1148 /* \d+ */ 1149 if( !isdigit( *s ) ) 1150 return SET_INVALID; 1151 while( *s && isdigit( *s ) ) s ++; 1152 1153 /* EOS */ 1154 return *s == '\0' ? value : SET_INVALID; 1155 } 1156 1157 static char *format_timestamp( irc_t *irc, time_t msg_ts ) 1158 { 1159 time_t now_ts = time( NULL ); 1160 struct tm now, msg; 1161 char *set; 1162 1163 /* If the timestamp is <= 0 or less than a minute ago, discard it as 1164 it doesn't seem to add to much useful info and/or might be noise. */ 1165 if( msg_ts <= 0 || msg_ts > now_ts - 60 ) 1166 return NULL; 1167 1168 set = set_getstr( &irc->set, "timezone" ); 1169 if( strcmp( set, "local" ) == 0 ) 1170 { 1171 localtime_r( &now_ts, &now ); 1172 localtime_r( &msg_ts, &msg ); 1173 } 1174 else 1175 { 1176 int hr, min = 0, sign = 60; 1177 1178 if( set[0] == '-' ) 1179 { 1180 sign *= -1; 1181 set ++; 1182 } 1183 else if( set[0] == '+' ) 1184 { 1185 set ++; 1186 } 1187 1188 if( sscanf( set, "%d:%d", &hr, &min ) >= 1 ) 1189 { 1190 msg_ts += sign * ( hr * 60 + min ); 1191 now_ts += sign * ( hr * 60 + min ); 1192 } 1193 1194 gmtime_r( &now_ts, &now ); 1195 gmtime_r( &msg_ts, &msg ); 1196 } 1197 1198 if( msg.tm_year == now.tm_year && msg.tm_yday == now.tm_yday ) 1199 return g_strdup_printf( "\x02[\x02\x02\x02%02d:%02d:%02d\x02]\x02 ", 1200 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1201 else 1202 return g_strdup_printf( "\x02[\x02\x02\x02%04d-%02d-%02d " 1203 "%02d:%02d:%02d\x02]\x02 ", 1204 msg.tm_year + 1900, msg.tm_mon, msg.tm_mday, 1205 msg.tm_hour, msg.tm_min, msg.tm_sec ); 1206 } 1073 1207 1074 1208 /* The plan is to not allow straight calls to prpl functions anymore, but do … … 1113 1247 { 1114 1248 char *away, *msg = NULL; 1249 1250 if( ic->acc->prpl->away_states == NULL || 1251 ic->acc->prpl->set_away == NULL ) 1252 return 0; 1115 1253 1116 1254 away = set_getstr( &ic->acc->set, "away" ) ?
Note: See TracChangeset
for help on using the changeset viewer.