Revision: 7245
http://svn.sourceforge.net/mahogany/?rev=7245&view=rev
Author: vadz
Date: 2007-04-26 09:06:11 -0700 (Thu, 26 Apr 2007)
Log Message:
-----------
add the possibility to treat different addresses as equivalent
Modified Paths:
--------------
trunk/M/CHANGES
trunk/M/doc/Manual.htex
trunk/M/include/Address.h
trunk/M/include/Moptions.h
trunk/M/src/classes/Moptions.cpp
trunk/M/src/gui/wxOptionsDlg.cpp
trunk/M/src/mail/Address.cpp
Modified: trunk/M/CHANGES
===================================================================
--- trunk/M/CHANGES 2007-04-26 15:57:21 UTC (rev 7244)
+++ trunk/M/CHANGES 2007-04-26 16:06:11 UTC (rev 7245)
@@ -9,6 +9,7 @@
Release 0.68 '' September xx, 2006
---------------------------------------
+2007-04-26 VZ: Add the possibility to treat different addresses as equivalent
2007-01-10 VZ: Show the message subject in the composer window title bar
2007-01-08 VZ: Added support for "subject" parameter of mailto: URLs
2006-12-25 VZ: Added "Remove attachments" command
Modified: trunk/M/doc/Manual.htex
===================================================================
--- trunk/M/doc/Manual.htex 2007-04-26 15:57:21 UTC (rev 7244)
+++ trunk/M/doc/Manual.htex 2007-04-26 16:06:11 UTC (rev 7245)
@@ -71,6 +71,9 @@
\item A much faster DSPAM storage driver is used now.
\item Added ``Remove attachments'' command which can be used to strip the
unwanted attachments from a message in a local or IMAP folder.
+ \item Added the possibility to treat different addresses as equivalent,
+ this is useful to avoid sending duplicate replies to the different
+ addresses of the same person, for example.
\end{itemize}
\subsubsection{0.67 against 0.66}
@@ -2524,6 +2527,13 @@
the '@' symbol) will be used instead of the name.
\item \textbf{Whitelist}\\
Spam filter option "No match in whitelist" uses this address book.
+\item \textbf{Equivalent addresses}\\
+Adding a string of the form [EMAIL PROTECTED]@home.net} here will make
+Mahogany treat these two addresses as equivalent. This for example means that
+only one of them will be left in the outgoing message so that if you have the
+first address set as the default one for the folder which the messages from
+John Doe are filtered to and you reply to the message sent from the second
+address, the two addresses won't be duplicated in the composer window.
\end{itemize}
In addition to its own built-in addressbook format, Mahogany also
Modified: trunk/M/include/Address.h
===================================================================
--- trunk/M/include/Address.h 2007-04-26 15:57:21 UTC (rev 7244)
+++ trunk/M/include/Address.h 2007-04-26 16:06:11 UTC (rev 7245)
@@ -72,6 +72,11 @@
/**
Compares two address strings, returns true if they're equal.
+
+ This method takes into account the address equivalence as defined in the
+ program options. Both address1 and address2 should contain a single
+ address only, comparing multiple addresses is not supported and will
+ return false.
*/
static bool Compare(const String& address1, const String& address2);
Modified: trunk/M/include/Moptions.h
===================================================================
--- trunk/M/include/Moptions.h 2007-04-26 15:57:21 UTC (rev 7244)
+++ trunk/M/include/Moptions.h 2007-04-26 16:06:11 UTC (rev 7245)
@@ -207,6 +207,7 @@
extern const MOption MP_COMPOSE_SHOW_FROM;
extern const MOption MP_DEFAULT_REPLY_KIND;
extern const MOption MP_LIST_ADDRESSES;
+extern const MOption MP_EQUIV_ADDRESSES;
extern const MOption MP_REPLY_PREFIX;
extern const MOption MP_FORWARD_PREFIX;
extern const MOption MP_REPLY_COLLAPSE_PREFIX;
@@ -820,6 +821,8 @@
#define MP_DEFAULT_REPLY_KIND_NAME _T("ReplyDefault")
/// the mailing list addresses
#define MP_LIST_ADDRESSES_NAME _T("MLAddresses")
+/// array of equivalent address pairs
+#define MP_EQUIV_ADDRESSES_NAME _T("EquivAddresses")
/// prefix for subject in replies
#define MP_REPLY_PREFIX_NAME _T("ReplyPrefix")
/// prefix for subject in forwards
@@ -1670,6 +1673,8 @@
#define MP_DEFAULT_REPLY_KIND_DEFVAL 0l // MailFolder::REPLY_SENDER
/// the mailing list addresses
#define MP_LIST_ADDRESSES_DEFVAL wxEmptyString
+/// array of equivalent address pairs
+#define MP_EQUIV_ADDRESSES_DEFVAL wxEmptyString
/// prefix for subject in replies
#define MP_REPLY_PREFIX_DEFVAL _T("Re: ")
/// prefix for subject in forwards
Modified: trunk/M/src/classes/Moptions.cpp
===================================================================
--- trunk/M/src/classes/Moptions.cpp 2007-04-26 15:57:21 UTC (rev 7244)
+++ trunk/M/src/classes/Moptions.cpp 2007-04-26 16:06:11 UTC (rev 7245)
@@ -267,6 +267,7 @@
const MOption MP_COMPOSE_BCC;
const MOption MP_COMPOSE_SHOW_FROM;
const MOption MP_LIST_ADDRESSES;
+const MOption MP_EQUIV_ADDRESSES;
const MOption MP_DEFAULT_REPLY_KIND;
const MOption MP_REPLY_PREFIX;
const MOption MP_FORWARD_PREFIX;
@@ -683,6 +684,7 @@
DEFINE_OPTION(MP_COMPOSE_BCC),
DEFINE_OPTION(MP_COMPOSE_SHOW_FROM),
DEFINE_OPTION(MP_LIST_ADDRESSES),
+ DEFINE_OPTION(MP_EQUIV_ADDRESSES),
DEFINE_OPTION(MP_DEFAULT_REPLY_KIND),
DEFINE_OPTION(MP_REPLY_PREFIX),
DEFINE_OPTION(MP_FORWARD_PREFIX),
Modified: trunk/M/src/gui/wxOptionsDlg.cpp
===================================================================
--- trunk/M/src/gui/wxOptionsDlg.cpp 2007-04-26 15:57:21 UTC (rev 7244)
+++ trunk/M/src/gui/wxOptionsDlg.cpp 2007-04-26 16:06:11 UTC (rev 7245)
@@ -488,6 +488,8 @@
ConfigField_AutoCollectNameless,
ConfigField_WhiteListHelp,
ConfigField_WhiteList,
+ ConfigField_EquivAddressesHelp,
+ ConfigField_EquivAddresses,
#ifdef USE_BBDB
ConfigField_Bbdb_HelpText,
ConfigField_Bbdb_IgnoreAnonymous,
@@ -496,7 +498,7 @@
ConfigField_Bbdb_SaveOnExit,
ConfigField_AdbLast = ConfigField_Bbdb_SaveOnExit,
#else // !USE_BBDB
- ConfigField_AdbLast = ConfigField_WhiteList,
+ ConfigField_AdbLast = ConfigField_EquivAddresses,
#endif // USE_BBDB/!USE_BBDB
// helper programs
@@ -1669,6 +1671,15 @@
"through the built-in spam filter."),
Field_Message, -1 },
{ gettext_noop("Addresses in &white list"), Field_List, -1 },
+
+ { gettext_noop("\nYou can add strings of the form \"<address1>=<address2>\"
"
+ "here to indicate that\n"
+ "Mahogany should treat these addresses as being
equivalent.\n"
+ "For example, you can make a work address equivalent to the "
+ "home one to\n"
+ "avoid sending replies to both addresses at once."),
Field_Message | Field_AppWide, -1 },
+ { gettext_noop("E&quivalent addresses"), Field_List | Field_AppWide,
-1 },
+
#ifdef USE_BBDB
{ gettext_noop("The following settings configure the support of the Big
Brother\n"
"addressbook (BBDB) format. This is supported only for
compatibility\n"
@@ -2186,6 +2197,8 @@
CONFIG_ENTRY(MP_AUTOCOLLECT_NAMED),
CONFIG_NONE(),
CONFIG_ENTRY(MP_WHITE_LIST),
+ CONFIG_NONE(),
+ CONFIG_ENTRY(MP_EQUIV_ADDRESSES),
#ifdef USE_BBDB
CONFIG_NONE(),
CONFIG_ENTRY(MP_BBDB_IGNOREANONYMOUS),
@@ -4049,7 +4062,14 @@
lboxDataWhiteList->m_lboxDlgPers = _T("LastWhiteList");
lboxDataWhiteList->m_next = lboxDataMLAddr;
- m_lboxData = lboxDataWhiteList;
+ LboxData *lboxDataEquivList = new LboxData;
+ lboxDataEquivList->m_idListbox = ConfigField_EquivAddresses;
+ lboxDataEquivList->m_lboxDlgTitle = _("Equivalent addresses");
+ lboxDataEquivList->m_lboxDlgPrompt = _("Pair of equivalent addresses");
+ lboxDataEquivList->m_lboxDlgPers = _T("LastEquivList");
+ lboxDataEquivList->m_next = lboxDataWhiteList;
+
+ m_lboxData = lboxDataEquivList;
}
bool wxOptionsPageAdb::TransferDataToWindow()
Modified: trunk/M/src/mail/Address.cpp
===================================================================
--- trunk/M/src/mail/Address.cpp 2007-04-26 15:57:21 UTC (rev 7244)
+++ trunk/M/src/mail/Address.cpp 2007-04-26 16:06:11 UTC (rev 7245)
@@ -31,12 +31,19 @@
#include "Mdefaults.h"
#endif // USE_PCH
+#include <wx/hashmap.h>
+
#include "Address.h"
+// hash type associates the list of the address equivalent to the given one
+// (used as the key)
+WX_DECLARE_STRING_HASH_MAP(wxArrayString, AddressHash);
+
// ----------------------------------------------------------------------------
// options we use here
// ----------------------------------------------------------------------------
+extern const MOption MP_EQUIV_ADDRESSES;
extern const MOption MP_FROM_REPLACE_ADDRESSES;
extern const MOption MP_FROM_ADDRESS;
extern const MOption MP_HOSTNAME;
@@ -47,6 +54,41 @@
// ============================================================================
// ----------------------------------------------------------------------------
+// handling of address equivalence hash table
+// ----------------------------------------------------------------------------
+
+static const AddressHash& GetAddressHash()
+{
+ static AddressHash s_hash;
+
+ static bool s_hashInitDone = false;
+ if ( !s_hashInitDone )
+ {
+ s_hashInitDone = true;
+
+ const wxArrayString
+ equivPairs =
strutil_restore_array(READ_APPCONFIG(MP_EQUIV_ADDRESSES));
+
+ const size_t count = equivPairs.size();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ wxArrayString equiv = strutil_restore_array(equivPairs[n], '=');
+ if ( equiv.size() != 2 )
+ {
+ wxLogWarning(_("Invalid address equivalence option \"%s\""),
+ equivPairs[n].c_str());
+ continue;
+ }
+
+ s_hash[equiv[0]].push_back(equiv[1]);
+ s_hash[equiv[1]].push_back(equiv[0]);
+ }
+ }
+
+ return s_hash;
+}
+
+// ----------------------------------------------------------------------------
// Address
// ----------------------------------------------------------------------------
@@ -63,10 +105,37 @@
/* static */
bool Address::Compare(const String& address1, const String& address2)
{
- AddressList_obj addrList(address1);
- Address *addr = addrList->GetFirst();
+ AddressList_obj addrList1(address1),
+ addrList2(address2);
+ const Address * const addr1 = addrList1->GetFirst(),
+ * const addr2 = addrList2->GetFirst();
- return addr && !addrList->HasNext(addr) && *addr == address2;
+ if ( !addr1 || !addr2 )
+ return false;
+
+ // currently multiple addresses always compare differently because address2
+ // is always a single address
+ if ( addrList1->HasNext(addr1) || addrList2->HasNext(addr2) )
+ return false;
+
+ if ( *addr1 == *addr2 )
+ return true;
+
+ // check also for equivalent addresses
+ const AddressHash& hash = GetAddressHash();
+ AddressHash::const_iterator it = hash.find(addr2->GetEMail());
+ if ( it != hash.end() )
+ {
+ const wxArrayString& equivAddresses = it->second;
+ const size_t count = equivAddresses.size();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ if ( *addr1 == equivAddresses[n] )
+ return true;
+ }
+ }
+
+ return false;
}
Address::~Address()
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates