if (dialogTitle) { CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsDependentString(dialogTitle), pStr); theDialog->SetDescriptor(pStr);
if (dialogTitle) mTitle = _tcsdup(W2T(dialogTitle)); mMessage = _tcsdup(W2T(text)); if (checkMsg) { NS_ENSURE_ARG_POINTER(checkValue); mCheckMessage = _tcsdup(W2T(checkMsg)); mCheckValue = (*checkValue == PR_TRUE) ? TRUE : FALSE; } if (username) { mUsername = _tcsdup(W2T(*username)); } if (password) { mPassword = _tcsdup(W2T(*password));
NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent, const PRUnichar *dialogTitle,                                                        const PRUnichar *text,                                                        PRUnichar **username, PRUnichar **password,                                                        const PRUnichar *checkMsg, PRBool *checkValue,                                                        PRBool *_retval){    NS_ENSURE_ARG_POINTER(_retval);    nsresult resultErr = NS_OK;    StDialogHandler	theHandler(dlog_PromptNameAndPass, CBrowserChrome::GetLWindowForDOMWindow(parent));    LWindow			 *theDialog = theHandler.GetDialog();    LCheckBox        *checkbox = dynamic_cast<LCheckBox*>(theDialog->FindPaneByID('Chck'));    nsCAutoString   cStr;    Str255          pStr;    if (dialogTitle) {        CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsDependentString(dialogTitle), pStr);        theDialog->SetDescriptor(pStr);    }    LStaticText	*msgText = dynamic_cast<LStaticText*>(theDialog->FindPaneByID('Msg '));    CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsDependentString(text), cStr);    cStr.ReplaceChar('\n', '\r');    msgText->SetText(const_cast<char *>(cStr.get()), cStr.Length());        LEditText *userText = dynamic_cast<LEditText*>(theDialog->FindPaneByID('Name'));    if (username && *username) {        CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsDependentString(*username), pStr);        userText->SetDescriptor(pStr);    }    LEditText *pwdText = dynamic_cast<LEditText*>(theDialog->FindPaneByID('Pass'));    if (password && *password) {        CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsDependentString(*password), pStr);        pwdText->SetDescriptor(pStr);    }    if (checkValue) {        checkbox->SetValue(*checkValue);        if (checkMsg) {            CPlatformUCSConversion::GetInstance()->UCSToPlatform(nsDependentString(checkMsg), pStr);            checkbox->SetDescriptor(pStr);        }    }    else        checkbox->Hide();     theDialog->SetLatentSub(userText);       theDialog->Show();    theDialog->Select();		while (true)  // This is our modal dialog event loop	{						MessageT	hitMessage = theHandler.DoDialog();				if (hitMessage == msg_OK)		{		    nsAutoString    ucStr;		    		    if (username && *username) {		        nsMemory::Free(*username);		        *username = nsnull;		    }		    userText->GetDescriptor(pStr);		    CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr);		    *username = ToNewUnicode(ucStr);		    if (*username == nsnull)		        resultErr = NS_ERROR_OUT_OF_MEMORY;		    		    if (password && *password) {		        nsMemory::Free(*password);		        *password = nsnull;		    }		    pwdText->GetDescriptor(pStr);		    CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr);		    *password = ToNewUnicode(ucStr);		    if (*password == nsnull)		        resultErr = NS_ERROR_OUT_OF_MEMORY;   		    if (checkValue)   		        *checkValue = checkbox->GetValue();		    		    *_retval = PR_TRUE;           		    break;   		}   		else if (hitMessage == msg_Cancel)   		{   		    *_retval = PR_FALSE;   		    break;   		}	}    return resultErr;}