本文整理汇总了C++中nsCOMPtr::GetAsciiHost方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCOMPtr::GetAsciiHost方法的具体用法?C++ nsCOMPtr::GetAsciiHost怎么用?C++ nsCOMPtr::GetAsciiHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCOMPtr
的用法示例。
在下文中一共展示了nsCOMPtr::GetAsciiHost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
nsresult
PendingPACQuery::Start(PRUint32 flags)
{
if (mDNSRequest)
return NS_OK; // already started
nsresult rv;
nsCOMPtr<nsIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
NS_WARNING("unable to get the DNS service");
return rv;
}
nsCAutoString host;
rv = mURI->GetAsciiHost(host);
if (NS_FAILED(rv))
return rv;
rv = dns->AsyncResolve(host, flags, this, NS_GetCurrentThread(),
getter_AddRefs(mDNSRequest));
if (NS_FAILED(rv))
NS_WARNING("DNS AsyncResolve failed");
return rv;
}
示例2: OnLDAPInit
NS_IMETHODIMP nsAbQueryLDAPMessageListener::OnLDAPInit(nsILDAPConnection *aConn, nsresult aStatus)
{
nsresult rv;
nsXPIDLString passwd;
// Make sure that the Init() worked properly
NS_ENSURE_SUCCESS(aStatus, aStatus);
if (!mDirectoryQuery)
return NS_ERROR_NULL_POINTER;
// If mLogin is set, we're expected to use it to get a password.
//
if (!mDirectoryQuery->mLogin.IsEmpty()) {
// XXX hack until nsUTF8AutoString exists
#define nsUTF8AutoString nsCAutoString
nsUTF8AutoString spec;
PRBool status;
// we're going to use the URL spec of the server as the "realm" for
// wallet to remember the password by / for.
//
rv = mDirectoryQuery->mDirectoryUrl->GetSpec(spec);
if (NS_FAILED(rv)) {
NS_ERROR("nsAbQueryLDAPMessageListener::OnLDAPInit(): GetSpec"
" failed\n");
return NS_ERROR_FAILURE;
}
// get the string bundle service
//
nsCOMPtr<nsIStringBundleService>
stringBundleSvc(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
if (NS_FAILED(rv)) {
NS_ERROR("nsAbQueryLDAPMessageListener::OnLDAPInit():"
" error getting string bundle service");
return rv;
}
// get the LDAP string bundle
//
nsCOMPtr<nsIStringBundle> ldapBundle;
rv = stringBundleSvc->CreateBundle(
"chrome://mozldap/locale/ldap.properties",
getter_AddRefs(ldapBundle));
if (NS_FAILED(rv)) {
NS_ERROR("nsAbQueryLDAPMessageListener::OnLDAPInit():"
" error creating string bundle"
" chrome://mozldap/locale/ldap.properties");
return rv;
}
// get the title for the authentication prompt
//
nsXPIDLString authPromptTitle;
rv = ldapBundle->GetStringFromName(
NS_LITERAL_STRING("authPromptTitle").get(),
getter_Copies(authPromptTitle));
if (NS_FAILED(rv)) {
NS_ERROR("nsAbQueryLDAPMessageListener::OnLDAPInit():"
"error getting 'authPromptTitle' string from bundle "
"chrome://mozldap/locale/ldap.properties");
return rv;
}
// get the host name for the auth prompt
//
nsCAutoString host;
rv = mUrl->GetAsciiHost(host);
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
// hostTemp is only necessary to work around a code-generation
// bug in egcs 1.1.2 (the version of gcc that comes with Red Hat 6.2),
// which is the default compiler for Mozilla on linux at the moment.
//
NS_ConvertASCIItoUCS2 hostTemp(host);
const PRUnichar *hostArray[1] = { hostTemp.get() };
// format the hostname into the authprompt text string
//
nsXPIDLString authPromptText;
rv = ldapBundle->FormatStringFromName(
NS_LITERAL_STRING("authPromptText").get(),
hostArray, sizeof(hostArray) / sizeof(const PRUnichar *),
getter_Copies(authPromptText));
if (NS_FAILED(rv)) {
NS_ERROR("nsAbQueryLDAPMessageListener::OnLDAPInit():"
"error getting 'authPromptText' string from bundle "
"chrome://mozldap/locale/ldap.properties");
return rv;
}
// get the window watcher service, so we can get an auth prompter
//
nsCOMPtr<nsIWindowWatcher> windowWatcherSvc =
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
//.........这里部分代码省略.........