From 7a196cf51a94abc568b33e89c27283335a35ab7f Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Fri, 21 Sep 2012 12:48:08 +0000 Subject: [PATCH] Strips space characters from the contact addresses/phone numbers (typed into the user interface). --- .../impl/gui/main/call/CallManager.java | 89 ++++++++++--------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java index b78ec32e4..b99e974d9 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java @@ -38,6 +38,7 @@ * outgoing calls from and to the call operation set. * * @author Yana Stamcheva + * @author Lyubomir Marinov */ public class CallManager { @@ -777,13 +778,7 @@ public static void createCall( String callString, // Removes special characters from phone numbers. if (ConfigurationManager.isNormalizePhoneNumber()) - { - String normalizedContact[] = new String[1]; - normalizedContact[0] = callString; - - normalizePhoneNumbers(normalizedContact); - callString = normalizedContact[0]; - } + callString = normalizePhoneNumber(callString); List telephonyProviders = CallManager.getTelephonyProviders(); @@ -1495,13 +1490,7 @@ else if(stringContact != null) callString = stringContact; if(ConfigurationManager.isNormalizePhoneNumber()) - { - String normalizedContact[] = new String[1]; - - normalizedContact[0] = callString; - normalizePhoneNumbers(normalizedContact); - callString = normalizedContact[0]; - } + callString = normalizePhoneNumber(callString); try { @@ -1899,9 +1888,7 @@ public void run() return; if (ConfigurationManager.isNormalizePhoneNumber()) - { normalizePhoneNumbers(callees); - } for (String callee : callees) { @@ -2090,9 +2077,7 @@ public void run() contacts.toArray(contactAddressStrings); if (ConfigurationManager.isNormalizePhoneNumber()) - { normalizePhoneNumbers(contactAddressStrings); - } try { @@ -2493,32 +2478,56 @@ private static boolean showDesktopSharingWarning() } /** - * Normalizes the phone numbers (if any) in a list of Strings. + * Normalizes a String contact address or phone number for the + * purposes of establishing a Call. + * + * @param callee the String contact address or phone number to be + * normalized for the purposes of establishing a Call + * @return the normalized form of the specified callee appropriate + * for establishing a Call + */ + private static String normalizePhoneNumber(String callee) + { + return + normalizePhoneNumber(callee, GuiActivator.getPhoneNumberService()); + } + + /** + * Normalizes a String contact address or phone number for the + * purposes of establishing a Call. + * + * @param addr the String contact address or phone number to be + * normalized for the purposes of establishing a Call + * @param phoneNumberService the PhoneNumberI18nService to perform + * the normalization if the specified addr is recognized as a + * phone number + * @return the normalized form of the specified addr appropriate + * for establishing a Call + */ + private static String normalizePhoneNumber( + String addr, + PhoneNumberI18nService phoneNumberService) + { + addr = StringUtils.concatenateWords(addr); + if (!StringUtils.containsLetters(addr) + && phoneNumberService.isPhoneNumber(addr)) + addr = phoneNumberService.normalize(addr); + return addr; + } + + /** + * Normalizes the phone numbers (if any) in a list of String + * contact addresses or phone numbers. * - * @param callees list of contact addresses or phone numbers + * @param callees the list of contact addresses or phone numbers to be + * normalized */ private static void normalizePhoneNumbers(String callees[]) { - PhoneNumberI18nService phoneNumberService = - GuiActivator.getPhoneNumberService(); - - for(int i = 0 ; i < callees.length ; i++) - { - if (!StringUtils.containsLetters(callees[i]) && - GuiActivator.getPhoneNumberService().isPhoneNumber(callees[i])) - { - String addr = callees[i]; - if(phoneNumberService.isPhoneNumber(addr)) - { - addr = phoneNumberService.normalize(addr); - } - else - { - addr = StringUtils.concatenateWords(callees[i]); - } + PhoneNumberI18nService phoneNumberService + = GuiActivator.getPhoneNumberService(); - callees[i] = addr; - } - } + for (int i = 0 ; i < callees.length ; i++) + callees[i] = normalizePhoneNumber(callees[i], phoneNumberService); } }