value_array[value_cnt] = value.ToNewCString(); name_array[value_cnt] = field.ToNewCString(); value_cnt++;
nsAutoString field; result = inputElement->GetName(field); if (NS_SUCCEEDED(result)) { value_array[value_cnt] = value.ToNewCString(); name_array[value_cnt] = field.ToNewCString(); value_cnt++; }
WLLT_OnSubmit(nsIContent* formNode) {  /* get url name as ascii string */  char *URLName = nsnull;  nsCOMPtr<nsIURI> docURL;  nsCOMPtr<nsIDocument> doc;  formNode->GetDocument(*getter_AddRefs(doc));  if (!doc) {    return;  }  docURL = dont_AddRef(doc->GetDocumentURL());  if (!docURL) {    return;  }  (void)docURL->GetSpec(&URLName);  /* get to the form elements */  PRInt32 count = 0;  nsIDOMHTMLFormElement* formElement = nsnull;  nsresult 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)) {      char* name_array[MAX_ARRAY_SIZE];      char* value_array[MAX_ARRAY_SIZE];      uint8 type_array[MAX_ARRAY_SIZE];      PRInt32 value_cnt = 0;      /* got to the form elements at long last */      /* now build arrays for single signon */      /* also 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));              PRBool isPassword = (type.Compare("password", PR_TRUE)==0);              if (isText) {                count++;              }              if (value_cnt < MAX_ARRAY_SIZE) {                if (isText) {                  type_array[value_cnt] = FORM_TYPE_TEXT;                } else if (isPassword) {                  type_array[value_cnt] = FORM_TYPE_PASSWORD;                }                nsAutoString value;                result = inputElement->GetValue(value);                if (NS_SUCCEEDED(result)) {                  nsAutoString field;                  result = inputElement->GetName(field);                  if (NS_SUCCEEDED(result)) {                    value_array[value_cnt] = value.ToNewCString();                    name_array[value_cnt] = field.ToNewCString();                    value_cnt++;                  }                }              }            }            NS_RELEASE(inputElement);          }          NS_RELEASE(elementNode);        }      }      /* save login if appropriate */      SINGSIGN_RememberSignonData        (URLName, (char**)name_array, (char**)value_array, (char**)type_array, value_cnt);#ifndef AutoCapture      /* give notification if this is first significant form submitted */      if ((count>=3) && !wallet_GetWalletNotificationPref()) {        /* conditions all met, now give notification */        PRUnichar * notification = Wallet_Localize("WalletNotification");        wallet_SetWalletNotificationPref(PR_TRUE);        Wallet_Alert(notification);        Recycle(notification);      }#else      /* save form if it meets all necessary conditions */      if (wallet_GetFormsCapturingPref() && (count>=3) && wallet_OKToCapture(URLName)) {        /* 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);          }        }      }#endif      NS_RELEASE(elements);    }    NS_RELEASE(formElement);  }  nsCRT::free(URLName);}