亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cservice.java

?? JAVA手機短信開發包
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
//	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 a package which can be used in order to add SMS processing
//		capabilities in an application. jSMSEngine is written in Java. It allows you
//		to communicate with a compatible mobile phone or GSM Modem, and
//		send / receive SMS messages.
//
//	jSMSEngine is distributed under the LGPL license.
//
//	This library is free software; you can redistribute it and/or
//		modify it under the terms of the GNU Lesser General Public
//		License as published by the Free Software Foundation; either
//		version 2.1 of the License, or (at your option) any later version.
//	This library 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
//		Lesser General Public License for more details.
//	You should have received a copy of the GNU Lesser General Public
//		License along with this library; if not, write to the Free Software
//		Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//

package org.jsmsengine;

import java.io.*;
import java.util.*;
import java.util.logging.*;
import java.text.*;

/**
	This class provides all the functionality of jSMSEngine API to the developer.
	<br><br>
	The class CService provides all the interface routines to jSMSEngine. It
	is responsible for initialization of the communication with the GSM device,
	reading and sending messages, setting the phonebook.
	<br><br>
	The sequence of actions that need to be done are:
	<ul>
		<li>Call connect() to connect with the GSM device.</li>
		<li>Call sendMessage(), or readMessages() to send or receive messages
				from the device. Call deleteMessage() to delete a message from
				the device's memory.</li>
		<li>Call refreshDeviceInfo() to get updated GSM device specific information.</li>
		<li>Call disconnect() to disconnect from the GSM device.</li>
	</ul>
	<br>
*/
public class CService
{
	/**
		Internal Software Name.
	*/
	public static final String _name = "jSMSEngine API";
	/**
		Version.
	*/
	public static final String _version = "2.0.4";
	/**
		Release Date.
	*/
	public static final String _reldate = "Jan 18, 2006";

	/**
		Logging facilities.
	*/
	private static Logger log = Logger.getLogger("org.jsmsengine");

	/**
		Preferred Message Storage constants.
	*/
		public static final int SMS_STORAGE_SIM = 1;

	/**
		Preferred Message Storage constants.
	*/
		public static final int SMS_STORAGE_MEM = 2;

	/**
		Receive modes: Synchronous and Ascynchronous.
	*/
	public static final int RECEIVE_MODE_SYNC = 1;
	/**
		Receive modes: Synchronous and Ascynchronous.
	*/
	public static final int RECEIVE_MODE_ASYNC = 2;

	/**
		Default value for information that is not reported by the GSM device. 
	*/
	public static final String VALUE_NOT_REPORTED = "* N/A *";

	/**
		Maximum number of retries when a message failes to be sent (various CMS errors)
	*/
	public static final int CMS_ERRORS_MAX_RETRIES = 5;
	public static final int CMS_ERRORS_DELAY = 5000;

	public static final int MAX_SMS_LEN_7BIT = 160;
	public static final int MAX_SMS_LEN_8BIT = 140;
	public static final int MAX_SMS_LEN_UNICODE = 70;

	/**
		The SMSC number (if specifically given).
	*/
	private String smscNumber;

	/**
		The PIN number.
	*/
	private String simPin;

	/**
		Receive Mode: Synchronous or Asynchronous.
	*/
	private int receiveMode;

	/**
		AT Commands' Handler.
	*/
	private CATHandler atHandler;

	private CSerialDriver serialDriver;
	private boolean connected;
	private CPhoneBook phoneBook;
	private CDeviceInfo deviceInfo;

	private CReceiveThread receiveThread;
	private CSmsMessageListener messageHandler;

	/**
		Default constructor of the class.

		@param	port	the serial port where the GSM device is connected (e.g. "com1"). 
		@param	baud	the connection speed (i.e. 9600, 19200 etc).
		@param	gsmDeviceManufacturer	The manufacturer of your device, i.e. Nokia, Siemens, etc.
		@param	gsmDeviceModel	The model of your device, i.e. 6310i, C55, V600 etc.

		<br><br>
		Notes:
		<ul>
			<li>The manufacturer / model combination is used for accessing the correct AT handler for
					your device. If there is no specific handler developed, jSMSEngine will fall back and
					use the generic AT handler. This may or may not work, depending on the
					peculiarities of your device. If you wish to create a custom handler, please look
					at the specific section of the documentation pages.</li>
			<li>Use one of the standard values for baud. Most GSM phones work well
					at 9600 or 19200. Most dedicated GSM modems may work well up to
					115200. The connection speed is not that important to the speed
					at which jSMSEngine processes messages.</li>
		</ul>
	*/
	public CService(String port, int baud, String gsmDeviceManufacturer, String gsmDeviceModel)
	{
		smscNumber = null;
		simPin = null;

		connected = false;
		serialDriver = new CSerialDriver(port, baud, log);
		phoneBook = new CPhoneBook();
		deviceInfo = new CDeviceInfo();

		if ((System.getProperty("jsmsengine.debug") != null) && (System.getProperty("jsmsengine.debug").equalsIgnoreCase("true")))
		{
			log.setLevel(Level.FINEST);
			log.log(Level.INFO, "jSMSEngine:" + _name + " / " + _version + " / " + _reldate);
			log.log(Level.INFO, "	JRE Version: " + System.getProperty("java.version"));
			log.log(Level.INFO, "	JRE Impl Version: " + System.getProperty("java.vm.version"));
			log.log(Level.INFO, "	Class Path: " + System.getProperty("java.class.path"));
			log.log(Level.INFO, "	Library Path: " + System.getProperty("java.library.path"));
			log.log(Level.INFO, "	O/S: " + System.getProperty("os.name") + " / " + System.getProperty("os.arch") + " / " + System.getProperty("os.version"));
		}
		else log.setLevel(Level.SEVERE);

		// Which AT Handler should I use???
		if (gsmDeviceManufacturer.equalsIgnoreCase("Nokia"))
		{
			atHandler = new CATHandler_Nokia(serialDriver, log);
			log.log(Level.INFO, "jSMSEngine: Using Nokia(Generic) AT handler.");
		}
		else if (gsmDeviceManufacturer.equalsIgnoreCase("Wavecom"))
		{
			atHandler = new CATHandler_Wavecom(serialDriver, log);
			log.log(Level.INFO, "jSMSEngine: Using Wavecom(Generic) AT handler.");
		}
		else if (gsmDeviceManufacturer.equalsIgnoreCase("Siemens"))
		{
			atHandler = new CATHandler_Siemens(serialDriver, log);
			log.log(Level.INFO, "jSMSEngine: Using Siemens AT(Generic) handler.");
		}
		else if (gsmDeviceManufacturer.equalsIgnoreCase("SonyEricsson"))
		{
			atHandler = new CATHandler_SonyEricsson(serialDriver, log);
			log.log(Level.INFO, "jSMSEngine: Using SonyEricsson(Generic) AT handler.");
		}
		else
		{
			atHandler = new CATHandler(serialDriver, log);
			log.log(Level.INFO, "jSMSEngine: Using generic AT handler.");
		}
		
		receiveMode = RECEIVE_MODE_SYNC;
		receiveThread = null;
	}

	/**
		Returns TRUE if the API is connected to the GSM device.

		@return  TRUE if the API is connected to the GSM device.
	*/
	public boolean getConnected() { return connected; }

	/**
		Returns a CDeviceInfo object that holds information about the GSM
		device in use.

		@return  a CDeviceInfo object.
		@see	CDeviceInfo
	*/
	public CDeviceInfo getDeviceInfo() { return deviceInfo; }

	/**
		Sets the Short Message Service Center (SMSC) number. Please use international format.
		If you don't want to set the SMSC and use the one defined in your GSM device, use an
		empty string parameter. Another way to do the same, is to pass a null parameter. Some
		phones may prefer one way or the other - please test your phone.

		@param	smscNumber	the SMSC number.
	*/
	public void setSmscNumber(String smscNumber) { this.smscNumber = smscNumber; }

	/**
		Returns the Short Message Service Center (SMSC) number you have previously
		defined with setSmscNumber().

		@return  the SMSC number.
	*/
	public String getSmscNumber() { return smscNumber; }

	/**
		Sets the SIM pin number. This is used if and when the GSM device asks for it. If you set it to
		null, then the API does not give any PIN to the device (in order to avoid locking it up), and
		returns ERR_SIM_PIN_ERROR.

		@param	simPin	the SIM pin number.
	*/
	public void setSimPin(String simPin) { this.simPin = simPin; }

	public void setMessageHandler(CSmsMessageListener messageHandler) { this.messageHandler = messageHandler; }

	/**
		Returns the SIM pin number.

		@return  the SIM pin number.
	*/
	public String getSimPin() { return simPin; }

	/**
		Sets the reception mode.
		There are two reception modes, the synchronous and the asynchronous.
		In synchronous mode, you should call readMessages() function on demand,
		where you want to check for new messages. In asynchronous mode, the engine
		automatically calls the received() method (which you <strong>should</strong>
		override) for every received message.
		<br>By default, the reception mode is the synchronous one.

		@param	receiveMode	the reception mode (one of values RECEIVE_MODE_ASYNC, RECEIVE_MODE_SYNC).
		@see	CService#getReceiveMode()
	*/
	public void setReceiveMode(int receiveMode) { this.receiveMode = receiveMode; }

	/**
		Returns the reception mode.

		@return	the reception mode (one of values RECEIVE_MODE_ASYNC, RECEIVE_MODE_SYNC).
		@see	CService#setReceiveMode(int)
	*/
	public int getReceiveMode() { return receiveMode; }

	/**
		Loads the phonebook. The phonebook is an XML file containing associations of name
		and phone numbers.
		<br><br>
		<strong>The phonebook is optional.</strong> 

		@param	phoneBookFile	The XML full-path name which keeps the phonebook.
		@see	CPhoneBook
		@see	CService#sendMessage(COutgoingMessage)
		@see	CService#sendMessage(LinkedList)
	*/
	public void setPhoneBook(String phoneBookFile) throws Exception
	{
		phoneBook.load(phoneBookFile);
	}

	protected CSmsMessageListener getMessageHandler() { return messageHandler; }

	/**
		Connects to the GSM device. Opens the serial port, and sends the appropriate
		AT commands to initialize the operation mode of the GSM device. Retrieves
		information about the GSM device.
		Notes:
		<br>
		<ul>
			<li>The GSM device specific information (read by the call to refreshDeviceInfo()
					function is called once from this method. Since some information changes
					with time (such as battery or signal level), its your responsibility to
					call refreshDeviceInfo() periodically in order to have the latest information.
					Otherwise, you will get the information snapshot taken at the time
					of the initial connection.
			</li>
		</ul>

		@throws  AlreadyConnectedException
		@throws NoPinException
		@throws InvalidPinException
		@throws NoPduSupportException
		@throws CannotDisableIndicationsException
		@see	CDeviceInfo
		@see	CService#refreshDeviceInfo()
		@see	CService#disconnect()
	*/
	public void connect() throws Exception
	{
		if (getConnected()) throw new AlreadyConnectedException();
		else
			try
			{
				serialDriver.open();
				atHandler.reset();
				atHandler.sync();
				if (atHandler.isAlive())
				{
					if (atHandler.waitingForPin())
					{
						if (getSimPin() == null) throw new NoPinException();
						else if (!atHandler.enterPin(getSimPin())) throw new InvalidPinException();
					}
					atHandler.echoOff();
					atHandler.init();
					atHandler.setVerboseErrors();
					if (!atHandler.setPduMode()) throw new NoPduSupportException();
					if (!atHandler.disableIndications()) throw new CannotDisableIndicationsException();
					connected = true;
					refreshDeviceInfo();

					receiveThread = new CReceiveThread();
					receiveThread.start();
				}
				else throw new NotConnectedException("GSM device is not responding.");
			}
			catch (AlreadyConnectedException e)
			{
				throw e;
			}
			catch (Exception e)
			{
				disconnect();
				throw e;
			}
	}

	/**
		Disconnects to the GSM device. Closes the serial port. 

		@see	CService#connect()
	*/
	public void disconnect()
	{
		if (receiveThread != null)
		{
			receiveThread.killMe();
			while (!receiveThread.killed()) try { Thread.sleep(1000); } catch (Exception e) {}
			receiveThread = null;
		}
		try { serialDriver.close(); } catch (Exception e) {}
		connected = false;
	}

	/**
		Reads SMS from the GSM device's memory. You should call this method when
		you want to read messages from the device. In the MessageList object you
		pass, the method will add objects of type CIncomingMessage, as many of them
		as the messages pending to be read. The class defines which types of messages
		should be read.
		<br><br>
		<strong>Notes:</strong>
		<ul>
			<li>The method <strong>does not delete</strong> the messages it reads
				from the GSM device. It's your responsibility to delete them, if you
				don't want them. Otherwise, on the next call of this function you
				will read the same messages.</li>
		</ul>

		@param	messageList	a LinkedList object which will be loaded with the messages.
		@param	messageClass	one of the CLASS_* values defined in CIncomingMessage class which
				define what type of messages are to be read.
		@throws NotConnectedException
		@see	CIncomingMessage
		@see	CService#deleteMessage(CIncomingMessage)
		@see	CService#deleteMessage(int)
	*/
	public void readMessages(LinkedList messageList, int messageClass) throws Exception
	{
		int i, j, memIndex;
		String response, line, sms, temp, originator, text, pdu;
		String day, month, year, hour, min, sec;
		BufferedReader reader;
		Date sentDate;
		Calendar cal = Calendar.getInstance();

		if (getConnected())
		{
			atHandler.switchToCmdMode();
			response = atHandler.listMessages(messageClass);
			reader = new BufferedReader(new StringReader(response));
			line = reader.readLine().trim();
			while ((line != null) && (line.length() > 0) && (!line.equalsIgnoreCase("OK")))
			{
				i = line.indexOf(':');
				j = line.indexOf(',');
				memIndex = Integer.parseInt(line.substring(i + 1, j).trim());
				pdu = reader.readLine();
				if (isIncomingMessage(pdu))
				{
					messageList.add(new CIncomingMessage(pdu, memIndex));
					deviceInfo.getStatistics().incTotalIn();
				}
				else if (isStatusReportMessage(pdu))
				{
					messageList.add(new CStatusReportMessage(pdu, memIndex));

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91国偷自产一区二区三区成为亚洲经典| 国产精品蜜臀在线观看| 成人国产精品免费| 国内久久婷婷综合| 久久精品国产77777蜜臀| 婷婷开心久久网| 亚洲精品国产精华液| 尤物在线观看一区| 日韩不卡一区二区三区| 日本成人超碰在线观看| 国产一区二区三区| 国产99久久精品| 91丨九色丨尤物| 欧美老人xxxx18| 久久日韩粉嫩一区二区三区| 国产欧美日韩亚州综合| 亚洲精品综合在线| 日韩成人精品在线观看| 国产成人丝袜美腿| 一本大道久久精品懂色aⅴ| 欧美午夜电影网| 日韩精品专区在线影院重磅| 久久精品日韩一区二区三区| 中文字幕一区二区三| 性感美女久久精品| 国产一区二区三区免费看 | 亚洲图片欧美色图| 首页国产欧美日韩丝袜| 国产精品白丝jk黑袜喷水| 91在线小视频| 欧美一区永久视频免费观看| 国产日韩欧美综合一区| 欧美mv日韩mv| 一区二区三区四区在线| 激情五月激情综合网| 色婷婷精品大视频在线蜜桃视频| 欧美一区二区三区精品| 国产精品女人毛片| 视频一区国产视频| 9色porny自拍视频一区二区| 欧美精品久久一区二区三区| 国产亲近乱来精品视频| 日韩国产精品久久久| 9l国产精品久久久久麻豆| 欧美一级免费观看| 综合久久综合久久| 国内久久婷婷综合| 欧美日韩一区精品| 国产欧美1区2区3区| 香港成人在线视频| 99国产精品一区| 久久久久久免费网| 精品一区二区三区在线播放| 欧美天堂亚洲电影院在线播放| 国产精品丝袜久久久久久app| 免费成人在线播放| 欧美日韩在线亚洲一区蜜芽| 亚洲欧美二区三区| 国产69精品久久久久777| 精品少妇一区二区三区免费观看| 亚洲线精品一区二区三区八戒| 成人毛片老司机大片| 国产亚洲综合在线| 国产精品综合网| 精品国产一区二区在线观看| 日韩激情视频网站| 在线播放91灌醉迷j高跟美女| 亚洲香肠在线观看| 欧美三级日韩在线| 亚洲午夜av在线| 欧美日韩国产在线播放网站| 一区二区成人在线| 欧美三级视频在线| 亚洲国产你懂的| 欧美日韩国产123区| 亚洲一区二区偷拍精品| 日本高清成人免费播放| 亚洲一级二级在线| 欧美精品第一页| 日本怡春院一区二区| 欧美一区二区三区不卡| 五月婷婷久久丁香| 精品欧美黑人一区二区三区| 狠狠狠色丁香婷婷综合激情| 国产亚洲精品免费| 成人av免费在线| 亚洲精品视频一区| 欧美精选午夜久久久乱码6080| 欧美aaa在线| 日韩欧美123| 丁香婷婷综合激情五月色| 日本一区二区电影| 色婷婷激情一区二区三区| 亚洲线精品一区二区三区八戒| 欧美一区二区三区日韩视频| 国产一区二区精品在线观看| 国产精品五月天| 色老汉av一区二区三区| 天天综合日日夜夜精品| 欧美一激情一区二区三区| 国内精品国产三级国产a久久| 国产欧美日韩久久| 91啪亚洲精品| 美女一区二区在线观看| 国产精品毛片无遮挡高清| 欧美日韩中字一区| 国产二区国产一区在线观看| 日韩久久一区二区| 精品久久国产老人久久综合| av色综合久久天堂av综合| 亚洲国产中文字幕| 亚洲国产精品成人综合| 欧美乱熟臀69xxxxxx| 成人小视频在线| 日韩黄色免费电影| 国产精品久久久久三级| 4438x亚洲最大成人网| av中文字幕一区| 久久99九九99精品| 亚洲色图色小说| 亚洲精品在线三区| 欧美日韩成人高清| 成人av在线播放网址| 久久精品999| 亚洲美女在线国产| 国产日韩欧美激情| 欧美一区二区三区精品| 在线观看一区日韩| 粉嫩在线一区二区三区视频| 日韩精品一二三四| 亚洲综合免费观看高清在线观看| 久久精品亚洲一区二区三区浴池| 欧美高清精品3d| 在线观看日韩国产| 97精品国产露脸对白| 丁香婷婷综合激情五月色| 国内精品国产成人国产三级粉色| 午夜激情久久久| 亚洲午夜激情网页| 亚洲一区自拍偷拍| 亚洲老司机在线| 玉米视频成人免费看| 亚洲女人的天堂| 中文字幕一区二区三中文字幕| 337p粉嫩大胆色噜噜噜噜亚洲| 在线成人小视频| 欧美日韩极品在线观看一区| 欧美午夜精品一区| 欧美日韩dvd在线观看| 欧美自拍偷拍一区| 欧美在线啊v一区| 99re66热这里只有精品3直播 | 人人超碰91尤物精品国产| 舔着乳尖日韩一区| 国产精品影视在线| 精品在线免费视频| 极品少妇xxxx偷拍精品少妇| 蜜臀av性久久久久蜜臀aⅴ流畅| 三级久久三级久久久| 天使萌一区二区三区免费观看| 午夜精品免费在线观看| 日韩精品一二三四| 久久成人羞羞网站| 国产精品中文字幕一区二区三区| 黄色日韩网站视频| 国产成人亚洲综合a∨婷婷图片| 国产成人av影院| 成人午夜在线免费| 色综合中文综合网| 欧美人与z0zoxxxx视频| 欧美一区二区黄色| 久久精品一区蜜桃臀影院| 欧美国产日韩精品免费观看| √…a在线天堂一区| 亚洲国产日产av| 国内精品久久久久影院色| 不卡一区中文字幕| 欧美三级乱人伦电影| 精品久久国产老人久久综合| 日本一区二区不卡视频| 亚洲人成精品久久久久| 日日夜夜精品视频天天综合网| 免费在线观看一区二区三区| 成人黄色a**站在线观看| 欧美日韩一区二区在线视频| 久久久久久久综合日本| 一区二区三区丝袜| 国产一区视频在线看| 在线视频中文字幕一区二区| 久久综合久色欧美综合狠狠| 最新日韩av在线| 久久成人18免费观看| 91麻豆文化传媒在线观看| 日韩欧美123| 一区二区三区鲁丝不卡| 国产高清不卡一区| 91精品在线观看入口| 日韩一区中文字幕| 精品综合久久久久久8888| 欧美天天综合网|