1 /* 2 * Copyright 2002-2013, Haiku, Inc. All rights reserved. 3 * Copyright 2002 Alexander G. M. Smith. 4 * Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de> 5 * Distributed under the terms of the MIT License. 6 */ 7 #ifndef SPAM_FILTER_H 8 #define SPAM_FILTER_H 9 10 11 #include <MailFilter.h> 12 #include <Messenger.h> 13 14 15 class SpamFilter : public BMailFilter { 16 public: 17 SpamFilter(BMailProtocol& protocol, 18 const BMailAddOnSettings& settings); 19 virtual ~SpamFilter(); 20 21 virtual BMailFilterAction HeaderFetched(entry_ref& ref, BFile& file, 22 BMessage& attributes); 23 virtual void BodyFetched(const entry_ref& ref, BFile& file, 24 BMessage& attributes); 25 26 private: 27 status_t _CheckForSpam(BFile& file); 28 //! If the server is not running start it 29 status_t _CheckForSpamServer(); 30 status_t _GetTokenizeMode(); 31 status_t _GetSpamRatio(const char* data, off_t dataSize, 32 float& ratio); 33 status_t _TrainServer(const char* data, off_t dataSize, 34 float spamRatio); 35 status_t _AddSpamToSubject(BNode& file, float spamRatio); 36 37 private: 38 bool fAddSpamToSubject; 39 bool fAutoTraining; 40 float fGenuineCutoffRatio; 41 bool fHeaderOnly; 42 int fLaunchAttemptCount; 43 BMessenger fMessengerToServer; 44 bool fNoWordsMeansSpam; 45 bool fQuitServerWhenFinished; 46 float fSpamCutoffRatio; 47 }; 48 49 50 #endif // SPAM_FILTER_H 51