aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/googlecontacts
diff options
context:
space:
mode:
authorhristoterezov <hristo@jitsi.org>2014-01-08 14:38:13 +0200
committerhristoterezov <hristo@jitsi.org>2014-01-08 14:38:13 +0200
commit135354be48db43089821729032cd1e44d54fe199 (patch)
tree1432403a454273e594f10e2d8f6cd54427691e5f /src/net/java/sip/communicator/impl/googlecontacts
parent46888b088779c45c1b3e8aadb266e3b8b4e8bb51 (diff)
downloadjitsi-135354be48db43089821729032cd1e44d54fe199.zip
jitsi-135354be48db43089821729032cd1e44d54fe199.tar.gz
jitsi-135354be48db43089821729032cd1e44d54fe199.tar.bz2
Fixes issues with the async queries of the contact list which may cause
missing contacts.
Diffstat (limited to 'src/net/java/sip/communicator/impl/googlecontacts')
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java18
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java50
2 files changed, 39 insertions, 29 deletions
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java
index 4286a15..b653b95 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java
@@ -135,6 +135,24 @@ public class GoogleContactsQuery
});
}
+ @Override
+ public synchronized void start()
+ {
+ boolean hasStarted = false;
+
+ try
+ {
+ super.start();
+ hasStarted = true;
+ }
+ finally
+ {
+ if (!hasStarted)
+ {
+ getContactSource().removeQuery(this);
+ }
+ }
+ }
/**
* Gets the <tt>contactDetails</tt> to be set on a <tt>SourceContact</tt>.
*
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java
index b0f578c..723928a 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java
@@ -126,25 +126,25 @@ public class GoogleContactsSourceService
}
/**
- * Queries this search source for the given <tt>searchPattern</tt>.
+ * Creates query for the given <tt>searchPattern</tt>.
*
* @param queryPattern the pattern to search for
* @return the created query
*/
- public ContactQuery queryContactSource(Pattern queryPattern)
+ public ContactQuery createContactQuery(Pattern queryPattern)
{
- return queryContactSource(queryPattern,
+ return createContactQuery(queryPattern,
GoogleContactsQuery.GOOGLECONTACTS_MAX_RESULTS);
}
/**
- * Queries this search source for the given <tt>searchPattern</tt>.
+ * Creates query for the given <tt>searchPattern</tt>.
*
* @param queryPattern the pattern to search for
* @param count maximum number of contact returned
* @return the created query
*/
- public ContactQuery queryContactSource(Pattern queryPattern, int count)
+ public ContactQuery createContactQuery(Pattern queryPattern, int count)
{
GoogleContactsQuery query = new GoogleContactsQuery(this, queryPattern,
count);
@@ -154,29 +154,21 @@ public class GoogleContactsSourceService
queries.add(query);
}
- boolean hasStarted = false;
-
- try
- {
- query.start();
- hasStarted = true;
- }
- finally
- {
- if (!hasStarted)
- {
- synchronized (queries)
- {
- if (queries.remove(query))
- queries.notify();
- }
- }
- }
-
return query;
}
/**
+ * Removes query from the list of queries.
+ *
+ * @param query the query that will be removed.
+ */
+ public synchronized void removeQuery(ContactQuery query)
+ {
+ if (queries.remove(query))
+ queries.notify();
+ }
+
+ /**
* Returns the Google Contacts connection.
*
* @return Google Contacts connection
@@ -331,21 +323,21 @@ public class GoogleContactsSourceService
* @param query the string to search for
* @return the created query
*/
- public ContactQuery queryContactSource(String query)
+ public ContactQuery createContactQuery(String query)
{
- return queryContactSource(
+ return createContactQuery(
query,
GoogleContactsQuery.GOOGLECONTACTS_MAX_RESULTS);
}
/**
- * Queries this search source for the given <tt>queryString</tt>.
+ *Creates query for the given <tt>queryString</tt>.
*
* @param query the string to search for
* @param contactCount the maximum count of result contacts
* @return the created query
*/
- public ContactQuery queryContactSource(String query, int contactCount)
+ public ContactQuery createContactQuery(String query, int contactCount)
{
Pattern pattern = null;
try
@@ -360,7 +352,7 @@ public class GoogleContactsSourceService
if(pattern != null)
{
- return queryContactSource(pattern, contactCount);
+ return createContactQuery(pattern, contactCount);
}
return null;
}