⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listenerinstantmessaging.java

📁 The source code for this package is located in src/gov/nist/sip/proxy. The proxy is a pure JAIN-SIP
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * ListenerIM.java * * Created on July 28, 2002, 8:14 AM */package gov.nist.sip.instantmessaging;import javax.sip.*;import javax.sip.message.*; import javax.sip.header.*;import javax.sip.address.*;import javax.swing.*;import javax.swing.border.*;import java.awt.*;import java.io.*;import java.util.*;import java.awt.event.*;import gov.nist.sip.instantmessaging.presence.*;import tools.tracesviewer.*;/** * * @author  olivier * @version 1.0 */public class ListenerInstantMessaging {    protected InstantMessagingGUI imGUI;    protected ConfigurationFrame configurationFrame;    protected HelpBox helpBox;    protected ChatSessionManager chatSessionManager;    protected Process rmiregistryProcess;    protected String localStatus;    protected TracesViewer tracesViewer;         /** Creates new ListenerIM */    public ListenerInstantMessaging(InstantMessagingGUI imGUI) {        this.imGUI=imGUI;        localStatus="offline";        configurationFrame=new ConfigurationFrame(imGUI,"Configuration");                helpBox=new HelpBox();                chatSessionManager=new ChatSessionManager(imGUI);    }        public String getLocalStatus() {        return localStatus;    }        public void setLocalStatus(String localStatus) {        this.localStatus=localStatus;    }       public ChatSessionManager getChatSessionManager() {        return chatSessionManager;    }        public InstantMessagingGUI getInstantMessagingGUI() {        return imGUI;    }        public ConfigurationFrame getConfigurationFrame() {        return configurationFrame;    }         public void helpMenuMouseEvent(MouseEvent mouseEvent) {       try{            helpBox.show();        }        catch(Exception e) {            e.printStackTrace();        }    }        public void buddyListMouseClicked(MouseEvent e){        if (e.getClickCount() == 2) {            BuddyList buddyList=imGUI.getBuddyList();            int index = buddyList.locationToIndex(e.getPoint());            String buddy=buddyList.getBuddy(index);            if ( buddy== null || buddy.equals("(empty)") ) {                // we don't start anything!!!            }            else {                IMUserAgent imUA=imGUI.getInstantMessagingUserAgent();                IMRegisterProcessing imRegisterProcessing=imUA.getIMRegisterProcessing();                if (imRegisterProcessing.isRegistered()) {                    if (chatSessionManager.hasAlreadyChatSession(buddy) ) {                        // This chat session already exists, we put the focus on it:                        ChatSession chatSession=chatSessionManager.getChatSession(buddy);                        ChatFrame chatFrame=chatSession.getChatFrame();                        chatFrame.show();                    }                    else {                        ChatFrame chatFrame=new ChatFrame(imGUI,buddy);                        ChatSession chatSession=new ChatSession();                                                chatSession.setChatFrame(chatFrame);                        chatFrame.setChatSession(chatSession);                        chatSessionManager.addChatSession(chatSession);                    }                }                else  new AlertInstantMessaging(                "You must sign in first to the server!!!",JOptionPane.ERROR_MESSAGE);            }        }    }            public void configurationActionPerformed(ActionEvent evt){        try{            configurationFrame.show();        }        catch(Exception e) {            e.printStackTrace();        }    }         public void startRMIregistry() {         // Launches the rmiregistry:         try{             rmiregistryProcess=null;             Runtime runtime=Runtime.getRuntime();                          // The root directory             File file=new File("../../..");             String localRootDirectory=file.getAbsolutePath();             String javaHome= System.getProperty("java.home")+"/bin/";             String localSeparator= System.getProperty("path.separator");                         String rmiregistryClasspath=                localRootDirectory+"/classes"+localSeparator+                localRootDirectory+"/lib/antlr/antlrall.jar"+localSeparator+                localRootDirectory+"/lib/xerces/xerces.jar";                          // The command to execute             String commandLine=javaHome+"rmiregistry -J-Denv.class.path="+rmiregistryClasspath;                         DebugIM.println("Starting the rmiregistry:");             DebugIM.println(commandLine);             rmiregistryProcess=runtime.exec(commandLine);                      }         catch (Exception e) {             DebugIM.println("ERROR, starting the rmiregistry, exception raised:");             e.printStackTrace();         }        }            public void tracesViewerActionPerformed(ActionEvent evt){        try{           // String javaHome= System.getProperty("java.home")+"/bin/";            if (tracesViewer!=null) {                tracesViewer.show();                return;            }                /*            IMUserAgent imUA=imGUI.getInstantMessagingUserAgent();            String imAddress=imUA.getIMAddress();            int imPort=imUA.getIMPort();            if (imAddress==null ||                imAddress.trim().equals("") ||                imPort==-1 )                 {                   DebugIM.println("ERROR, ListenerInstantMessaging, tracesViewer"+                   "ActionPerformed(), you have to set the stack IP address/port"+                   " in the configuration frame.");                   return;            }            */            String back="images/back.gif";            String faces="images/faces.jpg";            String actors="images/comp.gif";            String logoNist="images/nistBanner.jpg";                        String serverLogFile="debug/server_im_log.txt";             if (serverLogFile!=null) {                String fileName =serverLogFile;		LogFileParser parser = new LogFileParser();		Hashtable traces = parser.parseLogsFromFile(fileName);		tracesViewer=new TracesViewer		      (serverLogFile,traces,parser.logName,parser.logDescription,			parser.auxInfo,"IM Traces Viewer",                         back,faces,actors,logoNist);                tracesViewer.show();            }             else {                 new AlertInstantMessaging("ERROR: Specify a server log file before viewing the traces!",                       JOptionPane.ERROR_MESSAGE);                return;            }                                                                                  //  tracesViewer=new TracesViewer("IM Traces Viewer",           //  imAddress,"0","nist-sip-im-client",back,faces,actors,logoNist);                                                 /*            String commandLine=javaHome+"java -classpath "+getViewerClasspath()+" "+                 "tools.tracesviewer.TracesViewer -stackId "+                 proxyIPAddress+":"+proxyPort+" -back "+back+" -faces "+faces+                 " -actors "+actors+" -logoNist "+logoNist;                                 System.out.println(commandLine);            Runtime runtime=Runtime.getRuntime();            viewerProcess=runtime.exec(commandLine);                                // Thread for Debug:            errorViewerThread=new ErrorStreamViewerThread(viewerProcess,viewerOutputFrame);            errorViewerThread.start();            inputViewerThread=new InputStreamViewerThread(viewerProcess,viewerOutputFrame);            inputViewerThread.start();              */        }        catch(Exception e) {            e.printStackTrace();        }    }          public void sendIMActionPerformed(ActionEvent evt){        try{            IMUserAgent imUA=imGUI.getInstantMessagingUserAgent();            IMRegisterProcessing imRegisterProcessing=imUA.getIMRegisterProcessing();           // if (imRegisterProcessing.isRegistered()) {                RemoteSipURLFrame remoteSipURLFrame=new RemoteSipURLFrame(imGUI);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -