NISTMessengerApplet.java
Upload User: liulanlin
Upload Date: 2017-12-08
Package Size: 1274k
Code Size: 22k
Category:

VOIP program

Development Platform:

Java

  1. /*
  2.  * NISTMessengerApplet.java
  3.  *
  4.  * Created on December 11, 2003, 3:51 PM
  5.  */
  6. package gov.nist.applet.phone.ua.gui;
  7. import gov.nist.applet.phone.media.messaging.VoiceRecorder;
  8. import gov.nist.applet.phone.ua.ChatSessionManager;
  9. import gov.nist.applet.phone.ua.Configuration;
  10. import gov.nist.applet.phone.ua.RegisterStatus;
  11. import gov.nist.applet.phone.ua.MessengerController;
  12. import gov.nist.applet.phone.ua.MessengerManager;
  13. import gov.nist.applet.phone.ua.StopMessenger;
  14. import gov.nist.applet.phone.ua.presence.Subscriber;
  15. import java.awt.Image;
  16. import java.awt.event.ActionEvent;
  17. import java.awt.event.ActionListener;
  18. import java.awt.event.MouseAdapter;
  19. import java.awt.event.MouseEvent;
  20. import java.net.Socket;
  21. import java.util.StringTokenizer;
  22. import java.util.Vector;
  23. import javax.swing.ButtonGroup;
  24. import javax.swing.DefaultListModel;
  25. import javax.swing.ImageIcon;
  26. import javax.swing.JApplet;
  27. import javax.swing.JButton;
  28. import javax.swing.JEditorPane;
  29. import javax.swing.JLabel;
  30. import javax.swing.JList;
  31. import javax.swing.JOptionPane;
  32. import javax.swing.JRadioButtonMenuItem;
  33. import javax.swing.JScrollPane;
  34. import javax.swing.ListSelectionModel;
  35. import javax.swing.UnsupportedLookAndFeelException;
  36. import javax.swing.UIManager;
  37. //import netscape.javascript.JSObject;
  38. /**
  39.  *
  40.  * @author  DERUELLE Jean
  41.  */
  42. public class NISTMessengerApplet
  43. extends javax.swing.JApplet
  44. implements NISTMessengerGUI {
  45. Configuration configuration;
  46. /*MVC attributes*/
  47. private MessengerManager sipMeetingManager;
  48. private MessengerController controllerMeeting;
  49. private ChatSessionManager chatSessionManager;
  50. /**
  51.  * GUI variables.
  52.  */
  53. // Variables declaration - do not modify//GEN-BEGIN:variables
  54. private javax.swing.JButton addContactButton;
  55. private javax.swing.JMenuBar fileMenuBar1;
  56. private javax.swing.JLabel imageLabel;
  57. private javax.swing.JLabel jLabel1;
  58. private javax.swing.JMenu jMenu5;
  59. private javax.swing.JMenuItem jMenuItemConfiguration;
  60. private javax.swing.JMenuItem jMenuItemRegister;
  61. private javax.swing.JMenuItem jMenuItemUnregister;
  62. private javax.swing.JMenu jMenuStatus;
  63. private javax.swing.JPanel mainPanel;
  64. private javax.swing.JButton removeContactButton;
  65. // End of variables declaration//GEN-END:variables
  66. private javax.swing.JList jList1;
  67. private DefaultListModel listModel;
  68. private JRadioButtonMenuItem onlineJRadioButtonMenuItem;
  69. private JRadioButtonMenuItem awayJRadioButtonMenuItem;
  70. private JRadioButtonMenuItem offlineJRadioButtonMenuItem;
  71. private JRadioButtonMenuItem busyJRadioButtonMenuItem;
  72. private ButtonGroup statusGroup;
  73. private boolean useResponder = false;
  74. //private JSObject document=null;
  75. /**
  76.  * 
  77.  */
  78. public void init() {
  79. if (!checkForJMF()) {
  80. JEditorPane jEditorPane = new JEditorPane();
  81. JOptionPane.showMessageDialog(
  82. this,
  83. "Please install the latest version of JMF from "
  84. + "the link provided on the webpagen",
  85. "Java Media Framework not installed on your computer",
  86. JOptionPane.ERROR_MESSAGE);
  87. return;
  88. }
  89. System.out.println("initializing Applet");
  90. configuration = new Configuration();
  91. configuration.outboundProxy = getParameter("PROXYADDRESS");
  92. if (configuration.outboundProxy == null) {
  93. JOptionPane.showMessageDialog(
  94. this,
  95. "JSP configuration Missing PROXYADDRESS");
  96. return;
  97. }
  98. if (getParameter("RESPONDER") != null)
  99. useResponder = true;
  100. System.out.println(
  101. "outbound proxy address " + configuration.outboundProxy);
  102. try {
  103. configuration.proxyPort =
  104. Integer.parseInt(getParameter("PROXYPORT"));
  105. } catch (Exception nfe) {
  106. nfe.printStackTrace();
  107. JOptionPane.showMessageDialog(
  108. this,
  109. "JSP configuration error bad PROXYPORT "
  110. + configuration.proxyPort);
  111. }
  112. System.out.println("outbound proxy port " + configuration.proxyPort);
  113. configuration.signalingTransport = getParameter("SIGNALINGTRANSPORT");
  114. if (configuration.signalingTransport == null) {
  115. JOptionPane.showMessageDialog(
  116. this,
  117. "JSP Configuration ERROR SINGALINGTRANSPORT param missing");
  118. return;
  119. }
  120. configuration.mediaTransport = getParameter("MEDIATRANSPORT");
  121. if (configuration.mediaTransport == null) {
  122. JOptionPane.showMessageDialog(
  123. this,
  124. "JSP Configuration ERROR MEDIATRANSPORT param missing");
  125. return;
  126. }
  127. configuration.userURI = getParameter("USERURI");
  128. if (configuration.userURI == null) {
  129. JOptionPane.showMessageDialog(
  130. this,
  131. "JSP Configuration ERROR USERURI param missing");
  132. return;
  133. }
  134. System.out.println(configuration.userURI);
  135. try {
  136. //open socket to web server to ensure you to get correct local IP
  137. String serverAddr = getParameter("SERVERADDR");
  138. int serverPort = Integer.parseInt(getParameter("SERVERPORT"));
  139. Socket socket = new Socket(serverAddr, serverPort);
  140. configuration.stackIPAddress =
  141. socket.getLocalAddress().getHostAddress();
  142. socket.close();
  143. } catch (Exception e) {
  144. e.printStackTrace();
  145. JOptionPane.showMessageDialog(this, "JSP Configuration ERROR ");
  146. return;
  147. }
  148. configuration.contactIPAddress = getParameter("MYADDRESS");
  149. System.out.println(configuration.stackIPAddress);
  150. try {
  151. UIManager.setLookAndFeel(
  152. UIManager.getCrossPlatformLookAndFeelClassName());
  153. } catch (ClassNotFoundException cnfe) {
  154. cnfe.printStackTrace();
  155. } catch (InstantiationException ie) {
  156. ie.printStackTrace();
  157. } catch (IllegalAccessException iae) {
  158. iae.printStackTrace();
  159. } catch (UnsupportedLookAndFeelException ulafe) {
  160. ulafe.printStackTrace();
  161. }
  162. /*JSObject jsobject = JSObject.getWindow(this);
  163. document = (JSObject) jsobject.getMember("document");*/
  164. }
  165. /**
  166.  * 
  167.  */
  168. public void start() {
  169. final JApplet object = this;
  170. chatSessionManager = new ChatSessionManager();
  171. sipMeetingManager = new MessengerManager(configuration, this);
  172. /*String cookieContacts = getCookieContacts();
  173. System.out.println(cookieContacts);
  174. if (cookieContacts != null) {
  175. Vector contacts = parseCookieContacts(cookieContacts);
  176. sipMeetingManager.setContactList(contacts);
  177. }*/
  178. //sipMeetingManager.addObserver(this);
  179. controllerMeeting =
  180. new MessengerController(
  181. sipMeetingManager,
  182. chatSessionManager,
  183. this);
  184. initComponents();
  185. listModel = new DefaultListModel();
  186. //Create the list and put it in a scroll pane.
  187. jList1 = new JList(listModel);
  188. jList1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  189. jList1.addMouseListener(new MouseAdapter() {
  190. public void mouseClicked(MouseEvent e) {
  191. if (e.getClickCount() == 2) {
  192. String contactAddress =
  193. (String) listModel.elementAt(jList1.getSelectedIndex());
  194. if (contactAddress.trim().indexOf('(') != -1)
  195. contactAddress =
  196. contactAddress.substring(
  197. 0,
  198. contactAddress.trim().indexOf("("));
  199. //check if a chat frame has already been opened
  200. ChatFrame chatFrame =
  201. (ChatFrame) chatSessionManager.getChatFrame(
  202. contactAddress);
  203. if (chatFrame == null) {
  204. //emulate button click
  205. chatFrame =
  206. new ChatFrame(
  207. object,
  208. contactAddress,
  209. sipMeetingManager,
  210. chatSessionManager);
  211. chatSessionManager.addChatSession(
  212. contactAddress,
  213. chatFrame);
  214. chatFrame.show();
  215. } else {
  216. chatFrame.show();
  217. }
  218. }
  219. }
  220. });
  221. JScrollPane listScrollPane = new JScrollPane(jList1);
  222. listScrollPane.setBounds(10, 100, 200, 250);
  223. mainPanel.add(listScrollPane);
  224. getContentPane().add(mainPanel);
  225. Image image = getImage(getCodeBase(), "short_nisthome_banner.jpg");
  226. if (image != null)
  227. imageLabel.setIcon(new ImageIcon(image));
  228. this.resize(320, 520);
  229. sipMeetingManager.unRegisterAndReRegister();
  230. if (useResponder) {
  231. addContactButton.setEnabled(false);
  232. removeContactButton.setEnabled(false);
  233. controllerMeeting.addContact("responder@nist.gov");
  234. }
  235. //this.show();
  236. }
  237. /**
  238.  * Call when the applet is stopped and cleaned 
  239.  */
  240. public void destroy() {
  241. chatSessionManager.closeAllSessions();
  242. if (!VoiceRecorder.isClosed())
  243. VoiceRecorder.getInstance().close();
  244. if (sipMeetingManager
  245. .getRegisterStatus()
  246. .equalsIgnoreCase(RegisterStatus.REGISTERED))
  247. sipMeetingManager.unRegister();
  248. //write a one more new cookie
  249. //storeContactsInCookie();
  250. new StopMessenger(sipMeetingManager.getMessageListener());
  251. }
  252. /**
  253.  * Call when the applet is stopped and cleaned 
  254.  */
  255. public void stop() {
  256. chatSessionManager.closeAllSessions();
  257. if (!VoiceRecorder.isClosed())
  258. VoiceRecorder.getInstance().close();
  259. if (sipMeetingManager
  260. .getRegisterStatus()
  261. .equalsIgnoreCase(RegisterStatus.REGISTERED))
  262. sipMeetingManager.unRegister();
  263. new StopMessenger(sipMeetingManager.getMessageListener());
  264. }
  265. /**
  266.  * 
  267.  *
  268.  */
  269. protected void unRegister() {
  270. if (sipMeetingManager
  271. .getRegisterStatus()
  272. .equalsIgnoreCase(RegisterStatus.REGISTERED)) {
  273. if (chatSessionManager.hasActiveSessions()) {
  274. int response =
  275. javax.swing.JOptionPane.showConfirmDialog(
  276. null,
  277. " All current sessions will be closed,n"
  278. + " do you still want to close the application ?",
  279. "Close the Application",
  280. javax.swing.JOptionPane.YES_NO_OPTION,
  281. javax.swing.JOptionPane.QUESTION_MESSAGE);
  282. if (response == javax.swing.JOptionPane.NO_OPTION)
  283. return;
  284. else if (response == javax.swing.JOptionPane.YES_OPTION) {
  285. chatSessionManager.closeAllSessions();
  286. }
  287. }
  288. sipMeetingManager.unRegister();
  289. }
  290. }
  291. /**
  292.  *      
  293.  * @param serverPort
  294.  * @return
  295. public void queryServerForIpAddress(int serverPort){             
  296.     String host=getCodeBase().getHost();
  297. System.out.println("Query Server "+host+":"+serverPort+" to get my own ip address");
  298.     Socket socket=null;
  299.     try{
  300.         socket=new Socket(host,serverPort);
  301.     }
  302.     catch(java.net.UnknownHostException uhe){
  303.         uhe.printStackTrace();
  304.     }
  305.     catch(java.io.IOException ioe){
  306.         ioe.printStackTrace();
  307.     }   
  308. String ipAddress=null;
  309. String localAddress=socket.getLocalAddress().getHostAddress();      
  310.     try{
  311.         java.io.InputStream in=socket.getInputStream();
  312.         java.io.BufferedReader bin=new java.io.BufferedReader(
  313.          new java.io.InputStreamReader(in));
  314.         ipAddress=bin.readLine();
  315.         in.close();
  316.         bin.close();
  317.         socket.close();            
  318.     }
  319.     catch(java.io.IOException ioe){
  320.         ioe.printStackTrace();
  321.     }                
  322. System.out.println("localAddress : "+localAddress);
  323. System.out.println("NATAddress : "+ipAddress);
  324. configuration.stackIPAddress=localAddress;
  325. configuration.contactIPAddress=ipAddress;
  326. }
  327.  */
  328. /** This method is called from within the constructor to
  329.  * initialize the form.
  330.  * WARNING: Do NOT modify this code. The content of this method is
  331.  * always regenerated by the Form Editor.
  332.  */
  333. private void initComponents() { //GEN-BEGIN:initComponents
  334. mainPanel = new javax.swing.JPanel();
  335. imageLabel = new javax.swing.JLabel();
  336. addContactButton = new javax.swing.JButton();
  337. removeContactButton = new javax.swing.JButton();
  338. jLabel1 = new javax.swing.JLabel();
  339. fileMenuBar1 = new javax.swing.JMenuBar();
  340. jMenu5 = new javax.swing.JMenu();
  341. jMenuItemConfiguration = new javax.swing.JMenuItem();
  342. jMenuItemRegister = new javax.swing.JMenuItem();
  343. jMenuItemUnregister = new javax.swing.JMenuItem();
  344. jMenuStatus = new javax.swing.JMenu();
  345. onlineJRadioButtonMenuItem = new JRadioButtonMenuItem("Online");
  346. awayJRadioButtonMenuItem = new JRadioButtonMenuItem("Away");
  347. offlineJRadioButtonMenuItem = new JRadioButtonMenuItem("Be Right Back");
  348. busyJRadioButtonMenuItem = new JRadioButtonMenuItem("Busy");
  349. getContentPane().setLayout(null);
  350. mainPanel.setLayout(null);
  351. mainPanel.setMinimumSize(new java.awt.Dimension(310, 500));
  352. mainPanel.setPreferredSize(new java.awt.Dimension(310, 500));
  353. imageLabel.setMaximumSize(new java.awt.Dimension(400, 50));
  354. imageLabel.setMinimumSize(new java.awt.Dimension(300, 50));
  355. imageLabel.setPreferredSize(new java.awt.Dimension(400, 50));
  356. mainPanel.add(imageLabel);
  357. imageLabel.setBounds(11, 6, 290, 50);
  358. addContactButton.setText("Add Contact");
  359. addContactButton.setOpaque(false);
  360. addContactButton
  361. .addActionListener(new java.awt.event.ActionListener() {
  362. public void actionPerformed(java.awt.event.ActionEvent evt) {
  363. addContactButtonActionPerformed(evt);
  364. }
  365. });
  366. mainPanel.add(addContactButton);
  367. addContactButton.setBounds(10, 400, 120, 40);
  368. removeContactButton.setText("Remove Contact");
  369. removeContactButton.setEnabled(false);
  370. removeContactButton
  371. .addActionListener(new java.awt.event.ActionListener() {
  372. public void actionPerformed(java.awt.event.ActionEvent evt) {
  373. removeContactButtonActionPerformed(evt);
  374. }
  375. });
  376. mainPanel.add(removeContactButton);
  377. removeContactButton.setBounds(160, 400, 130, 40);
  378. jLabel1.setText("Not Logged");
  379. mainPanel.add(jLabel1);
  380. jLabel1.setBounds(10, 70, 290, 20);
  381. getContentPane().add(mainPanel);
  382. mainPanel.setBounds(0, 0, 310, 500);
  383. jMenu5.setText("Menu");
  384. jMenuItemConfiguration.setText("Configuration");
  385. jMenuItemConfiguration
  386. .addActionListener(new java.awt.event.ActionListener() {
  387. public void actionPerformed(java.awt.event.ActionEvent evt) {
  388. jMenuItemConfigurationActionPerformed(evt);
  389. }
  390. });
  391. jMenu5.add(jMenuItemConfiguration);
  392. jMenuItemRegister.setText("Register");
  393. jMenuItemRegister
  394. .addActionListener(new java.awt.event.ActionListener() {
  395. public void actionPerformed(java.awt.event.ActionEvent evt) {
  396. jMenuItemRegisterActionPerformed(evt);
  397. }
  398. });
  399. jMenu5.add(jMenuItemRegister);
  400. jMenuItemUnregister.setText("Unregister");
  401. jMenuItemUnregister
  402. .addActionListener(new java.awt.event.ActionListener() {
  403. public void actionPerformed(java.awt.event.ActionEvent evt) {
  404. jMenuItemUnregisterActionPerformed(evt);
  405. }
  406. });
  407. jMenu5.add(jMenuItemUnregister);
  408. jMenuStatus.setText("Status");
  409. onlineJRadioButtonMenuItem.addActionListener(new ActionListener() {
  410. public void actionPerformed(ActionEvent evt) {
  411. onlineActionPerformed(evt);
  412. }
  413. });
  414. awayJRadioButtonMenuItem.addActionListener(new ActionListener() {
  415. public void actionPerformed(ActionEvent evt) {
  416. awayActionPerformed(evt);
  417. }
  418. });
  419. offlineJRadioButtonMenuItem.addActionListener(new ActionListener() {
  420. public void actionPerformed(ActionEvent evt) {
  421. beRightBackActionPerformed(evt);
  422. }
  423. });
  424. busyJRadioButtonMenuItem.addActionListener(new ActionListener() {
  425. public void actionPerformed(ActionEvent evt) {
  426. busyActionPerformed(evt);
  427. }
  428. });
  429. statusGroup = new ButtonGroup();
  430. onlineJRadioButtonMenuItem.setSelected(true);
  431. statusGroup.add(onlineJRadioButtonMenuItem);
  432. statusGroup.add(offlineJRadioButtonMenuItem);
  433. statusGroup.add(busyJRadioButtonMenuItem);
  434. statusGroup.add(awayJRadioButtonMenuItem);
  435. jMenuStatus.add(awayJRadioButtonMenuItem);
  436. jMenuStatus.add(onlineJRadioButtonMenuItem);
  437. jMenuStatus.add(offlineJRadioButtonMenuItem);
  438. jMenuStatus.add(busyJRadioButtonMenuItem);
  439. jMenu5.add(jMenuStatus);
  440. fileMenuBar1.add(jMenu5);
  441. setJMenuBar(fileMenuBar1);
  442. } //GEN-END:initComponents
  443. private void jMenuItemUnregisterActionPerformed(
  444. java.awt.event.ActionEvent evt) {
  445. //GEN-FIRST:event_jMenuItemUnregisterActionPerformed
  446. // Add your handling code here:
  447. if (sipMeetingManager
  448. .getRegisterStatus()
  449. .equalsIgnoreCase(RegisterStatus.NOT_REGISTERED)) {
  450. JOptionPane.showMessageDialog(
  451. this,
  452. "You are currently not registered, please register to un-register",
  453. "Already un-registered",
  454. JOptionPane.ERROR_MESSAGE);
  455. return;
  456. }
  457. unRegister();
  458. controllerMeeting.undisplayAllContact();
  459. removeContactButton.setEnabled(false);
  460. } //GEN-LAST:event_jMenuItemUnregisterActionPerformed
  461. private void jMenuItemRegisterActionPerformed(
  462. java.awt.event.ActionEvent evt) {
  463. //GEN-FIRST:event_jMenuItemRegisterActionPerformed
  464. // Add your handling code here:
  465. if (sipMeetingManager
  466. .getRegisterStatus()
  467. .equalsIgnoreCase(RegisterStatus.REGISTERED)) {
  468. JOptionPane.showMessageDialog(
  469. this,
  470. "You are already registered, please un-register before",
  471. "Already registered",
  472. JOptionPane.ERROR_MESSAGE);
  473. return;
  474. }
  475. sipMeetingManager.unRegisterAndReRegister();
  476. controllerMeeting.displayAllContact();
  477. removeContactButton.setEnabled(true);
  478. } //GEN-LAST:event_jMenuItemRegisterActionPerformed
  479. private void jMenuItemConfigurationActionPerformed(
  480. java.awt.event.ActionEvent evt) {
  481. //GEN-FIRST:event_jMenuItemConfigurationActionPerformed
  482. // Add your handling code here:
  483. new ConfigurationFrame(sipMeetingManager).show();
  484. } //GEN-LAST:event_jMenuItemConfigurationActionPerformed
  485. private void onlineActionPerformed(
  486. java.awt.event.ActionEvent evt) {
  487. //GEN-FIRST:event_jMenuItemRegisterActionPerformed
  488. // Add your handling code here:
  489. jLabel1.setText("Logged as : " + configuration.userURI + " - Online");
  490. sipMeetingManager.getPresentityManager().sendNotifyToAllSubscribers(
  491. "open",
  492. "online");
  493. } //GEN-LAST:event_jMenuItemRegisterActionPerformed
  494. private void busyActionPerformed(
  495. java.awt.event.ActionEvent evt) {
  496. //GEN-FIRST:event_jMenuItemRegisterActionPerformed
  497. // Add your handling code here:
  498. jLabel1.setText("Logged as : " + configuration.userURI + " - Busy");
  499. sipMeetingManager.getPresentityManager().sendNotifyToAllSubscribers(
  500. "inuse",
  501. "busy");
  502. } //GEN-LAST:event_jMenuItemRegisterActionPerformed
  503. private void awayActionPerformed(
  504. java.awt.event.ActionEvent evt) {
  505. //GEN-FIRST:event_jMenuItemRegisterActionPerformed
  506. // Add your handling code here:
  507. jLabel1.setText("Logged as : " + configuration.userURI + " - Away");
  508. sipMeetingManager.getPresentityManager().sendNotifyToAllSubscribers(
  509. "inactive",
  510. "away");
  511. } //GEN-LAST:event_jMenuItemRegisterActionPerformed
  512. private void beRightBackActionPerformed(
  513. java.awt.event.ActionEvent evt) {
  514. //GEN-FIRST:event_jMenuItemRegisterActionPerformed
  515. // Add your handling code here:
  516. jLabel1.setText(
  517. "Logged as : " + configuration.userURI + " - Be Right Back");
  518. sipMeetingManager.getPresentityManager().sendNotifyToAllSubscribers(
  519. "inactive",
  520. "berightback");
  521. } //GEN-LAST:event_jMenuItemRegisterActionPerformed
  522. private void removeContactButtonActionPerformed(
  523. java.awt.event.ActionEvent evt) {
  524. //GEN-FIRST:event_removeContactButtonActionPerformed
  525. controllerMeeting.removeContact();
  526. } //GEN-LAST:event_removeContactButtonActionPerformed
  527. private void addContactButtonActionPerformed(
  528. java.awt.event.ActionEvent evt) {
  529. //GEN-FIRST:event_addContactButtonActionPerformed
  530. // Add your handling code here:
  531. if (!sipMeetingManager
  532. .getRegisterStatus()
  533. .equalsIgnoreCase(RegisterStatus.REGISTERED)) {
  534. JOptionPane.showMessageDialog(
  535. this,
  536. "You must be registered to add a new contact",
  537. "Contact Error",
  538. JOptionPane.ERROR_MESSAGE);
  539. return;
  540. }
  541. String contactAddress =
  542. (String) JOptionPane.showInputDialog(
  543. this,
  544. "Enter the contact address to add:n",
  545. "Add Contact",
  546. JOptionPane.PLAIN_MESSAGE,
  547. null,
  548. null,
  549. null);
  550. if (contactAddress != null) {
  551. if (contactAddress.indexOf("@") != -1) {
  552. Subscriber subscriber = new Subscriber(contactAddress);
  553. sipMeetingManager.getPresentityManager().addSubscriber(
  554. subscriber);
  555. sipMeetingManager.sendSubscribe(contactAddress);
  556. controllerMeeting.addContact(contactAddress);
  557. } else {
  558. JOptionPane.showMessageDialog(
  559. this,
  560. "The contact must be of the form user@domain"
  561. + ", the contact has not been added",
  562. "Contact Error",
  563. JOptionPane.ERROR_MESSAGE);
  564. }
  565. }
  566. } //GEN-LAST:event_addContactButtonActionPerformed
  567. /**
  568.  * Get the contact list from this frame
  569.  * @return the contact list from this frame
  570.  */
  571. public JList getContactList() {
  572. return jList1;
  573. }
  574. /**
  575.  * Get the view component representing the logged status label
  576.  * @return the logged status label
  577.  */
  578. public JLabel getLoggedStatusLabel() {
  579. return jLabel1;
  580. }
  581. /**
  582.  * Get the contact list from this frame
  583.  * @return the contact list from this frame
  584.  */
  585. public JButton getRemoveContactButton() {
  586. return removeContactButton;
  587. }
  588. public boolean useResponder() {
  589. return useResponder;
  590. }
  591. /**     
  592.  *
  593.  */
  594. public boolean checkForJMF() {
  595. Class clz;
  596. //Check for basic JMF class.
  597. try {
  598. Class.forName("javax.media.Player");
  599. } catch (Throwable throwable2) {
  600. return false;
  601. }
  602. return true;
  603. }
  604. /**
  605.  * Return the cookie with the contacts
  606.  * @return the string representing the contacts
  607.  */
  608. /*public String getCookieContacts(){
  609. if(document!=null){
  610. return (String)document.getMember("cookie");
  611. }
  612. else
  613. return null;
  614. }*/
  615. /**
  616.  * Store the contacts into a cookie
  617.  */
  618. /*public void storeContactsInCookie(){
  619. Vector contacts=sipMeetingManager.getContactList();
  620. String cookieContacts="";
  621. for(int i=0;i<contacts.size();i++){
  622. cookieContacts+="contact"+i+"="+(String)contacts.get(i)+";";
  623. }
  624. Calendar calendar = Calendar.getInstance();
  625. calendar.add(Calendar.MONTH, 1);  // Setting the calendar to one year ahead
  626. String cookie=cookieContacts+" expires="+calendar.getTime().toString();
  627. System.out.println("Setting the cookie for the contacts: "+cookie);
  628. //document.removeMember("cookie");
  629. document.setMember( "cookie" ,  cookie);
  630. } */
  631. /**
  632.  * Parse the cookie String into a List of contacts 
  633.  * @param cookieContact -  the cookie string containing the contacts
  634.  * @return list of contacts
  635.  */
  636. public Vector parseCookieContacts(String cookieContact) {
  637. if (cookieContact == null || cookieContact.length() < 1) {
  638. return null;
  639. } else {
  640. Vector contacts = new Vector();
  641. StringTokenizer st = new StringTokenizer(cookieContact, ";");
  642. while (st.hasMoreTokens()) {
  643. String contact = st.nextToken();
  644. if (contact.indexOf("contact") != -1) {
  645. if (contact.indexOf("=") != -1) {
  646. contact = contact.substring(contact.indexOf("=") + 1);
  647. System.out.println(
  648. "Contact found in the cookie= " + contact);
  649. contacts.addElement(contact);
  650. }
  651. }
  652. }
  653. return contacts;
  654. }
  655. }
  656. /** Show a message in a dialog box and die.
  657.  */
  658. public void fatalError(String errorText) {
  659. JOptionPane.showMessageDialog(this, errorText);
  660. this.destroy();
  661. }
  662. }