Merging JAVADEV_RTM_20001102 into Trunk

_Ashu
This commit is contained in:
ashuk%eng.sun.com 2001-04-02 21:18:06 +00:00
parent 2045177b94
commit 49ccb36ceb
119 changed files with 8389 additions and 2560 deletions

View File

@ -25,14 +25,16 @@ srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
# PENDING(edburns): make it so it's possible to just build
# webclient and javadom
DIRS= util \
dom \
plugins \
webclient \
$(NULL)
external \
dom
ifeq ($(BUILD_WEBCLIENT_ONLY),)
DIRS += xpcom \
plugins
endif
DIRS += webclient
include $(topsrcdir)/config/rules.mk

View File

@ -40,3 +40,10 @@ JAVAC_PROG = $(JDKHOME)/bin/javac
JAVAC_FLAGS = -classpath $(CLASSPATH):$(JAVA_DESTPATH) -d $(JAVA_DESTPATH)
JAVAC = $(JAVAC_PROG) $(JAVAC_FLAGS)
rm_java:
ifeq ($(PACKAGE_BUILD),)
rm -Rf $(topsrcdir)/dist/classes/org/mozilla/dom
endif # PACKAGE_BUILD
clobber_all::rm_java

View File

@ -33,6 +33,16 @@ JDIRS = org/mozilla/dom \
$(NULL)
rm_java:
ifeq ($(PACKAGE_BUILD),)
rm -Rf $(topsrcdir)/dist/classes/org/mozilla/dom
endif # PACKAGE_BUILD
clobber_all::rm_java
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk

View File

@ -48,7 +48,7 @@ CPPSRCS = \
org_mozilla_dom_TextImpl.cpp \
org_mozilla_dom_events_EventImpl.cpp \
org_mozilla_dom_events_UIEventImpl.cpp \
org_mozilla_dom_events_MouseEventImpl.cpp
org_mozilla_dom_events_MouseEventImpl.cpp
include $(topsrcdir)/config/config.mk
@ -80,5 +80,7 @@ JAVAH_FLAGS=-jni -classpath $(CLASSPATH):$(JAVA_DESTPATH)
export::
$(JAVAH_PROG) $(JAVAH_FLAGS) $(JAVA_CLS)
clobber_all:: clobber
clobber::
rm -f org_*.h

View File

@ -80,5 +80,7 @@ JAVAH_FLAGS=-jni -classpath $(CLASSPATH):$(JAVA_DESTPATH)
export::
$(JAVAH_PROG) $(JAVAH_FLAGS) $(JAVA_CLS)
clobber_all:: clobber
clobber::
rm -f org_*.h

View File

@ -122,6 +122,8 @@ install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
clobber_all:: clobber
clobber::
rm -f $(DIST)\bin\$(DLLNAME).dll
rm -f $(DIST)\lib\$(DLLNAME).lib

View File

@ -79,6 +79,8 @@ install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
clobber_all:: clobber
clobber::
rm -f $(DIST)\bin\components\$(DLLNAME).dll
rm -f $(DIST)\lib\$(DLLNAME).lib

View File

@ -68,19 +68,11 @@ org.mozilla.dom.test.DOMImplementationImpl_createDocument_String_String_Document
org.mozilla.dom.test.DOMImplementationImpl_createDocument_String_String_DocumentType_4
org.mozilla.dom.test.DocumentImpl_createAttribute_String_0
org.mozilla.dom.test.DocumentImpl_createAttribute_String_1
org.mozilla.dom.test.DocumentImpl_createAttributeNS_String_String_0
org.mozilla.dom.test.DocumentImpl_createAttributeNS_String_String_1
org.mozilla.dom.test.DocumentImpl_createAttributeNS_String_String_2
org.mozilla.dom.test.DocumentImpl_createAttributeNS_String_String_3
org.mozilla.dom.test.DocumentImpl_createComment_String_0
org.mozilla.dom.test.DocumentImpl_createComment_String_1
org.mozilla.dom.test.DocumentImpl_createDocumentFragment
org.mozilla.dom.test.DocumentImpl_createElement_String_0
org.mozilla.dom.test.DocumentImpl_createElement_String_1
org.mozilla.dom.test.DocumentImpl_createElement_createElementNS_String_String_0
org.mozilla.dom.test.DocumentImpl_createElement_createElementNS_String_String_1
org.mozilla.dom.test.DocumentImpl_createElement_createElementNS_String_String_2
org.mozilla.dom.test.DocumentImpl_createElement_createElementNS_String_String_3
org.mozilla.dom.test.DocumentImpl_createEvent_String_0
org.mozilla.dom.test.DocumentImpl_createEvent_String_1
org.mozilla.dom.test.DocumentImpl_createEvent_String_2
@ -90,10 +82,6 @@ org.mozilla.dom.test.DocumentImpl_getDoctype
org.mozilla.dom.test.DocumentImpl_getDocumentElement
org.mozilla.dom.test.DocumentImpl_getElementsByTagName_String_0
org.mozilla.dom.test.DocumentImpl_getElementsByTagName_String_1
org.mozilla.dom.test.DocumentImpl_getElementsByTagNameNS_String_String_0
org.mozilla.dom.test.DocumentImpl_getElementsByTagNameNS_String_String_1
org.mozilla.dom.test.DocumentImpl_getElementsByTagNameNS_String_String_2
org.mozilla.dom.test.DocumentImpl_getElementsByTagNameNS_String_String_3
org.mozilla.dom.test.DocumentImpl_getElementById_String_0
org.mozilla.dom.test.DocumentImpl_getElementById_String_1
org.mozilla.dom.test.DocumentImpl_getElementById_String_2
@ -106,76 +94,34 @@ org.mozilla.dom.test.ElementImpl_getAttributeNode_String_0
org.mozilla.dom.test.ElementImpl_getAttributeNode_String_1
org.mozilla.dom.test.ElementImpl_getAttribute_String_0
org.mozilla.dom.test.ElementImpl_getAttribute_String_1
org.mozilla.dom.test.ElementImpl_getAttributeNS_String_String_0
org.mozilla.dom.test.ElementImpl_getAttributeNS_String_String_1
org.mozilla.dom.test.ElementImpl_getAttributeNS_String_String_2
org.mozilla.dom.test.ElementImpl_getAttributeNS_String_String_3
org.mozilla.dom.test.ElementImpl_getAttributeNodeNS_String_String_0
org.mozilla.dom.test.ElementImpl_getAttributeNodeNS_String_String_1
org.mozilla.dom.test.ElementImpl_getAttributeNodeNS_String_String_2
org.mozilla.dom.test.ElementImpl_getAttributeNodeNS_String_String_3
org.mozilla.dom.test.ElementImpl_getElementsByTagName_String_0
org.mozilla.dom.test.ElementImpl_getElementsByTagName_String_1
org.mozilla.dom.test.ElementImpl_getElementsByTagNameNS_String_String_0
org.mozilla.dom.test.ElementImpl_getElementsByTagNameNS_String_String_1
org.mozilla.dom.test.ElementImpl_getElementsByTagNameNS_String_String_2
org.mozilla.dom.test.ElementImpl_getElementsByTagNameNS_String_String_3
org.mozilla.dom.test.ElementImpl_getTagName
org.mozilla.dom.test.ElementImpl_hasAttribute_String_0
org.mozilla.dom.test.ElementImpl_hasAttribute_String_1
org.mozilla.dom.test.ElementImpl_hasAttributeNS_String_String_0
org.mozilla.dom.test.ElementImpl_hasAttributeNS_String_String_1
org.mozilla.dom.test.ElementImpl_hasAttributeNS_String_String_2
org.mozilla.dom.test.ElementImpl_hasAttributeNS_String_String_3
org.mozilla.dom.test.ElementImpl_normalize
org.mozilla.dom.test.ElementImpl_removeAttributeNode_Attr_0
org.mozilla.dom.test.ElementImpl_removeAttributeNode_Attr_1
org.mozilla.dom.test.ElementImpl_removeAttribute_String_0
org.mozilla.dom.test.ElementImpl_removeAttribute_String_1
org.mozilla.dom.test.ElementImpl_removeAttributeNS_String_String_0
org.mozilla.dom.test.ElementImpl_removeAttributeNS_String_String_1
org.mozilla.dom.test.ElementImpl_removeAttributeNS_String_String_2
org.mozilla.dom.test.ElementImpl_removeAttributeNS_String_String_3
org.mozilla.dom.test.ElementImpl_setAttributeNode_Attr_0
org.mozilla.dom.test.ElementImpl_setAttributeNode_Attr_1
org.mozilla.dom.test.ElementImpl_setAttributeNode_Attr_2
org.mozilla.dom.test.ElementImpl_setAttributeNodeNS_Attr_0
org.mozilla.dom.test.ElementImpl_setAttributeNodeNS_Attr_1
org.mozilla.dom.test.ElementImpl_setAttribute_String_String_0
org.mozilla.dom.test.ElementImpl_setAttribute_String_String_1
org.mozilla.dom.test.ElementImpl_setAttribute_String_String_2
org.mozilla.dom.test.ElementImpl_setAttribute_String_String_3
org.mozilla.dom.test.ElementImpl_setAttributeNS_String_String_String_0
org.mozilla.dom.test.ElementImpl_setAttributeNS_String_String_String_1
org.mozilla.dom.test.ElementImpl_setAttributeNS_String_String_String_2
org.mozilla.dom.test.ElementImpl_setAttributeNS_String_String_String_3
org.mozilla.dom.test.ElementImpl_setAttributeNS_String_String_String_4
org.mozilla.dom.test.ElementImpl_setAttributeNS_String_String_String_5
org.mozilla.dom.test.ElementImpl_setAttributeNS_String_String_String_6
org.mozilla.dom.test.ElementImpl_setAttributeNS_String_String_String_7
org.mozilla.dom.test.ElementImpl_setAttributeNS_String_String_String_8
org.mozilla.dom.test.ElementImpl_setAttributeNS_String_String_String_9
org.mozilla.dom.test.NamedNodeMapImpl_getLength
org.mozilla.dom.test.NamedNodeMapImpl_getNamedItem_String_0
org.mozilla.dom.test.NamedNodeMapImpl_getNamedItem_String_1
org.mozilla.dom.test.NamedNodeMapImpl_getNamedItemNS_String_String_0
org.mozilla.dom.test.NamedNodeMapImpl_getNamedItemNS_String_String_1
org.mozilla.dom.test.NamedNodeMapImpl_getNamedItemNS_String_String_2
org.mozilla.dom.test.NamedNodeMapImpl_getNamedItemNS_String_String_3
org.mozilla.dom.test.NamedNodeMapImpl_item_int_0
org.mozilla.dom.test.NamedNodeMapImpl_item_int_1
org.mozilla.dom.test.NamedNodeMapImpl_item_int_2
org.mozilla.dom.test.NamedNodeMapImpl_removeNamedItem_String_0
org.mozilla.dom.test.NamedNodeMapImpl_removeNamedItem_String_1
org.mozilla.dom.test.NamedNodeMapImpl_removeNamedItemNS_String_String_0
org.mozilla.dom.test.NamedNodeMapImpl_removeNamedItemNS_String_String_1
org.mozilla.dom.test.NamedNodeMapImpl_removeNamedItemNS_String_String_2
org.mozilla.dom.test.NamedNodeMapImpl_removeNamedItemNS_String_String_3
org.mozilla.dom.test.NamedNodeMapImpl_setNamedItem_Node_0
org.mozilla.dom.test.NamedNodeMapImpl_setNamedItem_Node_1
org.mozilla.dom.test.NamedNodeMapImpl_setNamedItem_Node_2
org.mozilla.dom.test.NamedNodeMapImpl_setNamedItemNS_Node_0
org.mozilla.dom.test.NamedNodeMapImpl_setNamedItemNS_Node_1
org.mozilla.dom.test.NodeImpl_appendChild_Node_0
org.mozilla.dom.test.NodeImpl_appendChild_Node_1
org.mozilla.dom.test.NodeImpl_cloneNode_boolean_0

View File

@ -109,4 +109,13 @@ org.mozilla.dom.test.NodeImpl_supports_String_String_0
org.mozilla.dom.test.NodeImpl_supports_String_String_1
org.mozilla.dom.test.NodeImpl_supports_String_String_2
org.mozilla.dom.test.NodeImpl_supports_String_String_3
org.mozilla.dom.test.NamedNodeMapImpl_getNamedItemNS_String_String_0
org.mozilla.dom.test.NamedNodeMapImpl_getNamedItemNS_String_String_1
org.mozilla.dom.test.NamedNodeMapImpl_getNamedItemNS_String_String_2
org.mozilla.dom.test.NamedNodeMapImpl_getNamedItemNS_String_String_3
org.mozilla.dom.test.NamedNodeMapImpl_removeNamedItemNS_String_String_0
org.mozilla.dom.test.NamedNodeMapImpl_removeNamedItemNS_String_String_1
org.mozilla.dom.test.NamedNodeMapImpl_removeNamedItemNS_String_String_2
org.mozilla.dom.test.NamedNodeMapImpl_removeNamedItemNS_String_String_3
org.mozilla.dom.test.NamedNodeMapImpl_setNamedItemNS_Node_0
org.mozilla.dom.test.NamedNodeMapImpl_setNamedItemNS_Node_1

View File

@ -83,12 +83,10 @@ public class DocumentImpl_createEvent_String_1 extends BWBaseTest implements Exe
if (d != null)
{
try {
Event me = d.createEvent("MouseEvent");
Event ke = d.createEvent("KeyEvent");
Event he = d.createEvent("HTMLEvent");
if (me == null || ke == null || he == null) {
Event me = d.createEvent("UIEvents");
if (me == null) {
TestLoader.logErrPrint("DocumentEvent returned null ...");
System.out.println("DocumentEvent returned null: me="+me+" ke="+ke+" he="+he);
//System.out.println("DocumentEvent returned null: me="+me+" ke="+ke+" he="+he);
return BWBaseTest.FAILED;
}
} catch (Exception e) {

View File

@ -86,13 +86,26 @@ public class ElementImpl_getAttributeNS_String_String_0 extends BWBaseTest imple
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String nuri = "xmlns:edi='http://ecommerce.com/schema'";
String lname = "dummyattr";
String val = "1";
e.setAttributeNS(nuri, lname, val);
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String lname = "myattr";
String retval = "ATTRVAL";
String s = e.getAttributeNS(nuri, lname);
if (s == null || !s.equals(val)) {
TestLoader.logErrPrint("Element 'getAttributeNS' returned incorrect value: "+s+" != "+val);
if (s == null) {
TestLoader.logErrPrint("Element 'getAttributeNS' returned null instad of " + retval);
return BWBaseTest.FAILED;
}
if (!s.equals(retval)) {
TestLoader.logErrPrint("Element 'getAttributeNS' returned incorrect value: "+s+" != "+ retval);
return BWBaseTest.FAILED;
}
}

View File

@ -86,10 +86,19 @@ public class ElementImpl_getAttributeNS_String_String_1 extends BWBaseTest imple
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = "dummyattr";
String lname = "myattr";
String s = e.getAttributeNS(nuri, lname);
TestLoader.logErrPrint("Element 'getAttributeNS' didn't throw exception");
TestLoader.logErrPrint("Element 'getAttributeNS' didn't throw exception for null URI");
return BWBaseTest.FAILED;
}
} catch (Exception e) {

View File

@ -86,10 +86,19 @@ public class ElementImpl_getAttributeNS_String_String_2 extends BWBaseTest imple
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String nuri = "xmlns:edi='http://ec.com/schema'";
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String lname = null;
String s = e.getAttributeNS(nuri, lname);
TestLoader.logErrPrint("Element 'getAttributeNS' didn't throw exception ");
TestLoader.logErrPrint("Element 'getAttributeNS' did not throw Exception for localname set to null");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -86,6 +86,15 @@ public class ElementImpl_getAttributeNS_String_String_3 extends BWBaseTest imple
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = null;
String s = e.getAttributeNS(nuri, lname);

View File

@ -86,10 +86,19 @@ public class ElementImpl_getAttributeNodeNS_String_String_0 extends BWBaseTest i
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = null;
Node n = e.getAttributeNodeNS(nuri, lname);
TestLoader.logErrPrint("Element 'getAttributeNodeNS' didn't throw exception... ");
TestLoader.logErrPrint("Element 'getAttributeNodeNS' didn't throw exception for URI set to null and local name set to null... ");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -86,10 +86,19 @@ public class ElementImpl_getAttributeNodeNS_String_String_1 extends BWBaseTest i
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = "dummyattr";
String lname = "myattr";
Node n = e.getAttributeNodeNS(nuri, lname);
TestLoader.logErrPrint("Element 'getAttributeNodeNS' didn't throw exception... ");
TestLoader.logErrPrint("Element 'getAttributeNodeNS' didn't throw exception for URI set to null... ");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -86,10 +86,19 @@ public class ElementImpl_getAttributeNodeNS_String_String_2 extends BWBaseTest i
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String nuri = "";
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String lname = null;
Node n = e.getAttributeNodeNS(nuri, lname);
TestLoader.logErrPrint("Element 'getAttributeNodeNS' didn't throw exception... ");
TestLoader.logErrPrint("Element 'getAttributeNodeNS' didn't throw exception for local name set to null... ");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -86,13 +86,26 @@ public class ElementImpl_getAttributeNodeNS_String_String_3 extends BWBaseTest i
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String nuri = "xmlns:edi='http://ecommerce.org/schema'";
String lname = "dummyattr";
String val = "1";
e.setAttributeNS(nuri, lname, val);
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String lname = "myattr";
String val = "ATTRVAL";
Node n = e.getAttributeNodeNS(nuri, lname);
if (n == null || n.getNodeType() != Node.ATTRIBUTE_NODE || !((Attr)n).getValue().equals(val)) {
TestLoader.logErrPrint("Element 'getAttributeNS' returned incorrect value ");
if (n == null)
{
TestLoader.logErrPrint("Element 'getAttributeNS' returned null value instead of " + val);
return BWBaseTest.FAILED;
}
if (n.getNodeType() != Node.ATTRIBUTE_NODE || !((Attr)n).getValue().equals(val)) {
TestLoader.logErrPrint("Element 'getAttributeNS' returned value " + ((Attr)n).getValue() + " instead of " + val);
return BWBaseTest.FAILED;
}
}

View File

@ -86,10 +86,19 @@ public class ElementImpl_getElementsByTagNameNS_String_String_0 extends BWBaseTe
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = null;
NodeList nl = e.getElementsByTagNameNS(nuri, lname);
TestLoader.logErrPrint("Element 'getElementsByTagNameNS' didn't throw exception... ");
nl = e.getElementsByTagNameNS(nuri, lname);
TestLoader.logErrPrint("Element 'getElementsByTagNameNS' didn't throw exception for URI set to null and localname set to null... ");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -86,10 +86,19 @@ public class ElementImpl_getElementsByTagNameNS_String_String_1 extends BWBaseTe
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = "dummyattr";
NodeList nl = e.getElementsByTagNameNS(nuri, lname);
TestLoader.logErrPrint("Element 'getElementsByTagNameNS' didn't throw exception... ");
String lname = "myattr";
nl = e.getElementsByTagNameNS(nuri, lname);
TestLoader.logErrPrint("Element 'getElementsByTagNameNS' didn't throw exception for URI set to null and localname set to myattr... ");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -86,10 +86,19 @@ public class ElementImpl_getElementsByTagNameNS_String_String_2 extends BWBaseTe
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String nuri = "";
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String lname = null;
NodeList nl = e.getElementsByTagNameNS(nuri, lname);
TestLoader.logErrPrint("Element 'getElementsByTagNameNS' didn't throw exception... ");
nl = e.getElementsByTagNameNS(nuri, lname);
TestLoader.logErrPrint("Element 'getElementsByTagNameNS' didn't throw exception for localname set to null... ");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -86,9 +86,18 @@ public class ElementImpl_getElementsByTagNameNS_String_String_3 extends BWBaseTe
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String nuri = "xmlns:edi='http://ecommerce.org/schema'";
String lname = "body";
NodeList nl = e.getElementsByTagNameNS(nuri, lname);
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String lname = "myattr";
nl = e.getElementsByTagNameNS(nuri, lname);
if (nl == null) {
TestLoader.logErrPrint("Element 'getElementsByTagNameNS' returned incorrect value ");
return BWBaseTest.FAILED;
@ -128,4 +137,4 @@ public class ElementImpl_getElementsByTagNameNS_String_String_3 extends BWBaseTe
else {}
}
}

View File

@ -85,8 +85,17 @@ public class ElementImpl_hasAttributeNS_String_String_0 extends BWBaseTest imple
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
}
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
if (e.hasAttributeNS(null, null)) ;
TestLoader.logErrPrint("Element 'hasAttributeNS didn't throw exception... ");
TestLoader.logErrPrint("Element 'hasAttributeNS didn't throw exception for URI set to null and localname set to null... ");
return BWBaseTest.FAILED;
} catch (Exception r) {
String msg = "Caught Exception " + r ;

View File

@ -85,8 +85,17 @@ public class ElementImpl_hasAttributeNS_String_String_1 extends BWBaseTest imple
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
}
if (e.hasAttributeNS("dummy", null));
TestLoader.logErrPrint("Element 'hasAttributeNS didn't throw exception... ");
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
if (e.hasAttributeNS("http://www.foo.org/", null));
TestLoader.logErrPrint("Element 'hasAttributeNS didn't throw exception for localname set to null... ");
return BWBaseTest.FAILED;
} catch (Exception r) {
String msg = "Caught Exception " + r ;

View File

@ -85,8 +85,17 @@ public class ElementImpl_hasAttributeNS_String_String_2 extends BWBaseTest imple
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
}
if (e.hasAttributeNS(null, "dummy"));
TestLoader.logErrPrint("Element 'hasAttributeNS didn't throw exception... ");
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
if (e.hasAttributeNS(null, "myattr"));
TestLoader.logErrPrint("Element 'hasAttributeNS didn't throw exception for URI set to null... ");
return BWBaseTest.FAILED;
} catch (Exception r) {
String msg = "Caught Exception " + r ;

View File

@ -85,12 +85,19 @@ public class ElementImpl_hasAttributeNS_String_String_3 extends BWBaseTest imple
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
}
String nsuri = "xmlns:edi='http://ec.com/schema'";
String lname = "dummyattr";
String val = "1";
e.setAttributeNS(nsuri, lname, val);
if (e.hasAttributeNS(nsuri, val) == false) {
TestLoader.logErrPrint("Element 'hasAttributeNS returned incorrect value... ");
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nsuri = "http://www.foo.org/";
String lname = "myattr";
if (!(e.hasAttributeNS(nsuri, lname))) {
TestLoader.logErrPrint("Element 'hasAttributeNS returned false instead of true... ");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -86,10 +86,19 @@ public class ElementImpl_removeAttributeNS_String_String_0 extends BWBaseTest im
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = null;
e.removeAttributeNS(nuri, lname);
TestLoader.logErrPrint("Element 'removeAttributeNS' didn't throw exception... ");
TestLoader.logErrPrint("Element 'removeAttributeNS' didn't throw exception for URI set to null and lname set to null... ");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -86,10 +86,19 @@ public class ElementImpl_removeAttributeNS_String_String_1 extends BWBaseTest im
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = "dummyattr";
String lname = "myattr";
e.removeAttributeNS(nuri, lname);
TestLoader.logErrPrint("Element 'removeAttributeNS' didn't throw exception... ");
TestLoader.logErrPrint("Element 'removeAttributeNS' didn't throw exception for URI set to null... ");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -86,10 +86,19 @@ public class ElementImpl_removeAttributeNS_String_String_2 extends BWBaseTest im
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String nuri = "";
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String lname = null;
e.removeAttributeNS(nuri, lname);
TestLoader.logErrPrint("Element 'removeAttributeNS' didn't throw exception... ");
TestLoader.logErrPrint("Element 'removeAttributeNS' didn't throw exception for localname set to null... ");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -86,10 +86,27 @@ public class ElementImpl_removeAttributeNS_String_String_3 extends BWBaseTest im
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String nuri = "xmlns:edi='http://ecommerce.org/schema'";
String lname = "dummyattr";
e.setAttributeNS(nuri, lname, "1");
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String lname = "myattr";
String retval= "ATTRVAL";
e.removeAttributeNS(nuri, lname);
String s = e.getAttributeNS(nuri, lname);
if ((s == null) || !(s.equals("")))
{
TestLoader.logErrPrint("Element 'removeAttributeNS' failedto remove attribute myattr ");
return BWBaseTest.FAILED;
}
}
} catch (Exception r) {
String msg = "Caught Exception " + r ;

View File

@ -87,11 +87,20 @@ public class ElementImpl_setAttributeNS_String_String_String_0 extends BWBaseTes
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = null;
String qname = null;
String val = null;
e.setAttributeNS(nuri, lname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception ...");
e.setAttributeNS(nuri, qname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception for URI set to NULL and qualified name set to null ...");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -87,11 +87,20 @@ public class ElementImpl_setAttributeNS_String_String_String_1 extends BWBaseTes
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = null;
String val = "1";
e.setAttributeNS(nuri, lname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception ...");
String qname = null;
String val = "MYVAL";
e.setAttributeNS(nuri, qname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception for URI set to null and qualifiedname set to null ...");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -87,11 +87,20 @@ public class ElementImpl_setAttributeNS_String_String_String_2 extends BWBaseTes
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = "dummyattr";
String qname = "foo:myattr";
String val = null;
e.setAttributeNS(nuri, lname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception ...");
e.setAttributeNS(nuri, qname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception for URI set to null and qualifiedname set to foo:myattr...");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -87,11 +87,20 @@ public class ElementImpl_setAttributeNS_String_String_String_3 extends BWBaseTes
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = "dummyattr";
String val = "1";
e.setAttributeNS(nuri, lname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception ...");
String qname = "foo:myattr";
String val = "ATTRVAL";
e.setAttributeNS(nuri, qname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception for URI set to NULL and qualifiedname set to foo:myattr...");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -87,11 +87,20 @@ public class ElementImpl_setAttributeNS_String_String_String_4 extends BWBaseTes
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = "dummyattr";
String qname = "foo:myattr";
String val = null;
e.setAttributeNS(nuri, lname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception ...");
e.setAttributeNS(nuri, qname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception for URI set to null and qualifiedname set to foo:myattr...");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -87,11 +87,20 @@ public class ElementImpl_setAttributeNS_String_String_String_5 extends BWBaseTes
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = null;
String lname = "dummyattr";
String val = "1";
e.setAttributeNS(nuri, lname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception ...");
String qname = "foo:myattr";
String val = "ATTRVAL";
e.setAttributeNS(nuri, qname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception for URI=null Qualifiedname=foo:myattr Value=ATTRVAL...");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -87,11 +87,20 @@ public class ElementImpl_setAttributeNS_String_String_String_6 extends BWBaseTes
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String nuri = "xmlns:edi='http://ecommerce.org/schema'";
String lname = null;
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String qname = null;
String val = null;
e.setAttributeNS(nuri, lname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception ...");
e.setAttributeNS(nuri, qname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception for qualifiedname=null and Value=null ...");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -87,11 +87,20 @@ public class ElementImpl_setAttributeNS_String_String_String_7 extends BWBaseTes
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String nuri = "xmlns:edi='http://ecommerce.org/schema'";
String lname = null;
String val = "1";
e.setAttributeNS(nuri, lname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception ...");
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String qname = null;
String val = "MYVAL";
e.setAttributeNS(nuri, qname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception for QualifiedName=null and val=MYVAL...");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -87,11 +87,20 @@ public class ElementImpl_setAttributeNS_String_String_String_8 extends BWBaseTes
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String nuri = "xmlns:edi='http://ecommerce.org/schema'";
String lname = "dummyattr";
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String qname = "foo:myattr";
String val = null;
e.setAttributeNS(nuri, lname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception ...");
e.setAttributeNS(nuri, qname, val);
TestLoader.logErrPrint("setAttributeNS didn't throw exception for value=Null...");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -87,13 +87,28 @@ public class ElementImpl_setAttributeNS_String_String_String_9 extends BWBaseTes
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String nuri = "xmlns:edi='http://ecommerce.org/schema'";
String lname = "dummyattr";
String val = "1";
e.setAttributeNS(nuri, lname, val);
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String qname = "foo:myattr";
String lname = "myattr";
String val = "MYVAL";
e.setAttributeNS(nuri, qname, val);
String s = e.getAttributeNS(nuri, lname);
if (s == null || !s.equals(val)) {
TestLoader.logErrPrint("'setAttributeNS' didn't set attribute correctly");
if (s == null) {
TestLoader.logErrPrint("'setAttributeNS' returned null attirbute value");
return BWBaseTest.FAILED;
}
if (!s.equals(val)) {
TestLoader.logErrPrint("'setAttributeNS' set attribute to " + s + " instead of " + val);
return BWBaseTest.FAILED;
}
}

View File

@ -87,8 +87,17 @@ public class ElementImpl_setAttributeNodeNS_Attr_0 extends BWBaseTest implements
TestLoader.logErrPrint("Document Element is NULL..");
return BWBaseTest.FAILED;
} else {
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
Attr anode = e.setAttributeNodeNS(null);
TestLoader.logErrPrint("Document setAttributeNodeNS didn't throw exception...");
TestLoader.logErrPrint("Document setAttributeNodeNS didn't throw exception for null attribute...");
return BWBaseTest.FAILED;
}
} catch (Exception r) {

View File

@ -82,23 +82,26 @@ public class ElementImpl_setAttributeNodeNS_Attr_1 extends BWBaseTest implements
if (d != null)
{
try {
Element e = d.getDocumentElement();
String nuri = "xmlns:edi='http://ecommerce.org/schema'";
String lname = "dummyattr";
String val = "1";
Attr a = d.createAttribute(lname);
a.setValue(val);
if (e == null || a == null) {
TestLoader.logErrPrint("Document Element is NULL or can't create new attribute..");
return BWBaseTest.FAILED;
} else {
e.setAttributeNodeNS(a);
Node n = e.getAttributeNodeNS(nuri, lname);
if (n == null || n.getNodeType() != Node.ATTRIBUTE_NODE || !((Attr)n).getValue().equals(val)) {
TestLoader.logErrPrint("Element 'getAttributeNS' returned incorrect value ");
Element e = d.getDocumentElement();
String uri = "http://www.foo.org/";
String name = "*";
NodeList nl = e.getElementsByTagNameNS(uri, name);
if (nl != null) {
Node n = (Node)nl.item(0);
e = (Element)n;
}
String nuri = "http://www.foo.org/";
String lname = "myattr";
String val = "ATTRVAL";
Attr getattr = e.getAttributeNodeNS(nuri, lname);
Attr retattr = (Attr)e.setAttributeNodeNS(getattr);
if (retattr != null)
{
TestLoader.logErrPrint("Element 'getAttributeNS' did not return null for an already existing Attribute myattr ");
return BWBaseTest.FAILED;
}
}
} catch (Exception r) {
String msg = "Caught Exception " + r ;
TestLoader.logErrPrint(msg);

View File

@ -68,7 +68,7 @@ title()
echo "################################################"
echo
echo "NOTE: You need to copy files test.html and"
echo " testxml.html to DOCUMENT_ROOT dir. of"
echo " test.xml to DOCUMENT_ROOT dir. of"
echo " your Web-Server on this machine."
echo
echo
@ -138,14 +138,14 @@ checkRun()
##################################################################
#
# check Document Root and check if files test.html and testxml.html
# check Document Root and check if files test.html and test.xml
# exists in thos directories
#
##################################################################
#checkDocRoot()
#{
# echo
#echo "You need to copy files test.html and testxml.html to your DOCUMENT_ROOT"
#echo "You need to copy files test.html and test.xml to your DOCUMENT_ROOT"
#echo "of your Web-Server"
#echo
#echo "This test assumes that you have set up you WebServer and copied the"
@ -172,7 +172,7 @@ checkRun()
#
#
#echo
#echo "Checking if the files test.html and testxml.html exists in DOCUMENT_ROOT..."
#echo "Checking if the files test.html and test.xml exists in DOCUMENT_ROOT..."
#if [ ! -f "$docroot/test.html"
#then
# echo "Could not find 'test.html' in DOCUMENT_ROOT directory"
@ -181,10 +181,10 @@ checkRun()
# exit 1
#fi
#
#if [ ! -f "$docroot/testxml.html" ]
#if [ ! -f "$docroot/test.xml" ]
#then
# echo "Could not find 'testxml.html' in DOCUMENT_ROOT directory"
# echo "Please copy testxml.html to DOCUMENT_ROOT and rerun this script"
# echo "Could not find 'test.xml' in DOCUMENT_ROOT directory"
# echo "Please copy test.xml to DOCUMENT_ROOT and rerun this script"
# echo
# exit 1
#fi
@ -311,7 +311,7 @@ constructLogFooter()
##################################################################
#
# check Document Root and check if files test.html and testxml.html
# check Document Root and check if files test.html and test.xml
# exists in thos directories
#
##################################################################
@ -492,10 +492,10 @@ fi
if [ "$runtype" = "2" ]
then
DOCFILE="$DOCROOT/testxml.html"
DOCFILE="$DOCROOT/test.xml"
if [ -z "$appreg" ]
then
DOCFILE="$DOCROOT/testxml.html";
DOCFILE="$DOCROOT/test.xml";
else
DOCFILE="$DOCROOT/TestLoaderXML.html";
fi
@ -641,7 +641,7 @@ do
if [ "$runtype" = "3" ]
then
DOCFILE="$DOCROOT/testxml.html"
DOCFILE="$DOCROOT/test.xml"
filename="$curdir/BWTestClass.lst.xml.ORIG"
constructHTML
appendEntries

View File

@ -1,29 +1,17 @@
<?xml version="1.0"?>
<!DOCTYPE html [
<!ENTITY Myimage SYSTEM "Image.gif" NDATA GIF>
<!NOTATION GIF SYSTEM "/usr/dist/local/exe/xv">
<!ELEMENT head (title, script, base)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT script (#PCDATA)>
<!ELEMENT base EMPTY>
<!ATTLIST base
target CDATA #IMPLIED>
<!ELEMENT body (#PCDATA)>
<!ATTLIST body
name CDATA #IMPLIED
id CDATA #IMPLIED
bgcolor CDATA #IMPLIED >
<!ENTITY myentity "New Entity">
]>
<html>
<body name="hello_body" id="body_tag_id">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>Virtual Library</title>
</head>
<body name="hello_body">
<EMBED type="application/dom-pluglet" width="0" height="0">
</EMBED>
Hello
<foo:mytag foo:myattr="ATTRVAL" foo:coredom="LEVEL2" xmlns:foo="http://www.foo.org/">
</foo:mytag>
</body>
</html>

View File

@ -32,6 +32,16 @@ DIRS= \
classes \
$(NULL)
rm_java:
ifeq ($(PACKAGE_BUILD),)
rm -Rf $(topsrcdir)/dist/classes/org/mozilla/util
endif # PACKAGE_BUILD
clobber_all::rm_java
include $(topsrcdir)/config/rules.mk

View File

@ -64,13 +64,44 @@ PACKAGE_DIR=$(topsrcdir)/dist/javadev
PACKAGE_LIB=$(PACKAGE_DIR)/lib
endif # PACKAGE_BUILD
ifneq ($(WEBCLIENT_PACKAGE_BUILD),)
PACKAGE_VER = 1_0
PACKAGE_DIR = $(DIST)/javadev
PACKAGE_LIB = $(PACKAGE_DIR)/lib
PACKAGE_EXAMPLE = $(PACKAGE_DIR)/example
endif # WEBCLIENT_PACKAGE_BUILD
JAVA_SOURCEPATH=$(topsrcdir)/java/webclient/classes_spec
JAVAC_FLAGS=-classpath $(CLASSPATH):$(JAVA_DESTPATH) -d $(JAVA_DESTPATH)
rm_java:
ifeq ($(PACKAGE_BUILD),)
rm -Rf $(topsrcdir)/dist/classes/org/mozilla/webclient
else
rm -Rf $(topsrcdir)/dist/javadev
endif # PACKAGE_BUILD
ifneq ($(WEBCLIENT_PACKAGE_BUILD),)
rm -Rf $(topsrcdir)/dist/javadev
endif
clobber_all::rm_java
install:: jarEmUp
jarEmUp:
ifneq ($(WEBCLIENT_PACKAGE_BUILD),)
if test ! -d $(PACKAGE_DIR) ; then mkdir $(PACKAGE_DIR) ; else true ; fi ;
if test ! -d $(PACKAGE_LIB) ; then mkdir $(PACKAGE_LIB) ; else true ; fi ;
if test ! -d $(PACKAGE_LIB)/webclient_$(PACKAGE_VER).jar ; then rm -f $(PACKAGE_LIB)/webclient_$(PACKAGE_VER).jar ; else true ; fi ;
if test ! -d $(PACKAGE_LIB)/webclient.jar ; then rm -f $(PACKAGE_LIB)/webclient.jar ; else true ; fi ;
cd $(topsrcdir)/dist/classes ; \
jar -cvfM0 webclient_$(PACKAGE_VER).jar org ; \
mv webclient_$(PACKAGE_VER).jar ../javadev/lib ;
cd $(topsrcdir)/dist/javadev/lib ; \
ln -s webclient_$(PACKAGE_VER).jar $(PACKAGE_LIB)/webclient.jar ;
endif
ifneq ($(PACKAGE_BUILD),)
if test ! -d $(PACKAGE_DIR) ; then mkdir $(PACKAGE_DIR) ; else true ; fi ;
if test ! -d $(PACKAGE_LIB) ; then mkdir $(PACKAGE_LIB) ; else true ; fi ;

View File

@ -23,6 +23,8 @@ IGNORE_MANIFEST=1
#//------------------------------------------------------------------------
#//
#// Makefile to build the java portion of the java wrapper to mozilla
#// Assumes that all necesssary classes for webclient have already been
#// compiled into $(DIST)\classes
#//
#//------------------------------------------------------------------------
@ -57,7 +59,13 @@ JAR_WEBCLIENT_CLASSES = \
JDIRS = $(JAR_WEBCLIENT_CLASSES)
!endif
WEBCLIENT_JAR_NAME=webclient(VERSION_NUMBER).jar
!ifdef PACKAGE_BUILD
PACKAGE_VER = 1_0
#PENDING(edburns): jar name should be defined elewhere!
WEBCLIENT_JAR_NAME=webclient_$(PACKAGE_VER).jar
PACKAGE_DIR = $(DIST)\javadev
PACKAGE_LIB = $(PACKAGE_DIR)\lib
!endif
JAVAC_PROG=$(JDKHOME)\bin\javac
@ -81,3 +89,19 @@ JAVAC_CLASSPATH=$(JAVAC_CLASSPATH);$(CLASSPATH)
include <$(DEPTH)\config\javarules.mak>
include <$(DEPTH)\config\rules.mak>
install:: jarEmUp
jarEmup:
!ifdef PACKAGE_BUILD
-mkdir $(DIST)\javadev
chmod 775 $(DIST)\javadev
-mkdir $(DIST)\javadev\lib
chmod 775 $(DIST)\javadev\lib
rm -f $(PACKAGE_LIB)\$(WEBCLIENT_JAR_NAME)
jar -cvfM0 $(PACKAGE_LIB)\$(WEBCLIENT_JAR_NAME) -C $(DIST)\..\classes org
!endif
clobber_all::
!ifdef PACKAGE_BUILD
rm -f $(PACKAGE_LIB)\$(WEBCLIENT_JAR_NAME)
!endif

View File

@ -40,6 +40,7 @@ public final static String LAST_VISIT_DATE = "LastVisitDate";
public final static String NAME = "Name";
public final static String URL = "URL";
public final static String DESCRIPTION = "Description";
public final static String IS_FOLDER = "IsFolder";
public Properties getProperties();

View File

@ -70,6 +70,7 @@ private WindowControl windowControl = null;
private Navigation navigation = null;
private History history = null;
private static Bookmarks bookmarks = null;
private static Preferences prefs = null;
//
// Constructors and Initializers
@ -126,8 +127,8 @@ void delete()
((ImplObject)windowControl).delete();
windowControl = null;
// since bookmarks is static, we must not deallocate it here. That
// is done in the static method appTerminate
// since bookmarks and prefs are static, we must not deallocate them
// here. That is done in the static method appTerminate
}
@ -152,6 +153,10 @@ static void appTerminate() throws Exception
((ImplObject)bookmarks).delete();
bookmarks = null;
}
if (null != prefs) {
((ImplObject)prefs).delete();
prefs = null;
}
wrapperFactory.terminate();
}
@ -269,6 +274,13 @@ public Object queryInterface(String interfaceName) throws ClassNotFoundException
}
return bookmarks;
}
if (PREFERENCES_NAME.equals(interfaceName)) {
if (null == prefs) {
prefs = (Preferences)
wrapperFactory.newImpl(PREFERENCES_NAME, this);
}
return prefs;
}
// extensibility mechanism: just see if wrapperFactory can make one!
return wrapperFactory.newImpl(interfaceName, this);
}
@ -284,7 +296,7 @@ public static void main(String [] args)
Assert.setEnabled(true);
Log.setApplicationName("BrowserControlImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.3 2000/07/22 02:48:23 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.4 2001/04/02 21:13:43 ashuk%eng.sun.com Exp $");
}

View File

@ -87,7 +87,7 @@ public void copyCurrentSelectionToSystemClipboard();
public void findInPage(String stringToFind, boolean forward, boolean matchCase);
public void findNextInPage(boolean forward);
public void findNextInPage();
public String getCurrentURL();
@ -97,7 +97,7 @@ public Properties getPageInfo();
public String getSource();
public byte [] getSourceBytes(boolean viewMode);
public byte [] getSourceBytes();
public void resetFind();

View File

@ -27,6 +27,9 @@
package org.mozilla.webclient;
import java.io.InputStream;
import java.util.Properties;
public interface Navigation
{
@ -40,8 +43,22 @@ public static int LOAD_NORMAL = 0;
public static int LOAD_FORCE_RELOAD = 1 << 9;
public void loadURL(String absoluteURL);
public void loadFromStream(InputStream stream, String uri,
String contentType, int contentLength,
Properties loadInfo);
public void refresh(long loadFlags);
public void stop();
/**
* Gives this Navigation instance the ability to call back the custom
* app when a site with basic authentication, cookies, etc, is
* encountered. The custom app can choose to put up appropriate modal
* UI.
*/
public void setPrompt(Prompt yourPrompt);
}
// end of interface CurrentPage

View File

@ -0,0 +1,30 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ed Burns <edburns@acm.org>
*/
package org.mozilla.webclient;
public interface PrefChangedCallback
{
public int prefChanged(String prefName, Object closure);
}
// end of interface PrefChangedCallback

View File

@ -0,0 +1,35 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ed Burns <edburns@acm.org>
*/
package org.mozilla.webclient;
import java.util.Properties;
public interface Preferences
{
public void setPref(String prefName, String prefValue);
public Properties getPrefs();
public void registerPrefChangedCallback(PrefChangedCallback cb,
String prefName, Object closure);
}
// end of interface Preferences

View File

@ -0,0 +1,136 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ed Burns <edburns@acm.org>
*/
package org.mozilla.webclient;
import java.util.Properties;
/**
* The custom app must implement this interface in order to supply the
* underlying browser with basic authentication behavior. The custom
* app must tell webclient about its Prompt implementation by calling
* Navigation.setPrompt(). This must be done FOR EACH BrowserControl
* instance!
*/
public interface Prompt
{
public static final String USER_NAME_KEY = "userName";
public static final String PASSWORD_KEY = "password";
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";
/**
* Puts up a username/password dialog with OK and Cancel buttons.
* @param fillThis a pre-allocated properties object
* that the callee fills in.
* keys: userName, password
* @return true for OK, false for Cancel
*/
public boolean promptUsernameAndPassword(String dialogTitle,
String text,
String passwordRealm,
int savePassword,
Properties fillThis);
/**
* Tells the custom app to put up a modal dialog using the information
* in the params for the dialog ui. <P>
* keys: <P>
* <DL>
* <DT>editfield1Value</DT>
* <DD>initial and final value for first edit field</DD>
* <DT>editfield2Value</DT>
* <DD>initial and final value for second edit field</DD>
* <DT>checkboxState</DT>
* <DD>initial and final state of checkbox: true or false</DD>
* <DT>buttonPressed</DT>
* <DD>number of button that was pressed (0 to 3)</DD>
* </DL><P>
* @param titleMessage
* @param dialogTitle e.g., alert, confirm, prompt, prompt password
* @param text main message for dialog
* @param checkboxMsg message for checkbox
* @param button0Text text for first button
* @param button1Text text for second button
* @param button2Text text for third button
* @param button3Text text for fourth button
* @param editfield1Msg message for first edit field
* @param editfield2Msg message for second edit field
* @param numberButtons total number of buttons (0 to 4)
* @param numberEditfields total number of edit fields (0 to 2)
* @param editField1Password whether or not editField1 is a password
* @param fillThis the properties object to be filled with the above
* keys
*/
public boolean universalDialog(String titleMessage,
String dialogTitle,
String text,
String checkboxMsg,
String button0Text,
String button1Text,
String button2Text,
String button3Text,
String editfield1Msg,
String editfield2Msg,
int numberButtons,
int numberEditfields,
boolean editField1Password,
Properties fillThis);
} // end of interface History

View File

@ -48,19 +48,22 @@ import org.mozilla.util.Assert;
import org.w3c.dom.Document;
import java.io.File;
import java.io.FileInputStream;
/**
*
* This is a test application for using the BrowserControl.
*
* @version $Id: EMWindow.java,v 1.24 2000/11/03 03:16:46 edburns%acm.org Exp $
* @version $Id: EMWindow.java,v 1.25 2001/04/02 21:13:48 ashuk%eng.sun.com Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
*/
public class EMWindow extends Frame implements DialogClient, ActionListener, DocumentLoadListener, MouseListener {
public class EMWindow extends Frame implements DialogClient, ActionListener, DocumentLoadListener, MouseListener, Prompt, PrefChangedCallback {
static final int defaultWidth = 640;
static final int defaultHeight = 480;
@ -73,6 +76,7 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
private Navigation navigation = null;
private CurrentPage currentPage;
private History history;
private static Preferences prefs;
private Bookmarks bookmarks;
private BookmarksFrame bookmarksFrame = null;
private TreeModel bookmarksTree;
@ -81,14 +85,20 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
private Panel statusPanel;
private Panel buttonsPanel;
private FindDialog findDialog = null;
private PasswordDialog passDialog = null;
private UniversalDialog uniDialog = null;
private MenuBar menuBar;
private Menu historyMenu;
private MenuItem backMenuItem;
private MenuItem forwardMenuItem;
private HistoryActionListener historyActionListener = null;
private Menu bookmarksMenu;
private Label statusLabel;
private String currentURL;
private Document currentDocument = null;
private EmbeddedMozilla creator;
private boolean viewMode = true;
private Component forwardButton;
private Component backButton;
@ -127,7 +137,7 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
MenuItem closeItem = new MenuItem("Close");
MenuItem findItem = new MenuItem("Find");
MenuItem findNextItem = new MenuItem("Find Next");
MenuItem sourceItem = new MenuItem("View Page Source");
MenuItem sourceItem = new MenuItem("View Page Source as String");
MenuItem pageInfoItem = new MenuItem("View Page Info");
MenuItem selectAllItem = new MenuItem("Select All");
MenuItem copyItem = new MenuItem("Copy");
@ -143,6 +153,39 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
findItem.addActionListener(this);
searchMenu.add(findNextItem);
findNextItem.addActionListener(this);
historyMenu = new Menu("History");
backMenuItem = new MenuItem("Back");
backMenuItem.addActionListener(this);
historyMenu.add(backMenuItem);
forwardMenuItem = new MenuItem("Forward");
forwardMenuItem.addActionListener(this);
historyMenu.add(forwardMenuItem);
menuBar.add(historyMenu);
bookmarksMenu = new Menu("Bookmarks");
MenuItem addBookmark = new MenuItem("Add Current Page");
addBookmark.addActionListener(this);
bookmarksMenu.add(addBookmark);
addBookmark = new MenuItem("Add Current Page In New Folder");
addBookmark.addActionListener(this);
bookmarksMenu.add(addBookmark);
MenuItem manageBookmarks = new MenuItem("Manage Bookmarks...");
manageBookmarks.addActionListener(this);
bookmarksMenu.add(manageBookmarks);
menuBar.add(bookmarksMenu);
Menu streamMenu = new Menu("Stream");
MenuItem streamFromFile = new MenuItem("Load Stream From File...");
streamFromFile.addActionListener(this);
streamMenu.add(streamFromFile);
MenuItem randomStream = new MenuItem("Load Random HTML InputStream");
randomStream.addActionListener(this);
streamMenu.add(randomStream);
menuBar.add(streamMenu);
viewMenu.add(sourceItem);
sourceItem.addActionListener(this);
viewMenu.add(pageInfoItem);
@ -171,15 +214,19 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
stopButton.setEnabled(false);
refreshButton = makeItem(buttonsPanel, "Refresh", 3, 0, 1, 1, 0.0, 0.0);
refreshButton.setEnabled(false);
makeItem(buttonsPanel, "Bookmarks", 4, 0, 1, 1, 0.0, 0.0);
// makeItem(buttonsPanel, "DOMViewer", 5, 0, 1, 1, 0.0, 0.0);
makeItem(buttonsPanel, "DOMViewer", 4, 0, 1, 1, 0.0, 0.0);
// Create the control panel
controlPanel = new Panel();
controlPanel.setLayout(new BorderLayout());
// Add the URL field, and the buttons panel
controlPanel.add(urlField, BorderLayout.CENTER);
Panel centerPanel = new Panel();
centerPanel.setLayout(new BorderLayout());
centerPanel.add(urlField, BorderLayout.NORTH);
// controlPanel.add(urlField, BorderLayout.CENTER);
controlPanel.add(centerPanel, BorderLayout.CENTER);
controlPanel.add(buttonsPanel, BorderLayout.WEST);
// create the status panel
@ -229,7 +276,7 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
// Create the Context Menus
add(popup);
popup.add(popup_ViewSource = new MenuItem("View Source"));
popup.add(popup_ViewSource = new MenuItem("View Source as ByteArray"));
popup.add(popup_SelectAll = new MenuItem("Select All"));
contextListener = new PopupActionListener();
@ -243,11 +290,30 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
try {
navigation = (Navigation)
browserControl.queryInterface(BrowserControl.NAVIGATION_NAME);
navigation.setPrompt(this);
currentPage = (CurrentPage)
browserControl.queryInterface(BrowserControl.CURRENT_PAGE_NAME);
history = (History)
browserControl.queryInterface(BrowserControl.HISTORY_NAME);
prefs = (Preferences)
browserControl.queryInterface(BrowserControl.PREFERENCES_NAME);
prefs.registerPrefChangedCallback(this,
"network.cookie.warnAboutCookies",
"This IS the Closure!");
prefs.setPref("network.cookie.warnAboutCookies", "true");
prefs.setPref("browser.cache.disk_cache_size", "0");
// pull out the proxies, and make java aware of them
Properties prefsProps = prefs.getPrefs();
String proxyHost = (String) prefsProps.get("network.proxy.http");
String proxyPort = (String) prefsProps.get("network.proxy.http_port");
if (null != proxyHost && null != proxyPort) {
System.setProperty("http.proxyHost", proxyHost);
System.setProperty("http.proxyPort", proxyPort);
}
//prefsProps = prefs.getPrefs();
//prefsProps.list(System.out); // This works, try it!
}
catch (Exception e) {
System.out.println(e.toString());
@ -267,6 +333,7 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
System.out.println("debug: edburns: got Bookmarks instance");
bookmarksTree = bookmarks.getBookmarks();
/*********
TreeNode bookmarksRoot = (TreeNode) bookmarksTree.getRoot();
@ -295,11 +362,8 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
*****/
/**********
BookmarkEntry folder = bookmarks.newBookmarkFolder("newFolder");
bookmarks.addBookmark(null, folder);
BookmarkEntry entry = bookmarks.newBookmarkEntry("http://yoyo.com");
System.out.println("debug: edburns: got new entry");
Properties entryProps = entry.getProperties();
@ -352,55 +416,69 @@ public void actionPerformed (ActionEvent evt)
try {
// deal with the menu item commands
if (evt.getSource() instanceof MenuItem) {
if (command.equals("New Window")) {
creator.CreateEMWindow();
if (command.equals("New Window")) {
creator.CreateEMWindow();
}
else if (command.equals("Close")) {
System.out.println("Got windowClosing");
System.out.println("destroying the BrowserControl");
EMWindow.this.delete();
// should close the BrowserControlCanvas
creator.DestroyEMWindow(winNum);
}
else if (command.equals("Find")) {
if (null == findDialog) {
Frame f = new Frame();
f.setSize(350,150);
findDialog = new FindDialog(this, this,
"Find in Page", "Find ",
"", 20, false);
findDialog.setModal(false);
}
else if (command.equals("Close")) {
System.out.println("Got windowClosing");
System.out.println("destroying the BrowserControl");
EMWindow.this.delete();
// should close the BrowserControlCanvas
creator.DestroyEMWindow(winNum);
}
else if (command.equals("Find")) {
if (null == findDialog) {
Frame f = new Frame();
f.setSize(350,150);
findDialog = new FindDialog(this, this,
"Find in Page", "Find ",
"", 20, false);
findDialog.setModal(false);
}
findDialog.setVisible(true);
// currentPage.findInPage("Sun", true, true);
}
else if (command.equals("Find Next")) {
currentPage.findNextInPage(false);
}
else if (command.equals("View Page Source")) {
currentPage.getSourceBytes(viewMode);
viewMode = !viewMode;
}
else if (command.equals("View Page Info")) {
currentPage.getPageInfo();
}
else if (command.equals("Select All")) {
currentPage.selectAll();
}
else if (command.equals("Copy")) {
currentPage.copyCurrentSelectionToSystemClipboard();
}
}
// deal with the button bar commands
findDialog.setVisible(true);
// currentPage.findInPage("Sun", true, true);
}
else if (command.equals("Find Next")) {
currentPage.findNextInPage();
}
else if (command.equals("View Page Source as String")) {
String sou = currentPage.getSource();
System.out.println("+++++++++++ Page Source is +++++++++++\n\n" + sou);
}
else if (command.equals("View Page Info")) {
currentPage.getPageInfo();
}
else if (command.equals("Select All")) {
currentPage.selectAll();
}
else if (command.equals("Copy")) {
currentPage.copyCurrentSelectionToSystemClipboard();
}
else if(command.equals("Stop")) {
navigation.stop();
}
else if (command.equals("Refresh")) {
navigation.refresh(Navigation.LOAD_NORMAL);
}
else if (command.equals("Bookmarks")) {
else if (command.equals("Add Current Page")) {
if (null == bookmarksTree) {
bookmarksTree = bookmarks.getBookmarks();
}
BookmarkEntry entry =
bookmarks.newBookmarkEntry(urlField.getText());
bookmarks.addBookmark(null, entry);
}
else if (command.equals("Add Current Page In New Folder")) {
if (null == bookmarksTree) {
bookmarksTree = bookmarks.getBookmarks();
}
BookmarkEntry folder = bookmarks.newBookmarkFolder("newFolder");
bookmarks.addBookmark(null, folder);
BookmarkEntry entry =
bookmarks.newBookmarkEntry(urlField.getText());
bookmarks.addBookmark(folder, entry);
}
else if (command.equals("Manage Bookmarks...")) {
if (null == bookmarksTree) {
bookmarksTree = bookmarks.getBookmarks();
}
@ -413,6 +491,33 @@ public void actionPerformed (ActionEvent evt)
}
bookmarksFrame.setVisible(true);
}
else if (command.equals("Load Stream From File...")) {
FileDialog fileDialog = new FileDialog(this, "Pick an HTML file",
FileDialog.LOAD);
fileDialog.show();
String file = fileDialog.getFile();
String directory = fileDialog.getDirectory();
if ((null != file) && (null != directory) &&
(0 < file.length()) && (0 < directory.length())) {
String absPath = directory + file;
FileInputStream fis = new FileInputStream(absPath);
File tFile = new File(absPath);
System.out.println("debug: edburns: file: " + absPath);
navigation.loadFromStream(fis, "file:///hello.html",
"text/html", (int) tFile.length(),
null);
}
}
else if (command.equals("Load Random HTML InputStream")) {
RandomHTMLInputStream rhis = new RandomHTMLInputStream(3);
System.out.println("debug: edburns: created RandomHTMLInputStream");
navigation.loadFromStream(rhis, "http://randomstream.com/",
"text/html", -1, null);
}
else if (command.equals("DOMViewer")) {
if (null == domViewer) {
domViewer = new DOMViewerFrame("DOM Viewer", creator);
@ -434,6 +539,8 @@ public void actionPerformed (ActionEvent evt)
history.forward();
}
}
else if (command.equals(" ")) {
}
else {
navigation.loadURL(urlField.getText());
}
@ -445,6 +552,9 @@ public void actionPerformed (ActionEvent evt)
public void dialogDismissed(Dialog d) {
if (d == passDialog || d == uniDialog) {
return;
}
if(findDialog.wasClosed()) {
System.out.println("Find Dialog Closed");
}
@ -508,6 +618,10 @@ private Component makeItem (Panel p, Object arg, int x, int y, int w, int h, dou
p.add(comp);
gbl.setConstraints(comp, c);
if (((String)arg).equals(" ")) {
b.setEnabled(false);
}
}
return comp;
} // makeItem()
@ -543,7 +657,10 @@ public void eventDispatched(WebclientEvent event)
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());
populateHistoryMenu();
statusLabel.setText("Done.");
currentDocument = currentPage.getDOM();
// add the new document to the domViewer
@ -556,6 +673,55 @@ public void eventDispatched(WebclientEvent event)
}
}
/**
* This method exercises the rest of the history API that isn't
* exercised elsewhere in the browser.
*/
private void populateHistoryMenu()
{
int i = 0;
int histLen = 0;
int curIndex = 0;
String curUrl;
MenuItem curItem;
historyMenu.removeAll();
if (null == historyActionListener) {
historyActionListener = new HistoryActionListener();
if (null == historyActionListener) {
return;
}
}
// add back these MenuItems
historyMenu.add(backMenuItem);
historyMenu.add(forwardMenuItem);
// now populate the menu with history items
histLen = history.getHistoryLength();
curIndex = history.getCurrentHistoryIndex();
for (i = 0; i < histLen; i++) {
// PENDING(put in code to truncate unruly long URLs)
curUrl = history.getURLForIndex(i);
// It's important that we prepend the index. This is used in
// the actionListener to load by index.
if (i == curIndex) {
curUrl = Integer.toString(i) + " * " + curUrl;
}
else {
curUrl = Integer.toString(i) + " " + curUrl;
}
curItem = new MenuItem(curUrl);
curItem.addActionListener(historyActionListener);
historyMenu.add(curItem);
}
}
//
// From MouseListener
//
@ -626,14 +792,134 @@ public void mouseReleased(java.awt.event.MouseEvent e)
{
}
//
// Prompt methods
//
public boolean promptUsernameAndPassword(String dialogTitle,
String text,
String passwordRealm,
int savePassword,
Properties fillThis)
{
if (null == fillThis) {
return false;
}
if (null == passDialog) {
if (dialogTitle.equals("")) {
dialogTitle = "Basic Authentication Test";
}
passDialog = new PasswordDialog(this, this,
dialogTitle, text, passwordRealm,
20, true, fillThis);
if (null == passDialog) {
return false;
}
passDialog.setModal(true);
}
passDialog.setVisible(true);
return passDialog.wasOk();
}
public boolean universalDialog(String titleMessage,
String dialogTitle,
String text,
String checkboxMsg,
String button0Text,
String button1Text,
String button2Text,
String button3Text,
String editfield1Msg,
String editfield2Msg,
int numButtons,
int numEditfields,
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 (null == uniDialog) {
if (dialogTitle.equals("")) {
dialogTitle = "Universal Dialog";
}
uniDialog = new UniversalDialog(this, this, dialogTitle);
if (null == uniDialog) {
return false;
}
uniDialog.setParms(titleMessage, dialogTitle, text, checkboxMsg,
button0Text, button1Text, button2Text,
editfield1Msg, editfield2Msg, numButtons,
numEditfields, editfield1Password, fillThis);
uniDialog.setModal(true);
}
uniDialog.setVisible(true);
return true;
}
//
// PrefChangedCallback
//
public int prefChanged(String prefName, Object closure)
{
System.out.println("prefChanged: " + prefName + " closure: " + closure);
return 0;
}
class HistoryActionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
String command = event.getActionCommand();
if (null == command) {
return;
}
// pull out the leading integer
Integer index;
int space = command.indexOf((int)' ');
if (-1 == space) {
return;
}
index = new Integer(command.substring(0, space));
EMWindow.this.history.setCurrentHistoryIndex(index.intValue());
}
}
class PopupActionListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
if (command.equals("View Source"))
if (command.equals("View Source as ByteArray"))
{
System.out.println("I will now View Soure");
EMWindow.this.currentPage.getSourceBytes(EMWindow.this.viewMode);
EMWindow.this.viewMode = !EMWindow.this.viewMode;
System.out.println("I will now View Source");
byte source[] = EMWindow.this.currentPage.getSourceBytes();
String sou = new String(source);
System.out.println("+++++++++++ Page Source is +++++++++++\n\n" + sou);
}
else if (command.equals("Select All"))
{

View File

@ -38,7 +38,7 @@ import org.mozilla.util.Assert;
* This is a test application for using the BrowserControl.
*
* @version $Id: EmbeddedMozilla.java,v 1.4 2000/04/20 18:15:42 edburns%acm.org Exp $
* @version $Id: EmbeddedMozilla.java,v 1.5 2001/04/02 21:13:48 ashuk%eng.sun.com Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
@ -68,7 +68,7 @@ public void CreateEMWindow()
{
System.out.println("Creating new EmbeddedMozilla window");
EMWindow aEMWindow ;
aEMWindow = new EMWindow("EmbeddedMozila#" + count+1,
aEMWindow = new EMWindow("EmbeddedMozila#" + (int)(count+1),
binDir, url, count, this);
count++;
}
@ -93,7 +93,7 @@ public static void main(String [] arg)
printUsage();
System.exit(-1);
}
String urlArg =(2 == arg.length) ? arg[1] : "file:///E|/Projects/tmp/5105.html";
String urlArg =(2 == arg.length) ? arg[1] : "http://www.mozilla.org/projects/blackwood/webclient/";
// set class vars used in EmbeddedMozilla ctor
binDir = arg[0];

View File

@ -0,0 +1,194 @@
/** Ashu -- this is the Find Dialog Class
instantiated within the EMWindow class, this
will act as the Modal dialog for calling Find/Find Next
functions for CurrentPage
*/
package org.mozilla.webclient.test;
import java.awt.*;
import java.awt.event.*;
import org.mozilla.webclient.Prompt;
import java.util.Properties;
public class PasswordDialog extends WorkDialog implements ActionListener, ItemListener{
static private int _defaultTextFieldSize = 20;
private Button okButton;
private Button cancelButton;
private String realm;
private TextField userField;
private TextField passField;
private boolean wasOk;
private boolean wasCanceled;
private ButtonPanel buttonPanel = new ButtonPanel();
private Properties props;
public PasswordDialog(Frame frame, DialogClient client, String title,
String text, String realm,
int userFieldSize, boolean modal,
Properties passwordProperties) {
super(frame, client, title, modal);
RealmPanel realmPanel;
okButton = addButton("Ok");
cancelButton = addButton("Cancel");
props = passwordProperties;
okButton.addActionListener(this);
cancelButton.addActionListener(this);
realmPanel = new RealmPanel(this, text, realm,
userFieldSize);
userField = realmPanel.getUserField();
passField = realmPanel.getPassField();
setWorkPanel(realmPanel);
}
public void actionPerformed(ActionEvent ae) {
if(ae.getSource() == cancelButton) {
wasOk = false;
wasCanceled = true;
dispose(true);
}
else if(ae.getSource() == okButton) {
wasCanceled = false;
wasOk = true;
props.setProperty(Prompt.USER_NAME_KEY, userField.getText());
props.setProperty(Prompt.PASSWORD_KEY, passField.getText());
setUserField("");
setPassField("");
dispose(true);
}
}
public void itemStateChanged(ItemEvent e) {
}
public void setVisible(boolean b) {
userField.requestFocus();
super.setVisible(b);
}
public void returnInTextField() {
okButton.requestFocus();
}
public TextField getUserField() {
return userField;
}
public void setUserField(String string) {
// realmPanel.setUserField(string);
userField.setText(string);
}
public void setPassField(String string) {
passField.setText(string);
}
public String getAnswer() {
return userField.getText();
}
public boolean wasOk() {
return wasOk;
}
public boolean wasCanceled() {
return wasCanceled;
}
private void setRealm(String realm) {
this.realm = realm;
}
}
class RealmPanel extends Postcard {
private TextField userField;
private TextField passField;
private PasswordDialog dialog;
public RealmPanel(PasswordDialog myDialog, String text,
String realm, int cols)
{
super(new Panel());
Panel panel = getPanel();
this.dialog = myDialog;
// set up the stuff on top of the text fields
Panel northPanel = new Panel();
northPanel.setLayout(new BorderLayout());
Label textLabel = new Label(text);
textLabel.setBackground(Color.lightGray);
Label realmLabel = new Label("Realm: " + realm);
realmLabel.setBackground(Color.lightGray);
northPanel.add(textLabel, BorderLayout.NORTH);
northPanel.add(realmLabel, BorderLayout.CENTER);
panel.setLayout(new BorderLayout());
panel.add(northPanel, BorderLayout.NORTH);
// set up the text fields
// set up the user name label and field
Panel centerPanel = new Panel();
centerPanel.setLayout(new BorderLayout());
Panel userPanel = new Panel();
userPanel.setLayout(new BorderLayout());
Label nameLabel = new Label("User Name: ");
nameLabel.setBackground(Color.lightGray);
userPanel.add(nameLabel, BorderLayout.WEST);
if (cols != 0) {
userField = new TextField("", cols);
}
else {
userField = new TextField();
}
userPanel.add(userField, BorderLayout.CENTER);
centerPanel.add(userPanel, BorderLayout.NORTH);
// set up the password label and field
Panel passPanel = new Panel();
passPanel.setLayout(new BorderLayout());
Label passLabel = new Label("Password: ");
passLabel.setBackground(Color.lightGray);
passPanel.add(passLabel, BorderLayout.WEST);
if (cols != 0) {
passField = new TextField("", cols);
}
else {
passField = new TextField();
}
passField.setEchoChar('*');
passPanel.add(passField, BorderLayout.CENTER);
centerPanel.add(passPanel, BorderLayout.CENTER);
//
// add the center panel to the main panel
panel.add(centerPanel, BorderLayout.CENTER);
}
public TextField getUserField()
{
return userField;
}
public void setUserField(String string) {
userField.setText(string);
}
public TextField getPassField() {
return passField;
}
public void setPassField(String string) {
passField.setText(string);
}
}

View File

@ -0,0 +1,268 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ed Burns <edburns@acm.org>
*/
package org.mozilla.webclient.test;
/*
* RandomHTMLInputStream.java
*/
import org.mozilla.util.Assert;
import org.mozilla.util.ParameterCheck;
import java.io.InputStream;
import java.io.IOException;
import java.util.Random;
/**
* This class simulates a nasty, misbehavin' InputStream.
* It randomly throws IOExceptions, blocks on read, and is bursty.
*/
public class RandomHTMLInputStream extends InputStream
{
//
// Class variables
//
private static final int MAX_AVAILABLE = 4096;
/**
* This makes it so only when we get a random between 0 and 100 number
* that evenly divides by three do we throw an IOException
*/
private static final int EXCEPTION_DIVISOR = 179;
private static final byte [] CHARSET;
//
// relationship ivars
//
private Random random;
//
// attribute ivars
//
private boolean isClosed;
private boolean firstRead;
/**
* the number of times that read(bytearray) can be called and still get
* data.
*/
private int numReads;
private int available;
/**
* @param yourNumReads must be at least 2
*/
static {
String charSet = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890[]{}";
CHARSET = charSet.getBytes();
}
public RandomHTMLInputStream(int yourNumReads)
{
ParameterCheck.greaterThan(yourNumReads, 1);
random = new Random();
Assert.assert(null != random);
isClosed = false;
firstRead = true;
numReads = yourNumReads;
available = random.nextInt(MAX_AVAILABLE);
}
public int available() throws IOException
{
int result;
if (shouldThrowException()) {
throw new IOException("It's time for an IOException!");
}
if (isClosed) {
result = -1;
}
else {
result = available;
}
return result;
}
public int read() throws IOException
{
int result = 0;
if (shouldThrowException()) {
throw new IOException("It's time for an IOException!");
}
if (0 < available) {
result = (int) 'a';
available--;
}
else {
result = -1;
}
return result;
}
public int read(byte[] b, int off, int len) throws IOException
{
if (shouldThrowException()) {
throw new IOException("It's time for an IOException!");
}
byte [] bytes;
int i = 0;
int max = 0;
int numRead = -1;
// write case 0, no more reads left
if (0 == numReads || isClosed) {
return -1;
}
if (len <= available) {
max = len;
}
else {
max = available;
}
if (firstRead) {
String htmlHead = "<HTML><BODY><PRE>START Random Data";
numRead = htmlHead.length();
// write case 1, yes enough length to write htmlHead
if (numRead < len && len <= available) {
bytes = htmlHead.getBytes();
for (i = 0; i < numRead; i++) {
b[off+i] = bytes[i];
}
available -= numRead;
}
else {
// write case 2, not enough length to write htmlHead
for (i = 0; i < max; i++) {
b[off+i] = (byte) random.nextInt(8);
}
numRead = max;
available -= max;
}
firstRead = false;
}
else {
// if this is the last read
if (1 == numReads) {
String htmlTail = "\nEND Random Data</PRE></BODY></HTML>";
numRead = htmlTail.length();
// write case 3, yes enough length to write htmlTail
if (numRead < len && len <= available) {
bytes = htmlTail.getBytes();
for (i = 0; i < numRead; i++) {
b[off+i] = bytes[i];
}
available -= numRead;
}
else {
// write case 4, not enough length to write htmlTail
for (i = 0; i < max; i++) {
b[off+i] = (byte) random.nextInt(8);
}
numRead = max;
available -= max;
}
}
else {
// if it's time to block
if (random.nextBoolean()) {
try {
System.out.println("RandomHTMLInputStream:: sleeping");
Thread.sleep(3000);
}
catch (Exception e) {
throw new IOException(e.getMessage());
}
}
// write case 5, write some random bytes to fit length
// this is not the first or the last read, just cough up
// some random bytes.
bytes = new byte[max];
for (i = 0; i < max; i++) {
if (0 == (i % 78)) {
b[off+i] = (byte) '\n';
}
else {
b[off+i] = CHARSET[random.nextInt(CHARSET.length)];
}
}
numRead = max;
available -= max;
}
}
available = random.nextInt(MAX_AVAILABLE);
numReads--;
return numRead;
}
public void close() throws IOException
{
if (shouldThrowException()) {
throw new IOException("It's time for an IOException!");
}
isClosed = true;
}
private boolean shouldThrowException()
{
int nextInt = random.nextInt(10000);
boolean result = false;
if (nextInt > EXCEPTION_DIVISOR) {
result = (0 == (nextInt % EXCEPTION_DIVISOR));
}
return result;
}
}

View File

@ -0,0 +1,217 @@
/** Ashu -- this is the Find Dialog Class
instantiated within the EMWindow class, this
will act as the Modal dialog for calling Find/Find Next
functions for CurrentPage
*/
package org.mozilla.webclient.test;
import org.mozilla.util.Assert;
import org.mozilla.webclient.Prompt;
import java.awt.*;
import java.awt.event.*;
import java.util.Properties;
// PENDING(edburns): Apply uniform formatting throughout webclient
public class UniversalDialog extends WorkDialog implements ActionListener, ItemListener
{
static private int _defaultTextFieldSize = 20;
public Button [] buttons;
public TextField [] fields;
public String mTitleMsg;
public String mText;
public String mCheckboxMsg;
public Checkbox mCheckbox;
public String mField1Label;
public String mField2Label;
public boolean mField1IsPasswd;
public Properties mProps;
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)
{
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;
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);
}
}
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('*');
}
}
}
dialogPanel = new DialogPanel(this);
setWorkPanel(dialogPanel);
}
public void actionPerformed(ActionEvent ae)
{
Assert.assert(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 (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);
}
}
}
if (null != mCheckbox) {
Boolean bool = new Boolean(mCheckbox.getState());
mProps.put(Prompt.CHECKBOX_STATE_KEY, bool.toString());
}
dispose(true);
}
public void itemStateChanged(ItemEvent e)
{
}
public void setVisible(boolean b)
{
if (null != fields) {
fields[0].requestFocus();
}
super.setVisible(b);
}
}
class DialogPanel extends Postcard
{
private UniversalDialog dialog;
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);
}
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.mCheckboxMsg) {
dialog.mCheckbox = new Checkbox(dialog.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);
}
}

View File

@ -30,9 +30,8 @@ import org.mozilla.webclient.Bookmarks;
import org.mozilla.webclient.BookmarkEntry;
import org.mozilla.webclient.UnimplementedException;
import java.util.Properties;
import javax.swing.tree.MutableTreeNode;
import java.util.Properties;
public class BookmarkEntryImpl extends RDFTreeNode implements BookmarkEntry
{
@ -52,9 +51,6 @@ public class BookmarkEntryImpl extends RDFTreeNode implements BookmarkEntry
// Relationship Instance Variables
Properties properties = null;
//
// Constructors and Initializers
//
@ -114,17 +110,12 @@ public void setUserObject(Object object)
public Properties getProperties()
{
if ((null == properties) &&
(null == (properties = new Properties()))) {
throw new IllegalStateException("Can't create properties table");
}
return properties;
return super.getProperties();
}
public boolean isFolder()
{
return nativeIsContainer(nativeWebShell, getNativeRDFNode());
return super.isFolder();
}
// ----VERTIGO_TEST_START
@ -139,7 +130,7 @@ public static void main(String [] args)
Log.setApplicationName("BookmarkEntryImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BookmarkEntryImpl.java,v 1.3 2000/11/03 03:16:48 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: BookmarkEntryImpl.java,v 1.4 2001/04/02 21:13:56 ashuk%eng.sun.com Exp $");
}

View File

@ -44,6 +44,7 @@ public class BookmarksImpl extends ImplObjectNative implements Bookmarks
//
// Constants
//
private static final String NC_NS = "http://home.netscape.com/NC-rdf#";
//
// Class Variables
@ -176,29 +177,40 @@ public BookmarkEntry newBookmarkEntry(String url)
getBookmarks();
int newNode;
System.out.println("debug: edburns: BookmarksImpl.newBookmarkEntry: url:" + url);
if (-1 != (newNode = nativeNewRDFNode(nativeWebShell, url, false))) {
result = new BookmarkEntryImpl(nativeWebShell,
newNode, null);
// use put instead of setProperty for jdk1.1.x compatibility.
result.getProperties().put(BookmarkEntry.NAME, url);
result.getProperties().put(BookmarkEntry.URL, url);
}
return result;
}
/**
* Due to the vagaries of the mozilla RDF implementation, folders and
* bookmark entries are handled differently. For Folders, we don't
* create a nativeRDFNode at the outset. Rather, we just create the
* properties table and stock it with the known keys, then wait for the
* nativeRDFNode to be created en addBookmark.
*/
public BookmarkEntry newBookmarkFolder(String name)
{
ParameterCheck.nonNull(name);
BookmarkEntry result = null;
getBookmarks();
int newNode;
System.out.println("debug: edburns: BookmarksImpl.newBookmarkFolder: name:" + name);
if (-1 != (newNode = nativeNewRDFNode(nativeWebShell, name, true))) {
result = new BookmarkEntryImpl(nativeWebShell, newNode, null);
result.getProperties().put(BookmarkEntry.NAME, name);
if (null == (result = new BookmarkEntryImpl(nativeWebShell, -1, null))) {
throw new NullPointerException("Can't create bookmark folder for: " +
name);
}
result.getProperties().put(BookmarkEntry.NAME, name);
result.getProperties().put(BookmarkEntry.URL, NC_NS + "$" + name);
result.getProperties().put(BookmarkEntry.IS_FOLDER, name);
return result;
}
@ -230,7 +242,7 @@ public static void main(String [] args)
Log.setApplicationName("BookmarksImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BookmarksImpl.java,v 1.7 2000/11/03 03:16:49 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: BookmarksImpl.java,v 1.8 2001/04/02 21:13:56 ashuk%eng.sun.com Exp $");
try {
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);

View File

@ -108,12 +108,12 @@ public void findInPage(String stringToFind, boolean forward, boolean matchCase)
}
}
public void findNextInPage(boolean forward)
public void findNextInPage()
{
myFactory.throwExceptionIfNotInitialized();
synchronized(myBrowserControl) {
nativeFindNextInPage(nativeWebShell, forward);
nativeFindNextInPage(nativeWebShell);
}
}
@ -151,62 +151,67 @@ public Properties getPageInfo()
public String getSource()
{
String result = null;
myFactory.throwExceptionIfNotInitialized();
/* synchronized(myBrowserControl) {
result = nativeGetSource();
String HTMLContent = null;
String currURL = getCurrentURL();
System.out.println("\nThe Current URL is -- " + currURL);
try {
URL aURL = new URL(currURL);
URLConnection connection = aURL.openConnection();
connection.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
boolean more = true;
while (more)
{
String line = in.readLine();
if (line == null) more = false;
else
{
HTMLContent = HTMLContent + line;
}
}
}
*/
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::getSource has not yet been implemented.\n");
// return result;
catch (Throwable e)
{
System.out.println("Error occurred while establishing connection -- \n ERROR - " + e);
}
return HTMLContent;
}
public byte [] getSourceBytes(boolean viewMode)
public byte [] getSourceBytes()
{
byte [] result = null;
myFactory.throwExceptionIfNotInitialized();
synchronized(myBrowserControl) {
result = nativeGetSourceBytes(nativeWebShell, viewMode);
}
//throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::getSourceBytes has not yet been implemented.\n Will be available after Webclient M3 Release\n");
// PENDING (Ashu) - This should work - but it does not get anything from URl
// and hangs up from time to time. Have to Debug. In M15, other native solution
// will also be available using DocShell::viewMode
/*
String HTMLContent = null;
String URL = getCurrentURL();
System.out.println("\nThe Current URL is -- " + URL);
String currURL = getCurrentURL();
System.out.println("\nThe Current URL is -- " + currURL);
try {
Socket s = new Socket("sunweb.central",80);
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
boolean more = true;
while (more)
{
String line = in.readLine();
if (line == null) more = false;
else
{
HTMLContent = HTMLContent + line;
System.out.println(line);
}
}
URL aURL = new URL(currURL);
URLConnection connection = aURL.openConnection();
connection.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
boolean more = true;
while (more)
{
String line = in.readLine();
if (line == null) more = false;
else
{
HTMLContent = HTMLContent + line;
}
}
}
catch (Throwable e)
{
System.out.println("Error occurred while establishing connection -- \n ERROR - " + e);
}
*/
catch (Throwable e)
{
System.out.println("Error occurred while establishing connection -- \n ERROR - " + e);
}
result = HTMLContent.getBytes();
return result;
}
public void resetFind()
{
myFactory.throwExceptionIfNotInitialized();
@ -233,17 +238,19 @@ native public void nativeCopyCurrentSelectionToSystemClipboard(int webShellPtr);
native public void nativeFindInPage(int webShellPtr, String stringToFind, boolean forward, boolean matchCase);
native public void nativeFindNextInPage(int webShellPtr, boolean forward);
native public void nativeFindNextInPage(int webShellPtr);
native public String nativeGetCurrentURL(int webShellPtr);
native public Document nativeGetDOM(int webShellPtr);
// webclient.PageInfo getPageInfo();
native public String nativeGetSource();
/* PENDING(ashuk): remove this from here and in the motif directory
* native public String nativeGetSource();
native public byte [] nativeGetSourceBytes(int webShellPtr, boolean viewMode);
* native public byte [] nativeGetSourceBytes(int webShellPtr, boolean viewMode);
*/
native public void nativeResetFind(int webShellPtr);
@ -261,7 +268,7 @@ public static void main(String [] args)
Assert.setEnabled(true);
Log.setApplicationName("CurrentPageImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.10 2000/11/03 01:26:59 ashuk%eng.sun.com Exp $");
Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.11 2001/04/02 21:13:57 ashuk%eng.sun.com Exp $");
}

View File

@ -45,6 +45,13 @@ import org.mozilla.webclient.UnimplementedException;
public class NativeEventThread extends Thread
{
//
// Class variables
//
private static Object firstThread = null;
//
// Attribute ivars
//
@ -111,6 +118,10 @@ public NativeEventThread(String threadName, BrowserControl yourBrowserControl)
super(threadName);
ParameterCheck.nonNull(yourBrowserControl);
if (null == firstThread) {
firstThread = this;
}
browserControl = yourBrowserControl;
try {
@ -206,6 +217,13 @@ public void run()
}
while (true) {
try {
Thread.sleep(1);
}
catch (Exception e) {
System.out.println("NativeEventThread.run(): Exception: " + e +
" while sleeping: " + e.getMessage());
}
synchronized (this) {
// this has to be inside the synchronized block!
@ -222,7 +240,9 @@ public void run()
return;
}
nativeProcessEvents(nativeWebShell);
if (this == firstThread) {
nativeProcessEvents(nativeWebShell);
}
if (null != listenersToAdd && !listenersToAdd.isEmpty()) {
tempEnum = listenersToAdd.elements();

View File

@ -25,13 +25,16 @@ package org.mozilla.webclient.wrapper_native;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.RangeException;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.Navigation;
import org.mozilla.webclient.WindowControl;
import org.mozilla.webclient.WrapperFactory;
import org.mozilla.webclient.Prompt;
import java.awt.Rectangle;
import java.io.InputStream;
import java.util.Properties;
public class NavigationImpl extends ImplObjectNative implements Navigation
{
@ -84,6 +87,29 @@ public void loadURL(String absoluteURL)
}
}
public void loadFromStream(InputStream stream, String uri,
String contentType, int contentLength,
Properties loadInfo)
{
ParameterCheck.nonNull(stream);
ParameterCheck.nonNull(uri);
ParameterCheck.nonNull(contentType);
if (contentLength < -1 || contentLength == 0) {
throw new RangeException("contentLength value " + contentLength +
" is out of range. It is should be either -1 or greater than 0.");
}
myFactory.throwExceptionIfNotInitialized();
Assert.assert(-1 != nativeWebShell);
synchronized(myBrowserControl) {
nativeLoadFromStream(nativeWebShell, stream,
uri, contentType, contentLength,
loadInfo);
}
}
public void refresh(long loadFlags)
{
ParameterCheck.noLessThan(loadFlags, 0);
@ -105,16 +131,36 @@ public void stop()
}
}
public void setPrompt(Prompt yourPrompt)
{
ParameterCheck.nonNull(yourPrompt);
myFactory.throwExceptionIfNotInitialized();
Assert.assert(-1 != nativeWebShell);
synchronized(myBrowserControl) {
nativeSetPrompt(nativeWebShell, yourPrompt);
}
}
//
// Native methods
//
public native void nativeLoadURL(int webShellPtr, String absoluteURL);
public native void nativeLoadFromStream(int webShellPtr, InputStream stream,
String uri,
String contentType,
int contentLength,
Properties loadInfo);
public native void nativeRefresh(int webShellPtr, long loadFlags);
public native void nativeStop(int webShellPtr);
public native void nativeSetPrompt(int webShellPtr, Prompt yourPrompt);
// ----VERTIGO_TEST_START
//
@ -127,7 +173,7 @@ public static void main(String [] args)
Log.setApplicationName("NavigationImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.3 2000/07/22 02:48:26 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.4 2001/04/02 21:13:59 ashuk%eng.sun.com Exp $");
try {
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);

View File

@ -0,0 +1,186 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ed Burns <edburns@acm.org>
*/
package org.mozilla.webclient.wrapper_native;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.WrapperFactory;
import org.mozilla.webclient.Preferences;
import org.mozilla.webclient.PrefChangedCallback;
import java.util.Properties;
import org.mozilla.webclient.UnimplementedException;
public class PreferencesImpl extends ImplObjectNative implements Preferences
{
//
// Constants
//
//
// Class Variables
//
//
// Instance Variables
//
// Attribute Instance Variables
// Relationship Instance Variables
private Properties props;
//
// Constructors and Initializers
//
public PreferencesImpl(WrapperFactory yourFactory,
BrowserControl yourBrowserControl)
{
super(yourFactory, yourBrowserControl);
props = null;
}
/**
* Since this class is a singleton, we don't expect this method to be
* called until the app is done with bookmarks for a considerable amount
* of time.
// PENDING(): Write test case to see that a cycle of Preferences
// allocation/destruction/new instance allocation works correctly.
*/
public void delete()
{
}
//
// Class methods
//
//
// General Methods
//
//
// Methods from Preferences
//
public void setPref(String prefName, String prefValue)
{
if (null == prefName) {
return;
}
if (null == prefValue) {
return;
}
// determine the type of pref value: String, boolean, integer
try {
Integer intVal = Integer.valueOf(prefValue);
nativeSetIntPref(nativeWebShell, prefName, intVal.intValue());
}
catch (NumberFormatException e) {
// it's not an integer
if (prefValue.equals("true") || prefValue.equals("false")) {
Boolean boolVal = Boolean.valueOf(prefValue);
nativeSetBoolPref(nativeWebShell, prefName,
boolVal.booleanValue());
}
else {
// it must be a string
nativeSetUnicharPref(nativeWebShell, prefName, prefValue);
}
}
}
public Properties getPrefs()
{
props = nativeGetPrefs(nativeWebShell, props);
return props;
}
public void registerPrefChangedCallback(PrefChangedCallback cb,
String prefName, Object closure)
{
ParameterCheck.nonNull(cb);
ParameterCheck.nonNull(prefName);
nativeRegisterPrefChangedCallback(nativeWebShell, cb, prefName, closure);
}
//
// native methods
//
public native void nativeSetUnicharPref(int nativeWebShell,
String prefName, String prefValue);
public native void nativeSetIntPref(int nativeWebShell,
String prefName, int prefValue);
public native void nativeSetBoolPref(int nativeWebShell,
String prefName, boolean prefValue);
public native Properties nativeGetPrefs(int nativeWebShell, Properties props);
public native void nativeRegisterPrefChangedCallback(int nativeWebShell,
PrefChangedCallback cb,
String prefName,
Object closure);
// ----VERTIGO_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
Log.setApplicationName("PreferencesImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: PreferencesImpl.java,v 1.2 2001/04/02 21:13:59 ashuk%eng.sun.com Exp $");
try {
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
org.mozilla.webclient.BrowserControl control =
org.mozilla.webclient.BrowserControlFactory.newBrowserControl();
Assert.assert(control != null);
Preferences wc = (Preferences)
control.queryInterface(org.mozilla.webclient.BrowserControl.WINDOW_CONTROL_NAME);
Assert.assert(wc != null);
}
catch (Exception e) {
System.out.println("got exception: " + e.getMessage());
}
}
// ----VERTIGO_TEST_END
} // end of class PreferencesImpl

View File

@ -27,9 +27,13 @@ import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import java.util.Enumeration;
import java.util.Properties;
import javax.swing.tree.TreeNode;
import javax.swing.tree.MutableTreeNode;
import org.mozilla.webclient.BookmarkEntry;
public abstract class RDFTreeNode extends ISupportsPeer implements MutableTreeNode
{
//
@ -48,10 +52,11 @@ public abstract class RDFTreeNode extends ISupportsPeer implements MutableTreeNo
// Relationship Instance Variables
private int nativeRDFNode = -1;
protected int nativeRDFNode = -1;
private RDFTreeNode parent;
Properties properties = null;
/**
@ -84,6 +89,16 @@ protected RDFTreeNode(int yourNativeWebShell,
// General Methods
//
public Properties getProperties()
{
if ((null == properties) &&
(null == (properties = new Properties()))) {
throw new IllegalStateException("Can't create properties table");
}
return properties;
}
//
// Abstract Methods
//
@ -111,7 +126,9 @@ private void setNativeRDFNode(int yourNativeRDFNode)
protected void finalize() throws Throwable
{
nativeRelease(nativeRDFNode);
if (-1 != nativeRDFNode) {
nativeRelease(nativeRDFNode);
}
super.finalize();
}
@ -199,12 +216,17 @@ public boolean isLeaf()
return nativeIsLeaf(nativeWebShell, nativeRDFNode);
}
//
// Methods from MutableTreeNode
//
/**
* Unfortunately, we have to handle folders and bookmarks differently.
*/
public void insert(MutableTreeNode child, int index)
{
if (!(child instanceof RDFTreeNode)) {
@ -212,13 +234,29 @@ public void insert(MutableTreeNode child, int index)
}
Assert.assert(-1 != nativeRDFNode);
RDFTreeNode childNode = (RDFTreeNode) child;
Assert.assert(-1 != childNode.getNativeRDFNode());
int childNativeRDFNode = childNode.getNativeRDFNode();
// hook up the child to its native peer
nativeInsertElementAt(nativeWebShell, nativeRDFNode,
childNativeRDFNode, index);
if (childNode.isFolder()) {
Assert.assert(-1 == childNode.getNativeRDFNode());
Assert.assert(null != childNode.getProperties());
int childNativeRDFNode;
// hook up the child to its native peer
childNativeRDFNode = nativeNewFolder(nativeWebShell, nativeRDFNode,
childNode.getProperties());
// hook up the child to its native peer
childNode.setNativeRDFNode(childNativeRDFNode);
}
else {
Assert.assert(-1 != childNode.getNativeRDFNode());
int childNativeRDFNode = childNode.getNativeRDFNode();
// hook up the child to its native peer
nativeInsertElementAt(nativeWebShell, nativeRDFNode,
childNativeRDFNode, childNode.getProperties(),
index);
}
// hook up the child to its java parent
childNode.setParent(this);
@ -251,6 +289,24 @@ public void setUserObject(Object object)
}
//
// methods on this
//
public boolean isFolder()
{
boolean result = false;
if (-1 == nativeRDFNode) {
if (null != getProperties()) {
result = (null != getProperties().get(BookmarkEntry.IS_FOLDER));
}
}
else {
result = nativeIsContainer(nativeWebShell, getNativeRDFNode());
}
return result;
}
//
// Native methods
//
@ -272,7 +328,11 @@ public native int nativeGetIndex(int webShellPtr, int nativeRDFNode,
public native String nativeToString(int webShellPtr, int nativeRDFNode);
public native void nativeInsertElementAt(int webShellPtr,
int parentNativeRDFNode,
int childNativeRDFNode, int index);
int childNativeRDFNode,
Properties childProps, int index);
public native int nativeNewFolder(int webShellPtr, int parentRDFNode,
Properties childProps);
// ----VERTIGO_TEST_START
@ -286,7 +346,7 @@ public static void main(String [] args)
Log.setApplicationName("RDFTreeNode");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: RDFTreeNode.java,v 1.2 2000/11/03 03:16:50 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: RDFTreeNode.java,v 1.3 2001/04/02 21:13:59 ashuk%eng.sun.com Exp $");
}

View File

@ -140,6 +140,10 @@ public Object newImpl(String interfaceName,
result = new BookmarksImpl(this, browserControl);
return result;
}
if (BrowserControl.PREFERENCES_NAME == interfaceName) {
result = new PreferencesImpl(this, browserControl);
return result;
}
}
return result;
@ -222,7 +226,7 @@ public static void main(String [] args)
WrapperFactory me = new WrapperFactoryImpl();
Log.setApplicationName("WrapperFactoryImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: WrapperFactoryImpl.java,v 1.3 2000/11/02 23:33:13 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: WrapperFactoryImpl.java,v 1.4 2001/04/02 21:13:59 ashuk%eng.sun.com Exp $");
}

View File

@ -27,7 +27,7 @@ CMyDialog::CMyDialog(WebShellInitContext *yourInitContext) : m_initContext(yourI
{
// initialize the string constants (including properties keys)
if (!util_StringConstantsAreInitialized()) {
util_InitStringConstants(m_initContext->env);
util_InitStringConstants();
}
}

View File

@ -22,10 +22,10 @@
#include "BookmarksImpl.h"
#include "RDFActionEvents.h"
#include "rdf_util.h"
#include "ns_util.h"
#include "nsActions.h"
#include "nsCOMPtr.h"
#include "nsISimpleEnumerator.h"

View File

@ -24,8 +24,6 @@
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
*/
#include <limits.h>
#include "CBrowserContainer.h"
#include "nsCWebBrowser.h"
@ -38,27 +36,27 @@
#include "dom_util.h"
#include "PromptActionEvents.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
#if defined(XP_UNIX) || defined(XP_MAC) || defined(XP_BEOS)
#define WC_ITOA(intVal, buf, radix) sprintf(buf, "%d", intVal)
#else
#define WC_ITOA(intVal, buf, radix) itoa(intVal, buf, radix)
#endif
jobject gPromptProperties = nsnull;
PRInt32 CBrowserContainer::mInstanceCount = 0;
CBrowserContainer::CBrowserContainer(nsIWebBrowser *pOwner, JNIEnv *env,
WebShellInitContext *yourInitContext) :
m_pOwner(pOwner), mJNIEnv(env), mInitContext(yourInitContext),
mDocTarget(nsnull), mMouseTarget(nsnull), mDomEventTarget(nsnull),
inverseDepth(-1), properties(nsnull), currentDOMEvent(nsnull)
mDocTarget(nsnull), mMouseTarget(nsnull), mPrompt(nsnull),
mDomEventTarget(nsnull), inverseDepth(-1),
properties(nsnull), currentDOMEvent(nsnull)
{
NS_INIT_REFCNT();
// initialize the string constants (including properties keys)
if (!util_StringConstantsAreInitialized()) {
util_InitStringConstants(env);
util_InitStringConstants();
}
mInstanceCount++;
}
@ -77,6 +75,7 @@ CBrowserContainer::~CBrowserContainer()
}
properties = nsnull;
currentDOMEvent = nsnull;
mInstanceCount--;
}
@ -171,7 +170,65 @@ NS_IMETHODIMP CBrowserContainer::PromptUsernameAndPassword(const PRUnichar *dial
PRUnichar **pwd,
PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
nsresult rv = NS_ERROR_FAILURE;
// if the user hasn't given us a prompt, oh well
if (!mPrompt) {
return NS_OK;
}
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
wsPromptUsernameAndPasswordEvent *actionEvent = nsnull;
wsStringStruct strings[3] = {
{dialogTitle, nsnull},
{text, nsnull},
{passwordRealm, nsnull} };
rv = ::util_CreateJstringsFromUnichars(strings, 3);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: PromptUserNameAndPassword: can't create jstrings from Unichars");
goto PUAP_CLEANUP;
}
// PENDING(edburns): uniformly apply checks for this throughout the
// code
PR_ASSERT(mInitContext);
PR_ASSERT(mInitContext->initComplete);
// try to initialize the properties object for basic auth and cookies
if (!gPromptProperties) {
gPromptProperties =
::util_CreatePropertiesObject(env, (jobject)
&(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)
&(mInitContext->shareContext));
}
if (!(actionEvent = new wsPromptUsernameAndPasswordEvent(mInitContext, mPrompt,
strings, savePassword,
user, pwd, _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(mInitContext,
(PLEvent *) *actionEvent);
rv = NS_OK;
PUAP_CLEANUP:
::util_DeleteJstringsFromUnichars(strings, 3);
return rv;
}
/* boolean promptPassword (in wstring text, in wstring title, out wstring pwd); */
@ -191,10 +248,101 @@ NS_IMETHODIMP CBrowserContainer::Select(const PRUnichar *inDialogTitle, const PR
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void universalDialog (in wstring inTitleMessage, in wstring inDialogTitle, in wstring inMsg, in wstring inCheckboxMsg, in wstring inButton0Text, in wstring inButton1Text, in wstring inButton2Text, in wstring inButton3Text, in wstring inEditfield1Msg, in wstring inEditfield2Msg, inout wstring inoutEditfield1Value, inout wstring inoutEditfield2Value, in wstring inIConURL, inout boolean inoutCheckboxState, in PRInt32 inNumberButtons, in PRInt32 inNumberEditfields, in PRInt32 inEditField1Password, out PRInt32 outButtonPressed); */
NS_IMETHODIMP CBrowserContainer::UniversalDialog(const PRUnichar *inTitleMessage, const PRUnichar *inDialogTitle, const PRUnichar *inMsg, const PRUnichar *inCheckboxMsg, const PRUnichar *inButton0Text, const PRUnichar *inButton1Text, const PRUnichar *inButton2Text, const PRUnichar *inButton3Text, const PRUnichar *inEditfield1Msg, const PRUnichar *inEditfield2Msg, PRUnichar **inoutEditfield1Value, PRUnichar **inoutEditfield2Value, const PRUnichar *inIConURL, PRBool *inoutCheckboxState, PRInt32 inNumberButtons, PRInt32 inNumberEditfields, PRInt32 inEditField1Password, PRInt32 *outButtonPressed)
NS_IMETHODIMP
CBrowserContainer::UniversalDialog(const PRUnichar *inTitleMessage,
const PRUnichar *inDialogTitle,
const PRUnichar *inMsg,
const PRUnichar *inCheckboxMsg,
const PRUnichar *inButton0Text,
const PRUnichar *inButton1Text,
const PRUnichar *inButton2Text,
const PRUnichar *inButton3Text,
const PRUnichar *inEditfield1Msg,
const PRUnichar *inEditfield2Msg,
PRUnichar **inoutEditfield1Value,
PRUnichar **inoutEditfield2Value,
const PRUnichar *inIConURL,
PRBool *inoutCheckboxState,
PRInt32 inNumberButtons,
PRInt32 inNumberEditfields,
PRInt32 inEditField1Password,
PRInt32 *outButtonPressed)
{
return NS_ERROR_NOT_IMPLEMENTED;
printf("debug: edburns: CBrowserContainer::UniversalDialog()\n");
nsresult rv = NS_ERROR_FAILURE;
// if the user hasn't given us a prompt, oh well
if (!mPrompt) {
return NS_OK;
}
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
wsPromptUniversalDialogEvent *actionEvent = nsnull;
wsStringStruct strings[10] = {
{inTitleMessage, nsnull},
{inDialogTitle, nsnull},
{inMsg, nsnull},
{inCheckboxMsg, nsnull},
{inButton0Text, nsnull},
{inButton1Text, nsnull},
{inButton2Text, nsnull},
{inButton3Text, nsnull},
{inEditfield1Msg, nsnull},
{inEditfield2Msg, nsnull} };
rv = ::util_CreateJstringsFromUnichars(strings, 10);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: UniversalDialog: can't create jstrings from Unichars");
goto UD_CLEANUP;
}
// PENDING(edburns): uniformly apply checks for this throughout the
// code
PR_ASSERT(mInitContext);
PR_ASSERT(mInitContext->initComplete);
// try to initialize the properties object for basic auth and cookies
if (!gPromptProperties) {
gPromptProperties =
::util_CreatePropertiesObject(env, (jobject)
&(mInitContext->shareContext));
if (!gPromptProperties) {
printf("Error: can't create properties object for authentitication");
rv = NS_ERROR_NULL_POINTER;
goto UD_CLEANUP;
}
}
else {
::util_ClearPropertiesObject(env, gPromptProperties, (jobject)
&(mInitContext->shareContext));
}
if (!(actionEvent = new wsPromptUniversalDialogEvent(mInitContext,
mPrompt,
strings,
inoutEditfield1Value,
inoutEditfield2Value,
inoutCheckboxState,
inNumberButtons,
inNumberEditfields,
inEditField1Password,
outButtonPressed))) {
::util_ThrowExceptionToJava(env, "Exception: UniversalDialog: can't create wsPromptUniversalDialogEvent");
rv = NS_ERROR_NULL_POINTER;
goto UD_CLEANUP;
}
// the out params to this method are set in wsPromptUsernameAndPasswordEvent::handleEvent()
::util_PostSynchronousEvent(mInitContext, (PLEvent *) *actionEvent);
rv = NS_OK;
UD_CLEANUP:
::util_DeleteJstringsFromUnichars(strings, 10);
return rv;
}
@ -1020,6 +1168,24 @@ NS_IMETHODIMP CBrowserContainer::AddDocumentLoadListener(jobject target)
return rv;
}
NS_IMETHODIMP CBrowserContainer::SetPrompt(jobject target)
{
nsresult rv = NS_OK;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
if (mPrompt) {
::util_DeleteGlobalRef(env, mPrompt);
mPrompt = nsnull;
}
if (nsnull == (mPrompt = ::util_NewGlobalRef(env, target))) {
::util_ThrowExceptionToJava(env, "Exception: Navigation.nativeSetPrompt(): can't create NewGlobalRef\n\tfor argument");
rv = NS_ERROR_NULL_POINTER;
}
return rv;
}
NS_IMETHODIMP CBrowserContainer::RemoveMouseListener()
{
nsresult rv = NS_OK;
@ -1045,7 +1211,12 @@ NS_IMETHODIMP CBrowserContainer::RemoveDocumentLoadListener()
return rv;
}
NS_IMETHODIMP CBrowserContainer::GetInstanceCount(PRInt32 *outCount)
{
PR_ASSERT(outCount);
*outCount = mInstanceCount;
return NS_OK;
}
NS_IMETHODIMP CBrowserContainer::RemoveAllListeners()
{

View File

@ -88,7 +88,9 @@ protected:
WebShellInitContext *mInitContext;
jobject mDocTarget;
jobject mMouseTarget;
jobject mPrompt;
nsCOMPtr<nsIDOMEventTarget> mDomEventTarget;
static PRInt32 mInstanceCount;
//
// The following arguments are used in the takeActionOnNode method.

View File

@ -0,0 +1,334 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
* Jason Mawdsley <jason@macadamian.com>
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
*/
/*
* CurrentPageActionEvents.cpp
*/
#include "CurrentPageActionEvents.h"
#include "nsIDOMWindowInternal.h"
#include "nsIFindComponent.h"
#include "nsISearchContext.h"
#include "nsIDocShell.h"
#include "nsIContentViewer.h"
#include "nsIContentViewer.h"
#include "nsIContentViewerEdit.h"
#include "nsIInterfaceRequestor.h"
wsCopySelectionEvent::wsCopySelectionEvent(WebShellInitContext *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
}
void *
wsCopySelectionEvent::handleEvent ()
{
void *result = nsnull;
if (mInitContext) {
nsIContentViewer* contentViewer ;
nsresult rv = nsnull;
rv = mInitContext->docShell->GetContentViewer(&contentViewer);
if (NS_FAILED(rv) || contentViewer==nsnull ) {
return (void *) rv;
}
nsCOMPtr<nsIContentViewerEdit> contentViewerEdit(do_QueryInterface(contentViewer));
rv = contentViewerEdit->CopySelection();
result = (void *) rv;
}
return result;
}
wsFindEvent::wsFindEvent(WebShellInitContext *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext),
mSearchString(nsnull),
mForward(JNI_FALSE),
mMatchCase(JNI_FALSE)
{
}
wsFindEvent::wsFindEvent(WebShellInitContext *yourInitContext, jstring searchString,
jboolean forward, jboolean matchCase) :
nsActionEvent(),
mInitContext(yourInitContext),
mSearchString(searchString),
mForward(forward),
mMatchCase(matchCase)
{
}
void *
wsFindEvent::handleEvent ()
{
void *result = nsnull;
nsresult rv = NS_ERROR_FAILURE;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
if (mInitContext) {
//First get the FindComponent object
NS_WITH_SERVICE(nsIFindComponent, findComponent, NS_IFINDCOMPONENT_CONTRACTID, &rv);
if (NS_FAILED(rv) || nsnull == findComponent) {
return (void *) rv;
}
nsCOMPtr<nsISupports> searchContext;
// get the nsISearchContext
// No seachString means this is Find, not FindNext.
if (mSearchString) {
nsCOMPtr<nsIDOMWindowInternal> domWindowInternal;
if (mInitContext->docShell != nsnull) {
nsCOMPtr<nsIInterfaceRequestor> interfaceRequestor(do_QueryInterface(mInitContext->docShell));
nsCOMPtr<nsIURI> url = nsnull;
rv = mInitContext->webNavigation->GetCurrentURI(getter_AddRefs(url));
if (NS_FAILED(rv) || nsnull == url) {
return (void *) rv;
}
if (interfaceRequestor != nsnull) {
rv = interfaceRequestor->GetInterface(NS_GET_IID(nsIDOMWindowInternal),
getter_AddRefs(domWindowInternal));
if (NS_FAILED(rv) || nsnull == domWindowInternal) {
return (void *) rv;
}
}
else
{
mInitContext->initFailCode = kFindComponentError;
return (void *) rv;
}
}
else {
mInitContext->initFailCode = kFindComponentError;
return (void *) rv;
}
// if we get here, we have a domWindowInternal
rv = findComponent->CreateContext(domWindowInternal, nsnull, getter_AddRefs(searchContext));
if (NS_FAILED(rv)) {
mInitContext->initFailCode = kSearchContextError;
return (void *) rv;
}
}
else {
// this is findNext
searchContext = mInitContext->searchContext;
}
if (!searchContext) {
mInitContext->initFailCode = kSearchContextError;
return (void *) NS_ERROR_FAILURE;
}
nsCOMPtr<nsISearchContext> srchcontext;
rv = searchContext->QueryInterface(NS_GET_IID(nsISearchContext), getter_AddRefs(srchcontext));
if (NS_FAILED(rv)) {
mInitContext->initFailCode = kSearchContextError;
return (void *) rv;
}
PRUnichar * aString;
srchcontext->GetSearchString(& aString);
PRUnichar * srchString = nsnull;
if (mSearchString) {
srchString = (PRUnichar *) ::util_GetStringChars(env, mSearchString);
// Check if String is NULL
if (nsnull == srchString) {
return (void *) NS_ERROR_NULL_POINTER;
}
srchcontext->SetSearchString(srchString);
srchcontext->SetSearchBackwards(!mForward);
srchcontext->SetCaseSensitive(mMatchCase);
}
PRBool found = PR_TRUE;
rv = findComponent->FindNext(srchcontext, &found);
result = (void *) rv;
if (mSearchString) {
::util_ReleaseStringChars(env, mSearchString, srchString);
::util_DeleteGlobalRef(env, mSearchString);
mSearchString = nsnull;
}
// Save in initContext struct for future findNextInPage calls
mInitContext->searchContext = srchcontext;
}
return result;
}
/*
* wsGetURLEvent
*/
wsGetURLEvent::wsGetURLEvent(WebShellInitContext *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
}
void *
wsGetURLEvent::handleEvent ()
{
void *result = nsnull;
if (mInitContext) {
nsISHistory* mHistory;
nsresult rv;
PRInt32 currentIndex;
char *currentURL = nsnull;
rv = mInitContext->webNavigation->GetSessionHistory(&mHistory);
if (NS_FAILED(rv)) {
return (void *) rv;
}
rv = mHistory->GetIndex(&currentIndex);
if (NS_FAILED(rv)) {
return result;
}
nsISHEntry * Entry;
rv = mHistory->GetEntryAtIndex(currentIndex, PR_FALSE, &Entry);
if (NS_FAILED(rv)) {
return result;
}
nsIURI * URI;
rv = Entry->GetURI(&URI);
if (NS_FAILED(rv)) {
return result;
}
rv = URI->GetSpec(&currentURL);
if (NS_FAILED(rv)) {
return result;
}
result = (void *) currentURL;
}
return result;
} // handleEvent()
wsSelectAllEvent::wsSelectAllEvent(WebShellInitContext *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
}
void *
wsSelectAllEvent::handleEvent ()
{
void *result = nsnull;
if (mInitContext) {
nsIContentViewer* contentViewer;
nsresult rv = nsnull;
rv = mInitContext->docShell->GetContentViewer(&contentViewer);
if (NS_FAILED(rv) || contentViewer==nsnull) {
mInitContext->initFailCode = kGetContentViewerError;
return (void *) rv;
}
nsCOMPtr<nsIContentViewerEdit> contentViewerEdit(do_QueryInterface(contentViewer));
rv = contentViewerEdit->SelectAll();
result = (void *) rv;
}
return result;
}
/* PENDING(ashuk): remove this from here and in the motif directory
wsViewSourceEvent::wsViewSourceEvent(nsIDocShell* docShell, PRBool viewMode) :
nsActionEvent(),
mDocShell(docShell),
mViewMode(viewMode)
{
}
void *
wsViewSourceEvent::handleEvent ()
{
if(mDocShell) {
if(mViewMode) {
nsresult rv = mDocShell->SetViewMode(nsIDocShell::viewSource);
return (void *) rv;
}
else
{
nsresult rv = mDocShell->SetViewMode(nsIDocShell::viewNormal);
return (void *) rv;
}
}
return nsnull;
}
*/
wsGetDOMEvent::wsGetDOMEvent(JNIEnv *yourEnv, jclass clz,
jmethodID yourID, jlong yourDoc) :
nsActionEvent(),
mEnv(yourEnv),
mClazz(clz),
mID(yourID),
mDoc(yourDoc)
{
}
void *
wsGetDOMEvent::handleEvent ()
{
void * result = nsnull;
if (mEnv != nsnull && mClazz != nsnull &&
mID != nsnull && mDoc != nsnull)
result = (void *) util_CallStaticObjectMethodlongArg(mEnv, mClazz, mID, mDoc);
return result;
}

View File

@ -0,0 +1,110 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
*/
/*
* nsActions.h
*/
#ifndef CurrentPageActionEvents_h___
#define CurrentPageActionEvents_h___
#include "nsActions.h"
#include "nsIContentViewerEdit.h"
#include "nsIFindComponent.h"
#include "nsISearchContext.h"
#include "nsISHistory.h"
#include "ns_util.h"
class wsCopySelectionEvent : public nsActionEvent {
public:
wsCopySelectionEvent(WebShellInitContext *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
};
class wsFindEvent : public nsActionEvent {
public:
wsFindEvent(WebShellInitContext *yourInitContext, jstring searchString,
jboolean forward, jboolean matchCase);
wsFindEvent(WebShellInitContext *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
jstring mSearchString;
jboolean mForward;
jboolean mMatchCase;
};
class wsGetURLEvent : public nsActionEvent {
public:
wsGetURLEvent (WebShellInitContext *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
};
class wsSelectAllEvent : public nsActionEvent {
public:
wsSelectAllEvent(WebShellInitContext *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
};
/* PENDING(ashuk): remove this from here and in the motif directory
class wsViewSourceEvent : public nsActionEvent {
public:
wsViewSourceEvent (nsIDocShell * docShell, PRBool viewMode);
void * handleEvent (void);
protected:
nsIDocShell * mDocShell;
PRBool mViewMode;
};
*/
class wsGetDOMEvent : public nsActionEvent {
public:
wsGetDOMEvent (JNIEnv *env, jclass clz, jmethodID yourID, jlong yourDoc);
void * handleEvent (void);
protected:
JNIEnv * mEnv;
jclass mClazz;
jmethodID mID;
jlong mDoc;
};
#endif /* CurrentPageActionEvents_h___ */
// EOF

View File

@ -31,56 +31,22 @@
#include "CurrentPageImpl.h"
#include "CurrentPageActionEvents.h"
#include "ns_util.h"
#include "rdf_util.h"
#include "nsActions.h"
#include "nsLayoutCID.h"
#include "nsCRT.h"
#include "nsIPresShell.h"
#include "nsCOMPtr.h"
#include "nsISupports.h"
#include "nsIFindComponent.h"
#include "nsISearchContext.h"
#include "nsIDocShell.h"
#include "nsIDocumentViewer.h"
#include "nsIDocument.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMNode.h"
#include "nsIDOMRange.h"
#include "nsIContentViewer.h"
#include "nsIServiceManager.h"
#include "nsIContentViewer.h"
#include "nsIContentViewerEdit.h"
#include "nsIDOMWindowInternal.h"
#include "nsIScriptGlobalObject.h"
#include "nsIInterfaceRequestor.h"
static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID);
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeCopyCurrentSelectionToSystemClipboard
(JNIEnv *env, jobject obj, jint webShellPtr)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
nsIContentViewer* contentViewer ;
nsresult rv = nsnull;
rv = initContext->docShell->GetContentViewer(&contentViewer);
if (NS_FAILED(rv) || contentViewer==nsnull ) {
initContext->initFailCode = kGetContentViewerError;
::util_ThrowExceptionToJava(env, "Exception: cant get ContentViewer from DocShell");
return;
}
nsCOMPtr<nsIContentViewerEdit> contentViewerEdit(do_QueryInterface(contentViewer));
if (initContext->initComplete) {
wsCopySelectionEvent * actionEvent = new wsCopySelectionEvent(contentViewerEdit);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostEvent(initContext, event);
wsCopySelectionEvent * actionEvent = new wsCopySelectionEvent(initContext);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostEvent(initContext, event);
}
}
@ -97,92 +63,20 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
//First get the FindComponent object
nsresult rv;
NS_WITH_SERVICE(nsIFindComponent, findComponent, NS_IFINDCOMPONENT_CONTRACTID, &rv);
if (NS_FAILED(rv) || nsnull == findComponent) {
initContext->initFailCode = kFindComponentError;
::util_ThrowExceptionToJava(env, "Exception: can't access FindComponent Service");
return;
}
nsCOMPtr<nsIDOMWindowInternal> domWindowInternal;
if (initContext->docShell != nsnull) {
nsCOMPtr<nsIInterfaceRequestor> interfaceRequestor(do_QueryInterface(initContext->docShell));
nsCOMPtr<nsIURI> url = nsnull;
rv = initContext->webNavigation->GetCurrentURI(getter_AddRefs(url));
if (NS_FAILED(rv) || nsnull == url) {
::util_ThrowExceptionToJava(env, "Exception: NULL URL passed to Find call");
return;
}
if (interfaceRequestor != nsnull) {
rv = interfaceRequestor->GetInterface(NS_GET_IID(nsIDOMWindowInternal), getter_AddRefs(domWindowInternal));
if (NS_FAILED(rv) || nsnull == domWindowInternal) {
initContext->initFailCode = kGetDOMWindowError;
::util_ThrowExceptionToJava(env, "Exception: cant get DOMWindow from DocShell");
return;
}
}
else
{
initContext->initFailCode = kFindComponentError;
::util_ThrowExceptionToJava(env, "Exception: cant get InterfaceRequestor from DocShell");
return;
}
}
else
{
initContext->initFailCode = kFindComponentError;
::util_ThrowExceptionToJava(env, "Exception: DocShell is not initialized");
return;
}
nsCOMPtr<nsISupports> searchContext;
rv = findComponent->CreateContext(domWindowInternal, nsnull, getter_AddRefs(searchContext));
if (NS_FAILED(rv)) {
initContext->initFailCode = kSearchContextError;
::util_ThrowExceptionToJava(env, "Exception: can't create SearchContext for Find");
return;
}
nsCOMPtr<nsISearchContext> srchcontext;
rv = searchContext->QueryInterface(NS_GET_IID(nsISearchContext), getter_AddRefs(srchcontext));
if (NS_FAILED(rv)) {
initContext->initFailCode = kSearchContextError;
::util_ThrowExceptionToJava(env, "Exception: can't create SearchContext for Find");
return;
}
PRUnichar * aString;
srchcontext->GetSearchString(& aString);
PRUnichar * srchString = (PRUnichar *) ::util_GetStringChars(env, searchString);
// Check if String is NULL
if (nsnull == srchString) {
::util_ThrowExceptionToJava(env, "Exception: NULL String passed to Find call");
jstring searchStringGlobalRef = (jstring) ::util_NewGlobalRef(env, searchString);
if (!searchStringGlobalRef) {
initContext->initFailCode = kFindComponentError;
::util_ThrowExceptionToJava(env, "Exception: Can't create global ref for search string");
return;
}
srchcontext->SetSearchString(srchString);
srchcontext->SetSearchBackwards(!forward);
srchcontext->SetCaseSensitive(matchCase);
// Pass searchContext to findComponent for the actual find call
PRBool found = PR_TRUE;
if (initContext->initComplete) {
wsFindEvent * actionEvent = new wsFindEvent(findComponent, srchcontext);
wsFindEvent * actionEvent = new wsFindEvent(initContext, searchStringGlobalRef,
forward, matchCase);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostEvent(initContext, event);
}
// Save in initContext struct for future findNextInPage calls
initContext->searchContext = srchcontext;
}
@ -194,40 +88,20 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
* Signature: (Z)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeFindNextInPage
(JNIEnv *env, jobject obj, jint webShellPtr, jboolean forward)
(JNIEnv *env, jobject obj, jint webShellPtr)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
//First get the FindComponent object
nsresult rv;
NS_WITH_SERVICE(nsIFindComponent, findComponent, NS_IFINDCOMPONENT_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
initContext->initFailCode = kFindComponentError;
::util_ThrowExceptionToJava(env, "Exception: can't access FindComponent Service");
return;
}
// Get the searchContext from the initContext struct
nsCOMPtr<nsISearchContext> searchContext = initContext->searchContext;
if (nsnull == searchContext) {
initContext->initFailCode = kSearchContextError;
::util_ThrowExceptionToJava(env, "Exception: NULL SearchContext received for FindNext");
return;
}
// Set the forward flag as per input parameter
searchContext->SetSearchBackwards(!forward);
// Pass searchContext to findComponent for the actual find call
PRBool found = PR_TRUE;
if (initContext->initComplete) {
wsFindEvent * actionEvent = new wsFindEvent(findComponent, searchContext);
if (initContext->initComplete && initContext->searchContext) {
wsFindEvent * actionEvent = new wsFindEvent(initContext);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostEvent(initContext, event);
}
}
}
@ -252,22 +126,11 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage
}
if (initContext->initComplete) {
// nsISessionHistory *yourHistory;
nsISHistory* yourHistory;
nsresult rv;
rv = initContext->webNavigation->GetSessionHistory(&yourHistory);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: can't get SessionHistory from webNavigation");
return urlString;
}
wsGetURLEvent * actionEvent = new wsGetURLEvent(yourHistory);
wsGetURLEvent * actionEvent = new wsGetURLEvent(initContext);
PLEvent * event = (PLEvent*) *actionEvent;
charResult = (char *) ::util_PostSynchronousEvent(initContext, event);
if (charResult != nsnull) {
urlString = ::util_NewStringUTF(env, (const char *) charResult);
}
@ -275,10 +138,10 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage
::util_ThrowExceptionToJava(env, "raptorWebShellGetURL Exception: GetURL() returned NULL");
return nsnull;
}
nsCRT::free(charResult);
}
return urlString;
}
@ -310,7 +173,11 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage
::util_ThrowExceptionToJava(env, "Exception: Can't get DOM Node.");
return nsnull;
}
result = env->CallStaticObjectMethod(clazz, mid, documentLong);
wsGetDOMEvent * actionEvent = new wsGetDOMEvent(env, clazz, mid, documentLong);
PLEvent * event = (PLEvent*) *actionEvent;
result = (jobject) ::util_PostSynchronousEvent(initContext, event);
return result;
}
@ -321,6 +188,8 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage
* Method: nativeGetSource
* Signature: ()Ljava/lang/String;
*/
/* PENDING(ashuk): remove this from here and in the motif directory
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSource
(JNIEnv * env, jobject jobj)
{
@ -328,12 +197,16 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage
return result;
}
*/
/*
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
* Method: nativeGetSourceBytes
* Signature: ()[B
*/
/* PENDING(ashuk): remove this from here and in the motif directory
JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSourceBytes
(JNIEnv * env, jobject jobj, jint webShellPtr, jboolean viewMode)
{
@ -346,12 +219,14 @@ JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentP
new wsViewSourceEvent(initContext->docShell, ((JNI_TRUE == viewMode)? PR_TRUE : PR_FALSE));
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostSynchronousEvent(initContext, event);
::util_PostEvent(initContext, event);
}
jbyteArray result = nsnull;
return result;
}
*/
/*
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
@ -376,21 +251,10 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeSelectAll
(JNIEnv * env, jobject obj, jint webShellPtr)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
nsIContentViewer* contentViewer ;
nsresult rv = nsnull;
rv = initContext->docShell->GetContentViewer(&contentViewer);
if (NS_FAILED(rv) || contentViewer==nsnull) {
initContext->initFailCode = kGetContentViewerError;
::util_ThrowExceptionToJava(env, "Exception: cant get ContentViewer from DocShell");
return;
}
nsCOMPtr<nsIContentViewerEdit> contentViewerEdit(do_QueryInterface(contentViewer));
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
if (initContext->initComplete) {
wsSelectAllEvent * actionEvent = new wsSelectAllEvent(contentViewerEdit);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostEvent(initContext, event);
}
wsSelectAllEvent * actionEvent = new wsSelectAllEvent(initContext);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostEvent(initContext, event);
}
}

View File

@ -0,0 +1,282 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
* Jason Mawdsley <jason@macadamian.com>
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
*/
/*
* HistoryActionEvents.cpp
*/
#include "HistoryActionEvents.h"
#include "ns_util.h"
/*
* wsCanBackEvent
*/
wsCanBackEvent::wsCanBackEvent(nsIWebNavigation* webNavigation) :
nsActionEvent(),
mWebNavigation(webNavigation)
{
}
void *
wsCanBackEvent::handleEvent ()
{
void *result = nsnull;
if (mWebNavigation) {
nsresult rv;
PRBool canGoBack;
rv = mWebNavigation->GetCanGoBack(&canGoBack);
if (NS_FAILED(rv)) {
return result;
}
result = (void *)canGoBack;
}
return result;
} // handleEvent()
/*
* wsCanForwardEvent
*/
wsCanForwardEvent::wsCanForwardEvent(nsIWebNavigation* webNavigation) :
nsActionEvent(),
mWebNavigation(webNavigation)
{
}
void *
wsCanForwardEvent::handleEvent ()
{
void *result = nsnull;
if (mWebNavigation) {
nsresult rv;
PRBool canGoForward;
rv = mWebNavigation->GetCanGoForward(&canGoForward);
if (NS_FAILED(rv)) {
return result;
}
result = (void *)canGoForward;
}
return result;
} // handleEvent()
/*
* wsBackEvent
*/
wsBackEvent::wsBackEvent(nsIWebNavigation* webNavigation) :
nsActionEvent(),
mWebNavigation(webNavigation)
{
}
void *
wsBackEvent::handleEvent ()
{
void *result = nsnull;
if (mWebNavigation) {
nsresult rv = mWebNavigation->GoBack();
result = (void *) rv;
}
return result;
} // handleEvent()
/*
* wsForwardEvent
*/
wsForwardEvent::wsForwardEvent(nsIWebNavigation* webNavigation) :
nsActionEvent(),
mWebNavigation(webNavigation)
{
}
void *
wsForwardEvent::handleEvent ()
{
void *result = nsnull;
if (mWebNavigation) {
nsresult rv = mWebNavigation->GoForward();
result = (void *) rv;
}
return result;
} // handleEvent()
/*
* wsGoToEvent
*/
wsGoToEvent::wsGoToEvent(nsIWebNavigation* webNavigation, PRInt32 historyIndex) :
nsActionEvent(),
mWebNavigation(webNavigation), mHistoryIndex(historyIndex)
{
}
void *
wsGoToEvent::handleEvent ()
{
void *result = nsnull;
nsresult rv = nsnull;
if (mWebNavigation) {
nsresult rv = mWebNavigation->GotoIndex(mHistoryIndex);
result = (void *) rv;
}
return result;
} // handleEvent()
/*
* wsGetHistoryLengthEvent
*/
wsGetHistoryLengthEvent::wsGetHistoryLengthEvent(WebShellInitContext
*yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
}
void *
wsGetHistoryLengthEvent::handleEvent ()
{
void *result = nsnull;
if (mInitContext) {
nsISHistory* sHistory;
PRInt32 historyLength = 0;
nsresult rv = mInitContext->webNavigation->
GetSessionHistory(&sHistory);
if ( NS_FAILED(rv)) {
return result;
}
rv = sHistory->GetCount(&historyLength);
result = (void *) historyLength;
}
return result;
} // handleEvent()
/*
* wsGetHistoryIndexEvent
*/
wsGetHistoryIndexEvent::wsGetHistoryIndexEvent(WebShellInitContext *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
}
void *
wsGetHistoryIndexEvent::handleEvent ()
{
void *result = nsnull;
if (mInitContext) {
PRInt32 historyIndex = 0;
nsISHistory* sHistory;
nsresult rv = mInitContext->webNavigation->GetSessionHistory(&sHistory);
rv = sHistory->GetIndex(&historyIndex);
result = (void *) historyIndex;
}
return result;
} // handleEvent()
/*
* wsGetURLForIndexEvent
*/
wsGetURLForIndexEvent::wsGetURLForIndexEvent(WebShellInitContext *yourInitContext,
PRInt32 historyIndex) :
nsActionEvent(),
mInitContext(yourInitContext),
mHistoryIndex(historyIndex)
{
}
void *
wsGetURLForIndexEvent::handleEvent ()
{
void *result = nsnull;
if (mInitContext) {
nsresult rv;
nsISHistory* sHistory;
rv = mInitContext->webNavigation->GetSessionHistory(&sHistory);
char *indexURL = nsnull;
nsISHEntry * Entry;
rv = sHistory->GetEntryAtIndex(mHistoryIndex, PR_FALSE, &Entry);
if (NS_FAILED(rv)) {
return result;
}
nsIURI * URI;
rv = Entry->GetURI(&URI);
if (NS_FAILED(rv)) {
return result;
}
rv = URI->GetSpec(&indexURL);
if (NS_FAILED(rv)) {
return result;
}
result = (void *) indexURL;
}
return result;
} // handleEvent()

View File

@ -0,0 +1,117 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
*/
/*
* nsActions.h
*/
#ifndef HistoryActionEvents_h___
#define HistoryActionEvents_h___
#include "nsActions.h"
#include "nsIWebNavigation.h"
#include "nsISHistory.h"
struct WebShellInitContext;
class wsCanBackEvent : public nsActionEvent {
public:
wsCanBackEvent (nsIWebNavigation* webNavigation);
void * handleEvent (void);
protected:
nsIWebNavigation * mWebNavigation;
};
class wsCanForwardEvent : public nsActionEvent {
public:
wsCanForwardEvent(nsIWebNavigation* webNavigation);
void * handleEvent (void);
protected:
nsIWebNavigation * mWebNavigation;
};
class wsBackEvent : public nsActionEvent {
public:
wsBackEvent (nsIWebNavigation* webNavigation);
void * handleEvent (void);
protected:
nsIWebNavigation * mWebNavigation;
};
class wsForwardEvent : public nsActionEvent {
public:
wsForwardEvent (nsIWebNavigation* webNavigation);
void * handleEvent (void);
protected:
nsIWebNavigation * mWebNavigation;
};
class wsGoToEvent : public nsActionEvent {
public:
wsGoToEvent (nsIWebNavigation* webNavigation,
PRInt32 historyIndex);
void * handleEvent (void);
protected:
nsIWebNavigation * mWebNavigation;
PRInt32 mHistoryIndex;
};
class wsGetHistoryLengthEvent : public nsActionEvent {
public:
wsGetHistoryLengthEvent(WebShellInitContext *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
};
class wsGetHistoryIndexEvent : public nsActionEvent {
public:
wsGetHistoryIndexEvent (WebShellInitContext *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
};
class wsGetURLForIndexEvent : public nsActionEvent {
public:
wsGetURLForIndexEvent(WebShellInitContext *yourInitContext,
PRInt32 historyIndex);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
PRInt32 mHistoryIndex;
};
#endif /* HistoryActionEvents_h___ */
// EOF

View File

@ -27,9 +27,10 @@
#include "HistoryImpl.h"
#include "HistoryActionEvents.h"
#include "ns_util.h"
#include "nsActions.h"
JNIEXPORT void JNICALL
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeBack
@ -50,7 +51,7 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeBack
new wsBackEvent(initContext->webNavigation);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostSynchronousEvent(initContext, event);
::util_PostEvent(initContext, event);
}
return;
@ -119,7 +120,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_na
new wsForwardEvent(initContext->webNavigation);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostSynchronousEvent(initContext, event);
::util_PostEvent(initContext, event);
}
return;
@ -195,16 +196,8 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetCurrentHistoryIn
}
if (initContext->initComplete) {
nsISHistory* sHistory;
nsresult rv = initContext->webNavigation->GetSessionHistory(&sHistory);
if ( NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: couldn't get History for passing to raptorWebShellGetHistoryIndex");
return result;
}
wsGetHistoryIndexEvent * actionEvent =
new wsGetHistoryIndexEvent(sHistory);
new wsGetHistoryIndexEvent(initContext);
PLEvent * event = (PLEvent*) *actionEvent;
voidResult = ::util_PostSynchronousEvent(initContext, event);
@ -221,7 +214,6 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeSetCurrentHistoryIn
{
JNIEnv * pEnv = env;
jobject jobj = obj;
void * voidResult = nsnull;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
@ -235,7 +227,7 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeSetCurrentHistoryIn
new wsGoToEvent(initContext->webNavigation, historyIndex);
PLEvent * event = (PLEvent*) *actionEvent;
voidResult = ::util_PostSynchronousEvent(initContext, event);
::util_PostEvent(initContext, event);
}
return;
@ -258,16 +250,8 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistoryLength
}
if (initContext->initComplete) {
nsISHistory* sHistory;
nsresult rv = initContext->webNavigation->GetSessionHistory(&sHistory);
if ( NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: couldn't get History for passing to raptorWebShellGetHistoryIndex");
return result;
}
wsGetHistoryLengthEvent * actionEvent =
new wsGetHistoryLengthEvent(sHistory);
new wsGetHistoryLengthEvent(initContext);
PLEvent * event = (PLEvent*) *actionEvent;
voidResult = ::util_PostSynchronousEvent(initContext, event);
@ -294,30 +278,21 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl
}
if (initContext->initComplete) {
nsISHistory* sHistory;
nsresult rv = initContext->webNavigation->GetSessionHistory(&sHistory);
if ( NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: couldn't get History for passing to raptorWebShellGetHistoryIndex");
return nsnull;
}
wsGetURLForIndexEvent * actionEvent =
new wsGetURLForIndexEvent(initContext->sHistory,
historyIndex);
PLEvent * event = (PLEvent*) *actionEvent;
charResult = (char *) ::util_PostSynchronousEvent(initContext, event);
if (charResult != nsnull) {
urlString = ::util_NewStringUTF(env, (const char *) charResult);
}
else {
::util_ThrowExceptionToJava(env, "raptorWebShellGetURL Exception: GetURL() returned nsnull");
return nsnull;
}
nsCRT::free(charResult);
wsGetURLForIndexEvent * actionEvent =
new wsGetURLForIndexEvent(initContext, historyIndex);
PLEvent * event = (PLEvent*) *actionEvent;
charResult = (char *) ::util_PostSynchronousEvent(initContext, event);
if (charResult != nsnull) {
urlString = ::util_NewStringUTF(env, (const char *) charResult);
}
else {
::util_ThrowExceptionToJava(env, "raptorWebShellGetURL Exception: GetURL() returned nsnull");
return nsnull;
}
nsCRT::free(charResult);
}
return urlString;

View File

@ -0,0 +1,414 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
*/
#include "InputStreamShim.h"
#include "jni_util.h"
#include "nsCRT.h"
#include "prlock.h"
#include "prlog.h"
#include "prthread.h"
static const PRInt32 buffer_increment = 1024;
static const PRInt32 do_close_code = -524;
InputStreamShim::InputStreamShim(jobject yourJavaStreamRef,
PRInt32 yourContentLength) :
mJavaStream(yourJavaStreamRef), mContentLength(yourContentLength),
mBuffer(nsnull), mBufferLength(0), mCountFromJava(0),
mCountFromMozilla(0), mAvailable(0), mAvailableForMozilla(0), mNumRead(0),
mDoClose(PR_FALSE), mDidClose(PR_FALSE), mLock(nsnull)
{
NS_INIT_REFCNT();
mLock = PR_NewLock();
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
}
InputStreamShim::~InputStreamShim()
{
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
::util_DeleteGlobalRef(env, mJavaStream);
mJavaStream = nsnull;
mContentLength = -1;
delete [] mBuffer;
mBuffer = nsnull;
mBufferLength = 0;
mAvailable = 0;
mAvailableForMozilla = 0;
mNumRead = 0;
mDoClose = PR_TRUE;
mDidClose = PR_TRUE;
PR_DestroyLock(mLock);
mLock = nsnull;
}
//NS_IMPL_ISUPPORTS(InputStreamShim, NS_GET_IID(nsIInputStream))
NS_IMETHODIMP_(nsrefcnt) InputStreamShim::AddRef(void)
{
NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");
NS_ASSERT_OWNINGTHREAD(InputStreamShim);
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "InputStreamShim", sizeof(*this));
return mRefCnt;
}
NS_IMETHODIMP_(nsrefcnt) InputStreamShim::Release(void)
{
NS_PRECONDITION(0 != mRefCnt, "dup release");
NS_ASSERT_OWNINGTHREAD(_class);
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "InputStreamShim");
if (mRefCnt == 0) {
mRefCnt = 1; /* stabilize */
NS_DELETEXPCOM(this);
return 0;
}
return mRefCnt;
}
NS_IMPL_QUERY_INTERFACE(InputStreamShim, NS_GET_IID(nsIInputStream))
nsresult InputStreamShim::doReadFromJava()
{
nsresult rv = NS_ERROR_FAILURE;
PR_ASSERT(mLock);
PR_Lock(mLock);
// first, see how much data is available
if (NS_FAILED(rv = doAvailable())) {
goto DRFJ_CLEANUP;
}
// if we have all our data, give the error appropriate result
if (0 == mAvailable ||
(0 != mCountFromJava &&
(((PRUint32)mContentLength) == mCountFromJava))) {
mDoClose = PR_TRUE;
doClose();
rv = NS_ERROR_NOT_AVAILABLE;
goto DRFJ_CLEANUP;
}
if (NS_FAILED(doRead())) {
rv = NS_ERROR_FAILURE;
goto DRFJ_CLEANUP;
}
rv = NS_OK;
// finally, do another check for available bytes
if (NS_FAILED(doAvailable())) {
rv = NS_ERROR_FAILURE;
goto DRFJ_CLEANUP;
}
if (0 == mAvailable ||
(0 != mCountFromJava &&
(((PRUint32)mContentLength) == mCountFromJava))) {
mDoClose = PR_TRUE;
doClose();
rv = NS_ERROR_NOT_AVAILABLE;
goto DRFJ_CLEANUP;
}
DRFJ_CLEANUP:
PR_Unlock(mLock);
return rv;
}
//
// Helper methods called from doReadFromJava
//
nsresult
InputStreamShim::doAvailable(void)
{
nsresult rv = NS_ERROR_FAILURE;
if (mDidClose) {
mAvailable = 0;
return NS_OK;
}
#ifdef BAL_INTERFACE
#else
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
jclass streamClass = nsnull;
jmethodID mid = nsnull;
if (!(streamClass = env->GetObjectClass(mJavaStream))) {
return rv;
}
if (!(mid = env->GetMethodID(streamClass, "available", "()I"))) {
return rv;
}
mAvailable = (PRUint32) env->CallIntMethod(mJavaStream, mid);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionClear();
return NS_ERROR_FAILURE;
}
rv = NS_OK;
#endif
return rv;
}
nsresult
InputStreamShim::doRead(void)
{
nsresult rv = NS_ERROR_FAILURE;
if (mDoClose) {
doClose();
return NS_ERROR_NOT_AVAILABLE;
}
PR_ASSERT(0 != mAvailable);
// if we don't have a buffer, create one
if (!mBuffer) {
if (0 < mContentLength) {
mBuffer = new char[mContentLength];
mBufferLength = mContentLength;
}
else {
// make sure we allocate enough buffer to store what is
// currently available.
if (mAvailable < buffer_increment) {
mBufferLength = buffer_increment;
}
else {
PRInt32 bufLengthCalc = mAvailable / buffer_increment;
mBufferLength = buffer_increment +
(bufLengthCalc * buffer_increment);
}
mBuffer = new char[mBufferLength];
}
if (!mBuffer) {
mBufferLength = 0;
return NS_ERROR_FAILURE;
}
}
else {
// See if we need to grow our buffer. If what we have plus what
// we're about to get is greater than the current buffer size...
if (mBufferLength < (mCountFromJava + mAvailable)) {
// create the new buffer
char *tBuffer = new char[mBufferLength + buffer_increment];
if (!tBuffer) {
return NS_ERROR_FAILURE;
}
// copy the old buffer into the new buffer
nsCRT::memcpy(tBuffer, mBuffer, mBufferLength);
// delete the old buffer
delete [] mBuffer;
// update mBuffer;
mBuffer = tBuffer;
// update our bufferLength
mBufferLength += buffer_increment;
}
}
#ifdef BAL_INTERFACE
#else
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
jmethodID mid = nsnull;
jclass streamClass = nsnull;
jbyteArray javaByteArray = nsnull;
if (!(streamClass = env->GetObjectClass(mJavaStream))) {
return rv;
}
if (!(mid = env->GetMethodID(streamClass, "read", "([BII)I"))) {
return rv;
}
if (!(javaByteArray = env->NewByteArray((jsize) mAvailable))) {
return rv;
}
mNumRead = env->CallIntMethod(mJavaStream, mid, javaByteArray, (jint) 0,
(jint) mAvailable);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionClear();
return NS_ERROR_FAILURE;
}
if (0 < mNumRead) {
// copy the bytes from java into our buffer
env->GetByteArrayRegion(javaByteArray, 0, (jint) mNumRead,
(jbyte *) (mBuffer + mCountFromJava));
mCountFromJava += mNumRead;
mAvailableForMozilla = mCountFromJava - mCountFromMozilla;
}
rv = NS_OK;
#endif
return rv;
}
nsresult
InputStreamShim::doClose(void)
{
nsresult rv = NS_ERROR_FAILURE;
PR_ASSERT(mDoClose);
if (mDidClose) {
return NS_OK;
}
#ifdef BAL_INTERFACE
#else
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
jclass streamClass = nsnull;
jmethodID mid = nsnull;
if (!(streamClass = env->GetObjectClass(mJavaStream))) {
return rv;
}
if (!(mid = env->GetMethodID(streamClass, "close", "()V"))) {
return rv;
}
env->CallVoidMethod(mJavaStream, mid);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionClear();
return NS_ERROR_FAILURE;
}
rv = NS_OK;
#endif
mDidClose = PR_TRUE;
return rv;
}
//
// nsIInputStream methods
//
NS_IMETHODIMP
InputStreamShim::Available(PRUint32* aResult)
{
nsresult rv = NS_ERROR_FAILURE;
if (!aResult) {
return NS_ERROR_NULL_POINTER;
}
PR_ASSERT(mLock);
PR_Lock(mLock);
*aResult = mAvailableForMozilla;
rv = NS_OK;
PR_Unlock(mLock);
return rv;
}
NS_IMETHODIMP
InputStreamShim::Close()
{
nsresult rv = NS_ERROR_FAILURE;
PR_ASSERT(mLock);
PR_Lock(mLock);
mDoClose = PR_TRUE;
rv = NS_OK;
PR_Unlock(mLock);
return rv;
}
NS_IMETHODIMP
InputStreamShim::Read(char* aBuffer, PRUint32 aCount, PRUint32 *aNumRead)
{
nsresult rv = NS_ERROR_FAILURE;
if (!aBuffer || !aNumRead) {
return NS_ERROR_NULL_POINTER;
}
*aNumRead = 0;
PR_ASSERT(mLock);
PR_ASSERT(mCountFromMozilla <= mCountFromJava);
PR_Lock(mLock);
// wait for java to load the buffer with some data
do {
if (mAvailableForMozilla == 0) {
PR_Unlock(mLock);
PR_Sleep(PR_INTERVAL_MIN);
PR_Lock(mLock);
}
else {
break;
}
} while ((!mDidClose) && (-1 != mNumRead));
if (mAvailableForMozilla) {
if (aCount <= (mCountFromJava - mCountFromMozilla)) {
// what she's asking for is less than or equal to what we have
nsCRT::memcpy(aBuffer, (mBuffer + mCountFromMozilla), aCount);
mCountFromMozilla += aCount;
*aNumRead = aCount;
}
else {
// what she's asking for is more than what we have
nsCRT::memcpy(aBuffer, (mBuffer + mCountFromMozilla),
(mCountFromJava - mCountFromMozilla));
*aNumRead = (mCountFromJava - mCountFromMozilla);
mCountFromMozilla += (mCountFromJava - mCountFromMozilla);
}
mAvailableForMozilla -= *aNumRead;
}
rv = NS_OK;
PR_Unlock(mLock);
return rv;
}
NS_IMETHODIMP
InputStreamShim::ReadSegments(nsWriteSegmentFun writer, void * closure, PRUint32 count, PRUint32 *_retval)
{
NS_NOTREACHED("ReadSegments");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
InputStreamShim::GetNonBlocking(PRBool *aNonBlocking)
{
NS_NOTREACHED("GetNonBlocking");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
InputStreamShim::GetObserver(nsIInputStreamObserver * *aObserver)
{
NS_NOTREACHED("GetObserver");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
InputStreamShim::SetObserver(nsIInputStreamObserver * aObserver)
{
NS_NOTREACHED("SetObserver");
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -0,0 +1,179 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
*/
#ifndef InputStreamShim_h
#define InputStreamShim_h
#include "nsIInputStream.h"
#include <jni.h>
class InputStreamShimActionEvent;
struct PRLock;
class InputStreamShim : public nsIInputStream
{
public:
InputStreamShim(jobject yourJavaStreamRef,
PRInt32 contentLength);
virtual ~InputStreamShim();
/**
* Called on NativeEventThread from
* wsLoadFromStreamEvent::handleEvent()
* When called, this method will read as up to mContentLength data
* from the Java input stream. Each read will update the number of
* bytes available on the stream.
* if the ivar mDoClose's value is PR_TRUE, the java
* InputStream should be closed.
* @return NS_ERROR_NOT_AVAILABLE when there is no more data.
* @return NS_OK when there is more data
* @return NS_ERROR_FAILURE when there has been an unrecoverable
* error
*/
nsresult doReadFromJava(void);
PRInt32 getContentLength() const { return mContentLength; };
private:
// called from doReadFromJava. These methods assume they execute
// within PR_Lock(mLock)
nsresult doAvailable(void);
nsresult doRead(void);
nsresult doClose(void);
private:
// nsISupports methods
NS_DECL_ISUPPORTS
// nsIInputStream methods
NS_DECL_NSIINPUTSTREAM
protected:
/**
* A global jobject reference for the java InputStream
* MUST be ::util_deleteGlobalRef'd in destructor.
*/
jobject mJavaStream;
/**
* the number of bytes we expect to read.
*/
PRInt32 mContentLength;
/**
* a dynamically allocated buffer, written by NativeEventThread
* calling out doReadFromJava(), read by Mozilla calling our Read().
* deleting this buffer signifies the java InputStream should be
* closed.
* MUST be deallocated in the destructor.
*/
char *mBuffer;
/**
* the length of the buffer
*/
PRUint32 mBufferLength;
/**
* Running sum of the total number of bytes read so far from java.
*/
PRUint32 mCountFromJava;
/**
* Running sum of the total number of bytes read so far by mozilla
*/
PRUint32 mCountFromMozilla;
/**
* The number of bytes available on the java InputStream
*/
PRUint32 mAvailable;
/**
* The number of bytes available in the buffer that haven't yet been
* read from Mozilla.
*/
PRUint32 mAvailableForMozilla;
/**
* The number of bytes read on the last read from the java
* InputStream
*/
PRInt32 mNumRead;
PRBool mDoClose;
PRBool mDidClose;
/**
* Provides mutex
*/
PRLock *mLock;
};
#endif // InputStreamShim_h

View File

@ -22,6 +22,30 @@ topsrcdir = $(DEPTH)
srcdir = $(topsrcdir)/java/webclient/src_moz
VPATH = $(topsrcdir)/java/webclient/src_moz
# IMPORTANT: on Linux, if building webclient with a non-debug mozilla
# tree, the libwidget_gtk.so binary produced will not work with
# webclient. Namely, the symbol handle_gdk_event__FP9_GdkEventPv will
# be defined locally, not globaly, as is required. For the webclient
# 1.0 release, we're going to bundle a libwidget_gtk.so with the xpi.
# If you want to do a non-debug build of your own, you must make sure
# yor libwidget_gtk.so is linked without these options:
# -DNDEBUG -DTRIMMED
# and with these options
# -DNDEBUG -DDEBUG_edburns
# If your libwidget_gtk.so has this symbol:
# 0003b2d0 T handle_gdk_event__FP9_GdkEventPv
# with the capital T, you're ok. The version of libwidget_gtk.so used
# in the webclient 1.0 bundle is available at:
# <http://www.mozilla.org/projects/blackwood/webclient/bin/1.0/libwidget_gtk.so>.
# to build WEBCLIENT_PACKAGE_BUILD on linux, grab libwidget_gtk.so from
# the above URL and put it in the same directory as this file.
# We don't need to build the stubs in the BAL case.
ifeq ($(BAL_INTERFACE),)
DIRS = motif
@ -45,14 +69,25 @@ CPPSRCS = \
rdf_util.cpp \
BookmarksImpl.cpp \
CBrowserContainer.cpp \
PromptActionEvents.cpp \
CurrentPageImpl.cpp \
CurrentPageActionEvents.cpp \
HistoryImpl.cpp \
HistoryActionEvents.cpp \
ISupportsPeer.cpp \
NativeEventThread.cpp \
NativeEventThreadActionEvents.cpp \
NavigationImpl.cpp \
NavigationActionEvents.cpp \
InputStreamShim.cpp \
RDFEnumeration.cpp \
RDFTreeNode.cpp \
RDFActionEvents.cpp \
wsRDFObserver.cpp \
WindowControlImpl.cpp \
WindowControlActionEvents.cpp \
PreferencesImpl.cpp \
PreferencesActionEvents.cpp \
WrapperFactoryImpl.cpp \
motif/MotifBrowserControlCanvas.cpp \
motif/gtkmozilla.cpp \
@ -103,10 +138,51 @@ PACKAGE_LIB=$(PACKAGE_DIR)/lib
PACKAGE_EXAMPLE=$(PACKAGE_DIR)/example
endif # PACKAGE_BUILD
clobber_all::
ifneq ($(WEBCLIENT_PACKAGE_BUILD),)
PACKAGE_VER = 1_0
PACKAGE_DIR = $(DIST)/javadev
PACKAGE_LIB = $(PACKAGE_DIR)/lib
PACKAGE_EXAMPLE = $(PACKAGE_DIR)/example
endif # WEBCLIENT_PACKAGE_BUILD
buildRunems:
ifeq ($(BAL_INTERFACE),)
ifneq ($(WEBCLIENT_PACKAGE_BUILD),)
@echo +++ Creating Commercial Package. Use runem to run the test browser.
@echo +++ Checking for special libwidget_gtk.so.
ifeq ($(OS_ARCH),Linux)
@if test ! -f libwidget_gtk.so ; then echo "You don't have libwidget_gtk.so, see the IMPORTANT section in Makefile.in!!!"; stopbuild; else echo "Found libwidget_gtk.so, continuing."; fi ;
chmod 775 libwidget_gtk.so
cp -f libwidget_gtk.so $(PACKAGE_LIB)
endif
rm -f runem_unix_commercial
@echo "#!/bin/csh -x" >> runem_unix_commercial
@echo ln -s -f "$$"MOZILLA_FIVE_HOME/javadev/lib/libjavadom.so "$$"MOZILLA_FIVE_HOME/components/libjavadom.so >> runem_unix_commercial
@echo setenv CLASSPATH "$$"MOZILLA_FIVE_HOME/javadev/lib/$(LIBRARY_NAME)_$(PACKAGE_VER).jar>> runem_unix_commercial
@echo setenv LD_LIBRARY_PATH "$$"MOZILLA_FIVE_HOME'"':'"'"$$"MOZILLA_FIVE_HOME/components'"':'"'"$$"MOZILLA_FIVE_HOME/javadev/lib'"':'"'"$$"LD_LIBRARY_PATH>> runem_unix_commercial
@echo "$$"JDKHOME/bin/java org.mozilla.webclient.test.EmbeddedMozilla "$$"MOZILLA_FIVE_HOME "$$"1 >> runem_unix_commercial
mkdir -p $(PACKAGE_EXAMPLE)
chmod 775 $(PACKAGE_EXAMPLE)
cp -f $(DIST)/bin/lib$(LIBRARY_NAME).so $(PACKAGE_LIB)
cp -f $(DIST)/bin/lib$(LIBRARY_NAME)stub.so $(PACKAGE_LIB)
cp -f $(DIST)/bin/libjavadomjni.so $(PACKAGE_LIB)
cp -f $(DIST)/bin/components/libjavadom.so $(PACKAGE_LIB)
chmod 775 $(PACKAGE_LIB)/lib$(LIBRARY_NAME).so
chmod 775 $(PACKAGE_LIB)/lib$(LIBRARY_NAME)stub.so
chmod 775 $(PACKAGE_LIB)/libjavadomjni.so
chmod 775 $(PACKAGE_LIB)/libjavadom.so
cp -f $(DEPTH)/java/webclient/src_moz/runem_unix_commercial $(PACKAGE_EXAMPLE)/runem
chmod 775 $(PACKAGE_EXAMPLE)/runem
cp -f $(DEPTH)/java/webclient/src_moz/install_win32.js $(DIST)/install.js
ifeq ($(OS_ARCH),Linux)
cd $(DIST); zip -r $(LIBRARY_NAME)_$(PACKAGE_VER)_linux.xpi install.js javadev
else
cd $(DIST); zip -r $(LIBRARY_NAME)_$(PACKAGE_VER)_solaris.xpi install.js javadev
endif
endif
ifeq ($(PACKAGE_BUILD),)
@echo +++ Creating runem. Use this to run the test browser.
rm -f runem
@ -123,6 +199,12 @@ else
cp $(topsrcdir)/dist/bin/libplugletjni.so $(PACKAGE_LIB)/libplugletjni.so.$(VERSION_NUMBER)
cp $(topsrcdir)/dist/bin/components/libpluglet.so $(PACKAGE_LIB)/libpluglet.so.$(VERSION_NUMBER)
cp $(topsrcdir)/dist/bin/components/libjavadom.so $(PACKAGE_LIB)/libjavadom.so.$(VERSION_NUMBER)
cp $(topsrcdir)/dist/bin/components/libbcorb.so $(PACKAGE_LIB)/libbcorb.so.$(VERSION_NUMBER)
cp $(topsrcdir)/dist/bin/components/libbcjavastubs.so $(PACKAGE_LIB)/libbcjavastubs.so.$(VERSION_NUMBER)
cp $(topsrcdir)/dist/bin/components/libjavaloader.so $(PACKAGE_LIB)/libjavaloader.so.$(VERSION_NUMBER)
cp $(topsrcdir)/dist/bin/components/libjavaSample.so $(PACKAGE_LIB)/libjavaSample.so.$(VERSION_NUMBER)
cp $(topsrcdir)/dist/bin/components/libbcTest.so $(PACKAGE_LIB)/libbcTest.so.$(VERSION_NUMBER)
cp $(topsrcdir)/dist/bin/components/libbcxpcomstubs.so $(PACKAGE_LIB)/libbcxpcomstubs.so.$(VERSION_NUMBER)
rm -f $(topsrcdir)/dist/bin/libwebclientstub.so
rm -f $(topsrcdir)/dist/lib/libwebclientstub.so
rm -f $(topsrcdir)/dist/bin/libwebclient.so
@ -136,6 +218,12 @@ else
rm -f $(topsrcdir)/dist/lib/components/libpluglet.so
rm -f $(topsrcdir)/dist/bin/components/libjavadom.so
rm -f $(topsrcdir)/dist/lib/components/libjavadom.so
rm -f $(topsrcdir)/dist/bin/components/libbcorb.so
rm -f $(topsrcdir)/dist/bin/components/libbcjavastubs.so
rm -f $(topsrcdir)/dist/bin/components/libjavaloader.so
rm -f $(topsrcdir)/dist/bin/components/libjavaSample.so
rm -f $(topsrcdir)/dist/bin/components/libbcTest.so
rm -f $(topsrcdir)/dist/bin/components/libbcxpcomstubs.so
chmod 555 $(PACKAGE_LIB)/libwebclientstub.so.$(VERSION_NUMBER)
chmod 555 $(PACKAGE_LIB)/libwebclient.so.$(VERSION_NUMBER)
chmod 555 $(PACKAGE_LIB)/libwc_share.a.$(VERSION_NUMBER)
@ -143,6 +231,18 @@ else
chmod 555 $(PACKAGE_LIB)/libplugletjni.so.$(VERSION_NUMBER)
chmod 555 $(PACKAGE_LIB)/libpluglet.so.$(VERSION_NUMBER)
chmod 555 $(PACKAGE_LIB)/libjavadom.so.$(VERSION_NUMBER)
chmod 555 $(PACKAGE_LIB)/libbcorb.so.$(VERSION_NUMBER)
chmod 555 $(PACKAGE_LIB)/libbcjavastubs.so.$(VERSION_NUMBER)
chmod 555 $(PACKAGE_LIB)/libjavaloader.so.$(VERSION_NUMBER)
chmod 555 $(PACKAGE_LIB)/libjavaSample.so.$(VERSION_NUMBER)
chmod 555 $(PACKAGE_LIB)/libbcTest.so.$(VERSION_NUMBER)
chmod 555 $(PACKAGE_LIB)/libbcxpcomstubs.so.$(VERSION_NUMBER)
if test ! -d $(PACKAGE_LIB)/libbcorb.so ; then ln -s libbcorb.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libbcorb.so ; else true ; fi ;
if test ! -d $(PACKAGE_LIB)/libbcjavastubs.so ; then ln -s libbcjavastubs.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libbcjavastubs.so ; else true ; fi ;
if test ! -d $(PACKAGE_LIB)/libjavaloader.so ; then ln -s libjavaloader.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libjavaloader.so ; else true ; fi ;
if test ! -d $(PACKAGE_LIB)/libjavaSample.so ; then ln -s libjavaSample.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libjavaSample.so ; else true ; fi ;
if test ! -d $(PACKAGE_LIB)/libbcTest.so ; then ln -s libbcTest.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libbcTest.so ; else true ; fi ;
if test ! -d $(PACKAGE_LIB)/libbcxpcomstubs.so ; then ln -s libbcxpcomstubs.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libbcxpcomstubs.so ; else true ; fi ;
if test ! -d $(PACKAGE_LIB)/libwc_share.a ; then ln -s libwc_share.a.$(VERSION_NUMBER) $(PACKAGE_LIB)/libwc_share.a ; else true ; fi ;
if test ! -d $(PACKAGE_LIB)/libwebclientstub.so ; then ln -s libwebclientstub.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libwebclientstub.so ; else true ; fi ;
if test ! -d $(PACKAGE_LIB)/libwebclient.so ; then ln -s libwebclient.so.$(VERSION_NUMBER) $(PACKAGE_LIB)/libwebclient.so ; else true ; fi ;
@ -158,3 +258,11 @@ endif # BAL_INTERFACE
install:: buildRunems
clobber_all:: clobber
ifneq ($(WEBCLIENT_PACKAGE_BUILD),)
rm -f runem_unix_commercial
rm -rf $(DIST)/javadev
rm -f $(DIST)/$(LIBRARY_NAME)_$(PACKAGE_VER)*.xpi
rm -f $(DIST)/install.js
endif

View File

@ -34,15 +34,26 @@ OBJS = \
.\$(OBJDIR)\dom_util.obj \
.\$(OBJDIR)\nsActions.obj \
.\$(OBJDIR)\CurrentPageImpl.obj \
.\$(OBJDIR)\CurrentPageActionEvents.obj \
.\$(OBJDIR)\HistoryImpl.obj \
.\$(OBJDIR)\HistoryActionEvents.obj \
.\$(OBJDIR)\BookmarksImpl.obj \
.\$(OBJDIR)\WrapperFactoryImpl.obj \
.\$(OBJDIR)\WindowControlImpl.obj \
.\$(OBJDIR)\WindowControlActionEvents.obj \
.\$(OBJDIR)\InputStreamShim.obj \
.\$(OBJDIR)\NavigationImpl.obj \
.\$(OBJDIR)\NavigationActionEvents.obj \
.\$(OBJDIR)\CBrowserContainer.obj \
.\$(OBJDIR)\PromptActionEvents.obj \
.\$(OBJDIR)\NativeEventThreadActionEvents.obj \
.\$(OBJDIR)\NativeEventThread.obj \
.\$(OBJDIR)\RDFEnumeration.obj \
.\$(OBJDIR)\RDFTreeNode.obj \
.\$(OBJDIR)\RDFActionEvents.obj \
.\$(OBJDIR)\wsRDFObserver.obj \
.\$(OBJDIR)\PreferencesImpl.obj \
.\$(OBJDIR)\PreferencesActionEvents.obj \
.\$(OBJDIR)\ISupportsPeer.obj \
$(NULL)
@ -120,21 +131,68 @@ INCS = \
# generate the jni header
!ifdef PACKAGE_BUILD
PERCENT=%
PACKAGE_VER = 1_0
#PENDING(edburns): jar name should be defined elewhere!
WEBCLIENT_JAR_NAME=webclient_$(PACKAGE_VER).jar
PACKAGE_DIR = $(DIST)\javadev
PACKAGE_LIB = $(PACKAGE_DIR)\lib
PACKAGE_EXAMPLE = $(PACKAGE_DIR)\example
!endif
PATH_SAVE=$(PATH)
buildRunems:
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
!ifdef BAL_INTERFACE
!else
!ifndef PACKAGE_BUILD
@echo +++ Creating runem.bat. Use this to run the test browser.
rm -f runem.bat
@echo $(PERL) ..\src_share\runem.pl org.mozilla.webclient.test.EmbeddedMozilla $(DEPTH) %1% >> runem.bat
!else
@echo +++ Creating Commercial Package. Use runem.bat to run the test browser.
@rm -f runem_win_commercial.bat
@set MOZILLA_FIVE_HOME=
@set PATH=
@set JDKHOME=
@echo copy %MOZILLA_FIVE_HOME%\javadev\lib\javadom.dll %MOZILLA_FIVE_HOME%\components>> runem_win_commercial.bat
@echo set PATH=%MOZILLA_FIVE_HOME%\javadev\lib;%MOZILLA_FIVE_HOME%;%MOZILLA_FIVE_HOME%\components;%PATH%>> runem_win_commercial.bat
@echo set CLASSPATH=%MOZILLA_FIVE_HOME%\javadev\lib\$(WEBCLIENT_JAR_NAME)>> runem_win_commercial.bat
@echo %JDKHOME%\bin\java org.mozilla.webclient.test.EmbeddedMozilla %MOZILLA_FIVE_HOME% %1% >> runem_win_commercial.bat
@set PATH=$(PATH_SAVE)
-mkdir $(PACKAGE_EXAMPLE)
chmod 775 $(PACKAGE_EXAMPLE)
cp $(DIST)\bin\webclient.dll $(PACKAGE_LIB)\webclient.dll
cp $(DIST)\bin\javadomjni.dll $(PACKAGE_LIB)\javadomjni.dll
cp $(DIST)\bin\components\javadom.dll $(PACKAGE_LIB)\javadom.dll
chmod 775 $(PACKAGE_LIB)\webclient.dll
chmod 775 $(PACKAGE_LIB)\javadomjni.dll
chmod 775 $(PACKAGE_LIB)\javadom.dll
cp -f $(DEPTH)\java\webclient\src_moz\runem_win_commercial.bat $(PACKAGE_EXAMPLE)\runem.bat
chmod 775 $(PACKAGE_EXAMPLE)\runem.bat
cp -f $(DEPTH)\java\webclient\src_moz\install_win32.js $(DIST)\install.js
cd $(DIST)
zip -r $(DLLNAME)_$(PACKAGE_VER)_win32.xpi install.js javadev
!endif
!endif
install:: $(DLL) buildRunems
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
install:: $(DLL) buildRunems
clobber_all:: clobber
!ifdef PACKAGE_BUILD
rm -rf $(DIST)\javadev
rm -f $(DIST)\$(DLLNAME)_$(PACKAGE_VER).xpi
rm -f $(DIST)\install.js
!endif
clobber::
rm -f $(DIST)\bin\$(DLLNAME).dll
!ifdef PACKAGE_BUILD
rm -f runem_win_commercial.bat
!else
rm -f runem.bat
!endif

View File

@ -53,6 +53,7 @@
#include "nsIEventQueueService.h" // for PLEventQueue
#include "nsRepository.h"
#include "nsIServiceManager.h" // for do_GetService
#include "nsISHistory.h" // for sHistory
#include "nsIPref.h" // for preferences
#include "nsIThread.h" // for PRThread
#include "nsIDocShell.h"
@ -62,7 +63,7 @@
#include "nsIEventQueueService.h"
#include "nsIThread.h"
//nsIWebShell is included in ns_util.h
#include "NativeEventThreadActionEvents.h"
#include "prlog.h" // for PR_ASSERT
@ -70,6 +71,12 @@
#include <unistd.h>
#include "gdksuperwin.h"
#include "gtkmozarea.h"
extern "C" {
static int wc_x_error (Display *display,
XErrorEvent *error);
}
#endif
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
@ -117,6 +124,29 @@ extern const char * gBinDir; // defined in WrapperFactoryImpl.cpp
// Local functions
//
#ifdef XP_UNIX
static int
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,
error->request_code,
error->minor_code);
}
return 0;
}
#endif
/**
* Called from InitMozillaStuff().
@ -127,7 +157,7 @@ int processEventLoop(WebShellInitContext * initContext);
/**
* Called from Java nativeInitialize to create the webshell, history
* Called from Java nativeInitialize to create the webshell
* and other mozilla things, then start the event loop.
*/
@ -138,11 +168,11 @@ nsresult InitMozillaStuff (WebShellInitContext * arg);
// Local data
//
nsISHistory *gHistory = nsnull;
nsIComponentManager *gComponentManager = nsnull;
static PRBool gFirstTime = PR_TRUE;
PLEventQueue * gActionQueue = nsnull;
PRThread * gEmbeddedThread = nsnull;
nsISHistory *gHistory = nsnull;
char * errorMessages[] = {
"No Error",
@ -199,7 +229,12 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
"NULL webShellPtr passed to nativeProcessEvents.");
return;
}
processEventLoop(initContext);
void* threadId = PR_GetCurrentThread();
if (threadId == (void *) gEmbeddedThread) {
// printf("--------- Thread ID ---- %p\n",gEmbeddedThread);
processEventLoop(initContext);
}
}
/**
@ -378,20 +413,20 @@ int processEventLoop(WebShellInitContext * initContext)
#endif
::PR_Sleep(PR_INTERVAL_NO_WAIT);
if ((initContext->initComplete) && (initContext->actionQueue)) {
if ((initContext->initComplete) && (gActionQueue)) {
PL_ENTER_EVENT_QUEUE_MONITOR(initContext->actionQueue);
PL_ENTER_EVENT_QUEUE_MONITOR(gActionQueue);
if (::PL_EventAvailable(initContext->actionQueue)) {
if (::PL_EventAvailable(gActionQueue)) {
PLEvent * event = ::PL_GetEvent(initContext->actionQueue);
PLEvent * event = ::PL_GetEvent(gActionQueue);
if (event != nsnull) {
::PL_HandleEvent(event);
}
}
PL_EXIT_EVENT_QUEUE_MONITOR(initContext->actionQueue);
PL_EXIT_EVENT_QUEUE_MONITOR(gActionQueue);
}
if (initContext->stopThread) {
@ -437,13 +472,13 @@ void DoMozInitialization(WebShellInitContext * initContext)
nsresult rv = nsnull;
JNIEnv * env = initContext->env;
const char * BinDir = gBinDir;
rv = NS_NewLocalFile(BinDir, PR_TRUE, &pathFile);
if (NS_FAILED(rv)) {
::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);
@ -458,7 +493,7 @@ void DoMozInitialization(WebShellInitContext * initContext)
PR_SetLogFile(webclientLogFile);
// If this fails, it just goes to stdout/stderr
}
gComponentManager->RegisterComponentLib(kSHistoryCID, nsnull,
nsnull, APPSHELL_DLL,
PR_FALSE, PR_FALSE);
@ -469,10 +504,40 @@ void DoMozInitialization(WebShellInitContext * initContext)
::util_ThrowExceptionToJava(env, "Can't get the profile manager.");
return;
}
char *argv[1];
PRInt32 numProfiles=0;
rv = profile->GetProfileCount(&numProfiles);
char *argv[3];
int i, argc = 0;
argv[0] = strdup(gBinDir);
rv = cmdLine->Initialize(1, argv);
nsCRT::free(argv[0]);
if (numProfiles > 1) {
PRUnichar * Names;
rv = profile->GetProfileList(&Names);
// PENDING(edburns): fix for 70656. Really we should have a way
// for the embedding app to specify which profile to use.
// For now we just get the name of the first profile.
argv[1] = strdup("-p");
char * temp = new char[100]; // de-allocated in following for loop
for (i = 0; i<100; i++) {
if ((char) Names[i] != ',')
temp[i] = (char) Names[i];
else {
temp[i] = '\0';
break;
}
}
nsCRT::free(Names);
argv[2] = temp;
argc = 3;
printf("debug: edburns: argv[1]: %s argv[2]: %s\n", argv[1],
argv[2]);
}
else {
argc = 1;
}
rv = cmdLine->Initialize(argc, argv);
for (i = 0; i < argc; i++) {
nsCRT::free(argv[i]);
}
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Can't initialize nsICmdLineService.");
return;
@ -495,69 +560,70 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
PR_ASSERT(gComponentManager);
nsCOMPtr<nsIEventQueueService>
aEventQService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID);
if (gFirstTime) {
printf ("\n\nCreating Event Queue \n\n");
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;
}
// 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));
}
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 for the UI thread...
if (!aEventQService) {
initContext->initFailCode = kEventQueueError;
return rv;
}
// Create the event queue.
rv = aEventQService->CreateThreadEventQueue();
initContext->embeddedThread = PR_GetCurrentThread();
// Create the event queue.
rv = aEventQService->CreateThreadEventQueue();
gEmbeddedThread = PR_GetCurrentThread();
// Create the action queue
if (initContext->embeddedThread) {
if (initContext->actionQueue == nsnull) {
printf("InitMozillaStuff(%lx): Create the action queue\n", initContext);
// Create the action queue
if (gEmbeddedThread) {
// We need to do something different for Unix
nsIEventQueue * EQueue = nsnull;
if (gActionQueue == nsnull) {
printf("InitMozillaStuff(%lx): Create the action queue\n", initContext);
rv = aEventQService->GetThreadEventQueue(initContext->embeddedThread,
// We need to do something different for Unix
nsIEventQueue * EQueue = nsnull;
rv = aEventQService->GetThreadEventQueue(gEmbeddedThread,
&EQueue);
if (NS_FAILED(rv)) {
initContext->initFailCode = kCreateWebShellError;
return rv;
}
if (NS_FAILED(rv)) {
initContext->initFailCode = kCreateWebShellError;
return rv;
}
#ifdef XP_UNIX
gdk_input_add(EQueue->GetEventQueueSelectFD(),
GDK_INPUT_READ,
event_processor_callback,
EQueue);
gdk_input_add(EQueue->GetEventQueueSelectFD(),
GDK_INPUT_READ,
event_processor_callback,
EQueue);
#endif
PLEventQueue * plEventQueue = nsnull;
PLEventQueue * plEventQueue = nsnull;
EQueue->GetPLEventQueue(&plEventQueue);
initContext->actionQueue = plEventQueue;
EQueue->GetPLEventQueue(&plEventQueue);
gActionQueue = plEventQueue;
}
}
else {
initContext->initFailCode = kCreateWebShellError;
return NS_ERROR_UNEXPECTED;
}
}
else {
initContext->initFailCode = kCreateWebShellError;
return NS_ERROR_UNEXPECTED;
}
// Setup Prefs obj and read default prefs
if (gFirstTime) {
nsCOMPtr<nsIPref> mPrefs(do_GetService(kPrefCID));
@ -570,7 +636,9 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
gFirstTime = PR_FALSE;
}
PRBool allowPlugins = PR_TRUE;
/*
// Create the WebBrowser.
nsCOMPtr<nsIWebBrowser> webBrowser = nsnull;
webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
@ -641,27 +709,11 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
nsCOMPtr<nsIDocumentLoaderObserver> observer(do_QueryInterface(initContext->browserContainer));
initContext->docShell->SetDocLoaderObserver(observer);
if (nsnull == gHistory) {
rv = gComponentManager->CreateInstance(kSHistoryCID, nsnull,
kISHistoryIID,
(void**)&gHistory);
if (NS_FAILED(rv)) {
initContext->initFailCode = kHistoryWebShellError;
return rv;
}
}
printf("Creation Done.....\n");
// Get the WebNavigation Object from the DocShell
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(initContext->docShell));
initContext->webNavigation = webNav;
// Set the History
// initContext->webNavigation->SetSessionHistory(gHistory);
// Save the sessionHistory in the initContext
// initContext->sHistory = gHistory;
printf("Show the webBrowser\n");
// Show the webBrowser
rv = initContext->baseWindow->SetVisibility(PR_TRUE);
@ -672,12 +724,27 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
initContext->initComplete = TRUE;
*/
wsRealizeBrowserEvent * actionEvent = new wsRealizeBrowserEvent(initContext);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostSynchronousEvent(initContext, event);
#if DEBUG_RAPTOR_CANVAS
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("InitMozillaStuff(%lx): enter event loop\n", initContext));
}
#endif
#ifdef XP_UNIX
// The gdk_x_error function exits in some cases, we don't
// want that.
XSetErrorHandler(wc_x_error);
#endif
// Just need to loop once to clear out events before returning
processEventLoop(initContext);

View File

@ -0,0 +1,160 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ed Burns <edburns@acm.org>
*/
/*
* NativeEventThreadActionEvents.cpp
*/
#include "NativeEventThreadActionEvents.h"
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kISHistoryIID, NS_ISHISTORY_IID);
static NS_DEFINE_CID(kSHistoryCID, NS_SHISTORY_CID);
/*
* wsRealizeBrowserEvent
*/
wsRealizeBrowserEvent::wsRealizeBrowserEvent(WebShellInitContext * yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
}
void *
wsRealizeBrowserEvent::handleEvent ()
{
nsresult rv = nsnull;
nsCOMPtr<nsIWebBrowser> webBrowser = nsnull;
webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
mInitContext->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));
mInitContext->baseWindow = docShellAsWin;
printf ("Init the baseWindow\n");
#ifdef XP_UNIX
GtkWidget * bin;
bin = (GtkWidget *) mInitContext->gtkWinPtr;
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3, ("Ashu Debugs - Inside InitMozillaStuff(%lx): - before Init Call...\n", mInitContext));
}
rv = mInitContext->baseWindow->InitWindow((nativeWindow) bin, nsnull, mInitContext->x, mInitContext->y, mInitContext->w, mInitContext->h);
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3, ("Ashu Debugs - Inside InitMozillaStuff(%lx): - after Init Call...\n", mInitContext));
}
#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
nsCOMPtr<nsIDocumentLoaderObserver> observer(do_QueryInterface(mInitContext->browserContainer));
mInitContext->docShell->SetDocLoaderObserver(observer);
if (nsnull == gHistory) {
rv = gComponentManager->CreateInstance(kSHistoryCID, nsnull,
kISHistoryIID,
(void**)&gHistory);
if (NS_FAILED(rv)) {
mInitContext->initFailCode = kHistoryWebShellError;
return (void *) rv;
}
}
printf("Creation Done.....\n");
// Get the WebNavigation Object from the DocShell
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mInitContext->docShell));
mInitContext->webNavigation = webNav;
// 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);
if (NS_FAILED(rv)) {
mInitContext->initFailCode = kShowWebShellError;
return (void *) rv;
}
mInitContext->initComplete = TRUE;
return (void *) nsnull;
} // handleEvent()
wsRealizeBrowserEvent::~wsRealizeBrowserEvent ()
{
}

View File

@ -0,0 +1,69 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ed Burns <edburns@acm.org>
*/
/*
* nsActions.h
*/
#ifndef NativeEventThreadActionEvents_h___
#define NativeEventThreadActionEvents_h___
#include "NativeEventThread.h"
#include "CBrowserContainer.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsActions.h"
#include "nsIDocShell.h"
#include "nsIBaseWindow.h"
#include "nsIDocShellTreeItem.h"
#include "nsCWebBrowser.h"
#include "nsISHistory.h"
#ifdef XP_UNIX
#include <unistd.h>
#include "gdksuperwin.h"
#include "gtkmozarea.h"
#endif
#ifdef XP_PC
#include <windows.h>
#endif
struct WebShellInitContext;
class wsRealizeBrowserEvent : public nsActionEvent {
public:
wsRealizeBrowserEvent (WebShellInitContext * yourInitContext);
~wsRealizeBrowserEvent ();
void * handleEvent (void);
protected:
WebShellInitContext * mInitContext;
};
#endif /* NativeEventThreadActionEvents_h___ */
// EOF

View File

@ -0,0 +1,258 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
* Jason Mawdsley <jason@macadamian.com>
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
*/
/*
* NavigationActionEvents.cpp
*/
#include "NavigationActionEvents.h"
#include "ns_util.h"
#include "InputStreamShim.h"
#include "nsNetUtil.h"
/*
* wsLoadURLEvent
*/
wsLoadURLEvent::wsLoadURLEvent(nsIWebNavigation* webNavigation, PRUnichar * urlString, PRInt32 urlLength) :
nsActionEvent(),
mWebNavigation(webNavigation),
mURL(nsnull)
{
mURL = new nsString(urlString, urlLength);
}
void *
wsLoadURLEvent::handleEvent ()
{
void* threadId = PR_GetCurrentThread();
printf ("+++++++++++++++++++++ Thread Id ---- %p\n\n", threadId);
if (mWebNavigation && mURL) {
nsresult rv = mWebNavigation->LoadURI(mURL->GetUnicode(), nsIWebNavigation::LOAD_FLAGS_NONE);
}
return nsnull;
} // handleEvent()
wsLoadURLEvent::~wsLoadURLEvent ()
{
if (mURL != nsnull)
delete mURL;
}
wsLoadFromStreamEvent::wsLoadFromStreamEvent(WebShellInitContext *yourInitCx,
void *globalStream,
nsString &uriToCopy,
const char *contentTypeToCopy,
PRInt32 contentLength,
void *globalLoadProperties) :
nsActionEvent(), mInitContext(yourInitCx), mUriString(uriToCopy),
mContentType(PL_strdup(contentTypeToCopy)),
mProperties(globalLoadProperties), mShim(nsnull)
{
mShim = new InputStreamShim((jobject) globalStream, contentLength);
NS_IF_ADDREF(mShim);
}
wsLoadFromStreamEvent::wsLoadFromStreamEvent(WebShellInitContext *yourInitCx,
InputStreamShim *yourShim) :
nsActionEvent(), mInitContext(yourInitCx), mUriString(nsnull),
mContentType(nsnull), mProperties(nsnull), mShim(yourShim)
{
}
/**
* This funky handleEvent allows the java InputStream to be read from
* the correct thread (the NativeEventThread), while, on a separate
* thread, mozilla's LoadFromStream reads from our nsIInputStream. This
* is accomplished using a "shim" class, InputStreamShim.
* InputStreamShim is an nsIInputStream, but it also maintains
* information on how to read from the java InputStream. The important
* thing is that InputStreamShim::doReadFromJava() is called on
* NativeEventThread() until all the data is read. This is accomplished
* by having this wsLoadFromStream instance copy itself and re-enqueue
* itself, if there is more data to read.
*/
void *
wsLoadFromStreamEvent::handleEvent ()
{
nsresult rv = NS_ERROR_FAILURE;
nsresult readFromJavaStatus = NS_ERROR_FAILURE;
nsCOMPtr<nsIURI> uri;
wsLoadFromStreamEvent *repeatEvent = nsnull;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
// we must have both mInitContext and mShim to do anything
if (!mInitContext || !mShim) {
return (void *) rv;
}
// Try to read as much as possible off the java InputStream
// into the shim's internal buffer.
// see InputShimStream::doReadFromJava() for the meaning of the
// return values. They are very important.
readFromJavaStatus = mShim->doReadFromJava();
if (NS_ERROR_FAILURE == readFromJavaStatus) {
NS_IF_RELEASE(mShim);
return (void *) readFromJavaStatus;
}
// if this is the first time handleEvent has been called for this
// InputStreamShim instance.
if (mContentType) {
rv = NS_NewURI(getter_AddRefs(uri), mUriString);
if (!uri) {
return (void *) rv;
}
// PENDING(edburns): turn the mProperties jobject into an
// nsIDocShellLoadInfo instance.
// Kick off a LoadStream. This will cause
// InputStreamShim::Read() to be called,
rv = mInitContext->docShell->LoadStream(mShim, uri, mContentType,
mShim->getContentLength(),
nsnull);
if (mProperties) {
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
::util_DeleteGlobalRef(env, (jobject) mProperties);
mProperties = nsnull;
}
// make it so we don't issue multiple LoadStream calls
// for this InputStreamShim instance.
nsCRT::free(mContentType);
mContentType = nsnull;
}
// if there is more data
if (NS_OK == readFromJavaStatus){
// and we can create a copy of ourselves
if (repeatEvent = new wsLoadFromStreamEvent(mInitContext, mShim)) {
// do the loop
::util_PostEvent(mInitContext, (PLEvent *) *repeatEvent);
rv = NS_OK;
}
else {
NS_IF_RELEASE(mShim);
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
if (NS_ERROR_NOT_AVAILABLE == readFromJavaStatus) {
NS_IF_RELEASE(mShim);
rv = NS_OK;
}
return (void *) rv;
} // handleEvent()
wsLoadFromStreamEvent::~wsLoadFromStreamEvent ()
{
nsCRT::free(mContentType);
mContentType = nsnull;
}
/*
* wsStopEvent
*/
wsStopEvent::wsStopEvent(nsIWebNavigation* webNavigation) :
nsActionEvent(),
mWebNavigation(webNavigation)
{
}
void *
wsStopEvent::handleEvent ()
{
if (mWebNavigation) {
nsresult rv = mWebNavigation->Stop();
}
return nsnull;
} // handleEvent()
// Added by Mark Goddard OTMP 9/2/1999
/*
* wsRefreshEvent
*/
wsRefreshEvent::wsRefreshEvent(nsIWebNavigation* webNavigation, PRInt32 reloadType) :
nsActionEvent(),
mWebNavigation(webNavigation),
mReloadType(reloadType)
{
}
void *
wsRefreshEvent::handleEvent ()
{
if (mWebNavigation) {
nsresult rv = mWebNavigation->Reload(mReloadType);
return (void *) rv;
}
return nsnull;
} // handleEvent()
wsSetPromptEvent::wsSetPromptEvent(wcIBrowserContainer* aBrowserContainer,
jobject aUserPrompt) :
nsActionEvent(),
mBrowserContainer(aBrowserContainer),
mUserPrompt(aUserPrompt)
{
}
void *
wsSetPromptEvent::handleEvent ()
{
if (mBrowserContainer && mUserPrompt) {
mBrowserContainer->SetPrompt(mUserPrompt);
}
return nsnull;
} // handleEvent()

View File

@ -0,0 +1,116 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
*/
/*
* nsActions.h
*/
#ifndef NavigationActionEvents_h___
#define NavigationActionEvents_h___
#include "nsActions.h"
#include "nsIWebNavigation.h"
#include "nsString.h"
#include "ns_util.h"
struct WebShellInitContext;
class InputStreamShim;
class wsLoadURLEvent : public nsActionEvent {
public:
wsLoadURLEvent (nsIWebNavigation* webNavigation, PRUnichar * urlString, PRInt32 urlLength);
~wsLoadURLEvent ();
void * handleEvent (void);
protected:
nsIWebNavigation * mWebNavigation;
nsString * mURL;
};
class wsLoadFromStreamEvent : public nsActionEvent {
public:
wsLoadFromStreamEvent(WebShellInitContext *yourInitContext,
void *globalStream,
nsString &uriToCopy,
const char *contentTypeToCopy,
PRInt32 contentLength, void *globalLoadProperties);
virtual ~wsLoadFromStreamEvent();
void * handleEvent(void);
private:
wsLoadFromStreamEvent(WebShellInitContext *yourDocShell,
InputStreamShim *yourShim);
protected:
WebShellInitContext *mInitContext;
nsString mUriString;
char *mContentType; // MUST be delete'd in destructor
void * mProperties; // MUST be util_deleteGlobalRef'd in destructor.
InputStreamShim *mShim; // DO NOT delete this in the destructor
};
class wsStopEvent : public nsActionEvent {
public:
wsStopEvent (nsIWebNavigation* webNavigation);
void * handleEvent (void);
protected:
nsIWebNavigation * mWebNavigation;
};
// added by Mark Goddard OTMP 9/2/1999
class wsRefreshEvent : public nsActionEvent {
public:
wsRefreshEvent (nsIWebNavigation* webNavigation,
PRInt32 reloadType);
void * handleEvent (void);
protected:
nsIWebNavigation * mWebNavigation;
PRInt32 mReloadType;
};
class wsSetPromptEvent : public nsActionEvent {
public:
wsSetPromptEvent (wcIBrowserContainer* aBrowserContainer, jobject aUserPrompt);
void * handleEvent (void);
protected:
wcIBrowserContainer * mBrowserContainer;
jobject mUserPrompt;
};
#endif /* NavigationActionEvents_h___ */
// EOF

View File

@ -28,9 +28,9 @@
#include "NavigationImpl.h"
#include "ns_util.h"
#include "NavigationActionEvents.h"
#include "nsActions.h"
#include "ns_util.h"
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeLoadURL
(JNIEnv *env, jobject obj, jint webShellPtr, jstring urlString)
@ -77,12 +77,79 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl
::util_ReleaseStringChars(env, urlString, (const jchar *) urlStringChars);
}
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeLoadFromStream
(JNIEnv *env, jobject obj, jint webShellPtr, jobject stream, jstring uri,
jstring contentType, jint contentLength, jobject loadProperties)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
PRUnichar *uriStringUniChars = nsnull;
PRInt32 uriStringUniCharsLength = -1;
const char *contentTypeChars = nsnull;
jobject globalStream = nsnull;
jobject globalLoadProperties = nsnull;
nsString *uriNsString = nsnull;
wsLoadFromStreamEvent *actionEvent = nsnull;
if (initContext == nsnull || !initContext->initComplete) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeLoadFromStream");
return;
}
uriStringUniChars = (PRUnichar *) ::util_GetStringChars(env, uri);
uriStringUniCharsLength = (PRInt32) ::util_GetStringLength(env, uri);
contentTypeChars = (char *) ::util_GetStringUTFChars(env, contentType);
if (!uriStringUniChars || !contentTypeChars) {
::util_ThrowExceptionToJava(env, "Exception: nativeLoadFromStream: unable to convert java string to native format");
goto NLFS_CLEANUP;
}
if (!(uriNsString =
new nsString(uriStringUniChars, uriStringUniCharsLength))) {
::util_ThrowExceptionToJava(env, "Exception: nativeLoadFromStream: unable to convert native string to nsString");
goto NLFS_CLEANUP;
}
// the deleteGlobalRef is done in the wsLoadFromStream destructor
if (!(globalStream = ::util_NewGlobalRef(env, stream))) {
::util_ThrowExceptionToJava(env, "Exception: nativeLoadFromStream: unable to create gloabal ref to stream");
goto NLFS_CLEANUP;
}
if (loadProperties) {
// the deleteGlobalRef is done in the wsLoadFromStream destructor
if (!(globalLoadProperties =
::util_NewGlobalRef(env, loadProperties))) {
::util_ThrowExceptionToJava(env, "Exception: nativeLoadFromStream: unable to create gloabal ref to properties");
goto NLFS_CLEANUP;
}
}
if (!(actionEvent = new wsLoadFromStreamEvent(initContext,
(void *) globalStream,
*uriNsString,
contentTypeChars,
(PRInt32) contentLength,
(void *)
globalLoadProperties))) {
::util_ThrowExceptionToJava(env, "Exception: nativeLoadFromStream: can't create wsLoadFromStreamEvent");
goto NLFS_CLEANUP;
}
::util_PostSynchronousEvent(initContext, (PLEvent *) *actionEvent);
NLFS_CLEANUP:
::util_ReleaseStringChars(env, uri, (const jchar *) uriStringUniChars);
::util_ReleaseStringUTFChars(env, contentType, contentTypeChars);
delete uriNsString;
// note, the deleteGlobalRef for loadProperties happens in the
// wsLoadFromStreamEvent destructor.
}
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeRefresh
(JNIEnv *env, jobject obj, jint webShellPtr, jlong loadFlags)
{
JNIEnv * pEnv = env;
jobject jobj = obj;
void * voidResult = nsnull;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
@ -95,7 +162,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl
wsRefreshEvent * actionEvent = new wsRefreshEvent(initContext->webNavigation, (PRInt32) loadFlags);
PLEvent * event = (PLEvent*) *actionEvent;
voidResult = ::util_PostSynchronousEvent(initContext, event);
::util_PostEvent(initContext, event);
return;
}
@ -123,3 +190,38 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl
::util_PostEvent(initContext, event);
}
}
JNIEXPORT void JNICALL
Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeSetPrompt
(JNIEnv *env, jobject obj, jint webShellPtr, jobject userPrompt)
{
JNIEnv * pEnv = env;
jobject jobj = obj;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeSetPrompt");
return;
}
if (userPrompt == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null properties passed to nativeSetPrompt");
return;
}
if (!initContext->initComplete) {
return;
}
// IMPORTANT: do the DeleteGlobalRef when we set a new prompt!
PR_ASSERT(initContext->browserContainer);
wsSetPromptEvent * actionEvent = new wsSetPromptEvent(initContext->browserContainer, userPrompt);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostSynchronousEvent(initContext, event);
}

View File

@ -0,0 +1,283 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ed Burns <edburns@acm.org>
*/
/*
* PreferencesActionEvents.cpp
*/
#include "PreferencesActionEvents.h"
#include "nsIPref.h"
#include "nsCRT.h" // for memset
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
//
// Local functions
//
void prefEnumerator(const char *name, void *closure);
static int PR_CALLBACK prefChanged(const char *name, void *closure);
void prefEnumerator(const char *name, void *closure)
{
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
if (nsnull == closure) {
return;
}
peStruct *pes = (peStruct *) closure;
WebShellInitContext *mInitContext = pes->cx;
jobject props = pes->obj;
PRInt32 prefType, intVal;
PRBool boolVal;
nsresult rv = NS_ERROR_FAILURE;
jstring prefName = nsnull;
jstring prefValue = nsnull;
PRUnichar *prefValueUni = nsnull;
nsAutoString prefValueAuto;
const PRInt32 bufLen = 20;
char buf[bufLen];
nsCRT::memset(buf, 0, bufLen);
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
if (nsnull == props || !prefs) {
return;
}
if (NS_FAILED(prefs->GetPrefType(name, &prefType))) {
return;
}
if (nsnull == (prefName = ::util_NewStringUTF(env, name))) {
return;
}
switch(prefType) {
case nsIPref::ePrefInt:
if (NS_SUCCEEDED(prefs->GetIntPref(name, &intVal))) {
WC_ITOA(intVal, buf, 10);
prefValue = ::util_NewStringUTF(env, buf);
}
break;
case nsIPref::ePrefBool:
if (NS_SUCCEEDED(prefs->GetBoolPref(name, &boolVal))) {
if (boolVal) {
prefValue = ::util_NewStringUTF(env, "true");
}
else {
prefValue = ::util_NewStringUTF(env, "false");
}
}
break;
case nsIPref::ePrefString:
if (NS_SUCCEEDED(prefs->CopyUnicharPref(name, &prefValueUni))) {
prefValueAuto = prefValueUni;
prefValue = ::util_NewString(env, (const jchar *) prefValueUni,
prefValueAuto.Length());
delete [] prefValueUni;
}
break;
default:
PR_ASSERT(PR_TRUE);
break;
}
if (nsnull == prefValue) {
prefValue = ::util_NewStringUTF(env, "");
}
::util_StoreIntoPropertiesObject(env, props, prefName, prefValue,
(jobject) &(mInitContext->shareContext));
}
static int PR_CALLBACK prefChanged(const char *name, void *closure)
{
if (nsnull == name || nsnull == closure) {
return NS_ERROR_NULL_POINTER;
}
nsresult rv;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
wsPrefChangedEvent *actionEvent = nsnull;
peStruct *pes = (peStruct *) closure;
void *voidResult = nsnull;
jstring prefName;
if (!(prefName = ::util_NewStringUTF(env, name))) {
rv = NS_ERROR_NULL_POINTER;
goto PC_CLEANUP;
}
if (!(actionEvent = new wsPrefChangedEvent(name, (peStruct *) closure))) {
rv = NS_ERROR_NULL_POINTER;
goto PC_CLEANUP;
}
voidResult = ::util_PostSynchronousEvent(pes->cx,(PLEvent *) *actionEvent);
rv = (nsresult) voidResult;
PC_CLEANUP:
return rv;
}
wsPrefChangedEvent::wsPrefChangedEvent(const char *prefName,
peStruct *yourPeStruct) :
mPrefName(prefName), mPeStruct(yourPeStruct)
{
}
void *wsPrefChangedEvent::handleEvent()
{
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
jint result;
jstring prefName;
#ifdef BAL_INTERFACE
#else
jclass pcClass = nsnull;
jmethodID pcMID = nsnull;
if (!(pcClass = env->GetObjectClass(mPeStruct->callback))) {
return (void*) NS_ERROR_FAILURE;
}
if (!(pcMID =env->GetMethodID(pcClass, "prefChanged",
"(Ljava/lang/String;Ljava/lang/Object;)I"))){
return (void*) NS_ERROR_FAILURE;
}
if (!(prefName = ::util_NewStringUTF(env, mPrefName))) {
return (void*) NS_ERROR_FAILURE;
}
result = env->CallIntMethod(mPeStruct->callback, pcMID, prefName,
mPeStruct->obj);
#endif
return (void *) result;
}
wsSetUnicharPrefEvent::wsSetUnicharPrefEvent(const char *prefName,
const jchar *yourPrefValue) :
mPrefName(prefName), mPrefValue(yourPrefValue)
{
}
void *wsSetUnicharPrefEvent::handleEvent()
{
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
nsresult rv = NS_ERROR_FAILURE;
if (!prefs) {
return (void *) rv;
}
rv = prefs->SetUnicharPref(mPrefName, (const PRUnichar *) mPrefValue);
return (void *) rv;
}
wsSetIntPrefEvent::wsSetIntPrefEvent(const char *prefName,
PRInt32 yourPrefValue) :
mPrefName(prefName), mPrefValue(yourPrefValue)
{
}
void *wsSetIntPrefEvent::handleEvent()
{
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
nsresult rv = NS_ERROR_FAILURE;
if (!prefs) {
return (void *) rv;
}
rv = prefs->SetIntPref(mPrefName, mPrefValue);
return (void *) rv;
}
wsSetBoolPrefEvent::wsSetBoolPrefEvent(const char *prefName,
PRBool yourPrefValue) :
mPrefName(prefName), mPrefValue(yourPrefValue)
{
}
void *wsSetBoolPrefEvent::handleEvent()
{
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
nsresult rv = NS_ERROR_FAILURE;
if (!prefs) {
return (void *) rv;
}
rv = prefs->SetBoolPref(mPrefName, mPrefValue);
return (void *) rv;
}
wsGetPrefsEvent::wsGetPrefsEvent(peStruct *yourPeStruct) :
mPeStruct(yourPeStruct)
{
}
void *wsGetPrefsEvent::handleEvent()
{
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
nsresult rv = NS_ERROR_FAILURE;
if (!prefs) {
return (void *) rv;
}
rv = prefs->EnumerateChildren("", prefEnumerator, mPeStruct);
return (void *) rv;
}
wsRegisterPrefCallbackEvent::wsRegisterPrefCallbackEvent(const char *yourPrefName,
peStruct *yourPeStruct) :
mPrefName(yourPrefName), mPeStruct(yourPeStruct)
{
}
void *wsRegisterPrefCallbackEvent::handleEvent()
{
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
nsresult rv = NS_ERROR_FAILURE;
if (!prefs) {
return (void *) rv;
}
rv = prefs->RegisterCallback(mPrefName, prefChanged, mPeStruct);
return (void *) rv;
}

View File

@ -0,0 +1,113 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
*/
/*
* nsActions.h
*/
#ifndef PreferencesActionEvents_h___
#define PreferencesActionEvents_h___
#include "nsActions.h"
#include "ns_util.h"
typedef struct _peStruct {
WebShellInitContext *cx;
jobject obj;
jobject callback;
} peStruct;
//
// ActionEvent class definitions
//
class wsPrefChangedEvent : public nsActionEvent {
public:
wsPrefChangedEvent (const char *prefName, peStruct *yourPeStruct);
void * handleEvent (void);
protected:
const char *mPrefName;
peStruct *mPeStruct;
};
class wsSetUnicharPrefEvent : public nsActionEvent {
public:
wsSetUnicharPrefEvent (const char *prefName, const jchar *yourPrefValue);
void * handleEvent (void);
protected:
const char *mPrefName;
const jchar *mPrefValue;
};
class wsSetIntPrefEvent : public nsActionEvent {
public:
wsSetIntPrefEvent (const char *prefName, PRInt32 yourPrefValue);
void * handleEvent (void);
protected:
const char *mPrefName;
PRInt32 mPrefValue;
};
class wsSetBoolPrefEvent : public nsActionEvent {
public:
wsSetBoolPrefEvent (const char *prefName, PRBool yourPrefValue);
void * handleEvent (void);
protected:
const char *mPrefName;
PRBool mPrefValue;
};
class wsGetPrefsEvent : public nsActionEvent {
public:
wsGetPrefsEvent (peStruct *yourPeStruct);
void * handleEvent (void);
protected:
peStruct *mPeStruct;
};
class wsRegisterPrefCallbackEvent : public nsActionEvent {
public:
wsRegisterPrefCallbackEvent (const char * prefName,
peStruct *yourPeStruct);
void * handleEvent (void);
protected:
const char *mPrefName;
peStruct *mPeStruct;
};
#endif /* PreferencesActionEvents_h___ */
// EOF

View File

@ -0,0 +1,298 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ed Burns <edburns@acm.org>
*/
#include "PreferencesImpl.h"
#include "PreferencesActionEvents.h"
JNIEXPORT void JNICALL
Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeSetUnicharPref
(JNIEnv *env, jobject obj, jint webShellPtr, jstring prefName,
jstring prefValue)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to netiveSetPref");
return;
}
const char * prefNameChars = (char *) ::util_GetStringUTFChars(env,
prefName);
const jchar * prefValueChars = (jchar *) ::util_GetStringChars(env,
prefValue);
nsresult rv = NS_ERROR_FAILURE;
wsSetUnicharPrefEvent *actionEvent = nsnull;
void *voidResult = nsnull;
if (nsnull == prefNameChars) {
::util_ThrowExceptionToJava(env, "nativeSetUnicharPref: unable to extract Java string for pref name");
rv = NS_ERROR_NULL_POINTER;
goto NSUP_CLEANUP;
}
if (nsnull == prefValueChars) {
::util_ThrowExceptionToJava(env, "nativeSetUnicharPref: unable to extract Java string for pref value");
rv = NS_ERROR_NULL_POINTER;
goto NSUP_CLEANUP;
}
if (!(actionEvent = new wsSetUnicharPrefEvent(prefNameChars,
prefValueChars))) {
::util_ThrowExceptionToJava(env, "nativeSetPref: unable to create actionEvent");
rv = NS_ERROR_NULL_POINTER;
goto NSUP_CLEANUP;
}
voidResult = ::util_PostSynchronousEvent(initContext,
(PLEvent *) *actionEvent);
rv = (nsresult) voidResult;
NSUP_CLEANUP:
::util_ReleaseStringUTFChars(env, prefName, prefNameChars);
::util_ReleaseStringChars(env, prefName, prefValueChars);
if (NS_FAILED(rv)) {
// PENDING(edburns): set a more specific kind of pref
::util_ThrowExceptionToJava(env, "nativeSetUnicharPref: can't set pref");
}
return;
}
JNIEXPORT void JNICALL
Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeSetIntPref
(JNIEnv *env, jobject obj, jint webShellPtr, jstring prefName,
jint prefValue)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to netiveSetPref");
return;
}
const char * prefNameChars = (char *) ::util_GetStringUTFChars(env,
prefName);
nsresult rv = NS_ERROR_FAILURE;
wsSetIntPrefEvent *actionEvent = nsnull;
void *voidResult = nsnull;
if (nsnull == prefNameChars) {
::util_ThrowExceptionToJava(env, "nativeSetIntPref: unable to extract Java string");
return;
}
if (!(actionEvent = new wsSetIntPrefEvent(prefNameChars,
(PRInt32) prefValue))) {
::util_ThrowExceptionToJava(env, "nativeSetPref: unable to create actionEvent");
rv = NS_ERROR_NULL_POINTER;
goto NSIP_CLEANUP;
}
voidResult = ::util_PostSynchronousEvent(initContext,
(PLEvent *) *actionEvent);
rv = (nsresult) voidResult;
NSIP_CLEANUP:
::util_ReleaseStringUTFChars(env, prefName, prefNameChars);
if (NS_FAILED(rv)) {
// PENDING(edburns): set a more specific kind of pref
::util_ThrowExceptionToJava(env, "nativeSetIntPref: can't set pref");
}
return;
}
JNIEXPORT void JNICALL
Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeSetBoolPref
(JNIEnv *env, jobject obj, jint webShellPtr, jstring prefName,
jboolean prefValue)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to netiveSetPref");
return;
}
const char * prefNameChars = (char *) ::util_GetStringUTFChars(env,
prefName);
nsresult rv = NS_ERROR_FAILURE;
wsSetBoolPrefEvent *actionEvent = nsnull;
void *voidResult = nsnull;
if (nsnull == prefNameChars) {
::util_ThrowExceptionToJava(env, "nativeSetBoolPref: unable to extract Java string");
return;
}
if (!(actionEvent = new wsSetBoolPrefEvent(prefNameChars,
prefValue))) {
::util_ThrowExceptionToJava(env, "nativeSetPref: unable to create actionEvent");
rv = NS_ERROR_NULL_POINTER;
goto NSBP_CLEANUP;
}
voidResult = ::util_PostSynchronousEvent(initContext,
(PLEvent *) *actionEvent);
rv = (nsresult) voidResult;
NSBP_CLEANUP:
::util_ReleaseStringUTFChars(env, prefName, prefNameChars);
if (NS_FAILED(rv)) {
// PENDING(edburns): set a more specific kind of pref
::util_ThrowExceptionToJava(env, "nativeSetBoolPref: can't set pref");
}
return;
}
JNIEXPORT jobject JNICALL
Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeGetPrefs
(JNIEnv *env, jobject obj, jint webShellPtr, jobject props)
{
nsresult rv = NS_ERROR_FAILURE;
jobject newProps;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
wsGetPrefsEvent *actionEvent = nsnull;
void *voidResult = nsnull;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to netiveGetPrefs");
return props;
}
PR_ASSERT(initContext->initComplete);
// step one: create or clear props
if (nsnull == props) {
if (nsnull ==
(newProps =
::util_CreatePropertiesObject(env, (jobject)
&(initContext->shareContext)))) {
::util_ThrowExceptionToJava(env, "Exception: nativeGetPrefs: can't create prefs.");
return props;
}
if (nsnull == (props = ::util_NewGlobalRef(env, newProps))) {
::util_ThrowExceptionToJava(env, "Exception: nativeGetPrefs: can't create global ref for prefs.");
return props;
}
}
else {
::util_ClearPropertiesObject(env, props, (jobject)
&(initContext->shareContext));
}
PR_ASSERT(props);
// step two, call the magic enumeration function, to populate the
// properties
peStruct pes;
pes.cx = initContext;
pes.obj = props;
if (!(actionEvent = new wsGetPrefsEvent(&pes))) {
::util_ThrowExceptionToJava(env, "nativeSetPref: unable to create actionEvent");
return props;
}
voidResult = ::util_PostSynchronousEvent(initContext,
(PLEvent *) *actionEvent);
rv = (nsresult) voidResult;
if (NS_FAILED(rv)) {
// PENDING(edburns): set a more specific kind of pref
::util_ThrowExceptionToJava(env, "nativeGetPrefs: can't get prefs");
}
return props;
}
JNIEXPORT void JNICALL
Java_org_mozilla_webclient_wrapper_1native_PreferencesImpl_nativeRegisterPrefChangedCallback
(JNIEnv *env, jobject obj, jint webShellPtr,
jobject callback, jstring prefName, jobject closure)
{
nsresult rv = NS_ERROR_FAILURE;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
const char *prefNameChars;
wsRegisterPrefCallbackEvent *actionEvent = nsnull;
void *voidResult = nsnull;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeRegisterPrefChangedCallback");
return;
}
PR_ASSERT(initContext->initComplete);
if (nsnull == (callback = ::util_NewGlobalRef(env, callback))) {
::util_ThrowExceptionToJava(env, "Exception: nativeRegisterPrefChangedCallback: can't global ref for callback");
return;
}
if (nsnull == (closure = ::util_NewGlobalRef(env, closure))) {
::util_ThrowExceptionToJava(env, "Exception: nativeRegisterPrefChangedCallback: can't global ref for closure");
return;
}
// step one, set up our struct
peStruct *pes;
if (nsnull == (pes = new peStruct())) {
::util_ThrowExceptionToJava(env, "Exception: nativeRegisterPrefChangedCallback: can't get peStruct");
return;
}
pes->cx = initContext;
pes->obj = closure;
pes->callback = callback;
// step two: create a const char * from the prefName
if (nsnull == (prefNameChars = ::util_GetStringUTFChars(env, prefName))) {
::util_ThrowExceptionToJava(env, "Exception: nativeRegisterPrefChangedCallback: can't get string for prefName");
return;
}
if (!(actionEvent = new wsRegisterPrefCallbackEvent(prefNameChars, pes))) {
::util_ThrowExceptionToJava(env, "nativeSetPref: unable to create actionEvent");
rv = NS_ERROR_NULL_POINTER;
return;
}
voidResult = ::util_PostSynchronousEvent(initContext,
(PLEvent *) *actionEvent);
rv = (nsresult) voidResult;
if (NS_FAILED(rv)) {
// PENDING(edburns): set a more specific kind of pref
::util_ThrowExceptionToJava(env, "nativeRegisterPrefChangedCallback: can't set callback");
}
::util_ReleaseStringUTFChars(env, prefName, prefNameChars);
return;
}

View File

@ -0,0 +1,211 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ed Burns <edburns@acm.org>
*/
/*
* RDFActionEvents.cpp
*/
#include "PromptActionEvents.h"
#include "ns_util.h"
wsPromptUsernameAndPasswordEvent::wsPromptUsernameAndPasswordEvent(WebShellInitContext *yourInitContext,
jobject yourPromptGlobalRef,
wsStringStruct *inStrings,
PRUint32 savePassword,
PRUnichar **outUser,
PRUnichar **outPwd,
PRBool *_retval) :
mInitContext(yourInitContext), mPromptGlobalRef(yourPromptGlobalRef),
mInStrings(inStrings), mOutUser(outUser),
mOutPwd(outPwd), mRetVal(_retval)
{
}
void *wsPromptUsernameAndPasswordEvent::handleEvent()
{
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
jboolean result = JNI_FALSE;
jstring user = nsnull;
jstring password = nsnull;
const jchar *userJchar = nsnull;
const jchar *passwordJchar = nsnull;
jclass promptClass = nsnull;
jmethodID mid = nsnull;
nsAutoString autoUser;
nsAutoString autoPassword;
if (!gPromptProperties) {
return (void *) NS_ERROR_FAILURE;
}
#ifdef BAL_INTERFACE
#else
// step two, call the java method.
if (!(promptClass = env->GetObjectClass(mPromptGlobalRef))) {
return (void *) NS_ERROR_FAILURE;
}
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,
gPromptProperties);
#endif
// pull userName and password entries out of the properties table
user = (jstring) ::util_GetFromPropertiesObject(env, gPromptProperties,
USER_NAME_KEY, (jobject)
&(mInitContext->shareContext));
userJchar = ::util_GetStringChars(env, user);
autoUser = (PRUnichar *) userJchar;
*mOutUser = autoUser.ToNewUnicode();
::util_ReleaseStringChars(env, user, userJchar);
password = (jstring) ::util_GetFromPropertiesObject(env, gPromptProperties,
PASSWORD_KEY, (jobject)
&(mInitContext->shareContext));
passwordJchar = ::util_GetStringChars(env, password);
autoPassword = (PRUnichar *) passwordJchar;
*mOutPwd = autoPassword.ToNewUnicode();
::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),
mInStrings(inStrings), mFieldOne(fieldOne), mFieldTwo(fieldTwo),
mCheckboxState(checkboxState), mNumButtons(numButtons),
mNumFields(numFields), mFieldIsPasswd(fieldIsPasswd),
mButtonPressed(buttonPressed)
{
}
void *wsPromptUniversalDialogEvent::handleEvent()
{
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
jboolean result = JNI_FALSE;
jclass promptClass = nsnull;
jmethodID mid = nsnull;
jstring edit1 = nsnull;
jstring edit2 = nsnull;
const jchar *edit1Jchar = nsnull;
const jchar *edit2Jchar = nsnull;
nsAutoString autoEdit1;
nsAutoString autoEdit2;
if (!gPromptProperties) {
return (void *) NS_ERROR_FAILURE;
}
#ifdef BAL_INTERFACE
#else
// step two, call the java method.
if (!(promptClass = env->GetObjectClass(mPromptGlobalRef))) {
return (void *) NS_ERROR_FAILURE;
}
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,
(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 = autoEdit1.ToNewUnicode();
::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 = autoEdit2.ToNewUnicode();
::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;
}

View File

@ -0,0 +1,89 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ed Burns <edburns@acm.org>
*/
/*
* nsActions.h
*/
#ifndef PromptActionEvents_h___
#define PromptActionEvents_h___
#include "nsActions.h"
#include "ns_util.h"
struct WebShellInitContext;
extern jobject gPromptProperties; // declared, defined in CBrowserContainer.cpp
class wsPromptUsernameAndPasswordEvent : public nsActionEvent {
public:
wsPromptUsernameAndPasswordEvent (WebShellInitContext *yourInitContext,
jobject yourPromptGlobalRef,
wsStringStruct *inStrings,
PRUint32 savePassword,
PRUnichar **outUser,
PRUnichar **outPwd,
PRBool *_retval);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
jobject mPromptGlobalRef;
wsStringStruct *mInStrings;
PRUint32 mSavePassword;
PRUnichar **mOutUser;
PRUnichar **mOutPwd;
PRBool *mRetVal;
};
class wsPromptUniversalDialogEvent : public nsActionEvent {
public:
wsPromptUniversalDialogEvent (WebShellInitContext *yourInitContext,
jobject yourPromptGlobalRef,
wsStringStruct *inStrings,
PRUnichar **fieldOne,
PRUnichar **fieldTwo,
PRBool *checkboxState,
PRInt32 numButtons,
PRInt32 numFields,
PRInt32 fieldIsPasswd,
PRInt32 *buttonPressed);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
jobject mPromptGlobalRef;
wsStringStruct *mInStrings;
PRUnichar **mFieldOne;
PRUnichar **mFieldTwo;
PRBool *mCheckboxState;
PRInt32 mNumButtons;
PRInt32 mNumFields;
PRInt32 mFieldIsPasswd;
PRInt32 *mButtonPressed;
};
#endif /* PromptActionEvents_h___ */
// EOF

View File

@ -0,0 +1,934 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
* Jason Mawdsley <jason@macadamian.com>
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
*/
/*
* RDFActionEvents.cpp
*/
#include "RDFActionEvents.h"
#include "rdf_util.h"
#include "ns_util.h"
#include "ns_globals.h"
#include "prlog.h"
#include "nsIComponentManager.h"
#include "nsISupportsArray.h"
#include "nsRDFCID.h" // for NS_RDFCONTAINER_CID
#include "wsRDFObserver.h"
static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
static NS_DEFINE_CID(kSupportsArrayCID, NS_SUPPORTSARRAY_CID);
//
// Local function prototypes
//
/**
* pull the int for the field nativeEnum from the java object obj.
*/
jint getNativeEnumFromJava(JNIEnv *env, jobject obj, jint nativeRDFNode);
wsInitBookmarksEvent::wsInitBookmarksEvent(WebShellInitContext* yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
}
void *
wsInitBookmarksEvent::handleEvent ()
{
void *result = nsnull;
if (!mInitContext) {
return (void *) NS_ERROR_UNEXPECTED;
}
nsresult rv;
rv = rdf_InitRDFUtils();
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: can't initialize RDF Utils");
return (void *) result;
}
result = (void *) kNC_BookmarksRoot.get();
return result;
} // handleEvent()
wsNewRDFNodeEvent::wsNewRDFNodeEvent(WebShellInitContext* yourInitContext,
const char * yourUrlString,
PRBool yourIsFolder) :
nsActionEvent(),
mInitContext(yourInitContext), mUrlString(yourUrlString),
mIsFolder(yourIsFolder)
{
}
void *
wsNewRDFNodeEvent::handleEvent ()
{
void *result = nsnull;
if (!mInitContext) {
return (void *) NS_ERROR_UNEXPECTED;
}
nsresult rv;
nsCOMPtr<nsIRDFResource> newNode;
nsCAutoString uri(mUrlString);
JNIEnv *env = (JNIEnv*) JNU_GetEnv(gVm, JNI_VERSION);
// PENDING(edburns): does this leak?
PRUnichar *uriUni = uri.ToNewUnicode();
rv = gRDF->GetUnicodeResource(uriUni, getter_AddRefs(newNode));
nsCRT::free(uriUni);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: can't create new nsIRDFResource.");
return result;
}
if (mIsFolder) {
rv = gRDFCU->MakeSeq(gBookmarksDataSource, newNode, nsnull);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: unable to make new folder as a sequence.");
return result;
}
rv = gBookmarksDataSource->Assert(newNode, kRDF_type,
kNC_Folder, PR_TRUE);
if (rv != NS_OK) {
::util_ThrowExceptionToJava(env, "Exception: unable to mark new folder as folder.");
return result;
}
}
/*
* Do the AddRef here.
*/
result = (void *)newNode.get();
((nsISupports *)result)->AddRef();
return result;
} // handleEvent()
wsRDFIsContainerEvent::wsRDFIsContainerEvent(WebShellInitContext* yourInitContext,
PRUint32 yourNativeRDFNode) :
nsActionEvent(),
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode)
{
}
void *
wsRDFIsContainerEvent::handleEvent ()
{
if (!mInitContext) {
return (void *) NS_ERROR_UNEXPECTED;
}
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
nsCOMPtr<nsIRDFNode> node = (nsIRDFNode *) mNativeRDFNode;
nsCOMPtr<nsIRDFResource> nodeResource;
nsresult rv;
jboolean result = JNI_FALSE;
PRBool prBool;
rv = node->QueryInterface(NS_GET_IID(nsIRDFResource),
getter_AddRefs(nodeResource));
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeIsContainer: nativeRDFNode is not an RDFResource.");
return nsnull;
}
rv = gRDFCU->IsContainer(gBookmarksDataSource, nodeResource,
&prBool);
result = (prBool == PR_FALSE) ? JNI_FALSE : JNI_TRUE;
return (void *) result;
} // handleEvent()
wsRDFGetChildAtEvent::wsRDFGetChildAtEvent(WebShellInitContext* yourInitContext,
PRUint32 yourNativeRDFNode,
PRUint32 yourChildIndex) :
nsActionEvent(),
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode),
mChildIndex(yourChildIndex)
{
}
void *
wsRDFGetChildAtEvent::handleEvent ()
{
if (!mInitContext) {
return (void *) NS_ERROR_UNEXPECTED;
}
jint result = -1;
nsresult rv;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
// PENDING(edburns): assert rdf_InitRDFUtils()
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) mNativeRDFNode;
nsCOMPtr<nsIRDFResource> child;
rv = rdf_getChildAt(mChildIndex, parent, getter_AddRefs(child));
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeGetChildAt: Can't get child.");
return nsnull;
}
result = (jint)child.get();
((nsISupports *)result)->AddRef();
return (void *) result;
} // handleEvent()
wsRDFGetChildCountEvent::wsRDFGetChildCountEvent(WebShellInitContext* yourInitContext,
PRUint32 yourNativeRDFNode) :
nsActionEvent(),
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode)
{
}
void *
wsRDFGetChildCountEvent::handleEvent ()
{
if (!mInitContext) {
return (void *) NS_ERROR_UNEXPECTED;
}
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
jint result = -1;
PRInt32 count;
nsresult rv;
// PENDING(edburns): assert rdf_InitRDFUtils()
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) mNativeRDFNode;
rv = rdf_getChildCount(parent, &count);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeGetChildCount: Can't get child count.");
return nsnull;
}
result = (jint)count;
return (void *) result;
} // handleEvent()
wsRDFGetChildIndexEvent::wsRDFGetChildIndexEvent(WebShellInitContext* yourInitContext,
PRUint32 yourNativeRDFNode,
PRUint32 yourChildRDFNode) :
nsActionEvent(),
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode),
mChildRDFNode(yourChildRDFNode)
{
}
void *
wsRDFGetChildIndexEvent::handleEvent ()
{
if (!mInitContext) {
return (void *) NS_ERROR_UNEXPECTED;
}
jint result = -1;
PRInt32 index;
nsresult rv;
// PENDING(edburns): assert rdf_InitRDFUtils()
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) mNativeRDFNode;
nsCOMPtr<nsIRDFResource> child = (nsIRDFResource *) mChildRDFNode;
rv = rdf_getIndexOfChild(parent, child, &index);
result = (jint) index;
return (void *) result;
} // handleEvent()
wsRDFToStringEvent::wsRDFToStringEvent(WebShellInitContext* yourInitContext,
PRUint32 yourNativeRDFNode) :
nsActionEvent(),
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode)
{
}
void *
wsRDFToStringEvent::handleEvent ()
{
if (!mInitContext) {
return (void *) NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsIRDFResource> currentResource =
(nsIRDFResource *) mNativeRDFNode;
nsCOMPtr<nsIRDFNode> node;
nsCOMPtr<nsIRDFLiteral> literal;
jstring result = nsnull;
PRBool isContainer = PR_FALSE;
nsresult rv;
const PRUnichar *textForNode = nsnull;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
rv = gRDFCU->IsContainer(gBookmarksDataSource, currentResource,
&isContainer);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeToString: Can't tell if RDFResource is container.");
return nsnull;
}
if (isContainer) {
// It's a bookmarks folder
rv = gBookmarksDataSource->GetTarget(currentResource,
kNC_Name, PR_TRUE,
getter_AddRefs(node));
// get the name of the folder
if (rv == 0) {
// if so, make sure it's an nsIRDFLiteral
rv = node->QueryInterface(NS_GET_IID(nsIRDFLiteral),
getter_AddRefs(literal));
if (NS_SUCCEEDED(rv)) {
rv = literal->GetValueConst(&textForNode);
}
else {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("nativeToString: node is not an nsIRDFLiteral.\n"));
}
}
}
}
else {
// It's a bookmark or a Separator
rv = gBookmarksDataSource->GetTarget(currentResource,
kNC_URL, PR_TRUE,
getter_AddRefs(node));
// See if it has a Name
if (0 != rv) {
rv = gBookmarksDataSource->GetTarget(currentResource,
kNC_Name, PR_TRUE,
getter_AddRefs(node));
}
if (0 == rv) {
rv = node->QueryInterface(NS_GET_IID(nsIRDFLiteral),
getter_AddRefs(literal));
if (NS_SUCCEEDED(rv)) {
// get the value of the literal
rv = literal->GetValueConst(&textForNode);
if (NS_FAILED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("nativeToString: node doesn't have a value.\n"));
}
}
}
else {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("nativeToString: node is not an nsIRDFLiteral.\n"));
}
}
}
else {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("nativeToString: node doesn't have a URL.\n"));
}
}
}
if (nsnull != textForNode) {
nsString * string = new nsString(textForNode);
int length = 0;
if (nsnull != string) {
length = string->Length();
}
result = ::util_NewString(env, (const jchar *) textForNode, length);
}
else {
result = ::util_NewStringUTF(env, "");
}
return (void *) result;
} // handleEvent()
wsRDFInsertElementAtEvent::wsRDFInsertElementAtEvent(WebShellInitContext* yourInitContext,
PRUint32 yourParentRDFNode,
PRUint32 yourChildRDFNode,
void *yourChildProperties,
PRUint32 yourChildIndex) :
nsActionEvent(),
mInitContext(yourInitContext), mParentRDFNode(yourParentRDFNode),
mChildRDFNode(yourChildRDFNode),
mChildPropsJobject(yourChildProperties), mChildIndex(yourChildIndex)
{
}
void *
wsRDFInsertElementAtEvent::handleEvent ()
{
if (!mInitContext) {
return (void *) NS_ERROR_UNEXPECTED;
}
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) mParentRDFNode;
nsCOMPtr<nsIRDFResource> newChild = (nsIRDFResource *) mChildRDFNode;
nsCOMPtr<nsIRDFContainer> container;
nsCOMPtr<nsIRDFLiteral> nameLiteral;
nsCOMPtr<nsIRDFLiteral> urlLiteral;
jstring name;
const jchar *nameJchar;
jstring url;
const jchar *urlJchar;
jobject childProps = (jobject) mChildPropsJobject;
PR_ASSERT(childProps);
nsresult rv;
PRBool isContainer;
rv = gRDFCU->IsContainer(gBookmarksDataSource, parent,
&isContainer);
// PENDING(edburns): I don't think we can throw exceptions from
// here, no?
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: RDFResource is not a container.");
rv = NS_ERROR_UNEXPECTED;
goto RIEAEHE_CLEANUP;
}
PR_ASSERT(gComponentManager);
// get a container in order to create a child
rv = gComponentManager->CreateInstance(kRDFContainerCID,
nsnull,
NS_GET_IID(nsIRDFContainer),
getter_AddRefs(container));
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't create container.");
rv = NS_ERROR_UNEXPECTED;
goto RIEAEHE_CLEANUP;
}
rv = container->Init(gBookmarksDataSource, parent);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't create container.");
rv = NS_ERROR_UNEXPECTED;
goto RIEAEHE_CLEANUP;
}
// pull the info from the properties object and add it to the new
// node.
if (nsnull == (name = (jstring) ::util_GetFromPropertiesObject(env,
childProps,
BM_NAME_VALUE,
(jobject)
&(mInitContext->shareContext)))) {
rv = NS_ERROR_UNEXPECTED;
goto RIEAEHE_CLEANUP;
}
if (nsnull == (nameJchar = ::util_GetStringChars(env, name))) {
rv = NS_ERROR_UNEXPECTED;
goto RIEAEHE_CLEANUP;
}
if (nsnull == (url = (jstring) ::util_GetFromPropertiesObject(env, childProps,
BM_URL_VALUE,
(jobject)
&(mInitContext->shareContext)))) {
rv = NS_ERROR_UNEXPECTED;
goto RIEAEHE_CLEANUP;
}
if (nsnull == (urlJchar = ::util_GetStringChars(env, url))) {
rv = NS_ERROR_UNEXPECTED;
goto RIEAEHE_CLEANUP;
}
// if we get here, we have valid nameJchar and urlJchar strings.
// create literals for the name and url
rv = gRDF->GetLiteral((const PRUnichar *) nameJchar,
getter_AddRefs(nameLiteral));
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't arguments nsISupportsArray.");
rv = NS_ERROR_UNEXPECTED;
goto RIEAEHE_CLEANUP;
}
rv = gRDF->GetLiteral((const PRUnichar *) urlJchar,
getter_AddRefs(urlLiteral));
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't create arguments nsISupportsArray.");
rv = NS_ERROR_UNEXPECTED;
goto RIEAEHE_CLEANUP;
}
// now Assert them to add the to the newChild
rv = gBookmarksDataSource->Assert(newChild, kNC_Name, nameLiteral,
PR_TRUE);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't add name literal to new node.");
rv = NS_ERROR_UNEXPECTED;
goto RIEAEHE_CLEANUP;
}
// + 1 because for some reason the 1 is the first, not 0.
rv = container->InsertElementAt(newChild, mChildIndex + 1, PR_TRUE);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't insert element into parent container.");
rv = NS_ERROR_UNEXPECTED;
goto RIEAEHE_CLEANUP;
}
RIEAEHE_CLEANUP:
::util_ReleaseStringChars(env, name, nameJchar);
::util_ReleaseStringChars(env, url, urlJchar);
return (void *) rv;
} // handleEvent()
wsRDFNewFolderEvent::wsRDFNewFolderEvent(WebShellInitContext* yourInitContext,
PRUint32 yourParentRDFNode,
void *yourChildPropsJobject,
PRUint32 *yourRetVal) :
nsActionEvent(),
mInitContext(yourInitContext), mParentRDFNode(yourParentRDFNode),
mChildPropsJobject(yourChildPropsJobject), mRetVal(yourRetVal)
{
}
/**
* The adding of bookmark folders is done through the RDF DoCommand
* interface. The DoCommand interface creates the nsIRDFResource on
* your behalf. We use an nsIRDFObserver to obtain the created resource
* as the DoCommand executes.
*/
void *
wsRDFNewFolderEvent::handleEvent ()
{
if (!mInitContext) {
return (void *) NS_ERROR_UNEXPECTED;
}
PR_ASSERT(gComponentManager);
PR_ASSERT(mRetVal);
*mRetVal = -1;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
nsCOMPtr<nsIRDFResource> parent = (nsIRDFResource *) mParentRDFNode;
nsCOMPtr<nsIRDFResource> newChildFromObserver;
nsCOMPtr<nsISupportsArray> selectionArray;
nsCOMPtr<nsISupportsArray> argumentsArray;
nsCOMPtr<nsIRDFLiteral> nameLiteral;
nsCOMPtr<nsIRDFLiteral> urlLiteral;
nsresult rv = NS_ERROR_UNEXPECTED;
PRBool isContainer;
nsCOMPtr<nsIRDFObserver> o = new wsRDFObserver();
wsRDFObserver *wsO = nsnull;
jstring name;
const jchar *nameJchar;
jstring url;
const jchar *urlJchar;
jobject childProps = (jobject) mChildPropsJobject;
PR_ASSERT(childProps);
rv = gRDFCU->IsContainer(gBookmarksDataSource, parent,
&isContainer);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeNewFolder: RDFResource is not a container.");
rv = NS_ERROR_UNEXPECTED;
goto RNFEHE_CLEANUP;
}
// pull out the necessary keys from the properties table
if (nsnull == (name = (jstring) ::util_GetFromPropertiesObject(env,
childProps,
BM_NAME_VALUE,
(jobject)
&(mInitContext->shareContext)))) {
rv = NS_ERROR_UNEXPECTED;
goto RNFEHE_CLEANUP;
}
if (nsnull == (nameJchar = ::util_GetStringChars(env, name))) {
rv = NS_ERROR_UNEXPECTED;
goto RNFEHE_CLEANUP;
}
if (nsnull == (url = (jstring) ::util_GetFromPropertiesObject(env, childProps,
BM_URL_VALUE,
(jobject)
&(mInitContext->shareContext)))) {
rv = NS_ERROR_UNEXPECTED;
goto RNFEHE_CLEANUP;
}
if (nsnull == (urlJchar = ::util_GetStringChars(env, url))) {
rv = NS_ERROR_UNEXPECTED;
goto RNFEHE_CLEANUP;
}
// if we get here, we have valid nameJchar and urlJchar strings.
// use the magic "command interface" as in bookmarks.js
// http://lxr.mozilla.org/mozilla/source/xpfe/components/bookmarks/resources/bookmarks.js#1190
// set up selection nsISupportsArray
rv = gComponentManager->CreateInstance(kSupportsArrayCID,
nsnull,
NS_GET_IID(nsISupportsArray),
getter_AddRefs(selectionArray));
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeNewFolder: can't create selection nsISupportsArray.");
rv = NS_ERROR_UNEXPECTED;
goto RNFEHE_CLEANUP;
}
// set up arguments nsISupportsArray
rv = gComponentManager->CreateInstance(kSupportsArrayCID,
nsnull,
NS_GET_IID(nsISupportsArray),
getter_AddRefs(argumentsArray));
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeNewFolder: can't create arguments nsISupportsArray.");
rv = NS_ERROR_UNEXPECTED;
goto RNFEHE_CLEANUP;
}
// get various arguments (parent, name)
// kNC_parent
// kNC_Name
// kNC_URL
// add parent into selection array
selectionArray->AppendElement(parent);
// add multiple arguments into arguments array
argumentsArray->AppendElement(kNC_parent);
argumentsArray->AppendElement(parent);
rv = gRDF->GetLiteral((const PRUnichar *) nameJchar,
getter_AddRefs(nameLiteral));
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeNewFolder: can't arguments nsISupportsArray.");
rv = NS_ERROR_UNEXPECTED;
goto RNFEHE_CLEANUP;
}
argumentsArray->AppendElement(kNC_Name);
argumentsArray->AppendElement(nameLiteral);
rv = gRDF->GetLiteral((const PRUnichar *) urlJchar,
getter_AddRefs(urlLiteral));
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeNewFolder: can't create arguments nsISupportsArray.");
rv = NS_ERROR_UNEXPECTED;
goto RNFEHE_CLEANUP;
}
argumentsArray->AppendElement(kNC_URL);
argumentsArray->AppendElement(urlLiteral);
// at this point, selectionArray contains the parent
// and argumentsArray contains arcs and literals for the name and the
// url of the node to be inserted.
if (o) {
gBookmarksDataSource->AddObserver(o);
}
// find out if it's a folder
if (nsnull != ::util_GetFromPropertiesObject(env, childProps,
BM_IS_FOLDER_VALUE, (jobject)
&(mInitContext->shareContext))){
// do the command
rv = gBookmarksDataSource->DoCommand(selectionArray,
kNewFolderCommand,
argumentsArray);
}
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeInsertElementAt: can't execute bookmarks command to add folder.");
rv = NS_ERROR_UNEXPECTED;
goto RNFEHE_CLEANUP;
}
if (o) {
gBookmarksDataSource->RemoveObserver(o);
wsO = (wsRDFObserver *) o.get();
newChildFromObserver = wsO->getFolder();
if (newChildFromObserver) {
*mRetVal = (PRUint32) newChildFromObserver.get();
((nsISupports *)*mRetVal)->AddRef();
}
}
RNFEHE_CLEANUP:
::util_ReleaseStringChars(env, name, nameJchar);
::util_ReleaseStringChars(env, url, urlJchar);
return (void *) rv;
} // handleEvent()
wsRDFHasMoreElementsEvent::wsRDFHasMoreElementsEvent(WebShellInitContext* yourInitContext,
PRUint32 yourNativeRDFNode,
void *yourJobject) :
nsActionEvent(),
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode),
mJobject(yourJobject)
{
}
void *
wsRDFHasMoreElementsEvent::handleEvent ()
{
if (!mInitContext) {
return (void *) NS_ERROR_UNEXPECTED;
}
nsresult rv;
jboolean result = JNI_FALSE;
PRBool prResult = PR_FALSE;
// assert -1 != nativeRDFNode
jint nativeEnum;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
if (-1 == (nativeEnum = getNativeEnumFromJava(env, (jobject) mJobject,
mNativeRDFNode))) {
::util_ThrowExceptionToJava(env, "Exception: nativeHasMoreElements: Can't get nativeEnum from nativeRDFNode.");
return (void *) NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsISimpleEnumerator> enumerator = (nsISimpleEnumerator *)nativeEnum;
rv = enumerator->HasMoreElements(&prResult);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeHasMoreElements: Can't ask nsISimpleEnumerator->HasMoreElements().");
return (void *) NS_ERROR_UNEXPECTED;
}
result = (PR_FALSE == prResult) ? JNI_FALSE : JNI_TRUE;
return (void *) result;
} // handleEvent()
wsRDFNextElementEvent::wsRDFNextElementEvent(WebShellInitContext* yourInitContext,
PRUint32 yourNativeRDFNode,
void *yourJobject) :
nsActionEvent(),
mInitContext(yourInitContext), mNativeRDFNode(yourNativeRDFNode),
mJobject(yourJobject)
{
}
void *
wsRDFNextElementEvent::handleEvent ()
{
if (!mInitContext) {
return (void *) NS_ERROR_UNEXPECTED;
}
nsresult rv;
jint result = -1;
PRBool hasMoreElements = PR_FALSE;
// assert -1 != nativeRDFNode
jint nativeEnum;
nsCOMPtr<nsISupports> supportsResult;
nsCOMPtr<nsIRDFNode> nodeResult;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
if (-1 == (nativeEnum = getNativeEnumFromJava(env, (jobject) mJobject,
mNativeRDFNode))) {
::util_ThrowExceptionToJava(env, "Exception: nativeNextElement: Can't get nativeEnum from nativeRDFNode.");
return (void *) NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsISimpleEnumerator> enumerator = (nsISimpleEnumerator *)nativeEnum;
rv = enumerator->HasMoreElements(&hasMoreElements);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativeNextElement: Can't ask nsISimpleEnumerator->HasMoreElements().");
return (void *) NS_ERROR_UNEXPECTED;
}
if (!hasMoreElements) {
return (void *) NS_ERROR_UNEXPECTED;
}
rv = enumerator->GetNext(getter_AddRefs(supportsResult));
if (NS_FAILED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("Exception: nativeNextElement: Can't get next from enumerator.\n"));
}
return (void *) NS_ERROR_UNEXPECTED;
}
// make sure it's an RDFNode
rv = supportsResult->QueryInterface(NS_GET_IID(nsIRDFNode),
getter_AddRefs(nodeResult));
if (NS_FAILED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("Exception: nativeNextElement: next from enumerator is not an nsIRDFNode.\n"));
}
return (void *) NS_ERROR_UNEXPECTED;
}
result = (jint)nodeResult.get();
((nsISupports *)result)->AddRef();
return (void *) result;
} // handleEvent()
wsRDFFinalizeEvent::wsRDFFinalizeEvent(void *yourJobject) :
nsActionEvent(),
mJobject(yourJobject)
{
}
void *
wsRDFFinalizeEvent::handleEvent ()
{
if (!mJobject) {
return (void *) NS_ERROR_UNEXPECTED;
}
jint nativeEnum, nativeContainer;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
// release the nsISimpleEnumerator
if (-1 == (nativeEnum =
::util_GetIntValueFromInstance(env, (jobject) mJobject,
"nativeEnum"))) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("nativeFinalize: Can't get fieldID for nativeEnum.\n"));
}
return (void *) NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsISimpleEnumerator> enumerator =
(nsISimpleEnumerator *) nativeEnum;
((nsISupports *)enumerator.get())->Release();
// release the nsIRDFContainer
if (-1 == (nativeContainer =
::util_GetIntValueFromInstance(env, (jobject) mJobject,
"nativeContainer"))) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("nativeFinalize: Can't get fieldID for nativeContainerFieldID.\n"));
}
return (void *) NS_ERROR_UNEXPECTED;
}
nsCOMPtr<nsIRDFContainer> container =
(nsIRDFContainer *) nativeContainer;
((nsISupports *)container.get())->Release();
return (void *) NS_OK;
} // handleEvent()
//
// Local functions
//
jint getNativeEnumFromJava(JNIEnv *env, jobject obj, jint nativeRDFNode)
{
nsresult rv;
jint result = -1;
result = ::util_GetIntValueFromInstance(env, obj, "nativeEnum");
// if the field has been initialized, just return the value
if (-1 != result) {
// NORMAL EXIT 1
return result;
}
// else, we need to create the enum
nsCOMPtr<nsIRDFNode> node = (nsIRDFNode *) nativeRDFNode;
nsCOMPtr<nsIRDFResource> nodeResource;
nsCOMPtr<nsIRDFContainer> container;
nsCOMPtr<nsISimpleEnumerator> enumerator;
rv = node->QueryInterface(NS_GET_IID(nsIRDFResource),
getter_AddRefs(nodeResource));
if (NS_FAILED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("getNativeEnumFromJava: Argument nativeRDFNode isn't an nsIRDFResource.\n"));
}
return -1;
}
PR_ASSERT(gComponentManager);
// get a container in order to get the enum
rv = gComponentManager->CreateInstance(kRDFContainerCID,
nsnull,
NS_GET_IID(nsIRDFContainer),
getter_AddRefs(container));
if (NS_FAILED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("recursiveResourceTraversal: can't get a new container\n"));
}
return -1;
}
rv = container->Init(gBookmarksDataSource, nodeResource);
if (NS_FAILED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("getNativeEnumFromJava: Can't Init container.\n"));
}
return -1;
}
rv = container->GetElements(getter_AddRefs(enumerator));
if (NS_FAILED(rv)) {
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("getNativeEnumFromJava: Can't get enumeration from container.\n"));
}
return -1;
}
// IMPORTANT: Store the enum back into java
::util_SetIntValueForInstance(env,obj,"nativeEnum",(jint)enumerator.get());
// IMPORTANT: make sure it doesn't get deleted when it goes out of scope
((nsISupports *)enumerator.get())->AddRef();
// PENDING(edburns): I'm not sure if we need to keep the
// nsIRDFContainer from being destructed in order to maintain the
// validity of the nsISimpleEnumerator that came from the container.
// Just to be safe, I'm doing so.
::util_SetIntValueForInstance(env, obj, "nativeContainer",
(jint) container.get());
((nsISupports *)container.get())->AddRef();
// NORMAL EXIT 2
result = (jint)enumerator.get();
return result;
}

View File

@ -0,0 +1,188 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
*/
/*
* nsActions.h
*/
#ifndef RDFActionEvents_h___
#define RDFActionEvents_h___
#include "nsActions.h"
struct WebShellInitContext;
class wsInitBookmarksEvent : public nsActionEvent {
public:
wsInitBookmarksEvent(WebShellInitContext *yourInitContext);
void * handleEvent(void);
protected:
WebShellInitContext *mInitContext;
};
class wsNewRDFNodeEvent : public nsActionEvent {
public:
wsNewRDFNodeEvent(WebShellInitContext *yourInitContext,
const char *yourUrlString, PRBool yourIsFolder);
void * handleEvent(void);
protected:
WebShellInitContext *mInitContext;
const char *mUrlString;
PRBool mIsFolder;
};
class wsRDFIsContainerEvent : public nsActionEvent {
public:
wsRDFIsContainerEvent(WebShellInitContext *yourInitContext,
PRUint32 yourNativeRDFNode);
void * handleEvent(void);
protected:
WebShellInitContext *mInitContext;
PRUint32 mNativeRDFNode;
};
class wsRDFGetChildAtEvent : public nsActionEvent {
public:
wsRDFGetChildAtEvent(WebShellInitContext *yourInitContext,
PRUint32 yourNativeRDFNode, PRUint32 childIndex);
void * handleEvent(void);
protected:
WebShellInitContext *mInitContext;
PRUint32 mNativeRDFNode;
PRUint32 mChildIndex;
};
class wsRDFGetChildCountEvent : public nsActionEvent {
public:
wsRDFGetChildCountEvent(WebShellInitContext *yourInitContext,
PRUint32 yourNativeRDFNode);
void * handleEvent(void);
protected:
WebShellInitContext *mInitContext;
PRUint32 mNativeRDFNode;
};
class wsRDFGetChildIndexEvent : public nsActionEvent {
public:
wsRDFGetChildIndexEvent(WebShellInitContext *yourInitContext,
PRUint32 yourNativeRDFNode,
PRUint32 yourChildRDFNode);
void * handleEvent(void);
protected:
WebShellInitContext *mInitContext;
PRUint32 mNativeRDFNode;
PRUint32 mChildRDFNode;
};
class wsRDFToStringEvent : public nsActionEvent {
public:
wsRDFToStringEvent(WebShellInitContext *yourInitContext,
PRUint32 yourNativeRDFNode);
void * handleEvent(void);
protected:
WebShellInitContext *mInitContext;
PRUint32 mNativeRDFNode;
};
class wsRDFInsertElementAtEvent : public nsActionEvent {
public:
wsRDFInsertElementAtEvent(WebShellInitContext *yourInitContext,
PRUint32 yourParentRDFNode,
PRUint32 yourChildRDFNode,
void *yourChildProperties,
PRUint32 yourChildIndex);
void * handleEvent(void);
protected:
WebShellInitContext *mInitContext;
PRUint32 mParentRDFNode;
PRUint32 mChildRDFNode;
void *mChildPropsJobject;
PRUint32 mChildIndex;
};
class wsRDFNewFolderEvent : public nsActionEvent {
public:
wsRDFNewFolderEvent(WebShellInitContext* yourInitContext,
PRUint32 yourParentRDFNode,
void *yourChildPropsJobject,
PRUint32 *yourRetVal);
void * handleEvent(void);
protected:
WebShellInitContext *mInitContext;
PRUint32 mParentRDFNode;
void *mChildPropsJobject;
PRUint32 *mRetVal;
};
class wsRDFHasMoreElementsEvent : public nsActionEvent {
public:
wsRDFHasMoreElementsEvent(WebShellInitContext *yourInitContext,
PRUint32 mNativeRDFNode,
void *yourJobject);
void * handleEvent(void);
protected:
WebShellInitContext *mInitContext;
PRUint32 mNativeRDFNode;
void *mJobject;
};
class wsRDFNextElementEvent : public nsActionEvent {
public:
wsRDFNextElementEvent(WebShellInitContext *yourInitContext,
PRUint32 mNativeRDFNode,
void *yourJobject);
void * handleEvent(void);
protected:
WebShellInitContext *mInitContext;
PRUint32 mNativeRDFNode;
void *mJobject;
};
class wsRDFFinalizeEvent : public nsActionEvent {
public:
wsRDFFinalizeEvent(void *yourJobject);
void * handleEvent(void);
protected:
void *mJobject;
};
#endif /* RDFActionEvents_h___ */
// EOF

View File

@ -22,10 +22,11 @@
#include "RDFEnumeration.h"
#include "RDFActionEvents.h"
#include "rdf_util.h"
#include "rdf_progids.h"
#include "ns_util.h"
#include "nsActions.h"
#include "nsIRDFContainer.h"
#include "nsIServiceManager.h"

View File

@ -22,10 +22,11 @@
#include "RDFTreeNode.h"
#include "RDFActionEvents.h"
#include "rdf_util.h"
#include "rdf_progids.h"
#include "ns_util.h"
#include "nsActions.h"
#include "nsIServiceManager.h"
@ -216,10 +217,11 @@ Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeToString
JNIEXPORT void JNICALL
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeInsertElementAt
(JNIEnv *env, jobject obj, jint webShellPtr, jint parentRDFNode,
jint childRDFNode, jint childIndex)
jint childRDFNode, jobject childProps, jint childIndex)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
void * voidResult = nsnull;
jobject propsGlobalRef;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeInsertElementAt");
@ -228,20 +230,60 @@ Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeInsertElementAt
if (!initContext->initComplete) {
::util_ThrowExceptionToJava(env, "Exception: can't InsertElementAt");
}
propsGlobalRef = ::util_NewGlobalRef(env, childProps);
wsRDFInsertElementAtEvent *actionEvent =
new wsRDFInsertElementAtEvent(initContext,
(PRUint32) parentRDFNode,
(PRUint32) childRDFNode,
(void *) propsGlobalRef,
(PRUint32) childIndex);
PLEvent * event = (PLEvent*) *actionEvent;
voidResult = ::util_PostSynchronousEvent(initContext, event);
::util_DeleteGlobalRef(env, propsGlobalRef);
if (NS_FAILED((nsresult) voidResult)) {
::util_ThrowExceptionToJava(env, "Exception: Can't InsertElementAt");
}
return;
}
JNIEXPORT jint JNICALL
Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeNewFolder
(JNIEnv *env, jobject obj, jint webShellPtr, jint parentRDFNode,
jobject childProps)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
void * voidResult = nsnull;
jobject propsGlobalRef;
jint retVal = 0;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeNewFolder");
}
if (!initContext->initComplete || !childProps) {
::util_ThrowExceptionToJava(env, "Exception: can't NewFolder");
}
propsGlobalRef = ::util_NewGlobalRef(env, childProps);
if (!propsGlobalRef) {
::util_ThrowExceptionToJava(env, "Exception: can't NewFolder");
}
wsRDFNewFolderEvent *actionEvent =
new wsRDFNewFolderEvent(initContext,
(PRUint32) parentRDFNode,
(void *) propsGlobalRef,
(PRUint32 *) &retVal);
PLEvent * event = (PLEvent*) *actionEvent;
voidResult = ::util_PostSynchronousEvent(initContext, event);
::util_DeleteGlobalRef(env, propsGlobalRef);
if (NS_FAILED((nsresult) voidResult)) {
::util_ThrowExceptionToJava(env, "Exception: Can't do NewFolder");
}
return retVal;
}

View File

@ -0,0 +1,299 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
* Jason Mawdsley <jason@macadamian.com>
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
*/
/*
* WindowControlActionEvents.cpp
*/
#include "WindowControlActionEvents.h"
#include "ns_util.h"
#include "nsIDocShellTreeItem.h"
#include "nsEmbedAPI.h" // for NS_TermEmbedding
/*
* wsResizeEvent
*/
wsResizeEvent::wsResizeEvent(nsIBaseWindow* baseWindow, PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h) :
nsActionEvent(),
mBaseWindow(baseWindow),
mLeft(x),
mBottom(y),
mWidth(w),
mHeight(h)
{
}
void *
wsResizeEvent::handleEvent ()
{
nsresult rv = NS_ERROR_FAILURE;
if (mBaseWindow) {
rv = mBaseWindow->SetPositionAndSize(mLeft, mBottom, mWidth, mHeight,
PR_TRUE);
return (void *) rv;
}
return nsnull;
} // handleEvent()
wsDeallocateInitContextEvent::wsDeallocateInitContextEvent(WebShellInitContext* yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
}
void *
wsDeallocateInitContextEvent::handleEvent ()
{
void *result = nsnull;
if (!mInitContext) {
return (void *) NS_ERROR_UNEXPECTED;
}
PRBool isLastWindow = PR_TRUE;
PRInt32 winCount;
if (NS_SUCCEEDED(mInitContext->browserContainer->
GetInstanceCount(&winCount))) {
isLastWindow = (1 == winCount);
}
mInitContext->parentHWnd = nsnull;
// make sure the webBrowser's contentListener doesn't have a ref to
// CBrowserContainer
mInitContext->webBrowser->SetParentURIContentListener(nsnull);
mInitContext->webBrowser = nsnull;
// make sure the webShell's container is set to null.
// get the webShell from the docShell
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mInitContext->docShell));
if (webShell) {
webShell->SetContainer(nsnull);
}
// make sure the docShell's TreeOwner is set to null
// get the docShellTreeItem from the docShell
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mInitContext->docShell));
if (docShellAsItem) {
docShellAsItem->SetTreeOwner(nsnull);
}
mInitContext->docShell->SetDocLoaderObserver(nsnull);
mInitContext->docShell = nsnull;
// PENDING(edburns): this is a leak. For some reason, webShell's
// refcount is two. I believe it should be one.
// see http://bugzilla.mozilla.org/show_bug.cgi?id=38271
mInitContext->webShell = nsnull;
mInitContext->webNavigation = nsnull;
mInitContext->presShell = nsnull;
mInitContext->baseWindow = nsnull;
// mInitContext->embeddedThread = nsnull;
mInitContext->env = nsnull;
if (nsnull != mInitContext->nativeEventThread) {
::util_DeleteGlobalRef((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION),
mInitContext->nativeEventThread);
mInitContext->nativeEventThread = nsnull;
}
mInitContext->stopThread = -1;
mInitContext->initComplete = FALSE;
mInitContext->initFailCode = 0;
mInitContext->x = -1;
mInitContext->y = -1;
mInitContext->w = -1;
mInitContext->h = -1;
mInitContext->gtkWinPtr = nsnull;
mInitContext->searchContext = nsnull;
// make sure we aren't listening anymore. This needs to be done
// before currentDocument = nsnull
mInitContext->browserContainer->RemoveAllListeners();
mInitContext->currentDocument = nsnull;
mInitContext->browserContainer = nsnull;
util_DeallocateShareInitContext(&(mInitContext->shareContext));
// delete mInitContext;
if (isLastWindow) {
NS_TermEmbedding();
#ifdef _WIN32
_exit(0);
#endif
}
return (void *) NS_OK;
} // handleEvent()
/*
* wsMoveToEvent
*/
wsMoveToEvent::wsMoveToEvent(nsIBaseWindow* baseWindow, PRInt32 x, PRInt32 y) :
nsActionEvent(),
mBaseWindow(baseWindow),
mX(x),
mY(y)
{
}
void *
wsMoveToEvent::handleEvent ()
{
if (mBaseWindow) {
nsresult rv = mBaseWindow->SetPosition(mX, mY);
}
return nsnull;
} // handleEvent()
/*
* wsSetFocusEvent
*/
wsSetFocusEvent::wsSetFocusEvent(nsIBaseWindow* baseWindow) :
nsActionEvent(),
mBaseWindow(baseWindow)
{
}
void *
wsSetFocusEvent::handleEvent ()
{
if (mBaseWindow) {
nsresult rv = mBaseWindow->SetFocus();
}
return nsnull;
} // handleEvent()
/*
* wsRemoveFocusEvent
*/
wsRemoveFocusEvent::wsRemoveFocusEvent(nsIBaseWindow* baseWindow) :
nsActionEvent(),
mBaseWindow(baseWindow)
{
}
void *
wsRemoveFocusEvent::handleEvent ()
{
if (mBaseWindow) {
//PENDING (Ashu) : No removeFocus functionality provided in M15
// nsresult rv = mWebShell->RemoveFocus();
}
return nsnull;
} // handleEvent()
/*
* wsRepaintEvent
*/
wsRepaintEvent::wsRepaintEvent(nsIBaseWindow* baseWindow, PRBool forceRepaint) :
nsActionEvent(),
mBaseWindow(baseWindow),
mForceRepaint(forceRepaint)
{
}
void *
wsRepaintEvent::handleEvent ()
{
if (mBaseWindow) {
nsresult rv = mBaseWindow->Repaint(mForceRepaint);
}
return nsnull;
} // handleEvent()
/*
* wsShowEvent
*/
wsShowEvent::wsShowEvent(nsIBaseWindow* baseWindow, PRBool state) :
nsActionEvent(),
mBaseWindow(baseWindow),
mState(state)
{
}
void *
wsShowEvent::handleEvent ()
{
if (mBaseWindow) {
mBaseWindow->SetVisibility(mState);
}
return nsnull;
} // handleEvent()
/*
* wsHideEvent
*/
wsHideEvent::wsHideEvent(nsIBaseWindow* baseWindow) :
nsActionEvent(),
mBaseWindow(baseWindow)
{
}
void *
wsHideEvent::handleEvent ()
{
if (mBaseWindow) {
mBaseWindow->SetVisibility(PR_FALSE);
}
return nsnull;
} // handleEvent()

View File

@ -0,0 +1,128 @@
/* -*- 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 RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
*/
/*
* nsActions.h
*/
#ifndef WindowControlActionEvents_h___
#define WindowControlActionEvents_h___
#include "nsActions.h"
#include "nsIBaseWindow.h"
struct WebShellInitContext;
class wsResizeEvent : public nsActionEvent {
public:
wsResizeEvent (nsIBaseWindow* baseWindow, PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h);
void * handleEvent (void);
protected:
nsIBaseWindow * mBaseWindow;
PRInt32 mLeft;
PRInt32 mBottom;
PRInt32 mWidth;
PRInt32 mHeight;
};
class wsDeallocateInitContextEvent : public nsActionEvent {
public:
wsDeallocateInitContextEvent(WebShellInitContext *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
};
class wsMoveToEvent : public nsActionEvent {
public:
wsMoveToEvent (nsIBaseWindow* baseWindow, PRInt32 x, PRInt32 y);
void * handleEvent (void);
protected:
nsIBaseWindow * mBaseWindow;
PRInt32 mX;
PRInt32 mY;
};
class wsSetFocusEvent : public nsActionEvent {
public:
wsSetFocusEvent(nsIBaseWindow* baseWindow);
void * handleEvent (void);
protected:
nsIBaseWindow * mBaseWindow;
};
class wsRemoveFocusEvent : public nsActionEvent {
public:
wsRemoveFocusEvent(nsIBaseWindow* baseWindow);
void * handleEvent (void);
protected:
nsIBaseWindow * mBaseWindow;
};
class wsRepaintEvent : public nsActionEvent {
public:
wsRepaintEvent (nsIBaseWindow* baseWindow, PRBool forceRepaint);
void * handleEvent (void);
protected:
nsIBaseWindow * mBaseWindow;
PRBool mForceRepaint;
};
class wsShowEvent : public nsActionEvent {
public:
wsShowEvent (nsIBaseWindow* baseWindow, PRBool state);
void * handleEvent (void);
protected:
nsIBaseWindow * mBaseWindow;
PRBool mState;
};
class wsHideEvent : public nsActionEvent {
public:
wsHideEvent (nsIBaseWindow* baseWindow);
void * handleEvent (void);
protected:
nsIBaseWindow * mBaseWindow;
};
#endif /* WindowControlActionEvents_h___ */
// EOF

View File

@ -27,8 +27,10 @@
*/
#include "WindowControlImpl.h"
#include "WindowControlActionEvents.h"
#include "ns_util.h"
#include "nsActions.h"
#include "nsIThread.h" // for PRThread
@ -85,11 +87,10 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI
initContext->webShell = nsnull;
initContext->docShell = nsnull;
initContext->baseWindow = nsnull;
initContext->sHistory = nsnull;
initContext->webNavigation = nsnull;
initContext->presShell = nsnull;
initContext->embeddedThread = nsnull;
initContext->actionQueue = nsnull;
// initContext->embeddedThread = nsnull;
// initContext->actionQueue = nsnull;
initContext->env = env;
initContext->nativeEventThread = nsnull;
initContext->stopThread = FALSE;
@ -103,6 +104,12 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI
util_InitializeShareInitContext(&(initContext->shareContext));
#ifdef XP_UNIX
/***** Uncomment this to debug on unix
pid_t pid = getpid();
printf("++++++++++++++++debug: edburns: pid is: %d\n", pid);
sleep(7);
**************/
initContext->gtkWinPtr =
(int)::util_GetGTKWinPtrFromCanvas(env, aBrowserControlImpl);
#else
@ -132,7 +139,7 @@ Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeDestroyInitCo
::util_ThrowExceptionToJava(env, "Exception: Can't destroy initContext");
return;
}
initContext->actionQueue = nsnull;
// initContext->actionQueue = nsnull;
delete initContext;
}

View File

@ -43,6 +43,7 @@ const char *gImplementedInterfaces[] = {
"webclient.History",
"webclient.EventRegistration",
"webclient.Bookmarks",
"webclient.Preferences",
nsnull
};
@ -71,7 +72,6 @@ Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeTerminate
(JNIEnv *env, jobject obj)
{
gComponentManager = nsnull;
gHistory = nsnull;
nsCRT::free((char *) gBinDir);
gBinDir = nsnull;
}

Some files were not shown because too many files have changed in this diff Show More