Update of /cvsroot/mahogany/M/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8889/src/gui
Modified Files:
wxComposeView.cpp wxOptionsDlg.cpp
Log Message:
added forgotten attachments detection
Index: wxComposeView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxComposeView.cpp,v
retrieving revision 1.402
retrieving revision 1.403
diff -b -u -2 -r1.402 -r1.403
--- wxComposeView.cpp 13 Feb 2006 18:30:24 -0000 1.402
+++ wxComposeView.cpp 8 Apr 2006 19:06:14 -0000 1.403
@@ -67,4 +67,5 @@
#include <wx/dir.h>
#include <wx/process.h>
+#include <wx/regex.h>
#include <wx/mimetype.h>
#include <wx/tokenzr.h>
@@ -116,4 +117,6 @@
extern const MOption MP_AUTOCOLLECT_NAMED;
extern const MOption MP_AUTOCOLLECT_OUTGOING;
+extern const MOption MP_CHECK_ATTACHMENTS_REGEX;
+extern const MOption MP_CHECK_FORGOTTEN_ATTACHMENTS;
extern const MOption MP_COMPOSE_BCC;
extern const MOption MP_COMPOSE_CC;
@@ -152,4 +155,5 @@
extern const MPersMsgBox *M_MSGBOX_ASK_SAVE_HEADERS;
extern const MPersMsgBox *M_MSGBOX_ASK_VCARD;
+extern const MPersMsgBox *M_MSGBOX_CHECK_FORGOTTEN_ATTACHMENTS;
extern const MPersMsgBox *M_MSGBOX_CONFIG_NET_FROM_COMPOSE;
extern const MPersMsgBox *M_MSGBOX_DRAFT_AUTODELETE;
@@ -3364,21 +3368,5 @@
{
case WXMENU_COMPOSE_INSERTFILE:
- {
- wxArrayString filenames;
- size_t nFiles = wxPFilesSelector
- (
- filenames,
- _T("MsgInsert"),
- _("Please choose files to insert."),
- NULL, _T("dead.letter"), NULL,
- wxGetTranslation(wxALL_FILES),
- wxOPEN | wxFILE_MUST_EXIST,
- this
- );
- for ( size_t n = 0; n < nFiles; n++ )
- {
- InsertFile(filenames[n]);
- }
- }
+ LetUserAddAttachment();
break;
@@ -4119,8 +4107,117 @@
}
+void wxComposeView::LetUserAddAttachment()
+{
+ wxArrayString filenames;
+ size_t nFiles = wxPFilesSelector
+ (
+ filenames,
+ _T("MsgInsert"),
+ _("Please choose files to insert."),
+ NULL, _T("dead.letter"), NULL,
+ wxGetTranslation(wxALL_FILES),
+ wxOPEN | wxFILE_MUST_EXIST,
+ this
+ );
+ for ( size_t n = 0; n < nFiles; n++ )
+ {
+ InsertFile(filenames[n]);
+ }
+}
+
// ----------------------------------------------------------------------------
// wxComposeView sending the message
// ----------------------------------------------------------------------------
+bool wxComposeView::CheckForForgottenAttachments() const
+{
+ if ( !READ_CONFIG(m_Profile, MP_CHECK_FORGOTTEN_ATTACHMENTS) )
+ return true;
+
+ // check if we have any attachments already as, if we do, we don't have to
+ // check if we forgot them (and also retrieve the message text while doing
+ // this)
+ wxString msgText;
+ bool hasAttachments = false;
+ for ( EditorContentPart *part = m_editor->GetFirstPart();
+ part && !hasAttachments;
+ part = m_editor->GetNextPart() )
+ {
+ switch ( part->GetType() )
+ {
+ case EditorContentPart::Type_Text:
+ msgText += part->GetText();
+ break;
+
+ default:
+ hasAttachments = true;
+ }
+
+ part->DecRef();
+ }
+
+ if ( hasAttachments )
+ {
+ // no need to check for anything: there is already at least one
+ // attachment so apparently the user didn't forget to add it
+ return true;
+ }
+
+ const String reText = READ_CONFIG_TEXT(m_Profile,
MP_CHECK_ATTACHMENTS_REGEX);
+ wxRegEx re(reText, wxRE_EXTENDED | wxRE_ICASE);
+ if ( !re.IsValid() )
+ {
+ MDialog_ErrorMessage
+ (
+ wxString::Format
+ (
+ _("The regular expression \"%s\" for detecting missing "
+ "attachments is invalid and can't be used.\n"
+ "Please change it in the program options and reenable "
+ "the check for forgotten attachments there\n"
+ "as it will be temporarily disabled now."),
+ reText.c_str()
+ ),
+ this
+ );
+
+ // TODO: should write it to the same path from which
+ // MP_CHECK_ATTACHMENTS_REGEX was really read
+ m_Profile->writeEntry(MP_CHECK_FORGOTTEN_ATTACHMENTS, false);
+
+ return true;
+ }
+
+ if ( !re.Matches(msgText) )
+ return true;
+
+ if ( !MDialog_YesNoDialog
+ (
+ _("You might have intended to attach a file to this "
+ "message but you are about to send it without any attachments\n"
+ "\n"
+ "Would you like to attach anything before sending?"),
+ this,
+ MDIALOG_YESNOTITLE,
+ M_DLG_YES_DEFAULT,
+ M_MSGBOX_CHECK_FORGOTTEN_ATTACHMENTS
+ ) )
+ {
+ if ( wxPMessageBoxIsDisabled(
+ GetPersMsgBoxName(M_MSGBOX_CHECK_FORGOTTEN_ATTACHMENTS)) )
+ {
+ // the user doesn't want us to bother him any more, so don't
+ mApplication->GetProfile()->
+ writeEntry(MP_CHECK_FORGOTTEN_ATTACHMENTS, false);
+ }
+
+ return true;
+ }
+
+ wx_const_cast(wxComposeView *, this)->LetUserAddAttachment();
+
+ return false;
+}
+
/// verify that the message is ready to be sent
bool
@@ -4211,5 +4308,10 @@
}
- if(!m_editor->FinishWork())
+ // check if the editor has anything to say
+ if ( !m_editor->FinishWork() )
+ return false;
+
+ // check if the user didn't forget to attach the files he wanted to attach
+ if ( !CheckForForgottenAttachments() )
return false;
Index: wxOptionsDlg.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxOptionsDlg.cpp,v
retrieving revision 1.427
retrieving revision 1.428
diff -b -u -2 -r1.427 -r1.428
--- wxOptionsDlg.cpp 16 Jan 2006 20:32:28 -0000 1.427
+++ wxOptionsDlg.cpp 8 Apr 2006 19:06:14 -0000 1.428
@@ -280,4 +280,8 @@
ConfigField_ComposeViewColourHeaders,
+ ConfigField_ComposeForgottenAttachmentsHelp,
+ ConfigField_ComposeCheckForgottenAttachments,
+ ConfigField_ComposeCheckAttachmentsRegex,
+
ConfigField_ComposePreviewHelp,
ConfigField_ComposePreview,
@@ -1280,5 +1284,5 @@
{ gettext_noop("\n"
- "The following settings control the appearance\n"
+ "The following settings control the appearance "
"of the composer window:"), Field_Message, -1 },
#ifdef USE_FONT_DESC
@@ -1297,4 +1301,14 @@
{ gettext_noop("\n"
+ "Mahogany can try to detect if you forget to attach a file\n"
+ "to your message when you mentioned it in the message
text.\n"
+ "If the check is activated, the regular expression below
can\n"
+ "be used to select the words which indicate attachment
present."),
+ Field_Message, -1 },
+ { gettext_noop("Check for &forgotten attachments"), Field_Bool, -1 },
+ { gettext_noop("Attachments check rege&x"), Field_Text,
+
ConfigField_ComposeCheckForgottenAttachments },
+
+ { gettext_noop("\n"
"The settings below allow you to have a last look at the\n"
"message before sending it and/or change your mind about\n"
@@ -1970,4 +1984,8 @@
CONFIG_ENTRY(MP_CVIEW_COLOUR_HEADERS),
+ CONFIG_NONE(), // forgotten attachments help
+ CONFIG_ENTRY(MP_CHECK_FORGOTTEN_ATTACHMENTS),
+ CONFIG_ENTRY(MP_CHECK_ATTACHMENTS_REGEX),
+
CONFIG_NONE(), // preview help
CONFIG_ENTRY(MP_PREVIEW_SEND),
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates