aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/googlecontacts
diff options
context:
space:
mode:
authorVincent Lucas <chenzo@jitsi.org>2012-09-25 14:11:58 +0000
committerVincent Lucas <chenzo@jitsi.org>2012-09-25 14:11:58 +0000
commitb7acf89cd9da40c9c78f4564c1cd4c37304829ae (patch)
tree63d36c5cce2ac2e8933967e67c4647b8d8dd40c7 /src/net/java/sip/communicator/impl/googlecontacts
parent09cd4c6414659d8488c94f89dd4347a0c9670e53 (diff)
downloadjitsi-b7acf89cd9da40c9c78f4564c1cd4c37304829ae.zip
jitsi-b7acf89cd9da40c9c78f4564c1cd4c37304829ae.tar.gz
jitsi-b7acf89cd9da40c9c78f4564c1cd4c37304829ae.tar.bz2
Updates the PhoneNumberI18nServiceImpl, in order to remove the dependency to the libphonenumber.
Diffstat (limited to 'src/net/java/sip/communicator/impl/googlecontacts')
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java26
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java98
2 files changed, 3 insertions, 121 deletions
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java
index 45afa50..e061cba 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java
@@ -60,13 +60,6 @@ public class GoogleContactsActivator implements BundleActivator
private static ResourceManagementService resourceService;
/**
- * The cached reference to the <tt>PhoneNumberI18nService</tt> instance used
- * by the functionality of the Google Contacts plug-in and fetched from its
- * <tt>BundleContext</tt>.
- */
- private static PhoneNumberI18nService phoneNumberI18nService;
-
- /**
* Google contacts service.
*/
private static GoogleContactsServiceImpl googleContactsService;
@@ -78,25 +71,6 @@ public class GoogleContactsActivator implements BundleActivator
= new HashMap<GoogleContactsSourceService, ServiceRegistration>();
/**
- * Gets the <tt>PhoneNumberI18nService</tt> to be used by the functionality
- * of the addrbook plug-in.
- *
- * @return the <tt>PhoneNumberI18nService</tt> to be used by the
- * functionality of the addrbook plug-in
- */
- public static PhoneNumberI18nService getPhoneNumberI18nService()
- {
- if (phoneNumberI18nService == null)
- {
- phoneNumberI18nService
- = ServiceUtils.getService(
- bundleContext,
- PhoneNumberI18nService.class);
- }
- return phoneNumberI18nService;
- }
-
- /**
* Returns a reference to a ConfigurationService implementation currently
* registered in the bundle context or null if no such implementation was
* found.
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java
index ea319bb..5fa2b77 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java
@@ -55,98 +55,6 @@ public class GoogleContactsQuery
}
/**
- * Normalizes a <tt>String</tt> phone number by converting alpha characters
- * to their respective digits on a keypad and then stripping non-digit
- * characters.
- *
- * @param phoneNumber a <tt>String</tt> which represents a phone number to
- * normalize
- * @return a <tt>String</tt> which is a normalized form of the specified
- * <tt>phoneNumber</tt>
- */
- protected String normalizePhoneNumber(String phoneNumber)
- {
- PhoneNumberI18nService phoneNumberI18nService
- = GoogleContactsActivator.getPhoneNumberI18nService();
-
- return
- (phoneNumberI18nService == null)
- ? phoneNumber
- : phoneNumberI18nService.normalize(phoneNumber);
- }
-
- /**
- * Determines whether a specific <tt>String</tt> phone number matches the
- * {@link #query} of this <tt>AsyncContactQuery</tt>.
- *
- * @param phoneNumber the <tt>String</tt> which represents the phone number
- * to match to the <tt>query</tt> of this <tt>AsyncContactQuery</tt>
- * @return <tt>true</tt> if the specified <tt>phoneNumber</tt> matches the
- * <tt>query</tt> of this <tt>AsyncContactQuery</tt>; otherwise,
- * <tt>false</tt>
- */
- protected boolean phoneNumberMatches(String phoneNumber)
- {
- /*
- * PhoneNumberI18nService implements functionality to aid the parsing,
- * formatting and validation of international phone numbers so attempt to
- * use it to determine whether the specified phoneNumber matches the
- * query. For example, check whether the normalized phoneNumber matches
- * the query.
- */
-
- PhoneNumberI18nService phoneNumberI18nService
- = GoogleContactsActivator.getPhoneNumberI18nService();
- boolean phoneNumberMatches = false;
-
- if (phoneNumberI18nService != null)
- {
- if (query
- .matcher(phoneNumberI18nService.normalize(phoneNumber))
- .find())
- {
- phoneNumberMatches = true;
- }
- else
- {
- /*
- * The fact that the normalized form of the phoneNumber doesn't
- * match the query doesn't mean that, for example, it doesn't
- * match the normalized form of the query. The latter, though,
- * requires the query to look like a phone number as well. In
- * order to not accidentally start matching all queries to phone
- * numbers, it seems justified to normalize the query only when
- * it is a phone number, not whenever it looks like a piece of a
- * phone number.
- */
-
- String phoneNumberQuery = getPhoneNumberQuery();
-
- if ((phoneNumberQuery != null)
- && (phoneNumberQuery.length() != 0))
- {
- try
- {
- phoneNumberMatches
- = phoneNumberI18nService.phoneNumbersMatch(
- phoneNumberQuery,
- phoneNumber);
- }
- catch (IllegalArgumentException iaex)
- {
- /*
- * Ignore it, phoneNumberMatches will remain equal to
- * false.
- */
- }
- }
- }
- }
- return phoneNumberMatches;
- }
-
-
- /**
* Create a <tt>SourceContact</tt> from a <tt>GoogleContactsEntry</tt>.
*
* @param entry <tt>GoogleContactsEntry</tt>
@@ -264,7 +172,7 @@ public class GoogleContactsQuery
= new ArrayList<Class<? extends OperationSet>>(1);
supportedOpSets.add(OperationSetBasicTelephony.class);
- homePhone = normalizePhoneNumber(homePhone);
+ homePhone = PhoneNumberI18nService.normalize(homePhone);
detail = new ContactDetail(homePhone,
ContactDetail.CATEGORY_PHONE,
new String[]{ContactDetail.LABEL_HOME});
@@ -278,7 +186,7 @@ public class GoogleContactsQuery
= new ArrayList<Class<? extends OperationSet>>(1);
supportedOpSets.add(OperationSetBasicTelephony.class);
- workPhone = normalizePhoneNumber(workPhone);
+ workPhone = PhoneNumberI18nService.normalize(workPhone);
detail = new ContactDetail(workPhone,
ContactDetail.CATEGORY_PHONE,
new String[]{ContactDetail.LABEL_WORK});
@@ -292,7 +200,7 @@ public class GoogleContactsQuery
= new ArrayList<Class<? extends OperationSet>>(1);
supportedOpSets.add(OperationSetBasicTelephony.class);
- mobilePhone = normalizePhoneNumber(mobilePhone);
+ mobilePhone = PhoneNumberI18nService.normalize(mobilePhone);
detail = new ContactDetail(mobilePhone,
ContactDetail.CATEGORY_PHONE,
new String[]{ContactDetail.LABEL_MOBILE});