From cffa8dc40ca40fa9327bcc36559834c4f6d5306b Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Wed, 12 Jan 2011 15:06:08 +0000 Subject: [PATCH] Fires QUERY_COMPLETED or QUERY_ERROR at the end of the execution of the ContactQueries of the Address Books of Microsoft Outlook and Mac OS X. --- .../plugin/addrbook/AsyncContactQuery.java | 13 +++++++++++-- .../msoutlook/MsOutlookAddrBookContactQuery.java | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/net/java/sip/communicator/plugin/addrbook/AsyncContactQuery.java b/src/net/java/sip/communicator/plugin/addrbook/AsyncContactQuery.java index cdefd4322..2e851930f 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/AsyncContactQuery.java +++ b/src/net/java/sip/communicator/plugin/addrbook/AsyncContactQuery.java @@ -155,16 +155,19 @@ public synchronized void start() @Override public void run() { + boolean completed = false; + try { AsyncContactQuery.this.run(); + completed = true; } finally { synchronized (AsyncContactQuery.this) { if (thread == Thread.currentThread()) - stopped(); + stopped(completed); } } } @@ -179,8 +182,14 @@ public void run() /** * Notifies this AsyncContactQuery that it has stopped performing * in the associated background Thread. + * + * @param completed true if this ContactQuery has + * successfully completed, false if an error has been encountered + * during its execution */ - protected void stopped() + protected void stopped(boolean completed) { + if (getStatus() == QUERY_IN_PROGRESS) + setStatus(completed ? QUERY_COMPLETED : QUERY_ERROR); } } diff --git a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java index 179a58b72..b60ef698c 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java +++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java @@ -365,11 +365,21 @@ public boolean callback(long iUnknown) * Notifies this AsyncContactQuery that it has stopped performing * in the associated background Thread. * - * @see AsyncContactQuery#stopped() + * @param completed true if this ContactQuery has + * successfully completed, false if an error has been encountered + * during its execution + * @see AsyncContactQuery#stopped(boolean) */ @Override - protected void stopped() + protected void stopped(boolean completed) { - getContactSource().stopped(this); + try + { + super.stopped(completed); + } + finally + { + getContactSource().stopped(this); + } } }