diff options
author | Vincent Lucas <chenzo@jitsi.org> | 2013-06-27 22:28:41 +0200 |
---|---|---|
committer | Vincent Lucas <chenzo@jitsi.org> | 2013-06-27 22:28:41 +0200 |
commit | cd56bd88b2d2dff89a16be17af5c9aa52a56264a (patch) | |
tree | 67470abc8d2dad4ea81830f9ab8bb083594a3e05 /src/native/addrbook/msoutlook | |
parent | 6939b99d6aeb480c610e438692ba7007b31098d0 (diff) | |
download | jitsi-cd56bd88b2d2dff89a16be17af5c9aa52a56264a.zip jitsi-cd56bd88b2d2dff89a16be17af5c9aa52a56264a.tar.gz jitsi-cd56bd88b2d2dff89a16be17af5c9aa52a56264a.tar.bz2 |
Adds management of Outlook contact with multiple identifier. Corrects null pointer segmentation fault when comparing entry identifiers. Uses MAPI service provider to retrieve a tag corresponding to a property identifier.
Diffstat (limited to 'src/native/addrbook/msoutlook')
18 files changed, 1774 insertions, 1409 deletions
diff --git a/src/native/addrbook/msoutlook/MAPINotification.cxx b/src/native/addrbook/msoutlook/MAPINotification.cxx index 92b35f2..6a41458 100644 --- a/src/native/addrbook/msoutlook/MAPINotification.cxx +++ b/src/native/addrbook/msoutlook/MAPINotification.cxx @@ -10,6 +10,7 @@ #include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h" #include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.h" #include "MsOutlookAddrBookContactSourceService.h" +#include "MsOutlookAddrBookContactQuery.h" #include <mapidefs.h> #include <stdio.h> @@ -29,7 +30,8 @@ static ULONG MAPINotification_EVENT_MASK = fnevObjectCreated | fnevObjectDeleted | fnevObjectModified - | fnevObjectMoved; + | fnevObjectMoved + | fnevObjectCopied; static LPMDB * MAPINotification_msgStores = NULL; static ULONG * MAPINotification_msgStoresConnection = NULL; @@ -121,9 +123,12 @@ 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->CallBooleanMethod( + tmpJniEnv->CallVoidMethod( MAPINotification_notificationsDelegateObject, MAPINotification_notificationsDelegateMethodIdDeleted, value); @@ -146,7 +151,7 @@ void MAPINotification_jniCallInsertedMethod(LPSTR iUnknown) { jstring value = tmpJniEnv->NewStringUTF(iUnknown); - tmpJniEnv->CallBooleanMethod( + tmpJniEnv->CallVoidMethod( MAPINotification_notificationsDelegateObject, MAPINotification_notificationsDelegateMethodIdInserted, value); @@ -169,7 +174,7 @@ void MAPINotification_jniCallUpdatedMethod(LPSTR iUnknown) { jstring value = tmpJniEnv->NewStringUTF(iUnknown); - tmpJniEnv->CallBooleanMethod( + tmpJniEnv->CallVoidMethod( MAPINotification_notificationsDelegateObject, MAPINotification_notificationsDelegateMethodIdUpdated, value); @@ -200,8 +205,9 @@ STDAPICALLTYPE MAPINotification_onNotify lpvContext); } - // A contact has been created - if(lpNotifications[i].ulEventType == fnevObjectCreated) + // A contact has been created (a new one or a copy). + if(lpNotifications[i].ulEventType == fnevObjectCreated + || lpNotifications[i].ulEventType == fnevObjectCopied) { if(lpvContext != NULL) { @@ -244,6 +250,30 @@ STDAPICALLTYPE MAPINotification_onNotify ::free(entryIdStr); entryIdStr = NULL; + + // If the entry identifier has changed, then deletes the old + // one. + if(lpNotifications[i].info.obj.lpOldID != NULL + && lpNotifications[i].info.obj.cbOldID > 0) + { + LPSTR oldEntryIdStr = (LPSTR) + ::malloc((lpNotifications[i].info.obj.cbOldID + 1) * 2); + HexFromBin( + (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) + { + MAPINotification_callDeletedMethod(oldEntryIdStr); + } + ::free(oldEntryIdStr); + oldEntryIdStr = NULL; + } } } // A contact has been deleted. @@ -259,6 +289,10 @@ 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) { @@ -306,6 +340,54 @@ STDAPICALLTYPE MAPINotification_onNotify lpNotifications[i].info.obj.lpParentID, lpvContext); + fprintf(stdout, + "MAPINotification_onNotify: evMoved: bin %s / %s / %s\n", + entryIdStr, + parentEntryIdStr, + wasteBasketEntryIdStr); + fflush(stdout); + + LPUNKNOWN entryDirBin = + MAPINotification_openEntry( + lpNotifications[i].info.obj.cbEntryID, + (LPENTRYID) lpNotifications[i].info.obj.lpEntryID, + lpvContext); + char* entryDir + = MsOutlookAddrBookContactQuery_getStringUnicodeProp( + entryDirBin, + 0x3001); // PR_DISPLAY_NAME + + LPUNKNOWN parentEntryDirBin = + MAPINotification_openEntry( + lpNotifications[i].info.obj.cbParentID, + (LPENTRYID) lpNotifications[i].info.obj.lpParentID, + lpvContext); + char* parentEntryDir + = MsOutlookAddrBookContactQuery_getStringUnicodeProp( + parentEntryDirBin, + 0x3001); // PR_DISPLAY_NAME + + LPUNKNOWN basketEntryDirBin = + MAPINotification_openEntry( + wasteBasketProps[0].Value.bin.cb, + (LPENTRYID) wasteBasketProps[0].Value.bin.lpb, + lpvContext); + char* basketEntryDir + = MsOutlookAddrBookContactQuery_getStringUnicodeProp( + basketEntryDirBin, + 0x3001); // PR_DISPLAY_NAME + + fprintf(stdout, + "MAPINotification_onNotify: evMoved: %s / %s / %s\n", + entryDir, + parentEntryDir, + basketEntryDir); + fflush(stdout); + + free(entryDir); + free(parentEntryDir); + free(basketEntryDir); + if(lpNotifications[i].info.obj.ulObjType == MAPI_MESSAGE && strcmp(parentEntryIdStr, wasteBasketEntryIdStr) == 0 @@ -320,6 +402,30 @@ STDAPICALLTYPE MAPINotification_onNotify parentEntryIdStr = NULL; ::free(wasteBasketEntryIdStr); wasteBasketEntryIdStr = NULL; + + // If the entry identifier has changed, then deletes the old + // one. + if(lpNotifications[i].info.obj.lpOldID != NULL + && lpNotifications[i].info.obj.cbOldID > 0) + { + LPSTR oldEntryIdStr = (LPSTR) + ::malloc((lpNotifications[i].info.obj.cbOldID + 1) * 2); + HexFromBin( + (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) + { + MAPINotification_callDeletedMethod(oldEntryIdStr); + } + ::free(oldEntryIdStr); + oldEntryIdStr = NULL; + } } } diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx index daa7670..c62da65 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx @@ -90,6 +90,8 @@ static HRESULT MsOutlookAddrBookContactQuery_getContactsFolderEntryID LPSTR MsOutlookAddrBookContactQuery_getContactId(LPMAPIPROP contact); LPMAPIFOLDER MsOutlookAddrBookContactQuery_getDefaultContactFolderId(void); LPMDB MsOutlookAddrBookContactQuery_getDefaultMsgStores(void); +ULONG MsOutlookAddrBookContactQuery_getPropTag + (LPMAPIPROP mapiProp, long propId, long propType); static ULONG MsOutlookAddrBookContactQuery_getPropTagFromLid (LPMAPIPROP mapiProp, LONG lid); static jboolean MsOutlookAddrBookContactQuery_mailUserMatches @@ -996,6 +998,39 @@ LPMDB MsOutlookAddrBookContactQuery_getDefaultMsgStores(void) return msgStore; } +/** + * Returns the property tag associated for the given identifier and type. + * + * @param mapiProp The MAPI object from which we need to get the property tag + * for a given identifier. + * @param propId The identifier to resolve into a tag. + * @param propType The type of the property (PT_UNSPECIFIED, PT_UNICODE, etc.). + * + * @return The property tag associated for the given identifier and type. + */ +ULONG MsOutlookAddrBookContactQuery_getPropTag + (LPMAPIPROP mapiProp, long propId, long propType) +{ + ULONG propTag; + + if (propId < 0x8000) + { + if (propId == PROP_ID(PR_ATTACHMENT_CONTACTPHOTO)) + propTag = PR_HASATTACH; + else + propTag = PROP_TAG(propType, propId); + } + else + { + propTag = MsOutlookAddrBookContactQuery_getPropTagFromLid( + (LPMAPIPROP) mapiProp, + (LONG)propId); + propTag = CHANGE_PROP_TYPE(propTag, propType); + } + + return propTag; +} + static ULONG MsOutlookAddrBookContactQuery_getPropTagFromLid(LPMAPIPROP mapiProp, LONG lid) { @@ -1129,9 +1164,10 @@ int MsOutlookAddrBookContactQuery_IMAPIProp_1DeleteProp propTagArray->cValues = nbProps; for(unsigned int i = 0; i < nbProps; ++i) { - propTag = MsOutlookAddrBookContactQuery_getPropTagFromLid( + propTag = MsOutlookAddrBookContactQuery_getPropTag( (LPMAPIPROP) mapiProp, - propIds[i]); + propIds[i], + PT_UNICODE); *(propTagArray->aulPropTag + i) = propTag; } @@ -1162,14 +1198,10 @@ int MsOutlookAddrBookContactQuery_IMAPIProp_1DeleteProp SPropTagArray propToDelete; propToDelete.cValues = 1; - if(propId == 0x8062) // PidLidInstantMessagingAddress - { - propToDelete.aulPropTag[0] = 0x8046001F; - } - else - { - propToDelete.aulPropTag[0] = PROP_TAG(PT_UNICODE, propId); - } + propToDelete.aulPropTag[0] = MsOutlookAddrBookContactQuery_getPropTag( + (LPMAPIPROP) mapiProp, + propId, + PT_UNICODE); HRESULT hResult = ((LPMAPIPROP) mapiProp)->DeleteProps( @@ -1227,22 +1259,10 @@ HRESULT MsOutlookAddrBookContactQuery_IMAPIProp_1GetProps( long propId = propIds[i]; - ULONG propTag; - - if (propId < 0x8000) - { - if (propId == PROP_ID(PR_ATTACHMENT_CONTACTPHOTO)) - propTag = PR_HASATTACH; - else - propTag = PROP_TAG(PT_UNSPECIFIED, propId); - } - else - { - propTag - = MsOutlookAddrBookContactQuery_getPropTagFromLid( - (LPMAPIPROP) mapiProp, - (LONG)propId); - } + ULONG propTag = MsOutlookAddrBookContactQuery_getPropTag( + (LPMAPIPROP) mapiProp, + propId, + PT_UNSPECIFIED); *(propTagArray->aulPropTag + i) = propTag; } @@ -1437,9 +1457,10 @@ int MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString propTagArray->cValues = nbProps; for(unsigned int i = 0; i < nbProps; ++i) { - propTag = MsOutlookAddrBookContactQuery_getPropTagFromLid( + propTag = MsOutlookAddrBookContactQuery_getPropTag( (LPMAPIPROP) mapiProp, - propIds[i]); + propIds[i], + PT_UNSPECIFIED); *(propTagArray->aulPropTag + i) = propTag; } hResult = ((LPMAPIPROP) mapiProp)->GetProps( @@ -1497,34 +1518,10 @@ int MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString } SPropValue updateValue; - if(propId == 0x8062) // PidLidInstantMessagingAddress - { - updateValue.ulPropTag = 0x8046001F; - } - else if(propId == 0x8045) // business address - street - { - updateValue.ulPropTag = 0x805F001F; - } - else if(propId == 0x8046) // business address - city - { - updateValue.ulPropTag = 0x8060001F; - } - else if(propId == 0x8047) // business address - state - { - updateValue.ulPropTag = 0x8061001F; - } - else if(propId == 0x8048) // business address - zip - { - updateValue.ulPropTag = 0x8062001F; - } - else if(propId == 0x8049) // business address - country - { - updateValue.ulPropTag = 0x8063001F; - } - else - { - updateValue.ulPropTag = PROP_TAG(PT_UNICODE, propId); - } + updateValue.ulPropTag = MsOutlookAddrBookContactQuery_getPropTag( + (LPMAPIPROP) mapiProp, + propId, + PT_UNICODE); updateValue.Value.lpszW = wCharValue; hResult = ((LPMAPIPROP) mapiProp)->SetProps( @@ -1792,3 +1789,140 @@ MsOutlookAddrBookContactQuery_readAttachment } return attachment; } + +/** + * Gets a string property for a given entry. + * + * @param entry The entry to red the property from. + * @param propId The property identifier. + * + * @return A string representation of the property value retrieved. Must be + * freed by the caller. + */ +char* MsOutlookAddrBookContactQuery_getStringUnicodeProp + (LPUNKNOWN entry, ULONG propId) +{ + SPropTagArray tagArray; + tagArray.cValues = 1; + tagArray.aulPropTag[0] = PROP_TAG(PT_UNICODE, propId); + + ULONG propCount; + LPSPropValue propArray; + HRESULT hResult = ((LPMAPIPROP)entry)->GetProps( + &tagArray, + 0x80000000, // MAPI_UNICODE. + &propCount, + &propArray); + + if (HR_SUCCEEDED(hResult)) + { + unsigned int length = wcslen(propArray->Value.lpszW); + char * value; + if((value = (char*) malloc((length + 1) * sizeof(char))) + == NULL) + { + fprintf(stderr, + "getStringUnicodeProp (addrbook/MsOutlookAddrBookContactQuery.c): \ + \n\tmalloc\n"); + fflush(stderr); + } + if(wcstombs(value, propArray->Value.lpszW, length + 1) != length) + { + fprintf(stderr, + "getStringUnicodeProp (addrbook/MsOutlookAddrBookContactQuery.c): \ + \n\tmbstowcs\n"); + fflush(stderr); + ::free(value); + value = NULL; + return NULL; + } + return value; + } + + return NULL; +} + +/** + * Compares two identifiers to determine if they are part of the same + * Outlook contact. + * + * @param id1 The first identifier. + * @param id2 The second identifier. + * + * @result True if id1 and id2 are two identifiers of the same contact. False + * otherwise. + */ +int MsOutlookAddrBookContactQuery_compareEntryIds( + LPSTR id1, + LPSTR id2) +{ + if(strcmp(id1, id2) == 0) + { + fprintf(stderr, + "CHENZO compareEntryIds: \ + \n\tid1: %s\ + \n\tid2: %s\n", + id1, + id2); + fflush(stderr); + } + //id2 = "ROH"; + int result = 0; + LPMAPISESSION session = MAPISession_getMapiSession(); + + LPMAPIPROP mapiId1; + if((mapiId1 = (LPMAPIPROP) + MsOutlookAddrBookContactQuery_openEntryIdStr(id1)) + == NULL) + { + return result; + } + SBinary contactId1; + contactId1.cb = 0; + MsOutlookAddrBookContactQuery_getBinaryProp(mapiId1, 0x0FFF, &contactId1); + + LPMAPIPROP mapiId2; + if((mapiId2 = (LPMAPIPROP) + MsOutlookAddrBookContactQuery_openEntryIdStr(id2)) + == NULL) + { + return result; + } + SBinary contactId2; + contactId2.cb = 0; + MsOutlookAddrBookContactQuery_getBinaryProp(mapiId2, 0x0FFF, &contactId2); + + if(session != NULL) + { + ULONG res; + if(session->CompareEntryIDs( + contactId1.cb, + (LPENTRYID) contactId1.lpb, + contactId2.cb, + (LPENTRYID) contactId2.lpb, + 0, + &res) != S_OK) + { + fprintf(stderr, + "compareEntryIds (addrbook/MsOutlookAddrBookContactQuery.c): \ + \n\tMAPISession::CompareEntryIDs\n"); + fflush(stderr); + return result; + } + 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); + } + return result; +} diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.h b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.h index 08a83c4..5cb333f 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.h +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.h @@ -7,6 +7,8 @@ #ifndef _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKADDRBOOKCONTACTQUERY_H_ #define _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKADDRBOOKCONTACTQUERY_H_ +#include <mapidefs.h> + int MsOutlookAddrBookContactQuery_IMAPIProp_1DeleteProp (long propId, const char * nativeEntryId); @@ -29,4 +31,10 @@ int MsOutlookAddrBookContactQuery_deleteContact(const char * nativeEntryId); void MsOutlookAddrBookContactQuery_foreachMailUser (const char * query, void * callback, void * callbackObject); +char* MsOutlookAddrBookContactQuery_getStringUnicodeProp + (LPUNKNOWN entry, ULONG propId); + +int MsOutlookAddrBookContactQuery_compareEntryIds + (LPSTR id1, LPSTR id2); + #endif diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx index 13adac6..1e0e751 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx @@ -1,724 +1,724 @@ -/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-#include "MsOutlookAddrBookContactSourceService.h"
-
-#include "com/ComClient.h"
-#include "MAPINotification.h"
-#include "MAPISession.h"
-#include "MAPIBitness.h"
-#include <Tchar.h>
-
-typedef BOOL (STDAPICALLTYPE *LPFBINFROMHEX)(LPSTR, LPBYTE);
-typedef void (STDAPICALLTYPE *LPFREEPROWS)(LPSRowSet);
-typedef void (STDAPICALLTYPE *LPHEXFROMBIN)(LPBYTE, int, LPSTR);
-typedef HRESULT (STDAPICALLTYPE *LPHRALLOCADVISESINK)(LPNOTIFCALLBACK, LPVOID, LPMAPIADVISESINK FAR *);
-typedef HRESULT (STDAPICALLTYPE *LPHRQUERYALLROWS)(LPMAPITABLE, LPSPropTagArray,
-LPSRestriction, LPSSortOrderSet, LONG, LPSRowSet FAR *);
-
-static HANDLE MsOutlookAddrBookContactSourceService_comServerHandle = NULL;
-static LPFBINFROMHEX MsOutlookAddrBookContactSourceService_fBinFromHex;
-static LPFREEPROWS MsOutlookAddrBookContactSourceService_freeProws;
-static LPHEXFROMBIN MsOutlookAddrBookContactSourceService_hexFromBin;
-static LPHRALLOCADVISESINK MsOutlookAddrBookContactSourceService_hrAllocAdviseSink;
-static LPHRQUERYALLROWS MsOutlookAddrBookContactSourceService_hrQueryAllRows;
-static LPMAPIALLOCATEBUFFER
- MsOutlookAddrBookContactSourceService_mapiAllocateBuffer;
-static LPMAPIFREEBUFFER MsOutlookAddrBookContactSourceService_mapiFreeBuffer;
-static LPMAPIINITIALIZE MsOutlookAddrBookContactSourceService_mapiInitialize;
-static LPMAPILOGONEX MsOutlookAddrBookContactSourceService_mapiLogonEx;
-static LPMAPIUNINITIALIZE
- MsOutlookAddrBookContactSourceService_mapiUninitialize;
-static HMODULE MsOutlookAddrBookContactSourceService_hMapiLib = NULL;
-
-static jboolean
-MsOutlookAddrBookContactSourceService_isValidDefaultMailClient
- (LPCTSTR name, DWORD nameLength);
-HRESULT MsOutlookAddrBookContactSourceService_startComServer(void);
-
-HRESULT MsOutlookAddrBookContactSourceService_MAPIInitialize
- (jlong version, jlong flags)
-{
- HKEY regKey;
- HRESULT hResult = MAPI_E_NO_SUPPORT;
-
- /*
- * In the absence of a default e-mail program, MAPIInitialize may show a
- * dialog to notify of the fact. The dialog is undesirable here. Because we
- * implement ContactSourceService for Microsoft Outlook, we will try to
- * mitigate the problem by implementing an ad-hoc check whether Microsoft
- * Outlook is installed.
- */
- if (ERROR_SUCCESS
- == RegOpenKeyEx(
- HKEY_LOCAL_MACHINE,
- _T("Software\\Microsoft\\Office"),
- 0,
- KEY_ENUMERATE_SUB_KEYS,
- ®Key))
- {
- DWORD i = 0;
- TCHAR installRootKeyName[
- 255 // The size limit of key name as documented in MSDN
- + 20 // \Outlook\InstallRoot
- + 1]; // The terminating null character
-
- while (1)
- {
- LONG regEnumKeyEx;
- DWORD subkeyNameLength = 255 + 1;
- LPTSTR str;
- HKEY installRootKey;
- DWORD pathValueType;
- DWORD pathValueSize;
-
- regEnumKeyEx
- = RegEnumKeyEx(
- regKey,
- i,
- installRootKeyName, &subkeyNameLength,
- NULL,
- NULL, NULL,
- NULL);
- if (ERROR_NO_MORE_ITEMS == regEnumKeyEx)
- break;
-
- i++;
- if (ERROR_SUCCESS != regEnumKeyEx)
- continue;
-
- str = installRootKeyName + subkeyNameLength;
- memcpy(str, _T("\\Outlook\\InstallRoot"), 20 * sizeof(TCHAR));
- *(str + 20) = 0;
- if (ERROR_SUCCESS
- == RegOpenKeyEx(
- regKey,
- installRootKeyName,
- 0,
- KEY_QUERY_VALUE,
- &installRootKey))
- {
- if ((ERROR_SUCCESS
- == RegQueryValueEx(
- installRootKey,
- _T("Path"),
- NULL,
- &pathValueType,
- NULL, &pathValueSize))
- && (REG_SZ == pathValueType)
- && pathValueSize)
- {
- LPTSTR pathValue;
-
- // MSDN says "the string may not have been stored with the
- // proper terminating null characters."
- pathValueSize
- += sizeof(TCHAR)
- * (12 // \Outlook.exe
- + 1); // The terminating null character
-
- if (pathValueSize <= sizeof(installRootKeyName))
- pathValue = installRootKeyName;
- else
- {
- pathValue = (LPTSTR)::malloc(pathValueSize);
- if (!pathValue)
- continue;
- }
-
- if (ERROR_SUCCESS
- == RegQueryValueEx(
- installRootKey,
- _T("Path"),
- NULL,
- NULL,
- (LPBYTE) pathValue, &pathValueSize))
- {
- DWORD pathValueLength = pathValueSize / sizeof(TCHAR);
-
- if (pathValueLength)
- {
- DWORD fileAttributes;
-
- str = pathValue + (pathValueLength - 1);
- if (*str)
- str++;
- memcpy(str, _T("\\Outlook.exe"), 12 * sizeof(TCHAR));
- *(str + 12) = 0;
-
- fileAttributes = GetFileAttributes(pathValue);
- if (INVALID_FILE_ATTRIBUTES != fileAttributes)
- hResult = S_OK;
- }
- }
-
- if (pathValue != installRootKeyName)
- free(pathValue);
- }
- RegCloseKey(installRootKey);
- }
- }
- RegCloseKey(regKey);
-
- // Make sure that Microsoft Outlook is the default mail client in order
- // to prevent its dialog in the case of it not being the default mail
- // client.
- if (HR_SUCCEEDED(hResult))
- {
- DWORD defaultValueType;
- // The buffer installRootKeyName is long enough to receive
- // "Microsoft Outlook" so use it in order to not have to allocate
- // more memory.
- LPTSTR defaultValue = (LPTSTR) installRootKeyName;
- DWORD defaultValueCapacity = sizeof(installRootKeyName);
- jboolean checkHKeyLocalMachine;
-
- hResult = MAPI_E_NO_SUPPORT;
- if (ERROR_SUCCESS
- == RegOpenKeyEx(
- HKEY_CURRENT_USER,
- _T("Software\\Clients\\Mail"),
- 0,
- KEY_QUERY_VALUE,
- ®Key))
- {
- DWORD defaultValueSize = defaultValueCapacity;
- LONG regQueryValueEx
- = RegQueryValueEx(
- regKey,
- NULL,
- NULL,
- &defaultValueType,
- (LPBYTE) defaultValue, &defaultValueSize);
-
- switch (regQueryValueEx)
- {
- case ERROR_SUCCESS:
- {
- if (REG_SZ == defaultValueType)
- {
- DWORD defaultValueLength
- = defaultValueSize / sizeof(TCHAR);
-
- if (JNI_TRUE
- == MsOutlookAddrBookContactSourceService_isValidDefaultMailClient(
- defaultValue,
- defaultValueLength))
- {
- checkHKeyLocalMachine = JNI_FALSE;
- if (_tcsnicmp(
- _T("Microsoft Outlook"), defaultValue,
- defaultValueLength)
- == 0)
- hResult = S_OK;
- }
- else
- checkHKeyLocalMachine = JNI_TRUE;
- }
- else
- checkHKeyLocalMachine = JNI_FALSE;
- break;
- }
- case ERROR_FILE_NOT_FOUND:
- checkHKeyLocalMachine = JNI_TRUE;
- break;
- case ERROR_MORE_DATA:
- checkHKeyLocalMachine = JNI_FALSE;
- break;
- default:
- checkHKeyLocalMachine = JNI_FALSE;
- break;
- }
- RegCloseKey(regKey);
- }
- else
- checkHKeyLocalMachine = JNI_TRUE;
- if ((JNI_TRUE == checkHKeyLocalMachine)
- && (ERROR_SUCCESS
- == RegOpenKeyEx(
- HKEY_LOCAL_MACHINE,
- _T("Software\\Clients\\Mail"),
- 0,
- KEY_QUERY_VALUE,
- ®Key)))
- {
- DWORD defaultValueSize = defaultValueCapacity;
- LONG regQueryValueEx
- = RegQueryValueEx(
- regKey,
- NULL,
- NULL,
- &defaultValueType,
- (LPBYTE) defaultValue, &defaultValueSize);
-
- if ((ERROR_SUCCESS == regQueryValueEx)
- && (REG_SZ == defaultValueType))
- {
- DWORD defaultValueLength = defaultValueSize / sizeof(TCHAR);
-
- if ((_tcsnicmp(
- _T("Microsoft Outlook"), defaultValue,
- defaultValueLength)
- == 0)
- && (JNI_TRUE
- == MsOutlookAddrBookContactSourceService_isValidDefaultMailClient(_T("Microsoft Outlook"), 17)))
- hResult = S_OK;
- }
- RegCloseKey(regKey);
- }
- }
- }
-
- // If we've determined that we'd like to go on with MAPI, try to load it.
- if (HR_SUCCEEDED(hResult))
- {
- MsOutlookAddrBookContactSourceService_hMapiLib
- = ::LoadLibrary(_T("mapi32.dll"));
-
- hResult = MAPI_E_NO_SUPPORT;
- if(MsOutlookAddrBookContactSourceService_hMapiLib)
- {
- // get and check function pointers
- MsOutlookAddrBookContactSourceService_mapiInitialize
- = (LPMAPIINITIALIZE) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "MAPIInitialize");
- MsOutlookAddrBookContactSourceService_mapiUninitialize
- = (LPMAPIUNINITIALIZE) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "MAPIUninitialize");
- MsOutlookAddrBookContactSourceService_mapiAllocateBuffer
- = (LPMAPIALLOCATEBUFFER) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "MAPIAllocateBuffer");
- MsOutlookAddrBookContactSourceService_mapiFreeBuffer
- = (LPMAPIFREEBUFFER) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "MAPIFreeBuffer");
- MsOutlookAddrBookContactSourceService_mapiLogonEx
- = (LPMAPILOGONEX) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "MAPILogonEx");
-
- // Depending on mapi32.dll version the following functions must be
- // loaded with or without "...@#".
- MsOutlookAddrBookContactSourceService_fBinFromHex
- = (LPFBINFROMHEX) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "FBinFromHex");
- if(MsOutlookAddrBookContactSourceService_fBinFromHex == NULL)
- {
- MsOutlookAddrBookContactSourceService_fBinFromHex
- = (LPFBINFROMHEX) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "FBinFromHex@8");
- }
- MsOutlookAddrBookContactSourceService_freeProws
- = (LPFREEPROWS) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "FreeProws");
- if(MsOutlookAddrBookContactSourceService_freeProws == NULL)
- {
- MsOutlookAddrBookContactSourceService_freeProws
- = (LPFREEPROWS) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "FreeProws@4");
- }
- MsOutlookAddrBookContactSourceService_hexFromBin
- = (LPHEXFROMBIN) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "HexFromBin");
- if(MsOutlookAddrBookContactSourceService_hexFromBin == NULL)
- {
- MsOutlookAddrBookContactSourceService_hexFromBin
- = (LPHEXFROMBIN) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "HexFromBin@12");
- }
- MsOutlookAddrBookContactSourceService_hrAllocAdviseSink
- = (LPHRALLOCADVISESINK)
- GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "HrAllocAdviseSink");
- if(MsOutlookAddrBookContactSourceService_hrAllocAdviseSink == NULL)
- {
- MsOutlookAddrBookContactSourceService_hrAllocAdviseSink
- = (LPHRALLOCADVISESINK)
- GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "HrAllocAdviseSink@12");
- }
- MsOutlookAddrBookContactSourceService_hrQueryAllRows
- = (LPHRQUERYALLROWS) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "HrQueryAllRows");
- if(MsOutlookAddrBookContactSourceService_hrQueryAllRows == NULL)
- {
- MsOutlookAddrBookContactSourceService_hrQueryAllRows
- = (LPHRQUERYALLROWS) GetProcAddress(
- MsOutlookAddrBookContactSourceService_hMapiLib,
- "HrQueryAllRows@24");
- }
-
- if (MsOutlookAddrBookContactSourceService_mapiInitialize
- && MsOutlookAddrBookContactSourceService_mapiUninitialize
- && MsOutlookAddrBookContactSourceService_mapiAllocateBuffer
- && MsOutlookAddrBookContactSourceService_mapiFreeBuffer
- && MsOutlookAddrBookContactSourceService_mapiLogonEx
- && MsOutlookAddrBookContactSourceService_fBinFromHex
- && MsOutlookAddrBookContactSourceService_freeProws
- && MsOutlookAddrBookContactSourceService_hexFromBin
- && MsOutlookAddrBookContactSourceService_hrAllocAdviseSink
- && MsOutlookAddrBookContactSourceService_hrQueryAllRows)
- {
- MAPIINIT_0 mapiInit = { (ULONG) version, (ULONG) flags };
-
- // Opening MAPI changes the working directory. Make a backup of
- // the current directory, login to MAPI and restore it
- DWORD dwSize = ::GetCurrentDirectory(0, NULL);
- if (dwSize > 0)
- {
- LPTSTR lpszWorkingDir
- = (LPTSTR)::malloc(dwSize*sizeof(TCHAR));
- DWORD dwResult
- = ::GetCurrentDirectory(dwSize, lpszWorkingDir);
- if (dwResult != 0)
- {
- MAPISession_lock();
- hResult
- = MsOutlookAddrBookContactSourceService_mapiInitialize(
- &mapiInit);
-
- if(HR_SUCCEEDED(hResult)
- && MAPISession_getMapiSession() == NULL)
- {
- LPMAPISESSION mapiSession = NULL;
- hResult = MsOutlookAddrBook_mapiLogonEx(
- 0,
- NULL, NULL,
- MAPI_EXTENDED
- | MAPI_NO_MAIL
- | MAPI_USE_DEFAULT,
- &mapiSession);
- // Register the notification of contact changed,
- // created and deleted.
- MAPINotification_registerNotifyAllMsgStores(
- mapiSession);
- }
- ::SetCurrentDirectory(lpszWorkingDir);
- MAPISession_unlock();
- }
- else
- {
- hResult = HRESULT_FROM_WIN32(::GetLastError());
- }
-
- ::free(lpszWorkingDir);
- }
- else
- {
- hResult = HRESULT_FROM_WIN32(::GetLastError());
- }
- }
- }
- }
-
- if (HR_FAILED(hResult))
- {
- if(MsOutlookAddrBookContactSourceService_hMapiLib)
- {
- FreeLibrary(MsOutlookAddrBookContactSourceService_hMapiLib);
- MsOutlookAddrBookContactSourceService_hMapiLib = NULL;
- }
- }
-
- return hResult;
-}
-
-/**
- * Starts the COM server.
- *
- * @return S_OK if eveything was fine. E_FAIL otherwise.
- */
-HRESULT MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer(void)
-{
- HRESULT hr = E_FAIL;
-
- MAPISession_lock();
-
- // Start COM service
- hr = MsOutlookAddrBookContactSourceService_startComServer();
- // Start COM client
- ComClient_start();
-
- MAPISession_unlock();
-
- return hr;
-}
-
-void MsOutlookAddrBookContactSourceService_MAPIUninitialize(void)
-{
- MAPISession_lock();
-
- LPMAPISESSION mapiSession = MAPISession_getMapiSession();
- if(mapiSession != NULL)
- {
- MAPINotification_unregisterNotifyAllMsgStores();
- mapiSession->Logoff(0, 0, 0);
- mapiSession->Release();
- MAPISession_setMapiSession(NULL);
- }
-
- if(MsOutlookAddrBookContactSourceService_hMapiLib)
- {
- MsOutlookAddrBookContactSourceService_mapiUninitialize();
-
- MsOutlookAddrBookContactSourceService_mapiInitialize = NULL;
- MsOutlookAddrBookContactSourceService_mapiUninitialize = NULL;
- MsOutlookAddrBookContactSourceService_mapiAllocateBuffer = NULL;
- MsOutlookAddrBookContactSourceService_mapiFreeBuffer = NULL;
- MsOutlookAddrBookContactSourceService_mapiLogonEx = NULL;
- MsOutlookAddrBookContactSourceService_fBinFromHex = NULL;
- MsOutlookAddrBookContactSourceService_freeProws = NULL;
- MsOutlookAddrBookContactSourceService_hexFromBin = NULL;
- MsOutlookAddrBookContactSourceService_hrAllocAdviseSink = NULL;
- MsOutlookAddrBookContactSourceService_hrQueryAllRows = NULL;
- ::FreeLibrary(MsOutlookAddrBookContactSourceService_hMapiLib);
- MsOutlookAddrBookContactSourceService_hMapiLib = NULL;
- }
-
- MAPISession_unlock();
-}
-
-/**
- * Stops the COM server.
- */
-void MsOutlookAddrBookContactSourceService_MAPIUninitializeCOMServer(void)
-{
- if(MsOutlookAddrBookContactSourceService_comServerHandle != NULL)
- {
- TerminateProcess(
- MsOutlookAddrBookContactSourceService_comServerHandle,
- 1);
-
- CloseHandle(MsOutlookAddrBookContactSourceService_comServerHandle);
- MsOutlookAddrBookContactSourceService_comServerHandle = NULL;
- }
- ComClient_stop();
-}
-
-/**
- * Initializes the plugin but from the COM server point of view: natif side, no
- * java available here.
- *
- * @param version The version of MAPI to load.
- * @param flags The option choosen to load the MAPI to lib.
- * @param deletedMethod A function pointer used as a callback on notification
- * from outlook when a contact has been removed.
- * @param insertedMethod A function pointer used as a callback on notification
- * from outlook when a contact has been added.
- * @param updatedMethod A function pointer used as a callback on notification
- * from outlook when a contact has been modified.
- *
- * @return S_OK if everything was alright.
- */
-HRESULT MsOutlookAddrBookContactSourceService_NativeMAPIInitialize
- (jlong version, jlong flags,
- void * deletedMethod, void * insertedMethod, void * updatedMethod)
-{
- MAPINotification_registerNativeNotificationsDelegate(
- deletedMethod, insertedMethod, updatedMethod);
-
- return MsOutlookAddrBookContactSourceService_MAPIInitialize(version, flags);
-}
-
-void MsOutlookAddrBookContactSourceService_NativeMAPIUninitialize(void)
-{
- MAPINotification_unregisterNativeNotificationsDelegate();
-
- MsOutlookAddrBookContactSourceService_MAPIUninitialize();
-}
-
-static jboolean
-MsOutlookAddrBookContactSourceService_isValidDefaultMailClient
- (LPCTSTR name, DWORD nameLength)
-{
- jboolean validDefaultMailClient = JNI_FALSE;
-
- if ((0 != nameLength) && (0 != name[0]))
- {
- LPTSTR str;
- TCHAR keyName[
- 22 /* Software\Clients\Mail\ */
- + 255
- + 1 /* The terminating null character */];
- HKEY key;
-
- str = keyName;
- _tcsncpy(str, _T("Software\\Clients\\Mail\\"), 22);
- str += 22;
- if (nameLength > 255)
- nameLength = 255;
- _tcsncpy(str, name, nameLength);
- *(str + nameLength) = 0;
-
- if (ERROR_SUCCESS
- == RegOpenKeyEx(
- HKEY_LOCAL_MACHINE,
- keyName,
- 0,
- KEY_QUERY_VALUE,
- &key))
- {
- validDefaultMailClient = JNI_TRUE;
- RegCloseKey(key);
- }
- }
- return validDefaultMailClient;
-}
-
-/**
- * Starts the COM server.
- *
- * @param S_OK if the server started correctly. E_FAIL otherwise.
- */
-HRESULT MsOutlookAddrBookContactSourceService_startComServer(void)
-{
- // Start COM service
- char applicationName32[] = "jmsoutlookaddrbookcomserver32.exe";
- char applicationName64[] = "jmsoutlookaddrbookcomserver64.exe";
- char * applicationName = applicationName32;
- if(MAPIBitness_getOutlookBitnessVersion() == 64)
- {
- applicationName = applicationName64;
- }
- int applicationNameLength = strlen(applicationName);
- char currentDirectory[FILENAME_MAX - applicationNameLength - 8];
- GetCurrentDirectory(
- FILENAME_MAX - applicationNameLength - 8,
- currentDirectory);
- char comServer[FILENAME_MAX];
- sprintf(comServer, "%s/native/%s", currentDirectory, applicationName);
-
- STARTUPINFO startupInfo;
- PROCESS_INFORMATION processInfo;
- memset(&startupInfo, 0, sizeof(startupInfo));
- memset(&processInfo, 0, sizeof(processInfo));
- startupInfo.dwFlags = STARTF_USESHOWWINDOW;
- startupInfo.wShowWindow = SW_HIDE;
-
- // Test 2 files: 0 for the build version, 1 for the git source version.
- char * serverExec[2];
- serverExec[0] = comServer;
- serverExec[1] = applicationName;
- for(int i = 0; i < 2; ++i)
- {
- // Create the COM server
- if(CreateProcess(
- NULL,
- serverExec[i],
- NULL, NULL, false, 0, NULL, NULL,
- &startupInfo,
- &processInfo))
- {
- MsOutlookAddrBookContactSourceService_comServerHandle
- = processInfo.hProcess;
-
- return S_OK;
- }
- }
-
- return E_FAIL;
-}
-
-BOOL MsOutlookAddrBook_fBinFromHex(LPSTR lpsz, LPBYTE lpb)
-{
- return MsOutlookAddrBookContactSourceService_fBinFromHex(lpsz, lpb);
-}
-
-void MsOutlookAddrBook_freeProws(LPSRowSet lpRows)
-{
- MsOutlookAddrBookContactSourceService_freeProws(lpRows);
-}
-
-void MsOutlookAddrBook_hexFromBin(LPBYTE pb, int cb, LPSTR sz)
-{
- MsOutlookAddrBookContactSourceService_hexFromBin(pb, cb, sz);
-}
-
-void
-MsOutlookAddrBook_hrAllocAdviseSink
- (LPNOTIFCALLBACK lpfnCallback, LPVOID lpvContext, LPMAPIADVISESINK*
- lppAdviseSink)
-{
- MsOutlookAddrBookContactSourceService_hrAllocAdviseSink(
- lpfnCallback,
- lpvContext,
- lppAdviseSink);
-}
-
-HRESULT
-MsOutlookAddrBook_hrQueryAllRows
- (LPMAPITABLE lpTable, LPSPropTagArray lpPropTags,
- LPSRestriction lpRestriction, LPSSortOrderSet lpSortOrderSet,
- LONG crowsMax, LPSRowSet* lppRows)
-{
- return MsOutlookAddrBookContactSourceService_hrQueryAllRows(
- lpTable,
- lpPropTags,
- lpRestriction,
- lpSortOrderSet,
- crowsMax,
- lppRows);
-}
-
-SCODE
-MsOutlookAddrBook_mapiAllocateBuffer(ULONG size, LPVOID FAR *buffer)
-{
- return
- MsOutlookAddrBookContactSourceService_mapiAllocateBuffer(size, buffer);
-}
-
-ULONG
-MsOutlookAddrBook_mapiFreeBuffer(LPVOID buffer)
-{
- return MsOutlookAddrBookContactSourceService_mapiFreeBuffer(buffer);
-}
-
-HRESULT
-MsOutlookAddrBook_mapiLogonEx
- (ULONG_PTR uiParam,
- LPTSTR profileName, LPTSTR password,
- FLAGS flags,
- LPMAPISESSION FAR *mapiSession)
-{
- HRESULT hResult;
-
- MAPISession_lock();
- LPMAPISESSION currentMapiSession = MAPISession_getMapiSession();
- if (currentMapiSession != NULL)
- hResult = S_OK;
- else
- {
- hResult
- = MsOutlookAddrBookContactSourceService_mapiLogonEx(
- uiParam,
- profileName, password,
- flags,
- ¤tMapiSession);
-
- MAPISession_setMapiSession(currentMapiSession);
- }
-
- if (HR_SUCCEEDED(hResult))
- {
- *mapiSession = currentMapiSession;
- }
-
- MAPISession_unlock();
- return hResult;
-}
+/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +#include "MsOutlookAddrBookContactSourceService.h" + +#include "com/ComClient.h" +#include "MAPINotification.h" +#include "MAPISession.h" +#include "MAPIBitness.h" +#include <Tchar.h> + +typedef BOOL (STDAPICALLTYPE *LPFBINFROMHEX)(LPSTR, LPBYTE); +typedef void (STDAPICALLTYPE *LPFREEPROWS)(LPSRowSet); +typedef void (STDAPICALLTYPE *LPHEXFROMBIN)(LPBYTE, int, LPSTR); +typedef HRESULT (STDAPICALLTYPE *LPHRALLOCADVISESINK)(LPNOTIFCALLBACK, LPVOID, LPMAPIADVISESINK FAR *); +typedef HRESULT (STDAPICALLTYPE *LPHRQUERYALLROWS)(LPMAPITABLE, LPSPropTagArray, +LPSRestriction, LPSSortOrderSet, LONG, LPSRowSet FAR *); + +static HANDLE MsOutlookAddrBookContactSourceService_comServerHandle = NULL; +static LPFBINFROMHEX MsOutlookAddrBookContactSourceService_fBinFromHex; +static LPFREEPROWS MsOutlookAddrBookContactSourceService_freeProws; +static LPHEXFROMBIN MsOutlookAddrBookContactSourceService_hexFromBin; +static LPHRALLOCADVISESINK MsOutlookAddrBookContactSourceService_hrAllocAdviseSink; +static LPHRQUERYALLROWS MsOutlookAddrBookContactSourceService_hrQueryAllRows; +static LPMAPIALLOCATEBUFFER + MsOutlookAddrBookContactSourceService_mapiAllocateBuffer; +static LPMAPIFREEBUFFER MsOutlookAddrBookContactSourceService_mapiFreeBuffer; +static LPMAPIINITIALIZE MsOutlookAddrBookContactSourceService_mapiInitialize; +static LPMAPILOGONEX MsOutlookAddrBookContactSourceService_mapiLogonEx; +static LPMAPIUNINITIALIZE + MsOutlookAddrBookContactSourceService_mapiUninitialize; +static HMODULE MsOutlookAddrBookContactSourceService_hMapiLib = NULL; + +static jboolean +MsOutlookAddrBookContactSourceService_isValidDefaultMailClient + (LPCTSTR name, DWORD nameLength); +HRESULT MsOutlookAddrBookContactSourceService_startComServer(void); + +HRESULT MsOutlookAddrBookContactSourceService_MAPIInitialize + (jlong version, jlong flags) +{ + HKEY regKey; + HRESULT hResult = MAPI_E_NO_SUPPORT; + + /* + * In the absence of a default e-mail program, MAPIInitialize may show a + * dialog to notify of the fact. The dialog is undesirable here. Because we + * implement ContactSourceService for Microsoft Outlook, we will try to + * mitigate the problem by implementing an ad-hoc check whether Microsoft + * Outlook is installed. + */ + if (ERROR_SUCCESS + == RegOpenKeyEx( + HKEY_LOCAL_MACHINE, + _T("Software\\Microsoft\\Office"), + 0, + KEY_ENUMERATE_SUB_KEYS, + ®Key)) + { + DWORD i = 0; + TCHAR installRootKeyName[ + 255 // The size limit of key name as documented in MSDN + + 20 // \Outlook\InstallRoot + + 1]; // The terminating null character + + while (1) + { + LONG regEnumKeyEx; + DWORD subkeyNameLength = 255 + 1; + LPTSTR str; + HKEY installRootKey; + DWORD pathValueType; + DWORD pathValueSize; + + regEnumKeyEx + = RegEnumKeyEx( + regKey, + i, + installRootKeyName, &subkeyNameLength, + NULL, + NULL, NULL, + NULL); + if (ERROR_NO_MORE_ITEMS == regEnumKeyEx) + break; + + i++; + if (ERROR_SUCCESS != regEnumKeyEx) + continue; + + str = installRootKeyName + subkeyNameLength; + memcpy(str, _T("\\Outlook\\InstallRoot"), 20 * sizeof(TCHAR)); + *(str + 20) = 0; + if (ERROR_SUCCESS + == RegOpenKeyEx( + regKey, + installRootKeyName, + 0, + KEY_QUERY_VALUE, + &installRootKey)) + { + if ((ERROR_SUCCESS + == RegQueryValueEx( + installRootKey, + _T("Path"), + NULL, + &pathValueType, + NULL, &pathValueSize)) + && (REG_SZ == pathValueType) + && pathValueSize) + { + LPTSTR pathValue; + + // MSDN says "the string may not have been stored with the + // proper terminating null characters." + pathValueSize + += sizeof(TCHAR) + * (12 // \Outlook.exe + + 1); // The terminating null character + + if (pathValueSize <= sizeof(installRootKeyName)) + pathValue = installRootKeyName; + else + { + pathValue = (LPTSTR)::malloc(pathValueSize); + if (!pathValue) + continue; + } + + if (ERROR_SUCCESS + == RegQueryValueEx( + installRootKey, + _T("Path"), + NULL, + NULL, + (LPBYTE) pathValue, &pathValueSize)) + { + DWORD pathValueLength = pathValueSize / sizeof(TCHAR); + + if (pathValueLength) + { + DWORD fileAttributes; + + str = pathValue + (pathValueLength - 1); + if (*str) + str++; + memcpy(str, _T("\\Outlook.exe"), 12 * sizeof(TCHAR)); + *(str + 12) = 0; + + fileAttributes = GetFileAttributes(pathValue); + if (INVALID_FILE_ATTRIBUTES != fileAttributes) + hResult = S_OK; + } + } + + if (pathValue != installRootKeyName) + free(pathValue); + } + RegCloseKey(installRootKey); + } + } + RegCloseKey(regKey); + + // Make sure that Microsoft Outlook is the default mail client in order + // to prevent its dialog in the case of it not being the default mail + // client. + if (HR_SUCCEEDED(hResult)) + { + DWORD defaultValueType; + // The buffer installRootKeyName is long enough to receive + // "Microsoft Outlook" so use it in order to not have to allocate + // more memory. + LPTSTR defaultValue = (LPTSTR) installRootKeyName; + DWORD defaultValueCapacity = sizeof(installRootKeyName); + jboolean checkHKeyLocalMachine; + + hResult = MAPI_E_NO_SUPPORT; + if (ERROR_SUCCESS + == RegOpenKeyEx( + HKEY_CURRENT_USER, + _T("Software\\Clients\\Mail"), + 0, + KEY_QUERY_VALUE, + ®Key)) + { + DWORD defaultValueSize = defaultValueCapacity; + LONG regQueryValueEx + = RegQueryValueEx( + regKey, + NULL, + NULL, + &defaultValueType, + (LPBYTE) defaultValue, &defaultValueSize); + + switch (regQueryValueEx) + { + case ERROR_SUCCESS: + { + if (REG_SZ == defaultValueType) + { + DWORD defaultValueLength + = defaultValueSize / sizeof(TCHAR); + + if (JNI_TRUE + == MsOutlookAddrBookContactSourceService_isValidDefaultMailClient( + defaultValue, + defaultValueLength)) + { + checkHKeyLocalMachine = JNI_FALSE; + if (_tcsnicmp( + _T("Microsoft Outlook"), defaultValue, + defaultValueLength) + == 0) + hResult = S_OK; + } + else + checkHKeyLocalMachine = JNI_TRUE; + } + else + checkHKeyLocalMachine = JNI_FALSE; + break; + } + case ERROR_FILE_NOT_FOUND: + checkHKeyLocalMachine = JNI_TRUE; + break; + case ERROR_MORE_DATA: + checkHKeyLocalMachine = JNI_FALSE; + break; + default: + checkHKeyLocalMachine = JNI_FALSE; + break; + } + RegCloseKey(regKey); + } + else + checkHKeyLocalMachine = JNI_TRUE; + if ((JNI_TRUE == checkHKeyLocalMachine) + && (ERROR_SUCCESS + == RegOpenKeyEx( + HKEY_LOCAL_MACHINE, + _T("Software\\Clients\\Mail"), + 0, + KEY_QUERY_VALUE, + ®Key))) + { + DWORD defaultValueSize = defaultValueCapacity; + LONG regQueryValueEx + = RegQueryValueEx( + regKey, + NULL, + NULL, + &defaultValueType, + (LPBYTE) defaultValue, &defaultValueSize); + + if ((ERROR_SUCCESS == regQueryValueEx) + && (REG_SZ == defaultValueType)) + { + DWORD defaultValueLength = defaultValueSize / sizeof(TCHAR); + + if ((_tcsnicmp( + _T("Microsoft Outlook"), defaultValue, + defaultValueLength) + == 0) + && (JNI_TRUE + == MsOutlookAddrBookContactSourceService_isValidDefaultMailClient(_T("Microsoft Outlook"), 17))) + hResult = S_OK; + } + RegCloseKey(regKey); + } + } + } + + // If we've determined that we'd like to go on with MAPI, try to load it. + if (HR_SUCCEEDED(hResult)) + { + MsOutlookAddrBookContactSourceService_hMapiLib + = ::LoadLibrary(_T("mapi32.dll")); + + hResult = MAPI_E_NO_SUPPORT; + if(MsOutlookAddrBookContactSourceService_hMapiLib) + { + // get and check function pointers + MsOutlookAddrBookContactSourceService_mapiInitialize + = (LPMAPIINITIALIZE) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "MAPIInitialize"); + MsOutlookAddrBookContactSourceService_mapiUninitialize + = (LPMAPIUNINITIALIZE) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "MAPIUninitialize"); + MsOutlookAddrBookContactSourceService_mapiAllocateBuffer + = (LPMAPIALLOCATEBUFFER) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "MAPIAllocateBuffer"); + MsOutlookAddrBookContactSourceService_mapiFreeBuffer + = (LPMAPIFREEBUFFER) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "MAPIFreeBuffer"); + MsOutlookAddrBookContactSourceService_mapiLogonEx + = (LPMAPILOGONEX) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "MAPILogonEx"); + + // Depending on mapi32.dll version the following functions must be + // loaded with or without "...@#". + MsOutlookAddrBookContactSourceService_fBinFromHex + = (LPFBINFROMHEX) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "FBinFromHex"); + if(MsOutlookAddrBookContactSourceService_fBinFromHex == NULL) + { + MsOutlookAddrBookContactSourceService_fBinFromHex + = (LPFBINFROMHEX) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "FBinFromHex@8"); + } + MsOutlookAddrBookContactSourceService_freeProws + = (LPFREEPROWS) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "FreeProws"); + if(MsOutlookAddrBookContactSourceService_freeProws == NULL) + { + MsOutlookAddrBookContactSourceService_freeProws + = (LPFREEPROWS) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "FreeProws@4"); + } + MsOutlookAddrBookContactSourceService_hexFromBin + = (LPHEXFROMBIN) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "HexFromBin"); + if(MsOutlookAddrBookContactSourceService_hexFromBin == NULL) + { + MsOutlookAddrBookContactSourceService_hexFromBin + = (LPHEXFROMBIN) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "HexFromBin@12"); + } + MsOutlookAddrBookContactSourceService_hrAllocAdviseSink + = (LPHRALLOCADVISESINK) + GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "HrAllocAdviseSink"); + if(MsOutlookAddrBookContactSourceService_hrAllocAdviseSink == NULL) + { + MsOutlookAddrBookContactSourceService_hrAllocAdviseSink + = (LPHRALLOCADVISESINK) + GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "HrAllocAdviseSink@12"); + } + MsOutlookAddrBookContactSourceService_hrQueryAllRows + = (LPHRQUERYALLROWS) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "HrQueryAllRows"); + if(MsOutlookAddrBookContactSourceService_hrQueryAllRows == NULL) + { + MsOutlookAddrBookContactSourceService_hrQueryAllRows + = (LPHRQUERYALLROWS) GetProcAddress( + MsOutlookAddrBookContactSourceService_hMapiLib, + "HrQueryAllRows@24"); + } + + if (MsOutlookAddrBookContactSourceService_mapiInitialize + && MsOutlookAddrBookContactSourceService_mapiUninitialize + && MsOutlookAddrBookContactSourceService_mapiAllocateBuffer + && MsOutlookAddrBookContactSourceService_mapiFreeBuffer + && MsOutlookAddrBookContactSourceService_mapiLogonEx + && MsOutlookAddrBookContactSourceService_fBinFromHex + && MsOutlookAddrBookContactSourceService_freeProws + && MsOutlookAddrBookContactSourceService_hexFromBin + && MsOutlookAddrBookContactSourceService_hrAllocAdviseSink + && MsOutlookAddrBookContactSourceService_hrQueryAllRows) + { + MAPIINIT_0 mapiInit = { (ULONG) version, (ULONG) flags }; + + // Opening MAPI changes the working directory. Make a backup of + // the current directory, login to MAPI and restore it + DWORD dwSize = ::GetCurrentDirectory(0, NULL); + if (dwSize > 0) + { + LPTSTR lpszWorkingDir + = (LPTSTR)::malloc(dwSize*sizeof(TCHAR)); + DWORD dwResult + = ::GetCurrentDirectory(dwSize, lpszWorkingDir); + if (dwResult != 0) + { + MAPISession_lock(); + hResult + = MsOutlookAddrBookContactSourceService_mapiInitialize( + &mapiInit); + + if(HR_SUCCEEDED(hResult) + && MAPISession_getMapiSession() == NULL) + { + LPMAPISESSION mapiSession = NULL; + hResult = MsOutlookAddrBook_mapiLogonEx( + 0, + NULL, NULL, + MAPI_EXTENDED + | MAPI_NO_MAIL + | MAPI_USE_DEFAULT, + &mapiSession); + // Register the notification of contact changed, + // created and deleted. + MAPINotification_registerNotifyAllMsgStores( + mapiSession); + } + ::SetCurrentDirectory(lpszWorkingDir); + MAPISession_unlock(); + } + else + { + hResult = HRESULT_FROM_WIN32(::GetLastError()); + } + + ::free(lpszWorkingDir); + } + else + { + hResult = HRESULT_FROM_WIN32(::GetLastError()); + } + } + } + } + + if (HR_FAILED(hResult)) + { + if(MsOutlookAddrBookContactSourceService_hMapiLib) + { + FreeLibrary(MsOutlookAddrBookContactSourceService_hMapiLib); + MsOutlookAddrBookContactSourceService_hMapiLib = NULL; + } + } + + return hResult; +} + +/** + * Starts the COM server. + * + * @return S_OK if eveything was fine. E_FAIL otherwise. + */ +HRESULT MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer(void) +{ + HRESULT hr = E_FAIL; + + MAPISession_lock(); + + // Start COM service + hr = MsOutlookAddrBookContactSourceService_startComServer(); + // Start COM client + ComClient_start(); + + MAPISession_unlock(); + + return hr; +} + +void MsOutlookAddrBookContactSourceService_MAPIUninitialize(void) +{ + MAPISession_lock(); + + LPMAPISESSION mapiSession = MAPISession_getMapiSession(); + if(mapiSession != NULL) + { + MAPINotification_unregisterNotifyAllMsgStores(); + mapiSession->Logoff(0, 0, 0); + mapiSession->Release(); + MAPISession_setMapiSession(NULL); + } + + if(MsOutlookAddrBookContactSourceService_hMapiLib) + { + MsOutlookAddrBookContactSourceService_mapiUninitialize(); + + MsOutlookAddrBookContactSourceService_mapiInitialize = NULL; + MsOutlookAddrBookContactSourceService_mapiUninitialize = NULL; + MsOutlookAddrBookContactSourceService_mapiAllocateBuffer = NULL; + MsOutlookAddrBookContactSourceService_mapiFreeBuffer = NULL; + MsOutlookAddrBookContactSourceService_mapiLogonEx = NULL; + MsOutlookAddrBookContactSourceService_fBinFromHex = NULL; + MsOutlookAddrBookContactSourceService_freeProws = NULL; + MsOutlookAddrBookContactSourceService_hexFromBin = NULL; + MsOutlookAddrBookContactSourceService_hrAllocAdviseSink = NULL; + MsOutlookAddrBookContactSourceService_hrQueryAllRows = NULL; + ::FreeLibrary(MsOutlookAddrBookContactSourceService_hMapiLib); + MsOutlookAddrBookContactSourceService_hMapiLib = NULL; + } + + MAPISession_unlock(); +} + +/** + * Stops the COM server. + */ +void MsOutlookAddrBookContactSourceService_MAPIUninitializeCOMServer(void) +{ + if(MsOutlookAddrBookContactSourceService_comServerHandle != NULL) + { + TerminateProcess( + MsOutlookAddrBookContactSourceService_comServerHandle, + 1); + + CloseHandle(MsOutlookAddrBookContactSourceService_comServerHandle); + MsOutlookAddrBookContactSourceService_comServerHandle = NULL; + } + ComClient_stop(); +} + +/** + * Initializes the plugin but from the COM server point of view: natif side, no + * java available here. + * + * @param version The version of MAPI to load. + * @param flags The option choosen to load the MAPI to lib. + * @param deletedMethod A function pointer used as a callback on notification + * from outlook when a contact has been removed. + * @param insertedMethod A function pointer used as a callback on notification + * from outlook when a contact has been added. + * @param updatedMethod A function pointer used as a callback on notification + * from outlook when a contact has been modified. + * + * @return S_OK if everything was alright. + */ +HRESULT MsOutlookAddrBookContactSourceService_NativeMAPIInitialize + (jlong version, jlong flags, + void * deletedMethod, void * insertedMethod, void * updatedMethod) +{ + MAPINotification_registerNativeNotificationsDelegate( + deletedMethod, insertedMethod, updatedMethod); + + return MsOutlookAddrBookContactSourceService_MAPIInitialize(version, flags); +} + +void MsOutlookAddrBookContactSourceService_NativeMAPIUninitialize(void) +{ + MAPINotification_unregisterNativeNotificationsDelegate(); + + MsOutlookAddrBookContactSourceService_MAPIUninitialize(); +} + +static jboolean +MsOutlookAddrBookContactSourceService_isValidDefaultMailClient + (LPCTSTR name, DWORD nameLength) +{ + jboolean validDefaultMailClient = JNI_FALSE; + + if ((0 != nameLength) && (0 != name[0])) + { + LPTSTR str; + TCHAR keyName[ + 22 /* Software\Clients\Mail\ */ + + 255 + + 1 /* The terminating null character */]; + HKEY key; + + str = keyName; + _tcsncpy(str, _T("Software\\Clients\\Mail\\"), 22); + str += 22; + if (nameLength > 255) + nameLength = 255; + _tcsncpy(str, name, nameLength); + *(str + nameLength) = 0; + + if (ERROR_SUCCESS + == RegOpenKeyEx( + HKEY_LOCAL_MACHINE, + keyName, + 0, + KEY_QUERY_VALUE, + &key)) + { + validDefaultMailClient = JNI_TRUE; + RegCloseKey(key); + } + } + return validDefaultMailClient; +} + +/** + * Starts the COM server. + * + * @param S_OK if the server started correctly. E_FAIL otherwise. + */ +HRESULT MsOutlookAddrBookContactSourceService_startComServer(void) +{ + // Start COM service + char applicationName32[] = "jmsoutlookaddrbookcomserver32.exe"; + char applicationName64[] = "jmsoutlookaddrbookcomserver64.exe"; + char * applicationName = applicationName32; + if(MAPIBitness_getOutlookBitnessVersion() == 64) + { + applicationName = applicationName64; + } + int applicationNameLength = strlen(applicationName); + char currentDirectory[FILENAME_MAX - applicationNameLength - 8]; + GetCurrentDirectory( + FILENAME_MAX - applicationNameLength - 8, + currentDirectory); + char comServer[FILENAME_MAX]; + sprintf(comServer, "%s/native/%s", currentDirectory, applicationName); + + STARTUPINFO startupInfo; + PROCESS_INFORMATION processInfo; + memset(&startupInfo, 0, sizeof(startupInfo)); + memset(&processInfo, 0, sizeof(processInfo)); + startupInfo.dwFlags = STARTF_USESHOWWINDOW; + startupInfo.wShowWindow = SW_HIDE; + + // Test 2 files: 0 for the build version, 1 for the git source version. + char * serverExec[2]; + serverExec[0] = comServer; + serverExec[1] = applicationName; + for(int i = 0; i < 2; ++i) + { + // Create the COM server + if(CreateProcess( + NULL, + serverExec[i], + NULL, NULL, false, 0, NULL, NULL, + &startupInfo, + &processInfo)) + { + MsOutlookAddrBookContactSourceService_comServerHandle + = processInfo.hProcess; + + return S_OK; + } + } + + return E_FAIL; +} + +BOOL MsOutlookAddrBook_fBinFromHex(LPSTR lpsz, LPBYTE lpb) +{ + return MsOutlookAddrBookContactSourceService_fBinFromHex(lpsz, lpb); +} + +void MsOutlookAddrBook_freeProws(LPSRowSet lpRows) +{ + MsOutlookAddrBookContactSourceService_freeProws(lpRows); +} + +void MsOutlookAddrBook_hexFromBin(LPBYTE pb, int cb, LPSTR sz) +{ + MsOutlookAddrBookContactSourceService_hexFromBin(pb, cb, sz); +} + +void +MsOutlookAddrBook_hrAllocAdviseSink + (LPNOTIFCALLBACK lpfnCallback, LPVOID lpvContext, LPMAPIADVISESINK* + lppAdviseSink) +{ + MsOutlookAddrBookContactSourceService_hrAllocAdviseSink( + lpfnCallback, + lpvContext, + lppAdviseSink); +} + +HRESULT +MsOutlookAddrBook_hrQueryAllRows + (LPMAPITABLE lpTable, LPSPropTagArray lpPropTags, + LPSRestriction lpRestriction, LPSSortOrderSet lpSortOrderSet, + LONG crowsMax, LPSRowSet* lppRows) +{ + return MsOutlookAddrBookContactSourceService_hrQueryAllRows( + lpTable, + lpPropTags, + lpRestriction, + lpSortOrderSet, + crowsMax, + lppRows); +} + +SCODE +MsOutlookAddrBook_mapiAllocateBuffer(ULONG size, LPVOID FAR *buffer) +{ + return + MsOutlookAddrBookContactSourceService_mapiAllocateBuffer(size, buffer); +} + +ULONG +MsOutlookAddrBook_mapiFreeBuffer(LPVOID buffer) +{ + return MsOutlookAddrBookContactSourceService_mapiFreeBuffer(buffer); +} + +HRESULT +MsOutlookAddrBook_mapiLogonEx + (ULONG_PTR uiParam, + LPTSTR profileName, LPTSTR password, + FLAGS flags, + LPMAPISESSION FAR *mapiSession) +{ + HRESULT hResult; + + MAPISession_lock(); + LPMAPISESSION currentMapiSession = MAPISession_getMapiSession(); + if (currentMapiSession != NULL) + hResult = S_OK; + else + { + hResult + = MsOutlookAddrBookContactSourceService_mapiLogonEx( + uiParam, + profileName, password, + flags, + ¤tMapiSession); + + MAPISession_setMapiSession(currentMapiSession); + } + + if (HR_SUCCEEDED(hResult)) + { + *mapiSession = currentMapiSession; + } + + MAPISession_unlock(); + return hResult; +} diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.h b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.h index dcd1e83..2d34e11 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.h +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.h @@ -1,62 +1,62 @@ -/*
- * 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_MSOUTLOOKADDRBOOKCONTACTSOURCESERVICE_H_
-#define _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKADDRBOOKCONTACTSOURCESERVICE_H_
-
-#include <jni.h>
-#include <mapix.h>
-
-BOOL MsOutlookAddrBook_fBinFromHex(LPSTR lpsz, LPBYTE lpb);
-#define FBinFromHex MsOutlookAddrBook_fBinFromHex
-
-void MsOutlookAddrBook_freeProws(LPSRowSet lpRows);
-#define FreeProws MsOutlookAddrBook_freeProws
-
-void MsOutlookAddrBook_hexFromBin(LPBYTE pb, int cb, LPSTR sz);
-#define HexFromBin MsOutlookAddrBook_hexFromBin
-
-void MsOutlookAddrBook_hrAllocAdviseSink
- (LPNOTIFCALLBACK lpfnCallback, LPVOID lpvContext,
- LPMAPIADVISESINK* lppAdviseSink);
-#define HrAllocAdviseSink MsOutlookAddrBook_hrAllocAdviseSink
-
-HRESULT MsOutlookAddrBook_hrQueryAllRows
- (LPMAPITABLE lpTable, LPSPropTagArray lpPropTags,
- LPSRestriction lpRestriction, LPSSortOrderSet lpSortOrderSet,
- LONG crowsMax, LPSRowSet* lppRows);
-#define HrQueryAllRows MsOutlookAddrBook_hrQueryAllRows
-
-SCODE MsOutlookAddrBook_mapiAllocateBuffer(ULONG size, LPVOID FAR *buffer);
-#define MAPIAllocateBuffer MsOutlookAddrBook_mapiAllocateBuffer
-
-ULONG MsOutlookAddrBook_mapiFreeBuffer(LPVOID buffer);
-#define MAPIFreeBuffer MsOutlookAddrBook_mapiFreeBuffer
-
-HRESULT MsOutlookAddrBook_mapiLogonEx
- (ULONG_PTR uiParam,
- LPTSTR profileName, LPTSTR password,
- FLAGS flags,
- LPMAPISESSION FAR *mapiSession);
-#define MAPILogonEx MsOutlookAddrBook_mapiLogonEx
-
-
-HRESULT MsOutlookAddrBookContactSourceService_MAPIInitialize
- (jlong version, jlong flags);
-
-HRESULT MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer(void);
-
-void MsOutlookAddrBookContactSourceService_MAPIUninitialize(void);
-
-void MsOutlookAddrBookContactSourceService_MAPIUninitializeCOMServer(void);
-
-HRESULT MsOutlookAddrBookContactSourceService_NativeMAPIInitialize
- (jlong version, jlong flags,
- void * deletedMethod, void * insertedMethod, void * updatedMethod);
-
-void MsOutlookAddrBookContactSourceService_NativeMAPIUninitialize(void);
-
-#endif
+/* + * 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_MSOUTLOOKADDRBOOKCONTACTSOURCESERVICE_H_ +#define _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKADDRBOOKCONTACTSOURCESERVICE_H_ + +#include <jni.h> +#include <mapix.h> + +BOOL MsOutlookAddrBook_fBinFromHex(LPSTR lpsz, LPBYTE lpb); +#define FBinFromHex MsOutlookAddrBook_fBinFromHex + +void MsOutlookAddrBook_freeProws(LPSRowSet lpRows); +#define FreeProws MsOutlookAddrBook_freeProws + +void MsOutlookAddrBook_hexFromBin(LPBYTE pb, int cb, LPSTR sz); +#define HexFromBin MsOutlookAddrBook_hexFromBin + +void MsOutlookAddrBook_hrAllocAdviseSink + (LPNOTIFCALLBACK lpfnCallback, LPVOID lpvContext, + LPMAPIADVISESINK* lppAdviseSink); +#define HrAllocAdviseSink MsOutlookAddrBook_hrAllocAdviseSink + +HRESULT MsOutlookAddrBook_hrQueryAllRows + (LPMAPITABLE lpTable, LPSPropTagArray lpPropTags, + LPSRestriction lpRestriction, LPSSortOrderSet lpSortOrderSet, + LONG crowsMax, LPSRowSet* lppRows); +#define HrQueryAllRows MsOutlookAddrBook_hrQueryAllRows + +SCODE MsOutlookAddrBook_mapiAllocateBuffer(ULONG size, LPVOID FAR *buffer); +#define MAPIAllocateBuffer MsOutlookAddrBook_mapiAllocateBuffer + +ULONG MsOutlookAddrBook_mapiFreeBuffer(LPVOID buffer); +#define MAPIFreeBuffer MsOutlookAddrBook_mapiFreeBuffer + +HRESULT MsOutlookAddrBook_mapiLogonEx + (ULONG_PTR uiParam, + LPTSTR profileName, LPTSTR password, + FLAGS flags, + LPMAPISESSION FAR *mapiSession); +#define MAPILogonEx MsOutlookAddrBook_mapiLogonEx + + +HRESULT MsOutlookAddrBookContactSourceService_MAPIInitialize + (jlong version, jlong flags); + +HRESULT MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer(void); + +void MsOutlookAddrBookContactSourceService_MAPIUninitialize(void); + +void MsOutlookAddrBookContactSourceService_MAPIUninitializeCOMServer(void); + +HRESULT MsOutlookAddrBookContactSourceService_NativeMAPIInitialize + (jlong version, jlong flags, + void * deletedMethod, void * insertedMethod, void * updatedMethod); + +void MsOutlookAddrBookContactSourceService_NativeMAPIUninitialize(void); + +#endif diff --git a/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.h b/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.h index 4ce3287..8425eae 100644 --- a/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.h +++ b/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.h @@ -1,26 +1,26 @@ -/*
- * 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_MSOUTLOOKMAPIHRESULTEXCEPTION_H_
-#define _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKMAPIHRESULTEXCEPTION_H_
-
-#include <jni.h>
-#include <Mapix.h>
-#include <tchar.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* #ifdef __cplusplus */
-
-void MsOutlookMAPIHResultException_throwNew
- (JNIEnv *jniEnv, HRESULT hResult, LPCSTR file, ULONG line);
-
-#ifdef __cplusplus
-}
-#endif /* #ifdef __cplusplus */
-
-#endif /* _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKMAPIHRESULTEXCEPTION_ */
+/* + * 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_MSOUTLOOKMAPIHRESULTEXCEPTION_H_ +#define _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKMAPIHRESULTEXCEPTION_H_ + +#include <jni.h> +#include <Mapix.h> +#include <tchar.h> + +#ifdef __cplusplus +extern "C" { +#endif /* #ifdef __cplusplus */ + +void MsOutlookMAPIHResultException_throwNew + (JNIEnv *jniEnv, HRESULT hResult, LPCSTR file, ULONG line); + +#ifdef __cplusplus +} +#endif /* #ifdef __cplusplus */ + +#endif /* _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKMAPIHRESULTEXCEPTION_ */ diff --git a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.h b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.h index 77f5f77..b8eed7e 100644 --- a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.h +++ b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookClient.h @@ -1,208 +1,208 @@ -
-
-/* 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
- */
-/* Compiler settings for IMsOutlookAddrBookClient.idl:
- Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0595
- protocol : dce , ms_ext, c_ext, robust
- error checks: allocation ref bounds_check enum stub_data
- VC __declspec() decoration level:
- __declspec(uuid()), __declspec(selectany), __declspec(novtable)
- DECLSPEC_UUID(), MIDL_INTERFACE()
-*/
-/* @@MIDL_FILE_HEADING( ) */
-
-//#pragma warning( disable: 4049 ) /* more than 64k source lines */
-
-
-/* verify that the <rpcndr.h> version is high enough to compile this file*/
-#ifndef __REQUIRED_RPCNDR_H_VERSION__
-#define __REQUIRED_RPCNDR_H_VERSION__ 475
-#endif
-
-#include "rpc.h"
-#include "rpcndr.h"
-
-#ifndef __RPCNDR_H_VERSION__
-#error this stub requires an updated version of <rpcndr.h>
-#endif // __RPCNDR_H_VERSION__
-
-#ifndef COM_NO_WINDOWS_H
-#include "windows.h"
-#include "ole2.h"
-#endif /*COM_NO_WINDOWS_H*/
-
-#ifndef __IMsOutlookAddrBookClient_h__
-#define __IMsOutlookAddrBookClient_h__
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once
-#endif
-
-/* Forward Declarations */
-
-#ifndef __IMsOutlookAddrBookClient_FWD_DEFINED__
-#define __IMsOutlookAddrBookClient_FWD_DEFINED__
-typedef interface IMsOutlookAddrBookClient IMsOutlookAddrBookClient;
-
-#endif /* __IMsOutlookAddrBookClient_FWD_DEFINED__ */
-
-
-#ifndef __IMsOutlookAddrBookClient_FWD_DEFINED__
-#define __IMsOutlookAddrBookClient_FWD_DEFINED__
-typedef interface IMsOutlookAddrBookClient IMsOutlookAddrBookClient;
-
-#endif /* __IMsOutlookAddrBookClient_FWD_DEFINED__ */
-
-
-/* header files for imported files */
-#include "Unknwn.h"
-#include "oaidl.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-
-#ifndef __IMsOutlookAddrBookClient_INTERFACE_DEFINED__
-#define __IMsOutlookAddrBookClient_INTERFACE_DEFINED__
-
-/* interface IMsOutlookAddrBookClient */
-/* [oleautomation][dual][uuid][object] */
-
-
-EXTERN_C const IID IID_IMsOutlookAddrBookClient;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("D579E840-B1A6-11E2-9E96-0800200C9A66")
- IMsOutlookAddrBookClient : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE foreachMailUserCallback(
- /* [in] */ BSTR id) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE deleted(
- /* [in] */ BSTR id) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE inserted(
- /* [in] */ BSTR id) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE updated(
- /* [in] */ BSTR id) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IMsOutlookAddrBookClientVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IMsOutlookAddrBookClient * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IMsOutlookAddrBookClient * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IMsOutlookAddrBookClient * This);
-
- HRESULT ( STDMETHODCALLTYPE *foreachMailUserCallback )(
- IMsOutlookAddrBookClient * This,
- /* [in] */ BSTR id);
-
- HRESULT ( STDMETHODCALLTYPE *deleted )(
- IMsOutlookAddrBookClient * This,
- /* [in] */ BSTR id);
-
- HRESULT ( STDMETHODCALLTYPE *inserted )(
- IMsOutlookAddrBookClient * This,
- /* [in] */ BSTR id);
-
- HRESULT ( STDMETHODCALLTYPE *updated )(
- IMsOutlookAddrBookClient * This,
- /* [in] */ BSTR id);
-
- END_INTERFACE
- } IMsOutlookAddrBookClientVtbl;
-
- interface IMsOutlookAddrBookClient
- {
- CONST_VTBL struct IMsOutlookAddrBookClientVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IMsOutlookAddrBookClient_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IMsOutlookAddrBookClient_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IMsOutlookAddrBookClient_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IMsOutlookAddrBookClient_foreachMailUserCallback(This,id) \
- ( (This)->lpVtbl -> foreachMailUserCallback(This,id) )
-
-#define IMsOutlookAddrBookClient_deleted(This,id) \
- ( (This)->lpVtbl -> deleted(This,id) )
-
-#define IMsOutlookAddrBookClient_inserted(This,id) \
- ( (This)->lpVtbl -> inserted(This,id) )
-
-#define IMsOutlookAddrBookClient_updated(This,id) \
- ( (This)->lpVtbl -> updated(This,id) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IMsOutlookAddrBookClient_INTERFACE_DEFINED__ */
-
-
-
-#ifndef __IMsOutlookAddrBookClientTypeLib_LIBRARY_DEFINED__
-#define __IMsOutlookAddrBookClientTypeLib_LIBRARY_DEFINED__
-
-/* library IMsOutlookAddrBookClientTypeLib */
-/* [helpstring][version][uuid] */
-
-
-
-EXTERN_C const IID LIBID_IMsOutlookAddrBookClientTypeLib;
-#endif /* __IMsOutlookAddrBookClientTypeLib_LIBRARY_DEFINED__ */
-
-/* Additional Prototypes for ALL interfaces */
-
-unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * );
-unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * );
-unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * );
-void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * );
-
-/* end of Additional Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
+ + +/* 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 + */ +/* Compiler settings for IMsOutlookAddrBookClient.idl: + Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0595 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +//#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the <rpcndr.h> version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of <rpcndr.h> +#endif // __RPCNDR_H_VERSION__ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __IMsOutlookAddrBookClient_h__ +#define __IMsOutlookAddrBookClient_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifndef __IMsOutlookAddrBookClient_FWD_DEFINED__ +#define __IMsOutlookAddrBookClient_FWD_DEFINED__ +typedef interface IMsOutlookAddrBookClient IMsOutlookAddrBookClient; + +#endif /* __IMsOutlookAddrBookClient_FWD_DEFINED__ */ + + +#ifndef __IMsOutlookAddrBookClient_FWD_DEFINED__ +#define __IMsOutlookAddrBookClient_FWD_DEFINED__ +typedef interface IMsOutlookAddrBookClient IMsOutlookAddrBookClient; + +#endif /* __IMsOutlookAddrBookClient_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "Unknwn.h" +#include "oaidl.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __IMsOutlookAddrBookClient_INTERFACE_DEFINED__ +#define __IMsOutlookAddrBookClient_INTERFACE_DEFINED__ + +/* interface IMsOutlookAddrBookClient */ +/* [oleautomation][dual][uuid][object] */ + + +EXTERN_C const IID IID_IMsOutlookAddrBookClient; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("D579E840-B1A6-11E2-9E96-0800200C9A66") + IMsOutlookAddrBookClient : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE foreachMailUserCallback( + /* [in] */ BSTR id) = 0; + + virtual HRESULT STDMETHODCALLTYPE deleted( + /* [in] */ BSTR id) = 0; + + virtual HRESULT STDMETHODCALLTYPE inserted( + /* [in] */ BSTR id) = 0; + + virtual HRESULT STDMETHODCALLTYPE updated( + /* [in] */ BSTR id) = 0; + + }; + + +#else /* C style interface */ + + typedef struct IMsOutlookAddrBookClientVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IMsOutlookAddrBookClient * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IMsOutlookAddrBookClient * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IMsOutlookAddrBookClient * This); + + HRESULT ( STDMETHODCALLTYPE *foreachMailUserCallback )( + IMsOutlookAddrBookClient * This, + /* [in] */ BSTR id); + + HRESULT ( STDMETHODCALLTYPE *deleted )( + IMsOutlookAddrBookClient * This, + /* [in] */ BSTR id); + + HRESULT ( STDMETHODCALLTYPE *inserted )( + IMsOutlookAddrBookClient * This, + /* [in] */ BSTR id); + + HRESULT ( STDMETHODCALLTYPE *updated )( + IMsOutlookAddrBookClient * This, + /* [in] */ BSTR id); + + END_INTERFACE + } IMsOutlookAddrBookClientVtbl; + + interface IMsOutlookAddrBookClient + { + CONST_VTBL struct IMsOutlookAddrBookClientVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IMsOutlookAddrBookClient_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IMsOutlookAddrBookClient_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IMsOutlookAddrBookClient_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IMsOutlookAddrBookClient_foreachMailUserCallback(This,id) \ + ( (This)->lpVtbl -> foreachMailUserCallback(This,id) ) + +#define IMsOutlookAddrBookClient_deleted(This,id) \ + ( (This)->lpVtbl -> deleted(This,id) ) + +#define IMsOutlookAddrBookClient_inserted(This,id) \ + ( (This)->lpVtbl -> inserted(This,id) ) + +#define IMsOutlookAddrBookClient_updated(This,id) \ + ( (This)->lpVtbl -> updated(This,id) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IMsOutlookAddrBookClient_INTERFACE_DEFINED__ */ + + + +#ifndef __IMsOutlookAddrBookClientTypeLib_LIBRARY_DEFINED__ +#define __IMsOutlookAddrBookClientTypeLib_LIBRARY_DEFINED__ + +/* library IMsOutlookAddrBookClientTypeLib */ +/* [helpstring][version][uuid] */ + + + +EXTERN_C const IID LIBID_IMsOutlookAddrBookClientTypeLib; +#endif /* __IMsOutlookAddrBookClientTypeLib_LIBRARY_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); +unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); +unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); +void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.h b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.h index cab73c7..0cf23fa 100644 --- a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.h +++ b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.h @@ -1,251 +1,265 @@ -
-
-/* 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:42 2013
- */
-/* Compiler settings for IMsOutlookAddrBookServer.idl:
- Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0595
- protocol : dce , ms_ext, c_ext, robust
- error checks: allocation ref bounds_check enum stub_data
- VC __declspec() decoration level:
- __declspec(uuid()), __declspec(selectany), __declspec(novtable)
- DECLSPEC_UUID(), MIDL_INTERFACE()
-*/
-/* @@MIDL_FILE_HEADING( ) */
-
-//#pragma warning( disable: 4049 ) /* more than 64k source lines */
-
-
-/* verify that the <rpcndr.h> version is high enough to compile this file*/
-#ifndef __REQUIRED_RPCNDR_H_VERSION__
-#define __REQUIRED_RPCNDR_H_VERSION__ 475
-#endif
-
-#include "rpc.h"
-#include "rpcndr.h"
-
-#ifndef __RPCNDR_H_VERSION__
-#error this stub requires an updated version of <rpcndr.h>
-#endif // __RPCNDR_H_VERSION__
-
-#ifndef COM_NO_WINDOWS_H
-#include "windows.h"
-#include "ole2.h"
-#endif /*COM_NO_WINDOWS_H*/
-
-#ifndef __IMsOutlookAddrBookServer_h__
-#define __IMsOutlookAddrBookServer_h__
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-#pragma once
-#endif
-
-/* Forward Declarations */
-
-#ifndef __IMsOutlookAddrBookServer_FWD_DEFINED__
-#define __IMsOutlookAddrBookServer_FWD_DEFINED__
-typedef interface IMsOutlookAddrBookServer IMsOutlookAddrBookServer;
-
-#endif /* __IMsOutlookAddrBookServer_FWD_DEFINED__ */
-
-
-#ifndef __IMsOutlookAddrBookServer_FWD_DEFINED__
-#define __IMsOutlookAddrBookServer_FWD_DEFINED__
-typedef interface IMsOutlookAddrBookServer IMsOutlookAddrBookServer;
-
-#endif /* __IMsOutlookAddrBookServer_FWD_DEFINED__ */
-
-
-/* header files for imported files */
-#include "Unknwn.h"
-#include "oaidl.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-
-#ifndef __IMsOutlookAddrBookServer_INTERFACE_DEFINED__
-#define __IMsOutlookAddrBookServer_INTERFACE_DEFINED__
-
-/* interface IMsOutlookAddrBookServer */
-/* [oleautomation][dual][uuid][object] */
-
-
-EXTERN_C const IID IID_IMsOutlookAddrBookServer;
-
-#if defined(__cplusplus) && !defined(CINTERFACE)
-
- MIDL_INTERFACE("5DDE9FF0-AC48-11E2-9E96-0800200C9A66")
- IMsOutlookAddrBookServer : public IUnknown
- {
- public:
- virtual HRESULT STDMETHODCALLTYPE foreachMailUser(
- /* [in] */ BSTR query) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE IMAPIProp_GetProps(
- /* [in] */ BSTR entryId,
- /* [in] */ int nbPropIds,
- /* [in] */ SAFEARRAY * propIds,
- /* [in] */ long flags,
- /* [out] */ SAFEARRAY * *props,
- /* [out] */ SAFEARRAY * *propsLength,
- /* [out] */ SAFEARRAY * *propsType) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE createContact(
- /* [out] */ BSTR *id) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE deleteContact(
- /* [in] */ BSTR id) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE IMAPIProp_DeleteProp(
- /* [in] */ long propId,
- /* [in] */ BSTR entryId) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE IMAPIProp_SetPropString(
- /* [in] */ long propId,
- /* [in] */ BSTR value,
- /* [in] */ BSTR entryId) = 0;
-
- };
-
-
-#else /* C style interface */
-
- typedef struct IMsOutlookAddrBookServerVtbl
- {
- BEGIN_INTERFACE
-
- HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
- IMsOutlookAddrBookServer * This,
- /* [in] */ REFIID riid,
- /* [annotation][iid_is][out] */
- _COM_Outptr_ void **ppvObject);
-
- ULONG ( STDMETHODCALLTYPE *AddRef )(
- IMsOutlookAddrBookServer * This);
-
- ULONG ( STDMETHODCALLTYPE *Release )(
- IMsOutlookAddrBookServer * This);
-
- HRESULT ( STDMETHODCALLTYPE *foreachMailUser )(
- IMsOutlookAddrBookServer * This,
- /* [in] */ BSTR query);
-
- HRESULT ( STDMETHODCALLTYPE *IMAPIProp_GetProps )(
- IMsOutlookAddrBookServer * This,
- /* [in] */ BSTR entryId,
- /* [in] */ int nbPropIds,
- /* [in] */ SAFEARRAY * propIds,
- /* [in] */ long flags,
- /* [out] */ SAFEARRAY * *props,
- /* [out] */ SAFEARRAY * *propsLength,
- /* [out] */ SAFEARRAY * *propsType);
-
- HRESULT ( STDMETHODCALLTYPE *createContact )(
- IMsOutlookAddrBookServer * This,
- /* [out] */ BSTR *id);
-
- HRESULT ( STDMETHODCALLTYPE *deleteContact )(
- IMsOutlookAddrBookServer * This,
- /* [in] */ BSTR id);
-
- HRESULT ( STDMETHODCALLTYPE *IMAPIProp_DeleteProp )(
- IMsOutlookAddrBookServer * This,
- /* [in] */ long propId,
- /* [in] */ BSTR entryId);
-
- HRESULT ( STDMETHODCALLTYPE *IMAPIProp_SetPropString )(
- IMsOutlookAddrBookServer * This,
- /* [in] */ long propId,
- /* [in] */ BSTR value,
- /* [in] */ BSTR entryId);
-
- END_INTERFACE
- } IMsOutlookAddrBookServerVtbl;
-
- interface IMsOutlookAddrBookServer
- {
- CONST_VTBL struct IMsOutlookAddrBookServerVtbl *lpVtbl;
- };
-
-
-
-#ifdef COBJMACROS
-
-
-#define IMsOutlookAddrBookServer_QueryInterface(This,riid,ppvObject) \
- ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
-
-#define IMsOutlookAddrBookServer_AddRef(This) \
- ( (This)->lpVtbl -> AddRef(This) )
-
-#define IMsOutlookAddrBookServer_Release(This) \
- ( (This)->lpVtbl -> Release(This) )
-
-
-#define IMsOutlookAddrBookServer_foreachMailUser(This,query) \
- ( (This)->lpVtbl -> foreachMailUser(This,query) )
-
-#define IMsOutlookAddrBookServer_IMAPIProp_GetProps(This,entryId,nbPropIds,propIds,flags,props,propsLength,propsType) \
- ( (This)->lpVtbl -> IMAPIProp_GetProps(This,entryId,nbPropIds,propIds,flags,props,propsLength,propsType) )
-
-#define IMsOutlookAddrBookServer_createContact(This,id) \
- ( (This)->lpVtbl -> createContact(This,id) )
-
-#define IMsOutlookAddrBookServer_deleteContact(This,id) \
- ( (This)->lpVtbl -> deleteContact(This,id) )
-
-#define IMsOutlookAddrBookServer_IMAPIProp_DeleteProp(This,propId,entryId) \
- ( (This)->lpVtbl -> IMAPIProp_DeleteProp(This,propId,entryId) )
-
-#define IMsOutlookAddrBookServer_IMAPIProp_SetPropString(This,propId,value,entryId) \
- ( (This)->lpVtbl -> IMAPIProp_SetPropString(This,propId,value,entryId) )
-
-#endif /* COBJMACROS */
-
-
-#endif /* C style interface */
-
-
-
-
-#endif /* __IMsOutlookAddrBookServer_INTERFACE_DEFINED__ */
-
-
-
-#ifndef __IMsOutlookAddrBookServerTypeLib_LIBRARY_DEFINED__
-#define __IMsOutlookAddrBookServerTypeLib_LIBRARY_DEFINED__
-
-/* library IMsOutlookAddrBookServerTypeLib */
-/* [helpstring][version][uuid] */
-
-
-
-EXTERN_C const IID LIBID_IMsOutlookAddrBookServerTypeLib;
-#endif /* __IMsOutlookAddrBookServerTypeLib_LIBRARY_DEFINED__ */
-
-/* Additional Prototypes for ALL interfaces */
-
-unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * );
-unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * );
-unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * );
-void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * );
-
-unsigned long __RPC_USER LPSAFEARRAY_UserSize( unsigned long *, unsigned long , LPSAFEARRAY * );
-unsigned char * __RPC_USER LPSAFEARRAY_UserMarshal( unsigned long *, unsigned char *, LPSAFEARRAY * );
-unsigned char * __RPC_USER LPSAFEARRAY_UserUnmarshal(unsigned long *, unsigned char *, LPSAFEARRAY * );
-void __RPC_USER LPSAFEARRAY_UserFree( unsigned long *, LPSAFEARRAY * );
-
-/* end of Additional Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
+ + +/* 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 + */ +/* Compiler settings for IMsOutlookAddrBookServer.idl: + Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0595 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +//#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the <rpcndr.h> version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of <rpcndr.h> +#endif // __RPCNDR_H_VERSION__ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __IMsOutlookAddrBookServer_h__ +#define __IMsOutlookAddrBookServer_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifndef __IMsOutlookAddrBookServer_FWD_DEFINED__ +#define __IMsOutlookAddrBookServer_FWD_DEFINED__ +typedef interface IMsOutlookAddrBookServer IMsOutlookAddrBookServer; + +#endif /* __IMsOutlookAddrBookServer_FWD_DEFINED__ */ + + +#ifndef __IMsOutlookAddrBookServer_FWD_DEFINED__ +#define __IMsOutlookAddrBookServer_FWD_DEFINED__ +typedef interface IMsOutlookAddrBookServer IMsOutlookAddrBookServer; + +#endif /* __IMsOutlookAddrBookServer_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "Unknwn.h" +#include "oaidl.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __IMsOutlookAddrBookServer_INTERFACE_DEFINED__ +#define __IMsOutlookAddrBookServer_INTERFACE_DEFINED__ + +/* interface IMsOutlookAddrBookServer */ +/* [oleautomation][dual][uuid][object] */ + + +EXTERN_C const IID IID_IMsOutlookAddrBookServer; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("5DDE9FF0-AC48-11E2-9E96-0800200C9A66") + IMsOutlookAddrBookServer : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE foreachMailUser( + /* [in] */ BSTR query) = 0; + + virtual HRESULT STDMETHODCALLTYPE IMAPIProp_GetProps( + /* [in] */ BSTR entryId, + /* [in] */ int nbPropIds, + /* [in] */ SAFEARRAY * propIds, + /* [in] */ long flags, + /* [out] */ SAFEARRAY * *props, + /* [out] */ SAFEARRAY * *propsLength, + /* [out] */ SAFEARRAY * *propsType) = 0; + + virtual HRESULT STDMETHODCALLTYPE createContact( + /* [out] */ BSTR *id) = 0; + + virtual HRESULT STDMETHODCALLTYPE deleteContact( + /* [in] */ BSTR id) = 0; + + virtual HRESULT STDMETHODCALLTYPE IMAPIProp_DeleteProp( + /* [in] */ long propId, + /* [in] */ BSTR entryId) = 0; + + virtual HRESULT STDMETHODCALLTYPE IMAPIProp_SetPropString( + /* [in] */ long propId, + /* [in] */ BSTR value, + /* [in] */ BSTR entryId) = 0; + + virtual HRESULT STDMETHODCALLTYPE compareEntryIds( + /* [in] */ BSTR id1, + /* [in] */ BSTR id2, + /* [out] */ int *result) = 0; + + }; + + +#else /* C style interface */ + + typedef struct IMsOutlookAddrBookServerVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IMsOutlookAddrBookServer * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + IMsOutlookAddrBookServer * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + IMsOutlookAddrBookServer * This); + + HRESULT ( STDMETHODCALLTYPE *foreachMailUser )( + IMsOutlookAddrBookServer * This, + /* [in] */ BSTR query); + + HRESULT ( STDMETHODCALLTYPE *IMAPIProp_GetProps )( + IMsOutlookAddrBookServer * This, + /* [in] */ BSTR entryId, + /* [in] */ int nbPropIds, + /* [in] */ SAFEARRAY * propIds, + /* [in] */ long flags, + /* [out] */ SAFEARRAY * *props, + /* [out] */ SAFEARRAY * *propsLength, + /* [out] */ SAFEARRAY * *propsType); + + HRESULT ( STDMETHODCALLTYPE *createContact )( + IMsOutlookAddrBookServer * This, + /* [out] */ BSTR *id); + + HRESULT ( STDMETHODCALLTYPE *deleteContact )( + IMsOutlookAddrBookServer * This, + /* [in] */ BSTR id); + + HRESULT ( STDMETHODCALLTYPE *IMAPIProp_DeleteProp )( + IMsOutlookAddrBookServer * This, + /* [in] */ long propId, + /* [in] */ BSTR entryId); + + HRESULT ( STDMETHODCALLTYPE *IMAPIProp_SetPropString )( + IMsOutlookAddrBookServer * This, + /* [in] */ long propId, + /* [in] */ BSTR value, + /* [in] */ BSTR entryId); + + HRESULT ( STDMETHODCALLTYPE *compareEntryIds )( + IMsOutlookAddrBookServer * This, + /* [in] */ BSTR id1, + /* [in] */ BSTR id2, + /* [out] */ int *result); + + END_INTERFACE + } IMsOutlookAddrBookServerVtbl; + + interface IMsOutlookAddrBookServer + { + CONST_VTBL struct IMsOutlookAddrBookServerVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IMsOutlookAddrBookServer_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define IMsOutlookAddrBookServer_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define IMsOutlookAddrBookServer_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define IMsOutlookAddrBookServer_foreachMailUser(This,query) \ + ( (This)->lpVtbl -> foreachMailUser(This,query) ) + +#define IMsOutlookAddrBookServer_IMAPIProp_GetProps(This,entryId,nbPropIds,propIds,flags,props,propsLength,propsType) \ + ( (This)->lpVtbl -> IMAPIProp_GetProps(This,entryId,nbPropIds,propIds,flags,props,propsLength,propsType) ) + +#define IMsOutlookAddrBookServer_createContact(This,id) \ + ( (This)->lpVtbl -> createContact(This,id) ) + +#define IMsOutlookAddrBookServer_deleteContact(This,id) \ + ( (This)->lpVtbl -> deleteContact(This,id) ) + +#define IMsOutlookAddrBookServer_IMAPIProp_DeleteProp(This,propId,entryId) \ + ( (This)->lpVtbl -> IMAPIProp_DeleteProp(This,propId,entryId) ) + +#define IMsOutlookAddrBookServer_IMAPIProp_SetPropString(This,propId,value,entryId) \ + ( (This)->lpVtbl -> IMAPIProp_SetPropString(This,propId,value,entryId) ) + +#define IMsOutlookAddrBookServer_compareEntryIds(This,id1,id2,result) \ + ( (This)->lpVtbl -> compareEntryIds(This,id1,id2,result) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __IMsOutlookAddrBookServer_INTERFACE_DEFINED__ */ + + + +#ifndef __IMsOutlookAddrBookServerTypeLib_LIBRARY_DEFINED__ +#define __IMsOutlookAddrBookServerTypeLib_LIBRARY_DEFINED__ + +/* library IMsOutlookAddrBookServerTypeLib */ +/* [helpstring][version][uuid] */ + + + +EXTERN_C const IID LIBID_IMsOutlookAddrBookServerTypeLib; +#endif /* __IMsOutlookAddrBookServerTypeLib_LIBRARY_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); +unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); +unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); +void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); + +unsigned long __RPC_USER LPSAFEARRAY_UserSize( unsigned long *, unsigned long , LPSAFEARRAY * ); +unsigned char * __RPC_USER LPSAFEARRAY_UserMarshal( unsigned long *, unsigned char *, LPSAFEARRAY * ); +unsigned char * __RPC_USER LPSAFEARRAY_UserUnmarshal(unsigned long *, unsigned char *, LPSAFEARRAY * ); +void __RPC_USER LPSAFEARRAY_UserFree( unsigned long *, LPSAFEARRAY * ); + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.idl b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.idl index 2bd0a03..354c947 100644 --- a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.idl +++ b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.idl @@ -36,6 +36,11 @@ interface IMsOutlookAddrBookServer : IUnknown [in] long propId, [in] BSTR value, [in] BSTR entryId); + + HRESULT compareEntryIds( + [in] BSTR id1, + [in] BSTR id2, + [out] int *result); }; diff --git a/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.tlb b/src/native/addrbook/msoutlook/com/IMsOutlookAddrBookServer.tlb Binary files differindex 8816623..a653c05 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 e34b0ce..fccaa9c 100644 --- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx +++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClient.cxx @@ -128,6 +128,9 @@ 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/MsOutlookAddrBookServer.cxx b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx index fb67675..ebd7aa5 100644 --- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx +++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx @@ -366,3 +366,34 @@ HRESULT STDMETHODCALLTYPE MsOutlookAddrBookServer::IMAPIProp_SetPropString( } return hr; } + +/** + * Compares two identifiers to determine if they are part of the same + * Outlook contact. + * + * @param id1 The first identifier. + * @param id2 The second identifier. + * @param result A boolean set to true if id1 and id2 are two identifiers of the + * same contact. False otherwise. + * + * @return S_OK if eveything works fine. E_FAIL otherwise. + */ +HRESULT STDMETHODCALLTYPE MsOutlookAddrBookServer::compareEntryIds( + BSTR id1, + BSTR id2, + int * result) +{ + HRESULT hr = E_FAIL; + if(id1 != NULL && id2 != NULL) + { + LPSTR nativeId1 = StringUtils::WideCharToMultiByte(id1); + LPSTR nativeId2 = StringUtils::WideCharToMultiByte(id2); + (*result) = MsOutlookAddrBookContactQuery_compareEntryIds( + nativeId1, + nativeId2); + hr = S_OK; + free(nativeId1); + free(nativeId2); + } + return hr; +} diff --git a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.h b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.h index 6dcaa1e..a1ba304 100644 --- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.h +++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.h @@ -61,6 +61,11 @@ class MsOutlookAddrBookServer: BSTR value, BSTR entryId); + HRESULT STDMETHODCALLTYPE compareEntryIds( + BSTR id1, + BSTR id2, + int *result); + protected: virtual ~MsOutlookAddrBookServer(); diff --git a/src/native/addrbook/msoutlook/com/server/Server.cxx b/src/native/addrbook/msoutlook/com/server/Server.cxx index fcdd731..d33c1b4 100644 --- a/src/native/addrbook/msoutlook/com/server/Server.cxx +++ b/src/native/addrbook/msoutlook/com/server/Server.cxx @@ -125,6 +125,9 @@ 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/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 a36e7bd..429bb74 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 @@ -420,3 +420,56 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac return javaProps; } + + +/** + * Compares two identifiers to determine if they are part of the same + * Outlook contact. + * + * @param jniEnv The Java native interface environment. + * @param clazz A Java class Object. + * @param id1 The first identifier. + * @param id2 The second identifier. + * + * @return True if id1 and id2 are two identifiers of the same contact. + * False otherwise. + */ +JNIEXPORT jboolean JNICALL +Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery_compareEntryIds + (JNIEnv *jniEnv, jclass clazz, jstring id1, jstring id2) +{ + jboolean res = JNI_FALSE; + + if(id1 == NULL || id2 == NULL) + { + return res; + } + + const char *nativeId1 = jniEnv->GetStringUTFChars(id1, NULL); + const char *nativeId2 = jniEnv->GetStringUTFChars(id2, NULL); + + IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); + if(iServer) + { + LPWSTR unicodeId1 = StringUtils::MultiByteToWideChar(nativeId1); + LPWSTR unicodeId2 = StringUtils::MultiByteToWideChar(nativeId2); + BSTR comId1 = SysAllocString(unicodeId1); + BSTR comId2 = SysAllocString(unicodeId2); + + int result = 0; + if(iServer->compareEntryIds(comId1, comId2, &result) == S_OK) + { + res = (result == 1); + } + + SysFreeString(comId1); + SysFreeString(comId2); + free(unicodeId1); + free(unicodeId2); + } + + jniEnv->ReleaseStringUTFChars(id1, nativeId1); + jniEnv->ReleaseStringUTFChars(id2, nativeId2); + + return res; +} 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 1d7e580..3a0d5b8 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 @@ -37,6 +37,10 @@ JNIEXPORT jobjectArray JNICALL Java_net_java_sip_communicator_plugin_addrbook_ms JNIEXPORT jboolean JNICALL Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString (JNIEnv *, jclass, jlong, jstring, jstring); +JNIEXPORT jboolean JNICALL +Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery_compareEntryIds + (JNIEnv *, jclass, jstring, jstring); + #ifdef __cplusplus } #endif 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 2bfc53b..21b5f5c 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 @@ -1,47 +1,46 @@ -/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-#include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h"
-
-#include "MsOutlookAddrBookContactSourceService.h"
-
-#include "MsOutlookMAPIHResultException.h"
-#include "MAPINotification.h"
-#include "MAPIBitness.h"
-
-JNIEXPORT void JNICALL
-Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_MAPIInitialize
- (JNIEnv *jniEnv, jclass clazz, jlong version, jlong flags,
- jobject notificationsDelegate)
-{
- HRESULT hr;
-
- MAPINotification_registerJniNotificationsDelegate(
- jniEnv,
- notificationsDelegate);
-
- hr = MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer();
-
- if (HR_FAILED(hr))
- {
- // Report any possible error regardless of where it has come from.
- MsOutlookMAPIHResultException_throwNew(
- jniEnv,
- hr,
- __FILE__, __LINE__);
- }
-}
-
-JNIEXPORT void JNICALL
-Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_MAPIUninitialize
- (JNIEnv *jniEnv, jclass clazz)
-{
- MAPINotification_unregisterJniNotificationsDelegate(jniEnv);
-
- MsOutlookAddrBookContactSourceService_MAPIUninitializeCOMServer();
-}
-
+/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +#include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h" + +#include "MsOutlookAddrBookContactSourceService.h" + +#include "MsOutlookMAPIHResultException.h" +#include "MAPINotification.h" +#include "MAPIBitness.h" + +JNIEXPORT void JNICALL +Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_MAPIInitialize + (JNIEnv *jniEnv, jclass clazz, jlong version, jlong flags, + jobject notificationsDelegate) +{ + HRESULT hr; + + MAPINotification_registerJniNotificationsDelegate( + jniEnv, + notificationsDelegate); + + hr = MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer(); + + if (HR_FAILED(hr)) + { + // Report any possible error regardless of where it has come from. + MsOutlookMAPIHResultException_throwNew( + jniEnv, + hr, + __FILE__, __LINE__); + } +} + +JNIEXPORT void JNICALL +Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_MAPIUninitialize + (JNIEnv *jniEnv, jclass clazz) +{ + MAPINotification_unregisterJniNotificationsDelegate(jniEnv); + + MsOutlookAddrBookContactSourceService_MAPIUninitializeCOMServer(); +} 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 50aa862..a8de352 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 @@ -1,31 +1,31 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService */
-
-#ifndef _Included_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService
-#define _Included_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Class: net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService
- * Method: MAPIInitialize
- * Signature: (JJ)V
- */
+/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService */ + +#ifndef _Included_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService +#define _Included_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Class: net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService + * Method: MAPIInitialize + * Signature: (JJ)V + */ JNIEXPORT void JNICALL
Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_MAPIInitialize
- (JNIEnv *, jclass, jlong, jlong, jobject);
-
-/*
- * Class: net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService
- * Method: MAPIUninitialize
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_MAPIUninitialize
- (JNIEnv *, jclass);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
+ (JNIEnv *, jclass, jlong, jlong, jobject); + +/* + * Class: net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService + * Method: MAPIUninitialize + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_MAPIUninitialize + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif |