diff options
Diffstat (limited to 'plugin/icedteanp/java')
-rw-r--r-- | plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3PanelFactory.java (renamed from plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java) | 69 | ||||
-rw-r--r-- | plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3Viewer.java (renamed from plugin/icedteanp/java/sun/applet/PluginAppletViewer.java) | 538 | ||||
-rw-r--r-- | plugin/icedteanp/java/netscape/javascript/JSObject.java | 23 | ||||
-rw-r--r-- | plugin/icedteanp/java/sun/applet/Applet3MessageHandler.java | 21 | ||||
-rw-r--r-- | plugin/icedteanp/java/sun/applet/PluginCookieManager.java | 5 | ||||
-rw-r--r-- | plugin/icedteanp/java/sun/applet/PluginMain.java | 15 | ||||
-rw-r--r-- | plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java | 2 | ||||
-rw-r--r-- | plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java | 2 | ||||
-rw-r--r-- | plugin/icedteanp/java/sun/applet/PluginParameterParser.java | 2 | ||||
-rw-r--r-- | plugin/icedteanp/java/sun/applet/PluginProxySelector.java | 4 | ||||
-rw-r--r-- | plugin/icedteanp/java/sun/applet/PluginStreamHandler.java | 6 |
11 files changed, 247 insertions, 440 deletions
diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java b/plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3PanelFactory.java index 429cb62..2c9040c 100644 --- a/plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java +++ b/plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3PanelFactory.java @@ -59,35 +59,43 @@ exception statement from your version. */ * have any questions. */ -package sun.applet; +package jogamp.plugin.applet; -import java.applet.Applet; -import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; -import javax.swing.SwingUtilities; - -import net.sourceforge.jnlp.NetxPanel; +import jogamp.applet.Applet3Panel; +import jogamp.plugin.jnlp.NetxApplet3Panel; import net.sourceforge.jnlp.PluginParameters; import net.sourceforge.jnlp.util.logging.OutputController; +import sun.applet.AppletPanel; +import sun.applet.AppletSecurityContextManager; +import sun.applet.PluginDebug; +import sun.applet.PluginStreamHandler; + +import com.jogamp.plugin.applet.Applet3; /** * Lets us construct one using unix-style one shot behaviors */ -class PluginAppletPanelFactory { +public class PluginApplet3PanelFactory { - public AppletPanel createPanel(PluginStreamHandler streamhandler, + public Applet3Panel createPanel(PluginStreamHandler streamhandler, final int identifier, - final long handle, + final long nativeWindowHandle, final URL doc, final PluginParameters params) { - final NetxPanel panel = AccessController.doPrivileged(new PrivilegedAction<NetxPanel>() { - public NetxPanel run() { - NetxPanel panel = new NetxPanel(doc, params); - NetxPanel.debug("Using NetX panel"); + final int width = params.getWidth(); + final int height = params.getHeight(); + PluginDebug.debug("NativeWindow (Browser) Handle: 0x" + Long.toHexString(nativeWindowHandle)); + PluginDebug.debug("NativeWindow (Browser) Size: " + width + " x " + height); + final NetxApplet3Panel panel = AccessController.doPrivileged(new PrivilegedAction<NetxApplet3Panel>() { + @Override + public NetxApplet3Panel run() { + NetxApplet3Panel panel = new NetxApplet3Panel(nativeWindowHandle, width, height, doc, params); + NetxApplet3Panel.debug("Using NetX panel"); PluginDebug.debug(params.toString()); return panel; } @@ -102,9 +110,9 @@ class PluginAppletPanelFactory { @Override public void run() { panel.createNewAppContext(); // create the frame. - PluginDebug.debug("X and Y are: " + params.getWidth() + " " + params.getHeight()); - panel.setAppletViewerFrame(PluginAppletViewer.framePanel(identifier, handle, - params.getWidth(), params.getHeight(), panel)); + final PluginApplet3Viewer pav = PluginApplet3Viewer.framePanel(identifier, panel); + panel.setAppletViewerFrame(pav); + panel.setAppletContext(pav); panel.init(); // Start the applet @@ -122,9 +130,9 @@ class PluginAppletPanelFactory { setAppletViewerSize(panel, params.getWidth(), params.getHeight()); // Wait for the panel to initialize - PluginAppletViewer.waitForAppletInit(panel); + PluginApplet3Viewer.waitForAppletInit(panel); - Applet a = panel.getApplet(); + Applet3 a = panel.getApplet(); // Still null? if (a == null) { @@ -143,27 +151,19 @@ class PluginAppletPanelFactory { return panel; } - /* AppletViewerPanel sometimes doesn't set size right initially. This + /* AppletViewerPanel sometimes doesn't set size right initially. This * causes the parent frame to be the default (10x10) size. - * - * Normally it goes unnoticed since browsers like Firefox make a resize + * + * Normally it goes unnoticed since browsers like Firefox make a resize * call after init. However some browsers (e.g. Midori) don't. - * + * * We therefore manually set the parent to the right size. */ - static private void setAppletViewerSize(final AppletPanel panel, + static private void setAppletViewerSize(final Applet3Panel panel, final int width, final int height) { try { - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - panel.getParent().setSize(width, height); - } - }); - } catch (InvocationTargetException e) { - // Not being able to resize is non-fatal - PluginDebug.debug("Unable to resize panel: "); - OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); - } catch (InterruptedException e) { + panel.resize(width, height); + } catch (Exception e) { // Not being able to resize is non-fatal PluginDebug.debug("Unable to resize panel: "); OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); @@ -174,10 +174,11 @@ class PluginAppletPanelFactory { * On start-up the current behaviour is to load the applet and call * Applet.init() and Applet.start(). */ - private void initEventQueue(AppletPanel panel) { + private void initEventQueue(Applet3Panel panel) { // appletviewer.send.event is an undocumented and unsupported system // property which is used exclusively for testing purposes. PrivilegedAction<String> pa = new PrivilegedAction<String>() { + @Override public String run() { return System.getProperty("appletviewer.send.event"); } diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java b/plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3Viewer.java index 8d1630d..338ce42 100644 --- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java +++ b/plugin/icedteanp/java/jogamp/plugin/applet/PluginApplet3Viewer.java @@ -60,25 +60,10 @@ exception statement from your version. */ * have any questions. */ -package sun.applet; +package jogamp.plugin.applet; import static net.sourceforge.jnlp.runtime.Translator.R; -import java.applet.Applet; -import java.applet.AppletContext; -import java.applet.AudioClip; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Insets; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import java.awt.print.PageFormat; -import java.awt.print.Printable; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; @@ -90,10 +75,8 @@ import java.security.AccessController; import java.security.AllPermission; import java.security.PrivilegedAction; import java.util.Enumeration; -import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; -import java.util.Map; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -101,10 +84,10 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; -import javax.swing.SwingUtilities; - +import jogamp.applet.App3Context; +import jogamp.applet.Applet3Panel; +import jogamp.plugin.jnlp.NetxApplet3Panel; import net.sourceforge.jnlp.LaunchException; -import net.sourceforge.jnlp.NetxPanel; import net.sourceforge.jnlp.PluginParameters; import net.sourceforge.jnlp.runtime.JNLPClassLoader; import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityLevel; @@ -112,20 +95,28 @@ import net.sourceforge.jnlp.security.appletextendedsecurity.AppletStartupSecurit import net.sourceforge.jnlp.splashscreen.SplashController; import net.sourceforge.jnlp.splashscreen.SplashPanel; import net.sourceforge.jnlp.splashscreen.SplashUtils; -import sun.awt.AppContext; -import sun.awt.SunToolkit; -import sun.awt.X11.XEmbeddedFrame; -import sun.misc.Ref; - -import com.sun.jndi.toolkit.url.UrlUtil; import net.sourceforge.jnlp.util.logging.OutputController; +import sun.applet.Applet3MessageHandler; +import sun.applet.AppletEvent; +import sun.applet.AppletListener; +import sun.applet.AppletPanel; +import sun.applet.AppletSecurityContextManager; +import sun.applet.PluginAppletSecurityContext; +import sun.applet.PluginCallRequest; +import sun.applet.PluginCallRequestFactory; +import sun.applet.PluginDebug; +import sun.applet.PluginMessageConsumer; +import sun.applet.PluginParameterParser; +import sun.applet.PluginStreamHandler; + +import com.jogamp.plugin.applet.Applet3; +import com.jogamp.plugin.applet.Applet3Context; +import com.sun.jndi.toolkit.url.UrlUtil; /* */ // FIXME: declare JSProxy implementation -@SuppressWarnings("serial") -public class PluginAppletViewer extends XEmbeddedFrame - implements AppletContext, Printable, SplashController { +public class PluginApplet3Viewer implements Applet3Context, SplashController { /** * Enumerates the current status of an applet @@ -143,15 +134,15 @@ public class PluginAppletViewer extends XEmbeddedFrame /** * The panel in which the applet is being displayed. */ - private NetxPanel panel; + private final NetxApplet3Panel panel; static final ReentrantLock panelLock = new ReentrantLock(); // CONDITION PREDICATE: panel.isAlive() static final Condition panelLive = panelLock.newCondition(); private int identifier; // Instance identifier -> PluginAppletViewer object. - private static ConcurrentMap<Integer, PluginAppletViewer> applets = - new ConcurrentHashMap<Integer, PluginAppletViewer>(); + private static ConcurrentMap<Integer, PluginApplet3Viewer> applets = + new ConcurrentHashMap<Integer, PluginApplet3Viewer>(); private static final ReentrantLock appletsLock = new ReentrantLock(); // CONDITION PREDICATE: !applets.containsKey(identifier) private static final Condition appletAdded = appletsLock.newCondition(); @@ -166,7 +157,6 @@ public class PluginAppletViewer extends XEmbeddedFrame // CONDITION PREDICATE: !status.get(identifier).equals(PAV_INIT_STATUS.INIT_COMPLETE) private static final Condition initComplete = statusLock.newCondition(); - private WindowListener windowEventListener = null; private AppletEventListener appletEventListener = null; public static final long APPLET_TIMEOUT = 180000000000L; // 180s in ns @@ -174,12 +164,8 @@ public class PluginAppletViewer extends XEmbeddedFrame private static final Object requestMutex = new Object(); private static long requestIdentityCounter = 0L; - private Image bufFrameImg; - private Graphics bufFrameImgGraphics; - - private SplashPanel splashPanel; - + private static long REQUEST_TIMEOUT=60000;//60s private static void waitForRequestCompletion(PluginCallRequest request) { @@ -199,25 +185,25 @@ public class PluginAppletViewer extends XEmbeddedFrame /** * Null constructor to allow instantiation via newInstance() */ - public PluginAppletViewer() { + public PluginApplet3Viewer() { + panel = null; } - public static PluginAppletViewer framePanel(int identifier, long handle, int width, int height, NetxPanel panel) { + public static PluginApplet3Viewer framePanel(int identifier, NetxApplet3Panel panel) { PluginDebug.debug("Framing ", panel); - + // SecurityManager MUST be set, and only privileged code may call framePanel() System.getSecurityManager().checkPermission(new AllPermission()); - PluginAppletViewer appletFrame = new PluginAppletViewer(handle, identifier, panel); - appletFrame.setSize(width, height); - - appletFrame.appletEventListener = new AppletEventListener(appletFrame, appletFrame); + PluginApplet3Viewer appletFrame = new PluginApplet3Viewer(identifier, panel); + + appletFrame.appletEventListener = new AppletEventListener(appletFrame); panel.addAppletListener(appletFrame.appletEventListener); // Clear references, if any if (applets.containsKey(identifier)) { - PluginAppletViewer oldFrame = applets.get(identifier); - oldFrame.remove(panel); + PluginApplet3Viewer oldFrame = applets.get(identifier); + // FIXME oldFrame.remove(panel); panel.removeAppletListener(oldFrame.appletEventListener); } @@ -233,10 +219,7 @@ public class PluginAppletViewer extends XEmbeddedFrame /** * Create new plugin appletviewer frame */ - private PluginAppletViewer(long handle, final int identifier, - NetxPanel appletPanel) { - - super(handle, true); + private PluginApplet3Viewer(final int identifier, NetxApplet3Panel appletPanel) { this.identifier = identifier; this.panel = appletPanel; @@ -245,6 +228,7 @@ public class PluginAppletViewer extends XEmbeddedFrame appletPanels.addElement(panel); } + /** FIXME windowEventListener = new WindowAdapter() { @Override @@ -262,74 +246,21 @@ public class PluginAppletViewer extends XEmbeddedFrame appletStart(); } }; - addWindowListener(windowEventListener); - final AppletPanel fPanel = panel; - try { - SwingUtilities.invokeAndWait(new SplashCreator(fPanel)); - } catch (Exception e) { - OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); // Not much we can do other than print - } + */ + new SplashCreator(panel); + } + /** Called by {@link SplashCreator#run()} */ + private void initializeViewAndSlash(final Applet3Panel fPanel) { } @Override public void replaceSplash(final SplashPanel newSplash) { - if (splashPanel == null) { - return; - } - if (newSplash == null) { - removeSplash(); - return; - } - try { - SwingUtilities.invokeAndWait(new Runnable() { - - @Override - public void run() { - splashPanel.getSplashComponent().setVisible(false); - splashPanel.stopAnimation(); - remove(splashPanel.getSplashComponent()); - newSplash.setPercentage(splashPanel.getPercentage()); - newSplash.setSplashWidth(splashPanel.getSplashWidth()); - newSplash.setSplashHeight(splashPanel.getSplashHeight()); - newSplash.adjustForSize(); - splashPanel = newSplash; - add("Center", splashPanel.getSplashComponent()); - pack(); - } - }); - } catch (Exception e) { - OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); // Not much we can do other than print - } } @Override public void removeSplash() { - if (splashPanel == null) { - return; - } - try { - SwingUtilities.invokeAndWait(new Runnable() { - - @Override - public void run() { - splashPanel.getSplashComponent().setVisible(false); - splashPanel.stopAnimation(); - removeAll(); - setLayout(new BorderLayout()); - //remove(splashPanel.getSplashComponent()); - splashPanel = null; - //remove(panel); - // Re-add the applet to notify container - add(panel); - panel.setVisible(true); - pack(); - } - }); - } catch (Exception e) { - OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); // Not much we can do other than print - } } @Override @@ -351,17 +282,15 @@ public class PluginAppletViewer extends XEmbeddedFrame } private static class AppletEventListener implements AppletListener { - final Frame frame; - final PluginAppletViewer appletViewer; + final PluginApplet3Viewer appletViewer; - public AppletEventListener(Frame frame, PluginAppletViewer appletViewer) { - this.frame = frame; + public AppletEventListener(PluginApplet3Viewer appletViewer) { this.appletViewer = appletViewer; } @Override public void appletStateChanged(AppletEvent evt) { - AppletPanel src = (AppletPanel) evt.getSource(); + Applet3Panel src = (Applet3Panel) evt.getSource(); panelLock.lock(); panelLive.signalAll(); @@ -369,14 +298,14 @@ public class PluginAppletViewer extends XEmbeddedFrame switch (evt.getID()) { case AppletPanel.APPLET_RESIZE: { if (src != null) { - appletViewer.setSize(appletViewer.getPreferredSize()); - appletViewer.validate(); + // FIXME ? appletViewer.setSize(appletViewer.getPreferredSize()); + // We already resized .. } break; } case AppletPanel.APPLET_LOADING_COMPLETED: { - Applet a = src.getApplet(); // sun.applet.AppletPanel - + /** + Applet3 a = src.getApplet(); // sun.applet.AppletPanel // Fixed #4754451: Applet can have methods running on main // thread event queue. // @@ -392,10 +321,10 @@ public class PluginAppletViewer extends XEmbeddedFrame // so we will have to rearrange it as well. // if (a != null) { - AppletPanel.changeFrameAppContext(frame, SunToolkit.targetToAppContext(a)); + Applet3Panel.changeFrameAppContext(src.appletWindow, SunToolkit.targetToAppContext(a)); } - else { - AppletPanel.changeFrameAppContext(frame, AppContext.getAppContext()); + else */ { + Applet3Panel.changeFrameAppContext(src.getAppletWindow(), App3Context.getAppContext()); } updateStatus(appletViewer.identifier, PAV_INIT_STATUS.INIT_COMPLETE); @@ -403,7 +332,8 @@ public class PluginAppletViewer extends XEmbeddedFrame break; } case AppletPanel.APPLET_START: { - if (src.status != AppletPanel.APPLET_INIT && src.status != AppletPanel.APPLET_STOP) { + final int src_status = src.getStatus(); + if (src_status != AppletPanel.APPLET_INIT && src_status != AppletPanel.APPLET_STOP) { String s="Applet started, but but reached invalid state"; PluginDebug.debug(s); SplashPanel sp=SplashUtils.getErrorSplashScreen(appletViewer.panel.getWidth(), appletViewer.panel.getHeight(), new Exception(s)); @@ -454,7 +384,7 @@ public class PluginAppletViewer extends XEmbeddedFrame message = message.substring(nextSpaceLocation + 1); } - long handle = Long.parseLong(msgParts[0]); + final long nativeWindowHandle = Long.parseLong(msgParts[0]); String width = msgParts[1]; String height = msgParts[2]; @@ -462,14 +392,14 @@ public class PluginAppletViewer extends XEmbeddedFrame String documentBase = message.substring("tag".length() + 1, spaceLocation); String paramString = message.substring(spaceLocation + 1); - PluginDebug.debug("Handle = ", handle, "\n", + PluginDebug.debug("Handle = 0x", Long.toHexString(nativeWindowHandle), "\n", "Width = ", width, "\n", "Height = ", height, "\n", "DocumentBase = ", documentBase, "\n", "Params = ", paramString); - PluginAppletPanelFactory factory = new PluginAppletPanelFactory(); - AppletMessageHandler amh = new AppletMessageHandler("appletviewer"); + PluginApplet3PanelFactory factory = new PluginApplet3PanelFactory(); + Applet3MessageHandler amh = new Applet3MessageHandler("appletviewer"); URL url = new URL(documentBase); URLConnection conn = url.openConnection(); /* The original URL may have been redirected - this @@ -481,7 +411,7 @@ public class PluginAppletViewer extends XEmbeddedFrame // Let user know we are starting up streamhandler.write("instance " + identifier + " status " + amh.getMessage("status.start")); - factory.createPanel(streamhandler, identifier, handle, url, params); + factory.createPanel(streamhandler, identifier, nativeWindowHandle, url, params); long maxTimeToSleep = APPLET_TIMEOUT; appletsLock.lock(); @@ -557,14 +487,14 @@ public class PluginAppletViewer extends XEmbeddedFrame applets.get(identifier).handleMessage(reference, message); } } catch (Exception e) { - OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); // If an exception happened during pre-init, we need to update status updateStatus(identifier, PAV_INIT_STATUS.INACTIVE); - throw new RuntimeException("Failed to handle message: " + - message + " for instance " + identifier, e); + e.printStackTrace(); // FIXME + + throw new RuntimeException("Failed to handle message: " + message + " for instance " + identifier, e); } } @@ -617,10 +547,13 @@ public class PluginAppletViewer extends XEmbeddedFrame */ private static synchronized void destroyApplet(int identifier) { + final PluginApplet3Viewer pav = applets.get(identifier); - // We should not try to destroy an applet during - // initialization. It may cause an inconsistent state. - waitForAppletInit( applets.get(identifier).panel ); + if( null != pav ) { + // We should not try to destroy an applet during + // initialization. It may cause an inconsistent state. + waitForAppletInit( pav.panel ); + } PluginDebug.debug("DestroyApplet called for ", identifier); @@ -635,24 +568,16 @@ public class PluginAppletViewer extends XEmbeddedFrame PluginDebug.debug("Attempting to destroy frame ", identifier); // Try to dispose the panel right away - final PluginAppletViewer pav = applets.get(identifier); if (pav != null) { - pav.dispose(); - // If panel is already disposed, return - if (pav.panel.applet == null) { + if (pav.panel.getApplet() == null) { PluginDebug.debug(identifier, " panel inactive. Returning."); return; } PluginDebug.debug("Attempting to destroy panel ", identifier); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - pav.appletClose(); - } - }); + pav.appletClose(); } PluginDebug.debug(identifier, " destroyed"); @@ -665,7 +590,7 @@ public class PluginAppletViewer extends XEmbeddedFrame * * @param panel the instance to wait for. */ - public static void waitForAppletInit(NetxPanel panel) { + public static void waitForAppletInit(NetxApplet3Panel panel) { PluginDebug.debug("Waiting for applet init"); @@ -674,7 +599,7 @@ public class PluginAppletViewer extends XEmbeddedFrame panelLock.lock(); try { - while (!panel.isInitialized() && + while (!panel.isInitialized() && maxTimeToSleep > 0) { PluginDebug.debug("Waiting for applet panel ", panel, " to initialize..."); maxTimeToSleep -= waitTillTimeout(panelLock, panelLive, maxTimeToSleep); @@ -687,41 +612,6 @@ public class PluginAppletViewer extends XEmbeddedFrame PluginDebug.debug("Applet panel ", panel, " initialized"); } - /* Resizes an applet panel, waiting for the applet to initialze. - * Should be done asynchronously to avoid the chance of deadlock. */ - private void resizeAppletPanel(final int width, final int height) { - // Wait for panel to come alive - waitForAppletInit(panel); - - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - panel.updateSizeInAtts(height, width); - - setSize(width, height); - - // There is a rather odd drawing bug whereby resizing - // the panel makes no difference on initial call - // because the panel thinks that it is already the - // right size. Validation has no effect there either. - // So we work around by setting size to 1, validating, - // and then setting to the right size and validating - // again. This is not very efficient, and there is - // probably a better way -- but resizing happens - // quite infrequently, so for now this is how we do it - - panel.setSize(1, 1); - panel.validate(); - - panel.setSize(width, height); - panel.validate(); - - panel.applet.resize(width, height); - panel.applet.validate(); - } - }); - } - public void handleMessage(int reference, String message) { if (message.startsWith("width")) { @@ -731,14 +621,14 @@ public class PluginAppletViewer extends XEmbeddedFrame final int width = Integer.parseInt(dimMsg[1]); final int height = Integer.parseInt(dimMsg[3]); - /* Resize the applet asynchronously, to avoid the chance of - * deadlock while waiting for the applet to initialize. - * + /* Resize the applet asynchronously, to avoid the chance of + * deadlock while waiting for the applet to initialize. + * * In general, worker threads should spawn new threads for any blocking operations. */ Thread resizeAppletThread = new Thread("resizeAppletThread") { @Override public void run() { - resizeAppletPanel(width, height); + resize(width, height); } }; @@ -775,105 +665,19 @@ public class PluginAppletViewer extends XEmbeddedFrame } } - /* - * Methods for java.applet.AppletContext - */ - - private static Map<URL, AudioClip> audioClips = new HashMap<URL, AudioClip>(); - - /** - * Get an audio clip. - */ - @Override - public AudioClip getAudioClip(URL url) { - checkConnect(url); - synchronized (audioClips) { - AudioClip clip = audioClips.get(url); - if (clip == null) { - audioClips.put(url, clip = new AppletAudioClip(url)); - } - return clip; - } - } - - private static Map<URL, AppletImageRef> imageRefs = new HashMap<URL, AppletImageRef>(); - - /** - * Get an image. - */ - @Override - public Image getImage(URL url) { - return getCachedImage(url); - } - - private Image getCachedImage(URL url) { - return (Image) getCachedImageRef(url).get(); - } - - /** - * Get an image ref. - */ - private synchronized Ref getCachedImageRef(URL url) { - PluginDebug.debug("getCachedImageRef() searching for ", url); - - try { - - String originalURL = url.toString(); - String codeBase = panel.getCodeBase().toString(); - - if (originalURL.startsWith(codeBase)) { - - PluginDebug.debug("getCachedImageRef() got URL = ", url); - PluginDebug.debug("getCachedImageRef() plugin codebase = ", codeBase); - - String resourceName = originalURL.substring(codeBase.length()); - JNLPClassLoader loader = (JNLPClassLoader) panel.getAppletClassLoader(); - - URL localURL = null; - if (loader.resourceAvailableLocally(resourceName)) { - url = loader.getResource(resourceName); - } - - url = localURL != null ? localURL : url; - } - - PluginDebug.debug("getCachedImageRef() getting img from URL = ", url); - - synchronized (imageRefs) { - AppletImageRef ref = imageRefs.get(url); - if (ref == null) { - ref = new AppletImageRef(url); - imageRefs.put(url, ref); - } - return ref; - } - } catch (Exception e) { - OutputController.getLogger().log(OutputController.Level.ERROR_ALL, "Error occurred when trying to fetch image:"); - OutputController.getLogger().log(e); - return null; - } - } - - /** - * Flush the image cache. - */ - static void flushImageCache() { - imageRefs.clear(); - } - - private static Vector<NetxPanel> appletPanels = new Vector<NetxPanel>(); + private static Vector<NetxApplet3Panel> appletPanels = new Vector<NetxApplet3Panel>(); /** * Get an applet by name. */ @Override - public Applet getApplet(String name) { + public Applet3Context getAppletContext(String name) { name = name.toLowerCase(); SocketPermission panelSp = new SocketPermission(panel.getCodeBase().getHost(), "connect"); synchronized(appletPanels) { - for (Enumeration<NetxPanel> e = appletPanels.elements(); e.hasMoreElements();) { - AppletPanel p = e.nextElement(); + for (Enumeration<NetxApplet3Panel> e = appletPanels.elements(); e.hasMoreElements();) { + Applet3Panel p = e.nextElement(); String param = p.getParameter("name"); if (param != null) { param = param.toLowerCase(); @@ -885,7 +689,7 @@ public class PluginAppletViewer extends XEmbeddedFrame new SocketPermission(p.getCodeBase().getHost(), "connect"); if (panelSp.implies(sp)) { - return p.applet; + return p; } } } @@ -893,25 +697,51 @@ public class PluginAppletViewer extends XEmbeddedFrame return null; } - /** - * Return an enumeration of all the accessible - * applets on this page. - */ @Override - public Enumeration<Applet> getApplets() { - Vector<Applet> v = new Vector<Applet>(); + public Applet3 getApplet() { + return panel.getApplet(); + } + + @Override + public String getAppletName() { + return panel.getAppletName(); + } + + @Override + public boolean isActive() { + return panel.isActive(); + } + + @Override + public URL getDocumentBase() { + return panel.getDocumentBase(); + } + + @Override + public URL getCodeBase() { + return panel.getCodeBase(); + } + + @Override + public String getParameter(String name) { + return panel.getParameter(name); + } + + @Override + public Enumeration<Applet3Context> getAllAppletContexts() { + Vector<Applet3Context> v = new Vector<Applet3Context>(); SocketPermission panelSp = new SocketPermission(panel.getCodeBase().getHost(), "connect"); synchronized(appletPanels) { - for (Enumeration<NetxPanel> e = appletPanels.elements(); e.hasMoreElements();) { - AppletPanel p = e.nextElement(); + for (Enumeration<NetxApplet3Panel> e = appletPanels.elements(); e.hasMoreElements();) { + Applet3Panel p = e.nextElement(); if (p.getDocumentBase().equals(panel.getDocumentBase())) { SocketPermission sp = new SocketPermission(p.getCodeBase().getHost(), "connect"); if (panelSp.implies(sp)) { - v.addElement(p.applet); + v.addElement(p); } } } @@ -919,6 +749,38 @@ public class PluginAppletViewer extends XEmbeddedFrame return v.elements(); } + /* Resizes an applet panel, waiting for the applet to initialze. + * Should be done asynchronously to avoid the chance of deadlock. */ + @Override + public void resize(final int width, final int height) { + /** FIXME: Resize native browser window ! + if (appEvtQ != null){ + appEvtQ.postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(), + new Runnable(){ + public void run(){ + if(ap != null) + { + ap.dispatchAppletEvent(APPLET_RESIZE, currentSize); + } + } + })); + } + */ + appletResize(width, height); + } + + /** + * Called when the applet wants to be resized. + * + * @param width the new requested width for the applet. + * @param height the new requested height for the applet. + */ + public void appletResize(int width, int height) { + // Wait for panel to come alive + waitForAppletInit(panel); + panel.appletResize(width, height); + } + @Override public void showDocument(URL url) { PluginDebug.debug("Showing document..."); @@ -1379,17 +1241,6 @@ public class PluginAppletViewer extends XEmbeddedFrame } /** - * Make sure the atrributes are uptodate. - */ - public void updateAtts() { - Dimension d = panel.getSize(); - Insets in = panel.getInsets(); - int width = d.width - (in.left + in.right); - int height = d.height - (in.top + in.bottom); - panel.updateSizeInAtts(height, width); - } - - /** * Restart the applet. */ void appletRestart() { @@ -1419,8 +1270,8 @@ public class PluginAppletViewer extends XEmbeddedFrame * at the same time. */ try { - ((AppletViewerPanel)panel).joinAppletThread(); - ((AppletViewerPanel)panel).release(); + ((Applet3Panel)panel).joinAppletThread(); + ((Applet3Panel)panel).release(); } catch (InterruptedException e) { return; // abort the reload } @@ -1428,7 +1279,7 @@ public class PluginAppletViewer extends XEmbeddedFrame AccessController.doPrivileged(new PrivilegedAction<Void>() { @Override public Void run() { - ((AppletViewerPanel)panel).createAppletThread(); + ((Applet3Panel)panel).createAppletThread(); return null; } }); @@ -1438,11 +1289,6 @@ public class PluginAppletViewer extends XEmbeddedFrame panel.sendEvent(AppletPanel.APPLET_START); } - @Override - public int print(Graphics graphics, PageFormat pf, int pageIndex) { - return Printable.NO_SUCH_PAGE; - } - /** * Start the applet. */ @@ -1461,7 +1307,7 @@ public class PluginAppletViewer extends XEmbeddedFrame * Shutdown a viewer. * Stop, Destroy, Dispose and Quit a viewer */ - private void appletShutdown(AppletPanel p) { + private void appletShutdown(Applet3Panel p) { p.sendEvent(AppletPanel.APPLET_STOP); p.sendEvent(AppletPanel.APPLET_DESTROY); p.sendEvent(AppletPanel.APPLET_DISPOSE); @@ -1480,13 +1326,12 @@ public class PluginAppletViewer extends XEmbeddedFrame // spawn a new thread to avoid blocking the event queue // when calling appletShutdown. // - final AppletPanel p = panel; + final Applet3Panel p = panel; new Thread(new Runnable() { - @SuppressWarnings("deprecation") @Override public void run() { - ClassLoader cl = p.applet.getClass().getClassLoader(); + ClassLoader cl = p.getApplet().getClass().getClassLoader(); // Since we want to deal with JNLPClassLoader, extract it if this // is a codebase loader @@ -1496,20 +1341,10 @@ public class PluginAppletViewer extends XEmbeddedFrame appletShutdown(p); appletPanels.removeElement(p); - + // Mark classloader unusable ((JNLPClassLoader) cl).decrementLoaderUseCount(); - try { - SwingUtilities.invokeAndWait(new Runnable() { - @Override - public void run() { - dispose(); - } - }); - } catch (Exception e) { // ignore, we are just disposing it - } - if (countApplets() == 0) { appletSystemExit(); } @@ -1537,57 +1372,6 @@ public class PluginAppletViewer extends XEmbeddedFrame } - private static void checkConnect(URL url) { - SecurityManager security = System.getSecurityManager(); - if (security != null) { - try { - java.security.Permission perm = - url.openConnection().getPermission(); - if (perm != null) { - security.checkPermission(perm); - } - else { - security.checkConnect(url.getHost(), url.getPort()); - } - } catch (java.io.IOException ioe) { - security.checkConnect(url.getHost(), url.getPort()); - } - } - } - - /** - * {@inheritDoc} - * - * This method calls paint directly, rather than via super.update() since - * the parent class's update() just does a couple of checks (both of - * which are accounted for) and then calls paint anyway. - */ - @Override - public void paint(Graphics g) { - - // If the image or the graphics don't exist, create new ones - if (bufFrameImg == null || bufFrameImgGraphics == null) { - // although invisible applets do not have right to paint - // we rather paint to 1x1 to be sure all callbacks will be completed - bufFrameImg = createImage(Math.max(1, getWidth()), Math.max(1, getHeight())); - bufFrameImgGraphics = bufFrameImg.getGraphics(); - } - - // Paint off-screen - for (Component c: this.getComponents()) { - c.paint(bufFrameImgGraphics); - } - - // Draw the painted image - g.drawImage(bufFrameImg, 0, 0, this); - } - - - @Override - public void update(Graphics g) { - paint(g); - } - /** * Waits on a given condition queue until timeout. * @@ -1625,23 +1409,15 @@ public class PluginAppletViewer extends XEmbeddedFrame private class SplashCreator implements Runnable { - private final AppletPanel fPanel; + private final Applet3Panel fPanel; - public SplashCreator(AppletPanel fPanel) { + public SplashCreator(Applet3Panel fPanel) { this.fPanel = fPanel; } @Override public void run() { - add("Center", fPanel); - fPanel.setVisible(false); - splashPanel = SplashUtils.getSplashScreen(fPanel.getWidth(), fPanel.getHeight()); - if (splashPanel != null) { - splashPanel.startAnimation(); - PluginDebug.debug("Added splash " + splashPanel); - add("Center", splashPanel.getSplashComponent()); - } - pack(); + initializeViewAndSlash(fPanel); } } } diff --git a/plugin/icedteanp/java/netscape/javascript/JSObject.java b/plugin/icedteanp/java/netscape/javascript/JSObject.java index 489efa6..d3eec67 100644 --- a/plugin/icedteanp/java/netscape/javascript/JSObject.java +++ b/plugin/icedteanp/java/netscape/javascript/JSObject.java @@ -50,7 +50,7 @@ import java.applet.Applet; import java.security.AccessControlException; import java.security.AccessController; -import sun.applet.PluginAppletViewer; +import jogamp.plugin.applet.PluginApplet3Viewer; import sun.applet.PluginDebug; /** @@ -162,7 +162,7 @@ public final class JSObject { public Object getMember(String name) { PluginDebug.debug("JSObject.getMember ", name); - Object o = PluginAppletViewer.getMember(internal, name); + Object o = PluginApplet3Viewer.getMember(internal, name); PluginDebug.debug("JSObject.getMember GOT ", o); return o; } @@ -175,7 +175,7 @@ public final class JSObject { public Object getSlot(int index) { PluginDebug.debug("JSObject.getSlot ", index); - return PluginAppletViewer.getSlot(internal, index); + return PluginApplet3Viewer.getSlot(internal, index); } /** @@ -185,7 +185,7 @@ public final class JSObject { public void setMember(String name, Object value) { PluginDebug.debug("JSObject.setMember ", name, " ", value); - PluginAppletViewer.setMember(internal, name, value); + PluginApplet3Viewer.setMember(internal, name, value); } /** @@ -198,7 +198,7 @@ public final class JSObject { public void setSlot(int index, Object value) { PluginDebug.debug("JSObject.setSlot ", index, " ", value); - PluginAppletViewer.setSlot(internal, index, value); + PluginApplet3Viewer.setSlot(internal, index, value); } /** @@ -207,7 +207,7 @@ public final class JSObject { public void removeMember(String name) { PluginDebug.debug("JSObject.removeMember ", name); - PluginAppletViewer.removeMember(internal, name); + PluginApplet3Viewer.removeMember(internal, name); } /** @@ -223,7 +223,7 @@ public final class JSObject { PluginDebug.debug(" ", arg); } PluginDebug.debug(""); - return PluginAppletViewer.call(internal, methodName, args); + return PluginApplet3Viewer.call(internal, methodName, args); } /** @@ -233,7 +233,7 @@ public final class JSObject { */ public Object eval(String s) { PluginDebug.debug("JSObject.eval ", s); - return PluginAppletViewer.eval(internal, s); + return PluginApplet3Viewer.eval(internal, s); } /** @@ -241,7 +241,7 @@ public final class JSObject { */ public String toString() { PluginDebug.debug("JSObject.toString"); - return PluginAppletViewer.javascriptToString(internal); + return PluginApplet3Viewer.javascriptToString(internal); } // should use some sort of identifier rather than String @@ -255,8 +255,7 @@ public final class JSObject { PluginDebug.debug("JSObject.getWindow"); // FIXME: handle long case as well. long internal = 0; - internal = ((PluginAppletViewer) - applet.getAppletContext()).getWindow(); + internal = ((PluginApplet3Viewer)applet.getAppletContext()).getWindow(); PluginDebug.debug("GOT IT: ", internal); return new JSObject(internal); } @@ -272,6 +271,6 @@ public final class JSObject { return; PluginDebug.debug("JSObject.finalize "); - PluginAppletViewer.JavaScriptFinalize(internal); + PluginApplet3Viewer.JavaScriptFinalize(internal); } } diff --git a/plugin/icedteanp/java/sun/applet/Applet3MessageHandler.java b/plugin/icedteanp/java/sun/applet/Applet3MessageHandler.java new file mode 100644 index 0000000..140e5eb --- /dev/null +++ b/plugin/icedteanp/java/sun/applet/Applet3MessageHandler.java @@ -0,0 +1,21 @@ +package sun.applet; + +import sun.applet.AppletMessageHandler; + +public class Applet3MessageHandler extends AppletMessageHandler { + + public Applet3MessageHandler(String baseKey) { + super(baseKey); + } + + public String getMessage(String key) { + return super.getMessage(key); + } + public String getMessage(String key, Object arg){ + return super.getMessage(key, arg); + } + public String getMessage(String key, Object arg1, Object arg2){ + return super.getMessage(key, arg1, arg2); + } + +} diff --git a/plugin/icedteanp/java/sun/applet/PluginCookieManager.java b/plugin/icedteanp/java/sun/applet/PluginCookieManager.java index 21bdbc0..de58d07 100644 --- a/plugin/icedteanp/java/sun/applet/PluginCookieManager.java +++ b/plugin/icedteanp/java/sun/applet/PluginCookieManager.java @@ -45,6 +45,8 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import jogamp.plugin.applet.PluginApplet3Viewer; + import com.sun.jndi.toolkit.url.UrlUtil; public class PluginCookieManager extends CookieManager { @@ -64,8 +66,7 @@ public class PluginCookieManager extends CookieManager { Map<String, List<String>> cookieMap = new java.util.HashMap<String, List<String>>(); - String cookies = (String) PluginAppletViewer - .requestPluginCookieInfo(uri); + String cookies = (String) PluginApplet3Viewer.requestPluginCookieInfo(uri); List<String> cookieHeader = new java.util.ArrayList<String>(); if (cookies != null && cookies.length() > 0) diff --git a/plugin/icedteanp/java/sun/applet/PluginMain.java b/plugin/icedteanp/java/sun/applet/PluginMain.java index 421edb5..32b8ab6 100644 --- a/plugin/icedteanp/java/sun/applet/PluginMain.java +++ b/plugin/icedteanp/java/sun/applet/PluginMain.java @@ -77,14 +77,13 @@ import java.util.Enumeration; import java.util.Hashtable; import java.util.Map; import java.util.Properties; -import sun.awt.AppContext; -import sun.awt.SunToolkit; +import jogamp.applet.App3Context; +import jogamp.plugin.applet.PluginApplet3Viewer; import net.sourceforge.jnlp.config.DeploymentConfiguration; import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.security.JNLPAuthenticator; import net.sourceforge.jnlp.util.logging.JavaConsole; -import net.sourceforge.jnlp.util.logging.LogConfig; import net.sourceforge.jnlp.util.logging.OutputController; /** @@ -127,8 +126,12 @@ public class PluginMain { OutputController.getLogger().log(i + ": "+string); } + /** if (AppContext.getAppContext() == null) { SunToolkit.createNewAppContext(); + } */ + if (App3Context.getAppContext() == null) { + App3Context.createAppContext(); } installDummyJavascriptProtocolHandler(); @@ -152,8 +155,10 @@ public class PluginMain { PluginAppletSecurityContext.setStreamhandler(streamHandler); AppletSecurityContextManager.addContext(0, sc); - PluginAppletViewer.setStreamhandler(streamHandler); - PluginAppletViewer.setPluginCallRequestFactory(new PluginCallRequestFactory()); + // FIXME PluginAppletViewer.setStreamhandler(streamHandler); + // FIXME PluginAppletViewer.setPluginCallRequestFactory(new PluginCallRequestFactory()); + PluginApplet3Viewer.setStreamhandler(streamHandler); // FIXME + PluginApplet3Viewer.setPluginCallRequestFactory(new PluginCallRequestFactory()); // FIXME init(); diff --git a/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java b/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java index 1de8bd7..1975cba 100644 --- a/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java +++ b/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java @@ -41,7 +41,7 @@ import java.util.ArrayList; import java.util.LinkedList; import net.sourceforge.jnlp.util.logging.OutputController; -class PluginMessageConsumer { +public class PluginMessageConsumer { private static final int MAX_PARALLEL_INITS = 1; diff --git a/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java b/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java index 79d925d..c945b8e 100644 --- a/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java +++ b/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java @@ -39,7 +39,7 @@ package sun.applet; import net.sourceforge.jnlp.util.logging.OutputController; -class PluginMessageHandlerWorker extends Thread { +public class PluginMessageHandlerWorker extends Thread { private boolean free = true; private final boolean isPriorityWorker; diff --git a/plugin/icedteanp/java/sun/applet/PluginParameterParser.java b/plugin/icedteanp/java/sun/applet/PluginParameterParser.java index 1db6034..56dabc9 100644 --- a/plugin/icedteanp/java/sun/applet/PluginParameterParser.java +++ b/plugin/icedteanp/java/sun/applet/PluginParameterParser.java @@ -6,7 +6,7 @@ import java.util.Map; import net.sourceforge.jnlp.PluginParameters; -class PluginParameterParser { +public class PluginParameterParser { static private final char DELIMITER_ESCAPE = ':'; static private final String KEY_VALUE_DELIMITER = ";"; diff --git a/plugin/icedteanp/java/sun/applet/PluginProxySelector.java b/plugin/icedteanp/java/sun/applet/PluginProxySelector.java index 25689f5..7355ab9 100644 --- a/plugin/icedteanp/java/sun/applet/PluginProxySelector.java +++ b/plugin/icedteanp/java/sun/applet/PluginProxySelector.java @@ -45,6 +45,8 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; +import jogamp.plugin.applet.PluginApplet3Viewer; + import com.sun.jndi.toolkit.url.UrlUtil; import net.sourceforge.jnlp.config.DeploymentConfiguration; @@ -135,7 +137,7 @@ public class PluginProxySelector extends JNLPProxySelector { /** For tests to override */ protected Object getProxyFromRemoteCallToBrowser(String uri) { - return PluginAppletViewer.requestPluginProxyInfo(uri); + return PluginApplet3Viewer.requestPluginProxyInfo(uri); } /** diff --git a/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java b/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java index 990a903..d45cdc4 100644 --- a/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java +++ b/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java @@ -46,7 +46,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.nio.charset.Charset; -import javax.swing.SwingUtilities; +import jogamp.plugin.applet.PluginApplet3Viewer; import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.runtime.Translator; import net.sourceforge.jnlp.util.logging.JavaConsole; @@ -230,12 +230,14 @@ public class PluginStreamHandler { final String frest = rest; if (type.equals("instance")) { - PluginAppletViewer.handleMessage(identifier, freference, frest); + PluginApplet3Viewer.handleMessage(identifier, freference, frest); // FIXME + // FIXME PluginAppletViewer.handleMessage(identifier, freference, frest); } else if (type.equals("context")) { PluginDebug.debug("Sending to PASC: ", identifier, "/", reference, " and ", rest); AppletSecurityContextManager.handleMessage(identifier, reference, src, privileges, rest); } } catch (Exception e) { + e.printStackTrace(); // FIXME throw new PluginException(this, identifier, reference, e); } } |