diff options
Diffstat (limited to 'src')
18 files changed, 179 insertions, 128 deletions
diff --git a/src/native/addrbook/msoutlook/MAPINotification.cxx b/src/native/addrbook/msoutlook/MAPINotification.cxx index bdbfccf..d2f2422 100644 --- a/src/native/addrbook/msoutlook/MAPINotification.cxx +++ b/src/native/addrbook/msoutlook/MAPINotification.cxx @@ -68,9 +68,9 @@ LONG STDAPICALLTYPE MAPINotification_tableChanged * @return True everything works fine and that we must continue to list the * other contacts. False otherwise. */ -boolean MAPINotification_callCallbackMethod(LPSTR iUnknown, void * object) +boolean MAPINotification_callCallbackMethod(LPSTR iUnknown, long objectAddr) { - if(object == NULL) + if(objectAddr <= 0) { MAPINotification_jniCallInsertedMethod(iUnknown); return true; @@ -82,9 +82,10 @@ boolean MAPINotification_callCallbackMethod(LPSTR iUnknown, void * object) if(MAPINotification_VM ->AttachCurrentThreadAsDaemon((void**) &tmpJniEnv, NULL) == 0) { - if(object != NULL) + if(objectAddr > 0) { - jclass callbackClass = tmpJniEnv->GetObjectClass((jobject) object); + jobject object = (jobject)(intptr_t)objectAddr; + jclass callbackClass = tmpJniEnv->GetObjectClass(object); if(callbackClass) { jmethodID ptrOutlookContactCallbackMethodIdCallback @@ -99,7 +100,7 @@ boolean MAPINotification_callCallbackMethod(LPSTR iUnknown, void * object) // Report the MAPI_MAILUSER to the callback. proceed = tmpJniEnv->CallBooleanMethod( - (jobject) object, + object, ptrOutlookContactCallbackMethodIdCallback, value); } diff --git a/src/native/addrbook/msoutlook/MAPINotification.h b/src/native/addrbook/msoutlook/MAPINotification.h index f2a81fc..f1517d7 100644 --- a/src/native/addrbook/msoutlook/MAPINotification.h +++ b/src/native/addrbook/msoutlook/MAPINotification.h @@ -23,7 +23,7 @@ extern "C" { * @author Vincent Lucas */ -boolean MAPINotification_callCallbackMethod(LPSTR iUnknown, void * object); +boolean MAPINotification_callCallbackMethod(LPSTR iUnknown, long objectAddr); void MAPINotification_jniCallDeletedMethod(LPSTR iUnknown); void MAPINotification_jniCallInsertedMethod(LPSTR iUnknown); diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx index f37cdf4..d24b305 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx @@ -47,7 +47,10 @@ typedef jboolean (*MsOutlookAddrBookContactQuery_ForeachRowInTableCallback) (LPUNKNOWN iUnknown, ULONG entryIDByteCount, LPENTRYID entryID, ULONG objType, - const char * query, void * callback, void * callbackObject); + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress); static ULONG MsOutlookAddrBookContactQuery_rdOpenEntryUlFlags = 0x0; static ULONG MsOutlookAddrBookContactQuery_rwOpenEntryUlFlags @@ -65,18 +68,27 @@ HRESULT MsOutlookAddrBookContactQuery_createEmailAddress LONG providerArrayType, ULONG propIds[], int nbPropId); static jboolean MsOutlookAddrBookContactQuery_foreachContactInMsgStoresTable (LPMAPISESSION mapiSession, const char * query, - void * callback, void * callbackObject); + void * callbackMethod, void * callbackClient, long callbackAddress); static jboolean MsOutlookAddrBookContactQuery_foreachMailUser (ULONG objType, LPUNKNOWN iUnknown, - const char * query, void * callback, void * callbackObject); + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress); static jboolean MsOutlookAddrBookContactQuery_foreachMailUserInContainerTable (LPMAPICONTAINER mapiContainer, LPMAPITABLE mapiTable, - const char * query, void * callback, void * callbackObject); + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress); static jboolean MsOutlookAddrBookContactQuery_foreachRowInTable (LPMAPITABLE mapiTable, MsOutlookAddrBookContactQuery_ForeachRowInTableCallback rowCallback, LPUNKNOWN iUnknown, - const char * query, void * callback, void * callbackObject); + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress); static void MsOutlookAddrBookContactQuery_freeSRowSet(LPSRowSet rows); static void* MsOutlookAddrBookContactQuery_getAttachmentContactPhoto (LPMESSAGE message, ULONGLONG * length); @@ -100,11 +112,17 @@ static jboolean MsOutlookAddrBookContactQuery_mailUserMatches static jboolean MsOutlookAddrBookContactQuery_onForeachContactInMsgStoresTableRow (LPUNKNOWN mapiSession, ULONG entryIDByteCount, LPENTRYID entryID, ULONG objType, - const char * query, void * callback, void * callbackObject); + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress); static jboolean MsOutlookAddrBookContactQuery_onForeachMailUserInContainerTableRow (LPUNKNOWN mapiContainer, ULONG entryIDByteCount, LPENTRYID entryID, ULONG objType, - const char * query, void * callback, void * callbackObject); + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress); LPUNKNOWN MsOutlookAddrBookContactQuery_openEntryId (ULONG entryIdSize, LPENTRYID entryId, ULONG flags); LPUNKNOWN MsOutlookAddrBookContactQuery_openEntryIdStr @@ -395,30 +413,40 @@ int MsOutlookAddrBookContactQuery_deleteContact(const char * nativeEntryId) return res; } -void MsOutlookAddrBookContactQuery_foreachMailUser( - const char * query, void * callback, void * callbackObject) +HRESULT MsOutlookAddrBookContactQuery_foreachMailUser( + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress) { MAPISession_lock(); LPMAPISESSION mapiSession = MAPISession_getMapiSession(); if (!mapiSession) { MAPISession_unlock(); - return; + return E_ABORT; } - MsOutlookAddrBookContactQuery_foreachContactInMsgStoresTable( + boolean proceed = + MsOutlookAddrBookContactQuery_foreachContactInMsgStoresTable( mapiSession, query, - callback, - callbackObject); + callbackMethod, + callbackClient, + callbackAddress); MAPISession_unlock(); + + return proceed ? S_OK : E_ABORT; } static jboolean MsOutlookAddrBookContactQuery_foreachContactInMsgStoresTable (LPMAPISESSION mapiSession, - const char * query, void * callback, void * callbackObject) + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress) { HRESULT hResult; LPMAPITABLE msgStoresTable = NULL; @@ -432,7 +460,10 @@ MsOutlookAddrBookContactQuery_foreachContactInMsgStoresTable msgStoresTable, MsOutlookAddrBookContactQuery_onForeachContactInMsgStoresTableRow, (LPUNKNOWN) mapiSession, - query, callback, callbackObject); + query, + callbackMethod, + callbackClient, + callbackAddress); msgStoresTable->Release(); } @@ -442,7 +473,10 @@ MsOutlookAddrBookContactQuery_foreachContactInMsgStoresTable static jboolean MsOutlookAddrBookContactQuery_foreachMailUser (ULONG objType, LPUNKNOWN iUnknown, - const char * query, void * callback, void * callbackObject) + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress) { jboolean proceed = JNI_TRUE; @@ -464,7 +498,10 @@ MsOutlookAddrBookContactQuery_foreachMailUser proceed = MsOutlookAddrBookContactQuery_foreachMailUserInContainerTable( mapiContainer, mapiTable, - query, callback, callbackObject); + query, + callbackMethod, + callbackClient, + callbackAddress); mapiTable->Release(); } @@ -478,7 +515,10 @@ MsOutlookAddrBookContactQuery_foreachMailUser proceed = MsOutlookAddrBookContactQuery_foreachMailUserInContainerTable( mapiContainer, mapiTable, - query, callback, callbackObject); + query, + callbackMethod, + callbackClient, + callbackAddress); mapiTable->Release(); } } @@ -495,8 +535,9 @@ MsOutlookAddrBookContactQuery_foreachMailUser LPSTR contactId = MsOutlookAddrBookContactQuery_getContactId( (LPMAPIPROP) iUnknown); - boolean(*cb)(LPSTR, void*) = (boolean(*)(LPSTR, void*)) callback; - proceed = cb(contactId, callbackObject); + boolean(*cb)(LPSTR, void *, long) + = (boolean(*)(LPSTR, void *, long)) callbackMethod; + proceed = cb(contactId, callbackClient, callbackAddress); ::free(contactId); contactId = NULL; @@ -510,14 +551,20 @@ MsOutlookAddrBookContactQuery_foreachMailUser static jboolean MsOutlookAddrBookContactQuery_foreachMailUserInContainerTable (LPMAPICONTAINER mapiContainer, LPMAPITABLE mapiTable, - const char * query, void * callback, void * callbackObject) + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress) { return MsOutlookAddrBookContactQuery_foreachRowInTable( mapiTable, MsOutlookAddrBookContactQuery_onForeachMailUserInContainerTableRow, (LPUNKNOWN) mapiContainer, - query, callback, callbackObject); + query, + callbackMethod, + callbackClient, + callbackAddress); } static jboolean @@ -525,7 +572,10 @@ MsOutlookAddrBookContactQuery_foreachRowInTable (LPMAPITABLE mapiTable, MsOutlookAddrBookContactQuery_ForeachRowInTableCallback rowCallback, LPUNKNOWN iUnknown, - const char * query, void * callback, void * callbackObject) + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress) { HRESULT hResult; // In case, that we have failed but other parts of the hierarchy may still @@ -590,7 +640,10 @@ MsOutlookAddrBookContactQuery_foreachRowInTable = rowCallback( iUnknown, entryIDBinary.cb, entryID, objType, - query, callback, callbackObject); + query, + callbackMethod, + callbackClient, + callbackAddress); MAPIFreeBuffer(entryID); } @@ -1558,7 +1611,10 @@ static jboolean MsOutlookAddrBookContactQuery_onForeachContactInMsgStoresTableRow (LPUNKNOWN mapiSession, ULONG entryIDByteCount, LPENTRYID entryID, ULONG objType, - const char * query, void * callback, void * callbackObject) + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress) { HRESULT hResult; LPMDB msgStore; @@ -1623,8 +1679,9 @@ MsOutlookAddrBookContactQuery_onForeachContactInMsgStoresTableRow contactsFolderObjType, contactsFolder, query, - callback, - callbackObject); + callbackMethod, + callbackClient, + callbackAddress); contactsFolder->Release(); } MAPIFreeBuffer(contactsFolderEntryID); @@ -1639,7 +1696,10 @@ static jboolean MsOutlookAddrBookContactQuery_onForeachMailUserInContainerTableRow (LPUNKNOWN mapiContainer, ULONG entryIDByteCount, LPENTRYID entryID, ULONG objType, - const char * query, void * callback, void * callbackObject) + const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress) { HRESULT hResult; LPUNKNOWN iUnknown; @@ -1659,8 +1719,9 @@ MsOutlookAddrBookContactQuery_onForeachMailUserInContainerTableRow objType, iUnknown, query, - callback, - callbackObject); + callbackMethod, + callbackClient, + callbackAddress); iUnknown->Release(); } else diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.h b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.h index cdc36d5..99fd749 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.h +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.h @@ -28,8 +28,11 @@ char* MsOutlookAddrBookContactQuery_createContact(void); int MsOutlookAddrBookContactQuery_deleteContact(const char * nativeEntryId); -void MsOutlookAddrBookContactQuery_foreachMailUser - (const char * query, void * callback, void * callbackObject); +HRESULT MsOutlookAddrBookContactQuery_foreachMailUser + (const char * query, + void * callbackMethod, + void * callbackClient, + long callbackAddress); char* MsOutlookAddrBookContactQuery_getStringUnicodeProp (LPUNKNOWN entry, ULONG propId); diff --git a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.h b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.h index b8eed7e..4337015 100644 --- a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.h +++ b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.h @@ -3,11 +3,11 @@ /* this ALWAYS GENERATED file contains the definitions for the interfaces */ - /* File created by MIDL compiler version 8.00.0595 */ -/* at Tue May 07 03:41:40 2013 + /* File created by MIDL compiler version 8.00.0603 */ +/* at Mon Mar 24 09:03:06 2014 */ /* Compiler settings for IMsOutlookAddrBookClient.idl: - Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0595 + Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0603 protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: @@ -84,7 +84,8 @@ EXTERN_C const IID IID_IMsOutlookAddrBookClient; { public: virtual HRESULT STDMETHODCALLTYPE foreachMailUserCallback( - /* [in] */ BSTR id) = 0; + /* [in] */ BSTR id, + /* [in] */ long callback) = 0; virtual HRESULT STDMETHODCALLTYPE deleted( /* [in] */ BSTR id) = 0; @@ -118,7 +119,8 @@ EXTERN_C const IID IID_IMsOutlookAddrBookClient; HRESULT ( STDMETHODCALLTYPE *foreachMailUserCallback )( IMsOutlookAddrBookClient * This, - /* [in] */ BSTR id); + /* [in] */ BSTR id, + /* [in] */ long callback); HRESULT ( STDMETHODCALLTYPE *deleted )( IMsOutlookAddrBookClient * This, @@ -155,8 +157,8 @@ EXTERN_C const IID IID_IMsOutlookAddrBookClient; ( (This)->lpVtbl -> Release(This) ) -#define IMsOutlookAddrBookClient_foreachMailUserCallback(This,id) \ - ( (This)->lpVtbl -> foreachMailUserCallback(This,id) ) +#define IMsOutlookAddrBookClient_foreachMailUserCallback(This,id,callback) \ + ( (This)->lpVtbl -> foreachMailUserCallback(This,id,callback) ) #define IMsOutlookAddrBookClient_deleted(This,id) \ ( (This)->lpVtbl -> deleted(This,id) ) diff --git a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.idl b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.idl index bf3450b..6e1fad5 100644 --- a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.idl +++ b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.idl @@ -10,7 +10,8 @@ import "Unknwn.idl", "oaidl.idl"; interface IMsOutlookAddrBookClient : IUnknown { HRESULT foreachMailUserCallback( - [in] BSTR id); + [in] BSTR id, + [in] long callback); HRESULT deleted( [in] BSTR id); diff --git a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.tlb b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.tlb Binary files differindex 716c3aa..168d9ad 100644 --- a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.tlb +++ b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.tlb diff --git a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.h b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.h index 0cf23fa..aee8983 100644 --- a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.h +++ b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.h @@ -3,11 +3,11 @@ /* this ALWAYS GENERATED file contains the definitions for the interfaces */ - /* File created by MIDL compiler version 8.00.0595 */ -/* at Wed Jun 19 15:47:56 2013 + /* File created by MIDL compiler version 8.00.0603 */ +/* at Mon Mar 24 09:03:14 2014 */ /* Compiler settings for IMsOutlookAddrBookServer.idl: - Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0595 + Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0603 protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: @@ -84,7 +84,8 @@ EXTERN_C const IID IID_IMsOutlookAddrBookServer; { public: virtual HRESULT STDMETHODCALLTYPE foreachMailUser( - /* [in] */ BSTR query) = 0; + /* [in] */ BSTR query, + /* [in] */ long callback) = 0; virtual HRESULT STDMETHODCALLTYPE IMAPIProp_GetProps( /* [in] */ BSTR entryId, @@ -138,7 +139,8 @@ EXTERN_C const IID IID_IMsOutlookAddrBookServer; HRESULT ( STDMETHODCALLTYPE *foreachMailUser )( IMsOutlookAddrBookServer * This, - /* [in] */ BSTR query); + /* [in] */ BSTR query, + /* [in] */ long callback); HRESULT ( STDMETHODCALLTYPE *IMAPIProp_GetProps )( IMsOutlookAddrBookServer * This, @@ -198,8 +200,8 @@ EXTERN_C const IID IID_IMsOutlookAddrBookServer; ( (This)->lpVtbl -> Release(This) ) -#define IMsOutlookAddrBookServer_foreachMailUser(This,query) \ - ( (This)->lpVtbl -> foreachMailUser(This,query) ) +#define IMsOutlookAddrBookServer_foreachMailUser(This,query,callback) \ + ( (This)->lpVtbl -> foreachMailUser(This,query,callback) ) #define IMsOutlookAddrBookServer_IMAPIProp_GetProps(This,entryId,nbPropIds,propIds,flags,props,propsLength,propsType) \ ( (This)->lpVtbl -> IMAPIProp_GetProps(This,entryId,nbPropIds,propIds,flags,props,propsLength,propsType) ) diff --git a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.idl b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.idl index 354c947..5fbaffa 100644 --- a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.idl +++ b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.idl @@ -10,7 +10,8 @@ import "Unknwn.idl", "oaidl.idl"; interface IMsOutlookAddrBookServer : IUnknown { HRESULT foreachMailUser( - [in] BSTR query); + [in] BSTR query, + [in] long callback); HRESULT IMAPIProp_GetProps( [in] BSTR entryId, diff --git a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.tlb b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.tlb Binary files differindex a653c05..9492af3 100644 --- a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.tlb +++ b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.tlb diff --git a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx index 8ae23fb..b21a636 100644 --- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx +++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx @@ -100,17 +100,21 @@ STDMETHODIMP_(ULONG) MsOutlookAddrBookClient::Release() * a search via the foreachMailUser function. * * @param id The contact identifier. + * @param callback the callback address * * @return S_OK. */ HRESULT STDMETHODCALLTYPE MsOutlookAddrBookClient::foreachMailUserCallback( - BSTR id) + BSTR id, long callback) { char * charId = StringUtils::WideCharToMultiByte(id); - MAPINotification_callCallbackMethod(charId, NULL); + boolean res = MAPINotification_callCallbackMethod(charId, callback); free(charId); - return S_OK; + if(res) + return S_OK; + else + return E_ABORT; } /** diff --git a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.h b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.h index f21b3c4..159e0f8 100644 --- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.h +++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.h @@ -35,7 +35,8 @@ class MsOutlookAddrBookClient: STDMETHODIMP_(ULONG) Release(); // IMsOutlookAddrBookClient - HRESULT STDMETHODCALLTYPE foreachMailUserCallback(BSTR id); + HRESULT STDMETHODCALLTYPE foreachMailUserCallback( + BSTR id, long callback); HRESULT STDMETHODCALLTYPE deleted(BSTR id); HRESULT STDMETHODCALLTYPE inserted(BSTR id); diff --git a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx index 1d3d362..f80b60b 100644 --- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx +++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx @@ -101,54 +101,67 @@ STDMETHODIMP_(ULONG) MsOutlookAddrBookServer::Release() * Starts a search for contact using MAPI.A * * @param query The search pattern (unused). + * @param callbackAddress The address of the callback. * * @return S_OK. */ -HRESULT STDMETHODCALLTYPE MsOutlookAddrBookServer::foreachMailUser(BSTR query) +HRESULT STDMETHODCALLTYPE MsOutlookAddrBookServer::foreachMailUser( + BSTR query, long callbackAddress) { char * charQuery = StringUtils::WideCharToMultiByte(query); - MsOutlookAddrBookContactQuery_foreachMailUser( - charQuery, - (void *) MsOutlookAddrBookServer::foreachMailUserCallback, - NULL); + HRESULT hr = E_FAIL; + + IMsOutlookAddrBookClient * msOutlookAddrBookClient = NULL; + if((hr = CoCreateInstance( + CLSID_MsOutlookAddrBookClient, + NULL, + CLSCTX_LOCAL_SERVER, + IID_IMsOutlookAddrBookClient, + (void**) &msOutlookAddrBookClient)) == S_OK) + { + hr = MsOutlookAddrBookContactQuery_foreachMailUser( + charQuery, + (void *) MsOutlookAddrBookServer::foreachMailUserCallback, + (void *) msOutlookAddrBookClient, + callbackAddress); + + msOutlookAddrBookClient->Release(); + } free(charQuery); - return S_OK; + return hr == S_OK; } /** * Calls back the java side to list a contact. * * @param iUnknown The string representation of the entry id of the contact. - * @param object Not used. Must be set to NULL. + * @param callbackClient the client object to call the callback and pass the + * result and the callbackAddress we have received. + * @param callbackAddress the address of the callback function. * * @return True everything works fine and that we must continue to list the * other contacts. False otherwise. */ boolean MsOutlookAddrBookServer::foreachMailUserCallback( LPSTR iUnknown, - void * object) + void * callbackClient, + long callbackAddress) { HRESULT hr = E_FAIL; - IMsOutlookAddrBookClient * msOutlookAddrBookClient = NULL; - if((hr = CoCreateInstance( - CLSID_MsOutlookAddrBookClient, - NULL, - CLSCTX_LOCAL_SERVER, - IID_IMsOutlookAddrBookClient, - (void**) &msOutlookAddrBookClient)) == S_OK) + if(callbackClient) { LPWSTR iUnknownW = StringUtils::MultiByteToWideChar(iUnknown); BSTR res = SysAllocString(iUnknownW); - hr = msOutlookAddrBookClient->foreachMailUserCallback(res); + hr = ((IMsOutlookAddrBookClient *)callbackClient) + ->foreachMailUserCallback(res, callbackAddress); SysFreeString(res); free(iUnknownW); - msOutlookAddrBookClient->Release(); } return (hr == S_OK); diff --git a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.h b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.h index a1ba304..190217a 100644 --- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.h +++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.h @@ -35,7 +35,7 @@ class MsOutlookAddrBookServer: STDMETHODIMP_(ULONG) Release(); // IMsOutlookAddrBookServer - HRESULT STDMETHODCALLTYPE foreachMailUser(BSTR query); + HRESULT STDMETHODCALLTYPE foreachMailUser(BSTR query, long callback); HRESULT STDMETHODCALLTYPE IMAPIProp_GetProps( BSTR entryId, @@ -74,7 +74,8 @@ class MsOutlookAddrBookServer: static boolean foreachMailUserCallback( LPSTR iUnknown, - void * object); + void * callbackClient, + long callbackAddress); }; #endif diff --git a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx index fa81c62..9e34c65 100644 --- a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx +++ b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx @@ -100,7 +100,7 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac LPWSTR unicodeQuery = StringUtils::MultiByteToWideChar(nativeQuery); BSTR comQuery = SysAllocString(unicodeQuery); - iServer->foreachMailUser(comQuery); + iServer->foreachMailUser(comQuery, (long)(intptr_t)callback); SysFreeString(comQuery); free(unicodeQuery); } diff --git a/src/native/build.xml b/src/native/build.xml index a5697e4..fbed1ff 100644 --- a/src/native/build.xml +++ b/src/native/build.xml @@ -824,6 +824,11 @@ </target> <!-- compile jmsoutlookaddrbook library for Windows --> + <!-- install tdm-gcc both 32 and 64 bit with command line tools and + can directly use command prompt + When changing idl file in visual studio console execute + midl <idl file>. + --> <target name="msoutlookaddrbook" description="Build jmsoutlookaddrbook shared library for Windows" 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 fe1b66d..b6c42ce 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java +++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java @@ -1040,9 +1040,15 @@ public class MsOutlookAddrBookContactQuery { synchronized (MsOutlookAddrBookContactQuery.class) { + long start = System.currentTimeMillis(); + foreachMailUser( query.toString(), new PtrOutlookContactCallback()); + + if(logger.isTraceEnabled()) + logger.trace("Query " + query + " took " + + (System.currentTimeMillis() - start) + " ms."); } } @@ -1073,18 +1079,6 @@ public class MsOutlookAddrBookContactQuery } /** - * Callback method when receiving notifications for query, - * finished all items. - */ - public void finishedNotifications() - { - synchronized (MsOutlookAddrBookContactQuery.class) - { - super.stopped(true); - } - } - - /** * Callback method when receiving notifications for updated items. * * @param id The outlook contact identifier. @@ -1286,33 +1280,4 @@ public class MsOutlookAddrBookContactQuery // not found return null; } - - @Override - protected void stopped(boolean completed) - { - // don't stop will stop when the thread that notifies about found - // contact ids stop notifying us - } - - /** - * When canceled clear all contact id that are in progress for notify. - * - * @param status {@link ContactQuery#QUERY_CANCELED}, - * {@link ContactQuery#QUERY_COMPLETED}, or - */ - @Override - public void setStatus(int status) - { - if(logger.isTraceEnabled()) - logger.trace("Query: " + query + " setStatus " + status); - - // first set status, so we don't end up with completed query, where - // it was canceled - super.setStatus(status); - - if (status == QUERY_CANCELED) - { - getContactSource().clearRemainingNotifications(); - } - } } 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 0e84367..508b0d2 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java +++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java @@ -403,15 +403,6 @@ public class MsOutlookAddrBookContactSourceService { idFunction = contactIds.get(0); } - else - { - // inform query that we had finished delivering - // all notifications - if(latestQuery != null) - { - latestQuery.finishedNotifications(); - } - } } } } |