NS_RELEASE(inputElement);
WLLT_RequestToCapture(nsIPresShell* shell) {  /* starting with the present shell, get each form element and put them on a list */  nsresult result;  PRInt32 captureCount = 0;  gEncryptionFailure = PR_FALSE;  if (nsnull != shell) {    nsIDocument* doc = nsnull;    result = shell->GetDocument(&doc);    if (NS_SUCCEEDED(result)) {      wallet_Initialize(PR_TRUE);      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) && !gEncryptionFailure; formX++) {            nsIDOMNode* formNode = nsnull;            forms->Item(formX, &formNode);            if (nsnull != formNode) {              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 elementY = 0; (elementY < numElements) && !gEncryptionFailure; 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.IsEmpty() || (type.CompareWithConversion("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; vcardName.AssignWithConversion("VCARD_NAME");                                result = element->GetAttribute(vcardName, vcardValue);                                NS_RELEASE(element);                              }                              captureCount++;                              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);    }  }  PRUnichar * message;  if (gEncryptionFailure) {    message = Wallet_Localize("UnableToCapture");  } else if (captureCount) {    message = Wallet_Localize("Captured");  } else {    message = Wallet_Localize("NotCaptured");  }  Wallet_Alert(message);  Recycle(message);}