Create an interface nsINSSComponent that we can use to look up

service for nsNSSComponent from the NSS callbacks.
This commit is contained in:
javi%netscape.com 2001-02-07 19:00:52 +00:00
parent b3db34c62b
commit 614c6cd815
3 changed files with 39 additions and 25 deletions

View File

@ -89,18 +89,14 @@ char* PK11PasswordPrompt(PK11SlotInfo* slot, PRBool retry, void* arg) {
}
nsString promptString;
nsNSSComponent *nssComponent;
nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv));
rv = nsServiceManager::GetService(kNSSComponentCID,
NS_GET_IID(nsISecurityManagerComponent),
(nsISupports**)&nssComponent);
if (NS_FAILED(rv))
return nsnull;
nssComponent->GetPIPNSSBundleString(NS_LITERAL_STRING("CertPassPrompt"),
promptString);
nsServiceManager::ReleaseService(kNSSComponentCID,
(nsISecurityManagerComponent*)nssComponent);
PRUnichar *uniString = promptString.ToNewUnicode();
rv = proxyPrompt->PromptPassword(nsnull, uniString,
NS_LITERAL_STRING(" "),
@ -142,20 +138,13 @@ void HandshakeCallback(PRFileDesc* fd, void* client_data) {
nsXPIDLString shortDesc;
const PRUnichar* formatStrings[1] = { ToNewUnicode(nsLiteralCString(caName)) };
nsNSSComponent *nssComponent;
rv = nsServiceManager::GetService(kNSSComponentCID,
NS_GET_IID(nsISecurityManagerComponent),
(nsISupports**)&nssComponent);
nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv));
if (NS_FAILED(rv))
return;
rv = nssComponent->PIPBundleFormatStringFromName(NS_LITERAL_STRING("SignedBy"),
formatStrings, 1,
getter_Copies(shortDesc));
nsServiceManager::ReleaseService(kNSSComponentCID,
(nsISecurityManagerComponent*)nssComponent);
nsMemory::Free(NS_CONST_CAST(PRUnichar*, formatStrings[0]));

View File

@ -95,7 +95,7 @@ nsNSSComponent::~nsNSSComponent()
#endif /*DEBUG*/
#endif /*XP_MAC*/
nsresult
NS_IMETHODIMP
nsNSSComponent::PIPBundleFormatStringFromName(const PRUnichar *name,
const PRUnichar **params,
PRUint32 numParams,
@ -110,7 +110,7 @@ nsNSSComponent::PIPBundleFormatStringFromName(const PRUnichar *name,
return rv;
}
nsresult
NS_IMETHODIMP
nsNSSComponent::GetPIPNSSBundleString(const PRUnichar *name,
nsString &outString)
{
@ -274,11 +274,12 @@ nsNSSComponent::Init()
}
/* nsISupports Implementation for the class */
NS_IMPL_THREADSAFE_ISUPPORTS4(nsNSSComponent,
NS_IMPL_THREADSAFE_ISUPPORTS5(nsNSSComponent,
nsISecurityManagerComponent,
nsIContentHandler,
nsISignatureVerifier,
nsIEntropyCollector);
nsIEntropyCollector,
nsINSSComponent);
NS_IMETHODIMP

View File

@ -39,11 +39,35 @@
#define NS_NSSCOMPONENT_CID \
{0xa277189c, 0x1dd1, 0x11b2, {0xa8, 0xc9, 0xe4, 0xe8, 0xbf, 0xb1, 0x33, 0x8e}}
//Define an interface that we can use to look up from the
//callbacks passed to NSS.
#define NS_INSSCOMPONENT_IID_STR "d4b49dd6-1dd1-11b2-b6fe-b14cfaf69cbd"
#define NS_INSSCOMPONENT_IID \
{0xd4b49dd6, 0x1dd1, 0x11b2, \
{ 0xb6, 0xfe, 0xb1, 0x4c, 0xfa, 0xf6, 0x9c, 0xbd }}
class NS_NO_VTABLE nsINSSComponent : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_INSSCOMPONENT_IID)
NS_IMETHOD GetPIPNSSBundleString(const PRUnichar *name,
nsString &outString) = 0;
NS_IMETHOD PIPBundleFormatStringFromName(const PRUnichar *name,
const PRUnichar **params,
PRUint32 numParams,
PRUnichar **outString) = 0;
};
// Implementation of the PSM component interface.
class nsNSSComponent : public nsISecurityManagerComponent,
public nsIContentHandler,
public nsISignatureVerifier,
public nsIEntropyCollector
public nsIEntropyCollector,
public nsINSSComponent
{
public:
NS_DEFINE_STATIC_CID_ACCESSOR( NS_NSSCOMPONENT_CID );
@ -59,12 +83,12 @@ public:
NS_METHOD Init();
nsresult GetPIPNSSBundleString(const PRUnichar *name,
nsString &outString);
nsresult PIPBundleFormatStringFromName(const PRUnichar *name,
const PRUnichar **params,
PRUint32 numParams,
PRUnichar **outString);
NS_IMETHOD GetPIPNSSBundleString(const PRUnichar *name,
nsString &outString);
NS_IMETHOD PIPBundleFormatStringFromName(const PRUnichar *name,
const PRUnichar **params,
PRUint32 numParams,
PRUnichar **outString);
nsresult InitializeNSS();
private: