~ubuntu-branches/ubuntu/oneiric/icedtea-web/oneiric

« back to all changes in this revision

Viewing changes to plugin/icedteanp/java/sun/applet/PluginAppletViewer.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2011-04-06 13:10:44 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110406131044-6jky8obchc43cf02
Tags: 1.1~20110406-0ubuntu1
Fix typo in icedtea-netx postinst to install the javaws alternative.

Show diffs side-by-side

added added

removed removed

Lines of Context:
189
189
            return null;
190
190
        }
191
191
 
192
 
        PluginDebug.debug("Applet " + a.getClass() + " initialized");
 
192
        PluginDebug.debug("Applet ", a.getClass(), " initialized");
193
193
        streamhandler.write("instance " + identifier + " reference 0 initialized");
194
194
 
195
195
        AppletSecurityContextManager.getSecurityContext(0).associateSrc(((NetxPanel) panel).getAppletClassLoader(), doc);
232
232
            String[] events = splitSeparator(",", eventList);
233
233
 
234
234
            for (int i = 0; i < events.length; i++) {
235
 
                PluginDebug.debug("Adding event to queue: " + events[i]);
 
235
                PluginDebug.debug("Adding event to queue: ", events[i]);
236
236
                if (events[i].equals("dispose"))
237
237
                    panel.sendEvent(AppletPanel.APPLET_DISPOSE);
238
238
                else if (events[i].equals("load"))
251
251
                    panel.sendEvent(AppletPanel.APPLET_ERROR);
252
252
                else
253
253
                    // non-fatal error if we get an unrecognized event
254
 
                    PluginDebug.debug("Unrecognized event name: " + events[i]);
 
254
                    PluginDebug.debug("Unrecognized event name: ", events[i]);
255
255
            }
256
256
 
257
257
            while (!panel.emptyEventQueue())
371
371
    public static void framePanel(int identifier, PrintStream statusMsgStream,
372
372
                                  long handle, AppletViewerPanel panel) {
373
373
 
374
 
        PluginDebug.debug("Framing " + panel);
 
374
        PluginDebug.debug("Framing ", panel);
375
375
 
376
376
        // SecurityManager MUST be set, and only privileged code may call reFrame()
377
377
        System.getSecurityManager().checkPermission(new AllPermission());
386
386
 
387
387
        applets.put(identifier, appletFrame);
388
388
 
389
 
        PluginDebug.debug(panel + " framed");
 
389
        PluginDebug.debug(panel, " framed");
390
390
    }
391
391
 
392
392
    /**
486
486
     */
487
487
    public static void handleMessage(int identifier, int reference, String message) {
488
488
 
489
 
        PluginDebug.debug("PAV handling: " + message);
 
489
        PluginDebug.debug("PAV handling: ", message);
490
490
 
491
491
        try {
492
492
            if (message.startsWith("handle")) {
515
515
                        UrlUtil.decode(message.substring("tag".length() + 1, spaceLocation));
516
516
                String tag = message.substring(spaceLocation + 1);
517
517
 
518
 
                PluginDebug.debug("Handle = " + handle + "\n" +
519
 
                                    "Width = " + width + "\n" +
520
 
                                    "Height = " + height + "\n" +
521
 
                                    "DocumentBase = " + documentBase + "\n" +
522
 
                                    "Tag = " + tag);
 
518
                PluginDebug.debug("Handle = ", handle, "\n",
 
519
                                    "Width = ", width, "\n",
 
520
                                    "Height = ", height, "\n",
 
521
                                    "DocumentBase = ", documentBase, "\n",
 
522
                                    "Tag = ", tag);
523
523
 
524
524
                PluginAppletViewer.parse
525
525
                                        (identifier, handle, width, height,
561
561
 
562
562
                // Set it inactive, and try to do cleanup is applicable
563
563
                PAV_INIT_STATUS previousStatus = updateStatus(identifier, PAV_INIT_STATUS.INACTIVE);
564
 
                PluginDebug.debug("Destroy status set for " + identifier);
 
564
                PluginDebug.debug("Destroy status set for ", identifier);
565
565
 
566
566
                if (previousStatus != null &&
567
567
                         previousStatus.equals(PAV_INIT_STATUS.REFRAME_COMPLETE)) {
569
569
                }
570
570
 
571
571
            } else {
572
 
                PluginDebug.debug("Handling message: " + message + " instance " + identifier + " " + Thread.currentThread());
 
572
                PluginDebug.debug("Handling message: ", message, " instance ", identifier, " ", Thread.currentThread());
573
573
 
574
574
                // Wait till initialization finishes
575
575
                while (!applets.containsKey(identifier) &&
643
643
 
644
644
    private static synchronized void destroyApplet(int identifier) {
645
645
 
646
 
        PluginDebug.debug("DestroyApplet called for " + identifier);
 
646
        PluginDebug.debug("DestroyApplet called for ", identifier);
647
647
 
648
648
        PAV_INIT_STATUS prev = updateStatus(identifier, PAV_INIT_STATUS.DESTROYED);
649
649
 
650
650
        // If already destroyed, return
651
651
        if (prev.equals(PAV_INIT_STATUS.DESTROYED)) {
652
 
            PluginDebug.debug(identifier + " already destroyed. Returning.");
 
652
            PluginDebug.debug(identifier, " already destroyed. Returning.");
653
653
            return;
654
654
        }
655
655
 
656
 
        PluginDebug.debug("Attempting to destroy frame " + identifier);
 
656
        PluginDebug.debug("Attempting to destroy frame ", identifier);
657
657
 
658
658
        // Try to dispose the panel right away
659
659
        if (applets.containsKey(identifier))
661
661
 
662
662
        // If panel is already disposed, return
663
663
        if (applets.get(identifier).panel.applet == null) {
664
 
            PluginDebug.debug(identifier + " panel inactive. Returning.");
 
664
            PluginDebug.debug(identifier, " panel inactive. Returning.");
665
665
            return;
666
666
        }
667
667
 
668
 
        PluginDebug.debug("Attempting to destroy panel " + identifier);
 
668
        PluginDebug.debug("Attempting to destroy panel ", identifier);
669
669
 
670
670
        final int fIdentifier = identifier;
671
671
        SwingUtilities.invokeLater(new Runnable() {
674
674
            }
675
675
        });
676
676
 
677
 
        PluginDebug.debug(identifier + " destroyed");
 
677
        PluginDebug.debug(identifier, " destroyed");
678
678
    }
679
679
 
680
680
    /**
692
692
                waitTime < APPLET_TIMEOUT) {
693
693
            try {
694
694
                if (waitTime % 500 == 0)
695
 
                    PluginDebug.debug("Waiting for applet panel " + panel + " to initialize...");
 
695
                    PluginDebug.debug("Waiting for applet panel ", panel, " to initialize...");
696
696
 
697
697
                Thread.sleep(waitTime += 50);
698
698
            } catch (InterruptedException ie) {
700
700
            }
701
701
        }
702
702
 
703
 
        PluginDebug.debug("Applet panel " + panel + " initialized");
 
703
        PluginDebug.debug("Applet panel ", panel, " initialized");
704
704
    }
705
705
 
706
706
    public void handleMessage(int reference, String message) {
783
783
            // (happens in a separate thread)
784
784
            waitForAppletInit((NetxPanel) panel);
785
785
 
786
 
            PluginDebug.debug(panel + " -- " + panel.getApplet() + " -- " + ((NetxPanel) panel).isAlive());
 
786
            PluginDebug.debug(panel, " -- ", panel.getApplet(), " -- ", ((NetxPanel) panel).isAlive());
787
787
 
788
788
            // Still null?
789
789
            if (panel.getApplet() == null) {
792
792
            }
793
793
 
794
794
            o = panel.getApplet();
795
 
            PluginDebug.debug("Looking for object " + o + " panel is " + panel);
 
795
            PluginDebug.debug("Looking for object ", o, " panel is ", panel);
796
796
            AppletSecurityContextManager.getSecurityContext(0).store(o);
797
 
            PluginDebug.debug("WRITING 1: " + "context 0 reference " + reference + " GetJavaObject "
798
 
                                 + AppletSecurityContextManager.getSecurityContext(0).getIdentifier(o));
 
797
            PluginDebug.debug("WRITING 1: ", "context 0 reference ", reference, " GetJavaObject "
 
798
                                 , AppletSecurityContextManager.getSecurityContext(0).getIdentifier(o));
799
799
            streamhandler.write("context 0 reference " + reference + " GetJavaObject "
800
800
                              + AppletSecurityContextManager.getSecurityContext(0).getIdentifier(o));
801
801
            PluginDebug.debug("WRITING 1 DONE");
844
844
     * Get an image ref.
845
845
     */
846
846
    private synchronized Ref getCachedImageRef(URL url) {
847
 
        PluginDebug.debug("getCachedImageRef() searching for " + url);
 
847
        PluginDebug.debug("getCachedImageRef() searching for ", url);
848
848
 
849
849
        try {
850
850
 
853
853
 
854
854
            if (originalURL.startsWith(codeBase)) {
855
855
 
856
 
                PluginDebug.debug("getCachedImageRef() got URL = " + url);
857
 
                PluginDebug.debug("getCachedImageRef() plugin codebase = " + codeBase);
 
856
                PluginDebug.debug("getCachedImageRef() got URL = ", url);
 
857
                PluginDebug.debug("getCachedImageRef() plugin codebase = ", codeBase);
858
858
 
859
859
                // try to fetch it locally
860
860
                if (panel instanceof NetxPanel) {
871
871
                }
872
872
            }
873
873
 
874
 
            PluginDebug.debug("getCachedImageRef() getting img from URL = " + url);
 
874
            PluginDebug.debug("getCachedImageRef() getting img from URL = ", url);
875
875
 
876
876
            synchronized (imageRefs) {
877
877
                AppletImageRef ref = imageRefs.get(url);
1049
1049
                PluginDebug.debug("wait getMEM request 2");
1050
1050
                while (request.isDone() == false)
1051
1051
                    request.wait();
1052
 
                PluginDebug.debug("wait getMEM request 3 GOT: " + request.getObject().getClass());
 
1052
                PluginDebug.debug("wait getMEM request 3 GOT: ", request.getObject().getClass());
1053
1053
            }
1054
1054
        } catch (InterruptedException e) {
1055
1055
            throw new RuntimeException("Interrupted waiting for call request.",
1101
1101
        streamhandler.postCallRequest(request);
1102
1102
        streamhandler.write(request.getMessage());
1103
1103
        try {
1104
 
            PluginDebug.debug("wait setMem request: " + request.getMessage());
 
1104
            PluginDebug.debug("wait setMem request: ", request.getMessage());
1105
1105
            PluginDebug.debug("wait setMem request 1");
1106
1106
            synchronized (request) {
1107
1107
                PluginDebug.debug("wait setMem request 2");
1342
1342
 
1343
1343
            requestURI = UrlUtil.encode(scheme + "://" + uri.getHost() + port + "/" + uri.getPath(), "UTF-8");
1344
1344
        } catch (Exception e) {
1345
 
            PluginDebug.debug("Cannot construct URL from " + uri.toString() + " ... falling back to DIRECT proxy");
 
1345
            PluginDebug.debug("Cannot construct URL from ", uri.toString(), " ... falling back to DIRECT proxy");
1346
1346
            e.printStackTrace();
1347
1347
            return null;
1348
1348
        }
1424
1424
    // FIXME: make this private and access it from JSObject using
1425
1425
    // reflection.
1426
1426
    private void write(String message) throws IOException {
1427
 
        PluginDebug.debug("WRITING 2: " + "instance " + identifier + " " + message);
 
1427
        PluginDebug.debug("WRITING 2: ", "instance ", identifier, " " + message);
1428
1428
        streamhandler.write("instance " + identifier + " " + message);
1429
1429
        PluginDebug.debug("WRITING 2 DONE");
1430
1430
    }
1741
1741
                    if ((c[0] = in.read()) == '>') {
1742
1742
                        buf.append((char) c[0]);
1743
1743
 
1744
 
                        PluginDebug.debug("Comment skipped: " + buf.toString());
 
1744
                        PluginDebug.debug("Comment skipped: ", buf.toString());
1745
1745
 
1746
1746
                        // comment skipped.
1747
1747
                        return;
1753
1753
 
1754
1754
            } else if (commentHeaderPassed == false) {
1755
1755
                buf.append((char) c[0]);
1756
 
                PluginDebug.debug("Warning: Attempted to skip comment, but this tag does not appear to be a comment: " + buf.toString());
 
1756
                PluginDebug.debug("Warning: Attempted to skip comment, but this tag does not appear to be a comment: ", buf.toString());
1757
1757
                return;
1758
1758
            }
1759
1759
 
1795
1795
                val = decodeString(buf.toString());
1796
1796
            }
1797
1797
 
1798
 
            PluginDebug.debug("PUT " + att + " = '" + val + "'");
 
1798
            PluginDebug.debug("PUT ", att, " = '", val, "'");
1799
1799
            atts.put(att.toLowerCase(java.util.Locale.ENGLISH), val);
1800
1800
 
1801
1801
            while (true) {
1958
1958
                            if (val == null) {
1959
1959
                                statusMsgStream.println(requiresNameWarning);
1960
1960
                            } else {
1961
 
                                PluginDebug.debug("PUT " + att + " = " + val);
 
1961
                                PluginDebug.debug("PUT ", att, " = ", val);
1962
1962
                                atts.put(att.toLowerCase(), val);
1963
1963
                            }
1964
1964
                        }