Bug 377319 Convert mailnews/addrbook to the external API r=Neil sr=bienvenu
This commit is contained in:
Родитель
a16d545d5f
Коммит
73998fc519
|
@ -46,7 +46,6 @@
|
||||||
#include "nsIComponentManager.h"
|
#include "nsIComponentManager.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "rdf.h"
|
#include "rdf.h"
|
||||||
#include "nsCRT.h"
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
|
||||||
#include "nsDirectoryDataSource.h"
|
#include "nsDirectoryDataSource.h"
|
||||||
|
|
|
@ -251,7 +251,7 @@ NS_IMETHODIMP nsAbBSDirectory::CreateDirectoryByURI(const nsAString &aDisplayNam
|
||||||
|
|
||||||
nsCString fileName;
|
nsCString fileName;
|
||||||
if (StringBeginsWith(aURI, NS_LITERAL_CSTRING(kMDBDirectoryRoot)))
|
if (StringBeginsWith(aURI, NS_LITERAL_CSTRING(kMDBDirectoryRoot)))
|
||||||
fileName = StringTail(aURI, aURI.Length() - kMDBDirectoryRootLen);
|
fileName = Substring(aURI, kMDBDirectoryRootLen);
|
||||||
|
|
||||||
DIR_Server * server = nsnull;
|
DIR_Server * server = nsnull;
|
||||||
rv = DIR_AddNewAddressBook(aDisplayName, fileName, aURI,
|
rv = DIR_AddNewAddressBook(aDisplayName, fileName, aURI,
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
#include "nsIProperty.h"
|
#include "nsIProperty.h"
|
||||||
#include "nsCOMArray.h"
|
#include "nsCOMArray.h"
|
||||||
#include "nsArrayEnumerator.h"
|
#include "nsArrayEnumerator.h"
|
||||||
|
#include "prmem.h"
|
||||||
|
|
||||||
#define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST "mail.addr_book.lastnamefirst"
|
#define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST "mail.addr_book.lastnamefirst"
|
||||||
|
|
||||||
|
@ -706,7 +707,9 @@ nsresult nsAbCardProperty::ConvertToBase64EncodedXML(nsACString &result)
|
||||||
xmlStr.Append(xmlSubstr);
|
xmlStr.Append(xmlSubstr);
|
||||||
xmlStr.AppendLiteral("</directory>\n");
|
xmlStr.AppendLiteral("</directory>\n");
|
||||||
|
|
||||||
result.Adopt(PL_Base64Encode(NS_ConvertUTF16toUTF8(xmlStr).get(), 0, nsnull));
|
char *tmpRes = PL_Base64Encode(NS_ConvertUTF16toUTF8(xmlStr).get(), 0, nsnull);
|
||||||
|
result.Assign(tmpRes);
|
||||||
|
PR_Free(tmpRes);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -501,19 +501,10 @@ nsresult nsAbDirectoryQuery::matchCardCondition(nsIAbCard* card,
|
||||||
*matchFound = PR_TRUE;
|
*matchFound = PR_TRUE;
|
||||||
break;
|
break;
|
||||||
case nsIAbBooleanConditionTypes::Contains:
|
case nsIAbBooleanConditionTypes::Contains:
|
||||||
#ifdef MOZILLA_INTERNAL_API
|
*matchFound = CaseInsensitiveFindInReadable(matchValue, value);
|
||||||
*matchFound = FindInReadable(matchValue, value, nsCaseInsensitiveStringComparator());
|
|
||||||
#else
|
|
||||||
*matchFound = value.Find(matchValue, CaseInsensitiveCompare) >= 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case nsIAbBooleanConditionTypes::DoesNotContain:
|
case nsIAbBooleanConditionTypes::DoesNotContain:
|
||||||
#ifdef MOZILLA_INTERNAL_API
|
*matchFound = CaseInsensitiveFindInReadable(matchValue, value);
|
||||||
*matchFound = !FindInReadable(matchValue, value, nsCaseInsensitiveStringComparator());
|
|
||||||
#else
|
|
||||||
*matchFound = value.Find(matchValue, CaseInsensitiveCompare) == -1;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case nsIAbBooleanConditionTypes::Is:
|
case nsIAbBooleanConditionTypes::Is:
|
||||||
*matchFound = value.Equals(matchValue, nsCaseInsensitiveStringComparator());
|
*matchFound = value.Equals(matchValue, nsCaseInsensitiveStringComparator());
|
||||||
|
|
|
@ -66,7 +66,7 @@ NS_IMETHODIMP nsAbDirectoryRDFResource::Init(const char* aURI)
|
||||||
PRInt32 searchCharLocation = mURINoQuery.FindChar('?');
|
PRInt32 searchCharLocation = mURINoQuery.FindChar('?');
|
||||||
if (searchCharLocation >= 0) {
|
if (searchCharLocation >= 0) {
|
||||||
mQueryString = Substring(mURINoQuery, searchCharLocation + 1);
|
mQueryString = Substring(mURINoQuery, searchCharLocation + 1);
|
||||||
mURINoQuery.Truncate(searchCharLocation);
|
mURINoQuery.SetLength(searchCharLocation);
|
||||||
mIsQueryURI = PR_TRUE;
|
mIsQueryURI = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ NS_IMETHODIMP nsAbLDAPDirectory::Init(const char* aURI)
|
||||||
PRInt32 searchCharLocation = uri.FindChar('?', kLDAPDirectoryRootLen);
|
PRInt32 searchCharLocation = uri.FindChar('?', kLDAPDirectoryRootLen);
|
||||||
|
|
||||||
if (searchCharLocation == -1)
|
if (searchCharLocation == -1)
|
||||||
m_DirPrefId = StringTail(uri, uri.Length() - kLDAPDirectoryRootLen);
|
m_DirPrefId = Substring(uri, kLDAPDirectoryRootLen);
|
||||||
else
|
else
|
||||||
m_DirPrefId = Substring(uri, kLDAPDirectoryRootLen, searchCharLocation - kLDAPDirectoryRootLen);
|
m_DirPrefId = Substring(uri, kLDAPDirectoryRootLen, searchCharLocation - kLDAPDirectoryRootLen);
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@
|
||||||
#include "nsILoginInfo.h"
|
#include "nsILoginInfo.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "nsXPCOMCIDInternal.h"
|
#include "nsXPCOMCIDInternal.h"
|
||||||
|
#include "nsComponentManagerUtils.h"
|
||||||
|
#include "nsMemory.h"
|
||||||
|
|
||||||
nsAbLDAPListenerBase::nsAbLDAPListenerBase(nsILDAPURL* url,
|
nsAbLDAPListenerBase::nsAbLDAPListenerBase(nsILDAPURL* url,
|
||||||
nsILDAPConnection* connection,
|
nsILDAPConnection* connection,
|
||||||
|
|
|
@ -537,9 +537,9 @@ void nsAbLDIFService::AddLdifColToDatabase(nsIAddrDatabase *aDatabase,
|
||||||
// This will remove the label and place the URI as the work URL
|
// This will remove the label and place the URI as the work URL
|
||||||
else if (colType.EqualsLiteral("labeleduri"))
|
else if (colType.EqualsLiteral("labeleduri"))
|
||||||
{
|
{
|
||||||
PRInt32 index = column.Find(" ", false, 0, -1);
|
PRInt32 index = column.FindChar(' ');
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
column.Truncate(index);
|
column.SetLength(index);
|
||||||
|
|
||||||
aDatabase->AddWebPage1(newRow, column.get());
|
aDatabase->AddWebPage1(newRow, column.get());
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ NS_IMETHODIMP nsAbMDBDirectory::Init(const char *aUri)
|
||||||
|
|
||||||
// extract the filename from the uri.
|
// extract the filename from the uri.
|
||||||
if (searchCharLocation == -1)
|
if (searchCharLocation == -1)
|
||||||
filename = StringTail(uri, uri.Length() - kMDBDirectoryRootLen);
|
filename = Substring(uri, kMDBDirectoryRootLen);
|
||||||
else
|
else
|
||||||
filename = Substring(uri, kMDBDirectoryRootLen, searchCharLocation - kMDBDirectoryRootLen);
|
filename = Substring(uri, kMDBDirectoryRootLen, searchCharLocation - kMDBDirectoryRootLen);
|
||||||
|
|
||||||
|
|
|
@ -556,9 +556,8 @@ NS_IMETHODIMP nsAbManager::ExportAddressBook(nsIDOMWindow *aParentWin, nsIAbDire
|
||||||
default:
|
default:
|
||||||
case LDIF_EXPORT_TYPE: // ldif
|
case LDIF_EXPORT_TYPE: // ldif
|
||||||
// If filename does not have the correct ext, add one.
|
// If filename does not have the correct ext, add one.
|
||||||
if ((fileName.Find(LDIF_FILE_EXTENSION, fileName.Length() - strlen(LDIF_FILE_EXTENSION), PR_TRUE) == -1) &&
|
if ((MsgFind(fileName, LDIF_FILE_EXTENSION, PR_TRUE, fileName.Length() - strlen(LDIF_FILE_EXTENSION)) == -1) &&
|
||||||
(fileName.Find(LDIF_FILE_EXTENSION2, fileName.Length() - strlen(LDIF_FILE_EXTENSION2), PR_TRUE) == -1)) {
|
(MsgFind(fileName, LDIF_FILE_EXTENSION2, PR_TRUE, fileName.Length() - strlen(LDIF_FILE_EXTENSION2)) == -1)) {
|
||||||
|
|
||||||
|
|
||||||
// Add the extension and build a new localFile.
|
// Add the extension and build a new localFile.
|
||||||
fileName.AppendLiteral(LDIF_FILE_EXTENSION2);
|
fileName.AppendLiteral(LDIF_FILE_EXTENSION2);
|
||||||
|
@ -569,7 +568,7 @@ NS_IMETHODIMP nsAbManager::ExportAddressBook(nsIDOMWindow *aParentWin, nsIAbDire
|
||||||
|
|
||||||
case CSV_EXPORT_TYPE: // csv
|
case CSV_EXPORT_TYPE: // csv
|
||||||
// If filename does not have the correct ext, add one.
|
// If filename does not have the correct ext, add one.
|
||||||
if (fileName.Find(CSV_FILE_EXTENSION, fileName.Length() - strlen(CSV_FILE_EXTENSION), PR_TRUE) == -1) {
|
if (MsgFind(fileName, CSV_FILE_EXTENSION, PR_TRUE, fileName.Length() - strlen(CSV_FILE_EXTENSION)) == -1) {
|
||||||
|
|
||||||
// Add the extension and build a new localFile.
|
// Add the extension and build a new localFile.
|
||||||
fileName.AppendLiteral(CSV_FILE_EXTENSION);
|
fileName.AppendLiteral(CSV_FILE_EXTENSION);
|
||||||
|
@ -580,8 +579,8 @@ NS_IMETHODIMP nsAbManager::ExportAddressBook(nsIDOMWindow *aParentWin, nsIAbDire
|
||||||
|
|
||||||
case TAB_EXPORT_TYPE: // tab & text
|
case TAB_EXPORT_TYPE: // tab & text
|
||||||
// If filename does not have the correct ext, add one.
|
// If filename does not have the correct ext, add one.
|
||||||
if ((fileName.Find(TXT_FILE_EXTENSION, fileName.Length() - strlen(TXT_FILE_EXTENSION), PR_TRUE) == -1) &&
|
if ((MsgFind(fileName, TXT_FILE_EXTENSION, PR_TRUE, fileName.Length() - strlen(TXT_FILE_EXTENSION)) == -1) &&
|
||||||
(fileName.Find(TAB_FILE_EXTENSION, fileName.Length() - strlen(TAB_FILE_EXTENSION), PR_TRUE) == -1)) {
|
(MsgFind(fileName, TAB_FILE_EXTENSION, PR_TRUE, fileName.Length() - strlen(TAB_FILE_EXTENSION)) == -1)) {
|
||||||
|
|
||||||
// Add the extension and build a new localFile.
|
// Add the extension and build a new localFile.
|
||||||
fileName.AppendLiteral(TXT_FILE_EXTENSION);
|
fileName.AppendLiteral(TXT_FILE_EXTENSION);
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
#include "nsCRTGlue.h"
|
#include "nsCRTGlue.h"
|
||||||
#include "nsArrayUtils.h"
|
#include "nsArrayUtils.h"
|
||||||
#include "nsArrayEnumerator.h"
|
#include "nsArrayEnumerator.h"
|
||||||
|
#include "nsMsgUtils.h"
|
||||||
|
|
||||||
#ifdef PR_LOGGING
|
#ifdef PR_LOGGING
|
||||||
static PRLogModuleInfo* gAbOutlookDirectoryLog
|
static PRLogModuleInfo* gAbOutlookDirectoryLog
|
||||||
|
@ -971,11 +972,11 @@ NS_IMETHODIMP nsAbOutlookDirectory::StartSearch(void)
|
||||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||||
nsCOMPtr<nsIAbDirSearchListener> proxyListener;
|
nsCOMPtr<nsIAbDirSearchListener> proxyListener;
|
||||||
|
|
||||||
retCode = NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
retCode = MsgGetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||||
NS_GET_IID(nsIAbDirSearchListener),
|
NS_GET_IID(nsIAbDirSearchListener),
|
||||||
static_cast<nsIAbDirSearchListener *>(this),
|
static_cast<nsIAbDirSearchListener *>(this),
|
||||||
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||||
getter_AddRefs(proxyListener));
|
getter_AddRefs(proxyListener));
|
||||||
NS_ENSURE_SUCCESS(retCode, retCode);
|
NS_ENSURE_SUCCESS(retCode, retCode);
|
||||||
|
|
||||||
return DoQuery(this, arguments, proxyListener, -1, 0, &mSearchContext);
|
return DoQuery(this, arguments, proxyListener, -1, 0, &mSearchContext);
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
#include "nsIPrefLocalizedString.h"
|
#include "nsIPrefLocalizedString.h"
|
||||||
#include "nsArrayUtils.h"
|
#include "nsArrayUtils.h"
|
||||||
#include "nsIAddrDatabase.h" // for kPriEmailColumn
|
#include "nsIAddrDatabase.h" // for kPriEmailColumn
|
||||||
|
#include "nsMsgUtils.h"
|
||||||
|
|
||||||
#define CARD_NOT_FOUND -1
|
#define CARD_NOT_FOUND -1
|
||||||
#define ALL_ROWS -1
|
#define ALL_ROWS -1
|
||||||
|
@ -77,7 +78,7 @@ nsAbView::nsAbView() : mInitialized(PR_FALSE),
|
||||||
mSuppressCountChange(PR_FALSE),
|
mSuppressCountChange(PR_FALSE),
|
||||||
mGeneratedNameFormat(0)
|
mGeneratedNameFormat(0)
|
||||||
{
|
{
|
||||||
mMailListAtom = do_GetAtom("MailList");
|
mMailListAtom = MsgGetAtom("MailList");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAbView::~nsAbView()
|
nsAbView::~nsAbView()
|
||||||
|
|
|
@ -229,7 +229,7 @@ nsAddbookProtocolHandler::GeneratePrintOutput(nsIAddbookUrl *addbookUrl,
|
||||||
turn "moz-abmdbdirectory/abook.mab"
|
turn "moz-abmdbdirectory/abook.mab"
|
||||||
into "moz-abmdbdirectory://abook.mab"
|
into "moz-abmdbdirectory://abook.mab"
|
||||||
*/
|
*/
|
||||||
pos = uri.Find("/");
|
pos = uri.FindChar('/');
|
||||||
if (pos == -1)
|
if (pos == -1)
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
#include "prprf.h"
|
#include "prprf.h"
|
||||||
#include "plstr.h"
|
#include "plstr.h"
|
||||||
#include "nsQuickSort.h"
|
#include "nsQuickSort.h"
|
||||||
|
#include "nsComponentManagerUtils.h"
|
||||||
#include "msgCore.h"
|
#include "msgCore.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -303,8 +304,7 @@ nsresult DIR_AddNewAddressBook(const nsAString &dirName,
|
||||||
DIR_GetDirServers();
|
DIR_GetDirServers();
|
||||||
if (dir_ServerList)
|
if (dir_ServerList)
|
||||||
{
|
{
|
||||||
NS_ConvertUTF16toUTF8 utf8str(dirName);
|
server->description = ToNewCString(NS_ConvertUTF16toUTF8(dirName));
|
||||||
server->description = ToNewCString(utf8str);
|
|
||||||
server->position = kDefaultPosition; // don't set position so alphabetic sort will happen.
|
server->position = kDefaultPosition; // don't set position so alphabetic sort will happen.
|
||||||
|
|
||||||
if (!fileName.IsEmpty())
|
if (!fileName.IsEmpty())
|
||||||
|
@ -858,8 +858,7 @@ static char *DIR_GetDescription(const char *prefRoot)
|
||||||
char *value = nsnull;
|
char *value = nsnull;
|
||||||
if (!wvalue.IsEmpty())
|
if (!wvalue.IsEmpty())
|
||||||
{
|
{
|
||||||
NS_ConvertUTF16toUTF8 utf8str(wvalue.get());
|
value = ToNewCString(NS_ConvertUTF16toUTF8(wvalue));
|
||||||
value = ToNewCString(utf8str);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче