diff --git a/mozilla/extensions/wallet/editor/nsIWalletEditor.idl b/mozilla/extensions/wallet/editor/nsIWalletEditor.idl index 41115b4b797..c2b6857efd7 100644 --- a/mozilla/extensions/wallet/editor/nsIWalletEditor.idl +++ b/mozilla/extensions/wallet/editor/nsIWalletEditor.idl @@ -35,8 +35,8 @@ [scriptable, uuid(0A904580-1C88-11d3-ABA9-0080C787AD96)] interface nsIWalletEditor : nsISupports { - void SetValue(in string aValue, in nsIDOMWindow win); - string GetValue(); + void SetValue(in wstring aValue, in nsIDOMWindow win); + wstring GetValue(); }; diff --git a/mozilla/extensions/wallet/editor/nsWalletEditor.cpp b/mozilla/extensions/wallet/editor/nsWalletEditor.cpp index e3b612da0aa..ec0ae9011ed 100644 --- a/mozilla/extensions/wallet/editor/nsWalletEditor.cpp +++ b/mozilla/extensions/wallet/editor/nsWalletEditor.cpp @@ -49,7 +49,7 @@ WalletEditorImpl::~WalletEditorImpl() NS_IMPL_ISUPPORTS1(WalletEditorImpl, nsIWalletEditor); NS_IMETHODIMP -WalletEditorImpl::GetValue(char** aValue) +WalletEditorImpl::GetValue(PRUnichar** aValue) { NS_PRECONDITION(aValue != nsnull, "null ptr"); if (!aValue) { @@ -61,7 +61,7 @@ WalletEditorImpl::GetValue(char** aValue) nsAutoString walletList; res = walletservice->WALLET_PreEdit(walletList); if (NS_SUCCEEDED(res)) { - *aValue = walletList.ToNewCString(); + *aValue = walletList.ToNewUnicode(); } return res; } @@ -86,7 +86,7 @@ static void DOMWindowToWebShellWindow( } NS_IMETHODIMP -WalletEditorImpl::SetValue(const char* aValue, nsIDOMWindow* win) +WalletEditorImpl::SetValue(const PRUnichar* aValue, nsIDOMWindow* win) { /* close the window */ if (!win) { diff --git a/mozilla/extensions/wallet/public/nsIWalletService.h b/mozilla/extensions/wallet/public/nsIWalletService.h index 25888116b64..6ef7ba1bc78 100644 --- a/mozilla/extensions/wallet/public/nsIWalletService.h +++ b/mozilla/extensions/wallet/public/nsIWalletService.h @@ -66,13 +66,13 @@ struct nsIWalletService : public nsISupports NS_IMETHOD PromptURL (const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **result, const char *urlname, nsIPrompt* dialog, PRBool *_retval) = 0; - NS_IMETHOD SI_RemoveUser(const char *URLName, char *userName) = 0; + NS_IMETHOD SI_RemoveUser(const char *URLName, PRUnichar *userName) = 0; - NS_IMETHOD WALLET_GetNopreviewListForViewer(nsString& aNopreviewList) = 0; - NS_IMETHOD WALLET_GetNocaptureListForViewer(nsString& aNocaptureList) = 0; - NS_IMETHOD WALLET_GetPrefillListForViewer(nsString& aPrefillList) = 0; - NS_IMETHOD SI_GetSignonListForViewer(nsString& aSignonList) = 0; - NS_IMETHOD SI_GetRejectListForViewer(nsString& aRejectList) = 0; + NS_IMETHOD WALLET_GetNopreviewListForViewer(nsAutoString& aNopreviewList) = 0; + NS_IMETHOD WALLET_GetNocaptureListForViewer(nsAutoString& aNocaptureList) = 0; + NS_IMETHOD WALLET_GetPrefillListForViewer(nsAutoString& aPrefillList) = 0; + NS_IMETHOD SI_GetSignonListForViewer(nsAutoString& aSignonList) = 0; + NS_IMETHOD SI_GetRejectListForViewer(nsAutoString& aRejectList) = 0; NS_IMETHOD SI_SignonViewerReturn(nsAutoString results) = 0; }; diff --git a/mozilla/extensions/wallet/signonviewer/nsISignonViewer.idl b/mozilla/extensions/wallet/signonviewer/nsISignonViewer.idl index 7604a770b16..908f89f7b14 100644 --- a/mozilla/extensions/wallet/signonviewer/nsISignonViewer.idl +++ b/mozilla/extensions/wallet/signonviewer/nsISignonViewer.idl @@ -35,11 +35,11 @@ [scriptable, uuid(C425FAE0-20F0-11d3-ABAA-0080C787AD96)] interface nsISignonViewer : nsISupports { - void SetValue(in string aValue, in nsIDOMWindow win); - string GetSignonValue(); - string GetRejectValue(); - string GetNopreviewValue(); - string GetNocaptureValue(); + void SetValue(in wstring aValue, in nsIDOMWindow win); + wstring GetSignonValue(); + wstring GetRejectValue(); + wstring GetNopreviewValue(); + wstring GetNocaptureValue(); }; %{ C++ diff --git a/mozilla/extensions/wallet/signonviewer/nsSignonViewer.cpp b/mozilla/extensions/wallet/signonviewer/nsSignonViewer.cpp index f74d4bd4966..c9527995704 100644 --- a/mozilla/extensions/wallet/signonviewer/nsSignonViewer.cpp +++ b/mozilla/extensions/wallet/signonviewer/nsSignonViewer.cpp @@ -50,7 +50,7 @@ SignonViewerImpl::~SignonViewerImpl() NS_IMPL_ISUPPORTS(SignonViewerImpl, NS_GET_IID(nsISignonViewer)); NS_IMETHODIMP -SignonViewerImpl::GetSignonValue(char** aValue) +SignonViewerImpl::GetSignonValue(PRUnichar** aValue) { NS_PRECONDITION(aValue != nsnull, "null ptr"); if (!aValue) { @@ -62,13 +62,13 @@ SignonViewerImpl::GetSignonValue(char** aValue) nsAutoString signonList; res = walletservice->SI_GetSignonListForViewer(signonList); if (NS_SUCCEEDED(res)) { - *aValue = signonList.ToNewCString(); + *aValue = signonList.ToNewUnicode(); } return res; } NS_IMETHODIMP -SignonViewerImpl::GetRejectValue(char** aValue) +SignonViewerImpl::GetRejectValue(PRUnichar** aValue) { NS_PRECONDITION(aValue != nsnull, "null ptr"); if (!aValue) { @@ -80,13 +80,13 @@ SignonViewerImpl::GetRejectValue(char** aValue) nsAutoString rejectList; res = walletservice->SI_GetRejectListForViewer(rejectList); if (NS_SUCCEEDED(res)) { - *aValue = rejectList.ToNewCString(); + *aValue = rejectList.ToNewUnicode(); } return res; } NS_IMETHODIMP -SignonViewerImpl::GetNopreviewValue(char** aValue) +SignonViewerImpl::GetNopreviewValue(PRUnichar** aValue) { NS_PRECONDITION(aValue != nsnull, "null ptr"); if (!aValue) { @@ -98,13 +98,13 @@ SignonViewerImpl::GetNopreviewValue(char** aValue) nsAutoString nopreviewList; res = walletservice->WALLET_GetNopreviewListForViewer(nopreviewList); if (NS_SUCCEEDED(res)) { - *aValue = nopreviewList.ToNewCString(); + *aValue = nopreviewList.ToNewUnicode(); } return res; } NS_IMETHODIMP -SignonViewerImpl::GetNocaptureValue(char** aValue) +SignonViewerImpl::GetNocaptureValue(PRUnichar** aValue) { NS_PRECONDITION(aValue != nsnull, "null ptr"); if (!aValue) { @@ -116,13 +116,13 @@ SignonViewerImpl::GetNocaptureValue(char** aValue) nsAutoString nocaptureList; res = walletservice->WALLET_GetNocaptureListForViewer(nocaptureList); if (NS_SUCCEEDED(res)) { - *aValue = nocaptureList.ToNewCString(); + *aValue = nocaptureList.ToNewUnicode(); } return res; } NS_IMETHODIMP -SignonViewerImpl::SetValue(const char* aValue, nsIDOMWindow* win) +SignonViewerImpl::SetValue(const PRUnichar* aValue, nsIDOMWindow* win) { /* process the value */ NS_PRECONDITION(aValue != nsnull, "null ptr"); diff --git a/mozilla/extensions/wallet/src/nsWalletService.cpp b/mozilla/extensions/wallet/src/nsWalletService.cpp index 7c725a31c4b..f7d412fba8c 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.cpp +++ b/mozilla/extensions/wallet/src/nsWalletService.cpp @@ -130,33 +130,33 @@ NS_IMETHODIMP nsWalletlibService::PromptURL return ::SINGSIGN_Prompt(text, defaultText, resultText, urlname, dialog, returnValue); } -NS_IMETHODIMP nsWalletlibService::SI_RemoveUser(const char *URLName, char *userName) { +NS_IMETHODIMP nsWalletlibService::SI_RemoveUser(const char *URLName, PRUnichar *userName) { ::SINGSIGN_RemoveUser(URLName, userName); return NS_OK; } -NS_IMETHODIMP nsWalletlibService::WALLET_GetNopreviewListForViewer(nsString& aNopreviewList){ +NS_IMETHODIMP nsWalletlibService::WALLET_GetNopreviewListForViewer(nsAutoString& aNopreviewList){ ::WLLT_GetNopreviewListForViewer(aNopreviewList); return NS_OK; } -NS_IMETHODIMP nsWalletlibService::WALLET_GetNocaptureListForViewer(nsString& aNocaptureList){ +NS_IMETHODIMP nsWalletlibService::WALLET_GetNocaptureListForViewer(nsAutoString& aNocaptureList){ ::WLLT_GetNocaptureListForViewer(aNocaptureList); return NS_OK; } -NS_IMETHODIMP nsWalletlibService::WALLET_GetPrefillListForViewer(nsString& aPrefillList){ +NS_IMETHODIMP nsWalletlibService::WALLET_GetPrefillListForViewer(nsAutoString& aPrefillList){ ::WLLT_GetPrefillListForViewer(aPrefillList); return NS_OK; } -NS_IMETHODIMP nsWalletlibService::SI_GetSignonListForViewer(nsString& aSignonList){ +NS_IMETHODIMP nsWalletlibService::SI_GetSignonListForViewer(nsAutoString& aSignonList){ ::SINGSIGN_GetSignonListForViewer(aSignonList); return NS_OK; } -NS_IMETHODIMP nsWalletlibService::SI_GetRejectListForViewer(nsString& aRejectList){ +NS_IMETHODIMP nsWalletlibService::SI_GetRejectListForViewer(nsAutoString& aRejectList){ ::SINGSIGN_GetRejectListForViewer(aRejectList); return NS_OK; } @@ -301,9 +301,9 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* ch nsAutoString field; rv = inputElement->GetName(field); if (NS_SUCCEEDED(rv)) { - char* nameString = field.ToNewCString(); + PRUnichar* nameString = field.ToNewUnicode(); if (nameString) { - char* valueString = NULL; + PRUnichar* valueString = NULL; SINGSIGN_RestoreSignonData(URLName, nameString, &valueString, elementNumber++); if (valueString) { nsAutoString value(valueString); diff --git a/mozilla/extensions/wallet/src/nsWalletService.h b/mozilla/extensions/wallet/src/nsWalletService.h index 2b8757e4e82..e78ebc067aa 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.h +++ b/mozilla/extensions/wallet/src/nsWalletService.h @@ -57,14 +57,14 @@ public: (const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **result, const char *urlname, nsIPrompt* dialog, PRBool *_retval); - NS_IMETHOD SI_RemoveUser(const char *URLName, char *userName); + NS_IMETHOD SI_RemoveUser(const char *URLName, PRUnichar *userName); - NS_IMETHOD WALLET_GetNopreviewListForViewer(nsString& aNopreviewList); - NS_IMETHOD WALLET_GetNocaptureListForViewer(nsString& aNocaptureList); - NS_IMETHOD WALLET_GetPrefillListForViewer(nsString& aPrefillList); - NS_IMETHOD SI_GetSignonListForViewer(nsString& aSignonList); - NS_IMETHOD SI_GetRejectListForViewer(nsString& aRejectList); + NS_IMETHOD WALLET_GetNopreviewListForViewer(nsAutoString& aNopreviewList); + NS_IMETHOD WALLET_GetNocaptureListForViewer(nsAutoString& aNocaptureList); + NS_IMETHOD WALLET_GetPrefillListForViewer(nsAutoString& aPrefillList); + NS_IMETHOD SI_GetSignonListForViewer(nsAutoString& aSignonList); + NS_IMETHOD SI_GetRejectListForViewer(nsAutoString& aRejectList); NS_IMETHOD SI_SignonViewerReturn(nsAutoString results); // nsIObserver diff --git a/mozilla/extensions/wallet/src/singsign.cpp b/mozilla/extensions/wallet/src/singsign.cpp index 518534afc44..9be8089a467 100644 --- a/mozilla/extensions/wallet/src/singsign.cpp +++ b/mozilla/extensions/wallet/src/singsign.cpp @@ -24,7 +24,6 @@ #define alphabetize 1 #include "singsign.h" -#include "libi18n.h" /* For the character code set conversions */ #ifdef XP_MAC #include "prpriv.h" /* for NewNamedMonitor */ @@ -83,12 +82,14 @@ si_SaveSignonDataInKeychain(); /* the following is from the now-defunct lo_ele.h */ -struct LO_FormSubmitData_struct { +struct si_FormSubmitData_struct { int32 value_cnt; - PA_Block name_array; - PA_Block value_array; - PA_Block type_array; + nsAutoString* name_array; + nsAutoString* value_array; + PRUnichar ** type_array; }; +typedef struct si_FormSubmitData_struct si_FormSubmitData; + #define FORM_TYPE_TEXT 1 #define FORM_TYPE_PASSWORD 7 @@ -125,7 +126,7 @@ si_3ButtonConfirm(PRUnichar * szMessage) { static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); PRIVATE PRBool -si_SelectDialog(const PRUnichar* szMessage, char** pList, PRInt32* pCount) { +si_SelectDialog(const PRUnichar* szMessage, PRUnichar** pList, PRInt32* pCount) { if (si_UserHasBeenSelected) { /* a user was already selected for this form, use same one again */ *pCount = 0; /* last user selected is now at head of list */ @@ -142,7 +143,7 @@ si_SelectDialog(const PRUnichar* szMessage, char** pList, PRInt32* pCount) { nsCOMPtr prompter(do_QueryInterface(webshellwindow)); PRInt32 selectedIndex; PRBool rtnValue; - rv = prompter->Select( NULL, szMessage, *pCount, (const char **)pList, &selectedIndex, &rtnValue ); + rv = prompter->Select( NULL, szMessage, *pCount, (const PRUnichar **)pList, &selectedIndex, &rtnValue ); *pCount = selectedIndex; si_UserHasBeenSelected = PR_TRUE; return rtnValue; @@ -154,7 +155,7 @@ si_SelectDialog(const PRUnichar* szMessage, char** pList, PRInt32* pCount) { ******************/ extern void Wallet_RestartKey(); -extern char Wallet_GetKey(); +extern PRUnichar Wallet_GetKey(); extern PRBool Wallet_KeySet(); extern void Wallet_KeyResetTime(); extern PRBool Wallet_KeyTimedOut(); @@ -170,7 +171,7 @@ si_RestartKey() { Wallet_RestartKey(); } -PRIVATE char +PRIVATE PRUnichar si_GetKey() { return Wallet_GetKey(); } @@ -195,6 +196,7 @@ si_KeyTimedOut() { return Wallet_KeyTimedOut(); } + /*************************** * Locking the Signon List * ***************************/ @@ -543,22 +545,23 @@ si_StrippedURL (char* URLName) { /* remove terminating CRs or LFs */ PRIVATE void -si_StripLF(char* buffer) { - while ((buffer[PL_strlen(buffer)-1] == '\n') || (buffer[PL_strlen(buffer)-1] == '\r')) { - buffer[PL_strlen(buffer)-1] = '\0'; +si_StripLF(nsAutoString buffer) { + PRUnichar c; + while ((c=buffer.CharAt(buffer.Length())-1) == '\n' || c == '\r' ) { + buffer.SetLength(buffer.Length()-1); } } /* If user-entered password is "********", then generate a random password */ PRIVATE void -si_Randomize(char * password) { +si_Randomize(nsAutoString& password) { PRIntervalTime randomNumber; int i; const char * hexDigits = "0123456789AbCdEf"; - if (PL_strcmp(password, "********") == 0) { + if (password == nsAutoString("********")) { randomNumber = PR_IntervalNow(); for (i=0; i<8; i++) { - password[i] = hexDigits[randomNumber%16]; + password.SetCharAt(hexDigits[randomNumber%16], i); randomNumber = randomNumber/16; } } @@ -569,27 +572,57 @@ si_Randomize(char * password) { * Managing Signon List * ************************/ -typedef struct _SignonDataStruct { - char * name; - char * value; +class si_SignonDataStruct { +public: + si_SignonDataStruct() : name(""), value(""), isPassword(PR_FALSE) {} + nsAutoString name; + nsAutoString value; PRBool isPassword; -} si_SignonDataStruct; +}; -typedef struct _SignonUserStruct { +class si_SignonUserStruct { +public: + si_SignonUserStruct() : signonData_list(NULL) {} nsVoidArray * signonData_list; -} si_SignonUserStruct; +}; -typedef struct _SignonURLStruct { +class si_SignonURLStruct { +public: + si_SignonURLStruct() : URLName(NULL), chosen_user(NULL), signonUser_list(NULL) {} char * URLName; si_SignonUserStruct* chosen_user; /* this is a state variable */ nsVoidArray * signonUser_list; -} si_SignonURLStruct; +}; -typedef struct _RejectStruct { +class si_Reject { +public: + si_Reject() : URLName(NULL), userName("") {} char * URLName; - char * userName; -} si_Reject; + nsAutoString userName; +}; + +//typedef struct _SignonDataStruct { +// nsAutoString name; +// nsAutoString value; +// PRBool isPassword; +//} si_SignonDataStruct; + +//typedef struct _SignonUserStruct { +// nsVoidArray * signonData_list; +//} si_SignonUserStruct; + +//typedef struct _SignonURLStruct { +// char * URLName; +// si_SignonUserStruct* chosen_user; /* this is a state variable */ +// nsVoidArray * signonUser_list; +//} si_SignonURLStruct; + + +//typedef struct _RejectStruct { +// char * URLName; +// nsAutoString userName; +//} si_Reject; PRIVATE nsVoidArray * si_signon_list=0; PRIVATE nsVoidArray * si_reject_list=0; @@ -627,7 +660,7 @@ si_GetURL(char * URLName) { /* Remove a user node from a given URL node */ PRIVATE PRBool -si_RemoveUser(char *URLName, char *userName, PRBool save) { +si_RemoveUser(char *URLName, nsAutoString userName, PRBool save) { nsresult res; si_SignonURLStruct * url; si_SignonUserStruct * user; @@ -640,8 +673,6 @@ si_RemoveUser(char *URLName, char *userName, PRBool save) { /* convert URLName to a uri so we can parse out the username and hostname */ char* host = nsnull; - char * userName2 = nsnull; - char * colon = nsnull; if (URLName) { nsCOMPtr uri; nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, NS_GET_IID(nsIURL), (void **) getter_AddRefs(uri)); @@ -656,18 +687,19 @@ si_RemoveUser(char *URLName, char *userName, PRBool save) { } /* if no username given, extract it from uri -- note: prehost is : */ - if (userName && *userName != '\0') { - userName2 = PL_strdup(userName); - } else { + if (userName.Length() == 0) { + char * userName2 = nsnull; res = uri->GetPreHost(&userName2); if (NS_FAILED(res)) { PR_FREEIF(host); return PR_FALSE; } if (userName2) { - colon = (char*) PL_strchr(userName2, ':'); - if (colon) { - *colon = '\0'; + userName = nsAutoString(userName2); + PR_FREEIF(userName2); + PRInt32 colon = userName.FindChar(':'); + if (colon != -1) { + userName.Truncate(colon); } } } @@ -680,16 +712,12 @@ si_RemoveUser(char *URLName, char *userName, PRBool save) { if (!url) { /* URL not found */ si_unlock_signon_list(); - if (colon) { - *colon = ':'; - } - PR_FREEIF(userName2); //@@@ PR_FREEIF(host); return PR_FALSE; } /* free the data in each node of the specified user node for this URL */ - if (userName2 == NULL) { + if (userName.Length() == 0) { /* no user specified so remove the first one */ user = (si_SignonUserStruct *) (url->signonUser_list->ElementAt(0)); @@ -703,29 +731,17 @@ si_RemoveUser(char *URLName, char *userName, PRBool save) { PRInt32 dataCount = LIST_COUNT(user->signonData_list); for (PRInt32 ii=0; iisignonData_list->ElementAt(ii)); - if (PL_strcmp(data->value, userName2)==0) { + if (data->value == userName) { goto foundUser; } } } si_unlock_signon_list(); - if (colon) { - *colon = ':'; - } - PR_FREEIF(user); //@@@ PR_FREEIF(host); return PR_FALSE; /* user not found so nothing to remove */ foundUser: ; } - /* free the items in the data list */ - PRInt32 dataCount = LIST_COUNT(user->signonData_list); - for (PRInt32 j=0; jsignonData_list->ElementAt(j)); - PR_Free(data->name); - PR_Free(data->value); - } - /* free the data list */ delete user->signonData_list; @@ -745,22 +761,18 @@ si_RemoveUser(char *URLName, char *userName, PRBool save) { } si_unlock_signon_list(); - if (colon) { - *colon = ':'; - } - PR_FREEIF(userName2); //@@@ PR_FREEIF(host); return PR_TRUE; } PUBLIC PRBool -SINGSIGN_RemoveUser(const char *URLName, char *userName) { +SINGSIGN_RemoveUser(const char *URLName, PRUnichar *userName) { return si_RemoveUser((char *)URLName, userName, PR_TRUE); } /* Determine if a specified url/user exists */ PRIVATE PRBool -si_CheckForUser(char *URLName, char *userName) { +si_CheckForUser(char *URLName, nsAutoString userName) { si_SignonURLStruct * url; si_SignonUserStruct * user; si_SignonDataStruct * data; @@ -787,7 +799,7 @@ si_CheckForUser(char *URLName, char *userName) { PRInt32 dataCount = LIST_COUNT(user->signonData_list); for (PRInt32 ii=0; iisignonData_list->ElementAt(ii)); - if (PL_strcmp(data->value, userName)==0) { + if (data->value == userName) { si_unlock_signon_list(); return PR_TRUE; } @@ -805,7 +817,7 @@ si_CheckForUser(char *URLName, char *userName) { * This routine is called only if signon pref is enabled!!! */ PRIVATE si_SignonUserStruct* -si_GetUser(char* URLName, PRBool pickFirstUser, char* userText) { +si_GetUser(char* URLName, PRBool pickFirstUser, nsAutoString userText) { si_SignonURLStruct* url; si_SignonUserStruct* user; si_SignonDataStruct* data; @@ -828,7 +840,7 @@ si_GetUser(char* URLName, PRBool pickFirstUser, char* userText) { user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list->ElementAt(i)); /* consider first data node to be the identifying item */ data = (si_SignonDataStruct *) (user->signonData_list->ElementAt(0)); - if (PL_strcmp(data->name, userText)) { + if (data->name != userText) { /* name of current data item does not match name in data node */ continue; } @@ -838,12 +850,12 @@ si_GetUser(char* URLName, PRBool pickFirstUser, char* userText) { } else { /* multiple users for this URL so a choice needs to be made */ - char ** list; - char ** list2; + PRUnichar ** list; + PRUnichar ** list2; si_SignonUserStruct** users; si_SignonUserStruct** users2; - list = (char**)PR_Malloc(user_count*sizeof(char*)); - users = (struct _SignonUserStruct **) PR_Malloc(user_count*sizeof(si_SignonUserStruct*)); + list = (PRUnichar**)PR_Malloc(user_count*sizeof(PRUnichar*)); + users = (si_SignonUserStruct **) PR_Malloc(user_count*sizeof(si_SignonUserStruct*)); list2 = list; users2 = users; @@ -858,7 +870,7 @@ si_GetUser(char* URLName, PRBool pickFirstUser, char* userText) { user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list->ElementAt(i)); /* consider first data node to be the identifying item */ data = (si_SignonDataStruct *) (user->signonData_list->ElementAt(0)); - if (PL_strcmp(data->name, userText)) { + if (data->name != userText) { /* name of current data item does not match name in data node */ continue; } @@ -886,11 +898,11 @@ si_GetUser(char* URLName, PRBool pickFirstUser, char* userText) { user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list->ElementAt(i2)); /* consider first data node to be the identifying item */ data = (si_SignonDataStruct *) (user->signonData_list->ElementAt(0)); - if (PL_strcmp(data->name, userText)) { + if (data->name != userText) { /* name of current data item does not match name in data node */ continue; } - *(list2++) = data->value; + *(list2++) = (data->value).ToNewUnicode(); *(users2++) = user; } @@ -921,6 +933,9 @@ si_GetUser(char* URLName, PRBool pickFirstUser, char* userText) { } Recycle(selectUser); url->chosen_user = user; + while (--list2 > list) { + Recycle(*list2); + } PR_Free(list); PR_Free(users); @@ -948,7 +963,7 @@ si_GetUser(char* URLName, PRBool pickFirstUser, char* userText) { * This routine is called only if signon pref is enabled!!! */ PRIVATE si_SignonUserStruct* -si_GetSpecificUser(char* URLName, char* userName, char* userText) { +si_GetSpecificUser(char* URLName, nsAutoString userName, nsAutoString userText) { si_SignonURLStruct* url; si_SignonUserStruct* user; si_SignonDataStruct* data; @@ -963,11 +978,11 @@ si_GetSpecificUser(char* URLName, char* userName, char* userText) { user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list->ElementAt(i2)); /* consider first data node to be the identifying item */ data = (si_SignonDataStruct *) (user->signonData_list->ElementAt(0)); - if (PL_strcmp(data->name, userText)) { + if (data->name != userText) { /* desired username text does not match name in data node */ continue; } - if (PL_strcmp(data->value, userName)) { + if (data->value != userName) { /* desired username value does not match value in data node */ continue; } @@ -995,15 +1010,15 @@ si_GetSpecificUser(char* URLName, char* userName, char* userText) { * This routine is called only if signon pref is enabled!!! */ PRIVATE si_SignonUserStruct* -si_GetURLAndUserForChangeForm(char* password) +si_GetURLAndUserForChangeForm(nsAutoString password) { si_SignonURLStruct* url; si_SignonUserStruct* user; si_SignonDataStruct * data; PRInt32 user_count; - char ** list; - char ** list2; + PRUnichar ** list; + PRUnichar ** list2; si_SignonUserStruct** users; si_SignonUserStruct** users2; si_SignonURLStruct** urls; @@ -1022,9 +1037,9 @@ si_GetURLAndUserForChangeForm(char* password) } /* allocate lists for maximumum possible url and user names */ - list = (char**)PR_Malloc(user_count*sizeof(char*)); - users = (struct _SignonUserStruct **) PR_Malloc(user_count*sizeof(si_SignonUserStruct*)); - urls = (struct _SignonURLStruct **)PR_Malloc(user_count*sizeof(si_SignonUserStruct*)); + list = (PRUnichar**)PR_Malloc(user_count*sizeof(PRUnichar*)); + users = (si_SignonUserStruct **) PR_Malloc(user_count*sizeof(si_SignonUserStruct*)); + urls = (si_SignonURLStruct **)PR_Malloc(user_count*sizeof(si_SignonUserStruct*)); list2 = list; users2 = users; urls2 = urls; @@ -1041,14 +1056,12 @@ si_GetURLAndUserForChangeForm(char* password) PRInt32 dataCount = LIST_COUNT(user->signonData_list); for (PRInt32 i4=0; i4signonData_list->ElementAt(i4)); - if (data->isPassword && !PL_strcmp(data->value, password)) { + if (data->isPassword && data->value == password) { /* passwords match so add entry to list */ /* consider first data node to be the identifying item */ data = (si_SignonDataStruct *) (user->signonData_list->ElementAt(0)); - *list2 = 0; - StrAllocCopy(*list2, url->URLName); - StrAllocCat(*list2,": "); - StrAllocCat(*list2, data->value); + nsAutoString temp = nsAutoString(url->URLName) + ":" + data->value; + *list2 = temp.ToNewUnicode(); list2++; *(users2++) = user; *(urls2++) = url; @@ -1080,7 +1093,7 @@ si_GetURLAndUserForChangeForm(char* password) /* free allocated strings */ while (--list2 > list) { - PR_Free(*list2); + Recycle(*list2); } PR_Free(list); PR_Free(users); @@ -1096,7 +1109,7 @@ PRIVATE void si_RemoveAllSignonData() { if (si_PartiallyLoaded) { /* repeatedly remove first user node of first URL node */ - while (si_RemoveUser(NULL, NULL, PR_FALSE)) { + while (si_RemoveUser(NULL, nsAutoString(""), PR_FALSE)) { } } si_PartiallyLoaded = PR_FALSE; @@ -1121,12 +1134,11 @@ si_FreeReject(si_Reject * reject) { } si_reject_list->RemoveElement(reject); PR_FREEIF(reject->URLName); - PR_FREEIF(reject->userName); PR_Free(reject); } PRIVATE PRBool -si_CheckForReject(char * URLName, char * userName) { +si_CheckForReject(char * URLName, nsAutoString userName) { si_Reject * reject; si_lock_signon_list(); @@ -1147,12 +1159,11 @@ si_CheckForReject(char * URLName, char * userName) { } PRIVATE void -si_PutReject(char * URLName, char * userName, PRBool save) { - si_Reject * reject; +si_PutReject(char * URLName, nsAutoString userName, PRBool save) { char * URLName2=NULL; - char * userName2=NULL; + nsAutoString userName2; + si_Reject * reject = new si_Reject; - reject = PR_NEW(si_Reject); if (reject) { /* * lock the signon list @@ -1168,7 +1179,7 @@ si_PutReject(char * URLName, char * userName, PRBool save) { } StrAllocCopy(URLName2, URLName); - StrAllocCopy(userName2, userName); + userName2 = userName; reject->URLName = URLName2; reject->userName = userName2; @@ -1176,7 +1187,6 @@ si_PutReject(char * URLName, char * userName, PRBool save) { si_reject_list = new nsVoidArray(); if(!si_reject_list) { PR_Free(reject->URLName); - PR_Free(reject->userName); PR_Free(reject); if (save) { si_unlock_signon_list(); @@ -1228,9 +1238,7 @@ si_PutReject(char * URLName, char * userName, PRBool save) { * This routine is called only if signon pref is enabled!!! */ PRIVATE void -si_PutData(char * URLName, LO_FormSubmitData * submit, PRBool save) { - char * name; - char * value; +si_PutData(char * URLName, si_FormSubmitData * submit, PRBool save) { PRBool added_to_list = PR_FALSE; si_SignonURLStruct * url; si_SignonUserStruct * user; @@ -1240,8 +1248,7 @@ si_PutData(char * URLName, LO_FormSubmitData * submit, PRBool save) { /* discard this if the password is empty */ for (PRInt32 i=0; ivalue_cnt; i++) { if ((((uint8*)submit->type_array)[i] == FORM_TYPE_PASSWORD) && - (!((char **)(submit->value_array))[i] || - !PL_strlen( ((char **)(submit->value_array)) [i])) ) { + (((submit->value_array)) [i]).Length == 0 ) { return; } } @@ -1274,7 +1281,7 @@ si_PutData(char * URLName, LO_FormSubmitData * submit, PRBool save) { if ((url = si_GetURL(URLName)) == NULL) { /* doesn't exist so allocate new node to be put into signon list */ - url = PR_NEW(si_SignonURLStruct); + url = new si_SignonURLStruct; if (!url) { if (save) { si_unlock_signon_list(); @@ -1352,19 +1359,10 @@ si_PutData(char * URLName, LO_FormSubmitData * submit, PRBool save) { if ((j < submit->value_cnt) && (data->isPassword == (((uint8*)submit->type_array)[j]==FORM_TYPE_PASSWORD)) && - (!PL_strcmp(data->name, ((char **)submit->name_array)[j]))) { + (data->name == (submit->name_array)[j])) { /* success, now check for match on value field if not password */ - if (!submit->value_array[j]) { - /* special case a null value */ - if (!PL_strcmp(data->value, "")) { - j++; /* success */ - } else { - mismatch = PR_TRUE; - break; /* value mismatch, try next user */ - } - } else if (!PL_strcmp(data->value, ((char **)submit->value_array)[j]) - || data->isPassword) { + if (data->value == (submit->value_array)[j] || data->isPassword) { j++; /* success */ } else { mismatch = PR_TRUE; @@ -1401,9 +1399,9 @@ si_PutData(char * URLName, LO_FormSubmitData * submit, PRBool save) { /* update saved password */ if ((j < submit->value_cnt) && data->isPassword) { - if (PL_strcmp(data->value, ((char **)submit->value_array)[j])) { + if (data->value != (submit->value_array)[j]) { si_signon_list_changed = PR_TRUE; - StrAllocCopy(data->value, ((char **)submit->value_array)[j]); + data->value = (submit->value_array)[j]; si_Randomize(data->value); } } @@ -1429,7 +1427,7 @@ si_PutData(char * URLName, LO_FormSubmitData * submit, PRBool save) { } /* user node with current data not found so create one */ - user = PR_NEW(si_SignonUserStruct); + user = new si_SignonUserStruct; if (!user) { if (save) { si_unlock_signon_list(); @@ -1455,7 +1453,7 @@ si_PutData(char * URLName, LO_FormSubmitData * submit, PRBool save) { } /* create signon data node */ - data = PR_NEW(si_SignonDataStruct); + data = new si_SignonDataStruct; if (!data) { delete user->signonData_list; PR_Free(user); @@ -1465,16 +1463,8 @@ si_PutData(char * URLName, LO_FormSubmitData * submit, PRBool save) { return; } data->isPassword = (((uint8 *)submit->type_array)[k] == FORM_TYPE_PASSWORD); - name = 0; /* so that StrAllocCopy doesn't free previous name */ - name = PL_strdup(((char **)submit->name_array)[k]); - data->name = name; - value = 0; /* so that StrAllocCopy doesn't free previous name */ - if (submit->value_array[k]) { - value = PL_strdup(((char **)submit->value_array)[k]); - } else { - value = PL_strdup(""); /* insures that value is not null */ - } - data->value = value; + data->name = (submit->name_array)[k]; + data->value = (submit->value_array)[k]; if (data->isPassword) { si_Randomize(data->value); } @@ -1508,6 +1498,12 @@ si_PutData(char * URLName, LO_FormSubmitData * submit, PRBool save) { * Managing the Signon Files * *****************************/ +extern void +Wallet_UTF8Put(nsOutputFileStream strm, PRUnichar c); + +extern PRUnichar +Wallet_UTF8Get(nsInputFileStream strm); + #define BUFFER_SIZE 4096 #define MAX_ARRAY_SIZE 500 @@ -1518,18 +1514,19 @@ si_PutData(char * URLName, LO_FormSubmitData * submit, PRBool save) { */ PRIVATE PRInt32 si_ReadLine - (nsInputFileStream strm, nsInputFileStream strmx, char * lineBuffer, PRBool obscure) { + (nsInputFileStream strm, nsInputFileStream strmx, nsAutoString& lineBuffer, PRBool obscure) { int count = 0; + lineBuffer = nsAutoString(""); /* read the line */ - char c; + PRUnichar c; for (;;) { if (obscure) { - c = strm.get(); /* get past the asterisk */ - c = strmx.get()^si_GetKey(); /* get the real character */ + c = Wallet_UTF8Get(strm); /* get past the asterisk */ + c = Wallet_UTF8Get(strmx)^si_GetKey(); /* get the real character */ } else { - c = strm.get(); + c = Wallet_UTF8Get(strm); } /* note that eof is not set until we read past the end of the file */ @@ -1538,14 +1535,10 @@ si_ReadLine } if (c == '\n') { - lineBuffer[count] = '\0'; break; } if (c != '\r') { - lineBuffer[count++] = c; - if (count == BUFFER_SIZE) { - return -1; - } + lineBuffer += c; } } return 0; @@ -1569,13 +1562,12 @@ SI_LoadSignonData(PRBool fullLoad) { * should never have to give his password to unlock the password file */ char * URLName; - LO_FormSubmitData submit; - char* name_array[MAX_ARRAY_SIZE]; - char* value_array[MAX_ARRAY_SIZE]; + si_FormSubmitData submit; + nsAutoString name_array[MAX_ARRAY_SIZE]; + nsAutoString value_array[MAX_ARRAY_SIZE]; uint8 type_array[MAX_ARRAY_SIZE]; - char buffer[BUFFER_SIZE+1]; + nsAutoString buffer; PRBool badInput; - int i; if (si_FullyLoaded && fullLoad) { return 0; @@ -1625,12 +1617,11 @@ SI_LoadSignonData(PRBool fullLoad) { /* read the reject list */ si_lock_signon_list(); while(!NS_FAILED(si_ReadLine(strm, strmx, buffer, PR_FALSE))) { - if (buffer[0] == '.') { + if (buffer.CharAt(0) == '.') { break; /* end of reject list */ } si_StripLF(buffer); - URLName = NULL; - StrAllocCopy(URLName, buffer); + URLName = buffer.ToNewCString(); if (NS_FAILED(si_ReadLine(strm, strmx, buffer, PR_FALSE))) { /* error in input file so give up */ badInput = PR_TRUE; @@ -1638,19 +1629,18 @@ SI_LoadSignonData(PRBool fullLoad) { } si_StripLF(buffer); si_PutReject(URLName, buffer, PR_FALSE); - PR_Free (URLName); + Recycle (URLName); } /* initialize the submit structure */ - submit.name_array = (PA_Block)name_array; - submit.value_array = (PA_Block)value_array; - submit.type_array = (PA_Block)type_array; + submit.name_array = name_array; + submit.value_array = value_array; + submit.type_array = (PRUnichar **)type_array; /* read the URL line */ while(!NS_FAILED(si_ReadLine(strm, strmx, buffer, PR_FALSE))) { si_StripLF(buffer); - URLName = NULL; - StrAllocCopy(URLName, buffer); + URLName = buffer.ToNewCString(); /* prepare to read the name/value pairs */ submit.value_cnt = 0; @@ -1659,7 +1649,7 @@ SI_LoadSignonData(PRBool fullLoad) { while(!NS_FAILED(si_ReadLine(strm, strmx, buffer, PR_FALSE))) { /* line starting with . terminates the pairs for this URL entry */ - if (buffer[0] == '.') { + if (buffer.CharAt(0) == '.') { break; /* end of URL entry */ } @@ -1668,14 +1658,15 @@ SI_LoadSignonData(PRBool fullLoad) { /* save the name part and determine if it is a password */ PRBool ret; si_StripLF(buffer); - name_array[submit.value_cnt] = NULL; - if (buffer[0] == '*') { + if (buffer.CharAt(0) == '*') { type_array[submit.value_cnt] = FORM_TYPE_PASSWORD; - StrAllocCopy(name_array[submit.value_cnt], buffer+1); + nsAutoString temp; + buffer.Mid(temp, 1, buffer.Length()-1); + name_array[submit.value_cnt] = temp; ret = si_ReadLine(strm, strmx, buffer, fullLoad); } else { type_array[submit.value_cnt] = FORM_TYPE_TEXT; - StrAllocCopy(name_array[submit.value_cnt], buffer); + name_array[submit.value_cnt] = buffer; ret = si_ReadLine(strm, strmx, buffer, PR_FALSE); } @@ -1686,8 +1677,7 @@ SI_LoadSignonData(PRBool fullLoad) { break; } si_StripLF(buffer); - value_array[submit.value_cnt] = NULL; - StrAllocCopy(value_array[submit.value_cnt++], buffer); + value_array[submit.value_cnt++] = buffer; /* check for overruning of the arrays */ if (submit.value_cnt >= MAX_ARRAY_SIZE) { @@ -1704,11 +1694,7 @@ SI_LoadSignonData(PRBool fullLoad) { } /* free up all the allocations done for processing this URL */ - PR_Free(URLName); - for (i=0; iElementAt(i)); - si_WriteLine(strm, strmx, reject->URLName, PR_FALSE, fullSave); - si_WriteLine(strm, strmx, reject->userName, PR_FALSE, fullSave); + si_WriteLine(strm, strmx, nsAutoString(reject->URLName), PR_FALSE, fullSave); + si_WriteLine(strm, strmx, nsAutoString(reject->userName), PR_FALSE, fullSave); } } - si_WriteLine(strm, strmx, ".", PR_FALSE, fullSave); + si_WriteLine(strm, strmx, nsAutoString("."), PR_FALSE, fullSave); /* format for cached logins shall be: * url LINEBREAK {name LINEBREAK value LINEBREAK}* . LINEBREAK @@ -1847,7 +1831,7 @@ si_SaveSignonDataLocked(PRBool fullSave) { PRInt32 userCount = LIST_COUNT(url->signonUser_list); for (PRInt32 i3=0; i3signonUser_list->ElementAt(i3)); - si_WriteLine(strm, strmx, url->URLName, PR_FALSE, fullSave); + si_WriteLine(strm, strmx, nsAutoString(url->URLName), PR_FALSE, fullSave); /* write out each data node of the user node */ PRInt32 dataCount = LIST_COUNT(user->signonData_list); @@ -1855,14 +1839,14 @@ si_SaveSignonDataLocked(PRBool fullSave) { data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list->ElementAt(i4)); if (data->isPassword) { si_WriteChar(strm, '*'); - si_WriteLine(strm, strmx, data->name, PR_FALSE, fullSave); - si_WriteLine(strm, strmx, data->value, PR_TRUE, fullSave); + si_WriteLine(strm, strmx, nsAutoString(data->name), PR_FALSE, fullSave); + si_WriteLine(strm, strmx, nsAutoString(data->value), PR_TRUE, fullSave); } else { - si_WriteLine(strm, strmx, data->name, PR_FALSE, fullSave); - si_WriteLine(strm, strmx, data->value, PR_FALSE, fullSave); + si_WriteLine(strm, strmx, nsAutoString(data->name), PR_FALSE, fullSave); + si_WriteLine(strm, strmx, nsAutoString(data->value), PR_FALSE, fullSave); } } - si_WriteLine(strm, strmx, ".", PR_FALSE, fullSave); + si_WriteLine(strm, strmx, nsAutoString("."), PR_FALSE, fullSave); } } } @@ -1905,7 +1889,7 @@ SI_SaveSignonData() { /* Ask user if it is ok to save the signon data */ PRIVATE PRBool -si_OkToSave(char *URLName, char *userName) { +si_OkToSave(char *URLName, nsAutoString userName) { char *strippedURLName = 0; /* if url/user already exists, then it is safe to save it again */ @@ -1951,15 +1935,15 @@ si_OkToSave(char *URLName, char *userName) { */ PUBLIC void SINGSIGN_RememberSignonData - (char* URLName, char** name_array, char** value_array, char** type_array, PRInt32 value_cnt) + (char* URLName, nsAutoString* name_array, nsAutoString* value_array, char** type_array, PRInt32 value_cnt) { int passwordCount = 0; int pswd[3]; - LO_FormSubmitData submit; - submit.name_array = (PA_Block)name_array; - submit.value_array = (PA_Block)value_array; - submit.type_array = (PA_Block)type_array; + si_FormSubmitData submit; + submit.name_array = name_array; + submit.value_array = value_array; + submit.type_array = (PRUnichar **)type_array; submit.value_cnt = value_cnt; /* do nothing if signon preference is not enabled */ @@ -1990,7 +1974,7 @@ SINGSIGN_RememberSignonData } if ((jvalue, ((char **)submit.value_array)[pswd[1]]); + si_Randomize((submit.value_array)[pswd[1]]); + (submit.value_array)[pswd[2]] = (submit.value_array)[pswd[1]]; + data->value = (submit.value_array)[pswd[1]]; si_signon_list_changed = PR_TRUE; si_SaveSignonDataLocked(PR_TRUE); si_unlock_signon_list(); @@ -2055,7 +2039,7 @@ SINGSIGN_RememberSignonData } PUBLIC void -SINGSIGN_RestoreSignonData (char* URLName, char* name, char** value, PRUint32 elementNumber) { +SINGSIGN_RestoreSignonData (char* URLName, PRUnichar* name, PRUnichar** value, PRUint32 elementNumber) { si_SignonUserStruct* user; si_SignonDataStruct* data; @@ -2071,12 +2055,12 @@ SINGSIGN_RestoreSignonData (char* URLName, char* name, char** value, PRUint32 el /* determine if name has been saved (avoids unlocking the database if not) */ PRBool nameFound = PR_FALSE; - user = si_GetUser(URLName, PR_FALSE, name); + user = si_GetUser(URLName, PR_FALSE, nsAutoString(name)); if (user) { PRInt32 dataCount = LIST_COUNT(user->signonData_list); for (PRInt32 i=0; isignonData_list->ElementAt(i)); - if(name && PL_strcmp(data->name, name)==0) { + if(name && data->name == name) { nameFound = PR_TRUE; } } @@ -2121,16 +2105,16 @@ SINGSIGN_RestoreSignonData (char* URLName, char* name, char** value, PRUint32 el /* restore the data from previous time this URL was visited */ - user = si_GetUser(URLName, PR_FALSE, name); + user = si_GetUser(URLName, PR_FALSE, nsAutoString(name)); if (user) { SI_LoadSignonData(PR_TRUE); /* this destroys user so need to recaculate it */ - user = si_GetUser(URLName, PR_FALSE, name); + user = si_GetUser(URLName, PR_FALSE, nsAutoString(name)); if (user) { /* this should always be true but just in case */ PRInt32 dataCount = LIST_COUNT(user->signonData_list); for (PRInt32 i=0; isignonData_list->ElementAt(i)); - if(name && PL_strcmp(data->name, name)==0) { - *value = data->value; + if(name && data->name == name) { + *value = (data->value).ToNewUnicode(); si_unlock_signon_list(); return; } @@ -2144,12 +2128,10 @@ SINGSIGN_RestoreSignonData (char* URLName, char* name, char** value, PRUint32 el * Remember signon data from a browser-generated password dialog */ PRIVATE void -si_RememberSignonDataFromBrowser(char* URLName, char* username, char* password) { - LO_FormSubmitData submit; - char* USERNAME = "username"; - char* PASSWORD = "password"; - char* name_array[2]; - char* value_array[2]; +si_RememberSignonDataFromBrowser(char* URLName, nsAutoString username, nsAutoString password) { + si_FormSubmitData submit; + nsAutoString name_array[2]; + nsAutoString value_array[2]; uint8 type_array[2]; /* do nothing if signon preference is not enabled */ @@ -2158,28 +2140,22 @@ si_RememberSignonDataFromBrowser(char* URLName, char* username, char* password) } /* initialize a temporary submit structure */ - submit.name_array = (PA_Block)name_array; - submit.value_array = (PA_Block)value_array; - submit.type_array = (PA_Block)type_array; + submit.name_array = name_array; + submit.value_array = value_array; + submit.type_array = (PRUnichar **)type_array; submit.value_cnt = 2; - name_array[0] = USERNAME; - value_array[0] = NULL; - StrAllocCopy(value_array[0], username); + name_array[0] = nsAutoString("username"); + value_array[0] = nsAutoString(username); type_array[0] = FORM_TYPE_TEXT; - name_array[1] = PASSWORD; - value_array[1] = NULL; - StrAllocCopy(value_array[1], password); + name_array[1] = nsAutoString("password"); + value_array[1] = nsAutoString(password); type_array[1] = FORM_TYPE_PASSWORD; /* Save the signon data */ SI_LoadSignonData(PR_TRUE); si_PutData(URLName, &submit, PR_TRUE); - - /* Free up the data memory just allocated */ - PR_Free(value_array[0]); - PR_Free(value_array[1]); } /* @@ -2188,16 +2164,16 @@ si_RememberSignonDataFromBrowser(char* URLName, char* username, char* password) */ PRIVATE void si_RestoreOldSignonDataFromBrowser - (char* URLName, PRBool pickFirstUser, char** username, char** password) { + (char* URLName, PRBool pickFirstUser, nsAutoString& username, nsAutoString& password) { si_SignonUserStruct* user; si_SignonDataStruct* data; /* get the data from previous time this URL was visited */ si_lock_signon_list(); - if (*username != NULL) { - user = si_GetSpecificUser(URLName, *username, "username"); + if (username.Length() != 0) { + user = si_GetSpecificUser(URLName, username, nsAutoString("username")); } else { - user = si_GetUser(URLName, pickFirstUser, "username"); + user = si_GetUser(URLName, pickFirstUser, nsAutoString("username")); } if (!user) { /* leave original username and password from caller unchanged */ @@ -2207,10 +2183,10 @@ si_RestoreOldSignonDataFromBrowser return; } SI_LoadSignonData(PR_TRUE); /* this destroys "user" so need to recalculate it */ - if (*username != NULL) { - user = si_GetSpecificUser(URLName, *username, "username"); + if (username.Length() != 0) { + user = si_GetSpecificUser(URLName, username, nsAutoString("username")); } else { - user = si_GetUser(URLName, pickFirstUser, "username"); + user = si_GetUser(URLName, pickFirstUser, nsAutoString("username")); } if (!user) { si_unlock_signon_list(); @@ -2221,10 +2197,10 @@ si_RestoreOldSignonDataFromBrowser PRInt32 dataCount = LIST_COUNT(user->signonData_list); for (PRInt32 i=0; isignonData_list->ElementAt(i)); - if(PL_strcmp(data->name, "username")==0) { - StrAllocCopy(*username, data->value); - } else if(PL_strcmp(data->name, "password")==0) { - StrAllocCopy(*password, data->value); + if(data->name == "username") { + username = data->value; + } else if(data->name == "password") { + password = data->value; } } si_unlock_signon_list(); @@ -2258,10 +2234,10 @@ SINGSIGN_PromptUsernameAndPassword } /* prefill with previous username/password if any */ - char *username= nsnull, *password=nsnull; - si_RestoreOldSignonDataFromBrowser(host, PR_FALSE, &username, &password); - *user = nsAutoString(username).ToNewUnicode(); - *pwd = nsAutoString(password).ToNewUnicode(); + nsAutoString username, password; + si_RestoreOldSignonDataFromBrowser(host, PR_FALSE, username, password); + *user = username.ToNewUnicode(); + *pwd = password.ToNewUnicode(); /* get new username/password from user */ res = dialog->PromptUsernameAndPassword(text, user, pwd, returnValue); @@ -2274,15 +2250,11 @@ SINGSIGN_PromptUsernameAndPassword } /* remember these values for next time */ - username = nsString(*user).ToNewCString(); - password = nsString(*pwd).ToNewCString(); - if (si_OkToSave(host, username)) { + if (si_OkToSave(host, nsAutoString(username))) { si_RememberSignonDataFromBrowser (host, username, password); } /* cleanup and return */ - PR_FREEIF(username); - PR_FREEIF(password); PR_FREEIF(host); return NS_OK; } @@ -2292,7 +2264,7 @@ SINGSIGN_PromptPassword (const PRUnichar *text, PRUnichar **pwd, const char *urlname, nsIPrompt* dialog, PRBool *returnValue) { nsresult res; - char *password=0, *username=0; + nsAutoString password, username; /* do only the dialog if signon preference is not enabled */ if (!si_GetSignonRememberingPref()){ @@ -2314,28 +2286,25 @@ SINGSIGN_PromptPassword } /* extract username from uri -- note: prehost is : */ - res = uri->GetPreHost(&username); + char * prehostCString; + res = uri->GetPreHost(&prehostCString); if (NS_FAILED(res)) { PR_FREEIF(host); return res; } - char * colon = (char*) PL_strchr(username, ':'); - if (colon) { - *colon = '\0'; - } + nsAutoString prehost = nsAutoString(prehostCString); + PRInt32 colon = prehost.Find(prehost, ':'); + prehost.Left(username, colon); + + PR_FREEIF(prehostCString); /* get previous password used with this username, pick first user if no username found */ - si_RestoreOldSignonDataFromBrowser(host, (username == nsnull), &username, &password); + si_RestoreOldSignonDataFromBrowser(host, (username.Length() == 0), username, password); /* return if a password was found */ - if (password) { - *pwd = nsAutoString(password).ToNewUnicode(); + if (password.Length() != 0) { + *pwd = password.ToNewUnicode(); *returnValue = PR_TRUE; - PR_FREEIF(password); - if (colon) { - *colon = ':'; - } - PR_FREEIF(username); PR_FREEIF(host); return NS_OK; } @@ -2344,26 +2313,17 @@ SINGSIGN_PromptPassword res = dialog->PromptPassword(text, nsnull /* window title */, pwd, returnValue); if (NS_FAILED(res) || !(*returnValue)) { /* user pressed Cancel */ - if (colon) { - *colon = ':'; - } - PR_FREEIF(username); PR_FREEIF(host); return res; } /* remember these values for next time */ - password = nsString(*pwd).ToNewCString(); - if (password && PL_strlen(password) && si_OkToSave(host, username)) { - si_RememberSignonDataFromBrowser (host, username, password); + nsAutoString temp = *pwd; + if (temp.Length() != 0 && si_OkToSave(host, username)) { + si_RememberSignonDataFromBrowser (host, username, nsAutoString(*pwd)); } /* cleanup and return */ - if (colon) { - *colon = ':'; - } - PR_FREEIF(username); - PR_FREEIF(password); PR_FREEIF(host); return NS_OK; } @@ -2380,70 +2340,45 @@ SINGSIGN_Prompt *****************/ /* return PR_TRUE if "number" is in sequence of comma-separated numbers */ -PUBLIC -PRBool SI_InSequence(char* sequence, int number) { - char* ptr; - char* endptr; - char* undo = NULL; - PRBool retval = PR_FALSE; - int i; +PUBLIC PRBool +SI_InSequence(nsAutoString sequence, PRInt32 number) { + nsAutoString tail = sequence; + nsAutoString head, temp; + PRInt32 separator; - /* not necessary -- routine will work even with null sequence */ - if (!*sequence) { - return PR_FALSE; - } + for (;;) { + /* get next item in list */ + separator = tail.FindChar(','); + if (-1 == separator) { + return PR_FALSE; + } + tail.Left(head, separator); + tail.Mid(temp, separator+1, tail.Length() - (separator+1)); + tail = temp; - for (ptr = sequence ; ptr ; ptr = endptr) { - - /* get to next comma */ - endptr = PL_strchr(ptr, ','); - - /* if comma found, process it */ - if (endptr) { - - /* restore last comma-to-null back to comma */ - if (undo) { - *undo = ','; - } - - /* set the comma to a null */ - undo = endptr; - *endptr++ = '\0'; - - /* compare the number before the comma with "number" */ - if (*ptr) { - i = atoi(ptr); - if (i == number) { - - /* "number" was in the sequence so return PR_TRUE */ - retval = PR_TRUE; - break; - } - } + /* test item to see if it equals our number */ + PRInt32 error; + PRInt32 numberInList = head.ToInteger(&error); + if (!error && numberInList == number) { + return PR_TRUE; } } - - /* restore last comma-to-null back to comma */ - if (undo) { - *undo = ','; - } - return retval; } -PUBLIC char* -SI_FindValueInArgs(nsAutoString results, char* name) { +PUBLIC PRUnichar* +SI_FindValueInArgs(nsAutoString results, nsAutoString name) { /* note: name must start and end with a vertical bar */ nsAutoString value; PRInt32 start, length; start = results.Find(name); PR_ASSERT(start >= 0); if (start < 0) { - return nsAutoString("").ToNewCString(); + return nsAutoString("").ToNewUnicode(); } - start += PL_strlen(name); /* get passed the |name| part */ + start += name.Length(); /* get passed the |name| part */ length = results.FindChar('|', PR_FALSE,start) - start; results.Mid(value, start, length); - return value.ToNewCString(); + return value.ToNewUnicode(); } extern void @@ -2467,7 +2402,8 @@ SINGSIGN_SignonViewerReturn (nsAutoString results) { /* * step backwards through all users and delete those that are in the sequence */ - char * gone = SI_FindValueInArgs(results, "|goneS|"); + nsAutoString gone; + gone = SI_FindValueInArgs(results, nsAutoString("|goneS|")); PRInt32 urlCount = LIST_COUNT(si_signon_list); while (urlCount>0) { urlCount--; @@ -2487,10 +2423,9 @@ SINGSIGN_SignonViewerReturn (nsAutoString results) { } } si_SaveSignonDataLocked(PR_TRUE); - delete[] gone; /* step backwards through all rejects and delete those that are in the sequence */ - gone = SI_FindValueInArgs(results, "|goneR|"); + gone = SI_FindValueInArgs(results, nsAutoString("|goneR|")); si_lock_signon_list(); PRInt32 rejectCount = LIST_COUNT(si_reject_list); while (rejectCount>0) { @@ -2503,7 +2438,6 @@ SINGSIGN_SignonViewerReturn (nsAutoString results) { } si_SaveSignonDataLocked(PR_FALSE); si_unlock_signon_list(); - delete[] gone; /* now give wallet a chance to do its deletions */ Wallet_SignonViewerReturn(results); @@ -2513,10 +2447,10 @@ SINGSIGN_SignonViewerReturn (nsAutoString results) { #define BREAK '\001' PUBLIC void -SINGSIGN_GetSignonListForViewer(nsString& aSignonList) +SINGSIGN_GetSignonListForViewer(nsAutoString& aSignonList) { - char *buffer = (char*)PR_Malloc(BUFLEN2); - int g = 0, signonNum; + nsAutoString buffer = ""; + int signonNum = 0; si_SignonURLStruct *url; si_SignonUserStruct * user; si_SignonDataStruct* data; @@ -2524,8 +2458,6 @@ SINGSIGN_GetSignonListForViewer(nsString& aSignonList) /* force loading of the signons file */ si_RegisterSignonPrefCallbacks(); - buffer[0] = '\0'; - signonNum = 0; PRInt32 urlCount = LIST_COUNT(si_signon_list); for (PRInt32 i=0; iElementAt(i)); @@ -2541,46 +2473,44 @@ SINGSIGN_GetSignonListForViewer(nsString& aSignonList) break; } } - g += PR_snprintf(buffer+g, BUFLEN2-g, -"%c \n", - BREAK, - signonNum, - url->URLName, - data->isPassword ? "" : data->value // just in case all fields were passwords - ); + buffer += BREAK; + buffer += "\n"; signonNum++; } } aSignonList = buffer; - PR_FREEIF(buffer); } PUBLIC void -SINGSIGN_GetRejectListForViewer(nsString& aRejectList) +SINGSIGN_GetRejectListForViewer(nsAutoString& aRejectList) { - char *buffer = (char*)PR_Malloc(BUFLEN2); - int g = 0, rejectNum; + nsAutoString buffer = ""; + int rejectNum = 0; si_Reject *reject; /* force loading of the signons file */ si_RegisterSignonPrefCallbacks(); - buffer[0] = '\0'; - rejectNum = 0; PRInt32 rejectCount = LIST_COUNT(si_reject_list); for (PRInt32 i=0; iElementAt(i)); - g += PR_snprintf(buffer+g, BUFLEN2-g, -"%c \n", - BREAK, - rejectNum, - reject->URLName, - reject->userName - ); + buffer += BREAK; + buffer += "\n"; rejectNum++; } aRejectList = buffer; - PR_FREEIF(buffer); } @@ -2611,9 +2541,9 @@ si_KeychainCallback( KCEvent keychainEvent, KCCallbackInfo *info, void *userCont PRIVATE int si_LoadSignonDataFromKeychain() { char * URLName; - LO_FormSubmitData submit; - char* name_array[MAX_ARRAY_SIZE]; - char* value_array[MAX_ARRAY_SIZE]; + si_FormSubmitData submit; + nsAutoString name_array[MAX_ARRAY_SIZE]; + nsAutoString value_array[MAX_ARRAY_SIZE]; uint8 type_array[MAX_ARRAY_SIZE]; char buffer[BUFFER_SIZE]; PRBool badInput = PR_FALSE; @@ -2626,9 +2556,9 @@ si_LoadSignonDataFromKeychain() { OSStatus status = noErr; KCSearchRef searchRef = NULL; /* initialize the submit structure */ - submit.name_array = (PA_Block)name_array; - submit.value_array = (PA_Block)value_array; - submit.type_array = (PA_Block)type_array; + submit.name_array = name_array; + submit.value_array = value_array; + submit.type_array = (PRUnichar *)type_array; /* set up the attribute list */ attrList.count = 2; @@ -2749,14 +2679,9 @@ si_LoadSignonDataFromKeychain() { si_PutData(URLName, &submit, PR_FALSE); } - /* free up all the allocations done for processing this URL */ - for (i = 0; i < submit.value_cnt; i++) { - PR_Free(name_array[i]); - PR_Free(value_array[i]); - } } else { /* reject */ - si_PutReject(URLName, buffer, PR_FALSE); + si_PutReject(URLName, nsAutoString(buffer), PR_FALSE); } reject = PR_FALSE; /* reset reject flag */ PR_Free(URLName); diff --git a/mozilla/extensions/wallet/src/singsign.h b/mozilla/extensions/wallet/src/singsign.h index 63b9838e8bb..80172d8b9e2 100644 --- a/mozilla/extensions/wallet/src/singsign.h +++ b/mozilla/extensions/wallet/src/singsign.h @@ -35,16 +35,16 @@ class nsIPrompt; XP_BEGIN_PROTOS extern void -SINGSIGN_GetSignonListForViewer (nsString& aSignonList); +SINGSIGN_GetSignonListForViewer (nsAutoString& aSignonList); extern void -SINGSIGN_GetRejectListForViewer (nsString& aRejectList); +SINGSIGN_GetRejectListForViewer (nsAutoString& aRejectList); extern void SINGSIGN_SignonViewerReturn(nsAutoString results); extern void -SINGSIGN_RestoreSignonData(char* URLName, char* name, char** value, PRUint32 elementNumber); +SINGSIGN_RestoreSignonData(char* URLName, PRUnichar* name, PRUnichar** value, PRUint32 elementNumber); extern nsresult SINGSIGN_PromptUsernameAndPassword @@ -61,7 +61,7 @@ SINGSIGN_Prompt const char *urlname,nsIPrompt* dialog, PRBool *returnValue); extern PRBool -SINGSIGN_RemoveUser(const char *URLName, char *userName); +SINGSIGN_RemoveUser(const char *URLName, PRUnichar *userName); XP_END_PROTOS diff --git a/mozilla/extensions/wallet/src/wallet.cpp b/mozilla/extensions/wallet/src/wallet.cpp index 1e432ee494d..411cdbf6e81 100644 --- a/mozilla/extensions/wallet/src/wallet.cpp +++ b/mozilla/extensions/wallet/src/wallet.cpp @@ -488,42 +488,6 @@ wallet_DumpStopwatch() { #endif /* DEBUG */ -/*************************************/ -/* Concatenating and Copying Strings */ -/*************************************/ - -#undef StrAllocCopy -#define StrAllocCopy(dest, src) Local_SACopy (&(dest), src) -PRIVATE char * -Local_SACopy(char **destination, const char *source) { - if(*destination) { - PL_strfree(*destination); - *destination = 0; - } - *destination = PL_strdup(source); - return *destination; -} - -#undef StrAllocCat -#define StrAllocCat(dest, src) Local_SACat (&(dest), src) -PRIVATE char * -Local_SACat(char **destination, const char *source) { - if (source && *source) { - if (*destination) { - int length = PL_strlen (*destination); - *destination = (char *) PR_Realloc(*destination, length + PL_strlen(source) + 1); - if (*destination == NULL) { - return(NULL); - } - PL_strcpy (*destination + length, source); - } else { - *destination = PL_strdup(source); - } - } - return *destination; -} - - /********************************************************/ /* The following data and procedures are for preference */ /********************************************************/ @@ -687,7 +651,7 @@ Wallet_Localize(char* genericString) { nsServiceManager::ReleaseService(kStringBundleServiceCID, pStringService); /* localize the given string */ - nsString strtmp(genericString); + nsAutoString strtmp(genericString); const PRUnichar *ptrtmp = strtmp.GetUnicode(); PRUnichar *ptrv = nsnull; ret = bundle->GetStringFromName(ptrtmp, &ptrv); @@ -716,7 +680,7 @@ Wallet_Confirm(PRUnichar * szMessage) return retval; } - const nsString message = szMessage; + const nsAutoString message = szMessage; retval = PR_FALSE; /* in case user exits dialog by clicking X */ res = dialog->Confirm(message.GetUnicode(), &retval); return retval; @@ -822,7 +786,7 @@ Wallet_Alert(PRUnichar * szMessage) return; // XXX should return the error } - const nsString message = szMessage; + const nsAutoString message = szMessage; res = dialog->Alert(message.GetUnicode()); return; // XXX should return the error } @@ -873,13 +837,14 @@ Wallet_CheckConfirmYN(PRUnichar * szMessage, PRUnichar * szCheckMessage, PRBool* return (buttonPressed == 0); } -char * wallet_GetString(PRUnichar * szMessage, PRUnichar * szMessage1) +nsresult +wallet_GetString(nsAutoString& result, PRUnichar * szMessage, PRUnichar * szMessage1) { - nsString password; + nsAutoString password; nsresult res; NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &res); if (NS_FAILED(res)) { - return NULL; // XXX should return the error + return res; } PRUnichar* pwd = NULL; @@ -909,25 +874,27 @@ char * wallet_GetString(PRUnichar * szMessage, PRUnichar * szMessage1) Recycle(prompt_string); if (NS_FAILED(res)) { - return NULL; + return res; } password = pwd; delete[] pwd; if (buttonPressed == 0) { - return password.ToNewCString(); + result = password; + return NS_OK; } else { - return NULL; /* user pressed cancel */ + return NS_ERROR_FAILURE; /* user pressed cancel */ } } -char * wallet_GetDoubleString(PRUnichar * szMessage, PRUnichar * szMessage1, PRUnichar * szMessage2, PRBool& matched) +nsresult +wallet_GetDoubleString(nsAutoString& result, PRUnichar * szMessage, PRUnichar * szMessage1, PRUnichar * szMessage2, PRBool& matched) { - nsString password, password2; + nsAutoString password, password2; nsresult res; NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &res); if (NS_FAILED(res)) { - return NULL; // XXX should return the error + return res; } PRUnichar* pwd = NULL; @@ -958,7 +925,7 @@ char * wallet_GetDoubleString(PRUnichar * szMessage, PRUnichar * szMessage1, PRU Recycle(prompt_string); if (NS_FAILED(res)) { - return NULL; + return res; } password = pwd; password2 = pwd2; @@ -967,9 +934,10 @@ char * wallet_GetDoubleString(PRUnichar * szMessage, PRUnichar * szMessage1, PRU matched = (password == password2); if (buttonPressed == 0) { - return password.ToNewCString(); + result = password; + return NS_OK; } else { - return NULL; /* user pressed cancel */ + return NS_ERROR_FAILURE; /* user pressed cancel */ } } @@ -1168,13 +1136,149 @@ wallet_ReadFromList( return wallet_ReadFromList(item1, item2, itemList, list, index); } + +/*************************************************************/ +/* The following routines are for reading/writing utf8 files */ +/*************************************************************/ + +/* + * For purposed of internationalization, characters are represented in memory as 16-bit + * values (unicode, aka UCS-2) rather than 7 bit values (ascii). For simplicity, the + * unicode representation of an ascii character has the upper 9 bits of zero and the + * lower 7 bits equal to the 7-bit ascii value. + * + * These 16-bit unicode values could be stored directly in files. However such files would + * not be readable by ascii editors even if they contained all ascii values. To solve + * this problem, the 16-bit unicode values are first encoded into a sequence of 8-bit + * characters before being written to the file -- the encoding is such that unicode + * characters which have the upper 9 bits of zero are encoded into a single 8-bit character + * of the same value whereas the remaining unicode characters are encoded into a sequence of + * more than one 8-bit character. + * + * There is a standard 8-bit-encoding of bit strings and it is called UTF-8. The format of + * UTF-8 is as follows: + * + * Up to 7 bits: 0xxxxxxx + * Up to 11 bits: 110xxxxx 10xxxxxx + * Up to 16 bits: 1110xxxx 10xxxxxx 10xxxxxx + * Up to 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + * Up to 26 bits: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx + * Up to 31 bits: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx + * + * Since we are converting unicode (16-bit) values, we need only be concerned with the + * first three lines above. + * + * There are conversion routines provided in intl/uconv which convert between unicode and + * UTF-8. However these routines are extremely cumbersome to use. So I have a very simple + * pair of encoding/decoding routines for converting between unicode characters and UTF-8 + * sequences. Here are the encoding/decoding algorithms that I use: + * + * encoding 16-bit unicode to 8-bit utf8 stream: + * if (unicodeChar <= 0x7F) { // up to 7 bits + * utf8Char1 = 0xxxxxxx + lower 7 bits of unicodeChar + * } else if (unicodeChar <= 0x7FF) { // up to 11 bits + * utf8Char1 = 110xxxxx + upper 5 bits of unicodeChar + * utf8Char2 = 10xxxxxx + lower 6 bits of unicodeChar + * } else { // up to 16 bits + * utf8Char1 = 1110xxxx + upper 4 bits of unicodeChar + * utf8Char2 = 10xxxxxx + next 6 bits of unicodeChar + * utf8Char3 = 10xxxxxx + lower 6 bits of unicodeChar + * } + * + * decoding 8-bit utf8 stream to 16-bit unicode: + * if (utf8Char1 starts with 0) { + * unicodeChar = utf8Char1; + * } else if (utf8Char1 starts with 110) { + * unicodeChar = (lower 5 bits of utf8Char1)<<6 + * + (lower 6 bits of utf8Char2); + * } else if (utf8Char1 starts with 1110) { + * unicodeChar = (lower 4 bits of utf8Char1)<<12 + * + (lower 6 bits of utf8Char2)<<6 + * + (lower 6 bits of utf8Char3); + * } else { + * error; + * } + * + */ + +PUBLIC void +Wallet_UTF8Put(nsOutputFileStream strm, PRUnichar c) { + if (c <= 0x7F) { + strm.put((char)c); + } else if (c <= 0x7FF) { + strm.put(((PRUnichar)0xC0) | ((c>>6) & 0x1F)); + strm.put(((PRUnichar)0x80) | (c & 0x3F)); + } else { + strm.put(((PRUnichar)0xE0) | ((c>>12) & 0xF)); + strm.put(((PRUnichar)0x80) | ((c>>6) & 0x3F)); + strm.put(((PRUnichar)0x80) | (c & 0x3F)); + } +} + +PUBLIC PRUnichar +Wallet_UTF8Get(nsInputFileStream strm) { + PRUnichar c = (strm.get() & 0xFF); + if ((c & 0x80) == 0x00) { + return c; + } else if ((c & 0xE0) == 0xC0) { + return (((c & 0x1F)<<6) + (strm.get() & 0x3F)); + } else if ((c & 0xF0) == 0xE0) { + return (((c & 0x0F)<<12) + ((strm.get() & 0x3F)<<6) + (strm.get() & 0x3F)); + } else { + return 0; /* this is an error, input was not utf8 */ + } +} + +/* + * I have an even a simpler set of routines if you are not concerned about UTF-8. The + * algorithms for those routines are as follows: + * + * encoding 16-bit unicode to 8-bit simple stream: + * if (unicodeChar < 0xFF) { + * simpleChar1 = unicodeChar + * } else { + * simpleChar1 = 0xFF + * simpleChar2 = upper 8 bits of unicodeChar + * simpleChar3 = lower 8 bits of unicodeChar + * } + * + * decoding 8-bit simple stream to 16-bit unicode: + * if (simpleChar1 < 0xFF) { + * unicodeChar = simpleChar1; + * } else { + * unicodeChar = 256*simpleChar2 + simpleChar3; + * } + * + */ + +PUBLIC void +Wallet_SimplePut(nsOutputFileStream strm, PRUnichar c) { + if (c < 0xFF) { + strm.put((char)c); + } else { + strm.put((PRUnichar)0xFF); + strm.put((c>>8) & 0xFF); + strm.put(c & 0xFF); + } +} + +PUBLIC PRUnichar +Wallet_SimpleGet(nsInputFileStream strm) { + PRUnichar c = (strm.get() & 0xFF); + if (c != 0xFF) { + return c; + } else { + return ((strm.get() & 0xFF)<<8) + (strm.get() & 0xFF); + } +} + + /************************************************************/ /* The following routines are for unlocking the stored data */ /************************************************************/ -#define maxKeySize 100 -char key[maxKeySize+1]; -PRUint32 keyPosition = 0; +nsAutoString key; +PRInt32 keyPosition = 0; PRBool keyCancel = PR_FALSE; PRBool keySet = PR_FALSE; time_t keyExpiresTime; @@ -1189,12 +1293,12 @@ Wallet_RestartKey() { keyPosition = 0; } -PUBLIC char +PUBLIC PRUnichar Wallet_GetKey() { - if (keyPosition >= PL_strlen(key)) { + if (keyPosition >= key.Length()) { keyPosition = 0; } - return key[keyPosition++]; + return key.CharAt(keyPosition++); } PUBLIC PRBool @@ -1294,7 +1398,7 @@ Wallet_KeySize() { if (!strm.is_open()) { return -1; } else { - strm.get(); + Wallet_UTF8Get(strm); PRInt32 ret = (strm.eof() ? 0 : 1); strm.close(); return ret; @@ -1303,12 +1407,13 @@ Wallet_KeySize() { PUBLIC PRBool Wallet_SetKey(PRBool isNewkey) { + nsresult res; if (Wallet_KeySet() && !isNewkey) { return PR_TRUE; } Wallet_RestartKey(); - char * newkey; + nsAutoString newkey; PRBool useDefaultKey = PR_FALSE; if (Wallet_KeySize() < 0) { /* no key has yet been established */ @@ -1318,12 +1423,12 @@ Wallet_SetKey(PRBool isNewkey) { PRUnichar * mismatch = Wallet_Localize("confirmFailed_TryAgain?"); PRBool matched; for (;;) { - newkey = wallet_GetDoubleString(message, message1, message2, matched); - if ((newkey != NULL) && matched) { + res = wallet_GetDoubleString(newkey, message, message1, message2, matched); + if (NS_SUCCEEDED(res) && matched) { break; /* break out of loop if both passwords matched */ } /* password confirmation failed, ask user if he wants to try again */ - if ((newkey == NULL) || (!Wallet_Confirm(mismatch))) { + if (NS_FAILED(res) || (!Wallet_Confirm(mismatch))) { Recycle(mismatch); Recycle(message); Recycle(message1); @@ -1349,16 +1454,16 @@ Wallet_SetKey(PRBool isNewkey) { } if ((Wallet_KeySize() == 0) && !isNewkey) { /* prev-established key is default key */ useDefaultKey = PR_TRUE; - newkey = PL_strdup("~"); + newkey = nsAutoString("~"); } else { /* ask the user for his key */ if (isNewkey) { /* user is changing his password */ for (;;) { - newkey = wallet_GetDoubleString(message, message1, message2, matched); - if ((newkey != NULL) && matched) { + res = wallet_GetDoubleString(newkey, message, message1, message2, matched); + if (!NS_FAILED(res) && matched) { break; /* break out of loop if both passwords matched */ } /* password confirmation failed, ask user if he wants to try again */ - if ((newkey == NULL) || (!Wallet_Confirm(mismatch))) { + if (NS_FAILED(res) || (!Wallet_Confirm(mismatch))) { Recycle(mismatch); Recycle(message); Recycle(message1); @@ -1368,9 +1473,9 @@ Wallet_SetKey(PRBool isNewkey) { } } } else { - newkey = wallet_GetString(message, message1); + res = wallet_GetString(newkey, message, message1); } - if (newkey == NULL) { + if (NS_FAILED(res)) { Recycle(message); Recycle(message1); Recycle(message2); @@ -1385,19 +1490,15 @@ Wallet_SetKey(PRBool isNewkey) { Recycle(mismatch); } - if (PL_strlen(newkey) == 0) { /* user entered a zero-length key */ + if (newkey.Length() == 0) { /* user entered a zero-length key */ if ((Wallet_KeySize() < 0) || isNewkey ){ /* no key file existed before or using is changing the key */ useDefaultKey = PR_TRUE; - PR_FREEIF(newkey); - newkey = PL_strdup("~"); /* use zero-length key */ + newkey = nsAutoString("~"); /* use zero-length key */ } } - for (; (keyPosition < PL_strlen(newkey) && keyPosition < maxKeySize); keyPosition++) { - key[keyPosition] = newkey[keyPosition]; - } - key[keyPosition] = '\0'; - PR_FREEIF(newkey); + + key = newkey; Wallet_RestartKey(); /* verify this with the saved key */ @@ -1416,7 +1517,7 @@ Wallet_SetKey(PRBool isNewkey) { } nsOutputFileStream strm2(dirSpec + keyFileName); if (!strm2.is_open()) { - *key = '\0'; + key = nsAutoString(""); keyCancel = PR_TRUE; return PR_FALSE; } @@ -1426,12 +1527,11 @@ Wallet_SetKey(PRBool isNewkey) { * key[1..n],key[0] obscured by the actual key. */ - if (!useDefaultKey && (PL_strlen(key) != 0)) { - char* p = key+1; - while (*p) { - strm2.put(*(p++)^Wallet_GetKey()); + if (!useDefaultKey && (key.Length() != 0)) { + for (PRInt32 i = 1; i < key.Length(); i++) { + Wallet_UTF8Put(strm2, (key.CharAt(i))^Wallet_GetKey()); } - strm2.put((*key)^Wallet_GetKey()); + Wallet_UTF8Put(strm2, (key.CharAt(0))^Wallet_GetKey()); } strm2.flush(); strm2.close(); @@ -1464,22 +1564,22 @@ Wallet_SetKey(PRBool isNewkey) { } nsInputFileStream strm(dirSpec + keyFileName); Wallet_RestartKey(); - char* p = key+1; - while (*p) { - if (strm.get() != (*(p++)^Wallet_GetKey()) || strm.eof()) { + + for (PRInt32 j = 1; j < key.Length(); j++) { + if (Wallet_UTF8Get(strm) != ((key.CharAt(j))^Wallet_GetKey()) || strm.eof()) { strm.close(); - *key = '\0'; + key = nsAutoString(""); keyCancel = PR_FALSE; return PR_FALSE; } } - if (strm.get() != ((*key)^Wallet_GetKey()) || strm.eof()) { + if (Wallet_UTF8Get(strm) != ((key.CharAt(0))^Wallet_GetKey()) || strm.eof()) { strm.close(); - *key = '\0'; + key = nsAutoString(""); keyCancel = PR_FALSE; return PR_FALSE; } - strm.get(); /* to get past the end of the file so eof() will get set */ + Wallet_UTF8Get(strm); /* to get past the end of the file so eof() will get set */ PRBool rv = strm.eof(); strm.close(); if (rv) { @@ -1488,7 +1588,7 @@ Wallet_SetKey(PRBool isNewkey) { keyExpiresTime = time(NULL) + keyDuration; return PR_TRUE; } else { - *key = '\0'; + key = nsAutoString(""); keyCancel = PR_TRUE; return PR_FALSE; } @@ -1508,9 +1608,9 @@ PRInt32 wallet_GetLine(nsInputFileStream strm, nsAutoString& line, PRBool obscure) { /* read the line */ - char c; + PRUnichar c; for (;;) { - c = strm.get()^(obscure ? Wallet_GetKey() : (char)0); + c = Wallet_UTF8Get(strm)^(obscure ? Wallet_GetKey() : (PRUnichar)0); if (c == '\n') { break; } @@ -1530,35 +1630,15 @@ wallet_GetLine(nsInputFileStream strm, nsAutoString& line, PRBool obscure) { /* * Write a line to a file - * return -1 if an error occurs */ -PRInt32 -wallet_PutLine(nsOutputFileStream strm, const nsString& line, PRBool obscure) +void +//@@@@@ why do we need the const and & for "line" on the next line +wallet_PutLine(nsOutputFileStream strm, const nsAutoString& line, PRBool obscure) { - /* allocate a buffer from the heap */ - for (int i=0; iElementAt(i)); - if (NS_FAILED(wallet_PutLine(strm, (*ptr).item1, obscure))) { - break; - } + wallet_PutLine(strm, (*ptr).item1, obscure); if ((*ptr).item2 != "") { - if (NS_FAILED(wallet_PutLine(strm, (*ptr).item2, obscure))) { - break; - } + wallet_PutLine(strm, (*ptr).item2, obscure); } else { wallet_Sublist * ptr1; PRInt32 count2 = LIST_COUNT(ptr->itemList); for (PRInt32 j=0; jitemList->ElementAt(j)); - if (NS_FAILED(wallet_PutLine(strm, (*ptr).item1, obscure))) { - break; - } + wallet_PutLine(strm, (*ptr).item1, obscure); } } - if (NS_FAILED(wallet_PutLine(strm, "", obscure))) { - break; - } + wallet_PutLine(strm, "", obscure); } /* close the stream */ @@ -2051,24 +2123,21 @@ wallet_FetchFromNetCenter() { if (NS_FAILED(rv)) { return; } - StrAllocCopy(url, wallet_Server); - StrAllocCat(url, "URLFieldSchema.tbl"); + url = (nsAutoString(wallet_Server) + "URLFieldSchema.tbl").ToNewCString(); rv = NS_NewURItoFile(url, dirSpec, "URLFieldSchema.tbl"); - PR_FREEIF(url); + Recycle(url); if (NS_FAILED(rv)) { return; } - StrAllocCopy(url, wallet_Server); - StrAllocCat(url, "SchemaConcat.tbl"); + url = (nsAutoString(wallet_Server) + "SchemaConcat.tbl").ToNewCString(); rv = NS_NewURItoFile(url, dirSpec, "SchemaConcat.tbl"); - PR_FREEIF(url); + Recycle(url); if (NS_FAILED(rv)) { return; } - StrAllocCopy(url, wallet_Server); - StrAllocCat(url, "FieldSchema.tbl"); + url = (nsAutoString(wallet_Server) + "FieldSchema.tbl").ToNewCString(); rv = NS_NewURItoFile(url, dirSpec, "FieldSchema.tbl"); - PR_FREEIF(url); + Recycle(url); if (NS_FAILED(rv)) { return; } @@ -2187,7 +2256,7 @@ wallet_InitializeURLList() { } } -nsString +nsAutoString wallet_GetHostFile(nsIURI * url) { nsAutoString urlName = nsAutoString(""); char* host; @@ -2252,19 +2321,15 @@ wallet_InitializeCurrentURL(nsIDocument * doc) { #define SEPARATOR "#*%$" -nsAutoString * -wallet_GetNextInString(char*& ptr) { - nsAutoString * result; - char * endptr; - endptr = PL_strstr(ptr, SEPARATOR); - if (!endptr) { - return NULL; +PRInt32 +wallet_GetNextInString(nsAutoString str, nsAutoString& head, nsAutoString& tail) { + PRInt32 separator = str.Find(SEPARATOR); + if (separator == -1) { + return -1; } - *endptr = '\0'; - result = new nsAutoString(ptr); - *endptr = SEPARATOR[0]; - ptr = endptr + PL_strlen(SEPARATOR); - return result; + str.Left(head, separator); + str.Mid(tail, separator+PL_strlen(SEPARATOR), str.Length() - (separator+PL_strlen(SEPARATOR))); + return 0; } void @@ -2291,43 +2356,45 @@ wallet_ReleasePrefillElementList(nsVoidArray * wallet_PrefillElement_list) { #define BREAK '\001' nsVoidArray * wallet_list; -nsString wallet_url; +nsAutoString wallet_url; PUBLIC void -WLLT_GetPrefillListForViewer(nsString& aPrefillList) +WLLT_GetPrefillListForViewer(nsAutoString& aPrefillList) { - char *buffer = (char*)PR_Malloc(BUFLEN3); - int g = 0; wallet_PrefillElement * ptr; - buffer[0] = '\0'; - char * schema; - char * value; + nsAutoString buffer = ""; + PRUnichar * schema; + PRUnichar * value; PRInt32 count = LIST_COUNT(wallet_list); for (PRInt32 i=0; iElementAt(i)); - schema = ptr->schema->ToNewCString(); - value = ptr->value->ToNewCString(); - g += PR_snprintf(buffer+g, BUFLEN3-g, - "%c%d%c%s%c%s", - BREAK, ptr->count, - BREAK, schema, - BREAK, value); - delete []schema; - delete []value; + schema = ptr->schema->ToNewUnicode(); + value = ptr->value->ToNewUnicode(); + buffer += BREAK; + buffer.Append(ptr->count,10); + buffer += BREAK; + buffer += schema; + buffer += BREAK; + buffer += value; + Recycle(schema); + Recycle(value); } - char * urlCString; - urlCString = wallet_url.ToNewCString(); - g += PR_snprintf(buffer+g, BUFLEN3-g,"%c%p%c%s", BREAK, wallet_list, BREAK, urlCString); - delete []urlCString; + + PRUnichar * urlUnichar = wallet_url.ToNewUnicode(); + buffer += BREAK; + buffer += (PRInt32)wallet_list; + buffer += BREAK; + buffer += urlUnichar; + Recycle(urlUnichar); + aPrefillList = buffer; - PR_FREEIF(buffer); } extern PRBool -SI_InSequence(char* sequence, int number); +SI_InSequence(nsAutoString sequence, int number); -extern char* -SI_FindValueInArgs(nsAutoString results, char* name); +extern PRUnichar* +SI_FindValueInArgs(nsAutoString results, nsAutoString name); PRIVATE void wallet_FreeURL(wallet_MapElement *url) { @@ -2342,10 +2409,10 @@ wallet_FreeURL(wallet_MapElement *url) { PUBLIC void Wallet_SignonViewerReturn (nsAutoString results) { wallet_MapElement *url; - char * gone; + nsAutoString gone; /* step through all nopreviews and delete those that are in the sequence */ - gone = SI_FindValueInArgs(results, "|goneP|"); + gone = SI_FindValueInArgs(results, nsAutoString("|goneP|")); PRInt32 count = LIST_COUNT(wallet_URL_list); while (count>0) { count--; @@ -2358,10 +2425,9 @@ Wallet_SignonViewerReturn (nsAutoString results) { } } } - delete[] gone; /* step through all nocaptures and delete those that are in the sequence */ - gone = SI_FindValueInArgs(results, "|goneC|"); + gone = SI_FindValueInArgs(results, nsAutoString("|goneC|")); PRInt32 count2 = LIST_COUNT(wallet_URL_list); while (count2>0) { count2--; @@ -2374,7 +2440,6 @@ Wallet_SignonViewerReturn (nsAutoString results) { } } } - delete[] gone; } #ifdef AutoCapture @@ -2418,7 +2483,7 @@ wallet_OKToCapture(char* urlName) { * capture the value of a form element */ PRIVATE void -wallet_Capture(nsIDocument* doc, nsAutoString field, nsAutoString value, nsString vcard) { +wallet_Capture(nsIDocument* doc, nsAutoString field, nsAutoString value, nsAutoString vcard) { /* do nothing if there is no value */ if (!value.Length()) { @@ -2519,63 +2584,51 @@ wallet_Capture(nsIDocument* doc, nsAutoString field, nsAutoString value, nsStrin #define BREAK '\001' PUBLIC void -WLLT_GetNopreviewListForViewer(nsString& aNopreviewList) +WLLT_GetNopreviewListForViewer(nsAutoString& aNopreviewList) { - char *buffer = (char*)PR_Malloc(BUFLEN2); - int g = 0, nopreviewNum; + nsAutoString buffer = ""; + int nopreviewNum = 0; wallet_MapElement *url; - char* urlCString; wallet_InitializeURLList(); - buffer[0] = '\0'; - nopreviewNum = 0; PRInt32 count = LIST_COUNT(wallet_URL_list); for (PRInt32 i=0; iElementAt(i)); if (url->item2.CharAt(NO_PREVIEW) == 'y') { - urlCString = url->item1.ToNewCString(); - g += PR_snprintf(buffer+g, BUFLEN2-g, -"%c \n", - BREAK, - nopreviewNum, - urlCString - ); - delete[] urlCString; + buffer += BREAK; + buffer += "\n"; nopreviewNum++; } } aNopreviewList = buffer; - PR_FREEIF(buffer); } PUBLIC void -WLLT_GetNocaptureListForViewer(nsString& aNocaptureList) +WLLT_GetNocaptureListForViewer(nsAutoString& aNocaptureList) { - char *buffer = (char*)PR_Malloc(BUFLEN2); - int g = 0, nocaptureNum; + nsAutoString buffer = ""; + int nocaptureNum = 0; wallet_MapElement *url; - char* urlCString; wallet_InitializeURLList(); - buffer[0] = '\0'; - nocaptureNum = 0; PRInt32 count = LIST_COUNT(wallet_URL_list); for (PRInt32 i=0; iElementAt(i)); if (url->item2.CharAt(NO_CAPTURE) == 'y') { - urlCString = url->item1.ToNewCString(); - g += PR_snprintf(buffer+g, BUFLEN2-g, -"%c \n", - BREAK, - nocaptureNum, - urlCString - ); - delete[] urlCString; + buffer += BREAK; + buffer += "\n"; nocaptureNum++; } } aNocaptureList = buffer; - PR_FREEIF(buffer); } PUBLIC void @@ -2584,63 +2637,55 @@ WLLT_PostEdit(nsAutoString walletList) { return; } - char* separator; - nsFileSpec dirSpec; nsresult rv = Wallet_ProfileDirectory(dirSpec); if (NS_FAILED(rv)) { return; } - /* convert walletList to a C string */ - char *walletListAsCString = walletList.ToNewCString(); - char *nextItem = walletListAsCString; + 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 */ - separator = strchr(nextItem, BREAK); - if (!separator) { - delete[] walletListAsCString; + if (head != "OK") { return; } - *separator = '\0'; - if (PL_strcmp(nextItem, "OK")) { - *separator = BREAK; - delete []walletListAsCString; - return; - } - nextItem = separator+1; - *separator = BREAK; /* open SchemaValue file */ nsOutputFileStream strm(dirSpec + schemaValueFileName); if (!strm.is_open()) { NS_ERROR("unable to open file"); - delete []walletListAsCString; return; } Wallet_RestartKey(); /* write the values in the walletList to the file */ - for (int i=0; (*nextItem != '\0'); i++) { - separator = strchr(nextItem, BREAK); - if (!separator) { - strm.close(); - delete[] walletListAsCString; + for (;;) { + separator = tail.FindChar(BREAK); + if (-1 == separator) { return; } - *separator = '\0'; - if (NS_FAILED(wallet_PutLine(strm, nextItem, PR_TRUE))) { - break; - } - nextItem = separator+1; - *separator = BREAK; + tail.Left(head, separator); + tail.Mid(temp, separator+1, tail.Length() - (separator+1)); + tail = temp; + + wallet_PutLine(strm, head, PR_TRUE); } /* close the file and read it back into the SchemaToValue list */ strm.close(); wallet_Clear(&wallet_SchemaToValue_list); wallet_ReadFromFile(schemaValueFileName, wallet_SchemaToValue_list, PR_TRUE, PR_TRUE); - delete []walletListAsCString; } PUBLIC void @@ -2676,20 +2721,20 @@ WLLT_PreEdit(nsAutoString& walletList) { */ PUBLIC void WLLT_PrefillReturn(nsAutoString results) { - char* listAsAscii; - char* fillins; - char* urlName; - char* skip; - nsAutoString * next; + PRUnichar* listAsAscii; + PRUnichar* fillins; + PRUnichar* urlName; + PRUnichar* skip; + nsAutoString next; /* get values that are in environment variables */ - fillins = SI_FindValueInArgs(results, "|fillins|"); - listAsAscii = SI_FindValueInArgs(results, "|list|"); - skip = SI_FindValueInArgs(results, "|skip|"); - urlName = SI_FindValueInArgs(results, "|url|"); + fillins = SI_FindValueInArgs(results, nsAutoString("|fillins|")); + listAsAscii = SI_FindValueInArgs(results, nsAutoString("|list|")); + skip = SI_FindValueInArgs(results, nsAutoString("|skip|")); + urlName = SI_FindValueInArgs(results, nsAutoString("|url|")); /* add url to url list if user doesn't want to preview this page in the future */ - if (!PL_strcmp(skip, "true")) { + if (nsAutoString(skip) == "true") { nsAutoString url = nsAutoString(urlName); nsVoidArray* dummy; nsAutoString value = nsAutoString("nn"); @@ -2701,7 +2746,8 @@ WLLT_PrefillReturn(nsAutoString results) { /* process the list, doing the fillins */ nsVoidArray * list; - sscanf(listAsAscii, "%p", &list); + PRInt32 error; + list = (nsVoidArray *)nsAutoString(listAsAscii).ToInteger(&error); if (fillins[0] == '\0') { /* user pressed CANCEL */ wallet_ReleasePrefillElementList(list); return; @@ -2720,10 +2766,8 @@ WLLT_PrefillReturn(nsAutoString results) { */ wallet_PrefillElement * ptr; - char * ptr2; - ptr2 = fillins; + nsAutoString ptr2 = nsAutoString(fillins); /* step through pre-fill list */ - PRBool first = PR_TRUE; PRInt32 count = LIST_COUNT(list); for (PRInt32 i=0; iElementAt(i)); @@ -2731,22 +2775,18 @@ WLLT_PrefillReturn(nsAutoString results) { /* advance in fillins list each time a new schema name in pre-fill list is encountered */ if (ptr->count != 0) { /* count != 0 indicates a new schema name */ - if (!first) { - delete next; - } else { - first = PR_FALSE; - } - next = wallet_GetNextInString(ptr2); - if (nsnull == next) { + nsAutoString tail; + if (wallet_GetNextInString(ptr2, next, tail) == -1) { break; } - if (*next != *ptr->schema) { + ptr2 = tail; + if (next != *ptr->schema) { break; /* something's wrong so stop prefilling */ } - delete next; - next = wallet_GetNextInString(ptr2); + wallet_GetNextInString(ptr2, next, tail); + ptr2 = tail; } - if (*next == *ptr->value) { + if (next == *ptr->value) { /* * Remove entry from wallet_SchemaToValue_list and then reinsert. This will * keep multiple values in that list for the same field ordered with @@ -2781,12 +2821,12 @@ WLLT_PrefillReturn(nsAutoString results) { } /* Change the value */ - if ((*next == *ptr->value) || ((ptr->count>0) && (*next == ""))) { - if (((*next == *ptr->value) || (*next == "")) && ptr->inputElement) { - ptr->inputElement->SetValue(*next); + if ((next == *ptr->value) || ((ptr->count>0) && (next == ""))) { + if (((next == *ptr->value) || (next == "")) && ptr->inputElement) { + ptr->inputElement->SetValue(next); } else { nsresult result; - result = wallet_GetSelectIndex(ptr->selectElement, *next, ptr->selectIndex); + result = wallet_GetSelectIndex(ptr->selectElement, next, ptr->selectIndex); if (NS_SUCCEEDED(result)) { ptr->selectElement->SetSelectedIndex(ptr->selectIndex); } else { @@ -2795,9 +2835,6 @@ WLLT_PrefillReturn(nsAutoString results) { } } } - if (next != nsnull ) { - delete next; - } /* Release the prefill list that was generated when we walked thru the html content */ wallet_ReleasePrefillElementList(list); @@ -2980,7 +3017,7 @@ wallet_ClearStopwatch(); extern void SINGSIGN_RememberSignonData - (char* URLName, char** name_array, char** value_array, char** type_array, PRInt32 value_cnt); + (char* URLName, nsAutoString* name_array, nsAutoString* value_array, char** type_array, PRInt32 value_cnt); PUBLIC void WLLT_RequestToCapture(nsIPresShell* shell) { @@ -3133,8 +3170,8 @@ WLLT_OnSubmit(nsIContent* formNode) { result = formElement->GetElements(&elements); if ((NS_SUCCEEDED(result)) && (nsnull != elements)) { - char* name_array[MAX_ARRAY_SIZE]; - char* value_array[MAX_ARRAY_SIZE]; + nsAutoString name_array[MAX_ARRAY_SIZE]; + nsAutoString value_array[MAX_ARRAY_SIZE]; uint8 type_array[MAX_ARRAY_SIZE]; PRInt32 value_cnt = 0; @@ -3172,8 +3209,8 @@ WLLT_OnSubmit(nsIContent* formNode) { nsAutoString field; result = inputElement->GetName(field); if (NS_SUCCEEDED(result)) { - value_array[value_cnt] = value.ToNewCString(); - name_array[value_cnt] = field.ToNewCString(); + value_array[value_cnt] = value; + name_array[value_cnt] = field; value_cnt++; } } @@ -3188,7 +3225,7 @@ WLLT_OnSubmit(nsIContent* formNode) { /* save login if appropriate */ SINGSIGN_RememberSignonData - (URLName, (char**)name_array, (char**)value_array, (char**)type_array, value_cnt); + (URLName, name_array, value_array, (char**)type_array, value_cnt); #ifndef AutoCapture /* give notification if this is first significant form submitted */ diff --git a/mozilla/extensions/wallet/src/wallet.h b/mozilla/extensions/wallet/src/wallet.h index ff9c30f8381..1cf9e2db1a3 100644 --- a/mozilla/extensions/wallet/src/wallet.h +++ b/mozilla/extensions/wallet/src/wallet.h @@ -55,13 +55,13 @@ extern nsresult WLLT_Prefill(nsIPresShell* shell, PRBool quick); extern void -WLLT_GetNopreviewListForViewer (nsString& aNopreviewList); +WLLT_GetNopreviewListForViewer (nsAutoString& aNopreviewList); extern void -WLLT_GetNocaptureListForViewer (nsString& aNocaptureList); +WLLT_GetNocaptureListForViewer (nsAutoString& aNocaptureList); extern void -WLLT_GetPrefillListForViewer (nsString& aPrefillList); +WLLT_GetPrefillListForViewer (nsAutoString& aPrefillList); extern void WLLT_OnSubmit (nsIContent* formNode); diff --git a/mozilla/extensions/wallet/walletpreview/nsIWalletPreview.idl b/mozilla/extensions/wallet/walletpreview/nsIWalletPreview.idl index f8db8cbed5c..4f617e79abc 100644 --- a/mozilla/extensions/wallet/walletpreview/nsIWalletPreview.idl +++ b/mozilla/extensions/wallet/walletpreview/nsIWalletPreview.idl @@ -35,8 +35,8 @@ [scriptable, uuid(8F4CFE41-2152-11d3-ABAA-0080C787AD96)] interface nsIWalletPreview : nsISupports { - void SetValue(in string aValue, in nsIDOMWindow win); - string GetPrefillValue(); + void SetValue(in wstring aValue, in nsIDOMWindow win); + wstring GetPrefillValue(); }; %{ C++ diff --git a/mozilla/extensions/wallet/walletpreview/nsWalletPreview.cpp b/mozilla/extensions/wallet/walletpreview/nsWalletPreview.cpp index 3b1643bc3ae..21b90b3b124 100644 --- a/mozilla/extensions/wallet/walletpreview/nsWalletPreview.cpp +++ b/mozilla/extensions/wallet/walletpreview/nsWalletPreview.cpp @@ -49,7 +49,7 @@ WalletPreviewImpl::~WalletPreviewImpl() NS_IMPL_ISUPPORTS1(WalletPreviewImpl, nsIWalletPreview) NS_IMETHODIMP -WalletPreviewImpl::GetPrefillValue(char** aValue) +WalletPreviewImpl::GetPrefillValue(PRUnichar** aValue) { NS_PRECONDITION(aValue != nsnull, "null ptr"); if (!aValue) { @@ -61,7 +61,7 @@ WalletPreviewImpl::GetPrefillValue(char** aValue) nsAutoString walletList; res = walletservice->WALLET_GetPrefillListForViewer(walletList); if (NS_SUCCEEDED(res)) { - *aValue = walletList.ToNewCString(); + *aValue = walletList.ToNewUnicode(); } return res; } @@ -86,7 +86,7 @@ static void DOMWindowToWebShellWindow( } NS_IMETHODIMP -WalletPreviewImpl::SetValue(const char* aValue, nsIDOMWindow* win) +WalletPreviewImpl::SetValue(const PRUnichar* aValue, nsIDOMWindow* win) { /* close the window */ if (!win) { diff --git a/mozilla/netwerk/base/public/nsIPrompt.idl b/mozilla/netwerk/base/public/nsIPrompt.idl index b721a60c7d6..85ad35dfef5 100644 --- a/mozilla/netwerk/base/public/nsIPrompt.idl +++ b/mozilla/netwerk/base/public/nsIPrompt.idl @@ -75,7 +75,7 @@ interface nsIPrompt : nsISupports boolean select(in wstring inDialogTitle, in wstring inMsg, in PRUint32 inCount, - [array, size_is(inCount)] in string inList, + [array, size_is(inCount)] in wstring inList, out long outSelection); /** diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index f3a49ed10c1..22f9e7c73a6 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -2277,7 +2277,7 @@ nsBrowserWindow::PromptPassword(const PRUnichar *text, return NS_OK; } -nsresult nsBrowserWindow::Select(const PRUnichar *, const PRUnichar *, PRUint32 , const char **, PRInt32 *, PRBool *_retval) +nsresult nsBrowserWindow::Select(const PRUnichar *, const PRUnichar *, PRUint32 , const PRUnichar **, PRInt32 *, PRBool *_retval) { return NS_OK; } diff --git a/mozilla/xpfe/appshell/public/nsICommonDialogs.idl b/mozilla/xpfe/appshell/public/nsICommonDialogs.idl index 6611d223f14..3d538837023 100644 --- a/mozilla/xpfe/appshell/public/nsICommonDialogs.idl +++ b/mozilla/xpfe/appshell/public/nsICommonDialogs.idl @@ -94,7 +94,7 @@ enum { eButtonPressed = 0, eCheckboxState = 1, eNumberButtons = 2, eNumberEditfi in wstring inDialogTitle, in wstring inMsg, in PRUint32 inCount, - [array,size_is(inCount) ] in string inList, + [array,size_is(inCount) ] in wstring inList, out long outSelection ); /** diff --git a/mozilla/xpfe/appshell/src/nsCommonDialogs.cpp b/mozilla/xpfe/appshell/src/nsCommonDialogs.cpp index 3080f60e322..bfd7ae28029 100644 --- a/mozilla/xpfe/appshell/src/nsCommonDialogs.cpp +++ b/mozilla/xpfe/appshell/src/nsCommonDialogs.cpp @@ -387,7 +387,7 @@ NS_IMETHODIMP nsCommonDialogs::PromptPassword(nsIDOMWindow *inParent, const PRU -nsresult nsCommonDialogs::Select(nsIDOMWindow *inParent, const PRUnichar *inDialogTitle, const PRUnichar* inMsg, PRUint32 inCount, const char **inList, PRInt32 *outSelection, PRBool *_retval) +nsresult nsCommonDialogs::Select(nsIDOMWindow *inParent, const PRUnichar *inDialogTitle, const PRUnichar* inMsg, PRUint32 inCount, const PRUnichar **inList, PRInt32 *outSelection, PRBool *_retval) { nsresult rv; const PRInt32 eSelection = 2 ; diff --git a/mozilla/xpfe/appshell/src/nsNetSupportDialog.cpp b/mozilla/xpfe/appshell/src/nsNetSupportDialog.cpp index 9bc681e8f2e..95f8dae4932 100644 --- a/mozilla/xpfe/appshell/src/nsNetSupportDialog.cpp +++ b/mozilla/xpfe/appshell/src/nsNetSupportDialog.cpp @@ -568,7 +568,7 @@ NS_IMETHODIMP nsNetSupportDialog::PromptPassword(const PRUnichar *text, #endif } -nsresult nsNetSupportDialog::Select(const PRUnichar *inDialogTitle, const PRUnichar *inMsg, PRUint32 inCount, const char **inList, PRInt32 *outSelection, PRBool *_retval) +nsresult nsNetSupportDialog::Select(const PRUnichar *inDialogTitle, const PRUnichar *inMsg, PRUint32 inCount, const PRUnichar **inList, PRInt32 *outSelection, PRBool *_retval) { nsresult rv; NS_WITH_SERVICE(nsIAppShellService, appshellservice, kAppShellServiceCID, &rv); diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index 5c3a18ed640..e5340c59c59 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -3071,7 +3071,7 @@ NS_IMETHODIMP nsWebShellWindow::PromptPassword(const PRUnichar *text, const PRUn return rv; } -NS_IMETHODIMP nsWebShellWindow::Select( const PRUnichar *inDialogTitle, const PRUnichar* inMsg, PRUint32 inCount, const char **inList, PRInt32 *outSelection, PRBool *_retval) +NS_IMETHODIMP nsWebShellWindow::Select( const PRUnichar *inDialogTitle, const PRUnichar* inMsg, PRUint32 inCount, const PRUnichar **inList, PRInt32 *outSelection, PRBool *_retval) { nsresult rv; nsCOMPtr domWindow;