wallet_Initialize();
wallet_Initialize(PR_TRUE);
WLLT_RequestToCapture(nsIPresShell* shell) {  /* starting with the present shell, get each form element and put them on a list */  nsresult result;  if (nsnull != shell) {    nsIDocument* doc = nsnull;    result = shell->GetDocument(&doc);    if (NS_SUCCEEDED(result)) {      wallet_Initialize();      if (!Wallet_KeySet()) {        NS_RELEASE(doc);        NS_RELEASE(shell);        return;      }      wallet_InitializeCurrentURL(doc);      nsIDOMHTMLDocument* htmldoc = nsnull;      result = doc->QueryInterface(kIDOMHTMLDocumentIID, (void**)&htmldoc);      if ((NS_SUCCEEDED(result)) && (nsnull != htmldoc)) {        nsIDOMHTMLCollection* forms = nsnull;        htmldoc->GetForms(&forms);        if (nsnull != forms) {          PRUint32 numForms;          forms->GetLength(&numForms);          for (PRUint32 formX = 0; formX < numForms; formX++) {            nsIDOMNode* formNode = nsnull;            forms->Item(formX, &formNode);            if (nsnull != formNode) {              PRInt32 count = 0;              nsIDOMHTMLFormElement* formElement = nsnull;              result = formNode->QueryInterface(kIDOMHTMLFormElementIID, (void**)&formElement);              if ((NS_SUCCEEDED(result)) && (nsnull != formElement)) {                nsIDOMHTMLCollection* elements = nsnull;                result = formElement->GetElements(&elements);                if ((NS_SUCCEEDED(result)) && (nsnull != elements)) {                  /* got to the form elements at long last */                  /* now find out how many text fields are on the form */                  PRUint32 numElements;                  elements->GetLength(&numElements);                  for (PRUint32 elementX = 0; elementX < numElements; elementX++) {                    nsIDOMNode* elementNode = nsnull;                    elements->Item(elementX, &elementNode);                    if (nsnull != elementNode) {                      nsIDOMHTMLInputElement* inputElement;                        result =                        elementNode->QueryInterface(kIDOMHTMLInputElementIID, (void**)&inputElement);                      if ((NS_SUCCEEDED(result)) && (nsnull != inputElement)) {                        nsAutoString type;                        result = inputElement->GetType(type);                        if (NS_SUCCEEDED(result)) {                          PRBool isText = ((type == "") || (type.Compare("text", PR_TRUE)==0));                          if (isText) {                            count++;                          }                        }                        NS_RELEASE(inputElement);                      }                      NS_RELEASE(elementNode);                    }                  }                  /* save form if it meets all necessary conditions */                  if (wallet_GetFormsCapturingPref() && (count>=3)) {                    /* conditions all met, now save it */                    for (PRUint32 elementY = 0; elementY < numElements; elementY++) {                      nsIDOMNode* elementNode = nsnull;                      elements->Item(elementY, &elementNode);                      if (nsnull != elementNode) {                        nsIDOMHTMLInputElement* inputElement;                          result =                          elementNode->QueryInterface(kIDOMHTMLInputElementIID, (void**)&inputElement);                        if ((NS_SUCCEEDED(result)) && (nsnull != inputElement)) {                          /* it's an input element */                          nsAutoString type;                          result = inputElement->GetType(type);                          if ((NS_SUCCEEDED(result)) &&                              ((type =="") || (type.Compare("text", PR_TRUE) == 0))) {                            nsAutoString field;                            result = inputElement->GetName(field);                            if (NS_SUCCEEDED(result)) {                              nsAutoString value;                              result = inputElement->GetValue(value);                              if (NS_SUCCEEDED(result)) {                                /* get schema name from vcard attribute if it exists */                                nsAutoString vcardValue("");                                nsIDOMElement * element;                                result = elementNode->QueryInterface(kIDOMElementIID, (void**)&element);                                if ((NS_SUCCEEDED(result)) && (nsnull != element)) {                                  nsAutoString vcardName("VCARD_NAME");                                  result = element->GetAttribute(vcardName, vcardValue);                                  NS_RELEASE(element);                                }                                wallet_Capture(doc, field, value, vcardValue);                              }                            }                          }                          NS_RELEASE(inputElement);                        }                        NS_RELEASE(elementNode);                      }                    }                  }                  NS_RELEASE(elements);                }                NS_RELEASE(formElement);              }              NS_RELEASE(formNode);            }          }          NS_RELEASE(forms);        }        NS_RELEASE(htmldoc);      }      NS_RELEASE(doc);    }    NS_RELEASE(shell);  }}