From: jihye kim Date: Thu, 5 Jul 2012 05:26:19 +0000 (+0900) Subject: [Title] add checking sms phone number.. X-Git-Tag: 2.2.1_release^2~89^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd86fb07af9f02f816765db16db3621ed76477a6;p=sdk%2Femulator%2Feventinjector-eplugin.git [Title] add checking sms phone number.. [Type] bug fix [Module] event injector [Priority] major [Jira#] N_SE-2568 [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- diff --git a/org.tizen.telephony.sms/src/org/tizen/telephony/sms/page/SMS.java b/org.tizen.telephony.sms/src/org/tizen/telephony/sms/page/SMS.java index d6a2c5b..ad8c048 100644 --- a/org.tizen.telephony.sms/src/org/tizen/telephony/sms/page/SMS.java +++ b/org.tizen.telephony.sms/src/org/tizen/telephony/sms/page/SMS.java @@ -32,6 +32,8 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -62,6 +64,7 @@ import org.tizen.telephony.sms.protocol.G04A01; import org.tizen.telephony.sms.protocol.G04A05; import org.tizen.common.connection.ConnectionPlugin; import org.tizen.common.connection.ConnectionPlugin.ISelectionListener; +import org.tizen.common.util.DialogUtil; import org.tizen.sdblib.IDevice; import org.tizen.sdblib.FileListingService.FileEntry; @@ -293,6 +296,23 @@ ISelectionListener{ } protected void sendMsg() { + // check number + String number = cmbMobileTerminateOriginatingAddress.getText().trim(); + { + if(number==null||number.length()==0) { + DialogUtil.openMessageDialog("Input phone number."); + return; + } + if(number.length() > 15) { + DialogUtil.openMessageDialog("The maximum length of phone number is 15."); + return; + } + if(checkNumberFormat(number)) { + DialogUtil.openMessageDialog("This is invalid number. (" + number + ")"); + return; + } + } + char[] packet = new char[500]; int pid = 0; int dcs = 0xF0; @@ -349,8 +369,7 @@ ISelectionListener{ tpdu_deliver.sri = false; SmsAddressInfo orgAddr = new SmsAddressInfo(); - orgAddr.diallingNum = String.format( - cmbMobileTerminateOriginatingAddress.getText()).toCharArray(); + orgAddr.diallingNum = number.toCharArray(); orgAddr.dialnumlen = orgAddr.diallingNum.length; tpdu_deliver.orgAddr = orgAddr; @@ -390,6 +409,12 @@ ISelectionListener{ } } + private static boolean checkNumberFormat(String noStr) { + Pattern tellPattern = Pattern.compile( "[^0-9++]"); + Matcher matcher = tellPattern.matcher(noStr); + return matcher.find(); + } + private ArrayList getUserData(String message) { ArrayList list = new ArrayList(); int length = 60; //temp length