зеркало из https://github.com/mozilla/pjs.git
Bug 113515. Decouple FTP from wallet using the observer service. r=bbaetz, morse, sr=darin
This commit is contained in:
Родитель
ab4fbaa51a
Коммит
20f5a1f648
|
@ -211,7 +211,7 @@ NS_IMETHODIMP nsWalletlibService::SI_SignonViewerReturn(nsAutoString results){
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWalletlibService::Observe(nsISupports*, const char *aTopic, const PRUnichar *someData)
|
||||
NS_IMETHODIMP nsWalletlibService::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
|
||||
{
|
||||
if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
|
||||
WLLT_ClearUserData();
|
||||
|
@ -219,6 +219,27 @@ NS_IMETHODIMP nsWalletlibService::Observe(nsISupports*, const char *aTopic, cons
|
|||
WLLT_DeletePersistentUserData();
|
||||
}
|
||||
}
|
||||
else if (!nsCRT::strcmp(aTopic, "login-succeeded")) {
|
||||
// A login succeeded; store the password.
|
||||
nsCOMPtr<nsIURI> uri = do_QueryInterface(aSubject);
|
||||
if (uri) {
|
||||
nsXPIDLCString spec;
|
||||
uri->GetSpec(getter_Copies(spec));
|
||||
if (spec)
|
||||
SI_StorePassword(spec, nsnull, someData);
|
||||
}
|
||||
}
|
||||
else if (!nsCRT::strcmp(aTopic, "login-failed")) {
|
||||
// A login failed; clean out any information we've stored about
|
||||
// the URL where the failure occurred.
|
||||
nsCOMPtr<nsIURI> uri = do_QueryInterface(aSubject);
|
||||
if (uri) {
|
||||
nsXPIDLCString spec;
|
||||
uri->GetSpec(getter_Copies(spec));
|
||||
if (spec)
|
||||
SI_RemoveUser(spec, nsnull);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -301,6 +322,9 @@ nsresult nsWalletlibService::Init()
|
|||
svc->AddObserver(this, NS_FORMSUBMIT_SUBJECT, PR_TRUE);
|
||||
// Register as an observer of profile changes
|
||||
svc->AddObserver(this, "profile-before-change", PR_TRUE);
|
||||
// Register as an observer for login
|
||||
svc->AddObserver(this, "login-succeeded", PR_TRUE);
|
||||
svc->AddObserver(this, "login-failed", PR_TRUE);
|
||||
}
|
||||
else
|
||||
NS_ASSERTION(PR_FALSE, "Could not get nsIObserverService");
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#include "nsEscape.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIDNSService.h" // for host error code
|
||||
#include "nsIWalletService.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIMemory.h"
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsIPref.h"
|
||||
|
@ -68,7 +68,6 @@
|
|||
#include "nsICacheListener.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kWalletServiceCID, NS_WALLETSERVICE_CID);
|
||||
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kStreamListenerTeeCID, NS_STREAMLISTENERTEE_CID);
|
||||
|
@ -1096,19 +1095,15 @@ nsFtpState::R_pass() {
|
|||
// user limit reached
|
||||
return FTP_ERROR;
|
||||
} else {
|
||||
// XXX turns out that a failed login will _never_ trigger this
|
||||
// code, because a failed login is a 530. Oops. And even when
|
||||
// this code _is_ triggered, it doesn't work very well. See
|
||||
// bug 113515 for more detail.
|
||||
|
||||
// kick back out to S_pass() and ask the user again.
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIWalletService> walletService =
|
||||
do_GetService(kWalletServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return FTP_ERROR;
|
||||
|
||||
nsXPIDLCString uri;
|
||||
rv = mURL->GetSpec(getter_Copies(uri));
|
||||
if (NS_FAILED(rv)) return FTP_ERROR;
|
||||
|
||||
rv = walletService->SI_RemoveUser(uri, nsnull);
|
||||
if (NS_FAILED(rv)) return FTP_ERROR;
|
||||
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
|
||||
if (os)
|
||||
os->NotifyObservers(mURL, "login-failed", nsnull);
|
||||
|
||||
mRetryPass = PR_TRUE;
|
||||
return FTP_S_PASS;
|
||||
|
|
Загрузка…
Ссылка в новой задаче