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

📄 cstatusreportmessage.java

📁 gsm modem 发送短信 闪信 WAP PUSH开发包
💻 JAVA
字号:
//	jSMSEngine API.
//	An open-source API package for sending and receiving SMS via a GSM device.
//	Copyright (C) 2002-2006, Thanasis Delenikas, Athens/GREECE
//		Web Site: http://www.jsmsengine.org
//
//	jSMSEngine is distributed under the GPL license.
//
//	This program is free software; you can redistribute it and/or
//	modify it under the terms of the GNU General Public License
//	version 2 as published by the Free Software Foundation
//
//	This program 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 this program; if not, write to the Free Software
//	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//

package org.jsmsengine;

import java.util.*;
import java.text.*;

/**
	This class represents a Status Report SMS message.

	In order to request a Status Report, use the setStatusReport() function of
		the outgoing message. Then, expect to eventually receive an IncomingMessage
		message of class CStatusReportMessage() (i.e. with type == TYPE_STATUS_REPORT).<br><br>
		Valid fields are:<br>
			recipient: the recipient of the original message.<br>
			text: a message reading the status of the delivery.<br>

	@see	CMessage
	@see	COutgoingMessage
	@see	COutgoingMessage#setStatusReport(boolean)
	@see	CIncomingMessage
	@see	CService#readMessages(LinkedList, int)
*/
public class CStatusReportMessage extends CIncomingMessage implements java.io.Serializable
{
	protected CStatusReportMessage(String pdu, int memIndex)
	{
		super(TYPE_STATUS_REPORT, memIndex);

		int index, i, j, k;

		i = Integer.parseInt(pdu.substring(0, 2), 16);
		index = (i + 1) * 2;
		index += 2;
		refNo = Integer.parseInt(pdu.substring(index, index + 2), 16);
		index += 2;

		i = Integer.parseInt(pdu.substring(index, index + 2), 16);
		j = index + 4;
		recipient = "";
		for (k = 0; k < i; k += 2) recipient = recipient + pdu.charAt(j + k + 1) + pdu.charAt(j + k);
		recipient = "+" + recipient;
		if (recipient.charAt(recipient.length() - 1) == 'F')
		{
			recipient = recipient.substring(0, recipient.length() - 1);
			i ++;
		}

		index = j + i;

		// -------------------------------------------------------------------- 
		// Modified by Gaetano Rossiello, Italy - info@ebstudionet.it 
 
		/* 
		* Parse and fetch the date of original sms 
		*/ 
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss"); 
		String dateOctect = pdu.substring(index, index + 12); 
		StringBuffer dateOk = new StringBuffer(); 
		for (int x = 0; x < 12; x = x + 2) dateOk.append(new char[] { dateOctect.charAt(x + 1), dateOctect.charAt(x) }); 
 
		try { this.dateOriginal = sdf.parse(dateOk.toString()); }
		catch (ParseException e) { this.dateOriginal = null; } 
		index += 14; 

		/* 
		* Parse and fetch the date of real receipt 
		*/ 
		dateOctect = pdu.substring(index, index + 12); 
		dateOk = new StringBuffer(); 
		for (int x = 0; x < 12; x = x + 2) dateOk.append(new char[] { dateOctect.charAt(x + 1), dateOctect.charAt(x) }); 
 
		try { this.dateReceived = sdf.parse(dateOk.toString()); }
		catch (ParseException e) { this.dateReceived = null; } 
		index += 14; 
		// **END **
		// Modified by Gaetano Rossiello, Italy - info@ebstudionet.it 
		// -------------------------------------------------------------------- 

		i = Integer.parseInt(pdu.substring(index, index + 1), 16);
		if ((i & 0x60) == 0) text = "00 - Succesful Delivery.";
		if ((i & 0x20) == 0x20) text = "01 - Errors, will retry dispatch.";
		if ((i & 0x40) == 0x40) text = "02 - Errors, stopped retrying dispatch.";
		if ((i & 0x60) == 0x60) text = "03 - Errors, stopped retrying dispatch.";

		date = null;
	}

	/**
		Returns the Originator of the message.
		Overloaded to return a valid value for CStatusReportMessage class.

		@return  the recipient of the original message.
	*/
	public String getOriginator() { return "TO:" + recipient; }

}

⌨️ 快捷键说明

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