00001 package net.threebit.jvr.console;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 import java.awt.*;
00024 import java.awt.event.*;
00025 import java.awt.image.*;
00026 import java.io.*;
00027 import java.lang.reflect.*;
00028 import java.lang.reflect.Constructor;
00029 import java.net.URL;
00030 import java.net.URLClassLoader;
00031 import java.util.*;
00032 import java.util.logging.*;
00033 import javax.imageio.*;
00034 import javax.imageio.stream.*;
00035 import javax.swing.*;
00036 import net.threebit.jvr.*;
00037
00038
00039
00040
00041 public class Example7 extends AbstractExample {
00042
00043 JDialog dlg = null;
00044 int d7;
00045 int d8;
00046 JVRMetaEventListener m = new JVRMetaEventListener() {
00047 public boolean handleEvent (MetaEvent e) throws JVRException {
00048 if (e.evtdev != d8) { return true; }
00049 if (e.evttype == ms.MSEV_SIGEVT) {
00050 int hook = ((Integer)e.evtdata).intValue();
00051 if (hook == ms.MSMM_OFFHOOK) {
00052 info("OFFHOOK");
00053 }
00054 else if (hook == ms.MSMM_ONHOOK) {
00055 info("ONHOOK");
00056 }
00057 else if (hook == ms.MSMM_HOOKFLASH) {
00058 info("FLASH");
00059 }
00060 else {
00061 info("Unknown hook event: " + hook);
00062 }
00063 }
00064 return true;
00065 }
00066 };
00067
00068
00069
00070
00071 public String getName() { return "MSI Gen Ring"; }
00072
00073 public void finalize() {
00074 try {
00075 jvr.removeEventListener(m);
00076 ms.close(d7);
00077 ms.close(d8);
00078 }
00079 catch (Throwable ignore) { }
00080 }
00081
00082
00083
00084
00085 public void run () {
00086 try {
00087
00088 d7 = ms.open("msiB1C7",0);
00089 d8 = ms.open("msiB1C8",0);
00090 jvr.addEventListener(m);
00091
00092 ms.listen(d7, ms.getxmitslot(d8));
00093 ms.listen(d8, ms.getxmitslot(d7));
00094
00095 ms.setevtmsk(d8,ms.DTG_SIGEVT,
00096 ms.MSMM_OFFHOOK|ms.MSMM_ONHOOK|ms.MSMM_HOOKFLASH,ms.DTA_ADDMSK);
00097
00098
00099 dlg = new JDialog(console.frame,"Example 1 Setup",true);
00100 dlg.getContentPane().setLayout(new BorderLayout());
00101
00102
00103 JPanel propPanel = new JPanel();
00104 dlg.getContentPane().add(propPanel,BorderLayout.CENTER);
00105
00106 JButton b = new JButton("Ring");
00107 b.addActionListener(new AbstractAction(){
00108 public void actionPerformed (ActionEvent e) {
00109 try {
00110 ms.genring(d8,2,ms.EV_ASYNC);
00111 }
00112 catch (Throwable ignore) {
00113 ignore.printStackTrace();
00114 }
00115 }
00116 });
00117 propPanel.add(b);
00118
00119 dlg.pack();
00120 dlg.setLocationRelativeTo(console.frame);
00121 dlg.setVisible(true);
00122 }
00123 catch (Throwable ignore) { }
00124
00125 }
00126
00127 }
00128