Changes in protocols/nogaim.c [cca0692:449a51d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
rcca0692 r449a51d 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 );42 41 43 42 GSList *connections; … … 133 132 extern void byahoo_initmodule(); 134 133 extern void jabber_initmodule(); 135 extern void twitter_initmodule();136 134 137 135 #ifdef WITH_MSN … … 149 147 #ifdef WITH_JABBER 150 148 jabber_initmodule(); 151 #endif152 153 #ifdef WITH_TWITTER154 twitter_initmodule();155 149 #endif 156 150 … … 724 718 { 725 719 irc_t *irc = ic->irc; 726 char *wrapped , *ts = NULL;720 char *wrapped; 727 721 user_t *u; 728 722 … … 766 760 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 767 761 strip_html( msg ); 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 762 777 763 wrapped = word_wrap( msg, 425 ); 778 764 irc_msgfrom( irc, u->nick, wrapped ); 779 765 g_free( wrapped ); 780 g_free( ts );781 766 } 782 767 … … 820 805 821 806 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 else847 {848 g_free( full_name );849 }850 }851 807 } 852 808 … … 911 867 if( c && u ) 912 868 { 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 ); 869 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); 918 870 } 919 871 else … … 1109 1061 } 1110 1062 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 } 1063 1064 1199 1065 1200 1066 /* The plan is to not allow straight calls to prpl functions anymore, but do … … 1239 1105 { 1240 1106 char *away, *msg = NULL; 1241 1242 if( ic->acc->prpl->away_states == NULL ||1243 ic->acc->prpl->set_away == NULL )1244 return 0;1245 1107 1246 1108 away = set_getstr( &ic->acc->set, "away" ) ?
Note: See TracChangeset
for help on using the changeset viewer.