fix for #26413 - new accounts were picking up old accounts's values, so clear them all out of the prefs r=putterman

This commit is contained in:
alecf%netscape.com 2000-02-11 00:55:54 +00:00
Родитель 28b1afa12e
Коммит 0611ca4bef
10 изменённых файлов: 106 добавлений и 7 удалений

Просмотреть файл

@ -59,6 +59,8 @@ interface nsIMsgAccount : nsISupports {
/* remove an identity from this account (probably does not work) */
void removeIdentity(in nsIMsgIdentity identity);
void clearAllValues();
/* name in javascript */
wstring toString();
};

Просмотреть файл

@ -93,6 +93,12 @@ interface nsIMsgIdentity : nsISupports {
* to ask the user to complete all the fields
*/
attribute boolean valid;
/**
* this is really dangerous. this destroys all pref values
* do not call this unless you know what you're doing!
*/
void clearAllValues();
wstring toString();
};

Просмотреть файл

@ -139,6 +139,12 @@ interface nsIMsgIncomingServer : nsISupports {
nsIFileSpec getFileValue(in string attr);
void setFileValue(in string attr, in nsIFileSpec value);
/**
* this is really dangerous. this destroys all pref values
* do not call this unless you know what you're doing!
*/
void clearAllValues();
attribute boolean valid;
wstring toString();

Просмотреть файл

@ -354,3 +354,21 @@ nsMsgAccount::ToString(PRUnichar **aResult)
}
NS_IMETHODIMP
nsMsgAccount::ClearAllValues()
{
nsresult rv;
nsCAutoString rootPref("mail.account.");
rootPref += m_accountKey;
rv = m_prefs->EnumerateChildren(rootPref, clearPrefEnum, (void *)m_prefs);
return rv;
}
void
nsMsgAccount::clearPrefEnum(const char *aPref, void *aClosure)
{
nsIPref *prefs = (nsIPref *)aClosure;
prefs->ClearUserPref(aPref);
}

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
@ -45,5 +45,7 @@ private:
nsresult getPrefService();
nsresult createIncomingServer();
nsresult createIdentities();
static void clearPrefEnum(const char *aPref, void *aClosure);
};

Просмотреть файл

@ -502,7 +502,33 @@ nsMsgAccountManager::RemoveAccount(nsIMsgAccount *aAccount)
NS_IF_RELEASE(removedServer);
NotifyServerUnloaded(server);
// now clear out the server once and for all.
// watch out! could be scary
server->ClearAllValues();
}
nsCOMPtr<nsISupportsArray> identityArray;
rv = aAccount->GetIdentities(getter_AddRefs(identityArray));
if (NS_SUCCEEDED(rv)) {
PRUint32 count=0;
identityArray->Count(&count);
PRUint32 i;
for (i=0; i<count; i++) {
nsCOMPtr<nsIMsgIdentity> identity;
rv = identityArray->QueryElementAt(i, NS_GET_IID(nsIMsgIdentity),
(void **)getter_AddRefs(identity));
if (NS_SUCCEEDED(rv))
// clear out all identity information.
// watch out! could be scary
identity->ClearAllValues();
}
}
aAccount->ClearAllValues();
return NS_OK;
}

Просмотреть файл

@ -374,6 +374,26 @@ nsMsgIdentity::SetSignature(nsIFileSpec *sig)
return NS_OK;
}
NS_IMETHODIMP
nsMsgIdentity::ClearAllValues()
{
nsresult rv;
nsCAutoString rootPref("mail.identity.");
rootPref += m_identityKey;
rv = m_prefs->EnumerateChildren(rootPref, clearPrefEnum, (void *)m_prefs);
return rv;
}
void
nsMsgIdentity::clearPrefEnum(const char *aPref, void *aClosure)
{
nsIPref *prefs = (nsIPref *)aClosure;
prefs->ClearUserPref(aPref);
}
NS_IMPL_GETSET(nsMsgIdentity, VCard, nsIMsgVCard*, m_vCard);
NS_IMPL_GETTER_STR(nsMsgIdentity::GetKey, m_identityKey);

Просмотреть файл

@ -27,12 +27,6 @@
#include "nsIPref.h"
#include "msgCore.h"
///////////////////////////////////////////////////////////////////////////////////
// an identity is an object designed to encapsulate all the information we need
// to know about a user identity. I expect this interface to grow and change a lot
// as we flesh out our thoughts on multiple identities and what properties go into
// these identities.
//////////////////////////////////////////////////////////////////////////////////
class NS_MSG_BASE nsMsgIdentity : public nsIMsgIdentity
@ -71,6 +65,9 @@ protected:
nsresult getDefaultIntPref(const char *pref, PRInt32 *);
nsresult setIntPref(const char *pref, PRInt32);
private:
static void clearPrefEnum(const char *aPref, void *aClosure);
};

Просмотреть файл

@ -750,6 +750,26 @@ nsMsgIncomingServer::Equals(nsIMsgIncomingServer *server, PRBool *_retval)
return rv;
}
NS_IMETHODIMP
nsMsgIncomingServer::ClearAllValues()
{
nsresult rv;
nsCAutoString rootPref("mail.server.");
rootPref += m_serverKey;
rv = m_prefs->EnumerateChildren(rootPref, clearPrefEnum, (void *)m_prefs);
return rv;
}
void
nsMsgIncomingServer::clearPrefEnum(const char *aPref, void *aClosure)
{
nsIPref *prefs = (nsIPref *)aClosure;
prefs->ClearUserPref(aPref);
}
// use the convenience macros to implement the accessors
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, HostName, "hostname");
NS_IMPL_SERVERPREF_INT(nsMsgIncomingServer, Port, "port");

Просмотреть файл

@ -73,6 +73,8 @@ protected:
nsresult CreateRootFolder();
// pref callback to clear the user prefs
static void clearPrefEnum(const char *aPref, void *aClosure);
};
#endif // nsMsgIncomingServer_h__