зеркало из https://github.com/mozilla/pjs.git
Bug 406035 Convert mailnews/import so it can compile with frozen api on linux r/sr=Neil
This commit is contained in:
Родитель
699e121cdb
Коммит
bb4293f2cc
|
@ -42,6 +42,7 @@
|
|||
#include "nsIModule.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// core import Include Files
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsMsgI18N.h"
|
||||
|
@ -49,28 +48,12 @@
|
|||
#include "Comm4xMailDebugLog.h"
|
||||
#include "prmem.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
#define kCopyBufferSize 8192
|
||||
#define kMailReadBufferSize 16384
|
||||
|
||||
|
||||
static PRBool
|
||||
nsStringEndsWith(nsString& name, const char *ending)
|
||||
{
|
||||
if (!ending) return PR_FALSE;
|
||||
|
||||
PRInt32 len = name.Length();
|
||||
if (len == 0) return PR_FALSE;
|
||||
|
||||
PRInt32 endingLen = strlen(ending);
|
||||
if (len > endingLen && name.RFind(ending, PR_TRUE) == len - endingLen) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static PRBool
|
||||
nsShouldIgnoreFile(nsString& name)
|
||||
{
|
||||
|
@ -84,13 +67,13 @@ nsShouldIgnoreFile(nsString& name)
|
|||
|
||||
// don't add summary files to the list of folders;
|
||||
// don't add popstate files to the list either, or rules (sort.dat).
|
||||
if (nsStringEndsWith(name, ".snm") ||
|
||||
if (StringEndsWith(name, NS_LITERAL_STRING(".snm")) ||
|
||||
name.LowerCaseEqualsLiteral("popstate.dat") ||
|
||||
name.LowerCaseEqualsLiteral("sort.dat") ||
|
||||
name.LowerCaseEqualsLiteral("mailfilt.log") ||
|
||||
name.LowerCaseEqualsLiteral("filters.js") ||
|
||||
nsStringEndsWith(name, ".toc")||
|
||||
nsStringEndsWith(name,".sbd"))
|
||||
StringEndsWith(name, NS_LITERAL_STRING(".toc")) ||
|
||||
StringEndsWith(name, NS_LITERAL_STRING(".sbd")))
|
||||
return PR_TRUE;
|
||||
|
||||
return PR_FALSE;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#define nsComm4xMail_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#endif
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIImportService.h"
|
||||
|
@ -64,13 +64,12 @@
|
|||
#include "nsTextFormatter.h"
|
||||
#include "nsComm4xMailStringBundle.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "Comm4xMailDebugLog.h"
|
||||
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsProxiedService.h"
|
||||
#include "nsXPCOMCIDInternal.h"
|
||||
|
||||
#define COMM4XMAIL_MSGS_URL "chrome://messenger/locale/comm4xMailImportMsgs.properties"
|
||||
|
||||
|
@ -195,11 +194,16 @@ nsresult ImportComm4xMailImpl::Initialize()
|
|||
if (NS_SUCCEEDED(rv) && (pBundleService)) {
|
||||
pBundleService->CreateBundle(COMM4XMAIL_MSGS_URL, getter_AddRefs(pBundle));
|
||||
|
||||
rv = NS_GetProxyForObject( NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIStringBundle),
|
||||
pBundle,
|
||||
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(m_pBundleProxy));
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyObjectManager =
|
||||
do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
rv = proxyObjectManager->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIStringBundle),
|
||||
pBundle,
|
||||
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(m_pBundleProxy));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -39,10 +39,10 @@
|
|||
#include "nsComm4xProfile.h"
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsILineInputStream.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "NSReg.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
#define PREF_FILE_NAME_IN_4x "Netscape Preferences"
|
||||
|
@ -260,15 +260,13 @@ nsresult nsComm4xProfile::GetPrefValue(nsILocalFile *filePath, const char * pref
|
|||
if (NS_FAILED(rv))
|
||||
break;
|
||||
CopyASCIItoUTF16(cLine, buffer);
|
||||
offset = buffer.Find(prefName,PR_FALSE, 0, -1);
|
||||
if (offset != kNotFound) {
|
||||
endOffset = buffer.Find(prefEnd,PR_FALSE, 0, -1);
|
||||
if (endOffset != kNotFound) {
|
||||
nsAutoString prefValue;
|
||||
buffer.Mid(prefValue, offset + PREF_LENGTH, endOffset-(offset + PREF_LENGTH));
|
||||
found = PR_TRUE;
|
||||
*retval = ToNewUnicode(prefValue);
|
||||
break;
|
||||
offset = buffer.Find(prefName);
|
||||
if (offset != -1) {
|
||||
endOffset = buffer.Find(prefEnd);
|
||||
if (endOffset != -1) {
|
||||
*retval = ToNewUnicode(Substring(buffer, offset + PREF_LENGTH, endOffset - (offset + PREF_LENGTH)));
|
||||
found = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "nsIFile.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIComm4xProfile.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
/* c66c1060-2bdc-11d6-92a0-0010a4b26cda */
|
||||
#define NS_ICOMM4XPROFILE_CID \
|
||||
|
|
|
@ -36,36 +36,26 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "prthread.h"
|
||||
#include "prprf.h"
|
||||
#include "nscore.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "plstr.h"
|
||||
#include "nsIImportService.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIImportAddressBooks.h"
|
||||
#include "nsIImportGeneric.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIImportABDescriptor.h"
|
||||
#include "nsIImportFieldMap.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
#include "nsIAddrDatabase.h"
|
||||
#include "nsIAddrBookSession.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsAbBaseCID.h"
|
||||
#include "nsIAbDirectory.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsImportStringBundle.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsProxiedService.h"
|
||||
#include "msgCore.h"
|
||||
#include "ImportDebug.h"
|
||||
#include "nsIAbMDBDirectory.h"
|
||||
|
@ -749,14 +739,27 @@ nsIAddrDatabase *GetAddressBookFromUri(const char *pUri)
|
|||
nsIAddrDatabase * pDatabase = nsnull;
|
||||
if (pUri) {
|
||||
nsresult rv;
|
||||
NS_WITH_PROXIED_SERVICE(nsIRDFService, rdfService,
|
||||
"@mozilla.org/rdf/rdf-service;1",
|
||||
NS_PROXY_TO_MAIN_THREAD, &rv);
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyObjectManager =
|
||||
do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIRDFService> mainRdfService =
|
||||
do_GetService(kRDFServiceCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
nsIRDFService *rdfService = nsnull;
|
||||
rv = proxyObjectManager->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIRDFService),
|
||||
mainRdfService,
|
||||
NS_PROXY_SYNC,
|
||||
(void**)&rdfService);
|
||||
if (NS_SUCCEEDED(rv) && rdfService)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
rv = rdfService->GetResource(nsDependentCString(pUri),
|
||||
getter_AddRefs(resource));
|
||||
getter_AddRefs(resource));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIAbMDBDirectory> directory = do_QueryInterface(resource, &rv);
|
||||
|
@ -786,9 +789,22 @@ nsIAddrDatabase *GetAddressBook( const PRUnichar *name, PRBool makeNew)
|
|||
/* Get the profile directory */
|
||||
nsCOMPtr<nsILocalFile> dbPath;
|
||||
|
||||
NS_WITH_PROXIED_SERVICE(nsIAddrBookSession, abSession,
|
||||
NS_ADDRBOOKSESSION_CONTRACTID,
|
||||
NS_PROXY_TO_MAIN_THREAD, &rv);
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyObjectManager =
|
||||
do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
nsCOMPtr<nsIAddrBookSession> addrBookSession =
|
||||
do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
nsIAddrBookSession *abSession = nsnull;
|
||||
rv = proxyObjectManager->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIAddrBookSession),
|
||||
addrBookSession,
|
||||
NS_PROXY_SYNC,
|
||||
(void**)&abSession);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = abSession->GetUserProfileDirectory(getter_AddRefs(dbPath));
|
||||
|
@ -802,9 +818,17 @@ nsIAddrDatabase *GetAddressBook( const PRUnichar *name, PRBool makeNew)
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
IMPORT_LOG0( "Getting the address database factory\n");
|
||||
|
||||
NS_WITH_PROXIED_SERVICE(nsIAddrDatabase, addrDBFactory,
|
||||
NS_ADDRDATABASE_CONTRACTID,
|
||||
NS_PROXY_TO_MAIN_THREAD, &rv);
|
||||
nsCOMPtr<nsIAddrDatabase> addrDatabaseFactory =
|
||||
do_GetService(NS_ADDRDATABASE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
nsIAddrDatabase *addrDBFactory = nsnull;
|
||||
rv = proxyObjectManager->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIAddrDatabase),
|
||||
addrDatabaseFactory,
|
||||
NS_PROXY_SYNC,
|
||||
(void**)&addrDBFactory);
|
||||
if (NS_SUCCEEDED(rv) && addrDBFactory) {
|
||||
IMPORT_LOG0( "Opening the new address book\n");
|
||||
rv = addrDBFactory->Open( dbPath, PR_TRUE, PR_TRUE, &pDatabase);
|
||||
|
@ -822,8 +846,17 @@ nsIAddrDatabase *GetAddressBook( const PRUnichar *name, PRBool makeNew)
|
|||
// This is major bogosity again! Why doesn't the address book
|
||||
// just handle this properly for me? Uggggg...
|
||||
|
||||
NS_WITH_PROXIED_SERVICE(nsIRDFService, rdfService, kRDFServiceCID,
|
||||
NS_PROXY_TO_MAIN_THREAD, &rv);
|
||||
nsCOMPtr<nsIRDFService> mainRdfService =
|
||||
do_GetService(kRDFServiceCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
nsIRDFService *rdfService = nsnull;
|
||||
rv = proxyObjectManager->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIRDFService),
|
||||
mainRdfService,
|
||||
NS_PROXY_SYNC,
|
||||
(void**)&rdfService);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIRDFResource> parentResource;
|
||||
rv = rdfService->GetResource(NS_LITERAL_CSTRING(kAllDirectoryRoot),
|
||||
|
@ -840,11 +873,11 @@ nsIAddrDatabase *GetAddressBook( const PRUnichar *name, PRBool makeNew)
|
|||
* a thread other than the UI thread.
|
||||
*
|
||||
*/
|
||||
rv = NS_GetProxyForObject( NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID( nsIAbDirectory),
|
||||
parentResource,
|
||||
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs( parentDir));
|
||||
rv = proxyObjectManager->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIAbDirectory),
|
||||
parentResource,
|
||||
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(parentDir));
|
||||
if (parentDir)
|
||||
{
|
||||
nsCAutoString URI("moz-abmdbdirectory://");
|
||||
|
@ -931,12 +964,17 @@ PR_STATIC_CALLBACK( void) ImportAddressThread( void *stuff)
|
|||
pDestDB = GetAddressBook(name.get(), PR_TRUE);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyObjectManager =
|
||||
do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIAddrDatabase> proxyAddrDatabase;
|
||||
rv = NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIAddrDatabase),
|
||||
pDestDB,
|
||||
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(proxyAddrDatabase));
|
||||
rv = proxyObjectManager->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIAddrDatabase),
|
||||
pDestDB,
|
||||
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(proxyAddrDatabase));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
|
|
|
@ -168,7 +168,16 @@ nsresult nsTextAddress::ReadRecord(nsILineInputStream *aLineStream, nsCString &a
|
|||
aLine.AppendLiteral(MSG_LINEBREAK);
|
||||
aLine.Append(line);
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
numQuotes += line.CountChar('"');
|
||||
#else
|
||||
const char *begin, *end;
|
||||
line.BeginReading(&begin, &end);
|
||||
for (const char *current = begin; current < end; ++current) {
|
||||
if (*current == '"')
|
||||
++numQuotes;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
// Continue whilst everything is ok, and we have an odd number of quotes.
|
||||
|
@ -358,7 +367,11 @@ PRBool nsTextAddress::GetField( const char *pLine, PRInt32 maxLen, PRInt32 index
|
|||
field.Trim( kWhitespace);
|
||||
|
||||
if (quoted) {
|
||||
field.ReplaceSubstring( "\"\"", "\"");
|
||||
PRInt32 offset = field.Find(NS_LITERAL_CSTRING("\"\""));
|
||||
while (offset != -1) {
|
||||
field.Cut(offset, 1);
|
||||
offset = field.Find(NS_LITERAL_CSTRING("\"\""), offset + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return( result);
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#define nsTextAddress_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "nsIImportFieldMap.h"
|
||||
#include "nsIImportService.h"
|
||||
|
||||
|
|
|
@ -50,8 +50,6 @@
|
|||
#endif
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIImportService.h"
|
||||
#include "nsMsgI18N.h"
|
||||
|
@ -71,7 +69,6 @@
|
|||
#include "nsTextAddress.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsProxiedService.h"
|
||||
#include "TextDebugLog.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
|
@ -353,9 +350,7 @@ NS_IMETHODIMP ImportAddressImpl::FindAddressBooks(nsIFile *pLoc, nsISupportsArra
|
|||
|
||||
PRInt32 idx = name.RFindChar( '.');
|
||||
if ((idx != -1) && (idx > 0) && ((name.Length() - idx - 1) < 5)) {
|
||||
nsString t;
|
||||
name.Left( t, idx);
|
||||
name = t;
|
||||
name.SetLength(idx);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIImportABDescriptor> desc;
|
||||
|
@ -570,9 +565,21 @@ NS_IMETHODIMP ImportAddressImpl::GetNeedsFieldMap(nsIFile *aLocation, PRBool *_r
|
|||
void ImportAddressImpl::SanitizeSampleData( nsCString& val)
|
||||
{
|
||||
// remove any line-feeds...
|
||||
val.ReplaceSubstring( "\x0D\x0A", ", ");
|
||||
val.ReplaceChar( 13, ',');
|
||||
val.ReplaceChar( 10, ',');
|
||||
PRInt32 offset = val.Find(NS_LITERAL_CSTRING("\x0D\x0A"));
|
||||
while (offset != -1) {
|
||||
val.Replace(offset, 2, ", ");
|
||||
offset = val.Find(NS_LITERAL_CSTRING("\x0D\x0A"), offset + 2);
|
||||
}
|
||||
offset = val.FindChar(13);
|
||||
while (offset != -1) {
|
||||
val.Replace(offset, 1, ',');
|
||||
offset = val.FindChar(13, offset + 2);
|
||||
}
|
||||
offset = val.FindChar(10);
|
||||
while (offset != -1) {
|
||||
val.Replace(offset, 1, ',');
|
||||
offset = val.FindChar(10, offset + 2);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ImportAddressImpl::GetSampleData( PRInt32 index, PRBool *pFound, PRUnichar **pStr)
|
||||
|
|
Загрузка…
Ссылка в новой задаче