diff options
author | Vincent Lucas <chenzo@jitsi.org> | 2013-07-10 00:52:34 +0200 |
---|---|---|
committer | Vincent Lucas <chenzo@jitsi.org> | 2013-07-10 00:52:34 +0200 |
commit | c995a7aa4026fc44606e72eef2461cce5563f8c4 (patch) | |
tree | 181c7199a312e4e4d31b50501bee1622fadbd3c1 | |
parent | 7b6b24ac11f6a3875d56064736cbcd1b6bc082ee (diff) | |
download | jitsi-c995a7aa4026fc44606e72eef2461cce5563f8c4.zip jitsi-c995a7aa4026fc44606e72eef2461cce5563f8c4.tar.gz jitsi-c995a7aa4026fc44606e72eef2461cce5563f8c4.tar.bz2 |
Removes extra debug for Outlook address book plugin. Adds a thread collector for Outlook notifications.
-rwxr-xr-x | lib/native/windows-64/jmsoutlookaddrbook.dll | bin | 222113 -> 221039 bytes | |||
-rwxr-xr-x | lib/native/windows-64/jmsoutlookaddrbookcomserver32.exe | bin | 217854 -> 216779 bytes | |||
-rwxr-xr-x | lib/native/windows-64/jmsoutlookaddrbookcomserver64.exe | bin | 226880 -> 225294 bytes | |||
-rwxr-xr-x | lib/native/windows/jmsoutlookaddrbook.dll | bin | 214251 -> 213176 bytes | |||
-rwxr-xr-x | lib/native/windows/jmsoutlookaddrbookcomserver32.exe | bin | 217854 -> 216779 bytes | |||
-rwxr-xr-x | lib/native/windows/jmsoutlookaddrbookcomserver64.exe | bin | 226880 -> 225294 bytes | |||
-rw-r--r-- | src/native/addrbook/msoutlook/MAPINotification.cxx | 22 | ||||
-rw-r--r-- | src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx | 75 | ||||
-rw-r--r-- | src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx | 3 | ||||
-rw-r--r-- | src/native/addrbook/msoutlook/com/server/Server.cxx | 3 | ||||
-rw-r--r-- | src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java | 29 | ||||
-rw-r--r-- | src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java | 224 |
12 files changed, 206 insertions, 150 deletions
diff --git a/lib/native/windows-64/jmsoutlookaddrbook.dll b/lib/native/windows-64/jmsoutlookaddrbook.dll Binary files differindex edea01e..5e4a82b 100755 --- a/lib/native/windows-64/jmsoutlookaddrbook.dll +++ b/lib/native/windows-64/jmsoutlookaddrbook.dll diff --git a/lib/native/windows-64/jmsoutlookaddrbookcomserver32.exe b/lib/native/windows-64/jmsoutlookaddrbookcomserver32.exe Binary files differindex c96b340..f7218e4 100755 --- a/lib/native/windows-64/jmsoutlookaddrbookcomserver32.exe +++ b/lib/native/windows-64/jmsoutlookaddrbookcomserver32.exe diff --git a/lib/native/windows-64/jmsoutlookaddrbookcomserver64.exe b/lib/native/windows-64/jmsoutlookaddrbookcomserver64.exe Binary files differindex 589475e..2d88099 100755 --- a/lib/native/windows-64/jmsoutlookaddrbookcomserver64.exe +++ b/lib/native/windows-64/jmsoutlookaddrbookcomserver64.exe diff --git a/lib/native/windows/jmsoutlookaddrbook.dll b/lib/native/windows/jmsoutlookaddrbook.dll Binary files differindex ce68678..6185e17 100755 --- a/lib/native/windows/jmsoutlookaddrbook.dll +++ b/lib/native/windows/jmsoutlookaddrbook.dll diff --git a/lib/native/windows/jmsoutlookaddrbookcomserver32.exe b/lib/native/windows/jmsoutlookaddrbookcomserver32.exe Binary files differindex f1be037..7a841ad 100755 --- a/lib/native/windows/jmsoutlookaddrbookcomserver32.exe +++ b/lib/native/windows/jmsoutlookaddrbookcomserver32.exe diff --git a/lib/native/windows/jmsoutlookaddrbookcomserver64.exe b/lib/native/windows/jmsoutlookaddrbookcomserver64.exe Binary files differindex 54e9a7e..e2a70a5 100755 --- a/lib/native/windows/jmsoutlookaddrbookcomserver64.exe +++ b/lib/native/windows/jmsoutlookaddrbookcomserver64.exe diff --git a/src/native/addrbook/msoutlook/MAPINotification.cxx b/src/native/addrbook/msoutlook/MAPINotification.cxx index a06455d..bdbfccf 100644 --- a/src/native/addrbook/msoutlook/MAPINotification.cxx +++ b/src/native/addrbook/msoutlook/MAPINotification.cxx @@ -126,9 +126,6 @@ void MAPINotification_jniCallDeletedMethod(LPSTR iUnknown) if(MAPINotification_VM ->AttachCurrentThreadAsDaemon((void**) &tmpJniEnv, NULL) == 0) { - fprintf(stdout, "MAPINotification_jniCallDeletedMethod: id: %s\n", - iUnknown); - fflush(stdout); jstring value = tmpJniEnv->NewStringUTF(iUnknown); tmpJniEnv->CallVoidMethod( @@ -262,10 +259,6 @@ STDAPICALLTYPE MAPINotification_onNotify (LPBYTE) lpNotifications[i].info.obj.lpOldID, lpNotifications[i].info.obj.cbOldID, oldEntryIdStr); - fprintf(stdout, - "MAPINotification_onNotify: evModified oldID: %s\n", - oldEntryIdStr); - fflush(stdout); if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE && MAPINotification_callDeletedMethod != NULL) { @@ -289,10 +282,6 @@ STDAPICALLTYPE MAPINotification_onNotify lpNotifications[i].info.obj.cbEntryID, entryIdStr); - fprintf(stdout, "MAPINotification_onNotify: evDeleted: %s\n", - entryIdStr); - fflush(stdout); - if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE && MAPINotification_callDeletedMethod != NULL) { @@ -335,13 +324,6 @@ STDAPICALLTYPE MAPINotification_onNotify wasteBasketProps[0].Value.bin.cb, wasteBasketEntryIdStr); - fprintf(stdout, - "MAPINotification_onNotify: evMoved: bin %s / %s / %s\n", - entryIdStr, - parentEntryIdStr, - wasteBasketEntryIdStr); - fflush(stdout); - if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE && strcmp(parentEntryIdStr, wasteBasketEntryIdStr) == 0 && MAPINotification_callDeletedMethod != NULL) @@ -368,10 +350,6 @@ STDAPICALLTYPE MAPINotification_onNotify (LPBYTE) lpNotifications[i].info.obj.lpOldID, lpNotifications[i].info.obj.cbOldID, oldEntryIdStr); - fprintf(stdout, - "MAPINotification_onNotify: evMoved oldID: %s\n", - oldEntryIdStr); - fflush(stdout); if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE && MAPINotification_callDeletedMethod != NULL) { diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx index 378ee0e..b3e4b27 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx @@ -67,9 +67,6 @@ static jboolean MsOutlookAddrBookContactQuery_foreachContactInMsgStoresTable static jboolean MsOutlookAddrBookContactQuery_foreachMailUser (ULONG objType, LPUNKNOWN iUnknown, const char * query, void * callback, void * callbackObject); -static jboolean MsOutlookAddrBookContactQuery_foreachMailUserInAddressBook - (LPMAPISESSION mapiSession, const char * query, - void * callback, void * callbackObject); static jboolean MsOutlookAddrBookContactQuery_foreachMailUserInContainerTable (LPMAPICONTAINER mapiContainer, LPMAPITABLE mapiTable, const char * query, void * callback, void * callbackObject); @@ -397,21 +394,11 @@ void MsOutlookAddrBookContactQuery_foreachMailUser( return; } - jboolean proceed - = MsOutlookAddrBookContactQuery_foreachContactInMsgStoresTable( - mapiSession, - query, - callback, - callbackObject); - - if(proceed) - { - MsOutlookAddrBookContactQuery_foreachMailUserInAddressBook( - mapiSession, - query, - callback, - callbackObject); - } + MsOutlookAddrBookContactQuery_foreachContactInMsgStoresTable( + mapiSession, + query, + callback, + callbackObject); MAPISession_unlock(); } @@ -509,45 +496,6 @@ MsOutlookAddrBookContactQuery_foreachMailUser } static jboolean -MsOutlookAddrBookContactQuery_foreachMailUserInAddressBook - (LPMAPISESSION mapiSession, const char * query, - void * callback, void * callbackObject) -{ - HRESULT hResult; - LPADRBOOK adrBook; - jboolean proceed = JNI_FALSE; - - hResult = mapiSession->OpenAddressBook(0, NULL, AB_NO_DIALOG, &adrBook); - if (HR_SUCCEEDED(hResult)) - { - ULONG objType; - LPUNKNOWN iUnknown; - - hResult = adrBook->OpenEntry( - 0, - NULL, - NULL, - MsOutlookAddrBookContactQuery_openEntryUlFlags, - &objType, - &iUnknown); - - if (HR_SUCCEEDED(hResult)) - { - proceed - = MsOutlookAddrBookContactQuery_foreachMailUser( - objType, iUnknown, - query, callback, callbackObject); - - iUnknown->Release(); - } - - adrBook->Release(); - } - - return proceed; -} - -static jboolean MsOutlookAddrBookContactQuery_foreachMailUserInContainerTable (LPMAPICONTAINER mapiContainer, LPMAPITABLE mapiTable, const char * query, void * callback, void * callbackObject) @@ -1937,19 +1885,6 @@ int MsOutlookAddrBookContactQuery_compareEntryIds( } result = res; } - - if(strcmp(id1, id2) == 0) - { - fprintf(stderr, - "CHENZO compareEntryIds: \ - \n\tid1: %s\ - \n\tid2: %s\ - \n\tresult: %d\n", - id1, - id2, - result); - fflush(stderr); - } mapiId1->Release(); MAPIFreeBuffer(contactId1.lpb); mapiId2->Release(); diff --git a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx index 03f0b49..8ae23fb 100644 --- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx +++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx @@ -124,9 +124,6 @@ HRESULT STDMETHODCALLTYPE MsOutlookAddrBookClient::foreachMailUserCallback( HRESULT STDMETHODCALLTYPE MsOutlookAddrBookClient::deleted(BSTR id) { char * charId = StringUtils::WideCharToMultiByte(id); - fprintf(stdout, "MsOutlookAddrBookClient_deleted: id: %s\n", - charId); - fflush(stdout); MAPINotification_jniCallDeletedMethod(charId); free(charId); diff --git a/src/native/addrbook/msoutlook/com/server/Server.cxx b/src/native/addrbook/msoutlook/com/server/Server.cxx index 6ffb503..841c96e 100644 --- a/src/native/addrbook/msoutlook/com/server/Server.cxx +++ b/src/native/addrbook/msoutlook/com/server/Server.cxx @@ -130,9 +130,6 @@ void waitParentProcessStop() static void Server_deleted(LPSTR id) { HRESULT hr = E_FAIL; - fprintf(stdout, "Server_deleted: id: %s\n", - id); - fflush(stdout); IMsOutlookAddrBookClient * msOutlookAddrBookClient = NULL; if((hr = CoCreateInstance( 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 e5c7beb..670e86b 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java +++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java @@ -381,10 +381,6 @@ public class MsOutlookAddrBookContactQuery Pattern query) { super(msoabcss, query); - if(logger.isDebugEnabled()) - { - logger.debug("Creating new query: " + query.toString()); - } } /** @@ -883,11 +879,6 @@ public class MsOutlookAddrBookContactQuery if (matches) { - if(logger.isDebugEnabled()) - { - logger.debug("Contact matches: " + id - + ", displayName: " + getDisplayName(props)); - } List<ContactDetail> contactDetails = getContactDetails(props); // What's the point of showing a contact who has no contact details? @@ -1004,10 +995,6 @@ public class MsOutlookAddrBookContactQuery @Override protected void run() { - if(logger.isDebugEnabled()) - { - logger.debug("run query: " + query.toString()); - } synchronized (MsOutlookAddrBookContactQuery.class) { foreachMailUser( @@ -1023,10 +1010,6 @@ public class MsOutlookAddrBookContactQuery */ public void inserted(String id) { - if(logger.isDebugEnabled()) - { - logger.debug("inserted: " + id); - } SourceContact sourceContact = findSourceContactByID(id); if(sourceContact != null && sourceContact instanceof MsOutlookAddrBookSourceContact) @@ -1059,10 +1042,6 @@ public class MsOutlookAddrBookContactQuery */ public void updated(String id) { - if(logger.isDebugEnabled()) - { - logger.debug("updated: " + id); - } SourceContact sourceContact = findSourceContactByID(id); if(sourceContact != null && sourceContact instanceof MsOutlookAddrBookSourceContact) @@ -1083,10 +1062,6 @@ public class MsOutlookAddrBookContactQuery */ public void deleted(String id) { - if(logger.isDebugEnabled()) - { - logger.debug("deleted: " + id); - } if(id != null) { SourceContact sourceContact = findSourceContactByID(id); @@ -1139,10 +1114,6 @@ public class MsOutlookAddrBookContactQuery */ public void addEmptyContact(String id) { - if(logger.isDebugEnabled()) - { - logger.debug("Add empty contact: " + id); - } if(id != null) { final MsOutlookAddrBookSourceContact sourceContact diff --git a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java index bb9822e..59bbcb8 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java +++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java @@ -6,6 +6,7 @@ */ package net.java.sip.communicator.plugin.addrbook.msoutlook; +import java.util.*; import java.util.regex.*; import net.java.sip.communicator.plugin.addrbook.*; @@ -52,6 +53,16 @@ public class MsOutlookAddrBookContactSourceService private static final long MAPI_MULTITHREAD_NOTIFICATIONS = 0x00000001; /** + * The thread used to collect the notifications. + */ + private NotificationThread notificationThread = null; + + /** + * The mutex used to synchronized the notification thread. + */ + private Object notificationThreadMutex = new Object(); + + /** * The latest query created. */ private MsOutlookAddrBookContactQuery latestQuery = null; @@ -209,12 +220,8 @@ public class MsOutlookAddrBookContactSourceService */ public void inserted(String id) { - if(logger.isDebugEnabled()) - { - logger.debug("Inserted: " + id); - } if(latestQuery != null) - latestQuery.inserted(id); + addNotification(id, 'i'); } /** @@ -222,12 +229,8 @@ public class MsOutlookAddrBookContactSourceService */ public void updated(String id) { - if(logger.isDebugEnabled()) - { - logger.debug("Updated: " + id); - } if(latestQuery != null) - latestQuery.updated(id); + addNotification(id, 'u'); } /** @@ -235,12 +238,8 @@ public class MsOutlookAddrBookContactSourceService */ public void deleted(String id) { - if(logger.isDebugEnabled()) - { - logger.debug("Deleted: " + id); - } if(latestQuery != null) - latestQuery.deleted(id); + addNotification(id, 'd'); } } @@ -263,10 +262,6 @@ public class MsOutlookAddrBookContactSourceService */ public void addEmptyContact(String id) { - if(logger.isDebugEnabled()) - { - logger.debug("Add empty contact: " + id); - } if(id != null && latestQuery != null) { latestQuery.addEmptyContact(id); @@ -281,10 +276,6 @@ public class MsOutlookAddrBookContactSourceService */ public void deleteContact(String id) { - if(logger.isDebugEnabled()) - { - logger.debug("Delete contact: " + id); - } if(id != null && MsOutlookAddrBookContactQuery.deleteContact(id)) { if(latestQuery != null) @@ -309,4 +300,191 @@ public class MsOutlookAddrBookContactSourceService return !AddrBookActivator.getConfigService().getBoolean( PNAME_OUTLOOK_ADDR_BOOK_SEARCH_FIELD_DISABLED, false); } + + /** + * Collects a new notification and adds it to the notification thread. + * + * @param id The contact id. + * @param function The kind of notification: 'd' for deleted, 'u' for + * updated and 'i' for inserted. + */ + public void addNotification(String id, char function) + { + synchronized(notificationThreadMutex) + { + if(notificationThread == null + || !notificationThread.isAlive()) + { + notificationThread = new NotificationThread(); + notificationThread.start(); + } + notificationThread.add(id, function); + } + } + + /** + * Thread used to collect the notification. + */ + private class NotificationThread + extends Thread + { + + /** + * The list of notification collected. + */ + private Vector<NotificationIdFunction> contactIds + = new Vector<NotificationIdFunction>(); + + /** + * Initializes a new notification thread. + */ + public NotificationThread() + { + super("MsOutlookAddrbookContactSourceService notification thread"); + } + + /** + * Dispatchs the collected notifications. + */ + public void run() + { + boolean hasMore = false; + NotificationIdFunction idFunction = null; + String id; + char function; + + synchronized(notificationThreadMutex) + { + hasMore = (contactIds.size() > 0); + if(hasMore) + { + idFunction = contactIds.remove(0); + } + } + while(hasMore) + { + if(latestQuery != null) + { + id = idFunction.getId(); + function = idFunction.getFunction(); + if(function == 'd') + { + latestQuery.deleted(id); + } + else if(function == 'u') + { + latestQuery.updated(id); + } + else if(function == 'i') + { + latestQuery.inserted(id); + } + } + synchronized(notificationThreadMutex) + { + hasMore = (contactIds.size() > 0); + if(hasMore) + { + idFunction = contactIds.remove(0); + } + } + } + } + + /** + * Adds a new notification. Avoids previous notification for the given + * contact. + * + * @param id The contact id. + * @param function The kind of notification: 'd' for deleted, 'u' for + * updated and 'i' for inserted. + */ + public void add(String id, char function) + { + NotificationIdFunction idFunction + = new NotificationIdFunction(id, function); + + synchronized(notificationThreadMutex) + { + contactIds.remove(idFunction); + contactIds.add(idFunction); + } + } + } + + /** + * Defines a notification: a combination of a contact identifier and a + * function. + */ + private class NotificationIdFunction + { + /** + * The contact identifier. + */ + private String id; + + /** + * The kind of notification: 'd' for deleted, 'u' for updated and 'i' + * for inserted. + */ + private char function; + + /** + * Creates a new notification. + * + * @param id The contact id. + * @param function The kind of notification: 'd' for deleted, 'u' for + * updated and 'i' for inserted. + */ + public NotificationIdFunction(String id, char function) + { + this.id = id; + this.function = function; + } + + /** + * Returns the contact identifier. + * + * @return The contact identifier. + */ + public String getId() + { + return this.id; + } + + /** + * Returns the kind of notification. + * + * @return 'd' for deleted, 'u' for updated and 'i' for inserted. + */ + public char getFunction() + { + return this.function; + } + + /** + * Returns if this notification is about the same contact has the one + * given in parameter. + * + * @param obj An NotificationIdFunction to compare with. + * + * @return True if this notification is about the same contact has the + * one given in parameter. False otherwise. + */ + public boolean equals(Object obj) + { + return (this.id == null && obj == null + || obj instanceof String && this.id.equals((String) obj)); + } + + /** + * Returns the hash code corresponding to the contact identifier. + * + * @return The hash code corresponding to the contact identifier. + */ + public int hashCode() + { + return this.id.hashCode(); + } + } } |