mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Bug 201275 [Webclient] move Prompt code from CBrowserContainer to PromptService
r=edburns
This commit is contained in:
parent
b82a4e450c
commit
636945d6ca
@ -44,6 +44,7 @@ public static final String EDIT_FIELD_1_KEY = "editfield1Value";
|
||||
public static final String EDIT_FIELD_2_KEY = "editfield2Value";
|
||||
public static final String CHECKBOX_STATE_KEY = "checkboxState";
|
||||
public static final String BUTTON_PRESSED_KEY = "buttonPressed";
|
||||
public static final String FINISHED_KEY = "finished";
|
||||
|
||||
/**
|
||||
|
||||
|
@ -59,7 +59,7 @@ import java.io.FileInputStream;
|
||||
* This is a test application for using the BrowserControl.
|
||||
|
||||
*
|
||||
* @version $Id: EMWindow.java,v 1.40 2003/04/24 05:55:07 kyle.yuan%sun.com Exp $
|
||||
* @version $Id: EMWindow.java,v 1.41 2003/05/06 01:49:57 kyle.yuan%sun.com Exp $
|
||||
*
|
||||
* @see org.mozilla.webclient.BrowserControlFactory
|
||||
|
||||
@ -86,6 +86,7 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
|
||||
private Panel controlPanel;
|
||||
private Panel statusPanel;
|
||||
private Panel buttonsPanel;
|
||||
private UniversalDialogData dlgData = null;
|
||||
private FindDialog findDialog = null;
|
||||
private PasswordDialog passDialog = null;
|
||||
private UniversalDialog uniDialog = null;
|
||||
@ -309,6 +310,9 @@ private void createMenubar()
|
||||
menuBar.add(fileMenu);
|
||||
|
||||
Menu viewMenu = new Menu("View");
|
||||
MenuItem pageSourceItem = new MenuItem("View Page Source");
|
||||
viewMenu.add(pageSourceItem);
|
||||
pageSourceItem.addActionListener(this);
|
||||
MenuItem sourceItem = new MenuItem("View Page Source as String");
|
||||
viewMenu.add(sourceItem);
|
||||
sourceItem.addActionListener(this);
|
||||
@ -465,6 +469,9 @@ public void actionPerformed (ActionEvent evt)
|
||||
else if (command.equals("New Window2")) {
|
||||
creator.CreateEMWindow("", chromeFlag);
|
||||
}
|
||||
else if (command.equals("Dialog")) {
|
||||
execUniversalDialog();
|
||||
}
|
||||
else if (command.equals("Close")) {
|
||||
System.out.println("Got windowClosing");
|
||||
System.out.println("destroying the BrowserControl");
|
||||
@ -494,6 +501,12 @@ public void actionPerformed (ActionEvent evt)
|
||||
else if (command.equals("Find Next")) {
|
||||
currentPage.findNextInPage();
|
||||
}
|
||||
else if (command.equals("View Page Source")) {
|
||||
creator.CreateEMWindow("view-source:" + urlField.getText(),
|
||||
NewWindowListener.CHROME_WINDOW_BORDERS |
|
||||
NewWindowListener.CHROME_TITLEBAR |
|
||||
NewWindowListener.CHROME_WINDOW_RESIZE);
|
||||
}
|
||||
else if (command.equals("View Page Source as String")) {
|
||||
String sou = currentPage.getSource();
|
||||
System.out.println("+++++++++++ Page Source is +++++++++++\n\n" + sou);
|
||||
@ -611,9 +624,15 @@ public void actionPerformed (ActionEvent evt)
|
||||
|
||||
|
||||
public void dialogDismissed(Dialog d) {
|
||||
if (d == passDialog || d == uniDialog) {
|
||||
return;
|
||||
}
|
||||
System.out.println("dialogDismissed");
|
||||
if (d == passDialog) {
|
||||
return;
|
||||
}
|
||||
if (d == uniDialog) {
|
||||
dlgData.mProps.put(Prompt.FINISHED_KEY, "true");
|
||||
uniDialog = null;
|
||||
return;
|
||||
}
|
||||
if(findDialog.wasClosed()) {
|
||||
System.out.println("Find Dialog Closed");
|
||||
}
|
||||
@ -650,7 +669,7 @@ public void dialogDismissed(Dialog d) {
|
||||
}
|
||||
|
||||
public void dialogCancelled(Dialog d) {
|
||||
System.out.println("Find Dialog Closed");
|
||||
System.out.println("dialogCancelled");
|
||||
}
|
||||
|
||||
|
||||
@ -705,24 +724,35 @@ public void eventDispatched(WebclientEvent event)
|
||||
if (event instanceof DocumentLoadEvent) {
|
||||
switch ((int) event.getType()) {
|
||||
case ((int) DocumentLoadEvent.START_DOCUMENT_LOAD_EVENT_MASK):
|
||||
stopButton.setEnabled(true);
|
||||
refreshButton.setEnabled(true);
|
||||
if (null != stopButton)
|
||||
stopButton.setEnabled(true);
|
||||
if (null != refreshButton)
|
||||
refreshButton.setEnabled(true);
|
||||
currentURL = (String) event.getEventData();
|
||||
System.out.println("debug: edburns: Currently Viewing: " +
|
||||
currentURL);
|
||||
statusLabel.setText("Starting to load " + currentURL);
|
||||
urlField.setText(currentURL);
|
||||
if (null != statusLabel && null != urlField) {
|
||||
statusLabel.setText("Starting to load " + currentURL);
|
||||
urlField.setText(currentURL);
|
||||
}
|
||||
currentDocument = null;
|
||||
break;
|
||||
case ((int) DocumentLoadEvent.END_DOCUMENT_LOAD_EVENT_MASK):
|
||||
stopButton.setEnabled(false);
|
||||
backButton.setEnabled(history.canBack());
|
||||
backMenuItem.setEnabled(history.canBack());
|
||||
forwardButton.setEnabled(history.canForward());
|
||||
forwardMenuItem.setEnabled(history.canForward());
|
||||
if (null != stopButton)
|
||||
stopButton.setEnabled(false);
|
||||
if (null != backButton)
|
||||
backButton.setEnabled(history.canBack());
|
||||
if (null != backMenuItem)
|
||||
backMenuItem.setEnabled(history.canBack());
|
||||
if (null != forwardButton)
|
||||
forwardButton.setEnabled(history.canForward());
|
||||
if (null != forwardMenuItem)
|
||||
forwardMenuItem.setEnabled(history.canForward());
|
||||
populateHistoryMenu();
|
||||
statusLabel.setText("Done.");
|
||||
urlStatusLabel.setText("");
|
||||
if (null != statusLabel && null != urlField) {
|
||||
statusLabel.setText("Done.");
|
||||
urlStatusLabel.setText("");
|
||||
}
|
||||
currentDocument = currentPage.getDOM();
|
||||
// add the new document to the domViewer
|
||||
if (null != currentDocument && null != domViewer) {
|
||||
@ -732,19 +762,23 @@ public void eventDispatched(WebclientEvent event)
|
||||
break;
|
||||
case ((int) DocumentLoadEvent.PROGRESS_URL_LOAD_EVENT_MASK):
|
||||
status = "Status: " + (String) event.getEventData();
|
||||
statusLabel.setText(status);
|
||||
if (null != statusLabel)
|
||||
statusLabel.setText(status);
|
||||
break;
|
||||
case ((int) DocumentLoadEvent.STATUS_URL_LOAD_EVENT_MASK):
|
||||
status = "Status: " + (String) event.getEventData();
|
||||
statusLabel.setText(status);
|
||||
if (null != statusLabel)
|
||||
statusLabel.setText(status);
|
||||
break;
|
||||
case ((int) DocumentLoadEvent.START_URL_LOAD_EVENT_MASK):
|
||||
status = (String) event.getEventData();
|
||||
urlStatusLabel.setText("startURL: " + status);
|
||||
if (null != urlStatusLabel)
|
||||
urlStatusLabel.setText("startURL: " + status);
|
||||
break;
|
||||
case ((int) DocumentLoadEvent.END_URL_LOAD_EVENT_MASK):
|
||||
status = (String) event.getEventData();
|
||||
urlStatusLabel.setText(" endURL: " + status);
|
||||
if (null != urlStatusLabel)
|
||||
urlStatusLabel.setText(" endURL: " + status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -924,43 +958,35 @@ public boolean universalDialog(String titleMessage,
|
||||
boolean editfield1Password,
|
||||
Properties fillThis)
|
||||
{
|
||||
System.out.println("titleMessage " + titleMessage);
|
||||
System.out.println("dialogTitle " + dialogTitle);
|
||||
System.out.println("text " + text);
|
||||
System.out.println("checkboxMsg " + checkboxMsg);
|
||||
System.out.println("button0Text " + button0Text);
|
||||
System.out.println("button1Text " + button1Text);
|
||||
System.out.println("button2Text " + button2Text);
|
||||
System.out.println("button3Text " + button3Text);
|
||||
System.out.println("editfield1Msg " + editfield1Msg);
|
||||
System.out.println("editfield2Msg " + editfield2Msg);
|
||||
System.out.println("numButtons " + numButtons);
|
||||
System.out.println("numEditfields " + numEditfields);
|
||||
System.out.println("editfield1Password " + editfield1Password);
|
||||
|
||||
fillThis.put("editfield1Value", "edit1");
|
||||
fillThis.put("editfield2Value", "edit2");
|
||||
fillThis.put("checkboxState", "true");
|
||||
if (null == fillThis) {
|
||||
return false;
|
||||
if (dialogTitle.equals("")) {
|
||||
dialogTitle = "Universal Dialog";
|
||||
}
|
||||
|
||||
dlgData = new UniversalDialogData(titleMessage, dialogTitle, text, checkboxMsg,
|
||||
button0Text, button1Text, button2Text,
|
||||
editfield1Msg, editfield2Msg,
|
||||
numButtons, numEditfields, editfield1Password, fillThis);
|
||||
// send a "new window" event to the window
|
||||
Toolkit.getDefaultToolkit().
|
||||
getSystemEventQueue().
|
||||
postEvent(new ActionEvent(newItem,
|
||||
ActionEvent.ACTION_PERFORMED,
|
||||
"Dialog"));
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean execUniversalDialog()
|
||||
{
|
||||
if (null == uniDialog) {
|
||||
if (dialogTitle.equals("")) {
|
||||
dialogTitle = "Universal Dialog";
|
||||
}
|
||||
uniDialog = new UniversalDialog(this, this, dialogTitle);
|
||||
uniDialog = new UniversalDialog(this, this, dlgData.mDialogTitle);
|
||||
if (null == uniDialog) {
|
||||
return false;
|
||||
}
|
||||
uniDialog.setParms(titleMessage, dialogTitle, text, checkboxMsg,
|
||||
button0Text, button1Text, button2Text,
|
||||
editfield1Msg, editfield2Msg, numButtons,
|
||||
numEditfields, editfield1Password, fillThis);
|
||||
uniDialog.setParms(dlgData);
|
||||
uniDialog.setModal(true);
|
||||
uniDialog.setVisible(true);
|
||||
}
|
||||
|
||||
uniDialog.setVisible(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/** Ashu -- this is the Find Dialog Class
|
||||
/** Ashu -- this is the Find Dialog Class
|
||||
instantiated within the EMWindow class, this
|
||||
will act as the Modal dialog for calling Find/Find Next
|
||||
will act as the Modal dialog for calling Find/Find Next
|
||||
functions for CurrentPage
|
||||
*/
|
||||
|
||||
@ -18,200 +18,189 @@ import java.util.Properties;
|
||||
|
||||
public class UniversalDialog extends WorkDialog implements ActionListener, ItemListener
|
||||
{
|
||||
static private int _defaultTextFieldSize = 20;
|
||||
public Button [] buttons;
|
||||
public TextField [] fields;
|
||||
static private int _defaultTextFieldSize = 20;
|
||||
public Button [] buttons;
|
||||
public TextField [] fields;
|
||||
|
||||
public String mTitleMsg;
|
||||
public String mText;
|
||||
public String mCheckboxMsg;
|
||||
public UniversalDialogData mData;
|
||||
public Checkbox mCheckbox;
|
||||
public String mField1Label;
|
||||
public String mField2Label;
|
||||
public boolean mField1IsPasswd;
|
||||
public Properties mProps;
|
||||
|
||||
public UniversalDialog(Frame frame, DialogClient client, String dialogTitle)
|
||||
|
||||
public UniversalDialog(Frame frame, DialogClient client, String dialogTitle)
|
||||
{
|
||||
super(frame, client, dialogTitle, /* isModal */ true);
|
||||
}
|
||||
|
||||
public void setParms(String titleMsg,
|
||||
String dialogTitle, String text, String checkboxMsg,
|
||||
String button0Text, String button1Text,
|
||||
String button2Text, String editfield1Msg,
|
||||
String editfield2Msg,
|
||||
int numButtons, int numEditfields,
|
||||
boolean editfield1Password,
|
||||
Properties props)
|
||||
public void setParms(UniversalDialogData data)
|
||||
{
|
||||
DialogPanel dialogPanel;
|
||||
int i = 0;
|
||||
buttons = null;
|
||||
fields = null;
|
||||
mTitleMsg = titleMsg;
|
||||
this.setTitle(dialogTitle);
|
||||
mText = text;
|
||||
mCheckboxMsg = checkboxMsg;
|
||||
mField1Label = editfield1Msg;
|
||||
mField2Label = editfield2Msg;
|
||||
mField1IsPasswd = editfield1Password;
|
||||
mProps = props;
|
||||
mData = data;
|
||||
|
||||
if (0 < numButtons) {
|
||||
buttons = new Button[numButtons];
|
||||
String label;
|
||||
|
||||
for (i = 0; i < numButtons; i++) {
|
||||
// figure out which String to use;
|
||||
if (0 == i) {
|
||||
label = button0Text;
|
||||
}
|
||||
else if (1 == i) {
|
||||
label = button1Text;
|
||||
}
|
||||
else {
|
||||
label = button2Text;
|
||||
}
|
||||
buttons[i] = addButton(label);
|
||||
buttons[i].addActionListener(this);
|
||||
}
|
||||
this.setTitle(mData.mDialogTitle);
|
||||
|
||||
if (0 < mData.mNumButtons) {
|
||||
buttons = new Button[mData.mNumButtons];
|
||||
String label;
|
||||
|
||||
for (i = 0; i < mData.mNumButtons; i++) {
|
||||
// figure out which String to use;
|
||||
if (0 == i) {
|
||||
label = mData.mButtonText0;
|
||||
}
|
||||
else if (1 == i) {
|
||||
label = mData.mButtonText1;
|
||||
}
|
||||
else {
|
||||
label = mData.mButtonText2;
|
||||
}
|
||||
buttons[i] = addButton(label);
|
||||
buttons[i].addActionListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < numEditfields) {
|
||||
fields = new TextField[numEditfields];
|
||||
|
||||
for (i = 0; i < numEditfields; i++) {
|
||||
fields[i] = new TextField("", _defaultTextFieldSize);
|
||||
if (mField1IsPasswd && i == 0) {
|
||||
fields[i].setEchoChar('*');
|
||||
}
|
||||
}
|
||||
if (0 < mData.mNumEditfields) {
|
||||
String defaultString;
|
||||
fields = new TextField[mData.mNumEditfields];
|
||||
|
||||
for (i = 0; i < mData.mNumEditfields; i++) {
|
||||
fields[i] = new TextField("", _defaultTextFieldSize);
|
||||
if (i == 0)
|
||||
defaultString = mData.mProps.getProperty(Prompt.EDIT_FIELD_1_KEY);
|
||||
else
|
||||
defaultString = mData.mProps.getProperty(Prompt.EDIT_FIELD_2_KEY);
|
||||
fields[i].setText(defaultString);
|
||||
if (mData.mField1IsPasswd && i == 0) {
|
||||
fields[i].setEchoChar('*');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dialogPanel = new DialogPanel(this);
|
||||
setWorkPanel(dialogPanel);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent ae)
|
||||
public void actionPerformed(ActionEvent ae)
|
||||
{
|
||||
Assert.assert_it(null != buttons);
|
||||
int i = 0;
|
||||
for (i = 0; i < buttons.length; i++) {
|
||||
if (ae.getSource() == buttons[i]) {
|
||||
mProps.put(Prompt.BUTTON_PRESSED_KEY, Integer.toString(i));
|
||||
// pull out the values from the TextFields
|
||||
break;
|
||||
}
|
||||
if (ae.getSource() == buttons[i]) {
|
||||
mData.mProps.put(Prompt.BUTTON_PRESSED_KEY, Integer.toString(i));
|
||||
// pull out the values from the TextFields
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (null != fields) {
|
||||
String curString;
|
||||
for (i = 0; i < fields.length; i++) {
|
||||
curString = fields[i].getText();
|
||||
if (0 == i) {
|
||||
mProps.put(Prompt.EDIT_FIELD_1_KEY, curString);
|
||||
}
|
||||
else {
|
||||
mProps.put(Prompt.EDIT_FIELD_2_KEY, curString);
|
||||
}
|
||||
}
|
||||
String curString;
|
||||
for (i = 0; i < fields.length; i++) {
|
||||
curString = fields[i].getText();
|
||||
if (0 == i) {
|
||||
mData.mProps.put(Prompt.EDIT_FIELD_1_KEY, curString);
|
||||
}
|
||||
else {
|
||||
mData.mProps.put(Prompt.EDIT_FIELD_2_KEY, curString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null != mCheckbox) {
|
||||
Boolean bool = new Boolean(mCheckbox.getState());
|
||||
mProps.put(Prompt.CHECKBOX_STATE_KEY, bool.toString());
|
||||
Boolean bool = new Boolean(mCheckbox.getState());
|
||||
mData.mProps.put(Prompt.CHECKBOX_STATE_KEY, bool.toString());
|
||||
}
|
||||
dispose(true);
|
||||
}
|
||||
|
||||
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
}
|
||||
|
||||
public void setVisible(boolean b)
|
||||
|
||||
public void setVisible(boolean b)
|
||||
{
|
||||
if (null != fields) {
|
||||
fields[0].requestFocus();
|
||||
fields[0].requestFocus();
|
||||
}
|
||||
super.setVisible(b);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class DialogPanel extends Postcard
|
||||
class DialogPanel extends Postcard
|
||||
{
|
||||
private UniversalDialog dialog;
|
||||
|
||||
public DialogPanel(UniversalDialog myDialog)
|
||||
|
||||
public DialogPanel(UniversalDialog myDialog)
|
||||
{
|
||||
super(new Panel());
|
||||
Panel panel = getPanel();
|
||||
panel.setLayout(new BorderLayout());
|
||||
this.dialog = myDialog;
|
||||
int i = 0;
|
||||
|
||||
if (null != dialog.mTitleMsg || null != dialog.mText) {
|
||||
Panel northPanel = new Panel();
|
||||
northPanel.setLayout(new BorderLayout());
|
||||
|
||||
// set up the stuff on top of the text fields
|
||||
if (null != dialog.mTitleMsg) {
|
||||
Label titleLabel = new Label(dialog.mTitleMsg);
|
||||
titleLabel.setBackground(Color.lightGray);
|
||||
northPanel.add(titleLabel, BorderLayout.NORTH);
|
||||
}
|
||||
if (null != dialog.mText) {
|
||||
Label textLabel = new Label(dialog.mText);
|
||||
textLabel.setBackground(Color.lightGray);
|
||||
northPanel.add(textLabel, BorderLayout.CENTER);
|
||||
}
|
||||
panel.add(northPanel, BorderLayout.NORTH);
|
||||
//System.out.println(dialog.mData.mTitleMsg);
|
||||
if (null != dialog.mData.mTitleMsg || null != dialog.mData.mText) {
|
||||
Panel northPanel = new Panel();
|
||||
northPanel.setLayout(new BorderLayout());
|
||||
|
||||
// set up the stuff on top of the text fields
|
||||
if (null != dialog.mData.mTitleMsg) {
|
||||
Label titleLabel = new Label(dialog.mData.mTitleMsg);
|
||||
titleLabel.setBackground(Color.lightGray);
|
||||
northPanel.add(titleLabel, BorderLayout.NORTH);
|
||||
}
|
||||
if (null != dialog.mData.mText) {
|
||||
Label textLabel = new Label(dialog.mData.mText);
|
||||
textLabel.setBackground(Color.lightGray);
|
||||
northPanel.add(textLabel, BorderLayout.CENTER);
|
||||
}
|
||||
panel.add(northPanel, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
Panel centerPanel = new Panel();
|
||||
centerPanel.setLayout(new BorderLayout());
|
||||
|
||||
if (null != dialog.fields) {
|
||||
Panel fieldPanel = new Panel();
|
||||
fieldPanel.setLayout(new BorderLayout());
|
||||
// set up the text fields
|
||||
Panel curPanel;
|
||||
Label curLabel;
|
||||
for (i = 0; i < dialog.fields.length; i++) {
|
||||
// set up the label and field
|
||||
curPanel = new Panel();
|
||||
curPanel.setLayout(new BorderLayout());
|
||||
|
||||
if (0 == i) {
|
||||
curLabel = new Label(dialog.mField1Label);
|
||||
}
|
||||
else {
|
||||
curLabel = new Label(dialog.mField2Label);
|
||||
}
|
||||
curLabel.setBackground(Color.lightGray);
|
||||
curPanel.add(curLabel, BorderLayout.WEST);
|
||||
|
||||
curPanel.add(dialog.fields[i], BorderLayout.CENTER);
|
||||
if (0 == i) {
|
||||
fieldPanel.add(curPanel, BorderLayout.NORTH);
|
||||
}
|
||||
else {
|
||||
fieldPanel.add(curPanel, BorderLayout.CENTER);
|
||||
}
|
||||
}
|
||||
centerPanel.add(fieldPanel, BorderLayout.NORTH);
|
||||
if (null != dialog.fields) {
|
||||
Panel fieldPanel = new Panel();
|
||||
fieldPanel.setLayout(new BorderLayout());
|
||||
// set up the text fields
|
||||
Panel curPanel;
|
||||
Label curLabel;
|
||||
for (i = 0; i < dialog.fields.length; i++) {
|
||||
// set up the label and field
|
||||
curPanel = new Panel();
|
||||
curPanel.setLayout(new BorderLayout());
|
||||
|
||||
if (0 == i) {
|
||||
curLabel = new Label(dialog.mData.mField1Label);
|
||||
}
|
||||
else {
|
||||
curLabel = new Label(dialog.mData.mField2Label);
|
||||
}
|
||||
curLabel.setBackground(Color.lightGray);
|
||||
curPanel.add(curLabel, BorderLayout.WEST);
|
||||
|
||||
curPanel.add(dialog.fields[i], BorderLayout.CENTER);
|
||||
if (0 == i) {
|
||||
fieldPanel.add(curPanel, BorderLayout.NORTH);
|
||||
}
|
||||
else {
|
||||
fieldPanel.add(curPanel, BorderLayout.CENTER);
|
||||
}
|
||||
}
|
||||
centerPanel.add(fieldPanel, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
if (null != dialog.mCheckboxMsg) {
|
||||
dialog.mCheckbox = new Checkbox(dialog.mCheckboxMsg);
|
||||
dialog.mCheckbox.setBackground(Color.lightGray);
|
||||
centerPanel.add(dialog.mCheckbox, BorderLayout.CENTER);
|
||||
|
||||
if (null != dialog.mData.mCheckboxMsg && dialog.mData.mCheckboxMsg.length() > 0) {
|
||||
dialog.mCheckbox = new Checkbox(dialog.mData.mCheckboxMsg);
|
||||
dialog.mCheckbox.setBackground(Color.lightGray);
|
||||
centerPanel.add(dialog.mCheckbox, BorderLayout.CENTER);
|
||||
}
|
||||
// add the center panel to the main panel
|
||||
panel.add(centerPanel, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,51 @@
|
||||
|
||||
package org.mozilla.webclient.test;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class UniversalDialogData
|
||||
{
|
||||
public String mDialogTitle;
|
||||
public String mTitleMsg;
|
||||
public String mText;
|
||||
public String mCheckboxMsg;
|
||||
public String mButtonText0;
|
||||
public String mButtonText1;
|
||||
public String mButtonText2;
|
||||
public String mField1Label;
|
||||
public String mField2Label;
|
||||
public boolean mField1IsPasswd;
|
||||
public int mNumButtons;
|
||||
public int mNumEditfields;
|
||||
public Properties mProps;
|
||||
|
||||
public UniversalDialogData(String titleMessage,
|
||||
String dialogTitle,
|
||||
String text,
|
||||
String checkboxMsg,
|
||||
String button0Text,
|
||||
String button1Text,
|
||||
String button2Text,
|
||||
String editfield1Msg,
|
||||
String editfield2Msg,
|
||||
int numButtons,
|
||||
int numEditfields,
|
||||
boolean editfield1Password,
|
||||
Properties props)
|
||||
{
|
||||
mDialogTitle = dialogTitle;
|
||||
mTitleMsg = titleMessage;
|
||||
mText = text;
|
||||
mCheckboxMsg = checkboxMsg;
|
||||
mButtonText0 = button0Text;
|
||||
mButtonText1 = button1Text;
|
||||
mButtonText2 = button2Text;
|
||||
mField1Label = editfield1Msg;
|
||||
mField2Label = editfield2Msg;
|
||||
mField1IsPasswd = editfield1Password;
|
||||
mNumButtons = numButtons;
|
||||
mNumEditfields = numEditfields;
|
||||
mProps = props;
|
||||
}
|
||||
|
||||
}
|
46
java/webclient/src_moz/AppComponents.cpp
Normal file
46
java/webclient/src_moz/AppComponents.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems, Inc.
|
||||
* Portions created by Sun Microsystems are Copyright (C) 2003 Sun
|
||||
* Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Original Author: Kyle Yuan <kyle.yuan@sun.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*/
|
||||
|
||||
#include "AppComponents.h"
|
||||
#include "PromptService.h"
|
||||
|
||||
#define NS_PROMPTSERVICE_CID \
|
||||
{0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(PromptService);
|
||||
|
||||
static const nsModuleComponentInfo components[] = {
|
||||
{
|
||||
"Prompt Service",
|
||||
NS_PROMPTSERVICE_CID,
|
||||
"@mozilla.org/embedcomp/prompt-service;1",
|
||||
PromptServiceConstructor
|
||||
}
|
||||
};
|
||||
|
||||
const nsModuleComponentInfo* GetAppModuleComponentInfo(int* outNumComponents)
|
||||
{
|
||||
*outNumComponents = sizeof(components) / sizeof(components[0]);
|
||||
return components;
|
||||
}
|
36
java/webclient/src_moz/AppComponents.h
Normal file
36
java/webclient/src_moz/AppComponents.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems, Inc.
|
||||
* Portions created by Sun Microsystems are Copyright (C) 2003 Sun
|
||||
* Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Original Author: Kyle Yuan <kyle.yuan@sun.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AppComponents_h__
|
||||
#define AppComponents_h__
|
||||
|
||||
#ifndef nsIGenericFactory_h___
|
||||
#include "nsIGenericFactory.h"
|
||||
#endif
|
||||
|
||||
// This method should return a nsModuleComponentInfo array of
|
||||
// application-provided XPCOM components to register.
|
||||
extern const nsModuleComponentInfo* GetAppModuleComponentInfo(int* outNumComponents);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
*
|
||||
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
* Ed Burns <edburns@acm.org>
|
||||
*
|
||||
@ -40,8 +40,7 @@
|
||||
#include "nsIURIContentListener.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIEmbeddingSiteWindow.h"
|
||||
#include "nsCWebBrowser.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
@ -55,16 +54,13 @@ class nsIURI;
|
||||
// interfaces into the web shell and so forth.
|
||||
|
||||
class CBrowserContainer :
|
||||
public nsIBaseWindow,
|
||||
public nsIWebBrowserChrome,
|
||||
public nsIWebProgressListener,
|
||||
public nsIWebShellContainer,
|
||||
public nsIURIContentListener,
|
||||
public nsIDocShellTreeOwner,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIPrompt,
|
||||
public nsIAuthPrompt,
|
||||
public nsIDOMMouseListener,
|
||||
public nsIWebBrowserChrome,
|
||||
public nsIEmbeddingSiteWindow,
|
||||
public nsIWebProgressListener,
|
||||
public nsIWebShellContainer,
|
||||
public nsIURIContentListener,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIDOMMouseListener,
|
||||
public wcIBrowserContainer,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
@ -94,7 +90,7 @@ protected:
|
||||
//
|
||||
// The following arguments are used in the takeActionOnNode method.
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 0 is the leaf depth. That's why we call it the inverse depth.
|
||||
@ -125,39 +121,34 @@ protected:
|
||||
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIBASEWINDOW
|
||||
NS_DECL_NSIWEBBROWSERCHROME
|
||||
NS_DECL_NSIDOCSHELLTREEOWNER
|
||||
NS_DECL_NSIURICONTENTLISTENER
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBBROWSERCHROME
|
||||
NS_DECL_NSIEMBEDDINGSITEWINDOW
|
||||
NS_DECL_NSIURICONTENTLISTENER
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
NS_DECL_WCIBROWSERCONTAINER
|
||||
NS_DECL_WCIBROWSERCONTAINER
|
||||
|
||||
// "Services" accessed through nsIInterfaceRequestor
|
||||
NS_DECL_NSIPROMPT
|
||||
NS_DECL_NSIAUTHPROMPT
|
||||
// nsIDOMMouseListener
|
||||
|
||||
// nsIDOMMouseListener
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent);
|
||||
|
||||
// nsIWebShellContainer
|
||||
NS_IMETHOD WillLoadURL(nsIWebShell* aShell,
|
||||
const PRUnichar* aURL,
|
||||
nsLoadType aReason);
|
||||
|
||||
|
||||
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell,
|
||||
const PRUnichar* aURL);
|
||||
|
||||
|
||||
|
||||
|
||||
NS_IMETHOD EndLoadURL(nsIWebShell* aShell,
|
||||
const PRUnichar* aURL,
|
||||
nsresult aStatus);
|
||||
@ -174,16 +165,17 @@ void JNICALL addMouseEventDataToProperties(nsIDOMEvent *aMouseEvent);
|
||||
|
||||
* Called from our nsIWebProgressListener.OnStateChanged()
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
nsresult JNICALL doStartDocumentLoad(const PRUnichar *documentName);
|
||||
nsresult JNICALL doEndDocumentLoad(nsIWebProgress *aWebProgress);
|
||||
nsresult JNICALL doStartURLLoad(const PRUnichar *documentName);
|
||||
nsresult JNICALL doEndURLLoad(const PRUnichar *documentName);
|
||||
|
||||
static nsresult JNICALL takeActionOnNode(nsCOMPtr<nsIDOMNode> curNode,
|
||||
static nsresult JNICALL takeActionOnNode(nsCOMPtr<nsIDOMNode> curNode,
|
||||
void *yourObject);
|
||||
|
||||
friend class PromptService;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -114,6 +114,8 @@ CPPSRCS = \
|
||||
PreferencesActionEvents.cpp \
|
||||
WrapperFactoryImpl.cpp \
|
||||
WindowCreator.cpp \
|
||||
PromptService.cpp \
|
||||
AppComponents.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),Linux)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
@ -65,6 +65,7 @@
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "WindowCreator.h"
|
||||
#include "AppComponents.h"
|
||||
|
||||
#include "prlog.h" // for PR_ASSERT
|
||||
|
||||
@ -74,7 +75,7 @@
|
||||
#include "gtkmozarea.h"
|
||||
|
||||
extern "C" {
|
||||
static int wc_x_error (Display *display,
|
||||
static int wc_x_error (Display *display,
|
||||
XErrorEvent *error);
|
||||
}
|
||||
|
||||
@ -125,23 +126,23 @@ extern const char * gBinDir; // defined in WrapperFactoryImpl.cpp
|
||||
|
||||
#ifdef XP_UNIX
|
||||
static int
|
||||
wc_x_error (Display *display,
|
||||
wc_x_error (Display *display,
|
||||
XErrorEvent *error)
|
||||
{
|
||||
if (error->error_code)
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
|
||||
XGetErrorText (display, error->error_code, buf, 63);
|
||||
|
||||
|
||||
fprintf (stderr, "Webclient-Gdk-ERROR **: %s\n serial %ld error_code %d request_code %d minor_code %d\n",
|
||||
buf,
|
||||
error->serial,
|
||||
error->error_code,
|
||||
buf,
|
||||
error->serial,
|
||||
error->error_code,
|
||||
error->request_code,
|
||||
error->minor_code);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -156,7 +157,7 @@ int processEventLoop(WebShellInitContext * initContext);
|
||||
|
||||
/**
|
||||
|
||||
* Called from Java nativeInitialize to create the webshell
|
||||
* Called from Java nativeInitialize to create the webshell
|
||||
* and other mozilla things, then start the event loop.
|
||||
|
||||
*/
|
||||
@ -168,18 +169,18 @@ nsresult InitMozillaStuff (WebShellInitContext * arg);
|
||||
//
|
||||
|
||||
nsIComponentManager *gComponentManager = nsnull;
|
||||
static PRBool gFirstTime = PR_TRUE;
|
||||
PLEventQueue * gActionQueue = nsnull;
|
||||
PRThread * gEmbeddedThread = nsnull;
|
||||
static PRBool gFirstTime = PR_TRUE;
|
||||
PLEventQueue * gActionQueue = nsnull;
|
||||
PRThread * gEmbeddedThread = nsnull;
|
||||
nsISHistory *gHistory = nsnull;
|
||||
WindowCreator * gCreatorCallback = nsnull;
|
||||
|
||||
char * errorMessages[] = {
|
||||
"No Error",
|
||||
"Could not obtain the event queue service.",
|
||||
"Unable to create the WebShell instance.",
|
||||
"Unable to initialize the WebShell instance.",
|
||||
"Unable to show the WebShell."
|
||||
"No Error",
|
||||
"Could not obtain the event queue service.",
|
||||
"Unable to create the WebShell instance.",
|
||||
"Unable to initialize the WebShell instance.",
|
||||
"Unable to show the WebShell."
|
||||
};
|
||||
|
||||
//
|
||||
@ -193,7 +194,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
||||
WebShellInitContext * initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (nsnull == initContext) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"NULL webShellPtr passed to nativeInitialize.");
|
||||
return;
|
||||
}
|
||||
@ -203,15 +204,15 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
||||
|
||||
rv = InitMozillaStuff(initContext);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
::util_ThrowExceptionToJava(env,
|
||||
errorMessages[initContext->initFailCode]);
|
||||
return;
|
||||
}
|
||||
|
||||
while (initContext->initComplete == FALSE) {
|
||||
|
||||
|
||||
::PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
|
||||
|
||||
if (initContext->initFailCode != 0) {
|
||||
::util_ThrowExceptionToJava(env, errorMessages[initContext->initFailCode]);
|
||||
return;
|
||||
@ -223,9 +224,9 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext * initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
|
||||
if (nsnull == initContext) {
|
||||
::util_ThrowExceptionToJava(env,
|
||||
::util_ThrowExceptionToJava(env,
|
||||
"NULL webShellPtr passed to nativeProcessEvents.");
|
||||
return;
|
||||
}
|
||||
@ -257,11 +258,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
||||
*/
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeAddListener
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject typedListener,
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject typedListener,
|
||||
jstring listenerString)
|
||||
{
|
||||
WebShellInitContext *initContext = (WebShellInitContext *)webShellPtr;
|
||||
|
||||
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null initContext passed tonativeAddListener");
|
||||
return;
|
||||
@ -269,23 +270,23 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
||||
|
||||
if (nsnull == initContext->nativeEventThread) {
|
||||
// store the java EventRegistrationImpl class in the initContext
|
||||
initContext->nativeEventThread =
|
||||
initContext->nativeEventThread =
|
||||
::util_NewGlobalRef(env, obj); // VERY IMPORTANT!!
|
||||
|
||||
|
||||
// This enables the listener to call back into java
|
||||
}
|
||||
|
||||
|
||||
jclass clazz = nsnull;
|
||||
int listenerType = 0;
|
||||
const char *listenerStringChars = ::util_GetStringUTFChars(env,
|
||||
const char *listenerStringChars = ::util_GetStringUTFChars(env,
|
||||
listenerString);
|
||||
if (listenerStringChars == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeAddListener: Can't get className for listener.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while (nsnull != gSupportedListenerInterfaces[listenerType]) {
|
||||
if (0 == nsCRT::strcmp(gSupportedListenerInterfaces[listenerType],
|
||||
if (0 == nsCRT::strcmp(gSupportedListenerInterfaces[listenerType],
|
||||
listenerStringChars)) {
|
||||
// We've got a winner!
|
||||
break;
|
||||
@ -294,7 +295,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
||||
}
|
||||
::util_ReleaseStringUTFChars(env, listenerString, listenerStringChars);
|
||||
listenerStringChars = nsnull;
|
||||
|
||||
|
||||
if (LISTENER_NOT_FOUND == (LISTENER_CLASSES) listenerType) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: NativeEventThread.nativeAddListener(): can't find listener \n\tclass for argument");
|
||||
return;
|
||||
@ -311,21 +312,21 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
||||
|
||||
switch(listenerType) {
|
||||
case DOCUMENT_LOAD_LISTENER:
|
||||
initContext->browserContainer->AddDocumentLoadListener(globalRef);
|
||||
initContext->browserContainer->AddDocumentLoadListener(globalRef);
|
||||
break;
|
||||
case MOUSE_LISTENER:
|
||||
initContext->browserContainer->AddMouseListener(globalRef);
|
||||
initContext->browserContainer->AddMouseListener(globalRef);
|
||||
break;
|
||||
case NEW_WINDOW_LISTENER:
|
||||
if (gCreatorCallback)
|
||||
gCreatorCallback->AddNewWindowListener(globalRef);
|
||||
gCreatorCallback->AddNewWindowListener(globalRef);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeRemoveListener
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jobject typedListener,
|
||||
jstring listenerString)
|
||||
@ -336,18 +337,18 @@ Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeRemoveListene
|
||||
::util_ThrowExceptionToJava(env, "Exception: null initContext passed to nativeRemoveListener");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
jclass clazz = nsnull;
|
||||
int listenerType = 0;
|
||||
const char *listenerStringChars = ::util_GetStringUTFChars(env,
|
||||
const char *listenerStringChars = ::util_GetStringUTFChars(env,
|
||||
listenerString);
|
||||
if (listenerStringChars == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeRemoveListener: Can't get className for listener.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while (nsnull != gSupportedListenerInterfaces[listenerType]) {
|
||||
if (0 == nsCRT::strcmp(gSupportedListenerInterfaces[listenerType],
|
||||
if (0 == nsCRT::strcmp(gSupportedListenerInterfaces[listenerType],
|
||||
listenerStringChars)) {
|
||||
// We've got a winner!
|
||||
break;
|
||||
@ -356,25 +357,25 @@ Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeRemoveListene
|
||||
}
|
||||
::util_ReleaseStringUTFChars(env, listenerString, listenerStringChars);
|
||||
listenerStringChars = nsnull;
|
||||
|
||||
|
||||
if (LISTENER_NOT_FOUND == (LISTENER_CLASSES) listenerType) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: NativeEventThread.nativeRemoveListener(): can't find listener \n\tclass for argument");
|
||||
return;
|
||||
}
|
||||
|
||||
PR_ASSERT(initContext->browserContainer);
|
||||
|
||||
|
||||
switch(listenerType) {
|
||||
case DOCUMENT_LOAD_LISTENER:
|
||||
initContext->browserContainer->RemoveDocumentLoadListener();
|
||||
initContext->browserContainer->RemoveDocumentLoadListener();
|
||||
break;
|
||||
case MOUSE_LISTENER:
|
||||
initContext->browserContainer->RemoveMouseListener();
|
||||
initContext->browserContainer->RemoveMouseListener();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeRemoveAllListeners(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
WebShellInitContext *initContext = (WebShellInitContext *)webShellPtr;
|
||||
@ -398,7 +399,7 @@ Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeRemoveAllList
|
||||
|
||||
*/
|
||||
|
||||
int processEventLoop(WebShellInitContext * initContext)
|
||||
int processEventLoop(WebShellInitContext * initContext)
|
||||
{
|
||||
#ifdef XP_UNIX
|
||||
while(gtk_events_pending()) {
|
||||
@ -408,7 +409,7 @@ int processEventLoop(WebShellInitContext * initContext)
|
||||
// PENDING(mark): Does this work on the Mac?
|
||||
MSG msg;
|
||||
PRBool wasHandled;
|
||||
|
||||
|
||||
if (::PeekMessage(&msg, nsnull, 0, 0, PM_NOREMOVE)) {
|
||||
if (::GetMessage(&msg, nsnull, 0, 0)) {
|
||||
wasHandled = PR_FALSE;
|
||||
@ -421,10 +422,10 @@ int processEventLoop(WebShellInitContext * initContext)
|
||||
}
|
||||
#endif
|
||||
::PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
|
||||
|
||||
if ((initContext->initComplete) && (gActionQueue)) {
|
||||
PLEvent * event = nsnull;
|
||||
|
||||
|
||||
PL_ENTER_EVENT_QUEUE_MONITOR(gActionQueue);
|
||||
if (::PL_EventAvailable(gActionQueue)) {
|
||||
event = ::PL_GetEvent(gActionQueue);
|
||||
@ -436,7 +437,7 @@ int processEventLoop(WebShellInitContext * initContext)
|
||||
}
|
||||
if (initContext->stopThread) {
|
||||
initContext->stopThread++;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -470,6 +471,34 @@ static void event_processor_callback(gpointer data,
|
||||
//
|
||||
|
||||
|
||||
nsresult OverrideComponents()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIComponentRegistrar> cr;
|
||||
NS_GetComponentRegistrar(getter_AddRefs(cr));
|
||||
if (!cr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
int numComponents;
|
||||
const nsModuleComponentInfo* componentInfo = GetAppModuleComponentInfo(&numComponents);
|
||||
for (int i = 0; i < numComponents; ++i) {
|
||||
nsCOMPtr<nsIGenericFactory> componentFactory;
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(componentFactory), &(componentInfo[i]));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(PR_FALSE, "Unable to create factory for component");
|
||||
continue;
|
||||
}
|
||||
|
||||
rv = cr->RegisterFactory(componentInfo[i].mCID,
|
||||
componentInfo[i].mDescription,
|
||||
componentInfo[i].mContractID,
|
||||
componentFactory);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to register factory for component");
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* InitializeWindowCreator creates and hands off an object with a callback
|
||||
to a window creation function. This is how all new windows are opened,
|
||||
except any created directly by the embedding app. */
|
||||
@ -494,11 +523,11 @@ nsresult InitializeWindowCreator(WebShellInitContext * initContext)
|
||||
}
|
||||
|
||||
void DoMozInitialization(WebShellInitContext * initContext)
|
||||
{
|
||||
{
|
||||
if (gFirstTime) {
|
||||
// PENDING(edburns): We need this for rdf_getChildCount
|
||||
PR_SetEnv("XPCOM_CHECK_THREADSAFE=0");
|
||||
|
||||
|
||||
nsILocalFile * pathFile = nsnull;
|
||||
nsresult rv = nsnull;
|
||||
JNIEnv * env = initContext->env;
|
||||
@ -510,7 +539,7 @@ void DoMozInitialization(WebShellInitContext * initContext)
|
||||
::util_ThrowExceptionToJava(env, "call to NS_NewLocalFile failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// It is vitally important to call NS_InitEmbedding before calling
|
||||
// anything else.
|
||||
NS_InitEmbedding(pathFile, nsnull);
|
||||
@ -524,7 +553,9 @@ void DoMozInitialization(WebShellInitContext * initContext)
|
||||
PR_SetLogFile(webclientLogFile);
|
||||
// If this fails, it just goes to stdout/stderr
|
||||
}
|
||||
|
||||
|
||||
OverrideComponents();
|
||||
|
||||
InitializeWindowCreator(initContext);
|
||||
|
||||
// handle the profile manager nonsense
|
||||
@ -547,7 +578,7 @@ void DoMozInitialization(WebShellInitContext * initContext)
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_ASSERT(NamesLen >= 1);
|
||||
// PENDING(edburns): fix for 70656. Really we should have a way
|
||||
// for the embedding app to specify which profile to use.
|
||||
// for the embedding app to specify which profile to use.
|
||||
// For now we just get the name of the first profile.
|
||||
char * temp = new char[100]; // de-allocated in following for loop
|
||||
for (i = 0; Names[0][i] != '\0'; i++) {
|
||||
@ -560,7 +591,7 @@ void DoMozInitialization(WebShellInitContext * initContext)
|
||||
}
|
||||
else {
|
||||
argv[2] = strdup("default");
|
||||
}
|
||||
}
|
||||
printf("debug: edburns: argv[1]: %s argv[2]: %s\n", argv[1],
|
||||
argv[2]);
|
||||
}
|
||||
@ -588,72 +619,72 @@ void DoMozInitialization(WebShellInitContext * initContext)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||
nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||
{
|
||||
nsresult rv = nsnull;
|
||||
|
||||
DoMozInitialization(initContext);
|
||||
|
||||
|
||||
PR_ASSERT(gComponentManager);
|
||||
|
||||
if (gFirstTime) {
|
||||
printf ("\n\nCreating Event Queue \n\n");
|
||||
nsCOMPtr<nsIEventQueueService>
|
||||
nsCOMPtr<nsIEventQueueService>
|
||||
aEventQService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID);
|
||||
|
||||
|
||||
// if we get here, we know that aEventQService is not null.
|
||||
if (!aEventQService) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
//TODO Add tracing from nspr.
|
||||
|
||||
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3, ("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n", initContext));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Create the Event Queue for the UI thread...
|
||||
if (!aEventQService) {
|
||||
initContext->initFailCode = kEventQueueError;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// Create the event queue.
|
||||
rv = aEventQService->CreateThreadEventQueue();
|
||||
gEmbeddedThread = PR_GetCurrentThread();
|
||||
|
||||
|
||||
// Create the action queue
|
||||
if (gEmbeddedThread) {
|
||||
|
||||
|
||||
if (gActionQueue == nsnull) {
|
||||
printf("InitMozillaStuff(%lx): Create the action queue\n", initContext);
|
||||
|
||||
|
||||
// We need to do something different for Unix
|
||||
nsIEventQueue * EQueue = nsnull;
|
||||
|
||||
rv = aEventQService->GetThreadEventQueue(gEmbeddedThread,
|
||||
|
||||
rv = aEventQService->GetThreadEventQueue(gEmbeddedThread,
|
||||
&EQueue);
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kCreateWebShellError;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
#ifdef XP_UNIX
|
||||
gdk_input_add(EQueue->GetEventQueueSelectFD(),
|
||||
GDK_INPUT_READ,
|
||||
event_processor_callback,
|
||||
EQueue);
|
||||
#endif
|
||||
|
||||
|
||||
PLEventQueue * plEventQueue = nsnull;
|
||||
|
||||
|
||||
EQueue->GetPLEventQueue(&plEventQueue);
|
||||
gActionQueue = plEventQueue;
|
||||
}
|
||||
@ -665,7 +696,7 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
||||
// The gdk_x_error function exits in some cases, we don't
|
||||
// The gdk_x_error function exits in some cases, we don't
|
||||
// want that.
|
||||
XSetErrorHandler(wc_x_error);
|
||||
#endif
|
||||
@ -678,22 +709,22 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||
PRBool allowPlugins = PR_TRUE;
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
// Create the WebBrowser.
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser = nsnull;
|
||||
webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
|
||||
|
||||
|
||||
initContext->webBrowser = webBrowser;
|
||||
|
||||
|
||||
// Get the BaseWindow from the DocShell - upcast
|
||||
// nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(webBrowser));
|
||||
nsCOMPtr<nsIBaseWindow> docShellAsWin;
|
||||
rv = webBrowser->QueryInterface(NS_GET_IID(nsIBaseWindow), getter_AddRefs(docShellAsWin));
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> docShellAsWin;
|
||||
rv = webBrowser->QueryInterface(NS_GET_IID(nsIBaseWindow), getter_AddRefs(docShellAsWin));
|
||||
|
||||
initContext->baseWindow = docShellAsWin;
|
||||
|
||||
|
||||
printf ("Init the baseWindow\n");
|
||||
|
||||
|
||||
#ifdef XP_UNIX
|
||||
GtkWidget * bin;
|
||||
bin = (GtkWidget *) initContext->gtkWinPtr;
|
||||
@ -704,56 +735,56 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3, ("Ashu Debugs - Inside InitMozillaStuff(%lx): - after Init Call...\n", initContext));
|
||||
}
|
||||
#else
|
||||
#else
|
||||
rv = initContext->baseWindow->InitWindow((nativeWindow) initContext->parentHWnd, nsnull,
|
||||
initContext->x, initContext->y, initContext->w, initContext->h);
|
||||
#endif
|
||||
|
||||
|
||||
printf("Create the BaseWindow...\n");
|
||||
|
||||
|
||||
rv = initContext->baseWindow->Create();
|
||||
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kInitWebShellError;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// Create the DocShell
|
||||
|
||||
|
||||
initContext->docShell = do_GetInterface(initContext->webBrowser);
|
||||
|
||||
|
||||
if (!initContext->docShell) {
|
||||
initContext->initFailCode = kCreateDocShellError;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// create our BrowserContainer, which implements many many things.
|
||||
|
||||
initContext->browserContainer =
|
||||
new CBrowserContainer(initContext->webBrowser, initContext->env,
|
||||
|
||||
initContext->browserContainer =
|
||||
new CBrowserContainer(initContext->webBrowser, initContext->env,
|
||||
initContext);
|
||||
|
||||
|
||||
// set the WebShellContainer. This is a pain. It's necessary
|
||||
// because nsWebShell.cpp still checks for mContainer all over the
|
||||
// place.
|
||||
nsCOMPtr<nsIWebShellContainer> wsContainer(do_QueryInterface(initContext->browserContainer));
|
||||
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(initContext->docShell));
|
||||
webShell->SetContainer(wsContainer);
|
||||
|
||||
|
||||
// set the TreeOwner
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(initContext->docShell));
|
||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner(do_QueryInterface(initContext->browserContainer));
|
||||
docShellAsItem->SetTreeOwner(treeOwner);
|
||||
|
||||
|
||||
// set the docloaderobserver
|
||||
nsCOMPtr<nsIDocumentLoaderObserver> observer(do_QueryInterface(initContext->browserContainer));
|
||||
initContext->docShell->SetDocLoaderObserver(observer);
|
||||
|
||||
printf("Creation Done.....\n");
|
||||
|
||||
printf("Creation Done.....\n");
|
||||
// Get the WebNavigation Object from the DocShell
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(initContext->docShell));
|
||||
initContext->webNavigation = webNav;
|
||||
|
||||
|
||||
printf("Show the webBrowser\n");
|
||||
// Show the webBrowser
|
||||
rv = initContext->baseWindow->SetVisibility(PR_TRUE);
|
||||
@ -761,19 +792,19 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||
initContext->initFailCode = kShowWebShellError;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
initContext->initComplete = TRUE;
|
||||
|
||||
|
||||
*/
|
||||
|
||||
wsRealizeBrowserEvent * actionEvent = new wsRealizeBrowserEvent(initContext);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
::util_PostSynchronousEvent(initContext, event);
|
||||
|
||||
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("InitMozillaStuff(%lx): enter event loop\n", initContext));
|
||||
}
|
||||
#endif
|
||||
@ -783,7 +814,7 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||
if (threadId == (void *) gEmbeddedThread)
|
||||
// Just need to loop once to clear out events before returning
|
||||
processEventLoop(initContext);
|
||||
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
@ -21,6 +21,7 @@
|
||||
* Ian Wilkinson <iw@ennoble.com>
|
||||
* Ashutosh Kulkarni <ashuk@eng.sun.com>
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Kyle Yuan <kyle.yuan@sun.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -52,22 +53,29 @@ wsRealizeBrowserEvent::wsRealizeBrowserEvent(WebShellInitContext * yourInitConte
|
||||
void *
|
||||
wsRealizeBrowserEvent::handleEvent ()
|
||||
{
|
||||
nsresult rv = nsnull;
|
||||
nsresult rv = nsnull;
|
||||
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser = nsnull;
|
||||
webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
|
||||
|
||||
mInitContext->webBrowser = webBrowser;
|
||||
|
||||
|
||||
// create our BrowserContainer, which implements many many things.
|
||||
|
||||
CBrowserContainer *browserContainer =
|
||||
new CBrowserContainer(mInitContext->webBrowser, mInitContext->env,
|
||||
mInitContext);
|
||||
mInitContext->browserContainer = browserContainer;
|
||||
|
||||
webBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, browserContainer));
|
||||
|
||||
// Get the BaseWindow from the DocShell - upcast
|
||||
// nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(webBrowser));
|
||||
nsCOMPtr<nsIBaseWindow> docShellAsWin;
|
||||
rv = webBrowser->QueryInterface(NS_GET_IID(nsIBaseWindow), getter_AddRefs(docShellAsWin));
|
||||
|
||||
mInitContext->baseWindow = docShellAsWin;
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow;
|
||||
baseWindow = do_QueryInterface(webBrowser, &rv);
|
||||
mInitContext->baseWindow = baseWindow;
|
||||
|
||||
printf ("Init the baseWindow\n");
|
||||
|
||||
|
||||
#ifdef XP_UNIX
|
||||
GtkWidget * bin;
|
||||
bin = (GtkWidget *) mInitContext->gtkWinPtr;
|
||||
@ -78,51 +86,33 @@ wsRealizeBrowserEvent::handleEvent ()
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3, ("Ashu Debugs - Inside InitMozillaStuff(%lx): - after Init Call...\n", mInitContext));
|
||||
}
|
||||
#else
|
||||
#else
|
||||
rv = mInitContext->baseWindow->InitWindow((nativeWindow) mInitContext->parentHWnd, nsnull,
|
||||
mInitContext->x, mInitContext->y, mInitContext->w, mInitContext->h);
|
||||
#endif
|
||||
|
||||
|
||||
printf("Create the BaseWindow...\n");
|
||||
|
||||
|
||||
rv = mInitContext->baseWindow->Create();
|
||||
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
mInitContext->initFailCode = kInitWebShellError;
|
||||
return (void *) rv;
|
||||
}
|
||||
|
||||
|
||||
// Create the DocShell
|
||||
|
||||
|
||||
mInitContext->docShell = do_GetInterface(mInitContext->webBrowser);
|
||||
|
||||
|
||||
if (!mInitContext->docShell) {
|
||||
mInitContext->initFailCode = kCreateDocShellError;
|
||||
return (void *) rv;
|
||||
}
|
||||
|
||||
// create our BrowserContainer, which implements many many things.
|
||||
|
||||
mInitContext->browserContainer =
|
||||
new CBrowserContainer(mInitContext->webBrowser, mInitContext->env,
|
||||
mInitContext);
|
||||
|
||||
// set the WebShellContainer. This is a pain. It's necessary
|
||||
// because nsWebShell.cpp still checks for mContainer all over the
|
||||
// place.
|
||||
nsCOMPtr<nsIWebShellContainer> wsContainer(do_QueryInterface(mInitContext->browserContainer));
|
||||
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mInitContext->docShell));
|
||||
webShell->SetContainer(wsContainer);
|
||||
|
||||
// set the TreeOwner
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mInitContext->docShell));
|
||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner(do_QueryInterface(mInitContext->browserContainer));
|
||||
docShellAsItem->SetTreeOwner(treeOwner);
|
||||
|
||||
|
||||
// set the docloaderobserver PENDING(edburns): how to we make our
|
||||
// presence as a nsIWebProgressListener know?n
|
||||
|
||||
printf("Creation Done.....\n");
|
||||
printf("Creation Done.....\n");
|
||||
// Get the WebNavigation Object from the DocShell
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mInitContext->docShell));
|
||||
mInitContext->webNavigation = webNav;
|
||||
@ -134,14 +124,14 @@ wsRealizeBrowserEvent::handleEvent ()
|
||||
return (void *) rv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Set the History
|
||||
// mInitContext->webNavigation->SetSessionHistory(gHistory);
|
||||
|
||||
|
||||
// Save the sessionHistory in the initContext
|
||||
// mInitContext->sHistory = gHistory;
|
||||
|
||||
|
||||
printf("Show the webBrowser\n");
|
||||
// Show the webBrowser
|
||||
rv = mInitContext->baseWindow->SetVisibility(PR_TRUE);
|
||||
@ -149,8 +139,8 @@ wsRealizeBrowserEvent::handleEvent ()
|
||||
mInitContext->initFailCode = kShowWebShellError;
|
||||
return (void *) rv;
|
||||
}
|
||||
|
||||
mInitContext->initComplete = TRUE;
|
||||
|
||||
mInitContext->initComplete = TRUE;
|
||||
|
||||
// we will check this value in WindowCreator::CreateChromeWindow
|
||||
gNewWindowInitContext = mInitContext;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
@ -31,17 +31,16 @@
|
||||
#include "nsString2.h" // for nsAutoString
|
||||
|
||||
wsPromptUsernameAndPasswordEvent::wsPromptUsernameAndPasswordEvent(WebShellInitContext *yourInitContext,
|
||||
jobject yourPromptGlobalRef,
|
||||
wsStringStruct *inStrings,
|
||||
PRUint32 savePassword,
|
||||
PRUnichar **outUser,
|
||||
PRUnichar **outPwd,
|
||||
jobject yourPromptGlobalRef,
|
||||
wsStringStruct *inStrings,
|
||||
PRUnichar **outUser,
|
||||
PRUnichar **outPwd,
|
||||
PRBool *_retval) :
|
||||
mInitContext(yourInitContext), mPromptGlobalRef(yourPromptGlobalRef),
|
||||
mInitContext(yourInitContext), mPromptGlobalRef(yourPromptGlobalRef),
|
||||
mInStrings(inStrings), mOutUser(outUser),
|
||||
mOutPwd(outPwd), mRetVal(_retval)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void *wsPromptUsernameAndPasswordEvent::handleEvent()
|
||||
@ -66,18 +65,18 @@ void *wsPromptUsernameAndPasswordEvent::handleEvent()
|
||||
if (!(promptClass = env->GetObjectClass(mPromptGlobalRef))) {
|
||||
return (void *) NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!(mid = env->GetMethodID(promptClass, "promptUsernameAndPassword",
|
||||
if (!(mid = env->GetMethodID(promptClass, "promptUsernameAndPassword",
|
||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/util/Properties;)Z"))) {
|
||||
return (void *) NS_ERROR_FAILURE;
|
||||
}
|
||||
result = env->CallBooleanMethod(mPromptGlobalRef, mid,
|
||||
mInStrings[0].jStr, mInStrings[1].jStr,
|
||||
mInStrings[2].jStr, (jint) mSavePassword,
|
||||
result = env->CallBooleanMethod(mPromptGlobalRef, mid,
|
||||
mInStrings[0].jStr, mInStrings[1].jStr,
|
||||
mInStrings[2].jStr, 0,
|
||||
gPromptProperties);
|
||||
#endif
|
||||
|
||||
|
||||
// pull userName and password entries out of the properties table
|
||||
|
||||
|
||||
user = (jstring) ::util_GetFromPropertiesObject(env, gPromptProperties,
|
||||
USER_NAME_KEY, (jobject)
|
||||
&(mInitContext->shareContext));
|
||||
@ -87,7 +86,7 @@ void *wsPromptUsernameAndPasswordEvent::handleEvent()
|
||||
*mOutUser = ToNewUnicode(autoUser);
|
||||
::util_ReleaseStringChars(env, user, userJchar);
|
||||
}
|
||||
|
||||
|
||||
password = (jstring) ::util_GetFromPropertiesObject(env, gPromptProperties,
|
||||
PASSWORD_KEY, (jobject)
|
||||
&(mInitContext->shareContext));
|
||||
@ -97,29 +96,24 @@ void *wsPromptUsernameAndPasswordEvent::handleEvent()
|
||||
*mOutPwd = ToNewUnicode(autoPassword);
|
||||
::util_ReleaseStringChars(env, password, passwordJchar);
|
||||
}
|
||||
|
||||
|
||||
*mRetVal = (result == JNI_TRUE) ? PR_TRUE : PR_FALSE;
|
||||
|
||||
|
||||
return (void *) NS_OK;
|
||||
}
|
||||
|
||||
wsPromptUniversalDialogEvent::wsPromptUniversalDialogEvent(WebShellInitContext *yourInitContext,
|
||||
jobject yourPromptGlobalRef,
|
||||
wsStringStruct *inStrings,
|
||||
PRUnichar **fieldOne,
|
||||
PRUnichar **fieldTwo,
|
||||
PRBool *checkboxState,
|
||||
PRInt32 numButtons,
|
||||
PRInt32 numFields,
|
||||
PRInt32 fieldIsPasswd,
|
||||
PRInt32 *buttonPressed) :
|
||||
mInitContext(yourInitContext), mPromptGlobalRef(yourPromptGlobalRef),
|
||||
jobject yourPromptGlobalRef,
|
||||
wsStringStruct *inStrings,
|
||||
PRUnichar **fieldOne,
|
||||
PRUnichar **fieldTwo,
|
||||
PRInt32 numButtons,
|
||||
PRInt32 numFields,
|
||||
PRInt32 fieldIsPasswd) :
|
||||
mInitContext(yourInitContext), mPromptGlobalRef(yourPromptGlobalRef),
|
||||
mInStrings(inStrings), mFieldOne(fieldOne), mFieldTwo(fieldTwo),
|
||||
mCheckboxState(checkboxState), mNumButtons(numButtons),
|
||||
mNumFields(numFields), mFieldIsPasswd(fieldIsPasswd),
|
||||
mButtonPressed(buttonPressed)
|
||||
mNumButtons(numButtons), mNumFields(numFields), mFieldIsPasswd(fieldIsPasswd)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void *wsPromptUniversalDialogEvent::handleEvent()
|
||||
@ -146,71 +140,26 @@ void *wsPromptUniversalDialogEvent::handleEvent()
|
||||
if (!(promptClass = env->GetObjectClass(mPromptGlobalRef))) {
|
||||
return (void *) NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!(mid = env->GetMethodID(promptClass, "universalDialog",
|
||||
if (!(mid = env->GetMethodID(promptClass, "universalDialog",
|
||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIZLjava/util/Properties;)Z"))) {
|
||||
return (void *) NS_ERROR_FAILURE;
|
||||
}
|
||||
result = env->CallBooleanMethod(mPromptGlobalRef, mid,
|
||||
mInStrings[0].jStr,
|
||||
mInStrings[1].jStr,
|
||||
mInStrings[2].jStr,
|
||||
mInStrings[3].jStr,
|
||||
mInStrings[4].jStr,
|
||||
mInStrings[5].jStr,
|
||||
mInStrings[6].jStr,
|
||||
mInStrings[7].jStr,
|
||||
mInStrings[8].jStr,
|
||||
mInStrings[9].jStr,
|
||||
(jint) mNumButtons,
|
||||
result = env->CallBooleanMethod(mPromptGlobalRef, mid,
|
||||
mInStrings[0].jStr,
|
||||
mInStrings[1].jStr,
|
||||
mInStrings[2].jStr,
|
||||
mInStrings[3].jStr,
|
||||
mInStrings[4].jStr,
|
||||
mInStrings[5].jStr,
|
||||
mInStrings[6].jStr,
|
||||
mInStrings[7].jStr,
|
||||
mInStrings[8].jStr,
|
||||
mInStrings[9].jStr,
|
||||
(jint) mNumButtons,
|
||||
(jint) mNumFields,
|
||||
(jboolean) mFieldIsPasswd,
|
||||
gPromptProperties);
|
||||
#endif
|
||||
|
||||
// pull entries out of the properties table
|
||||
// editfield1Value, editfield2Value, checkboxState, buttonPressed
|
||||
|
||||
if (mFieldOne) {
|
||||
edit1 = (jstring) ::util_GetFromPropertiesObject(env,
|
||||
gPromptProperties,
|
||||
EDIT_FIELD_1_KEY,
|
||||
(jobject)
|
||||
&(mInitContext->shareContext));
|
||||
edit1Jchar = ::util_GetStringChars(env, edit1);
|
||||
autoEdit1 = (PRUnichar *) edit1Jchar;
|
||||
*mFieldOne = ToNewUnicode(autoEdit1);
|
||||
::util_ReleaseStringChars(env, edit1, edit1Jchar);
|
||||
}
|
||||
|
||||
if (mFieldTwo) {
|
||||
edit2 = (jstring) ::util_GetFromPropertiesObject(env,
|
||||
gPromptProperties,
|
||||
EDIT_FIELD_2_KEY,
|
||||
(jobject)
|
||||
&(mInitContext->shareContext));
|
||||
edit2Jchar = ::util_GetStringChars(env, edit2);
|
||||
autoEdit2 = (PRUnichar *) edit2Jchar;
|
||||
*mFieldTwo = ToNewUnicode(autoEdit2);
|
||||
::util_ReleaseStringChars(env, edit2, edit2Jchar);
|
||||
}
|
||||
|
||||
if (mCheckboxState) {
|
||||
*mCheckboxState =
|
||||
(JNI_TRUE == ::util_GetBoolFromPropertiesObject(env,
|
||||
gPromptProperties,
|
||||
CHECKBOX_STATE_KEY,
|
||||
(jobject)
|
||||
&(mInitContext->shareContext)))
|
||||
? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
|
||||
if (mButtonPressed) {
|
||||
*mButtonPressed = (PRInt32)
|
||||
::util_GetIntFromPropertiesObject(env, gPromptProperties,
|
||||
BUTTON_PRESSED_KEY,
|
||||
(jobject)
|
||||
&(mInitContext->shareContext));
|
||||
}
|
||||
|
||||
return (void *) NS_OK;
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ public:
|
||||
wsPromptUsernameAndPasswordEvent (WebShellInitContext *yourInitContext,
|
||||
jobject yourPromptGlobalRef,
|
||||
wsStringStruct *inStrings,
|
||||
PRUint32 savePassword,
|
||||
PRUnichar **outUser,
|
||||
PRUnichar **outPwd,
|
||||
PRBool *_retval);
|
||||
@ -49,7 +48,6 @@ protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
jobject mPromptGlobalRef;
|
||||
wsStringStruct *mInStrings;
|
||||
PRUint32 mSavePassword;
|
||||
PRUnichar **mOutUser;
|
||||
PRUnichar **mOutPwd;
|
||||
PRBool *mRetVal;
|
||||
@ -62,11 +60,9 @@ public:
|
||||
wsStringStruct *inStrings,
|
||||
PRUnichar **fieldOne,
|
||||
PRUnichar **fieldTwo,
|
||||
PRBool *checkboxState,
|
||||
PRInt32 numButtons,
|
||||
PRInt32 numFields,
|
||||
PRInt32 fieldIsPasswd,
|
||||
PRInt32 *buttonPressed);
|
||||
PRInt32 fieldIsPasswd);
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
@ -75,11 +71,9 @@ protected:
|
||||
wsStringStruct *mInStrings;
|
||||
PRUnichar **mFieldOne;
|
||||
PRUnichar **mFieldTwo;
|
||||
PRBool *mCheckboxState;
|
||||
PRInt32 mNumButtons;
|
||||
PRInt32 mNumFields;
|
||||
PRInt32 mFieldIsPasswd;
|
||||
PRInt32 *mButtonPressed;
|
||||
};
|
||||
|
||||
|
||||
|
548
java/webclient/src_moz/PromptService.cpp
Normal file
548
java/webclient/src_moz/PromptService.cpp
Normal file
@ -0,0 +1,548 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems, Inc.
|
||||
* Portions created by Sun Microsystems are Copyright (C) 2003 Sun
|
||||
* Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Original Author: Kyle Yuan <kyle.yuan@sun.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*/
|
||||
|
||||
#include "PromptService.h"
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIEmbeddingSiteWindow.h"
|
||||
#include "CBrowserContainer.h"
|
||||
#include "PromptActionEvents.h"
|
||||
|
||||
int processEventLoop(WebShellInitContext * initContext);
|
||||
|
||||
//*****************************************************************************
|
||||
// PromptService
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ISUPPORTS1(PromptService, nsIPromptService)
|
||||
|
||||
PromptService::PromptService() :
|
||||
mWWatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID))
|
||||
{
|
||||
}
|
||||
|
||||
PromptService::~PromptService()
|
||||
{
|
||||
}
|
||||
|
||||
CBrowserContainer *
|
||||
PromptService::BrowserContainerForDOMWindow(nsIDOMWindow *aWindow)
|
||||
{
|
||||
nsCOMPtr<nsIWebBrowserChrome> chrome;
|
||||
CBrowserContainer *val = 0;
|
||||
|
||||
if (mWWatch) {
|
||||
nsCOMPtr<nsIDOMWindow> fosterParent;
|
||||
if (!aWindow) { // it will be a dependent window. try to find a foster parent.
|
||||
mWWatch->GetActiveWindow(getter_AddRefs(fosterParent));
|
||||
aWindow = fosterParent;
|
||||
}
|
||||
mWWatch->GetChromeForWindow(aWindow, getter_AddRefs(chrome));
|
||||
}
|
||||
|
||||
if (chrome) {
|
||||
nsCOMPtr<nsIEmbeddingSiteWindow> site(do_QueryInterface(chrome));
|
||||
if (site) {
|
||||
void *ret;
|
||||
site->GetSiteWindow(&ret);
|
||||
val = (CBrowserContainer *)ret;
|
||||
}
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
nsresult
|
||||
PromptService::PromptUniversalDialog(nsIDOMWindow *parent,
|
||||
const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
const PRUnichar *checkMsg,
|
||||
const PRUnichar *button0Title,
|
||||
const PRUnichar *button1Title,
|
||||
const PRUnichar *button2Title,
|
||||
const PRUnichar *button3Title,
|
||||
const PRUnichar *editfield1Msg,
|
||||
const PRUnichar *editfield2Msg,
|
||||
PRUnichar **editfield1Value,
|
||||
PRUnichar **editfield2Value,
|
||||
PRInt32 numButtons,
|
||||
PRInt32 numFields,
|
||||
PRInt32 fieldIsPasswd,
|
||||
PRBool *checkState,
|
||||
PRInt32 *buttonPressed)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
// if the user hasn't given us a prompt, oh well
|
||||
CBrowserContainer* bc = BrowserContainerForDOMWindow(parent);
|
||||
|
||||
// PENDING(edburns): uniformly apply checks for this throughout the
|
||||
// code
|
||||
PR_ASSERT(bc->mInitContext);
|
||||
PR_ASSERT(bc->mInitContext->initComplete);
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
// try to initialize the properties object for basic auth and cookies
|
||||
if (!gPromptProperties) {
|
||||
gPromptProperties =
|
||||
::util_CreatePropertiesObject(env, (jobject)
|
||||
&(bc->mInitContext->shareContext));
|
||||
if (!gPromptProperties) {
|
||||
printf("Error: can't create properties object for authentitication");
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
}
|
||||
else {
|
||||
::util_ClearPropertiesObject(env, gPromptProperties, (jobject)
|
||||
&(bc->mInitContext->shareContext));
|
||||
}
|
||||
|
||||
wsStringStruct strings[10] = {
|
||||
{text, nsnull},
|
||||
{dialogTitle, nsnull},
|
||||
{nsnull, nsnull},
|
||||
{checkMsg, nsnull},
|
||||
{button0Title, nsnull},
|
||||
{button1Title, nsnull},
|
||||
{button2Title, nsnull},
|
||||
{button3Title, nsnull},
|
||||
{editfield1Msg, nsnull},
|
||||
{editfield2Msg, nsnull} };
|
||||
|
||||
rv = ::util_CreateJstringsFromUnichars(strings, 10);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: UniversalDialog: can't create jstrings from Unichars");
|
||||
::util_DeleteJstringsFromUnichars(strings, 10);
|
||||
return rv;
|
||||
}
|
||||
|
||||
jstring defaultValue = nsnull;
|
||||
if (editfield1Value) {
|
||||
nsAutoString autoStr(*editfield1Value);
|
||||
defaultValue = ::util_NewString(env, (const jchar *) autoStr.get(), autoStr.Length());
|
||||
::util_StoreIntoPropertiesObject(env, gPromptProperties, EDIT_FIELD_1_KEY, defaultValue,
|
||||
(jobject) &(bc->mInitContext->shareContext));
|
||||
}
|
||||
if (editfield2Value) {
|
||||
nsAutoString autoStr(*editfield2Value);
|
||||
defaultValue = ::util_NewString(env, (const jchar *) autoStr.get(), autoStr.Length());
|
||||
::util_StoreIntoPropertiesObject(env, gPromptProperties, EDIT_FIELD_2_KEY, defaultValue,
|
||||
(jobject) &(bc->mInitContext->shareContext));
|
||||
}
|
||||
|
||||
wsPromptUniversalDialogEvent *actionEvent = nsnull;
|
||||
if (!(actionEvent = new wsPromptUniversalDialogEvent(bc->mInitContext,
|
||||
bc->mPrompt,
|
||||
strings,
|
||||
editfield1Value,
|
||||
editfield2Value,
|
||||
numButtons,
|
||||
numFields,
|
||||
fieldIsPasswd))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: UniversalDialog: can't create wsPromptUniversalDialogEvent");
|
||||
::util_DeleteJstringsFromUnichars(strings, 10);
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
// the out params to this method are set in wsPromptUsernameAndPasswordEvent::handleEvent()
|
||||
::util_PostSynchronousEvent(bc->mInitContext, (PLEvent *) *actionEvent);
|
||||
::util_DeleteJstringsFromUnichars(strings, 10);
|
||||
|
||||
while (1)
|
||||
{
|
||||
processEventLoop(bc->mInitContext);
|
||||
::PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
|
||||
jstring finished = (jstring) ::util_GetFromPropertiesObject(env,
|
||||
gPromptProperties,
|
||||
FINISHED_KEY,
|
||||
(jobject)
|
||||
&(bc->mInitContext->shareContext));
|
||||
if (finished) {
|
||||
const jchar *finishedJchar = ::util_GetStringChars(env, finished);
|
||||
nsAutoString strValue((const PRUnichar *) finishedJchar);
|
||||
::util_ReleaseStringChars(env, finished, finishedJchar);
|
||||
if (strValue.Equals(NS_LITERAL_STRING("true"))) {
|
||||
printf("***** Finished!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pull entries out of the properties table
|
||||
// editfield1Value, editfield2Value, checkboxState, buttonPressed
|
||||
jstring edit1 = nsnull;
|
||||
jstring edit2 = nsnull;
|
||||
const jchar *edit1Jchar = nsnull;
|
||||
const jchar *edit2Jchar = nsnull;
|
||||
nsAutoString autoEdit1;
|
||||
nsAutoString autoEdit2;
|
||||
|
||||
if (editfield1Value) {
|
||||
edit1 = (jstring) ::util_GetFromPropertiesObject(env,
|
||||
gPromptProperties,
|
||||
EDIT_FIELD_1_KEY,
|
||||
(jobject)
|
||||
&(bc->mInitContext->shareContext));
|
||||
edit1Jchar = ::util_GetStringChars(env, edit1);
|
||||
autoEdit1 = (PRUnichar *) edit1Jchar;
|
||||
*editfield1Value = ToNewUnicode(autoEdit1);
|
||||
::util_ReleaseStringChars(env, edit1, edit1Jchar);
|
||||
}
|
||||
|
||||
if (editfield2Value) {
|
||||
edit2 = (jstring) ::util_GetFromPropertiesObject(env,
|
||||
gPromptProperties,
|
||||
EDIT_FIELD_2_KEY,
|
||||
(jobject)
|
||||
&(bc->mInitContext->shareContext));
|
||||
edit2Jchar = ::util_GetStringChars(env, edit2);
|
||||
autoEdit2 = (PRUnichar *) edit2Jchar;
|
||||
*editfield2Value = ToNewUnicode(autoEdit2);
|
||||
::util_ReleaseStringChars(env, edit2, edit2Jchar);
|
||||
}
|
||||
|
||||
if (checkState) {
|
||||
*checkState =
|
||||
(JNI_TRUE == ::util_GetBoolFromPropertiesObject(env,
|
||||
gPromptProperties,
|
||||
CHECKBOX_STATE_KEY,
|
||||
(jobject)
|
||||
&(bc->mInitContext->shareContext)))
|
||||
? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
|
||||
if (buttonPressed) {
|
||||
*buttonPressed = (PRInt32)
|
||||
::util_GetIntFromPropertiesObject(env, gPromptProperties,
|
||||
BUTTON_PRESSED_KEY,
|
||||
(jobject)
|
||||
&(bc->mInitContext->shareContext));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PromptService::Alert(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text)
|
||||
{
|
||||
nsXPIDLString buttonOKStr;
|
||||
util_GetLocaleString("OK", getter_Copies(buttonOKStr));
|
||||
|
||||
nsresult rv = PromptUniversalDialog(parent,
|
||||
dialogTitle,
|
||||
text,
|
||||
nsnull,
|
||||
buttonOKStr.get(), nsnull, nsnull, nsnull,
|
||||
nsnull, nsnull,
|
||||
nsnull, nsnull,
|
||||
1,
|
||||
0,
|
||||
PR_FALSE,
|
||||
nsnull,
|
||||
nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PromptService::AlertCheck(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
const PRUnichar *checkMsg, PRBool *checkValue)
|
||||
{
|
||||
nsXPIDLString buttonOKStr;
|
||||
util_GetLocaleString("OK", getter_Copies(buttonOKStr));
|
||||
|
||||
nsresult rv = PromptUniversalDialog(parent,
|
||||
dialogTitle,
|
||||
text,
|
||||
checkMsg,
|
||||
buttonOKStr.get(), nsnull, nsnull, nsnull,
|
||||
nsnull, nsnull,
|
||||
nsnull, nsnull,
|
||||
1,
|
||||
0,
|
||||
PR_FALSE,
|
||||
checkValue,
|
||||
nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PromptService::Confirm(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsXPIDLString buttonOKStr, buttonCancelStr;
|
||||
util_GetLocaleString("OK", getter_Copies(buttonOKStr));
|
||||
util_GetLocaleString("Cancel", getter_Copies(buttonCancelStr));
|
||||
|
||||
PRInt32 buttonPressed;
|
||||
nsresult rv = PromptUniversalDialog(parent,
|
||||
dialogTitle,
|
||||
text,
|
||||
nsnull,
|
||||
buttonOKStr.get(), buttonCancelStr.get(), nsnull, nsnull,
|
||||
nsnull, nsnull,
|
||||
nsnull, nsnull,
|
||||
2,
|
||||
0,
|
||||
PR_FALSE,
|
||||
nsnull,
|
||||
&buttonPressed);
|
||||
|
||||
*_retval = (buttonPressed == 0) ? PR_TRUE : PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PromptService::ConfirmCheck(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
const PRUnichar *checkMsg, PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(checkValue);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsXPIDLString buttonOKStr, buttonCancelStr;
|
||||
util_GetLocaleString("OK", getter_Copies(buttonOKStr));
|
||||
util_GetLocaleString("Cancel", getter_Copies(buttonCancelStr));
|
||||
|
||||
PRInt32 buttonPressed;
|
||||
nsresult rv = PromptUniversalDialog(parent,
|
||||
dialogTitle,
|
||||
text,
|
||||
checkMsg,
|
||||
buttonOKStr.get(), buttonCancelStr.get(), nsnull, nsnull,
|
||||
nsnull, nsnull,
|
||||
nsnull, nsnull,
|
||||
2,
|
||||
0,
|
||||
PR_FALSE,
|
||||
checkValue,
|
||||
&buttonPressed);
|
||||
|
||||
*_retval = (buttonPressed == 0) ? PR_TRUE : PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PromptService::ConfirmEx(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
PRUint32 buttonFlags,
|
||||
const PRUnichar *button0Title,
|
||||
const PRUnichar *button1Title,
|
||||
const PRUnichar *button2Title,
|
||||
const PRUnichar *checkMsg, PRBool *checkValue,
|
||||
PRInt32 *buttonPressed)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(buttonPressed);
|
||||
|
||||
// the maximum number of buttons we expect
|
||||
const PRInt32 maxButtons = 3;
|
||||
const PRUnichar* buttonStrings[maxButtons] =
|
||||
{ button0Title, button1Title, button2Title };
|
||||
const PRUnichar* buttonTitles[maxButtons];
|
||||
|
||||
PRInt32 numberButtons = 0;
|
||||
// this code cribbed from nsPromptService.cpp::ConfirmEx
|
||||
|
||||
nsXPIDLString buttonTextStr[maxButtons];
|
||||
|
||||
for (PRInt32 i = 0; i < maxButtons; i++) {
|
||||
|
||||
nsXPIDLString buttonTextStr;
|
||||
const PRUnichar* buttonText = 0;
|
||||
switch (buttonFlags & 0xff) {
|
||||
case BUTTON_TITLE_OK:
|
||||
util_GetLocaleString("OK", getter_Copies(buttonTextStr));
|
||||
break;
|
||||
case BUTTON_TITLE_CANCEL:
|
||||
util_GetLocaleString("Cancel", getter_Copies(buttonTextStr));
|
||||
break;
|
||||
case BUTTON_TITLE_YES:
|
||||
util_GetLocaleString("Yes", getter_Copies(buttonTextStr));
|
||||
break;
|
||||
case BUTTON_TITLE_NO:
|
||||
util_GetLocaleString("No", getter_Copies(buttonTextStr));
|
||||
break;
|
||||
case BUTTON_TITLE_SAVE:
|
||||
util_GetLocaleString("Save", getter_Copies(buttonTextStr));
|
||||
break;
|
||||
case BUTTON_TITLE_DONT_SAVE:
|
||||
util_GetLocaleString("DontSave", getter_Copies(buttonTextStr));
|
||||
break;
|
||||
case BUTTON_TITLE_REVERT:
|
||||
util_GetLocaleString("Revert", getter_Copies(buttonTextStr));
|
||||
break;
|
||||
case BUTTON_TITLE_IS_STRING:
|
||||
buttonText = buttonStrings[i];
|
||||
break;
|
||||
}
|
||||
if (!buttonText)
|
||||
buttonText = buttonTextStr.get();
|
||||
|
||||
if (buttonText) {
|
||||
buttonTitles[numberButtons] = buttonText;
|
||||
++numberButtons;
|
||||
}
|
||||
buttonFlags >>= 8;
|
||||
}
|
||||
|
||||
nsresult rv = PromptUniversalDialog(parent,
|
||||
dialogTitle,
|
||||
text,
|
||||
checkMsg,
|
||||
buttonTitles[0], buttonTitles[1], buttonTitles[2], nsnull,
|
||||
nsnull, nsnull,
|
||||
nsnull, nsnull,
|
||||
numberButtons,
|
||||
0,
|
||||
PR_FALSE,
|
||||
checkValue,
|
||||
buttonPressed);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PromptService::Prompt(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text, PRUnichar **value,
|
||||
const PRUnichar *checkMsg, PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsXPIDLString buttonOKStr, buttonCancelStr;
|
||||
util_GetLocaleString("OK", getter_Copies(buttonOKStr));
|
||||
util_GetLocaleString("Cancel", getter_Copies(buttonCancelStr));
|
||||
|
||||
PRInt32 buttonPressed;
|
||||
nsresult rv = PromptUniversalDialog(parent,
|
||||
dialogTitle,
|
||||
text,
|
||||
checkMsg,
|
||||
buttonOKStr.get(), buttonCancelStr.get(), nsnull, nsnull,
|
||||
nsnull, nsnull,
|
||||
value, nsnull,
|
||||
2,
|
||||
1,
|
||||
PR_FALSE,
|
||||
checkValue,
|
||||
&buttonPressed);
|
||||
|
||||
*_retval = (buttonPressed == 0) ? PR_TRUE : PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PromptService::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 rv = NS_ERROR_FAILURE;
|
||||
|
||||
// if the user hasn't given us a prompt, oh well
|
||||
CBrowserContainer* bc = BrowserContainerForDOMWindow(parent);
|
||||
|
||||
// PENDING(edburns): uniformly apply checks for this throughout the
|
||||
// code
|
||||
PR_ASSERT(bc->mInitContext);
|
||||
PR_ASSERT(bc->mInitContext->initComplete);
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
wsPromptUsernameAndPasswordEvent *actionEvent = nsnull;
|
||||
|
||||
wsStringStruct strings[3] = {
|
||||
{dialogTitle, nsnull},
|
||||
{text, nsnull},
|
||||
{nsnull, nsnull} };
|
||||
|
||||
rv = ::util_CreateJstringsFromUnichars(strings, 3);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: PromptUserNameAndPassword: can't create jstrings from Unichars");
|
||||
goto PUAP_CLEANUP;
|
||||
}
|
||||
|
||||
// try to initialize the properties object for basic auth and cookies
|
||||
if (!gPromptProperties) {
|
||||
gPromptProperties =
|
||||
::util_CreatePropertiesObject(env, (jobject)
|
||||
&(bc->mInitContext->shareContext));
|
||||
if (!gPromptProperties) {
|
||||
printf("Error: can't create properties object for authentitication");
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
goto PUAP_CLEANUP;
|
||||
}
|
||||
}
|
||||
else {
|
||||
::util_ClearPropertiesObject(env, gPromptProperties, (jobject)
|
||||
&(bc->mInitContext->shareContext));
|
||||
}
|
||||
|
||||
if (!(actionEvent = new wsPromptUsernameAndPasswordEvent(bc->mInitContext, bc->mPrompt,
|
||||
strings, username, password, _retval))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: PromptUserNameAndPassword: can't create wsPromptUsernameAndPasswordEvent");
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
goto PUAP_CLEANUP;
|
||||
}
|
||||
// the out params to this method are set in wsPromptUsernameAndPasswordEvent::handleEvent()
|
||||
::util_PostSynchronousEvent(bc->mInitContext,
|
||||
(PLEvent *) *actionEvent);
|
||||
rv = NS_OK;
|
||||
PUAP_CLEANUP:
|
||||
|
||||
::util_DeleteJstringsFromUnichars(strings, 3);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PromptService::PromptPassword(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text,
|
||||
PRUnichar **password,
|
||||
const PRUnichar *checkMsg, PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
printf("###PromptPassword\n");
|
||||
*_retval = PR_TRUE;
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PromptService::Select(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
|
||||
const PRUnichar *text, PRUint32 count,
|
||||
const PRUnichar **selectList, PRInt32 *outSelection,
|
||||
PRBool *_retval)
|
||||
{
|
||||
printf("###Select\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
74
java/webclient/src_moz/PromptService.h
Normal file
74
java/webclient/src_moz/PromptService.h
Normal file
@ -0,0 +1,74 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems, Inc.
|
||||
* Portions created by Sun Microsystems are Copyright (C) 2003 Sun
|
||||
* Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Original Author: Kyle Yuan <kyle.yuan@sun.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PromptService_h
|
||||
#define __PromptService_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
|
||||
//*****************************************************************************
|
||||
// PromptService
|
||||
//*****************************************************************************
|
||||
|
||||
class CBrowserContainer;
|
||||
|
||||
class PromptService: public nsIPromptService
|
||||
{
|
||||
public:
|
||||
PromptService();
|
||||
virtual ~PromptService();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROMPTSERVICE
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIWindowWatcher> mWWatch;
|
||||
|
||||
CBrowserContainer *BrowserContainerForDOMWindow(nsIDOMWindow *aWindow);
|
||||
|
||||
nsresult PromptUniversalDialog(
|
||||
nsIDOMWindow *parent,
|
||||
const PRUnichar *dialogTitle, //[in] dialog title
|
||||
const PRUnichar *text, //[in] text main message for dialog
|
||||
const PRUnichar *checkMsg, //[in] message for checkbox
|
||||
const PRUnichar *button0Title, //[in] text for first button
|
||||
const PRUnichar *button1Title, //[in] text for second button
|
||||
const PRUnichar *button2Title, //[in] text for third button
|
||||
const PRUnichar *button3Title, //[in] text for fourth button
|
||||
const PRUnichar *editfield1Msg, //[in] message for first edit field
|
||||
const PRUnichar *editfield2Msg, //[in] message for second edit field
|
||||
PRUnichar **editfield1Value, //[in/out] initial/return value for first edit field
|
||||
PRUnichar **editfield2Value, //[in/out] initial/return value for second edit field
|
||||
PRInt32 numButtons, //[in] total number of buttons (0 to 4)
|
||||
PRInt32 numFields, //[in] total number of edit fields (0 to 2)
|
||||
PRInt32 fieldIsPasswd, //[in] whether or not editField1 is a password
|
||||
PRBool *checkState, //[out] state for checkbox
|
||||
PRInt32 *buttonPressed //[out] which button was pressed
|
||||
);
|
||||
};
|
||||
|
||||
#endif
|
@ -67,6 +67,7 @@ jobject EDIT_FIELD_1_KEY;
|
||||
jobject EDIT_FIELD_2_KEY;
|
||||
jobject CHECKBOX_STATE_KEY;
|
||||
jobject BUTTON_PRESSED_KEY;
|
||||
jobject FINISHED_KEY;
|
||||
jobject TRUE_VALUE;
|
||||
jobject FALSE_VALUE;
|
||||
jobject ONE_VALUE;
|
||||
@ -211,6 +212,12 @@ jboolean util_InitStringConstants()
|
||||
"buttonPressed")))) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
if (nsnull == (FINISHED_KEY =
|
||||
::util_NewGlobalRef(env, (jobject)
|
||||
::util_NewStringUTF(env,
|
||||
"finished")))) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
if (nsnull == (TRUE_VALUE =
|
||||
::util_NewGlobalRef(env, (jobject)
|
||||
::util_NewStringUTF(env, "true")))) {
|
||||
|
@ -82,6 +82,7 @@ extern jobject EDIT_FIELD_1_KEY;
|
||||
extern jobject EDIT_FIELD_2_KEY;
|
||||
extern jobject CHECKBOX_STATE_KEY;
|
||||
extern jobject BUTTON_PRESSED_KEY;
|
||||
extern jobject FINISHED_KEY;
|
||||
extern jobject TRUE_VALUE;
|
||||
extern jobject FALSE_VALUE;
|
||||
extern jobject ONE_VALUE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user