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

📄 aimplugin.java

📁 100%Java编写及时报信工具
💻 JAVA
字号:
package aimplugin;

import java.util.*;
import javax.swing.*;
import java.applet.*;
import java.io.*;
/* Copyright, 2001 Jason Dominiczak.
 *
 * This file is part of JIM - The Java Instant Messenger.
 * eMailer is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.

 * JIM is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with eMailer; see the file COPYING. If not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 * MA 02111-1307, USA.
 */
public class AimPlugin implements jim.PluginInterface {
	public jaimlib.Jaimlib AIMLib= new jaimlib.Jaimlib();
	public jim.Jim localJim;
	protected java.lang.String ScreenName;
	public java.lang.String tempPass;
	public java.lang.String tempUser;
	private java.util.Vector BuddyVector=new java.util.Vector();
	public boolean loggedon;
	public java.applet.AudioClip sendMessageSound;
	public java.applet.AudioClip revieveMessageSound;
	public java.applet.AudioClip BuddyOnSound;
	private boolean Online = false;
	public java.applet.AudioClip BuddyOffSound;
	private AimProperties ivjAimProperties = null;
	public java.util.Properties aimProp;
/**
 * AimPlugin constructor comment.
 */
public AimPlugin() {
	super();
	initialize();
}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param buddySN java.lang.String
 */
public void callbackBuddyAway(String buddySN) {}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param buddySN java.lang.String
 */
public void callbackBuddyBack(String buddySN) {}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param buddySN java.lang.String
 */
public void callbackBuddyOff(String buddySN) {
	localJim.callbackBuddyOff(buddySN, this);
	if(BuddyOffSound!=null)
		BuddyOffSound.play();
	BuddyVector.remove(buddySN);
	localJim.newStatusMessage(getTreeName() + ": " + buddySN + " Off");
	}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param buddySN java.lang.String
 */
public void callbackBuddyOn(String buddySN) {
	
	boolean alreadyOn = false;
	for(int i=0;i<BuddyVector.size();i++)
	{
		String TempSn = BuddyVector.get(i).toString();
		if(TempSn.equals(buddySN))
		{
			alreadyOn= true;
		}
	}
	if(alreadyOn!=true)
	{
		localJim.callbackBuddyOn(buddySN, this);
		localJim.newStatusMessage(getTreeName() + ": " + buddySN + " On");
		if(BuddyOnSound!=null)
			BuddyOnSound.play();
		BuddyVector.add(buddySN);
	}
}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param error int
 */
public void callbackDisconnect(int error) {}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param error int
 */
public void callbackError(int error) {
    if (error == 980) {
        JOptionPane jopane = new JOptionPane();
        jopane.showMessageDialog(
            null,
            "Your Username and/or Password Are Wrong.",
            "Error Occured",
            javax.swing.JOptionPane.ERROR_MESSAGE);
        localJim.newStatusMessage("AIM: Logged Off");
    } else {
        //System.out.println(error);
        JOptionPane jopane = new JOptionPane();
        jopane.showMessageDialog(
            null,
            "Error Number " + error + " occured in the AIM Plugin",
            "Error Occured",
            javax.swing.JOptionPane.ERROR_MESSAGE);
    }
}
/**
 * Insert the method's description here.
 * Creation date: (11/7/2001 6:47:26 PM)
 * @param error java.lang.String
 */
public void callbackError(String error) {
	System.out.println(error);
	}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param buddySN java.lang.String
 * @param idle long
 */
public void callbackGotIdle(String buddySN, long idle) {}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param buddySN java.lang.String
 * @param info java.lang.String
 * @param warning int
 * @param idle int
 * @param flags int
 */
public void callbackGotInfo(String buddySN, String info, int warning, int idle, int flags) {}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param level int
 * @param buddySN java.lang.String
 */
public void callbackGotWarned(int level, String buddySN) {}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param buddySN java.lang.String
 * @param online int
 * @param away int
 */
public void callbackListBuddy(String buddySN, int online, int away) {}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param who java.lang.String
 * @param text java.lang.String
 * @param automessage int
 */
public void callbackRecievedMessage(String who, String text, int automessage) {
	localJim.callbackRecievedMessage(who,text,this);
	if(revieveMessageSound!=null)
		revieveMessageSound.play();
	}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param idle long
 */
public void callbackSetIdle(long idle) {}
/**
 * Return the AimProperties property value.
 * @return aimplugin.AimProperties
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private AimProperties getAimProperties() {
	// user code begin {1}
	// user code end
	return ivjAimProperties;
}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @return boolean
 */
public boolean getConnected() {
	return Online;
}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @return jim.Jim
 */
public jim.Jim getJim() {
	return localJim;
}
/**
 * Insert the method's description here.
 * Creation date: (11/20/2001 5:01:05 PM)
 * @return javax.swing.JPanel
 */
public JPanel getProperties() {
	getAimProperties().setAimPluginThis(this);
	getAimProperties().setDefaults();
	return getAimProperties();
}
/**
 * Insert the method's description here.
 * Creation date: (11/24/2001 9:35:46 PM)
 * @return javax.swing.JPanel
 */
public JPanel getPropInst() {
	return getAimProperties();
}
/**
 * Insert the method's description here.
 * Creation date: (11/2/2001 11:37:18 PM)
 * @return java.lang.String
 */
public String getSN() {
	return ScreenName;
}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @return javax.swing.ImageIcon
 */
public javax.swing.ImageIcon getTabIcon() {
	return new javax.swing.ImageIcon(getClass().getResource("/aimicon.gif"));
}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @return java.lang.String
 */
public String getTreeName() {
	return "AIM";
}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @return java.lang.String
 */
public String getURL() {
	return "file:AimPlugin.html";
}
/**
 * Called whenever the part throws an exception.
 * @param exception java.lang.Throwable
 */
private void handleException(java.lang.Throwable exception) {

	/* Uncomment the following lines to print uncaught exceptions to stdout */
	 System.out.println("--------- UNCAUGHT EXCEPTION ---------");
	 exception.printStackTrace(System.out);
}
/**
 * Initialize the class.
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initialize() {
    try {
        // user code begin {1}
        try {
            sendMessageSound = Applet.newAudioClip((new File("imsend.wav")).toURL());
            revieveMessageSound = Applet.newAudioClip((new File("imrcv.wav")).toURL());
            BuddyOffSound = Applet.newAudioClip((new File("doorslam.wav")).toURL());
            BuddyOnSound = Applet.newAudioClip((new File("dooropen.wav")).toURL());
        } catch (java.net.MalformedURLException e) {
        }
        setAimProperties(new AimProperties());
        aimProp = new Properties();
        aimProp.load(new FileInputStream(new File("aim.properties")));
        
        // user code end
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
    // user code begin {2}
    // user code end
}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @return int
 * @param Username java.lang.String
 * @param Password java.lang.String
 */
public void login() {
    //AIMLib.connectServer("toc.oscar.aol.com", 9898);
    if (loggedon != true) {
	    AIMLib = new jaimlib.Jaimlib();
        AIMLib.callback = this;
        ScreenName = aimProp.getProperty("UsernameProp");
        localJim.newStatusMessage(getTreeName() + ": logging in");
        Runnable r = new Runnable() {
            public void run() {
                AIMLib.connectServer(aimProp.getProperty("ServerProp"), (new Integer(aimProp.getProperty("PortProp"))).intValue(), aimProp.getProperty("PasswordProp"),aimProp.getProperty("UsernameProp"));
				}
        };
        Thread newThread = new Thread(r, "Signon");
        newThread.start();
        loggedon = true;
    }
    return;
}
/**
 * Insert the method's description here.
 * Creation date: (11/24/2001 10:38:48 PM)
 */
public void logoff() {
	AIMLib.logoff();
	localJim.callbackLoggedOff(this);
	localJim.newStatusMessage("AIM: Logged Off");
	loggedon=false;
	}
/**
 * main entrypoint - starts the part when it is run as an application
 * @param args java.lang.String[]
 */
public static void main(java.lang.String[] args) {
	try {
		//AimPlugin aAimPlugin;
		//aAimPlugin = new AimPlugin();
	} catch (Throwable exception) {
		System.err.println("Exception occurred in main() of java.lang.Object");
		exception.printStackTrace(System.out);
	}
}
/**
 * Insert the method's description here.
 * Creation date: (11/23/2001 10:35:42 AM)
 */
public void saveProperties() {
	getAimProperties().saveProp();
	}
/**
 * Insert the method's description here.
 * Creation date: (11/2/2001 11:30:01 PM)
 * @param sname java.lang.String
 * @param message java.lang.String
 */
public void sendMessage(String sname, String message) {
    String work = "toc_send_im ";
    work = work.concat(sname);
    work = work.concat(" \"");
    for (int i = 0; i < message.length(); i++) {
        switch (message.charAt(i)) {
            case '$' :
            case '{' :
            case '}' :
            case '[' :
            case ']' :
            case '(' :
            case ')' :
            case '\"' :
            case '\\' :
                work = work.concat("\\" + message.charAt(i));
                break;
            default :
                work = work.concat("" + message.charAt(i));
                break;
        }
    }
    work = work.concat("\"\0");

    AIMLib.sendPacket(work);
    if (sendMessageSound != null) {
        sendMessageSound.play();
    }

}
/**
 * Set the AimProperties to a new value.
 * @param newValue aimplugin.AimProperties
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void setAimProperties(AimProperties newValue) {
	if (ivjAimProperties != newValue) {
		try {
			ivjAimProperties = newValue;
			// user code begin {1}
			// user code end
		} catch (java.lang.Throwable ivjExc) {
			// user code begin {2}
			// user code end
			handleException(ivjExc);
		}
	};
	// user code begin {3}
	// user code end
}
/**
 * Insert the method's description here.
 * Creation date: (11/18/2001 2:37:49 PM)
 */
public void setConnected(boolean conn) {
	Online = conn;
	}
/**
 * Insert the method's description here.
 * Creation date: (10/28/2001 4:04:49 PM)
 * @param localJIM jim.Jim
 */
public void setJim(jim.Jim jJIM) {
	localJim= jJIM;
	}
}

⌨️ 快捷键说明

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