Add new routine for setting numer of strings
Fix bug in password dialog git-svn-id: svn://10.0.0.236/trunk@43445 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
4f462f9a4f
commit
4a4473fae1
@ -29,6 +29,13 @@ class nsIFactory;
|
||||
[scriptable, uuid(c01ad082-4915-11d3-b7a0-85cf55c3523c)]
|
||||
interface nsICommonDialogs : nsISupports
|
||||
{
|
||||
%{C++
|
||||
enum { eMsg =0, eCheckboxMsg =1, eIconURL =2 , eTitleMessage =3, eEditfield1Msg =4, eEditfield2Msg =5, eEditfield1Value = 6, eEditfield2Value = 7,
|
||||
eButton0Text = 8, eButton1Text = 9 };
|
||||
enum { eButtonPressed = 0, eCheckboxState = 1, eNumberButtons = 2, eNumberEditfields =3, eEditField1Password =4 };
|
||||
%}
|
||||
|
||||
|
||||
/**
|
||||
* Puts up an alert dialog with an OK button.
|
||||
*/
|
||||
|
||||
@ -27,6 +27,7 @@ class nsIFactory;
|
||||
[scriptable, uuid(f76c0901-437a-11d3-b7a0-e35db351b4bc)]
|
||||
interface nsIDialogParamBlock: nsISupports
|
||||
{
|
||||
void SetNumberStrings( in PRInt32 inNumStrings );
|
||||
PRInt32 GetInt( in PRInt32 inIndex );
|
||||
void SetInt( in PRInt32 inIndex, in PRInt32 inInt );
|
||||
|
||||
@ -34,6 +35,7 @@ interface nsIDialogParamBlock: nsISupports
|
||||
void SetString( in PRInt32 inIndex, in wstring inString);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
||||
@ -27,8 +27,6 @@ static NS_DEFINE_CID( kDialogParamBlockCID, NS_DialogParamBlock_CID);
|
||||
class nsCommonDialogs: public nsICommonDialogs
|
||||
{
|
||||
public:
|
||||
enum { eMsg =0, eCheckboxMsg =1, eIconURL =2 , eTitleMessage =3, eEditfield1Msg =4, eEditfield2Msg =5, eEditfield1Value = 6, eEditfield2Value = 7 };
|
||||
enum { eButtonPressed = 0, eCheckboxState = 1, eNumberButtons = 2, eNumberEditfields =3, ePasswordEditfieldMask =4 };
|
||||
nsCommonDialogs();
|
||||
virtual ~nsCommonDialogs();
|
||||
NS_IMETHOD Alert(nsIDOMWindow *inParent, const PRUnichar *inMsg);
|
||||
@ -98,6 +96,11 @@ NS_IMETHODIMP nsCommonDialogs::Confirm(nsIDOMWindow *inParent, const PRUnichar *
|
||||
nsString url( kQuestionIconURL );
|
||||
block->SetString( eIconURL, url.GetUnicode());
|
||||
|
||||
nsString yes("yes");
|
||||
nsString no("no");
|
||||
block->SetString( nsICommonDialogs::eButton0Text, yes.GetUnicode() );
|
||||
block->SetString( nsICommonDialogs::eButton1Text, no.GetUnicode() );
|
||||
|
||||
rv = DoDialog( inParent, block, kPromptURL );
|
||||
|
||||
PRInt32 buttonPressed = 0;
|
||||
@ -216,9 +219,9 @@ NS_IMETHODIMP nsCommonDialogs::PromptPassword(nsIDOMWindow *inParent, const PRUn
|
||||
nsString url( kQuestionIconURL );
|
||||
block->SetString( eIconURL, url.GetUnicode());
|
||||
block->SetInt( eNumberEditfields, 1 );
|
||||
|
||||
block->SetInt( eEditField1Password, 1 );
|
||||
rv = DoDialog( inParent, block, kPromptURL );
|
||||
block->GetString( eEditfield1Value, outPassword );
|
||||
block->GetString( eEditfield2Value, outPassword );
|
||||
PRInt32 tempInt = 0;
|
||||
block->GetInt( eButtonPressed, &tempInt );
|
||||
*_retval = tempInt ? PR_FALSE : PR_TRUE;
|
||||
|
||||
@ -22,10 +22,12 @@
|
||||
|
||||
class nsDialogParamBlock: public nsISupports
|
||||
{
|
||||
enum {kNumInts = 8, kNumStrings = 8 };
|
||||
enum {kNumInts = 8, kNumStrings =12 };
|
||||
public:
|
||||
nsDialogParamBlock();
|
||||
~nsDialogParamBlock(){};
|
||||
~nsDialogParamBlock();
|
||||
|
||||
NS_IMETHOD SetNumberStrings( PRInt32 inNumStrings );
|
||||
NS_IMETHOD GetInt(PRInt32 inIndex, PRInt32 *_retval);
|
||||
NS_IMETHOD SetInt(PRInt32 inIndex, PRInt32 inInt);
|
||||
|
||||
@ -44,10 +46,11 @@ private:
|
||||
}
|
||||
|
||||
PRInt32 mInt[ kNumInts ];
|
||||
nsString mString[ kNumStrings ];
|
||||
PRInt32 mNumStrings;
|
||||
nsString* mString;
|
||||
};
|
||||
|
||||
nsDialogParamBlock::nsDialogParamBlock()
|
||||
nsDialogParamBlock::nsDialogParamBlock(): mNumStrings( 0 ), mString(NULL )
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
@ -55,6 +58,24 @@ nsDialogParamBlock::nsDialogParamBlock()
|
||||
mInt[ i ] = 0;
|
||||
}
|
||||
|
||||
nsDialogParamBlock::~nsDialogParamBlock()
|
||||
{
|
||||
delete [] mString;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDialogParamBlock::SetNumberStrings( PRInt32 inNumStrings )
|
||||
{
|
||||
if ( mString != NULL )
|
||||
{
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
mString = new nsString[ inNumStrings ];
|
||||
if ( !mString )
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mNumStrings = inNumStrings;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDialogParamBlock::GetInt(PRInt32 inIndex, PRInt32 *_retval)
|
||||
{
|
||||
nsresult rv = InBounds( inIndex, kNumInts );
|
||||
@ -74,7 +95,9 @@ NS_IMETHODIMP nsDialogParamBlock::SetInt(PRInt32 inIndex, PRInt32 inInt)
|
||||
|
||||
NS_IMETHODIMP nsDialogParamBlock::GetString(PRInt32 inIndex, PRUnichar **_retval)
|
||||
{
|
||||
nsresult rv = InBounds( inIndex, kNumStrings );
|
||||
if ( mNumStrings == 0 )
|
||||
SetNumberStrings( kNumStrings );
|
||||
nsresult rv = InBounds( inIndex, mNumStrings );
|
||||
if ( rv == NS_OK )
|
||||
*_retval = mString[ inIndex ].ToNewUnicode();
|
||||
return rv;
|
||||
@ -82,7 +105,9 @@ NS_IMETHODIMP nsDialogParamBlock::GetString(PRInt32 inIndex, PRUnichar **_retval
|
||||
|
||||
NS_IMETHODIMP nsDialogParamBlock::SetString(PRInt32 inIndex, const PRUnichar *inString)
|
||||
{
|
||||
nsresult rv = InBounds( inIndex, kNumStrings );
|
||||
if ( mNumStrings == 0 )
|
||||
SetNumberStrings( kNumStrings );
|
||||
nsresult rv = InBounds( inIndex, mNumStrings );
|
||||
if ( rv == NS_OK )
|
||||
mString[ inIndex ]= inString;
|
||||
return rv;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user