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

📄 actionlistener.java.svn-base

📁 类似QQ的功能
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
					// Handle ICQ6 status message reply					skip = 111;					gotStausMsg = true;				}				if (gotStausMsg)				{					// Create an message entry					long textLen = 0;					int lenSkip = 0;					if (msgType == Message.MESSAGE_TYPE_EXTENDED)					{						textLen = Util.getDWord(buf, skip + uinLen, false);						lenSkip = 4;					}					else					{						textLen = Util.getWord(buf, skip + uinLen, false);						lenSkip = 2;					}										MainThread.showStatusString(Util.byteArrayToString(buf, skip + lenSkip + uinLen, (int)textLen,false), uin);				}			}					/** ********************************************************************* */			// Watch out for SRV_RECVMSG			else if ((snacPacket.getFamily() == SnacPacket.SRV_RECVMSG_FAMILY)					&& (snacPacket.getCommand() == SnacPacket.SRV_RECVMSG_COMMAND))			{				// Get raw data, initialize marker				byte[] buf = snacPacket.getData();				int marker = 0;				// Check length				if (buf.length < 11)				{					throw (new JimmException(150, 0, false));				}				// Get message format				marker += 8;				int format = Util.getWord(buf, marker);				marker += 2;				// Get UIN length				int uinLen = Util.getByte(buf, marker);				marker += 1;				// Check length				if (buf.length < marker + uinLen + 4)				{					throw (new JimmException(150, 1, false));				}				// Get UIN				String uin = Util.byteArrayToString(buf, marker, uinLen);				marker += uinLen;				// Skip WARNING				marker += 2;				// Skip TLVS				int tlvCount = Util.getWord(buf, marker);				marker += 2;				for (int i = 0; i < tlvCount; i++)				{					byte[] tlvData = Util.getTlv(buf, marker);					if (tlvData == null)					{						throw (new JimmException(150, 2, false));					}					marker += 4 + tlvData.length;				}				// Get message data and initialize marker				byte[] msgBuf;				int tlvType;				do				{					msgBuf = Util.getTlv(buf, marker);					if (msgBuf == null)					{						throw (new JimmException(150, 3, false));					}					tlvType = Util.getWord(buf, marker);					marker += 4 + msgBuf.length;				} while ((tlvType != 0x0002) && (tlvType != 0x0005));				int msgMarker = 0;				//////////////////////				// Message format 1 //				//////////////////////				if (format == 0x0001)				{					// Variables for all possible TLVs					// byte[] capabilities = null;					byte[] message = null;					// Read all TLVs					while (msgMarker < msgBuf.length)					{						// Get next TLV						byte[] tlvValue = Util.getTlv(msgBuf, msgMarker);						if (tlvValue == null)						{							throw (new JimmException(151, 0, false));						}						// Get type of next TLV						tlvType = Util.getWord(msgBuf, msgMarker);						// Update markers						msgMarker += 4 + tlvValue.length;						// Save value						switch (tlvType)						{						case 0x0501:							// capabilities							// capabilities = tlvValue;							break;						case 0x0101:							// message							message = tlvValue;							break;						default:							throw (new JimmException(151, 1, false));						}					}					// Process packet if at least the message TLV was present					if (message != null)					{						// Check length of message						if (message.length < 4)						{							throw (new JimmException(151, 2, false));						}						// Get message text						String text;						if (Util.getWord(message, 0) == 0x0002)						{							text = Util.removeCr(Util.ucs2beByteArrayToString(									message, 4, message.length - 4));						} else						{							text = Util.removeCr(Util.byteArrayToString(									message, 4, message.length - 4));						}						// Construct object which encapsulates the received						// plain message						PlainMessage plainMsg = new PlainMessage(uin, Options								.getString(Options.OPTION_UIN), Util								.createCurrentDate(false), text, false);						MainThread.addMessageSerially(plainMsg);					}				}				//////////////////////				// Message format 2 //				//////////////////////				else if (format == 0x0002)				{					// TLV(A): Acktype 0x0000 - normal message					//                 0x0001 - file request / abort request					//                 0x0002 - file ack					// Check length					if (msgBuf.length < 10)					{						throw (new JimmException(152, 0, false));					}					// Get and validate SUB_MSG_TYPE2.COMMAND					int command = Util.getWord(msgBuf, msgMarker);					if (command != 0x0000)						return; // Only normal messages are					// supported yet					msgMarker += 2;					// Skip SUB_MSG_TYPE2.TIME and SUB_MSG_TYPE2.ID					msgMarker += 4 + 4;					// Check length					if (msgBuf.length < msgMarker + 16)					{						throw (new JimmException(152, 1, false));					}					// Skip SUB_MSG_TYPE2.CAPABILITY					msgMarker += 16;					// Get message data and initialize marker					byte[] msg2Buf;//#sijapp cond.if (target != "DEFAULT") & (modules_FILES = "true")#					int ackType = -1;					byte[] extIP = new byte[4];					byte[] ip = new byte[4];					String port = "0";//#sijapp cond.end#					do					{						msg2Buf = Util.getTlv(msgBuf, msgMarker);						if (msg2Buf == null)						{							throw (new JimmException(152, 2, false));						}						tlvType = Util.getWord(msgBuf, msgMarker);//#sijapp cond.if (target != "DEFAULT") & (modules_FILES = "true")#						switch (tlvType)						{						case 0x0003:							System.arraycopy(msg2Buf, 0, extIP, 0, 4);							break;						case 0x0004:							System.arraycopy(msg2Buf, 0, ip, 0, 4);							break;						case 0x0005:							port = Util.byteArrayToString(msg2Buf);							break;						case 0x000a:							ackType = Util.getWord(msg2Buf, 0);							break;						}//#sijapp cond.end#						msgMarker += 4 + msg2Buf.length;					} while (tlvType != 0x2711);					int msg2Marker = 0;					// Check length					if (msg2Buf.length < 2 + 2 + 16 + 3 + 4 + 2 + 2 + 2 + 12							+ 2 + 2 + 2 + 2)					{						throw (new JimmException(152, 3, false));					}					// Skip values up to (and including) SUB_MSG_TYPE2.UNKNOWN					// (before MSGTYPE)					msg2Marker += 2 + 2 + 16 + 3 + 4 + 2 + 2 + 2 + 12;					// Get and validate message type					int msgType = Util.getWord(msg2Buf, msg2Marker, false);					msg2Marker += 2;					if (!((msgType == Message.MESSAGE_TYPE_NORM) || (msgType == Message.MESSAGE_TYPE_URL)							|| (msgType == Message.MESSAGE_TYPE_EXTENDED) || ((msgType >= Message.MESSAGE_TYPE_AWAY) && (msgType <= Message.MESSAGE_TYPE_FFC))))						return;//#sijapp cond.if (target != "DEFAULT") & (modules_FILES = "true")#					Util.getWord(msg2Buf, msg2Marker);//#sijapp cond.end#					msg2Marker += 2;					// Skip PRIORITY					msg2Marker += 2;					// Get length of text					int textLen = Util.getWord(msg2Buf, msg2Marker, false);					msg2Marker += 2;					// Check length					if (!((msgType >= 1000) && (msgType <= 1004)))						if (msg2Buf.length < msg2Marker + textLen + 4 + 4)						{							throw (new JimmException(152, 4, false));						}					// Get raw text					byte[] rawText = new byte[textLen];					System.arraycopy(msg2Buf, msg2Marker, rawText, 0, textLen);					msg2Marker += textLen;					// Plain message or URL message					if (((msgType == 0x0001) || (msgType == 0x0004))							&& (rawText.length > 1))					{						// Skip FOREGROUND and BACKGROUND						if ((msgType == 0x0001) || (msgType == 0x0004))						{							msg2Marker += 4 + 4;						}						// Check encoding (by checking GUID)						boolean isUtf8 = false;						if (msg2Buf.length >= msg2Marker + 4)						{							int guidLen = (int) Util.getDWord(msg2Buf,									msg2Marker, false);							if (guidLen == 38)							{								if (Util										.byteArrayToString(msg2Buf,												msg2Marker + 4, guidLen)										.equals(												"{0946134E-4C7F-11D1-8222-444553540000}"))								{									isUtf8 = true;								}							}							msg2Marker += 4 + guidLen;						}						// Decode text and create Message object						Message message;						if (msgType == 0x0001)						{							// Decode text							String text = Util.removeCr(Util.byteArrayToString(									rawText, isUtf8));							// Instantiate message object							message = new PlainMessage(uin, Options									.getString(Options.OPTION_UIN), Util									.createCurrentDate(false), text, false);						} else						{							// Search for delimited							int delim = -1;							for (int i = 0; i < rawText.length; i++)							{								if (rawText[i] == 0xFE)								{									delim = i;									break;								}							}							// Decode text; split text first, if delimiter could							// be found							String urlText, url;							if (delim != -1)							{								urlText = Util.removeCr(Util.byteArrayToString(										rawText, 0, delim, isUtf8));								url = Util.removeCr(Util.byteArrayToString(										rawText, delim + 1, rawText.length												- delim - 1, isUtf8));							} else							{								urlText = Util.removeCr(Util.byteArrayToString(										rawText, isUtf8));								url = "";							}							// Instantiate UrlMessage object							message = new UrlMessage(uin, Options									.getString(Options.OPTION_UIN), Util									.createCurrentDate(false), url, urlText);						}						// Forward message object to contact list						MainThread.addMessageSerially(message);						// Acknowledge message						byte[] ackBuf = new byte[10 + 1 + uinLen + 2 + 51 + 3];						int ackMarker = 0;						System.arraycopy(buf, 0, ackBuf, ackMarker, 10);						ackMarker += 10;						Util.putByte(ackBuf, ackMarker, uinLen);						ackMarker += 1;						byte[] uinRaw = Util.stringToByteArray(uin);						System.arraycopy(uinRaw, 0, ackBuf, ackMarker,								uinRaw.length);						ackMarker += uinRaw.length;						Util.putWord(ackBuf, ackMarker, 0x0003);						ackMarker += 2;						System.arraycopy(msg2Buf, 0, ackBuf, ackMarker, 51);						ackMarker += 51;						Util.putWord(ackBuf, ackMarker, 0x0001, false);						ackMarker += 2;						Util.putByte(ackBuf, ackMarker, 0x00);						ackMarker += 1;						SnacPacket ackPacket = new SnacPacket(								SnacPacket.CLI_ACKMSG_FAMILY,								SnacPacket.CLI_ACKMSG_COMMAND, 0, new byte[0],								ackBuf);						Icq.sendPacket(ackPacket);					}					// Extended message					else if (msgType == 0x001A)					{						// Check length						if (msg2Buf.length < msg2Marker + 2 + 18 + 4)						{							throw (new JimmException(152, 5, false));						}						// Save current marker position						int extDataStart = msg2Marker;						// Skip EXTMSG.LEN and EXTMSG.UNKNOWN						msg2Marker += 2 + 18;						// Get length of plugin string						int pluginLen = (int) Util.getDWord(msg2Buf,								msg2Marker, false);						msg2Marker += 4;						// Check length						if (msg2Buf.length < msg2Marker + pluginLen + 15 + 4								+ 4)						{							throw (new JimmException(152, 6, false));						}						// Get plugin string						String plugin = Util.byteArrayToString(msg2Buf,								msg2Marker, pluginLen);						msg2Marker += pluginLen;

⌨️ 快捷键说明

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