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

Modified Files:
        DspamFilter.cpp 
Log Message:
updated to compile with dspam 3.2

Index: DspamFilter.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/spam/DspamFilter.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -b -u -2 -r1.11 -r1.12
--- DspamFilter.cpp     7 Sep 2004 21:51:29 -0000       1.11
+++ DspamFilter.cpp     2 Oct 2004 16:32:44 -0000       1.12
@@ -40,25 +40,14 @@
 {
    #include <libdspam.h>
-
-   extern void dspam_set_home(const char *home);
 }
 
 // ----------------------------------------------------------------------------
-// constants
-// ----------------------------------------------------------------------------
-
-// currently we always use the same user name...
-static const char *M_DSPAM_USER = "mahogany";
-
-// ----------------------------------------------------------------------------
-// DspamCtx simple wrapper around DSPAM_CTX
+// wrappers around DSPAM_CTX
 // ----------------------------------------------------------------------------
 
+// base class used by DspamProcess/ClassifyCtx
 class DspamCtx
 {
 public:
-   // take ownership of the specified context
-   DspamCtx(DSPAM_CTX *ctx) : m_ctx(ctx) { }
-
    // destroy the context
    ~DspamCtx()
@@ -74,4 +63,17 @@
    DSPAM_CTX *operator->() const { return m_ctx; }
 
+protected:
+   // take ownership of the specified context
+   DspamCtx(DSPAM_CTX *ctx) : m_ctx(ctx) { }
+
+   // currently we always use the same user name...
+   static const char *GetUser() { return "mahogany"; }
+
+   // return the base dir for dspam files
+   static wxCharBuffer GetHome()
+   {
+      return mApplication->GetLocalDir().ToAscii();
+   }
+
 private:
    DSPAM_CTX *m_ctx;
@@ -80,4 +82,37 @@
 };
 
+// normal DSPAM context
+class DspamProcessCtx : public DspamCtx
+{
+public:
+   DspamProcessCtx()
+      :  DspamCtx(dspam_init
+                  (
+                     GetUser(),
+                     NULL,             // no group
+                     GetHome(),
+                     DSM_PROCESS,
+                     DSF_CHAINED |
+                     DSF_NOISE |
+                     DSF_WHITELIST
+                  ))
+   {
+   }
+
+   DECLARE_NO_COPY_CLASS(DspamProcessCtx);
+};
+
+// context for classification only
+class DspamClassifyCtx : public DspamCtx
+{
+public:
+   DspamClassifyCtx()
+      : DspamCtx(dspam_init(GetUser(), NULL, GetHome(), DSM_CLASSIFY, 0))
+   {
+   }
+
+   DECLARE_NO_COPY_CLASS(DspamClassifyCtx);
+};
+
 // ----------------------------------------------------------------------------
 // DspamFilter class
@@ -213,6 +248,4 @@
 DspamFilter::DspamFilter()
 {
-   dspam_set_home(mApplication->GetLocalDir());
-
    dspam_init_driver();
 
@@ -229,12 +262,5 @@
    if ( !m_ctx )
    {
-      const_cast<DspamFilter *>(this)->
-         m_ctx = new DspamCtx(dspam_init
-                              (
-                                 M_DSPAM_USER,
-                                 NULL,
-                                 DSM_PROCESS,
-                                 DSF_CHAINED | DSF_NOISE
-                              ));
+      const_cast<DspamFilter *>(this)->m_ctx = new DspamProcessCtx();
    }
 
@@ -252,13 +278,7 @@
 {
 #if 0
-   DSPAM_CTX *ctx = GetCtx();
+   DSPAM_CTX& ctx = *GetCtx();
 #else
-   DspamCtx ctx(dspam_init
-                (
-                  M_DSPAM_USER,
-                  NULL,
-                  DSM_PROCESS,
-                  DSF_CHAINED | DSF_NOISE
-                ));
+   DspamProcessCtx ctx;
 #endif
    if ( !ctx )
@@ -348,5 +368,5 @@
 void DspamFilter::ShowStats(wxWindow *parent)
 {
-   DspamCtx ctx(dspam_init(M_DSPAM_USER, NULL, DSM_CLASSIFY, 0));
+   DspamClassifyCtx ctx;
 
    if ( !ctx )



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to