void nsBox::AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult) { aResult.Append(aAttribute); aResult.AppendLiteral("='"); aResult.Append(aValue); aResult.AppendLiteral("' "); }
NS_IMETHODIMP nsHTMLFormatConverter::ConvertFromHTMLToAOLMail(const nsAutoString & aFromStr, nsAutoString & aToStr) { aToStr.AssignLiteral("<HTML>"); aToStr.Append(aFromStr); aToStr.AppendLiteral("</HTML>"); return NS_OK; }
void nsBox::ListBox(nsAutoString& aResult) { nsAutoString name; GetBoxName(name); char addr[100]; sprintf(addr, "[@%p] ", static_cast<void*>(this)); aResult.AppendASCII(addr); aResult.Append(name); aResult.AppendLiteral(" "); nsIContent* content = GetContent(); // add on all the set attributes if (content) { nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content)); nsCOMPtr<nsIDOMNamedNodeMap> namedMap; node->GetAttributes(getter_AddRefs(namedMap)); PRUint32 length; namedMap->GetLength(&length); nsCOMPtr<nsIDOMNode> attribute; for (PRUint32 i = 0; i < length; ++i) { namedMap->Item(i, getter_AddRefs(attribute)); nsCOMPtr<nsIDOMAttr> attr(do_QueryInterface(attribute)); attr->GetName(name); nsAutoString value; attr->GetValue(value); AppendAttribute(name, value, aResult); } } }
nsresult nsNSSCertificate::FormatUIStrings(const nsAutoString &nickname, nsAutoString &nickWithSerial, nsAutoString &details) { if (!NS_IsMainThread()) { NS_ERROR("nsNSSCertificate::FormatUIStrings called off the main thread"); return NS_ERROR_NOT_SAME_THREAD; } nsresult rv = NS_OK; nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv)); if (NS_FAILED(rv) || !nssComponent) { return NS_ERROR_FAILURE; } nsAutoString info; nsAutoString temp1; nickWithSerial.Append(nickname); if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertInfoIssuedFor", info))) { details.Append(info); details.Append(PRUnichar(' ')); if (NS_SUCCEEDED(GetSubjectName(temp1)) && !temp1.IsEmpty()) { details.Append(temp1); } details.Append(PRUnichar('\n')); } if (NS_SUCCEEDED(GetSerialNumber(temp1)) && !temp1.IsEmpty()) { details.AppendLiteral(" "); if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertDumpSerialNo", info))) { details.Append(info); details.AppendLiteral(": "); } details.Append(temp1); nickWithSerial.AppendLiteral(" ["); nickWithSerial.Append(temp1); nickWithSerial.Append(PRUnichar(']')); details.Append(PRUnichar('\n')); } nsCOMPtr<nsIX509CertValidity> validity; rv = GetValidity(getter_AddRefs(validity)); if (NS_SUCCEEDED(rv) && validity) { details.AppendLiteral(" "); if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertInfoValid", info))) { details.Append(info); } if (NS_SUCCEEDED(validity->GetNotBeforeLocalTime(temp1)) && !temp1.IsEmpty()) { details.Append(PRUnichar(' ')); if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertInfoFrom", info))) { details.Append(info); details.Append(PRUnichar(' ')); } details.Append(temp1); } if (NS_SUCCEEDED(validity->GetNotAfterLocalTime(temp1)) && !temp1.IsEmpty()) { details.Append(PRUnichar(' ')); if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertInfoTo", info))) { details.Append(info); details.Append(PRUnichar(' ')); } details.Append(temp1); } details.Append(PRUnichar('\n')); } if (NS_SUCCEEDED(GetKeyUsagesString(mCert, nssComponent, temp1)) && !temp1.IsEmpty()) { details.AppendLiteral(" "); if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertDumpKeyUsage", info))) { details.Append(info); details.AppendLiteral(": "); } details.Append(temp1); details.Append(PRUnichar('\n')); } nsAutoString firstEmail; const char *aWalkAddr; for (aWalkAddr = CERT_GetFirstEmailAddress(mCert) ; aWalkAddr ; aWalkAddr = CERT_GetNextEmailAddress(mCert, aWalkAddr)) { NS_ConvertUTF8toUTF16 email(aWalkAddr); if (email.IsEmpty()) continue; if (firstEmail.IsEmpty()) { /* * If the first email address from the subject DN is also present * in the subjectAltName extension, GetEmailAddresses() will return * it twice (as received from NSS). Remember the first address so that * we can filter out duplicates later on. */ firstEmail = email; details.AppendLiteral(" "); if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertInfoEmail", info))) { details.Append(info); details.AppendLiteral(": "); } details.Append(email); } else { // Append current address if it's different from the first one. if (!firstEmail.Equals(email)) { details.AppendLiteral(", "); details.Append(email); } } } if (!firstEmail.IsEmpty()) { // We got at least one email address, so we want a newline details.Append(PRUnichar('\n')); } if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertInfoIssuedBy", info))) { details.Append(info); details.Append(PRUnichar(' ')); if (NS_SUCCEEDED(GetIssuerName(temp1)) && !temp1.IsEmpty()) { details.Append(temp1); } details.Append(PRUnichar('\n')); } if (NS_SUCCEEDED(nssComponent->GetPIPNSSBundleString("CertInfoStoredIn", info))) { details.Append(info); details.Append(PRUnichar(' ')); if (NS_SUCCEEDED(GetTokenName(temp1)) && !temp1.IsEmpty()) { details.Append(temp1); } } /* the above produces the following output: Issued to: $subjectName Serial number: $serialNumber Valid from: $starting_date to $expiration_date Certificate Key usage: $usages Email: $address(es) Issued by: $issuerName Stored in: $token */ return rv; }