| 1 | /** |
|---|
| 2 | * |
|---|
| 3 | * Applet to hold the recorder/uploader panel. |
|---|
| 4 | * |
|---|
| 5 | * MoodleSpeex written by Dan Stowell. |
|---|
| 6 | * (c) 2006 onwards; released under the GPL. |
|---|
| 7 | * |
|---|
| 8 | * MoodleSpeex uses code from other authors - |
|---|
| 9 | * please see the included documentation for |
|---|
| 10 | * details. |
|---|
| 11 | * |
|---|
| 12 | */ |
|---|
| 13 | |
|---|
| 14 | package speechrecorder; |
|---|
| 15 | |
|---|
| 16 | import java.net.URL; |
|---|
| 17 | import javax.swing.JApplet; |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | /** |
|---|
| 21 | * @author kmaclean |
|---|
| 22 | */ |
|---|
| 23 | public class RecorderApplet extends JApplet { |
|---|
| 24 | |
|---|
| 25 | static RecorderApplet applet; |
|---|
| 26 | private CapturePlayback theRecorder; |
|---|
| 27 | ////// MOODLEY: |
|---|
| 28 | String subject; |
|---|
| 29 | String fileFieldName; |
|---|
| 30 | URL endPageURL; |
|---|
| 31 | URL helpPageURL; |
|---|
| 32 | URL destinationURL; |
|---|
| 33 | String language; |
|---|
| 34 | String endpage; |
|---|
| 35 | String helppage; |
|---|
| 36 | String cookie; |
|---|
| 37 | |
|---|
| 38 | public void init() { |
|---|
| 39 | applet = this; |
|---|
| 40 | // At this point grab all our parameters |
|---|
| 41 | getParameters(); |
|---|
| 42 | getContentPane().add("Center", |
|---|
| 43 | theRecorder = new CapturePlayback( language, destinationURL, endPageURL, helpPageURL, cookie)); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | public void start() { |
|---|
| 47 | theRecorder.open(); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | public void stop() { |
|---|
| 51 | theRecorder.close(); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | // Helper method for getting the parameters from the webpage. |
|---|
| 55 | private void getParameters(){ |
|---|
| 56 | |
|---|
| 57 | /* SUBJECT (MOODLEY PARAMETER) */ |
|---|
| 58 | try { |
|---|
| 59 | subject = getParameter("subject"); |
|---|
| 60 | } catch (NullPointerException nullLang){ |
|---|
| 61 | // Default language being set |
|---|
| 62 | subject = null; |
|---|
| 63 | errorMessage(System.out,"subject is null"); |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | try { |
|---|
| 67 | // !!!!!! |
|---|
| 68 | cookie = getParameter("cookie"); |
|---|
| 69 | // System.err.println("RecorderApplet Cookie: " + cookie +":\n"); |
|---|
| 70 | // !!!!!! |
|---|
| 71 | } catch (NullPointerException nullLang){ |
|---|
| 72 | errorMessage(System.out,"cookie is null"); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | /* LANGUAGE */ |
|---|
| 76 | try { |
|---|
| 77 | language = getParameter("language"); |
|---|
| 78 | if (language == "" || language == null) |
|---|
| 79 | language = "EN"; |
|---|
| 80 | // debug System.err.println("RecorderAppletlanguage is:" + language); |
|---|
| 81 | } catch (NullPointerException nullLang){ |
|---|
| 82 | // Default language being set |
|---|
| 83 | language = "EN"; |
|---|
| 84 | errorMessage(System.out,"language is null"); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | /* DESTINATION */ |
|---|
| 88 | try { |
|---|
| 89 | // !!!!!! |
|---|
| 90 | destinationURL = new URL(getParameter("destination")); |
|---|
| 91 | // Following line is for testing, and to hard code the applet to postlet.com |
|---|
| 92 | // destinationURL = new URL("http://localhost:90/httpd/postlet/javaUpload.php"); |
|---|
| 93 | // !!!!!! |
|---|
| 94 | } catch(java.net.MalformedURLException malurlex){ |
|---|
| 95 | // Do something here for badly formed destination, which is ESENTIAL. |
|---|
| 96 | errorMessage(System.out, "Badly formed destination:###"+getParameter("destination")+"###"); |
|---|
| 97 | // JOptionPane.showMessageDialog(null, pLabels.getLabel(3),pLabels.getLabel(5), JOptionPane.ERROR_MESSAGE); |
|---|
| 98 | } catch(java.lang.NullPointerException npe){ |
|---|
| 99 | // Do something here for the missing destination, which is ESENTIAL. |
|---|
| 100 | errorMessage(System.out,"destination is null"); |
|---|
| 101 | // JOptionPane.showMessageDialog(null, pLabels.getLabel(4), pLabels.getLabel(5), JOptionPane.ERROR_MESSAGE); |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | /* ENDPAGE */ |
|---|
| 105 | try { |
|---|
| 106 | endPageURL = new URL(getParameter("endpage")); |
|---|
| 107 | } catch(java.net.MalformedURLException malurlex){ |
|---|
| 108 | errorMessage(System.out, "endpage is badly formed:###"+getParameter("endpage")+"###"); |
|---|
| 109 | } catch(java.lang.NullPointerException npe){ |
|---|
| 110 | errorMessage(System.out, "endpage is null"); |
|---|
| 111 | } |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | public void errorMessage(java.io.PrintStream out, String message){ |
|---|
| 115 | out.println("***"+message+"***"); |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | } |
|---|