From 8d2147e6365c47acb8e28c725147ceec4f6a0b9c Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Thu, 28 Feb 2013 20:53:13 +0000 Subject: Fixes crashes in the Outlook contact integration related to calling conventions. --- src/native/addrbook/msoutlook/MAPINotification.cxx | 175 ++++++++++++++++++++ src/native/addrbook/msoutlook/MAPINotification.h | 30 ++++ src/native/addrbook/msoutlook/Makefile | 27 ---- src/native/addrbook/msoutlook/MsOutlookMAPI.h | 7 + .../msoutlook/MsOutlookMAPIHResultException.h | 4 +- .../addrbook/msoutlook/lib/MAPINotification.cxx | 178 --------------------- .../addrbook/msoutlook/lib/MAPINotification.h | 30 ---- ...ook_msoutlook_MsOutlookAddrBookContactQuery.cxx | 17 +- ...rbook_msoutlook_MsOutlookAddrBookContactQuery.h | 3 +- ...tlook_MsOutlookAddrBookContactSourceService.cxx | 74 ++++----- ...outlook_MsOutlookAddrBookContactSourceService.h | 3 +- 11 files changed, 256 insertions(+), 292 deletions(-) create mode 100644 src/native/addrbook/msoutlook/MAPINotification.cxx create mode 100644 src/native/addrbook/msoutlook/MAPINotification.h delete mode 100644 src/native/addrbook/msoutlook/Makefile delete mode 100644 src/native/addrbook/msoutlook/lib/MAPINotification.cxx delete mode 100644 src/native/addrbook/msoutlook/lib/MAPINotification.h (limited to 'src/native/addrbook/msoutlook') diff --git a/src/native/addrbook/msoutlook/MAPINotification.cxx b/src/native/addrbook/msoutlook/MAPINotification.cxx new file mode 100644 index 0000000..229699a --- /dev/null +++ b/src/native/addrbook/msoutlook/MAPINotification.cxx @@ -0,0 +1,175 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +#include "MAPINotification.h" + +#include "MsOutlookMAPI.h" +#include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h" +#include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.h" +#include +#include +#include +#include + +/** + * Manages notification for the message data base (used to get the list of + * contact). + * + * @author Vincent Lucas + */ + +/** + * The List of events we want to retrieve. + */ +static ULONG EVENT_MASK + = fnevObjectCreated + | fnevObjectDeleted + | fnevObjectModified + | fnevObjectMoved; + +/** + * Functions called when an event is fired from the message data base. + * + * @param lpvContext A pointer to the message data base. + * @param cNotifications The number of event in this call. + * @param lpNotifications The list of notifications. + */ +LONG STDAPICALLTYPE onNotify( + LPVOID lpvContext, + ULONG cNotifications, + LPNOTIFICATION lpNotifications) +{ + for(unsigned int i = 0; i < cNotifications; ++i) + { + LPUNKNOWN iUnknown = NULL; + if(lpvContext != NULL) + { + iUnknown = openEntry( + lpNotifications[i].info.obj.cbEntryID, + lpNotifications[i].info.obj.lpEntryID, + lpvContext); + } + + // A contact has been created + if(lpNotifications[i].ulEventType == fnevObjectCreated) + { + if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE) + { + callInsertedCallbackMethod(iUnknown); + } + } + // A contact has been Modified + else if(lpNotifications[i].ulEventType == fnevObjectModified) + { + if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE) + { + callUpdatedCallbackMethod(iUnknown); + } + } + // A contact has been deleted. + else if(lpNotifications[i].ulEventType == fnevObjectDeleted) + { + if(lpvContext != NULL) + { + char entryIdStr[lpNotifications[i].info.obj.cbEntryID * 2 + 1]; + + MsOutlookAddrBookContact_hexFromBin( + //HexFromBin( + (LPBYTE) lpNotifications[i].info.obj.lpEntryID, + lpNotifications[i].info.obj.cbEntryID, + entryIdStr); + + if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE) + { + callDeletedCallbackMethod(entryIdStr); + } + } + } + // A contact has been deleted (moved to trash). + else if(lpNotifications[i].ulEventType == fnevObjectMoved) + { + if(lpvContext != NULL) + { + char entryIdStr[lpNotifications[i].info.obj.cbEntryID * 2 + 1]; + MsOutlookAddrBookContact_hexFromBin( + //HexFromBin( + (LPBYTE) lpNotifications[i].info.obj.lpEntryID, + lpNotifications[i].info.obj.cbEntryID, + entryIdStr); + char parentEntryIdStr[ + lpNotifications[i].info.obj.cbParentID * 2 + 1]; + MsOutlookAddrBookContact_hexFromBin( + //HexFromBin( + (LPBYTE) lpNotifications[i].info.obj.lpParentID, + lpNotifications[i].info.obj.cbParentID, + parentEntryIdStr); + ULONG wasteBasketTags[] = {1, PR_IPM_WASTEBASKET_ENTRYID}; + ULONG wasteBasketNbValues = 0; + LPSPropValue wasteBasketProps = NULL; + ((LPMDB)lpvContext)->GetProps( + (LPSPropTagArray) wasteBasketTags, + MAPI_UNICODE, + &wasteBasketNbValues, + &wasteBasketProps); + char wasteBasketEntryIdStr[ + wasteBasketProps[0].Value.bin.cb * 2 + 1]; + MsOutlookAddrBookContact_hexFromBin( + //HexFromBin( + (LPBYTE) wasteBasketProps[0].Value.bin.lpb, + wasteBasketProps[0].Value.bin.cb, + wasteBasketEntryIdStr); + + openEntry( + lpNotifications[i].info.obj.cbParentID, + lpNotifications[i].info.obj.lpParentID, + lpvContext); + + + if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE + && strcmp(parentEntryIdStr, wasteBasketEntryIdStr) == 0) + { + callDeletedCallbackMethod(entryIdStr); + } + } + } + + if(iUnknown != NULL) + { + iUnknown->Release(); + } + } + + // A client must always return a S_OK. + return S_OK; +} + +/** + * Registers to notification for the given message data base. + * + * @param iUnknown The data base to register to in order to receive events. + * + * @return A unsigned long which is a token wich must be used to call the + * unadvise function for the same message data base. + */ +ULONG registerNotifyMessageDataBase( + LPMDB iUnknown) +{ + LPMAPIADVISESINK adviseSink; + MsOutlookAddrBookContact_HrAllocAdviseSink( + //HrAllocAdviseSink( + &onNotify, + iUnknown, + &adviseSink); + ULONG nbConnection = 0; + iUnknown->Advise( + (ULONG) 0, + (LPENTRYID) NULL, + EVENT_MASK, + adviseSink, + (ULONG_PTR *) &nbConnection); + + return nbConnection; +} diff --git a/src/native/addrbook/msoutlook/MAPINotification.h b/src/native/addrbook/msoutlook/MAPINotification.h new file mode 100644 index 0000000..9b1c8d3 --- /dev/null +++ b/src/native/addrbook/msoutlook/MAPINotification.h @@ -0,0 +1,30 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +#ifndef _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MAPINOTIFICATION_H_ +#define _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MAPINOTIFICATION_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "MsOutlookMAPI.h" +#include + +LONG STDAPICALLTYPE onNotify( + LPVOID lpvContext, + ULONG cNotifications, + LPNOTIFICATION lpNotifications); + +ULONG registerNotifyMessageDataBase( + LPMDB iUnknown); + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MAPINOTIFICATION_H_ */ diff --git a/src/native/addrbook/msoutlook/Makefile b/src/native/addrbook/msoutlook/Makefile deleted file mode 100644 index a594e5a..0000000 --- a/src/native/addrbook/msoutlook/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -CC = gcc -O2 -OUTLOOK_MAPI_HEADERS ?= C:/Users/lyub0m1r/Downloads/Outlook2010MAPIHeaders -TARGET_BASENAME = jmsoutlookaddrbook - -ARCH ?= $(shell $(CC) -dumpmachine | sed -e s/x86_64-.*/-64/ -e s/i.86-.*// -e s/mingw32//) -ifeq "$(ARCH)" "-64" - JAVA_HOME ?= C:/PROGRA~1/jdk -else - JAVA_HOME ?= C:/PROGRA~2/jdk -endif - -CPPFLAGS = \ - -Wall -Wreturn-type \ - -DWINVER=0x0502 -D_WIN32_WINNT=0x0502 \ - -DJNI_IMPLEMENTATION \ - -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/win32 -I$(OUTLOOK_MAPI_HEADERS) -I.. -LDFLAGS = -shared -Wl,--kill-at -Wl,--subsystem,windows -LIBS = -ladvapi32 -luuid -TARGET = ../../../../lib/native/windows$(ARCH)/$(TARGET_BASENAME).dll - -$(TARGET): \ - ../AddrBookContactQuery.c \ - MsOutlookMAPIHResultException.cxx \ - net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx \ - net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx - $(CC) $(CPPFLAGS) $^ $(LDFLAGS) -o $@ $(LIBS) - -strip $(TARGET) diff --git a/src/native/addrbook/msoutlook/MsOutlookMAPI.h b/src/native/addrbook/msoutlook/MsOutlookMAPI.h index 9739835..ecab5b4 100644 --- a/src/native/addrbook/msoutlook/MsOutlookMAPI.h +++ b/src/native/addrbook/msoutlook/MsOutlookMAPI.h @@ -11,9 +11,16 @@ #define WIN32_LEAN_AND_MEAN #include +#ifndef __in +#define __in +#endif /* #ifndef __in */ #ifndef __in_opt #define __in_opt #endif /* #ifndef __in_opt */ +#ifndef __out +#define __out +#endif /* #ifndef __out */ + #if defined(_WINBASE_H) && !defined(_WINBASE_) #define _tagCY_DEFINED #define _WINBASE_ diff --git a/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.h b/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.h index 11350b5..c0f7742 100644 --- a/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.h +++ b/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.h @@ -8,8 +8,8 @@ #ifndef _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKMAPIHRESULTEXCEPTION_H_ #define _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKMAPIHRESULTEXCEPTION_H_ -#include #include "MsOutlookMAPI.h" +#include #include #ifdef __cplusplus @@ -23,4 +23,4 @@ void MsOutlookMAPIHResultException_throwNew } #endif /* #ifdef __cplusplus */ -#endif /* _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKMAPIHRESULTEXCEPTION_ */ \ No newline at end of file +#endif /* _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKMAPIHRESULTEXCEPTION_ */ diff --git a/src/native/addrbook/msoutlook/lib/MAPINotification.cxx b/src/native/addrbook/msoutlook/lib/MAPINotification.cxx deleted file mode 100644 index 51dc745..0000000 --- a/src/native/addrbook/msoutlook/lib/MAPINotification.cxx +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -#include "MAPINotification.h" - -#define WIN32_LEAN_AND_MEAN -#include - -#include -#include - -#include -#include - -#include "../net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h" -#include "../net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.h" -/** - * Manages notification for the message data base (used to get the list of - * contact). - * - * @author Vincent Lucas - */ - -/** - * The List of events we want to retrieve. - */ -static ULONG EVENT_MASK - = fnevObjectCreated - | fnevObjectDeleted - | fnevObjectModified - | fnevObjectMoved; - -/** - * Functions called when an event is fired from the message data base. - * - * @param lpvContext A pointer to the message data base. - * @param cNotifications The number of event in this call. - * @param lpNotifications The list of notifications. - */ -LONG STDAPICALLTYPE onNotify( - LPVOID lpvContext, - ULONG cNotifications, - LPNOTIFICATION lpNotifications) -{ - for(unsigned int i = 0; i < cNotifications; ++i) - { - LPUNKNOWN iUnknown = NULL; - if(lpvContext != NULL) - { - iUnknown = openEntry( - lpNotifications[i].info.obj.cbEntryID, - lpNotifications[i].info.obj.lpEntryID, - lpvContext); - } - - // A contact has been created - if(lpNotifications[i].ulEventType == fnevObjectCreated) - { - if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE) - { - callInsertedCallbackMethod(iUnknown); - } - } - // A contact has been Modified - else if(lpNotifications[i].ulEventType == fnevObjectModified) - { - if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE) - { - callUpdatedCallbackMethod(iUnknown); - } - } - // A contact has been deleted. - else if(lpNotifications[i].ulEventType == fnevObjectDeleted) - { - if(lpvContext != NULL) - { - char entryIdStr[lpNotifications[i].info.obj.cbEntryID * 2 + 1]; - - MsOutlookAddrBookContact_hexFromBin( - //HexFromBin( - (LPBYTE) lpNotifications[i].info.obj.lpEntryID, - lpNotifications[i].info.obj.cbEntryID, - entryIdStr); - - if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE) - { - callDeletedCallbackMethod(entryIdStr); - } - } - } - // A contact has been deleted (moved to trash). - else if(lpNotifications[i].ulEventType == fnevObjectMoved) - { - if(lpvContext != NULL) - { - char entryIdStr[lpNotifications[i].info.obj.cbEntryID * 2 + 1]; - MsOutlookAddrBookContact_hexFromBin( - //HexFromBin( - (LPBYTE) lpNotifications[i].info.obj.lpEntryID, - lpNotifications[i].info.obj.cbEntryID, - entryIdStr); - char parentEntryIdStr[ - lpNotifications[i].info.obj.cbParentID * 2 + 1]; - MsOutlookAddrBookContact_hexFromBin( - //HexFromBin( - (LPBYTE) lpNotifications[i].info.obj.lpParentID, - lpNotifications[i].info.obj.cbParentID, - parentEntryIdStr); - ULONG wasteBasketTags[] = {1, PR_IPM_WASTEBASKET_ENTRYID}; - ULONG wasteBasketNbValues = 0; - LPSPropValue wasteBasketProps = NULL; - ((LPMDB)lpvContext)->GetProps( - (LPSPropTagArray) wasteBasketTags, - MAPI_UNICODE, - &wasteBasketNbValues, - &wasteBasketProps); - char wasteBasketEntryIdStr[ - wasteBasketProps[0].Value.bin.cb * 2 + 1]; - MsOutlookAddrBookContact_hexFromBin( - //HexFromBin( - (LPBYTE) wasteBasketProps[0].Value.bin.lpb, - wasteBasketProps[0].Value.bin.cb, - wasteBasketEntryIdStr); - - openEntry( - lpNotifications[i].info.obj.cbParentID, - lpNotifications[i].info.obj.lpParentID, - lpvContext); - - - if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE - && strcmp(parentEntryIdStr, wasteBasketEntryIdStr) == 0) - { - callDeletedCallbackMethod(entryIdStr); - } - } - } - - if(iUnknown != NULL) - { - iUnknown->Release(); - } - } - - // A client must always return a S_OK. - return S_OK; -} - -/** - * Registers to notification for the given message data base. - * - * @param iUnknown The data base to register to in order to receive events. - * - * @return A unsigned long which is a token wich must be used to call the - * unadvise function for the same message data base. - */ -ULONG registerNotifyMessageDataBase( - LPMDB iUnknown) -{ - LPMAPIADVISESINK adviseSink; - MsOutlookAddrBookContact_HrAllocAdviseSink( - //HrAllocAdviseSink( - &onNotify, - iUnknown, - &adviseSink); - ULONG nbConnection = 0; - iUnknown->Advise( - 0, - NULL, - EVENT_MASK, - adviseSink, - &nbConnection); - - return nbConnection; -} diff --git a/src/native/addrbook/msoutlook/lib/MAPINotification.h b/src/native/addrbook/msoutlook/lib/MAPINotification.h deleted file mode 100644 index 2cf4eea..0000000 --- a/src/native/addrbook/msoutlook/lib/MAPINotification.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Jitsi, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -#ifndef _mapi_notification_h -#define _mapi_notification_h - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -LONG STDAPICALLTYPE onNotify( - LPVOID lpvContext, - ULONG cNotifications, - LPNOTIFICATION lpNotifications); - -ULONG registerNotifyMessageDataBase( - LPMDB iUnknown); - -#ifdef __cplusplus -} -#endif - -#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 2a49371..e63fd33 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 @@ -7,16 +7,13 @@ #include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.h" -#include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h" - #include "../AddrBookContactQuery.h" -#include "MsOutlookMAPI.h" #include "MsOutlookMAPIHResultException.h" -#include "lib/MAPINotification.h" - +#include "MAPINotification.h" +#include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h" +#include #include #include -#include #define PR_ATTACHMENT_CONTACTPHOTO PROP_TAG(PT_BOOLEAN, 0x7FFF) @@ -1527,8 +1524,8 @@ LPUNKNOWN openEntryId(const char* entryId) /** * Registers a callback function for when the message store table changes. */ -ULONG registerNotifyTable( - LPMAPITABLE iUnknown) +ULONG +registerNotifyTable(LPMAPITABLE iUnknown) { LPMAPIADVISESINK adviseSink; MsOutlookAddrBookContact_HrAllocAdviseSink( @@ -1537,10 +1534,10 @@ ULONG registerNotifyTable( iUnknown, &adviseSink); ULONG nbConnection = 0; - iUnknown->Advise( + iUnknown->Advise( fnevTableModified, adviseSink, - &nbConnection); + (ULONG_PTR *) &nbConnection); return nbConnection; } diff --git a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.h b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.h index 0699120..3c4786c 100644 --- a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.h +++ b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.h @@ -8,9 +8,10 @@ extern "C" { #endif +#include "MsOutlookMAPI.h" #include #include -#include +#include /* * Class: net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery diff --git a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx index 779361e..4514097 100644 --- a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx +++ b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx @@ -7,15 +7,11 @@ #include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h" -#include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.h" - #include "../AddrBookContactQuery.h" -#include "MsOutlookMAPI.h" #include "MsOutlookMAPIHResultException.h" - -#include "lib/MAPINotification.h" - -#include +#include "MAPINotification.h" +#include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.h" +#include #include #include #include @@ -141,7 +137,6 @@ void callDeletedCallbackMethod( contactSourceServiceVM->DetachCurrentThread(); } - static LPMAPIALLOCATEBUFFER MsOutlookAddrBookContactSourceService_mapiAllocateBuffer; static LPMAPIFREEBUFFER MsOutlookAddrBookContactSourceService_mapiFreeBuffer; @@ -149,18 +144,18 @@ static LPMAPIINITIALIZE MsOutlookAddrBookContactSourceService_mapiInitialize; static LPMAPILOGONEX MsOutlookAddrBookContactSourceService_mapiLogonEx; static LPMAPIUNINITIALIZE MsOutlookAddrBookContactSourceService_mapiUninitialize; -static void (STDAPICALLTYPE *MsOutlookAddrBookContactSourceService_hexFromBin) - (LPBYTE, int, LPTSTR); -static void (STDAPICALLTYPE *MsOutlookAddrBookContactSourceService_HrAllocAdviseSink) - (LPNOTIFCALLBACK, LPVOID, LPMAPIADVISESINK*); -static WINBOOL (STDAPICALLTYPE *MsOutlookAddrBookContactSourceService_FBinFromHex) - (LPTSTR, LPBYTE); -static HRESULT (STDAPICALLTYPE *MsOutlookAddrBookContactSourceService_HrQueryAllRows) - (LPMAPITABLE, LPSPropTagArray, LPSRestriction, LPSSortOrderSet, LONG, - LPSRowSet*); -static void (STDAPICALLTYPE *MsOutlookAddrBookContactSourceService_FreeProws) - (LPSRowSet); +typedef void (STDAPICALLTYPE *LPHEXFROMBIN)(LPBYTE, int, LPTSTR); +typedef HRESULT (STDAPICALLTYPE *LPHRALLOCADVISESINK)(LPNOTIFCALLBACK, LPVOID, LPMAPIADVISESINK FAR *); +typedef BOOL (STDAPICALLTYPE *LPFBINFROMHEX)(LPTSTR, LPBYTE); +typedef HRESULT (STDAPICALLTYPE *LPHRQUERYALLROWS)(LPMAPITABLE, LPSPropTagArray, LPSRestriction, LPSSortOrderSet, LONG, LPSRowSet FAR *); +typedef void (STDAPICALLTYPE *LPFREEPROWS)(LPSRowSet); + +static LPHEXFROMBIN MsOutlookAddrBookContactSourceService_hexFromBin; +static LPHRALLOCADVISESINK MsOutlookAddrBookContactSourceService_HrAllocAdviseSink; +static LPFBINFROMHEX MsOutlookAddrBookContactSourceService_FBinFromHex; +static LPHRQUERYALLROWS MsOutlookAddrBookContactSourceService_HrQueryAllRows; +static LPFREEPROWS MsOutlookAddrBookContactSourceService_FreeProws; static LPMAPISESSION MsOutlookAddrBookContactSourceService_mapiSession = NULL; static CRITICAL_SECTION MsOutlookAddrBookContactSourceService_mapiSessionCriticalSection; @@ -406,7 +401,7 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac // If we've determined that we'd like to go on with MAPI, try to load it. if (HR_SUCCEEDED(hResult)) { - HMODULE lib = LoadLibrary(_T("mapi32.dll")); + HMODULE lib = ::LoadLibrary(_T("mapi32.dll")); hResult = MAPI_E_NO_SUPPORT; if (lib) @@ -435,24 +430,18 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac MsOutlookAddrBookContactSourceService_mapiLogonEx = (LPMAPILOGONEX) GetProcAddress(lib, "MAPILogonEx"); - MsOutlookAddrBookContactSourceService_hexFromBin - = (STDAPICALLTYPE void(*)(LPBYTE, int, LPTSTR)) - GetProcAddress(lib, "HexFromBin@12"); + = (LPHEXFROMBIN) GetProcAddress(lib, "HexFromBin@12"); MsOutlookAddrBookContactSourceService_HrAllocAdviseSink - = (STDAPICALLTYPE void(*)(LPNOTIFCALLBACK, LPVOID, LPMAPIADVISESINK*)) + = (LPHRALLOCADVISESINK) GetProcAddress(lib, "HrAllocAdviseSink@12"); MsOutlookAddrBookContactSourceService_FBinFromHex - = (STDAPICALLTYPE WINBOOL(*)(LPTSTR, LPBYTE)) - GetProcAddress(lib, "FBinFromHex@8"); + = (LPFBINFROMHEX) GetProcAddress(lib, "FBinFromHex@8"); MsOutlookAddrBookContactSourceService_HrQueryAllRows - = (STDAPICALLTYPE HRESULT(*)(LPMAPITABLE, LPSPropTagArray, - LPSRestriction, LPSSortOrderSet, LONG, - LPSRowSet*)) + = (LPHRQUERYALLROWS) GetProcAddress(lib, "HrQueryAllRows@24"); MsOutlookAddrBookContactSourceService_FreeProws - = (STDAPICALLTYPE void(*)(LPSRowSet)) - GetProcAddress(lib, "FreeProws@4"); + = (LPFREEPROWS) GetProcAddress(lib, "FreeProws@4"); InitializeCriticalSection( &MsOutlookAddrBookContactSourceService_mapiSessionCriticalSection); @@ -462,14 +451,13 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac && MsOutlookAddrBookContactSourceService_mapiLogonEx && MsOutlookAddrBookContactSourceService_hexFromBin - && - MsOutlookAddrBookContactSourceService_HrAllocAdviseSink + && MsOutlookAddrBookContactSourceService_HrAllocAdviseSink && MsOutlookAddrBookContactSourceService_FBinFromHex - && - MsOutlookAddrBookContactSourceService_HrQueryAllRows - && MsOutlookAddrBookContactSourceService_FreeProws - ) + && MsOutlookAddrBookContactSourceService_HrQueryAllRows + && MsOutlookAddrBookContactSourceService_FreeProws) + { hResult = S_OK; + } else { MsOutlookAddrBookContactSourceService_mapiUninitialize(); @@ -485,12 +473,12 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac if (HR_SUCCEEDED(hResult) && MsOutlookAddrBookContactSourceService_mapiSession == NULL) { - hResult = MsOutlookAddrBook_mapiLogonEx( - //hResult = MAPILogonEx( - 0, - NULL, NULL, - MAPI_EXTENDED | MAPI_NO_MAIL | MAPI_USE_DEFAULT, - &MsOutlookAddrBookContactSourceService_mapiSession); + hResult + = MsOutlookAddrBook_mapiLogonEx( + 0, + NULL, NULL, + MAPI_EXTENDED | MAPI_NO_MAIL | MAPI_USE_DEFAULT, + &MsOutlookAddrBookContactSourceService_mapiSession); openAllMsgStores( MsOutlookAddrBookContactSourceService_mapiSession); } diff --git a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h index 00e0474..c93b7fb 100644 --- a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h +++ b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h @@ -8,9 +8,10 @@ extern "C" { #endif +#include "MsOutlookMAPI.h" #include #include -#include +#include /* * Class: net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService -- cgit v1.1