From 5b2f19acd0178fbf5a86007a5c8a7c1369828ac4 Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Tue, 15 Feb 2000 06:49:24 +0000 Subject: [PATCH] Bug #18591 --> turn on the address book collector for email addresses in the message pane. I needed a collector method that would take a unicode string. r=bienvenu --- .../addrbook/public/nsIAbAddressCollecter.idl | 8 +++++++- mailnews/addrbook/src/nsAbAddressCollecter.cpp | 17 +++++++++++++++++ mailnews/addrbook/src/nsAbAddressCollecter.h | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/mailnews/addrbook/public/nsIAbAddressCollecter.idl b/mailnews/addrbook/public/nsIAbAddressCollecter.idl index 3dd19b7b94b8..83753dcd1eb3 100644 --- a/mailnews/addrbook/public/nsIAbAddressCollecter.idl +++ b/mailnews/addrbook/public/nsIAbAddressCollecter.idl @@ -27,6 +27,12 @@ interface nsIAbAddressCollecter : nsISupports { - void CollectAddress(in string address); + void collectAddress(in string address); + /* CollectUnicodeAddress is the most I18N friendly + of the two methods to call. If you just take a char * address + as used by CollectAddress then you don't know what char set + the address is in (UTF-8??). + */ + void collectUnicodeAddress(in wstring address); }; diff --git a/mailnews/addrbook/src/nsAbAddressCollecter.cpp b/mailnews/addrbook/src/nsAbAddressCollecter.cpp index aaffff4190ce..03ae37033d5b 100644 --- a/mailnews/addrbook/src/nsAbAddressCollecter.cpp +++ b/mailnews/addrbook/src/nsAbAddressCollecter.cpp @@ -60,6 +60,23 @@ nsAbAddressCollecter::~nsAbAddressCollecter() } } +NS_IMETHODIMP nsAbAddressCollecter::CollectUnicodeAddress(const PRUnichar * aAddress) +{ + NS_ENSURE_ARG(aAddress); + nsresult rv = NS_OK; + + // convert the unicode string to UTF-8... + nsAutoString unicodeString (aAddress); + char * utf8Version = unicodeString.ToNewUTF8String(); + if (utf8Version) + { + rv = CollectAddress(utf8Version); + Recycle(utf8Version); + } + + return rv; +} + NS_IMETHODIMP nsAbAddressCollecter::CollectAddress(const char *address) { nsresult rv; diff --git a/mailnews/addrbook/src/nsAbAddressCollecter.h b/mailnews/addrbook/src/nsAbAddressCollecter.h index bf45966da0a4..1d78ca5fdac6 100644 --- a/mailnews/addrbook/src/nsAbAddressCollecter.h +++ b/mailnews/addrbook/src/nsAbAddressCollecter.h @@ -38,7 +38,7 @@ public: virtual ~nsAbAddressCollecter(); NS_DECL_ISUPPORTS - NS_DECL_NSIABADDRESSCOLLECTER + NS_DECL_NSIABADDRESSCOLLECTER nsresult OpenHistoryAB(nsIAddrDatabase **aDatabase); nsresult IsDomainExcluded(const char *address, nsIPref *pPref, PRBool *bExclude);