Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
wallet.h File Reference
#include "prtypes.h"
#include "nsIPresShell.h"
#include "nsString.h"
#include "nsIPrompt.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define HEADER_VERSION   "#2c"
#define YES_BUTTON   0
#define NO_BUTTON   1
#define NEVER_BUTTON   2
#define pref_Crypto   "wallet.crypto"
#define pref_AutoCompleteOverride   "wallet.crypto.autocompleteoverride"

Functions

void WLLT_ChangePassword (PRBool *status)
void WLLT_DeleteAll ()
void WLLT_ClearUserData ()
void WLLT_DeletePersistentUserData ()
void WLLT_PreEdit (nsAString &walletList)
void WLLT_PostEdit (const nsAString &walletList)
void WLLT_PrefillReturn (const nsAString &results)
void WLLT_RequestToCapture (nsIPresShell *shell, nsIDOMWindowInternal *win, PRUint32 *status)
nsresult WLLT_PrefillOneElement (nsIDOMWindowInternal *win, nsIDOMNode *elementNode, nsAString &compositeValue)
nsresult WLLT_Prefill (nsIPresShell *shell, PRBool quick, nsIDOMWindowInternal *win)
void WLLT_GetNopreviewListForViewer (nsAString &aNopreviewList)
void WLLT_GetNocaptureListForViewer (nsAString &aNocaptureList)
void WLLT_GetPrefillListForViewer (nsAString &aPrefillList)
void WLLT_OnSubmit (nsIContent *formNode, nsIDOMWindowInternal *window)
void WLLT_ExpirePassword (PRBool *status)
void WLLT_ExpirePasswordOnly (PRBool *status)
void WLLT_InitReencryptCallback (nsIDOMWindowInternal *window)
nsresult Wallet_Encrypt (const nsAString &text, nsAString &crypt)
nsresult Wallet_Decrypt (const nsAString &crypt, nsAString &text)
nsresult wallet_GetLine (nsIInputStream *strm, nsACString &line)
void wallet_PutLine (nsIOutputStream *strm, const char *line)
 Writes a line to a stream, including a newline character.
nsresult Wallet_ProfileDirectory (nsIFile **aFile)
 Gets the current profile directory.
PRUnicharWallet_Localize (const char *genericString)
char * Wallet_RandomName (char *suffix)
PRBool Wallet_ConfirmYN (PRUnichar *szMessage, nsIDOMWindowInternal *window)
PRInt32 Wallet_3ButtonConfirm (PRUnichar *szMessage, nsIDOMWindowInternal *window)
void Wallet_GiveCaveat (nsIDOMWindowInternal *window, nsIPrompt *dialog)
void Wallet_SignonViewerReturn (const nsAString &results)
void Wallet_ReleaseAllLists ()

Define Documentation

#define HEADER_VERSION   "#2c"

Definition at line 60 of file wallet.h.

Definition at line 64 of file wallet.h.

#define NO_BUTTON   1

Definition at line 63 of file wallet.h.

#define pref_AutoCompleteOverride   "wallet.crypto.autocompleteoverride"

Definition at line 67 of file wallet.h.

#define pref_Crypto   "wallet.crypto"

Definition at line 66 of file wallet.h.

#define YES_BUTTON   0

Definition at line 62 of file wallet.h.


Function Documentation

Definition at line 514 of file wallet.cpp.

{
  nsresult res;
  nsCOMPtr<nsIPrompt> dialog;
  window->GetPrompter(getter_AddRefs(dialog));
  if (!dialog) {
    return 0; /* default value is NO */
  } 

  PRInt32 buttonPressed = 1; /* default of NO if user exits dialog by clickin X */
  PRUnichar * never_string = Wallet_Localize("Never");
  PRUnichar * confirm_string = Wallet_Localize("Confirm");

  res = dialog->ConfirmEx(confirm_string, szMessage,
                          nsIPrompt::BUTTON_POS_1_DEFAULT +
                          (nsIPrompt::BUTTON_TITLE_YES * nsIPrompt::BUTTON_POS_0) +
                          (nsIPrompt::BUTTON_TITLE_NO * nsIPrompt::BUTTON_POS_1) +
                          (nsIPrompt::BUTTON_TITLE_IS_STRING * nsIPrompt::BUTTON_POS_2),
                          nsnull, nsnull, never_string, nsnull, nsnull, &buttonPressed);

  WALLET_FREE(never_string);
  WALLET_FREE(confirm_string);

  return buttonPressed;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool Wallet_ConfirmYN ( PRUnichar szMessage,
nsIDOMWindowInternal window 
)

Definition at line 493 of file wallet.cpp.

                                                                      {
  nsresult res;
  nsCOMPtr<nsIPrompt> dialog;
  window->GetPrompter(getter_AddRefs(dialog));
  if (!dialog) {
    return PR_FALSE;
  } 

  PRInt32 buttonPressed = 1; /* in case user exits dialog by clickin X */
  PRUnichar * confirm_string = Wallet_Localize("Confirm");

  res = dialog->ConfirmEx(confirm_string, szMessage,
                          (nsIPrompt::BUTTON_TITLE_YES * nsIPrompt::BUTTON_POS_0) +
                          (nsIPrompt::BUTTON_TITLE_NO * nsIPrompt::BUTTON_POS_1),
                          nsnull, nsnull, nsnull, nsnull, nsnull, &buttonPressed);

  WALLET_FREE(confirm_string);
  return (buttonPressed == 0);
}

Here is the call graph for this function:

nsresult Wallet_Decrypt ( const nsAString &  crypt,
nsAString &  text 
)

Definition at line 783 of file wallet.cpp.

                                                                {
  nsCAutoString textUTF8;
  nsresult rv = wallet_Decrypt(NS_ConvertUCS2toUTF8(cryptUCS2), textUTF8);
  CopyUTF8toUTF16(textUTF8, textUCS2);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult Wallet_Encrypt ( const nsAString &  text,
nsAString &  crypt 
)

Definition at line 775 of file wallet.cpp.

                                                                 {
  nsCAutoString cryptUTF8;
  nsresult rv = wallet_Encrypt(NS_ConvertUCS2toUTF8(textUCS2), cryptUTF8);
  CopyUTF8toUTF16(cryptUTF8, cryptUCS2);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult wallet_GetLine ( nsIInputStream strm,
nsACString &  line 
)

Definition at line 1099 of file wallet.cpp.

{
  line.Truncate();
  
  nsCOMPtr<nsILineInputStream> lis(do_QueryInterface(strm));
  NS_ENSURE_TRUE(lis, NS_ERROR_UNEXPECTED);

  PRBool more;
  nsresult rv = lis->ReadLine(line, &more);
  if (NS_FAILED(rv))
    return rv;

  // Assume that we are past EOF if more==FALSE and line is empty
  // this may be wrong if the file ends with an empty line, though
  if (!more && line.IsEmpty())
    return NS_ERROR_FAILURE;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Wallet_GiveCaveat ( nsIDOMWindowInternal window,
nsIPrompt dialog 
)

Definition at line 1353 of file wallet.cpp.

                                                                   {
  /* test for first capturing of data ever and give caveat if so */
  if (!SI_GetBoolPref(pref_Caveat, PR_FALSE)) {
    SI_SetBoolPref(pref_Caveat, PR_TRUE);
    PRUnichar * message = Wallet_Localize("Caveat");
    if (window) {
      wallet_Alert(message, window);
    } else {
      wallet_Alert(message, dialog);
    }
    WALLET_FREE(message);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRUnichar* Wallet_Localize ( const char *  genericString)

Definition at line 424 of file wallet.cpp.

                                           {
  nsresult ret;
  nsAutoString v;

  /* create a bundle for the localization */
  nsCOMPtr<nsIStringBundleService> pStringService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &ret);
  if (NS_FAILED(ret)) {
#ifdef DEBUG
    printf("cannot get string service\n");
#endif
    return ToNewUnicode(v);
  }
  nsCOMPtr<nsIStringBundle> bundle;
  ret = pStringService->CreateBundle(PROPERTIES_URL, getter_AddRefs(bundle));
  if (NS_FAILED(ret)) {
#ifdef DEBUG
    printf("cannot create instance\n");
#endif
    return ToNewUnicode(v);
  }

  /* localize the given string */
  NS_ConvertASCIItoUTF16 strtmp(genericString);
  PRUnichar *ptrv = nsnull;
  ret = bundle->GetStringFromName(strtmp.get(), &ptrv);
  if (NS_FAILED(ret)) {
#ifdef DEBUG
    printf("cannot get string from name\n");
#endif
    return ToNewUnicode(v);
  }
  v = ptrv;
  nsCRT::free(ptrv);

  /* convert # to newlines */
  PRUint32 i;
  for (i=0; i<v.Length(); i++) {
    if (v.CharAt(i) == '#') {
      v.SetCharAt('\n', i);
    }
  }

  return ToNewUnicode(v);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Gets the current profile directory.

Definition at line 1060 of file wallet.cpp.

                                                  {
  /* return the profile */
  return NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, aFile);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void wallet_PutLine ( nsIOutputStream strm,
const char *  line 
)

Writes a line to a stream, including a newline character.

parameter should not include '
'

Definition at line 1145 of file wallet.cpp.

                                                        {
  PRUint32 dummy;
  strm->Write(line, strlen(line), &dummy);
  wallet_EndLine(strm);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* Wallet_RandomName ( char *  suffix)

Definition at line 1080 of file wallet.cpp.

{
  /* pick the current time as the random number */
  time_t curTime = time(NULL);

  /* take 8 least-significant digits + three-digit suffix as the file name */
  char name[13];
  PR_snprintf(name, 13, "%lu.%s", ((int)curTime%100000000), suffix);
  return PL_strdup(name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2246 of file wallet.cpp.

                         {
    wallet_Clear(&wallet_FieldToSchema_list); /* otherwise we will duplicate the list */
    wallet_Clear(&wallet_VcardToSchema_list); /* otherwise we will duplicate the list */
    wallet_Clear(&wallet_SchemaConcat_list); /* otherwise we will duplicate the list */
    wallet_Clear(&wallet_SchemaStrings_list); /* otherwise we will duplicate the list */
    wallet_Clear(&wallet_PositionalSchema_list); /* otherwise we will duplicate the list */
    wallet_Clear(&wallet_StateSchema_list); /* otherwise we will duplicate the list */
    wallet_Clear(&wallet_DistinguishedSchema_list); /* otherwise we will duplicate the list */
    wallet_DeallocateMapElements();
    delete helpMac;
    helpMac = nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Wallet_SignonViewerReturn ( const nsAString &  results)

Definition at line 2504 of file wallet.cpp.

{
    wallet_MapElement *url;
    nsAutoString gone;
    char oldPermissionChar;

    /* step through all nopreviews and delete those that are in the sequence */
    {
      SI_FindValueInArgs(results, NS_LITERAL_STRING("|goneP|"), gone);
    }
    PRInt32 count = LIST_COUNT(wallet_URL_list);
    while (count>0) {
      count--;
      url = NS_STATIC_CAST(wallet_MapElement*, wallet_URL_list->ElementAt(count));
      if (url && SI_InSequence(gone, count)) {
        /* clear the NO_PREVIEW indicator */
        oldPermissionChar = NO_CAPTURE(url->item2);
        WALLET_FREEIF (url->item2);
        if (oldPermissionChar == 'y') {
          url->item2 = PL_strdup(permission_NoCapture_Preview);
        } else {
          url->item2 = PL_strdup(permission_Capture_Preview);
        }
        if (!PL_strcmp(url->item2, permission_Capture_Preview)) {
          wallet_FreeURL(url);
        }
        wallet_WriteToFile(URLFileName, wallet_URL_list);
      }
    }

    /* step through all nocaptures and delete those that are in the sequence */
    {
      SI_FindValueInArgs(results, NS_LITERAL_STRING("|goneC|"), gone);
    }
    PRInt32 count2 = LIST_COUNT(wallet_URL_list);
    while (count2>0) {
      count2--;
      url = NS_STATIC_CAST(wallet_MapElement*, wallet_URL_list->ElementAt(count2));
      if (url && SI_InSequence(gone, count2)) {
        /* clear the NO_CAPTURE indicator */
        oldPermissionChar = NO_PREVIEW(url->item2);
        WALLET_FREEIF (url->item2);
        if (oldPermissionChar == 'y') {
          url->item2 = PL_strdup(permission_Capture_NoPreview);
        } else {
          url->item2 = PL_strdup(permission_Capture_Preview);
        }
        if (!PL_strcmp(url->item2, permission_Capture_Preview)) {
          wallet_FreeURL(url);
        }
        wallet_WriteToFile(URLFileName, wallet_URL_list);
      }
    }
}

Here is the call graph for this function:

Definition at line 735 of file wallet.cpp.

Here is the call graph for this function:

Definition at line 2875 of file wallet.cpp.

Here is the call graph for this function:

Definition at line 2890 of file wallet.cpp.

Here is the call graph for this function:

Definition at line 716 of file wallet.cpp.

                                    {
  if (gSecretDecoderRing) {
    gSecretDecoderRing->LogoutAndTeardown();
  }
  *status = PR_TRUE;
}

Definition at line 724 of file wallet.cpp.

                                        {
  nsresult rv = wallet_CryptSetup();
  if (NS_SUCCEEDED(rv)) {
    rv = gSecretDecoderRing->Logout();
  }
  *status = NS_SUCCEEDED(rv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WLLT_GetNocaptureListForViewer ( nsAString &  aNocaptureList)

Definition at line 2752 of file wallet.cpp.

{
  nsAutoString buffer;
  wallet_MapElement *url;

  wallet_InitializeURLList();
  PRInt32 count = LIST_COUNT(wallet_URL_list);
  for (PRInt32 i=0; i<count; i++) {
    url = NS_STATIC_CAST(wallet_MapElement*, wallet_URL_list->ElementAt(i));
    if (NO_CAPTURE(url->item2) == 'y') {
      buffer.Append(BREAK);
      AppendUTF8toUTF16(url->item1, buffer);
    }
  }
  aNocaptureList = buffer;
}

Here is the call graph for this function:

void WLLT_GetNopreviewListForViewer ( nsAString &  aNopreviewList)

Definition at line 2733 of file wallet.cpp.

{
  wallet_Initialize(PR_FALSE); /* to initialize helpMac */
  nsAutoString buffer;
  wallet_MapElement *url;

  wallet_InitializeURLList();
  PRInt32 count = LIST_COUNT(wallet_URL_list);
  for (PRInt32 i=0; i<count; i++) {
    url = NS_STATIC_CAST(wallet_MapElement*, wallet_URL_list->ElementAt(i));
    if (NO_PREVIEW(url->item2) == 'y') {
      buffer.Append(BREAK);
      AppendUTF8toUTF16(url->item1, buffer);
    }
  }
  aNopreviewList = buffer;
}

Here is the call graph for this function:

void WLLT_GetPrefillListForViewer ( nsAString &  aPrefillList)

Definition at line 2467 of file wallet.cpp.

{
  wallet_Initialize(PR_FALSE); /* to initialize helpMac */
  wallet_PrefillElement * prefillElementPtr;
  nsAutoString buffer;
  PRInt32 count = LIST_COUNT(wallet_list);
  for (PRInt32 i=0; i<count; i++) {
    prefillElementPtr = NS_STATIC_CAST(wallet_PrefillElement*, wallet_list->ElementAt(i));
    buffer.Append(BREAK);
    buffer.AppendInt(prefillElementPtr->count,10);
    buffer.Append(BREAK);
    AppendUTF8toUTF16(prefillElementPtr->schema, buffer);
    buffer.Append(BREAK);
    buffer.Append(prefillElementPtr->value);
  }

  buffer.Append(BREAK);
  buffer += wallet_url;
  aPrefillList = buffer;
}

Here is the call graph for this function:

Definition at line 2991 of file wallet.cpp.

                                                         {
  static PRBool registered = PR_FALSE;
  static nsIDOMWindowInternal* lastWindow;
  if (registered) {
    SI_UnregisterCallback(pref_Crypto, wallet_ReencryptAll, lastWindow);
  }
  SI_RegisterCallback(pref_Crypto, wallet_ReencryptAll, window);
  lastWindow = window;
  registered = PR_TRUE;
}

Here is the call graph for this function:

void WLLT_OnSubmit ( nsIContent formNode,
nsIDOMWindowInternal window 
)

Definition at line 3612 of file wallet.cpp.

                                                                     {

  nsCOMPtr<nsIDOMHTMLFormElement> currentFormNode(do_QueryInterface(currentForm));

  /* get url name as ascii string */
  nsAutoString strippedURLNameUCS2;
  nsCOMPtr<nsIDocument> doc = currentForm->GetDocument();
  if (!doc) {
    return;
  }
  nsIURI *docURL = doc->GetDocumentURI();
  if (!docURL) {
    return;
  }
  wallet_GetHostFile(docURL, strippedURLNameUCS2);
  NS_ConvertUTF16toUTF8 strippedURLNameUTF8(strippedURLNameUCS2);

  /* get to the form elements */
  nsCOMPtr<nsIDOMHTMLDocument> htmldoc(do_QueryInterface(doc));
  if (htmldoc == nsnull) {
    return;
  }

  nsCOMPtr<nsIDOMHTMLCollection> forms;
  nsresult rv = htmldoc->GetForms(getter_AddRefs(forms));
  if (NS_FAILED(rv) || (forms == nsnull)) {
    return;
  }

  PRUint32 numForms;
  forms->GetLength(&numForms);
  for (PRUint32 formX = 0; formX < numForms; formX++) {
    nsCOMPtr<nsIDOMNode> formNode;
    forms->Item(formX, getter_AddRefs(formNode));
    if (nsnull != formNode) {
      nsCOMPtr<nsIDOMHTMLFormElement> formElement(do_QueryInterface(formNode));
      if ((nsnull != formElement)) {
        nsCOMPtr<nsIDOMHTMLCollection> elements;
        rv = formElement->GetElements(getter_AddRefs(elements));
        if ((NS_SUCCEEDED(rv)) && (nsnull != elements)) {
          /* got to the form elements at long last */ 
          nsVoidArray * signonData = new nsVoidArray();
          si_SignonDataStruct * data;
          PRUint32 numElements;
          elements->GetLength(&numElements);
          PRBool OKToPrompt = PR_FALSE;
          PRInt32 passwordcount = 0;
          PRInt32 hits = 0;
          wallet_Initialize(PR_FALSE);
          wallet_InitializeCurrentURL(doc);
          wallet_InitializeStateTesting();
          PRBool newValueFound = PR_FALSE;
          for (PRUint32 elementX = 0; elementX < numElements; elementX++) {
            nsCOMPtr<nsIDOMNode> elementNode;
            elements->Item(elementX, getter_AddRefs(elementNode));
            if (nsnull != elementNode) {
              nsCOMPtr<nsIDOMHTMLSelectElement> selectElement(do_QueryInterface(elementNode));
              if ((NS_SUCCEEDED(rv)) && (nsnull != selectElement)) {
                if (passwordcount == 0 && !newValueFound && !OKToPrompt) {
                  nsAutoString valueOnForm;
                  rv = selectElement->GetValue(valueOnForm);
                  if (NS_SUCCEEDED(rv) && wallet_IsNewValue (elementNode, valueOnForm)) {
                    newValueFound = PR_TRUE;
                    if (hits > 1) {
                      OKToPrompt = PR_TRUE;
                    }
                  }
                }
              }
              nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(elementNode));
              if ((NS_SUCCEEDED(rv)) && (nsnull != inputElement)) {
                nsAutoString type;
                rv = inputElement->GetType(type);
                if (NS_SUCCEEDED(rv)) {

                  PRBool isText = (type.IsEmpty() || type.LowerCaseEqualsLiteral("text"));
                  PRBool isPassword = type.LowerCaseEqualsLiteral("password");

                  // don't save password if field was left blank
                  if (isPassword) {
                    nsAutoString val;
                    (void) inputElement->GetValue(val);
                    if (val.IsEmpty()) {
                      isPassword = PR_FALSE;
                    }
                  }

                  // Do not store this 'password' form element if the 'autocomplete = off'
                  // attribute is present, unless the 'wallet.crypto.autocompleteoverride'
                  // preference is enabled. (The "autocomplete" property is a Microsoft
                  // extension to HTML.)
                  if (isPassword && !SI_GetBoolPref(pref_AutoCompleteOverride, PR_FALSE)) {
                    nsAutoString val;
                    (void) inputElement->GetAttribute(NS_LITERAL_STRING("autocomplete"), val);
                    if (val.LowerCaseEqualsLiteral("off")) {
                      isPassword = PR_FALSE;
                    } else {
                      (void) formElement->GetAttribute(NS_LITERAL_STRING("autocomplete"), val);
                      if (val.LowerCaseEqualsLiteral("off")) {
                        isPassword = PR_FALSE;
                      }
                    }
                  }

                  if (isPassword) {
                    passwordcount++;
                    OKToPrompt = PR_FALSE;
                  }

                  if (isText) {
                    if (passwordcount == 0 && !newValueFound && !OKToPrompt) {
                      nsAutoString valueOnForm;
                      rv = inputElement->GetValue(valueOnForm);
                      if (NS_SUCCEEDED(rv) && wallet_IsNewValue (elementNode, valueOnForm)) {
                        newValueFound = PR_TRUE;
                        if (hits > 1) {
                          OKToPrompt = PR_TRUE;
                        }
                      }
                    }
                  }

                  if (isText || isPassword) {
                    nsAutoString value;
                    rv = inputElement->GetValue(value);
                    if (NS_SUCCEEDED(rv)) {
                      nsAutoString field;
                      rv = inputElement->GetName(field);
                      if (NS_SUCCEEDED(rv)) {
                        data = new si_SignonDataStruct;
                        data->value = value;
                        if (!field.IsEmpty() && field.CharAt(0) == '\\') {
                          /*
                           * Note that data saved for browser-generated logins (e.g. http
                           * authentication) use artificial field names starting with
                           * \= (see USERNAMEFIELD and PASSWORDFIELD in singsign.cpp).  To
                           * avoid mistakes whereby saved logins for http authentication is
                           * then prefilled into a field on the html form at the same URL,
                           * we will prevent html field names from starting with \=.  We
                           * do that by doubling up a backslash if it appears in the first
                           * character position
                           */
                          data->name = nsAutoString('\\');
                          data->name.Append(field);

                        } else {
                          data->name = field;
                        }
                        data->isPassword = isPassword;
                        signonData->AppendElement(data);
                        if (passwordcount == 0 && !OKToPrompt) {
                          /* get schema from field */
                          nsCAutoString schema;
                          nsVoidArray* dummy;
                          nsCAutoString stripField;

                          /* try to get schema from displayable text */
                          if (schema.IsEmpty()) {
                            wallet_GetSchemaFromDisplayableText(inputElement, schema, PR_FALSE);
                          }

                          /* no schema found, so try to get it from field name */
                          if (schema.IsEmpty()) {
                            Strip(field, stripField);
                            wallet_ReadFromList
                              (stripField, schema, 
                               dummy, wallet_FieldToSchema_list, PR_FALSE);
                          }

                          /* if schema found, see if it is in distinguished schema list */
                          if (!schema.IsEmpty()) {
                            /* see if schema is in distinguished list */
                            wallet_MapElement * mapElementPtr;
                            PRInt32 count = LIST_COUNT(wallet_DistinguishedSchema_list);
                            /* test for at least two distinguished schemas and no passwords */
                            for (PRInt32 i=0; i<count; i++) {
                              mapElementPtr = NS_STATIC_CAST
                                (wallet_MapElement*, wallet_DistinguishedSchema_list->ElementAt(i));
                                  if (schema.Equals(mapElementPtr->item1, nsCaseInsensitiveCStringComparator()) && !value.IsEmpty()) {
                                hits++;
                                if (hits > 1 && newValueFound) {
                                  OKToPrompt = PR_TRUE;
                                  break;
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }

          /* save login if appropriate */
          if (currentFormNode == formNode) {
            nsCOMPtr<nsIPrompt> dialog;
            nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
            if (wwatch)
              wwatch->GetNewPrompter(0, getter_AddRefs(dialog));

            if (dialog) {
              SINGSIGN_RememberSignonData(dialog, docURL, signonData, window);
            }
          }
          PRInt32 count2 = signonData->Count();
          for (PRInt32 i=count2-1; i>=0; i--) {
            data = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(i));
            delete data;
          }
          delete signonData;

          /* save form if it meets all necessary conditions */
          if (wallet_GetFormsCapturingPref() &&
              (OKToPrompt) && wallet_OKToCapture(strippedURLNameUTF8, window)) {

            /* give caveat if this is the first time data is being captured */
            Wallet_GiveCaveat(window, nsnull);
  
            /* conditions all met, now save it */
            for (PRUint32 elementY = 0; elementY < numElements; elementY++) {
              nsIDOMNode* elementNode = nsnull;
              elements->Item(elementY, &elementNode);
              if (nsnull != elementNode) {
                wallet_CaptureInputElement(elementNode, doc);
                wallet_CaptureSelectElement(elementNode, doc);
              }
            }
          }
        }
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WLLT_PostEdit ( const nsAString &  walletList)

Definition at line 2770 of file wallet.cpp.

{
  nsCOMPtr<nsIFile> file;
  nsresult rv = Wallet_ProfileDirectory(getter_AddRefs(file));
  if (NS_FAILED(rv)) {
    return;
  }

  nsAutoString tail( walletList );
  nsAutoString head, temp;
  PRInt32 separator;

  /* get first item in list */
  separator = tail.FindChar(BREAK);
  if (-1 == separator) {
    return;
  }
  tail.Left(head, separator);
  tail.Mid(temp, separator+1, tail.Length() - (separator+1));
  tail = temp;

  /* return if OK button was not pressed */
  if (!head.EqualsLiteral("OK")) {
    return;
  }

  file->AppendNative(nsDependentCString(schemaValueFileName));

  /* open SchemaValue file */
  nsCOMPtr<nsIOutputStream> fileOutputStream;
  rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(fileOutputStream),
                                       file,
                                       -1,
                                       0600);
  if (NS_FAILED(rv))
    return;

  nsCOMPtr<nsIOutputStream> strm;
  rv = NS_NewBufferedOutputStream(getter_AddRefs(strm), fileOutputStream, 4096);
  if (NS_FAILED(rv))
    return;

  /* write the values in the walletList to the file */
  wallet_PutHeader(strm);
  for (;;) {
    separator = tail.FindChar(BREAK);
    if (-1 == separator) {
      break;
    }
    tail.Left(head, separator);
    tail.Mid(temp, separator+1, tail.Length() - (separator+1));
    tail = temp;

    wallet_PutLine(strm, NS_ConvertUCS2toUTF8(head).get());
  }

  /* close the file and read it back into the SchemaToValue list */
  // All went ok. Maybe except for problems in Write(), but the stream detects
  // that for us
  nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(strm);
  NS_ASSERTION(safeStream, "expected a safe output stream!");
  if (safeStream) {
    rv = safeStream->Finish();
    if (NS_FAILED(rv)) {
      NS_WARNING("failed to save wallet file! possible dataloss");
      return;
    }
  }

  strm = nsnull;
  fileOutputStream = nsnull;

  wallet_Clear(&wallet_SchemaToValue_list);
  wallet_ReadFromFile(schemaValueFileName, wallet_SchemaToValue_list, PR_TRUE);
}

Here is the call graph for this function:

void WLLT_PreEdit ( nsAString &  walletList)

Definition at line 2847 of file wallet.cpp.

{
  wallet_Initialize();
  walletList.Assign(BREAK);
  wallet_MapElement * mapElementPtr;
  PRInt32 count = LIST_COUNT(wallet_SchemaToValue_list);
  for (PRInt32 i=0; i<count; i++) {
    mapElementPtr = NS_STATIC_CAST(wallet_MapElement*, wallet_SchemaToValue_list->ElementAt(i));

    AppendUTF8toUTF16(mapElementPtr->item1, walletList);
    walletList.Append(BREAK);
    if (!WALLET_NULL(mapElementPtr->item2)) {
      AppendUTF8toUTF16(mapElementPtr->item2, walletList);
      walletList.Append(BREAK);
    } else {
      wallet_Sublist * sublistPtr;
      PRInt32 count2 = LIST_COUNT(mapElementPtr->itemList);
      for (PRInt32 i2=0; i2<count2; i2++) {
        sublistPtr = NS_STATIC_CAST(wallet_Sublist*, mapElementPtr->itemList->ElementAt(i2));
        AppendUTF8toUTF16(sublistPtr->item, walletList);
        walletList.Append(BREAK);
      }
    }
    walletList.Append(BREAK);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult WLLT_Prefill ( nsIPresShell shell,
PRBool  quick,
nsIDOMWindowInternal win 
)

Definition at line 3301 of file wallet.cpp.

{
  /* do not prefill if preview window is open in some other browser window */
  if (wallet_list) {
    return NS_ERROR_FAILURE;
  }

  /* create list of elements that can be prefilled */
  nsVoidArray *wallet_PrefillElement_list=new nsVoidArray();
  if (!wallet_PrefillElement_list) {
    return NS_ERROR_FAILURE;
  }

  nsAutoString urlName;
  gEncryptionFailure = PR_FALSE;
  wallet_TraversalForPrefill(win, wallet_PrefillElement_list, urlName);

  /* return if no elements were put into the list */
  if (LIST_COUNT(wallet_PrefillElement_list) == 0) {
    if (!gEncryptionFailure) {
      PRUnichar * message = Wallet_Localize("noPrefills");
      wallet_Alert(message, win);
      WALLET_FREE(message);
    }

    // Shouldn't wallet_PrefillElement_list be deleted here?

    return NS_ERROR_FAILURE; // indicates to caller not to display preview screen
  }

  /* prefill each element using the list */

  /* determine if url is on list of urls that should not be previewed */
  PRBool noPreview = PR_FALSE;
  if (!quick) {
    wallet_InitializeURLList();
    nsVoidArray* dummy;
    nsCAutoString urlPermissions;
    if (!urlName.IsEmpty()) {
      wallet_ReadFromList
        (NS_ConvertUCS2toUTF8(urlName), urlPermissions, dummy, wallet_URL_list, PR_FALSE);
      noPreview = (NO_PREVIEW(urlPermissions) == 'y');
    }
  }

  /* determine if preview is necessary */
  if (noPreview || quick) {
    /* prefill each element without any preview for user verification */
    wallet_PrefillElement * mapElementPtr;
    PRInt32 count = LIST_COUNT(wallet_PrefillElement_list);
    for (PRInt32 i=0; i<count; i++) {
      mapElementPtr = NS_STATIC_CAST(wallet_PrefillElement*, wallet_PrefillElement_list->ElementAt(i));
      if (mapElementPtr->count) {
        if (mapElementPtr->inputElement) {
          mapElementPtr->inputElement->SetValue(mapElementPtr->value);
        } else {
          mapElementPtr->selectElement->SetSelectedIndex(mapElementPtr->selectIndex);
        }
      }
    }
    /* go thru list just generated and release everything */
    wallet_ReleasePrefillElementList(wallet_PrefillElement_list);
    return NS_ERROR_FAILURE; // indicates to caller not to display preview screen
  } else {
    /* let user preview and verify the prefills first */
    wallet_list = wallet_PrefillElement_list;
    nsMemory::Free(wallet_url); 
    wallet_url = ToNewUnicode(urlName);
#ifdef DEBUG_morse


//wallet_DumpTiming();
//wallet_ClearTiming();
#endif
    return NS_OK; // indicates that caller is to display preview screen
  }
}

Here is the call graph for this function:

nsresult WLLT_PrefillOneElement ( nsIDOMWindowInternal win,
nsIDOMNode elementNode,
nsAString &  compositeValue 
)

Definition at line 3265 of file wallet.cpp.

{
  nsIDOMHTMLInputElement* inputElement;
  nsIDOMHTMLSelectElement* selectElement;
  nsCAutoString schema;
  nsString value;
  PRInt32 selectIndex = 0;
  PRInt32 index = 0;

  if (nsnull != win) {
    nsCOMPtr<nsIDOMDocument> domdoc;
    nsresult result = win->GetDocument(getter_AddRefs(domdoc));
    if (NS_SUCCEEDED(result)) {
      nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
      if (doc) {
        wallet_Initialize(PR_TRUE);
        wallet_InitializeCurrentURL(doc);
        wallet_InitializeStateTesting();
        while (NS_SUCCEEDED(wallet_GetPrefills
            (elementNode,
            inputElement,
            selectElement,
            schema,
            value,
            selectIndex,
            index))) {
          compositeValue.Append(BREAK);
          compositeValue.Append(value);
        }
      }
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

void WLLT_PrefillReturn ( const nsAString &  results)

Definition at line 3012 of file wallet.cpp.

{
  nsAutoString fillins;
  nsAutoString urlName;
  nsAutoString skip;
  nsAutoString next;

  /* get values that are in environment variables */
  SI_FindValueInArgs(results, NS_LITERAL_STRING("|fillins|"), fillins);
  SI_FindValueInArgs(results, NS_LITERAL_STRING("|skip|"), skip);
  SI_FindValueInArgs(results, NS_LITERAL_STRING("|url|"), urlName);
  wallet_DecodeVerticalBars(fillins);
  wallet_DecodeVerticalBars(urlName);

  /* add url to url list if user doesn't want to preview this page in the future */
  if (skip.EqualsLiteral("true")) {
    NS_ConvertUTF16toUTF8 url(urlName);
    nsVoidArray* dummy;
    nsCAutoString urlPermissions("nn");
    wallet_ReadFromList(url, urlPermissions, dummy, wallet_URL_list, PR_FALSE);
    /* add URL to list with NO_PREVIEW indicator set */
    if (NO_CAPTURE(urlPermissions) == 'y') {
      urlPermissions = permission_NoCapture_NoPreview;
    } else {
      urlPermissions = permission_Capture_NoPreview;
    }
    if (wallet_WriteToList(url.get(), urlPermissions.get(), dummy, wallet_URL_list, PR_FALSE, DUP_OVERWRITE)) {
      wallet_WriteToFile(URLFileName, wallet_URL_list);

      /* Notify signon manager dialog to update its display */
      nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
      if (os) {
        os->NotifyObservers(nsnull, "signonChanged", NS_LITERAL_STRING("nopreviews").get());
      }
    }
  }

  /* process the list, doing the fillins */
  if (fillins.Length() == 0) { /* user pressed CANCEL */
    wallet_ReleasePrefillElementList(wallet_list);
    wallet_list = nsnull;
    nsMemory::Free(wallet_url);
    wallet_url = nsnull;
    return;
  }

  /*
   * note: there are two lists involved here and we are stepping through both of them.
   * One is the pre-fill list that was generated when we walked through the html content.
   * For each pre-fillable item, it contains n entries, one for each possible value that
   * can be prefilled for that field.  The first entry for each field can be identified
   * because it has a non-zero count field (in fact, the count is the number of entries
   * for that field), all subsequent entries for the same field have a zero count field.
   * The other is the fillin list which was generated by the html dialog that just
   * finished.  It contains one entry for each pre-fillable item specificying that
   * particular value that should be prefilled for that item.
   */

  wallet_PrefillElement * mapElementPtr;
  /* step through pre-fill list */
  PRInt32 count = LIST_COUNT(wallet_list);
  for (PRInt32 i=0; i<count; i++) {
    mapElementPtr = NS_STATIC_CAST(wallet_PrefillElement*, wallet_list->ElementAt(i));

    /* advance in fillins list each time a new schema name in pre-fill list is encountered */
    if (mapElementPtr->count != 0) {
      /* count != 0 indicates a new schema name */
      nsAutoString tail;
      if (NS_FAILED(wallet_GetNextInString(fillins, next, tail))) {
        break;
      }
      fillins = tail;
      if (PL_strcmp(NS_ConvertUCS2toUTF8(next).get(), mapElementPtr->schema)) {
        break; /* something's wrong so stop prefilling */
      }
      wallet_GetNextInString(fillins, next, tail);
      fillins = tail;
    }
    if (next == mapElementPtr->value) {
      /*
       * Remove entry from wallet_SchemaToValue_list and then reinsert.  This will
       * keep multiple values in that list for the same field ordered with
       * most-recently-used first.  That's useful since the first such entry
       * is the default value used for pre-filling.
       */
      /*
       * Test for mapElementPtr->count being zero is an optimization that avoids us from doing a
       * reordering if the current entry already was first
       */
      if (mapElementPtr->count == 0) {
        nsCAutoString oldvalueUTF8;
        PRInt32 index = 0;
        PRInt32 lastIndex = index;
        nsVoidArray* dummy;
        while(wallet_ReadFromList(nsDependentCString(mapElementPtr->schema),
                                  oldvalueUTF8,
                                  dummy,
                                  wallet_SchemaToValue_list,
                                  PR_TRUE,
                                  index)) {
          if (oldvalueUTF8.Equals(NS_ConvertUCS2toUTF8(mapElementPtr->value).get())) {
            wallet_MapElement * mapElement =
              (wallet_MapElement *) (wallet_SchemaToValue_list->ElementAt(lastIndex));
            wallet_SchemaToValue_list->RemoveElementAt(lastIndex);
            wallet_WriteToList(
              mapElement->item1,
              mapElement->item2,
              mapElement->itemList,
              wallet_SchemaToValue_list,
              PR_FALSE); /* note: obscure=false, otherwise we will obscure an obscured value */
            delete mapElement;
            break;
          }
          lastIndex = index;
        }
      }
    }

    /* Change the value */

    if (!next.IsEmpty()) {
      if (mapElementPtr->inputElement) {
        mapElementPtr->inputElement->SetValue(next);
      } else {
        nsresult result;
        result = wallet_GetSelectIndex(mapElementPtr->selectElement, next, mapElementPtr->selectIndex);
        if (NS_SUCCEEDED(result)) {
          mapElementPtr->selectElement->SetSelectedIndex(mapElementPtr->selectIndex);
        } else {
          mapElementPtr->selectElement->SetSelectedIndex(0);
        }
      }
    }
  }

  /* Release the prefill list that was generated when we walked thru the html content */
  wallet_ReleasePrefillElementList(wallet_list);
  wallet_list = nsnull;
  nsMemory::Free(wallet_url);
  wallet_url = nsnull;
}

Here is the call graph for this function:

Definition at line 3568 of file wallet.cpp.

                                                                                        {

  PRInt32 captureCount = 0;
  gEncryptionFailure = PR_FALSE;
  wallet_TraversalForRequestToCapture(win, captureCount);

  PRUnichar * message;
  if (gEncryptionFailure) {
    message = Wallet_Localize("UnableToCapture");
    *status = 0;
  } else if (captureCount) {
    /* give caveat if this is the first time data is being captured */
    Wallet_GiveCaveat(win, nsnull);
    message = Wallet_Localize("Captured");
    *status = 0;
  } else {
    message = Wallet_Localize("NotCaptured");
    *status = +1;
  }
  wallet_Alert(message, win);
  WALLET_FREE(message);
}

Here is the call graph for this function: