if (NS_FAILED(EncryptString(plainText, crypt))) {
if (NS_FAILED(Wallet_Encrypt(value, sublistPtr->item))) {
wallet_ReencryptAll(const char * newpref, void* window) {  PRUnichar * message;  /* prevent reentry for the case that the user doesn't supply correct master password */  if (gReencryptionLevel != 0) {    return 0; /* this is PREF_NOERROR but we no longer include prefapi.h */  }  gReencryptionLevel ++;  PRInt32 count = LIST_COUNT(wallet_SchemaToValue_list);  PRInt32 i = 0;  char* plainText = nsnull;  /* logout first so there is no conversion unless user knows the master password */if (!changingPassword) {  nsresult rv = wallet_CryptSetup();  if (NS_SUCCEEDED(rv)) {    rv = gSecretDecoderRing->Logout();  }  if (NS_FAILED(rv)) {    goto fail;  }  wallet_Initialize();}  wallet_MapElement * mapElementPtr;  gEncryptionFailure = PR_FALSE;  for (i=0; i<count && !gEncryptionFailure; i++) {    mapElementPtr = NS_STATIC_CAST(wallet_MapElement*, wallet_SchemaToValue_list->ElementAt(i));    char * crypt = nsnull;    if (!WALLET_NULL(mapElementPtr->item2)) {      if (NS_FAILED(DecryptString(mapElementPtr->item2, plainText))) {        goto fail;      }      if (NS_FAILED(EncryptString(plainText, crypt))) {        goto fail;      }      mapElementPtr->item2 = crypt;    } 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));        if (NS_FAILED(DecryptString(sublistPtr->item, plainText))) {          goto fail;        }        if (NS_FAILED(EncryptString(plainText, crypt))) {          goto fail;        }        sublistPtr->item = crypt;      }    }  }  wallet_WriteToFile(schemaValueFileName, wallet_SchemaToValue_list);  if (!SINGSIGN_ReencryptAll()) {    goto fail;  }  /* force a rewriting of prefs.js to make sure pref_Crypto got updated   *   *   Note: In the event of a crash after changing this pref (either way), the user   *   could get misled as to what state his storage was in.  If the crash occurred    *   after changing to encrypted, he could think he was encrypting in the future (because   *   he remembered changed to encypting at one time) but his new values are only being   *   obscurred.  If the crash occurred after changing to obscured, later on he might   *   think his store was encrypted (because he checked the pref panel and that's what   *   it told him) whereas some of the earlier values are actually obscured and so not   *   protected.  For both these reasons, we force this rewriting of the prefs file now.   */  SI_SetBoolPref(pref_Crypto, SI_GetBoolPref(pref_Crypto, PR_TRUE));//  message = Wallet_Localize("Converted");//  wallet_Alert(message, (nsIDOMWindowInternal *)window);//  WALLET_FREE(message);  gReencryptionLevel--;  return 0; /* this is PREF_NOERROR but we no longer include prefapi.h */fail:  /* toggle the pref back to its previous value */  SI_SetBoolPref(pref_Crypto, !SI_GetBoolPref(pref_Crypto, PR_TRUE));  /* alert the user to the failure */  message = Wallet_Localize("NotConverted");  wallet_Alert(message, (nsIDOMWindowInternal *)window);  WALLET_FREE(message);  gReencryptionLevel--;  return 1;}