Update of /cvsroot/mahogany/M/src/gui
In directory usw-pr-cvs1:/tmp/cvs-serv25047/src/gui
Modified Files:
wxDialogLayout.cpp wxFiltersDialog.cpp wxHeadersDialogs.cpp
wxMDialogs.cpp wxMFrame.cpp wxMsgCmdProc.cpp wxOptionsDlg.cpp
Log Message:
added a dialog to configure the spam detection options and a test for ks_c_5601 charset
Index: wxDialogLayout.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxDialogLayout.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -b -u -2 -r1.86 -r1.87
--- wxDialogLayout.cpp 15 Jun 2002 22:18:03 -0000 1.86
+++ wxDialogLayout.cpp 20 Jun 2002 18:12:11 -0000 1.87
@@ -1304,5 +1304,5 @@
}
- EndModal(TRUE);
+ EndModal(wxID_OK);
}
//else: test done from DoApply() failed, don't close the dialog
@@ -1372,5 +1372,5 @@
}
- EndModal(FALSE);
+ EndModal(wxID_CANCEL);
}
Index: wxFiltersDialog.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxFiltersDialog.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -b -u -2 -r1.86 -r1.87
--- wxFiltersDialog.cpp 18 Jun 2002 14:48:12 -0000 1.86
+++ wxFiltersDialog.cpp 20 Jun 2002 18:12:12 -0000 1.87
@@ -58,4 +58,6 @@
#include "gui/wxDialogLayout.h"
#include "gui/wxFiltersDialog.h"
+#include "gui/wxOptionsPage.h"
+#include "gui/wxOptionsDlg.h"
#include "gui/wxSelectionDlg.h"
@@ -82,4 +84,7 @@
Button_Copy,
+ Button_MoreTests,
+ Button_LessTests,
+
// for wxOneFilterDialog
Text_Program = 200
@@ -113,5 +118,4 @@
gettext_noop("Score below"),
gettext_noop("Sent to me"),
- gettext_noop("Has 8 bit subject"),
};
@@ -203,12 +207,15 @@
bool HasChanges() const { return !(*m_FilterData == m_OriginalFilterData);}
+ // update the program text from the controls values
+ void UpdateProgram();
+
// event handlers
void OnUpdateUI(wxUpdateUIEvent& event);
- void OnButton(wxCommandEvent& event);
+ void OnButtonMoreOrLess(wxCommandEvent& event);
void OnProgramTextUpdate(wxCommandEvent& event);
void OnText(wxCommandEvent& event);
- void OnChoice(wxCommandEvent& event) { UpdateProgram(event); }
- void OnCheckBox(wxCommandEvent& event) { UpdateProgram(event); }
+ void OnChoice(wxCommandEvent& event) { UpdateProgram(); }
+ void OnCheckBox(wxCommandEvent& event) { UpdateProgram(); }
protected:
@@ -221,7 +228,4 @@
bool DoTransferDataFromWindow(MFilterDesc *filterData);
- // update the program text from the controls values
- void UpdateProgram(wxCommandEvent& event);
-
// true if we have a simple (expressed with dialog controls) filter
bool m_isSimple;
@@ -254,12 +258,17 @@
private:
+ DECLARE_DYNAMIC_CLASS(wxOneFilterDialog)
DECLARE_EVENT_TABLE()
};
+// abstract because we don't want to create it via wxRTTI
+IMPLEMENT_ABSTRACT_CLASS(wxOneFilterDialog, wxManuallyLaidOutDialog)
+
BEGIN_EVENT_TABLE(wxOneFilterDialog, wxManuallyLaidOutDialog)
EVT_UPDATE_UI(-1, wxOneFilterDialog::OnUpdateUI)
// More/Less button
- EVT_BUTTON(-1, wxOneFilterDialog::OnButton)
+ EVT_BUTTON(Button_MoreTests, wxOneFilterDialog::OnButtonMoreOrLess)
+ EVT_BUTTON(Button_LessTests, wxOneFilterDialog::OnButtonMoreOrLess)
// changes to the program text
@@ -273,4 +282,30 @@
// ----------------------------------------------------------------------------
+// CritDetailsButton: a helper button used by OneCritControl
+// ----------------------------------------------------------------------------
+
+class CritDetailsButton : public wxButton
+{
+public:
+ CritDetailsButton(wxWindow *parent, OneCritControl *ctrl)
+ : wxButton(parent, -1, _("Configure &details..."))
+ {
+ m_ctrl = ctrl;
+ }
+
+protected:
+ void OnClick(wxCommandEvent& event);
+
+private:
+ OneCritControl *m_ctrl;
+
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(CritDetailsButton, wxButton)
+ EVT_BUTTON(-1, CritDetailsButton::OnClick)
+END_EVENT_TABLE()
+
+// ----------------------------------------------------------------------------
// OneCritControl: a control handling one criterium from MFDialogSettings
// ----------------------------------------------------------------------------
@@ -310,17 +345,16 @@
String GetArgument() const
{
- return m_Argument->GetValue();
+ return GetTest() == ORC_T_IsSpam ? GetSpamTestArgument()
+ : m_Argument->GetValue();
}
+ // enable the controls corresponding to the current m_Type value
void UpdateUI();
- void Disable()
- {
- m_Not->Disable();
- m_Type->Disable();
- m_Argument->Disable();
- m_Where->Disable();
- if ( m_Logical )
- m_Logical->Disable();
- }
+
+ // show the details dialog: called by CritDetailsButton::OnClick()
+ void ShowDetails();
+
+ // disable all the controls
+ void Disable();
/// layout the current controls under the window *last
@@ -329,24 +363,54 @@
private:
- wxCheckBox *m_Not; // Not
- wxChoice *m_Type; // "Match", "Match substring", "Match RegExp",
- // "Greater than", "Smaller than", "Older than"; "Newer than"
+ // create the spam button and position it correctly
+ void CreateSpamButton();
+
+ // initialize m_checkXXX vars(called from CreateSpamButton())
+ void InitSpamOptions();
+
+ // return the string containing the argument for the isspam() test
+ String GetSpamTestArgument() const;
+
+ // the controls which are always shown
+
+ wxCheckBox *m_Not; // invert the condition if checked
+ wxChoice *m_Logical; // corresponds to ORC_Logical
+ wxChoice *m_Type; // corresponds to ORC_Types
+
+ // the controls which are shown for most of ORC_T_XXX values
wxTextCtrl *m_Argument; // string, number of days or bytes
- wxChoice *m_Where; // "In Header", "In Subject", "In From..."
- wxChoice *m_Logical;
+ wxChoice *m_Where; // corresponds to ORC_Where
- wxWindow *m_Parent; // the parent for all these controls
+ // special controls
+ wxButton *m_btnSpam; // configure the ORC_T_IsSpam test
+
+ // the parent for all these controls
+ wxWindow *m_Parent;
+
+
+ // the spam test data
+ bool m_check8bit:1;
+ bool m_checkKorean:1;
+ bool m_checkXAuthWarn:1;
+#ifdef USE_RBL
+ bool m_checkRBL:1;
+#endif // USE_RBL
};
+wxCOMPILE_TIME_ASSERT( ORC_LogicalCount == ORC_L_Max, MismatchInLogicOps );
+wxCOMPILE_TIME_ASSERT( ORC_TypesCount == ORC_T_Max, MismatchInTestTypes );
+wxCOMPILE_TIME_ASSERT( ORC_WhereCount == ORC_W_Max, MismatchInTargets );
+
OneCritControl::OneCritControl(wxWindow *parent, OneCritControl *previous)
{
m_Parent = parent;
+ // don't create it yet as it might be not needed at all, so postpone it
+ m_btnSpam = NULL;
+
// only create the logical condition (And/Or) control if we have something
// to combine this one with
if ( previous )
{
- wxASSERT_MSG( ORC_LogicalCount == ORC_L_Max, "forgot to update something" );
-
m_Logical = new wxChoice(parent, -1, wxDefaultPosition,
wxDefaultSize, ORC_LogicalCount,
@@ -360,10 +424,8 @@
}
- wxASSERT_MSG( ORC_TypesCount == ORC_T_Max, "forgot to update something" );
m_Type = new wxChoice(parent, -1, wxDefaultPosition,
wxDefaultSize, ORC_TypesCount, ORC_Types);
m_Argument = new wxTextCtrl(parent,-1,"", wxDefaultPosition);
- wxASSERT_MSG( ORC_WhereCount == ORC_W_Max, "forgot to update something" );
m_Where = new wxChoice(parent, -1, wxDefaultPosition,
wxDefaultSize, ORC_WhereCount, ORC_Where);
@@ -386,10 +448,15 @@
OneCritControl::~OneCritControl()
{
- // we need a destructor to clean up our controls:
+ // we need a destructor to clean up our controls because even though they
+ // would be deleted by their parent later, it would mean that
+ // adding/removing a test would result in "temporarily" leaking memory
delete m_Logical;
delete m_Not;
delete m_Type;
+
delete m_Argument;
delete m_Where;
+
+ delete m_btnSpam;
}
@@ -443,9 +510,44 @@
void
+OneCritControl::CreateSpamButton()
+{
+ ASSERT_MSG( !m_btnSpam, "CreateSpamButton() called twice?" );
+
+ InitSpamOptions();
+
+ m_btnSpam = new CritDetailsButton(m_Parent, this);
+
+ wxLayoutConstraints *c = new wxLayoutConstraints;
+ c->left.RightOf(m_Type, LAYOUT_X_MARGIN);
+ c->right.SameAs(m_Parent, wxRight, 2*LAYOUT_X_MARGIN);
+ c->centreY.SameAs(m_Not, wxCentreY);
+ c->height.AsIs();
+ m_btnSpam->SetConstraints(c);
+
+ m_Parent->Layout();
+}
+
+void
OneCritControl::UpdateUI()
{
int test = m_Type->GetSelection();
- if ( test != -1 )
+ switch ( test )
+ {
+ case -1:
+ // no selection -- do nothing
+ break;
+
+ case ORC_T_IsSpam:
+ if ( !m_btnSpam )
{
+ CreateSpamButton();
+ }
+
+ m_btnSpam->Show();
+ m_Argument->Hide();
+ m_Where->Hide();
+ break;
+
+ default:
bool enableArg = FilterTestNeedsArgument(test);
if ( !enableArg )
@@ -463,4 +565,11 @@
}
+ if ( m_btnSpam )
+ {
+ m_btnSpam->Hide();
+ m_Argument->Show();
+ m_Where->Show();
+ }
+
m_Argument->Enable(enableArg);
m_Where->Enable(FilterTestNeedsTarget(test));
@@ -469,4 +578,15 @@
void
+OneCritControl::Disable()
+{
+ m_Not->Disable();
+ m_Type->Disable();
+ m_Argument->Disable();
+ m_Where->Disable();
+ if ( m_Logical )
+ m_Logical->Disable();
+}
+
+void
OneCritControl::SetValues(const MFDialogSettings& settings, size_t n)
{
@@ -482,4 +602,159 @@
// ----------------------------------------------------------------------------
+// spam details dialog code
+// ----------------------------------------------------------------------------
+
+// spam details page options
+#define MP_SPAM_8BIT_SUBJECT "Spam8BitSubject"
+#define MP_SPAM_8BIT_SUBJECT_D 1l
+
+#define MP_SPAM_KOREAN_CSET "SpamKoreanCharset"
+#define MP_SPAM_KOREAN_CSET_D 1l
+
+#define MP_SPAM_X_AUTH_WARN "SpamXAuthWarning"
+#define MP_SPAM_X_AUTH_WARN_D 0l
+
+#ifdef USE_RBL
+#define MP_SPAM_RBL "SpamIsInRBL"
+#define MP_SPAM_RBL_D 0l
+#endif // USE_RBL
+
+#define CONFIG_ENTRY(name) ConfigValueDefault(name, name##_D)
+#define CONFIG_NONE() ConfigValueNone()
+
+static const ConfigValueDefault gs_SpamPageConfigValues[] =
+{
+ CONFIG_NONE(),
+ CONFIG_ENTRY(MP_SPAM_8BIT_SUBJECT),
+ CONFIG_ENTRY(MP_SPAM_KOREAN_CSET),
+ CONFIG_ENTRY(MP_SPAM_X_AUTH_WARN),
+#ifdef USE_RBL
+ CONFIG_ENTRY(MP_SPAM_RBL),
+#endif // USE_RBL
+};
+
+#undef CONFIG_ENTRY
+#undef CONFIG_NONE
+
+static const wxOptionsPage::FieldInfo gs_SpamPageFieldInfos[] =
+{
+ { gettext_noop("Mahogany may use several heuristic tests to detect spam.\n"
+ "Please choose the ones you'd like to be used by checking\n"
+ "the corresponding entries.\n"
+ "\n"
+ "So the message is considered to be spam if it has..."),
+ wxOptionsPage::Field_Message, -1 },
+ { gettext_noop("Too many &8 bit characters in subject"),
+wxOptionsPage::Field_Bool, -1},
+ { gettext_noop("&Korean charset"), wxOptionsPage::Field_Bool, -1},
+ { gettext_noop("X-Authentification-&Warning header"), wxOptionsPage::Field_Bool,
+-1},
+#ifdef USE_RBL
+ { gettext_noop("been &blacklisted by RBL"), wxOptionsPage::Field_Bool, -1},
+#endif // USE_RBL
+};
+
+static const wxOptionsPageDesc gs_SpamPageDesc =
+ wxOptionsPageDesc(
+ // title and image
+ gettext_noop("Details of spam detection"),
+ "spam",
+
+ // help id (TODO)
+ -1,
+
+ // the fields description
+ gs_SpamPageFieldInfos,
+ gs_SpamPageConfigValues,
+ WXSIZEOF(gs_SpamPageFieldInfos)
+ );
+
+
+void
+OneCritControl::InitSpamOptions()
+{
+ m_check8bit = MP_SPAM_8BIT_SUBJECT_D;
+ m_checkKorean = MP_SPAM_KOREAN_CSET_D;
+
+ m_checkXAuthWarn = MP_SPAM_X_AUTH_WARN_D;
+
+#ifdef USE_RBL
+ m_checkRBL = MP_SPAM_RBL_D;
+#endif // USE_RBL
+}
+
+void
+OneCritControl::ShowDetails()
+{
+ // we use the global app profile to pass the settings to/from the options
+ // page because like this we can reuse the options page classes easily
+ Profile *profile = mApplication->GetProfile();
+
+ // transfer data to dialog
+ profile->writeEntry(MP_SPAM_8BIT_SUBJECT, m_check8bit);
+ profile->writeEntry(MP_SPAM_KOREAN_CSET, m_checkKorean);
+ profile->writeEntry(MP_SPAM_X_AUTH_WARN, m_checkXAuthWarn);
+#ifdef USE_RBL
+ profile->writeEntry(MP_SPAM_RBL, m_checkRBL);
+#endif // USE_RBL
+
+ if ( ShowCustomOptionsDialog(gs_SpamPageDesc, profile, GetFrame(m_Parent)) )
+ {
+ m_check8bit = profile->readEntry(MP_SPAM_8BIT_SUBJECT, 0l) != 0;
+ m_checkKorean = profile->readEntry(MP_SPAM_KOREAN_CSET, 0l) != 0;
+ m_checkXAuthWarn = profile->readEntry(MP_SPAM_X_AUTH_WARN, 0l) != 0;
+#ifdef USE_RBL
+ m_checkRBL = profile->readEntry(MP_SPAM_RBL, 0l) != 0;
+#endif // USE_RBL
+
+ wxOneFilterDialog *dlg = GET_PARENT_OF_CLASS(m_Parent, wxOneFilterDialog);
+ CHECK_RET( dlg, "should be a child of wxOneFilterDialog" );
+
+ dlg->UpdateProgram();
+ }
+ //else: cancelled
+
+ // don't keep this stuff in profile, we don't use it except here
+ profile->DeleteEntry(MP_SPAM_8BIT_SUBJECT);
+ profile->DeleteEntry(MP_SPAM_KOREAN_CSET);
+ profile->DeleteEntry(MP_SPAM_X_AUTH_WARN);
+#ifdef USE_RBL
+ profile->DeleteEntry(MP_SPAM_RBL);
+#endif // USE_RBL
+}
+
+static void AddToSpamArgument(String& s, const char *arg)
+{
+ if ( !s.empty() )
+ s += ':';
+
+ s += arg;
+}
+
+String
+OneCritControl::GetSpamTestArgument() const
+{
+ String s;
+
+ CHECK( m_btnSpam, s, "shouldn't be called if spam button not used" );
+
+ if ( m_check8bit )
+ AddToSpamArgument(s, "subj8bit");
+ if ( m_checkKorean )
+ AddToSpamArgument(s, "korean");
+ if ( m_checkXAuthWarn )
+ AddToSpamArgument(s, "xauthwarn");
+#ifdef USE_RBL
+ if ( m_checkRBL )
+ AddToSpamArgument(s, "rbl");
+#endif // USE_RBL
+
+ return s;
+}
+
+void CritDetailsButton::OnClick(wxCommandEvent& WXUNUSED(event))
+{
+ m_ctrl->ShowDetails();
+}
+
+// ----------------------------------------------------------------------------
// OneActionControl: allows to edit the action part of MFDialogSettings
// ----------------------------------------------------------------------------
@@ -725,6 +1000,6 @@
m_IfMessage = new wxStaticText(canvas, -1, _("If message..."));
m_DoThis = new wxStaticText(canvas, -1, _("Then do this:"));
- m_ButtonMore = new wxButton(canvas, -1, _("&More"));
- m_ButtonLess = new wxButton(canvas, -1, _("&Fewer"));
+ m_ButtonMore = new wxButton(canvas, Button_MoreTests, _("&More"));
+ m_ButtonLess = new wxButton(canvas, Button_LessTests, _("&Fewer"));
m_ButtonMore->SetToolTip(_("Add another condition"));
m_ButtonLess->SetToolTip(_("Remove the last condition"));
@@ -809,5 +1084,5 @@
}
-void wxOneFilterDialog::UpdateProgram(wxCommandEvent& event)
+void wxOneFilterDialog::UpdateProgram()
{
if ( !m_initializing )
@@ -830,6 +1105,4 @@
}
}
-
- event.Skip();
}
@@ -878,38 +1151,29 @@
wxOneFilterDialog::OnText(wxCommandEvent& event)
{
+ event.Skip();
+
if ( event.GetEventObject() == m_NameCtrl )
{
// avoid updating the program unnecessarily if only the filter name was
// changed
- event.Skip();
-
return;
}
- UpdateProgram(event);
+ UpdateProgram();
}
void
-wxOneFilterDialog::OnButton(wxCommandEvent &event)
+wxOneFilterDialog::OnButtonMoreOrLess(wxCommandEvent &event)
{
- if ( event.GetEventObject() == m_ButtonLess )
+ if ( event.GetId() == Button_LessTests )
{
RemoveOneControl();
// make the and/or clause disappear
- UpdateProgram(event);
-
- // UpdateProgram() calls Skip() on the event, undo it
- event.Skip(FALSE);
+ UpdateProgram();
}
- else if ( event.GetEventObject() == m_ButtonMore )
+ else // Button_MoreTests
{
AddOneControl();
- }
- else
- {
- event.Skip();
-
- return;
}
Index: wxHeadersDialogs.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxHeadersDialogs.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -b -u -2 -r1.34 -r1.35
--- wxHeadersDialogs.cpp 12 Mar 2002 21:04:11 -0000 1.34
+++ wxHeadersDialogs.cpp 20 Jun 2002 18:12:14 -0000 1.35
@@ -449,5 +449,5 @@
wxCustomHeadersDialog dlg(m_profile, GetParent());
- dlg.ShowModal();
+ (void)dlg.ShowModal();
}
Index: wxMDialogs.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMDialogs.cpp,v
retrieving revision 1.373
retrieving revision 1.374
diff -b -u -2 -r1.373 -r1.374
--- wxMDialogs.cpp 15 Jun 2002 11:42:54 -0000 1.373
+++ wxMDialogs.cpp 20 Jun 2002 18:12:18 -0000 1.374
@@ -2730,5 +2730,5 @@
// now show the dialog allowing to choose those entries whih the user
// wants to reenable
- if ( dlg.ShowModal() )
+ if ( dlg.ShowModal() == wxID_OK )
{
const wxArrayInt& selections = dlg.GetSelections();
@@ -2836,7 +2836,7 @@
bool ShowLicenseDialog(wxWindow *parent)
{
- Profile *p = mApplication->GetProfile();
- wxLicenseDialog dlg(p, parent);
- return ( dlg.ShowModal() == wxID_OK );
+ wxLicenseDialog dlg(mApplication->GetProfile(), parent);
+
+ return dlg.ShowModal() == wxID_OK;
}
Index: wxMFrame.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMFrame.cpp,v
retrieving revision 1.155
retrieving revision 1.156
diff -b -u -2 -r1.155 -r1.156
--- wxMFrame.cpp 6 May 2002 11:33:41 -0000 1.155
+++ wxMFrame.cpp 20 Jun 2002 18:12:31 -0000 1.156
@@ -1103,8 +1103,9 @@
printerDialog.GetPrintDialogData().SetSetupDialog(TRUE);
- printerDialog.ShowModal();
-
+ if ( printerDialog.ShowModal() == wxID_OK )
+ {
(*((wxMApp *)mApplication)->GetPrintData())
= printerDialog.GetPrintDialogData().GetPrintData();
+ }
}
@@ -1159,8 +1160,9 @@
wxGenericPageSetupDialog pageSetupDialog(this, & data);
#endif
- pageSetupDialog.ShowModal();
-
+ if ( pageSetupDialog.ShowModal() == wxID_OK )
+ {
data = pageSetupDialog.GetPageSetupData();
//FIXME orientation = data.GetOrientation();
+ }
}
@@ -1173,5 +1175,5 @@
wxGenericPageSetupDialog pageSetupDialog(this, & data);
- pageSetupDialog.ShowModal();
+ (void)pageSetupDialog.ShowModal();
//FIXME orientation = pageSetupDialog.GetPageSetupData().GetOrientation();
Index: wxMsgCmdProc.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMsgCmdProc.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -b -u -2 -r1.23 -r1.24
--- wxMsgCmdProc.cpp 12 Jun 2002 00:03:40 -0000 1.23
+++ wxMsgCmdProc.cpp 20 Jun 2002 18:12:32 -0000 1.24
@@ -935,5 +935,5 @@
m_msgView->GetUId() == uid ? m_msgView : NULL);
- dialog.ShowModal();
+ (void)dialog.ShowModal();
msg->DecRef();
Index: wxOptionsDlg.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxOptionsDlg.cpp,v
retrieving revision 1.333
retrieving revision 1.334
diff -b -u -2 -r1.333 -r1.334
--- wxOptionsDlg.cpp 20 Jun 2002 14:32:03 -0000 1.333
+++ wxOptionsDlg.cpp 20 Jun 2002 18:12:38 -0000 1.334
@@ -4167,5 +4167,5 @@
}
-void ShowCustomOptionsDialog(size_t nPages,
+bool ShowCustomOptionsDialog(size_t nPages,
const wxOptionsPageDesc *pageDesc,
Profile *profile,
@@ -4176,5 +4176,5 @@
dlg.Layout();
- (void)dlg.ShowModal();
+ return dlg.ShowModal() == wxID_OK;
}
-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates