fix for 44633, 44634, and more threadpane performance work - use NS_LITERAL_STRING
where appropriate, avoid excess conversion of integer resources, etc. r=putterman,mscott git-svn-id: svn://10.0.0.236/trunk@75342 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
3fdc637ee3
commit
562414f7a2
@ -45,7 +45,6 @@ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
NS_IMPL_ISUPPORTS(nsMsgAccount, NS_GET_IID(nsIMsgAccount));
|
||||
|
||||
nsMsgAccount::nsMsgAccount():
|
||||
m_accountKey(0),
|
||||
m_prefs(0),
|
||||
m_incomingServer(null_nsCOMPtr()),
|
||||
m_defaultIdentity(null_nsCOMPtr())
|
||||
@ -60,7 +59,6 @@ nsMsgAccount::~nsMsgAccount()
|
||||
// release of servers an identites happen automatically
|
||||
// thanks to nsCOMPtrs and nsISupportsArray
|
||||
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID, m_prefs);
|
||||
PR_FREEIF(m_accountKey);
|
||||
|
||||
}
|
||||
|
||||
@ -106,7 +104,7 @@ nsMsgAccount::GetIncomingServer(nsIMsgIncomingServer * *aIncomingServer)
|
||||
nsresult
|
||||
nsMsgAccount::createIncomingServer()
|
||||
{
|
||||
if (!m_accountKey) return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!(const char*)m_accountKey) return NS_ERROR_NOT_INITIALIZED;
|
||||
// from here, load mail.account.myaccount.server
|
||||
// Load the incoming server
|
||||
//
|
||||
@ -124,7 +122,7 @@ nsMsgAccount::createIncomingServer()
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef DEBUG_alecf
|
||||
printf("\t%s's server: %s\n", m_accountKey, (const char*)serverKey);
|
||||
printf("\t%s's server: %s\n", (const char*)m_accountKey, (const char*)serverKey);
|
||||
#endif
|
||||
|
||||
// get the servertype
|
||||
@ -146,7 +144,8 @@ nsMsgAccount::createIncomingServer()
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("\tCould not read pref %s\n", (const char*)serverTypePref);
|
||||
} else {
|
||||
printf("\t%s's type: %s\n", m_accountKey, (const char*)serverType);
|
||||
printf("\t%s's type: %s\n",
|
||||
(const char*)m_accountKey, (const char*)serverType);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -160,7 +159,7 @@ nsMsgAccount::createIncomingServer()
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#ifdef DEBUG_alecf
|
||||
printf("%s loaded.\n", m_accountKey);
|
||||
printf("%s loaded.\n", (const char*)m_accountKey);
|
||||
#endif
|
||||
// store the server in this structure
|
||||
m_incomingServer = server;
|
||||
@ -179,10 +178,10 @@ nsMsgAccount::SetIncomingServer(nsIMsgIncomingServer * aIncomingServer)
|
||||
rv = aIncomingServer->GetKey(getter_Copies(key));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
char* serverPrefName =
|
||||
PR_smprintf("mail.account.%s.server", m_accountKey);
|
||||
nsCAutoString serverPrefName("mail.account.");
|
||||
serverPrefName.Append(m_accountKey);
|
||||
serverPrefName.Append(".server");
|
||||
m_prefs->SetCharPref(serverPrefName, key);
|
||||
PR_smprintf_free(serverPrefName);
|
||||
}
|
||||
|
||||
m_incomingServer = dont_QueryInterface(aIncomingServer);
|
||||
@ -220,26 +219,29 @@ nsMsgAccount::createIdentities()
|
||||
NS_ASSERTION(!m_identities, "only call createIdentities() once!");
|
||||
if (m_identities) return NS_ERROR_FAILURE;
|
||||
|
||||
NS_ASSERTION(m_accountKey, "Account key not initialized.");
|
||||
if (!m_accountKey) return NS_ERROR_NOT_INITIALIZED;
|
||||
NS_ENSURE_TRUE((const char*)m_accountKey, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
NS_NewISupportsArray(getter_AddRefs(m_identities));
|
||||
|
||||
// get the pref
|
||||
// ex) mail.account.myaccount.identities = "joe-home,joe-work"
|
||||
char *identitiesKeyPref = PR_smprintf("mail.account.%s.identities",
|
||||
m_accountKey);
|
||||
nsCAutoString identitiesKeyPref("mail.account.");
|
||||
identitiesKeyPref.Append(m_accountKey);
|
||||
identitiesKeyPref.Append(".identities");
|
||||
|
||||
nsXPIDLCString identityKey;
|
||||
nsresult rv;
|
||||
rv = getPrefService();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = m_prefs->CopyCharPref(identitiesKeyPref, getter_Copies(identityKey));
|
||||
PR_FREEIF(identitiesKeyPref);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef DEBUG_alecf
|
||||
printf("%s's identities: %s\n", m_accountKey, (const char*)identityKey);
|
||||
printf("%s's identities: %s\n",
|
||||
(const char*)m_accountKey,
|
||||
(const char*)identityKey);
|
||||
#endif
|
||||
|
||||
// get the server from the account manager
|
||||
@ -310,10 +312,11 @@ nsMsgAccount::AddIdentity(nsIMsgIdentity *identity)
|
||||
rv = identity->GetKey(getter_Copies(key));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
char *identitiesKeyPref = PR_smprintf("mail.account.%s.identities",
|
||||
m_accountKey);
|
||||
nsCAutoString identitiesKeyPref("mail.account.");
|
||||
identitiesKeyPref.Append(m_accountKey);
|
||||
identitiesKeyPref.Append(".identities");
|
||||
|
||||
m_prefs->SetCharPref(identitiesKeyPref, key);
|
||||
PR_smprintf_free(identitiesKeyPref);
|
||||
}
|
||||
|
||||
NS_ASSERTION(m_identities,"you never called Init()");
|
||||
@ -346,7 +349,7 @@ nsMsgAccount::SetKey(const char *accountKey)
|
||||
rv = getPrefService();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
m_accountKey = PL_strdup(accountKey);
|
||||
*(char**)getter_Copies(m_accountKey) = PL_strdup(accountKey);
|
||||
|
||||
return Init();
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ public:
|
||||
NS_DECL_NSIMSGACCOUNT
|
||||
|
||||
private:
|
||||
char *m_accountKey;
|
||||
nsXPIDLCString m_accountKey;
|
||||
nsIPref *m_prefs;
|
||||
nsCOMPtr<nsIMsgIncomingServer> m_incomingServer;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
@ -239,39 +239,40 @@ nsMsgAccountManager::getPrefService()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
char *
|
||||
void
|
||||
nsMsgAccountManager::getUniqueKey(const char* prefix,
|
||||
nsHashtable *hashTable)
|
||||
nsHashtable *hashTable,
|
||||
nsCString& aResult)
|
||||
{
|
||||
PRInt32 i=1;
|
||||
char key[30];
|
||||
PRBool unique=PR_FALSE;
|
||||
|
||||
do {
|
||||
PR_snprintf(key, 10, "%s%d",prefix, i++);
|
||||
nsStringKey hashKey(key);
|
||||
aResult=prefix;
|
||||
aResult.AppendInt(i++);
|
||||
nsStringKey hashKey(aResult);
|
||||
void* hashElement = hashTable->Get(&hashKey);
|
||||
|
||||
if (!hashElement) unique=PR_TRUE;
|
||||
} while (!unique);
|
||||
|
||||
return nsCRT::strdup(key);
|
||||
}
|
||||
|
||||
char *
|
||||
void
|
||||
nsMsgAccountManager::getUniqueAccountKey(const char *prefix,
|
||||
nsISupportsArray *accounts)
|
||||
nsISupportsArray *accounts,
|
||||
nsCString& aResult)
|
||||
{
|
||||
PRInt32 i=1;
|
||||
char key[30];
|
||||
PRBool unique = PR_FALSE;
|
||||
|
||||
findAccountByKeyEntry findEntry;
|
||||
findEntry.key = key;
|
||||
findEntry.account = nsnull;
|
||||
|
||||
do {
|
||||
PR_snprintf(key, 10, "%s%d", prefix, i++);
|
||||
aResult = prefix;
|
||||
aResult.AppendInt(i++);
|
||||
findEntry.key = aResult.GetBuffer();
|
||||
|
||||
accounts->EnumerateForwards(findAccountByKey, (void *)&findEntry);
|
||||
|
||||
@ -279,17 +280,21 @@ nsMsgAccountManager::getUniqueAccountKey(const char *prefix,
|
||||
findEntry.account = nsnull;
|
||||
} while (!unique);
|
||||
|
||||
return nsCRT::strdup(key);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgAccountManager::CreateIdentity(nsIMsgIdentity **_retval)
|
||||
{
|
||||
if (!_retval) return NS_ERROR_NULL_POINTER;
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv;
|
||||
|
||||
char *key = getUniqueKey(ID_PREFIX, &m_identities);
|
||||
nsCAutoString key;
|
||||
getUniqueKey(ID_PREFIX, &m_identities, key);
|
||||
|
||||
return createKeyedIdentity(key, _retval);
|
||||
rv = createKeyedIdentity(key, _retval);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -358,12 +363,14 @@ nsMsgAccountManager::CreateIncomingServer(const char* username,
|
||||
const char* type,
|
||||
nsIMsgIncomingServer **_retval)
|
||||
{
|
||||
if (!_retval) return NS_ERROR_NULL_POINTER;
|
||||
// make sure we've loaded existing accounts
|
||||
nsresult rv = LoadAccounts();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
const char *key = getUniqueKey(SERVER_PREFIX, &m_incomingServers);
|
||||
return createKeyedServer(key, username, hostname, type, _retval);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
nsresult rv;
|
||||
|
||||
nsCAutoString key;
|
||||
getUniqueKey(SERVER_PREFIX, &m_incomingServers, key);
|
||||
rv = createKeyedServer(key, username, hostname, type, _retval);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -1239,9 +1246,10 @@ nsMsgAccountManager::createKeyedAccount(const char* key,
|
||||
nsresult
|
||||
nsMsgAccountManager::CreateAccount(nsIMsgAccount **_retval)
|
||||
{
|
||||
if (!_retval) return NS_ERROR_NULL_POINTER;
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
const char *key=getUniqueAccountKey(ACCOUNT_PREFIX, m_accounts);
|
||||
nsCAutoString key;
|
||||
getUniqueAccountKey(ACCOUNT_PREFIX, m_accounts, key);
|
||||
|
||||
return createKeyedAccount(key, _retval);
|
||||
}
|
||||
|
||||
@ -161,9 +161,12 @@ private:
|
||||
static PRBool PR_CALLBACK writeFolderCache(nsHashKey *aKey, void *aData, void *closure);
|
||||
static PRBool PR_CALLBACK closeCachedConnections(nsHashKey *aKey, void *aData, void *closure);
|
||||
|
||||
static char *getUniqueKey(const char* prefix, nsHashtable *hashTable);
|
||||
static char *getUniqueAccountKey(const char* prefix,
|
||||
nsISupportsArray *accounts);
|
||||
static void getUniqueKey(const char* prefix,
|
||||
nsHashtable *hashTable,
|
||||
nsCString& aResult);
|
||||
static void getUniqueAccountKey(const char* prefix,
|
||||
nsISupportsArray *accounts,
|
||||
nsCString& aResult);
|
||||
|
||||
|
||||
nsresult SetSendLaterUriPref(nsIMsgIncomingServer *server);
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
#include "nsMsgFolderDataSource.h"
|
||||
#include "nsMsgFolderFlags.h"
|
||||
#include "nsMsgFolder.h"
|
||||
|
||||
#include "nsMsgRDFUtils.h"
|
||||
#include "nsIMessage.h"
|
||||
|
||||
@ -1443,7 +1443,7 @@ nsMsgFolderDataSource::GetNumMessagesNode(PRInt32 numMessages, nsIRDFNode **node
|
||||
{
|
||||
|
||||
if(numMessages >0)
|
||||
createNode(numMessages, node, getRDFService());
|
||||
createIntNode(numMessages, node, getRDFService());
|
||||
else if(numMessages == -1)
|
||||
{
|
||||
nsAutoString unknownMessages; unknownMessages.AssignWithConversion("???");
|
||||
|
||||
@ -224,101 +224,77 @@ nsresult nsMsgMessageDataSource::Init()
|
||||
|
||||
nsresult nsMsgMessageDataSource::CreateLiterals(nsIRDFService *rdf)
|
||||
{
|
||||
// STRING USE WARNING: more of a suggestion, really -- perhaps using |NS_ConvertASCIItoUCS2| right in the |createNode| calls
|
||||
// would be cleaner. It should generate identical code
|
||||
|
||||
PRUnichar *prustr = nsnull;
|
||||
createNode(NS_LITERAL_STRING(" "), getter_AddRefs(kEmptyStringLiteral), rdf);
|
||||
|
||||
nsAutoString str; str.AssignWithConversion(" ");
|
||||
createNode(str, getter_AddRefs(kEmptyStringLiteral), rdf);
|
||||
//
|
||||
// internal strings - not to be localized - usually reflected into the DOM
|
||||
// via the datasource, so that content can be styled
|
||||
//
|
||||
|
||||
// priority stuff
|
||||
createNode(NS_LITERAL_STRING("lowest"), getter_AddRefs(kLowestLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("low"), getter_AddRefs(kLowLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("high"), getter_AddRefs(kHighLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("highest"),getter_AddRefs(kHighestLiteral),rdf);
|
||||
createNode(NS_LITERAL_STRING("4"), getter_AddRefs(kLowestSortLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("3"), getter_AddRefs(kLowSortLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("2"), getter_AddRefs(kNormalSortLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("1"), getter_AddRefs(kHighSortLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("0"), getter_AddRefs(kHighestSortLiteral), rdf);
|
||||
|
||||
str.AssignWithConversion("lowest");
|
||||
createNode(str, getter_AddRefs(kLowestLiteral), rdf);
|
||||
// message status -
|
||||
createNode(NS_LITERAL_STRING("flagged"),getter_AddRefs(kFlaggedLiteral),rdf);
|
||||
createNode(NS_LITERAL_STRING("unflagged"), getter_AddRefs(kUnflaggedLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("replied"),getter_AddRefs(kRepliedLiteral),rdf);
|
||||
createNode(NS_LITERAL_STRING("new"), getter_AddRefs(kNewLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("read"), getter_AddRefs(kReadLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("fowarded"), getter_AddRefs(kForwardedLiteral), rdf);
|
||||
|
||||
prustr = GetString(NS_LITERAL_STRING("priorityLowest"));
|
||||
str.Assign(prustr);
|
||||
createNode(str, getter_AddRefs(kLowestLiteralDisplayString), rdf);
|
||||
// other useful strings
|
||||
createNode(NS_LITERAL_STRING("true"), getter_AddRefs(kTrueLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("false"), getter_AddRefs(kFalseLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("news"), getter_AddRefs(kNewsLiteral), rdf);
|
||||
createNode(NS_LITERAL_STRING("mail"), getter_AddRefs(kMailLiteral), rdf);
|
||||
|
||||
str.AssignWithConversion("low");
|
||||
createNode(str, getter_AddRefs(kLowLiteral), rdf);
|
||||
//
|
||||
// localized strings - some of the above strings need to be displayed
|
||||
// to the user
|
||||
|
||||
prustr = GetString(NS_LITERAL_STRING("priorityLow"));
|
||||
str.Assign(prustr);
|
||||
createNode(str, getter_AddRefs(kLowLiteralDisplayString), rdf);
|
||||
|
||||
str.AssignWithConversion("high");
|
||||
createNode(str, getter_AddRefs(kHighLiteral), rdf);
|
||||
// priority
|
||||
prustr = GetString(NS_LITERAL_STRING("priorityHighest"));
|
||||
createNode(prustr, getter_AddRefs(kHighestLiteralDisplayString), rdf);
|
||||
Recycle(prustr);
|
||||
|
||||
prustr = GetString(NS_LITERAL_STRING("priorityHigh"));
|
||||
str.Assign(prustr);
|
||||
createNode(str, getter_AddRefs(kHighLiteralDisplayString), rdf);
|
||||
createNode(prustr, getter_AddRefs(kHighLiteralDisplayString), rdf);
|
||||
Recycle(prustr);
|
||||
|
||||
str.AssignWithConversion("highest");
|
||||
createNode(str, getter_AddRefs(kHighestLiteral), rdf);
|
||||
|
||||
prustr = GetString(NS_LITERAL_STRING("priorityHighest"));
|
||||
str.Assign(prustr);
|
||||
createNode(str, getter_AddRefs(kHighestLiteralDisplayString), rdf);
|
||||
|
||||
str.AssignWithConversion("4");
|
||||
createNode(str, getter_AddRefs(kLowestSortLiteral), rdf);
|
||||
str.AssignWithConversion("3");
|
||||
createNode(str, getter_AddRefs(kLowSortLiteral), rdf);
|
||||
str.AssignWithConversion("2");
|
||||
createNode(str, getter_AddRefs(kNormalSortLiteral), rdf);
|
||||
str.AssignWithConversion("1");
|
||||
createNode(str, getter_AddRefs(kHighSortLiteral), rdf);
|
||||
str.AssignWithConversion("0");
|
||||
createNode(str, getter_AddRefs(kHighestSortLiteral), rdf);
|
||||
|
||||
str.AssignWithConversion("flagged");
|
||||
createNode(str, getter_AddRefs(kFlaggedLiteral), rdf);
|
||||
prustr = GetString(NS_LITERAL_STRING("priorityLow"));
|
||||
createNode(prustr, getter_AddRefs(kLowLiteralDisplayString), rdf);
|
||||
Recycle(prustr);
|
||||
|
||||
str.AssignWithConversion("unflagged");
|
||||
createNode(str, getter_AddRefs(kUnflaggedLiteral), rdf);
|
||||
|
||||
str.AssignWithConversion("replied");
|
||||
createNode(str, getter_AddRefs(kRepliedLiteral), rdf);
|
||||
|
||||
prustr = GetString(NS_LITERAL_STRING("replied"));
|
||||
str.Assign(prustr);
|
||||
createNode(str, getter_AddRefs(kRepliedLiteralDisplayString), rdf);
|
||||
|
||||
str.AssignWithConversion("fowarded");
|
||||
createNode(str, getter_AddRefs(kForwardedLiteral), rdf);
|
||||
|
||||
prustr = GetString(NS_LITERAL_STRING("forwarded"));
|
||||
str.Assign(prustr);
|
||||
createNode(str, getter_AddRefs(kForwardedLiteralDisplayString), rdf);
|
||||
|
||||
str.AssignWithConversion("new");
|
||||
createNode(str, getter_AddRefs(kNewLiteral), rdf);
|
||||
prustr = GetString(NS_LITERAL_STRING("priorityLowest"));
|
||||
createNode(prustr, getter_AddRefs(kLowestLiteralDisplayString), rdf);
|
||||
Recycle(prustr);
|
||||
|
||||
// message status
|
||||
prustr = GetString(NS_LITERAL_STRING("new"));
|
||||
str.Assign(prustr);
|
||||
createNode(str, getter_AddRefs(kNewLiteralDisplayString), rdf);
|
||||
createNode(prustr, getter_AddRefs(kNewLiteralDisplayString), rdf);
|
||||
Recycle(prustr);
|
||||
|
||||
str.AssignWithConversion("read");
|
||||
createNode(str, getter_AddRefs(kReadLiteral), rdf);
|
||||
|
||||
prustr = GetString(NS_LITERAL_STRING("read"));
|
||||
str.Assign(prustr);
|
||||
createNode(str, getter_AddRefs(kReadLiteralDisplayString), rdf);
|
||||
createNode(prustr, getter_AddRefs(kReadLiteralDisplayString), rdf);
|
||||
Recycle(prustr);
|
||||
|
||||
str.AssignWithConversion("true");
|
||||
createNode(str, getter_AddRefs(kTrueLiteral), rdf);
|
||||
prustr = GetString(NS_LITERAL_STRING("forwarded"));
|
||||
createNode(prustr, getter_AddRefs(kForwardedLiteralDisplayString), rdf);
|
||||
Recycle(prustr);
|
||||
|
||||
str.AssignWithConversion("false");
|
||||
createNode(str, getter_AddRefs(kFalseLiteral), rdf);
|
||||
|
||||
str.AssignWithConversion("news");
|
||||
createNode(str, getter_AddRefs(kNewsLiteral), rdf);
|
||||
|
||||
str.AssignWithConversion("mail");
|
||||
createNode(str, getter_AddRefs(kMailLiteral), rdf);
|
||||
prustr = GetString(NS_LITERAL_STRING("replied"));
|
||||
createNode(prustr, getter_AddRefs(kRepliedLiteralDisplayString), rdf);
|
||||
Recycle(prustr);
|
||||
|
||||
if(prustr != nsnull)
|
||||
nsCRT::free(prustr);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -341,23 +317,9 @@ nsresult nsMsgMessageDataSource::CreateArcsOutEnumerators()
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsMsgMessageDataSource, nsMsgRDFDataSource)
|
||||
NS_IMPL_RELEASE_INHERITED(nsMsgMessageDataSource, nsMsgRDFDataSource)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgMessageDataSource::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = nsnull;
|
||||
if(iid.Equals(NS_GET_IID(nsIFolderListener)))
|
||||
{
|
||||
*result = NS_STATIC_CAST(nsIFolderListener*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return nsMsgRDFDataSource::QueryInterface(iid, result);
|
||||
}
|
||||
NS_IMPL_QUERY_INTERFACE_INHERITED1(nsMsgMessageDataSource,
|
||||
nsMsgRDFDataSource,
|
||||
nsIFolderListener);
|
||||
|
||||
// nsIRDFDataSource methods
|
||||
NS_IMETHODIMP nsMsgMessageDataSource::GetURI(char* *uri)
|
||||
@ -432,35 +394,18 @@ nsMsgMessageDataSource::GetString(const PRUnichar *aStringName)
|
||||
}
|
||||
|
||||
//sender is the string we need to parse. senderuserName is the parsed user name we get back.
|
||||
nsresult nsMsgMessageDataSource::GetSenderName(const PRUnichar *sender, nsAutoString *senderUserName)
|
||||
nsresult nsMsgMessageDataSource::GetSenderName(const PRUnichar *sender, nsAutoString& senderUserName)
|
||||
{
|
||||
//XXXOnce we get the csid, use Intl version
|
||||
nsresult rv = NS_OK;
|
||||
if(mHeaderParser)
|
||||
{
|
||||
|
||||
char *name;
|
||||
nsAutoString senderStr(sender);
|
||||
char *senderUTF8 = senderStr.ToNewUTF8String();
|
||||
if(!senderUTF8)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsXPIDLCString name;
|
||||
|
||||
if(NS_SUCCEEDED(rv = mHeaderParser->ExtractHeaderAddressName("UTF-8", senderUTF8, &name)))
|
||||
{
|
||||
if(name)
|
||||
{
|
||||
PRUnichar *newSender;
|
||||
nsAutoString fmt; fmt.AssignWithConversion("%s");
|
||||
newSender = nsTextFormatter::smprintf(fmt.GetUnicode(),name);
|
||||
if(newSender)
|
||||
{
|
||||
senderUserName->Assign(newSender);
|
||||
nsTextFormatter::smprintf_free(newSender);
|
||||
}
|
||||
nsCRT::free(name);
|
||||
}
|
||||
Recycle(senderUTF8);
|
||||
}
|
||||
rv = mHeaderParser->ExtractHeaderAddressName("UTF-8", NS_ConvertUCS2toUTF8(sender), getter_Copies(name));
|
||||
if (NS_SUCCEEDED(rv) && (const char*)name)
|
||||
senderUserName.Assign(NS_ConvertUTF8toUCS2(name));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -470,7 +415,7 @@ NS_IMETHODIMP nsMsgMessageDataSource::GetSources(nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsISimpleEnumerator** sources)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
NS_ASSERTION(PR_FALSE, "Not implemented");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@ -511,25 +456,14 @@ NS_IMETHODIMP nsMsgMessageDataSource::GetTargets(nsIRDFResource* source,
|
||||
(kNC_OrderReceived == property) || (kNC_HasAttachment == property) ||
|
||||
(kNC_MessageType == property))
|
||||
{
|
||||
nsSingletonEnumerator* cursor =
|
||||
new nsSingletonEnumerator(source);
|
||||
if (cursor == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(cursor);
|
||||
*targets = cursor;
|
||||
rv = NS_OK;
|
||||
rv = NS_NewSingletonEnumerator(targets, source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!*targets) {
|
||||
//create empty cursor
|
||||
nsCOMPtr<nsISupportsArray> assertions;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(assertions));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = NS_NewArrayEnumerator(targets, assertions);
|
||||
rv = NS_NewEmptyEnumerator(targets);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -1209,7 +1143,7 @@ nsMsgMessageDataSource::createMessageNameNode(nsIMessage *message,
|
||||
rv = message->GetFlags(&flags);
|
||||
if(NS_SUCCEEDED(rv) && (flags & MSG_FLAG_HAS_RE))
|
||||
{
|
||||
nsAutoString reStr; reStr.AssignWithConversion("Re: ");
|
||||
nsAutoString reStr(NS_LITERAL_STRING("Re: "));
|
||||
reStr.Append(subject);
|
||||
*((PRUnichar **)getter_Copies(subject)) = nsXPIDLString::Copy(reStr.GetUnicode());
|
||||
}
|
||||
@ -1238,7 +1172,7 @@ nsMsgMessageDataSource::createMessageSenderNode(nsIMessage *message,
|
||||
{
|
||||
rv = message->GetMime2DecodedAuthor(getter_Copies(sender));
|
||||
if(NS_SUCCEEDED(rv))
|
||||
rv = GetSenderName(sender, &senderUserName);
|
||||
rv = GetSenderName(sender, senderUserName);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
rv = createNode(senderUserName, target, getRDFService());
|
||||
}
|
||||
@ -1263,7 +1197,7 @@ nsMsgMessageDataSource::createMessageRecipientNode(nsIMessage *message,
|
||||
{
|
||||
rv = message->GetMime2DecodedRecipients(getter_Copies(recipients));
|
||||
if(NS_SUCCEEDED(rv))
|
||||
rv = GetSenderName(recipients, &recipientUserName);
|
||||
rv = GetSenderName(recipients, recipientUserName);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
rv = createNode(recipientUserName, target, getRDFService());
|
||||
}
|
||||
@ -1450,11 +1384,11 @@ nsresult
|
||||
nsMsgMessageDataSource::createFlaggedStringFromFlag(PRUint32 flags, nsAutoString &flaggedStr)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
flaggedStr.AssignWithConversion(" ");
|
||||
flaggedStr.Assign(NS_LITERAL_STRING(" "));
|
||||
if(flags & MSG_FLAG_MARKED)
|
||||
flaggedStr.AssignWithConversion("flagged");
|
||||
flaggedStr.Assign(NS_LITERAL_STRING("flagged"));
|
||||
else
|
||||
flaggedStr.AssignWithConversion("unflagged");
|
||||
flaggedStr.Assign(NS_LITERAL_STRING("unflagged"));
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1463,13 +1397,13 @@ nsMsgMessageDataSource::createPriorityString(nsMsgPriorityValue priority, nsAuto
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRUnichar *prustr;
|
||||
priorityStr.AssignWithConversion(" ");
|
||||
priorityStr.Assign(NS_LITERAL_STRING(" "));
|
||||
switch (priority)
|
||||
{
|
||||
case nsMsgPriority::notSet:
|
||||
case nsMsgPriority::none:
|
||||
case nsMsgPriority::normal:
|
||||
priorityStr.AssignWithConversion(" ");
|
||||
priorityStr.Assign(NS_LITERAL_STRING(" "));
|
||||
break;
|
||||
case nsMsgPriority::lowest:
|
||||
//priorityStr = "Lowest";
|
||||
@ -1581,12 +1515,8 @@ nsMsgMessageDataSource::createMessageSizeNode(nsIMessage *message, nsIRDFNode **
|
||||
|
||||
if(!sort)
|
||||
{
|
||||
char * kbStr = PR_smprintf("%uKB", sizeInKB);
|
||||
if(kbStr)
|
||||
{
|
||||
sizeStr.AssignWithConversion(kbStr);
|
||||
PR_smprintf_free(kbStr);
|
||||
}
|
||||
sizeStr.AppendInt(sizeInKB);
|
||||
sizeStr.AppendWithConversion("KB");
|
||||
rv = createNode(sizeStr, target, getRDFService());
|
||||
}
|
||||
else
|
||||
@ -1673,7 +1603,7 @@ nsresult nsMsgMessageDataSource::GetUnreadChildrenNode(nsIMsgThread *thread, nsI
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
if(numUnread > 0)
|
||||
rv = createNode(numUnread, target, getRDFService());
|
||||
rv = createIntNode(numUnread, target, getRDFService());
|
||||
else
|
||||
rv = createNode(emptyString, target, getRDFService());
|
||||
}
|
||||
@ -1690,7 +1620,7 @@ nsresult nsMsgMessageDataSource::GetTotalChildrenNode(nsIMsgThread *thread, nsIR
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
if(numChildren > 0)
|
||||
rv = createNode(numChildren, target, getRDFService());
|
||||
rv = createIntNode(numChildren, target, getRDFService());
|
||||
else
|
||||
rv = createNode(emptyString, target, getRDFService());
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ protected:
|
||||
//String bundle:
|
||||
nsCOMPtr<nsIStringBundle> mStringBundle;
|
||||
|
||||
nsresult GetSenderName(const PRUnichar *sender, nsAutoString *senderUserName);
|
||||
nsresult GetSenderName(const PRUnichar *sender, nsAutoString& senderUserName);
|
||||
|
||||
nsresult createMessageNode(nsIMessage *message, nsIRDFResource *property,
|
||||
nsIRDFNode **target);
|
||||
|
||||
@ -88,7 +88,7 @@ nsresult createNode(const PRUnichar *str, nsIRDFNode **node, nsIRDFService *rdfS
|
||||
nsCOMPtr<nsIRDFLiteral> value;
|
||||
|
||||
if (str) {
|
||||
rv = rdfService->GetLiteral(str, getter_AddRefs(value));
|
||||
rv = rdfService->GetLiteral(str, getter_AddRefs(value));
|
||||
} else {
|
||||
PRUnichar blankStr[] = { 0 };
|
||||
rv = rdfService->GetLiteral(blankStr, getter_AddRefs(value));
|
||||
@ -114,15 +114,6 @@ nsresult createNode(nsString& str, nsIRDFNode **node, nsIRDFService *rdfService)
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult createNode(PRUint32 value, nsIRDFNode **node, nsIRDFService *rdfService)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoString str;
|
||||
str.AppendInt((PRInt32)value);
|
||||
rv = createNode(str, node, rdfService);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult createNode(const char* charstr, nsIRDFNode **node, nsIRDFService *rdfService)
|
||||
{
|
||||
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -130,16 +121,13 @@ nsresult createNode(const char* charstr, nsIRDFNode **node, nsIRDFService *rdfSe
|
||||
if (!rdfService) return NS_ERROR_NULL_POINTER;
|
||||
nsCOMPtr<nsIRDFLiteral> value;
|
||||
nsAutoString str; str.AssignWithConversion(charstr);
|
||||
PRUnichar *ucharstr = str.ToNewUnicode();
|
||||
if (ucharstr)
|
||||
{
|
||||
rv = rdfService->GetLiteral(ucharstr, getter_AddRefs(value));
|
||||
|
||||
rv = rdfService->GetLiteral(NS_ConvertUTF8toUCS2(charstr).GetUnicode(), getter_AddRefs(value));
|
||||
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
*node = value;
|
||||
NS_IF_ADDREF(*node);
|
||||
}
|
||||
nsMemory::Free(ucharstr);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
@ -121,9 +121,6 @@ peqCollationSort(nsIRDFResource* r1, nsIRDFResource* r2);
|
||||
nsresult createNode(nsString& str, nsIRDFNode **node, nsIRDFService *rdfService);
|
||||
nsresult createNode(const char*, nsIRDFNode **, nsIRDFService *rdfService);
|
||||
|
||||
//Given a PRUint32, create an nsiIRDFNode.
|
||||
nsresult createNode(PRUint32 value, nsIRDFNode **node, nsIRDFService *rdfService);
|
||||
|
||||
nsresult createNode(const PRUnichar *str, nsIRDFNode **, nsIRDFService *rdfService);
|
||||
|
||||
//Given a PRTime create an nsIRDFNode that is really a date literal.
|
||||
|
||||
@ -130,9 +130,6 @@ nsMsgServiceProviderService::Init()
|
||||
nsXPIDLCString url;
|
||||
ispFile->GetURLString(getter_Copies(url));
|
||||
|
||||
#if defined(DEBUG_alecf) || defined(DEBUG_tao)
|
||||
printf("nsMsgServiceProvider: reading %s\n", (const char*)url);
|
||||
#endif
|
||||
|
||||
rv = LoadDataSource(url);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed reading in the datasource\n");
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
@ -439,7 +439,7 @@ nsMsgIdentity::getFolderPref(const char *prefname, char **retval)
|
||||
nsresult
|
||||
nsMsgIdentity::setFolderPref(const char *prefname, const char *value)
|
||||
{
|
||||
char *oldpref = nsnull;
|
||||
nsXPIDLCString oldpref;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> res;
|
||||
nsCOMPtr<nsIMsgFolder> folder;
|
||||
@ -455,8 +455,8 @@ nsMsgIdentity::setFolderPref(const char *prefname, const char *value)
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = getFolderPref(prefname, &oldpref);
|
||||
if (NS_SUCCEEDED(rv) && oldpref)
|
||||
rv = getFolderPref(prefname, getter_Copies(oldpref));
|
||||
if (NS_SUCCEEDED(rv) && (const char*)oldpref)
|
||||
{
|
||||
rv = rdf->GetResource(oldpref, getter_AddRefs(res));
|
||||
if (NS_SUCCEEDED(rv) && res)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user