Update of /cvsroot/mahogany/M/src/modules/spam
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31699/src/modules/spam

Modified Files:
        DspamFilter.cpp HeadersFilter.cpp 
Log Message:
added code to configure isspam() filter function argument

Index: DspamFilter.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/spam/DspamFilter.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -b -u -2 -r1.6 -r1.7
--- DspamFilter.cpp     11 Jul 2004 20:39:47 -0000      1.6
+++ DspamFilter.cpp     12 Jul 2004 00:33:38 -0000      1.7
@@ -35,6 +35,5 @@
 
 #include "SpamFilter.h"
-
-#include "gui/wxOptionsPage.h"
+#include "gui/SpamOptionsPage.h"
 
 extern "C"
@@ -105,5 +104,7 @@
                               String *result);
    virtual const wxChar *GetOptionPageIconName() const { return _T("dspam"); }
-   virtual wxOptionsPage *CreateOptionPage(wxListOrNoteBook *notebook) const;
+   virtual SpamOptionsPage *CreateOptionPage(wxListOrNoteBook *notebook,
+                                             Profile *profile,
+                                             String *params) const;
 
 private:
@@ -162,8 +163,9 @@
 // ----------------------------------------------------------------------------
 
-class DspamOptionsPage : public wxOptionsPageDynamic
+class DspamOptionsPage : public SpamOptionsPage
 {
 public:
    DspamOptionsPage(DspamFilter *filter,
+                    String *params,
                     wxNotebook *parent,
                     const wxChar *title,
@@ -173,18 +175,9 @@
                     size_t nFields,
                     int image = -1)
-      : wxOptionsPageDynamic
-        (
-            parent,
-            title,
-            profile,
-            aFields,
-            aDefaults,
-            nFields,
-            0,          // offset
-            -1,         // help id
-            image
-        )
+      : SpamOptionsPage(parent, profile, params)
    {
       m_filter = filter;
+
+      Create(parent, title, profile, aFields, aDefaults, nFields, 0, -1, image);
    }
 
@@ -448,5 +441,8 @@
 };
 
-wxOptionsPage *DspamFilter::CreateOptionPage(wxListOrNoteBook *notebook) const
+SpamOptionsPage *
+DspamFilter::CreateOptionPage(wxListOrNoteBook *notebook,
+                              Profile *profile,
+                              String *params) const
 {
    static const wxOptionsPage::FieldInfo s_fields[] =
@@ -503,7 +499,8 @@
               (
                   const_cast<DspamFilter *>(this),
+                  params,
                   notebook,
                   gettext_noop("DSPAM"),
-                  mApplication->GetProfile(),
+                  profile,
                   s_fields,
                   s_values,

Index: HeadersFilter.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/spam/HeadersFilter.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -b -u -2 -r1.6 -r1.7
--- HeadersFilter.cpp   11 Jul 2004 22:39:03 -0000      1.6
+++ HeadersFilter.cpp   12 Jul 2004 00:33:38 -0000      1.7
@@ -42,7 +42,6 @@
 #include "Address.h"
 
-#include "gui/wxOptionsPage.h"
-
 #include "SpamFilter.h"
+#include "gui/SpamOptionsPage.h"
 
 // ----------------------------------------------------------------------------
@@ -108,5 +107,7 @@
                               String *result);
    virtual const wxChar *GetOptionPageIconName() const { return _T("spam"); }
-   virtual wxOptionsPage *CreateOptionPage(wxListOrNoteBook *notebook) const;
+   virtual SpamOptionsPage *CreateOptionPage(wxListOrNoteBook *notebook,
+                                             Profile *profile,
+                                             String *params) const;
 
 
@@ -134,5 +135,5 @@
 public:
    /// Is it on or off by default?
-   virtual bool DefaultValue() const = 0;
+   virtual bool GetDefaultValue() const = 0;
 
    /// The token used in spam filter string for this option
@@ -140,5 +141,5 @@
 
    /// The name of the profile entry used to pass the value to config dialog
-   virtual const wxChar *TempProfileEntryName() const = 0;
+   virtual const wxChar *GetProfileName() const = 0;
 
    /// The label of the correponding checkbox in the dialog
@@ -167,8 +168,8 @@
 {
 public:
-   virtual bool DefaultValue() const { return true; }
+   virtual bool GetDefaultValue() const { return true; }
    virtual const wxChar *Token() const
       { return SPAM_TEST_SPAMASSASSIN; }
-   virtual const wxChar *TempProfileEntryName() const
+   virtual const wxChar *GetProfileName() const
       { return _T("SpamAssassin"); }
    virtual const wxChar *DialogLabel() const
@@ -180,8 +181,8 @@
 {
 public:
-   virtual bool DefaultValue() const { return true; }
+   virtual bool GetDefaultValue() const { return true; }
    virtual const wxChar *Token() const
       { return SPAM_TEST_SUBJ8BIT; }
-   virtual const wxChar *TempProfileEntryName() const
+   virtual const wxChar *GetProfileName() const
       { return _T("Spam8BitSubject"); }
    virtual const wxChar *DialogLabel() const
@@ -193,8 +194,8 @@
 {
 public:
-   virtual bool DefaultValue() const { return true; }
+   virtual bool GetDefaultValue() const { return true; }
    virtual const wxChar *Token() const
       { return SPAM_TEST_SUBJCAPS; }
-   virtual const wxChar *TempProfileEntryName() const
+   virtual const wxChar *GetProfileName() const
       { return _T("SpamCapsSubject"); }
    virtual const wxChar *DialogLabel() const
@@ -206,9 +207,9 @@
 {
 public:
-   virtual bool DefaultValue() const { return true; }
+   virtual bool GetDefaultValue() const { return true; }
    virtual const wxChar *Token() const
       { return SPAM_TEST_SUBJENDJUNK; }
-   virtual const wxChar *TempProfileEntryName() const
-      { return _T("JunkEndSubject"); }
+   virtual const wxChar *GetProfileName() const
+      { return _T("SpamJunkEndSubject"); }
    virtual const wxChar *DialogLabel() const
       { return gettext_noop("&Junk at end of subject"); }
@@ -219,8 +220,8 @@
 {
 public:
-   virtual bool DefaultValue() const { return true; }
+   virtual bool GetDefaultValue() const { return true; }
    virtual const wxChar *Token() const
       { return SPAM_TEST_KOREAN; }
-   virtual const wxChar *TempProfileEntryName() const
+   virtual const wxChar *GetProfileName() const
       { return _T("SpamKoreanCharset"); }
    virtual const wxChar *DialogLabel() const
@@ -231,8 +232,8 @@
 {
 public:
-   virtual bool DefaultValue() const { return true; }
+   virtual bool GetDefaultValue() const { return true; }
    virtual const wxChar *Token() const
       { return SPAM_TEST_EXECUTABLE_ATTACHMENT; }
-   virtual const wxChar *TempProfileEntryName() const
+   virtual const wxChar *GetProfileName() const
       { return _T("SpamExeAttachment"); }
    virtual const wxChar *DialogLabel() const
@@ -256,8 +257,8 @@
 {
 public:
-   virtual bool DefaultValue() const { return false; }
+   virtual bool GetDefaultValue() const { return false; }
    virtual const wxChar *Token() const
       { return SPAM_TEST_XAUTHWARN; }
-   virtual const wxChar *TempProfileEntryName() const
+   virtual const wxChar *GetProfileName() const
       { return _T("SpamXAuthWarning"); }
    virtual const wxChar *DialogLabel() const
@@ -269,8 +270,8 @@
 {
 public:
-   virtual bool DefaultValue() const { return false; }
+   virtual bool GetDefaultValue() const { return false; }
    virtual const wxChar *Token() const
       { return SPAM_TEST_RECEIVED; }
-   virtual const wxChar *TempProfileEntryName() const
+   virtual const wxChar *GetProfileName() const
       { return _T("SpamReceived"); }
    virtual const wxChar *DialogLabel() const
@@ -282,8 +283,8 @@
 {
 public:
-   virtual bool DefaultValue() const { return false; }
+   virtual bool GetDefaultValue() const { return false; }
    virtual const wxChar *Token() const
       { return SPAM_TEST_HTML; }
-   virtual const wxChar *TempProfileEntryName() const
+   virtual const wxChar *GetProfileName() const
       { return _T("SpamHtml"); }
    virtual const wxChar *DialogLabel() const
@@ -295,8 +296,8 @@
 {
 public:
-   virtual bool DefaultValue() const { return false; }
+   virtual bool GetDefaultValue() const { return false; }
    virtual const wxChar *Token() const
       { return SPAM_TEST_MIME; }
-   virtual const wxChar *TempProfileEntryName() const
+   virtual const wxChar *GetProfileName() const
       { return _T("SpamMime"); }
    virtual const wxChar *DialogLabel() const
@@ -308,8 +309,8 @@
 {
 public:
-   virtual bool DefaultValue() const { return false; }
+   virtual bool GetDefaultValue() const { return false; }
    virtual const wxChar *Token() const
       { return SPAM_TEST_WHITE_LIST; }
-   virtual const wxChar *TempProfileEntryName() const
+   virtual const wxChar *GetProfileName() const
       { return _T("SpameWhiteList"); }
    virtual const wxChar *DialogLabel() const
@@ -323,8 +324,8 @@
 {
 public:
-   virtual bool DefaultValue() const { return false; }
+   virtual bool GetDefaultValue() const { return false; }
    virtual const wxChar *Token() const
       { return SPAM_TEST_RBL; }
-   virtual const wxChar *TempProfileEntryName() const
+   virtual const wxChar *GetProfileName() const
       { return _T("SpamIsInRBL"); }
    virtual const wxChar *DialogLabel() const
@@ -338,14 +339,13 @@
 // ----------------------------------------------------------------------------
 
-class HeadersOptionsPage : public wxOptionsPageDynamic
+class HeadersOptionsPage : public SpamOptionsPage
 {
 public:
-   HeadersOptionsPage(wxListOrNoteBook *notebook);
-
-   virtual void FromString(const String &source);
-   virtual String ToString();
+   HeadersOptionsPage(wxListOrNoteBook *notebook,
+                      Profile *profile,
+                      String *params);
 
-   virtual bool TransferDataToWindow();
-   virtual bool TransferDataFromWindow();
+   void FromString(const String &source);
+   String ToString();
 
 private:
@@ -356,7 +356,6 @@
    void SetFalse();
 
-   void WriteProfile(Profile *profile);
-   void ReadProfile(Profile *profile);
-   void DeleteProfile(Profile *profile);
+   void WriteParamsToProfile();
+   void ReadParamsFromProfile();
 
    size_t GetConfigEntryCount();
@@ -1437,8 +1436,10 @@
 // ----------------------------------------------------------------------------
 
-wxOptionsPage *
-HeadersFilter::CreateOptionPage(wxListOrNoteBook *notebook) const
+SpamOptionsPage *
+HeadersFilter::CreateOptionPage(wxListOrNoteBook *notebook,
+                                Profile *profile,
+                                String *params) const
 {
-   return new HeadersOptionsPage(notebook);
+   return new HeadersOptionsPage(notebook, profile, params);
 }
 
@@ -1469,6 +1470,8 @@
 
 
-HeadersOptionsPage::HeadersOptionsPage(wxListOrNoteBook *notebook)
-                  : wxOptionsPageDynamic(notebook)
+HeadersOptionsPage::HeadersOptionsPage(wxListOrNoteBook *notebook,
+                                       Profile *profile,
+                                       String *params)
+                  : SpamOptionsPage(notebook, profile, params)
 {
    m_nEntries = 0;
@@ -1478,5 +1481,5 @@
       notebook,
       gettext_noop("Headers filter"),
-      mApplication->GetProfile(),
+      profile,
       GetFieldInfo(),
       GetConfigValues(),
@@ -1488,22 +1491,4 @@
 }
 
-bool HeadersOptionsPage::TransferDataToWindow()
-{
-   WriteProfile(mApplication->GetProfile());
-
-   return wxOptionsPageDynamic::TransferDataToWindow();
-}
-
-bool HeadersOptionsPage::TransferDataFromWindow()
-{
-   bool rc = wxOptionsPageDynamic::TransferDataFromWindow();
-   if ( rc )
-      ReadProfile(mApplication->GetProfile());
-
-   DeleteProfile(mApplication->GetProfile());
-
-   return rc;
-}
-
 size_t HeadersOptionsPage::GetConfigEntryCount()
 {
@@ -1529,5 +1514,5 @@
    for ( HeadersOptionsPage::Iterator option(this); !option.IsEnd(); ++option )
    {
-      option->m_active = option->DefaultValue();
+      option->m_active = option->GetDefaultValue();
    }
 }
@@ -1595,28 +1580,29 @@
 }
 
-void HeadersOptionsPage::WriteProfile(Profile *profile)
+void HeadersOptionsPage::WriteParamsToProfile()
 {
-   for ( HeadersOptionsPage::Iterator option(this);
-      !option.IsEnd(); ++option )
-   {
-      profile->writeEntry(option->TempProfileEntryName(), option->m_active);
-   }
-}
+   CHECK_RET( m_params,
+              _T("WriteParamsToProfile() shouldn't be called without params") );
+
+   FromString(*m_params);
 
-void HeadersOptionsPage::ReadProfile(Profile *profile)
-{
    for ( HeadersOptionsPage::Iterator option(this); !option.IsEnd(); ++option )
    {
-      option->m_active = profile->readEntry(
-         option->TempProfileEntryName(), 0l) != 0l;
+      m_profile->writeEntry(option->GetProfileName(), option->m_active);
    }
 }
 
-void HeadersOptionsPage::DeleteProfile(Profile *profile)
+void HeadersOptionsPage::ReadParamsFromProfile()
 {
+   CHECK_RET( m_params,
+              _T("ReadParamsFromProfile() shouldn't be called without params") );
+
    for ( HeadersOptionsPage::Iterator option(this); !option.IsEnd(); ++option )
    {
-      profile->DeleteEntry(option->TempProfileEntryName());
+      option->m_active =
+         m_profile->readEntry(option->GetProfileName(), 0l) != 0l;
    }
+
+   *m_params = ToString();
 }
 
@@ -1633,6 +1619,6 @@
       value = ConfigValueDefault
               (
-                  option->TempProfileEntryName(),
-                  option->DefaultValue()
+                  option->GetProfileName(),
+                  option->GetDefaultValue()
               );
       n += option->GetEntriesCount();



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to