--------------------------------------------------------------------------- return false if message p should be ignored
| 1205 | //--------------------------------------------------------------------------- |
| 1206 | // return false if message p should be ignored |
| 1207 | bool ProcessMessageRules(TSyslogMessage * p) |
| 1208 | { |
| 1209 | bool rv = true; |
| 1210 | TMessProcessRule * pr; |
| 1211 | for(int i=0; i<ProcessRules->Count; i++) |
| 1212 | { |
| 1213 | pr = ProcessRules->Get(i); |
| 1214 | if( ! pr->bEnable ) |
| 1215 | continue; |
| 1216 | if( ! pr->Match.Match(p) ) |
| 1217 | continue; |
| 1218 | |
| 1219 | if( pr->Process.bIgnore ) |
| 1220 | { |
| 1221 | rv = false; |
| 1222 | } |
| 1223 | if( pr->Process.bAlarm ) |
| 1224 | { |
| 1225 | AlarmShow(p->Format(pr->Process.AlarmMess)); |
| 1226 | } |
| 1227 | if( pr->Process.bSound ) |
| 1228 | { |
| 1229 | TalkingThread->Play(pr->Process.GetSoundFileName(), pr->Process.PlayCount); |
| 1230 | } |
| 1231 | if( pr->Process.bSendMail ) |
| 1232 | { |
| 1233 | TLetter l; |
| 1234 | l = MainCfg.Letter; |
| 1235 | if( pr->Process.Recipient.Length() > 0 ) |
| 1236 | l.recipient = pr->Process.Recipient; |
| 1237 | l.subject = p->Format(l.subject); |
| 1238 | l.message = p->Format(l.message); |
| 1239 | l.callback = OnReceiveMail; |
| 1240 | TSendmailThread::Send(&l); |
| 1241 | } |
| 1242 | if( pr->Process.bRunProg ) |
| 1243 | { |
| 1244 | DWORD LastError; |
| 1245 | String cmd = p->Format(pr->Process.ProgFile); |
| 1246 | if( ! RunProg(cmd.c_str(), |
| 1247 | pr->Process.bProgHide ? SW_HIDE : SW_SHOWNORMAL, |
| 1248 | false, &LastError) ) |
| 1249 | WriteToLogError("ERROR\tRun program %s: %s", |
| 1250 | cmd.c_str(), FormatLastError2(LastError).c_str()); |
| 1251 | } |
| 1252 | if( pr->Process.bSaveToFile ) |
| 1253 | { |
| 1254 | TStorageFile * sf = fdb->GetByNumber( pr->Process.SaveFile ); |
| 1255 | if( sf ) |
| 1256 | { |
| 1257 | String f = sf->GetFileName(); |
| 1258 | if( ! sf->Save( p->ToString() ) ) |
| 1259 | WriteToLogError("ERROR\tSave message to file: %s", f.c_str()); |
| 1260 | } |
| 1261 | } |
| 1262 | } |
| 1263 | return rv; |
| 1264 | } |
no test coverage detected