diff options
author | Vincent Lucas <chenzo@jitsi.org> | 2013-05-07 17:56:43 +0200 |
---|---|---|
committer | Vincent Lucas <chenzo@jitsi.org> | 2013-05-07 17:56:43 +0200 |
commit | 7850999c1067defd8c6ab18d059e8d32897fa11a (patch) | |
tree | a7391718e131b1ba2c80ffdbe54d5558aeaa9f95 /src/native/addrbook/msoutlook | |
parent | 6035f9236c20f92c959593d424d3e26c77cc0af4 (diff) | |
download | jitsi-7850999c1067defd8c6ab18d059e8d32897fa11a.zip jitsi-7850999c1067defd8c6ab18d059e8d32897fa11a.tar.gz jitsi-7850999c1067defd8c6ab18d059e8d32897fa11a.tar.bz2 |
Always uses the COM server to interoperate with Outlook and thus even if Jitsi
bitness is compatible with MAPI library.
Diffstat (limited to 'src/native/addrbook/msoutlook')
6 files changed, 150 insertions, 241 deletions
diff --git a/src/native/addrbook/msoutlook/MAPIBitness.cxx b/src/native/addrbook/msoutlook/MAPIBitness.cxx index 1c0e775..1ecec0e 100644 --- a/src/native/addrbook/msoutlook/MAPIBitness.cxx +++ b/src/native/addrbook/msoutlook/MAPIBitness.cxx @@ -19,26 +19,6 @@ */ /** - * Returns the bitness of the current executable. - * - * @return 64 if the current executable is 64 bits. 32 otherwise. - */ -int MAPIBitness_getExecutableBitnessVersion(void) -{ - char executable[FILENAME_MAX]; - GetModuleFileName(NULL, executable, FILENAME_MAX); - - DWORD type; - GetBinaryType(executable, &type); - - if(type == SCS_64BIT_BINARY) - { - return 64; - } - return 32; -} - -/** * Returns the bitness of the Outlook installation. * * @return 64 if Outlook 64 bits version is installed. 32 if Outlook 32 bits @@ -82,18 +62,3 @@ int MAPIBitness_getOutlookBitnessVersion(void) return -1; } - -/** - * Tests if the bitness of the Outlook installation is identical to the current - * executable. - * - * Returns 1 if the bitness of the Outlook installation is identical to the - * current executable. 0 otherwise. - */ -int MAPIBitness_isOutlookBitnessCompatible(void) -{ - int outlookVersion = MAPIBitness_getOutlookBitnessVersion(); - int executableVersion = MAPIBitness_getExecutableBitnessVersion(); - - return (outlookVersion == executableVersion); -} diff --git a/src/native/addrbook/msoutlook/MAPIBitness.h b/src/native/addrbook/msoutlook/MAPIBitness.h index 0e3835a..9039b0b 100644 --- a/src/native/addrbook/msoutlook/MAPIBitness.h +++ b/src/native/addrbook/msoutlook/MAPIBitness.h @@ -14,8 +14,6 @@ * @author Vincent Lucas */ -int MAPIBitness_getExecutableBitnessVersion(void); int MAPIBitness_getOutlookBitnessVersion(void); -int MAPIBitness_isOutlookBitnessCompatible(void); #endif diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx index 09b1b84..13adac6 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx @@ -440,12 +440,11 @@ HRESULT MsOutlookAddrBookContactSourceService_MAPIInitialize }
/**
- * Starts the COM server if the bitness of Jitsi is different from the Outlook
- * one (mapi32.dll).
+ * Starts the COM server.
*
* @return S_OK if eveything was fine. E_FAIL otherwise.
*/
-HRESULT MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer()
+HRESULT MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer(void)
{
HRESULT hr = E_FAIL;
@@ -464,53 +463,55 @@ HRESULT MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer() void MsOutlookAddrBookContactSourceService_MAPIUninitialize(void)
{
MAPISession_lock();
- if(MAPIBitness_isOutlookBitnessCompatible())
- {
- 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;
- }
- }
- else
+ LPMAPISESSION mapiSession = MAPISession_getMapiSession();
+ if(mapiSession != NULL)
{
- if(MsOutlookAddrBookContactSourceService_comServerHandle != NULL)
- {
- TerminateProcess(
- MsOutlookAddrBookContactSourceService_comServerHandle,
- 1);
+ MAPINotification_unregisterNotifyAllMsgStores();
+ mapiSession->Logoff(0, 0, 0);
+ mapiSession->Release();
+ MAPISession_setMapiSession(NULL);
+ }
- CloseHandle(MsOutlookAddrBookContactSourceService_comServerHandle);
- MsOutlookAddrBookContactSourceService_comServerHandle = NULL;
- }
- ComClient_stop();
+ 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.
*
@@ -535,7 +536,7 @@ HRESULT MsOutlookAddrBookContactSourceService_NativeMAPIInitialize return MsOutlookAddrBookContactSourceService_MAPIInitialize(version, flags);
}
-void MsOutlookAddrBookContactSourceService_NativeMAPIUninitialize()
+void MsOutlookAddrBookContactSourceService_NativeMAPIUninitialize(void)
{
MAPINotification_unregisterNativeNotificationsDelegate();
@@ -588,7 +589,13 @@ MsOutlookAddrBookContactSourceService_isValidDefaultMailClient HRESULT MsOutlookAddrBookContactSourceService_startComServer(void)
{
// Start COM service
- char applicationName[] = "jmsoutlookaddrbookcomserver.exe";
+ 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(
diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.h b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.h index 5bfb9db..dcd1e83 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.h +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.h @@ -47,14 +47,16 @@ HRESULT MsOutlookAddrBook_mapiLogonEx HRESULT MsOutlookAddrBookContactSourceService_MAPIInitialize
(jlong version, jlong flags);
-HRESULT MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer();
+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 MsOutlookAddrBookContactSourceService_NativeMAPIUninitialize(void);
#endif
diff --git a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx index ec2b90f..6aa6e95 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 @@ -31,22 +31,15 @@ JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_msoutlo jstring value = NULL; char* messageIdStr = NULL; - if(MAPIBitness_isOutlookBitnessCompatible()) + IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); + if(iServer) { - messageIdStr = MsOutlookAddrBookContactQuery_createContact(); - } - else - { - IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); - if(iServer) + BSTR id; + iServer->createContact(&id); + if(id != NULL) { - BSTR id; - iServer->createContact(&id); - if(id != NULL) - { - messageIdStr = StringUtils::WideCharToMultiByte(id); - SysFreeString(id); - } + messageIdStr = StringUtils::WideCharToMultiByte(id); + SysFreeString(id); } } @@ -75,24 +68,18 @@ JNIEXPORT jboolean JNICALL Java_net_java_sip_communicator_plugin_addrbook_msoutl const char *nativeEntryId = jniEnv->GetStringUTFChars(id, NULL); jboolean res = JNI_FALSE; - if(MAPIBitness_isOutlookBitnessCompatible()) + IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); + if(iServer) { - res = (MsOutlookAddrBookContactQuery_deleteContact(nativeEntryId) == 1); - } - else - { - IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); - if(iServer) - { - LPWSTR unicodeId = StringUtils::MultiByteToWideChar(nativeEntryId); - BSTR comId = SysAllocString(unicodeId); + LPWSTR unicodeId = StringUtils::MultiByteToWideChar(nativeEntryId); + BSTR comId = SysAllocString(unicodeId); - res = (iServer->deleteContact(comId) == S_OK); + res = (iServer->deleteContact(comId) == S_OK); - SysFreeString(comId); - free(unicodeId); - } + SysFreeString(comId); + free(unicodeId); } + jniEnv->ReleaseStringUTFChars(id, nativeEntryId); return res; @@ -107,25 +94,15 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac { const char *nativeQuery = jniEnv->GetStringUTFChars(query, NULL); - if(MAPIBitness_isOutlookBitnessCompatible()) - { - MsOutlookAddrBookContactQuery_foreachMailUser( - nativeQuery, - (void *) MAPINotification_callCallbackMethod, - (void *) callback); - } - else + IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); + if(iServer) { - IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); - if(iServer) - { - LPWSTR unicodeQuery = StringUtils::MultiByteToWideChar(nativeQuery); - BSTR comQuery = SysAllocString(unicodeQuery); + LPWSTR unicodeQuery = StringUtils::MultiByteToWideChar(nativeQuery); + BSTR comQuery = SysAllocString(unicodeQuery); - iServer->foreachMailUser(comQuery); - SysFreeString(comQuery); - free(unicodeQuery); - } + iServer->foreachMailUser(comQuery); + SysFreeString(comQuery); + free(unicodeQuery); } jniEnv->ReleaseStringUTFChars(query, nativeQuery); @@ -149,25 +126,16 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac const char *nativeEntryId = jniEnv->GetStringUTFChars(entryId, NULL); - if(MAPIBitness_isOutlookBitnessCompatible()) - { - res = (MsOutlookAddrBookContactQuery_IMAPIProp_1DeleteProp( - propId, - nativeEntryId) == 1); - } - else + IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); + if(iServer) { - IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); - if(iServer) - { - LPWSTR unicodeId = StringUtils::MultiByteToWideChar(nativeEntryId); - BSTR comId = SysAllocString(unicodeId); + LPWSTR unicodeId = StringUtils::MultiByteToWideChar(nativeEntryId); + BSTR comId = SysAllocString(unicodeId); - res = (iServer->IMAPIProp_DeleteProp(propId, comId) == S_OK); + res = (iServer->IMAPIProp_DeleteProp(propId, comId) == S_OK); - SysFreeString(comId); - free(unicodeId); - } + SysFreeString(comId); + free(unicodeId); } jniEnv->ReleaseStringUTFChars(entryId, nativeEntryId); @@ -195,30 +163,22 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac const char *nativeEntryId = jniEnv->GetStringUTFChars(entryId, NULL); const char *nativeValue = jniEnv->GetStringUTFChars(value, NULL); - if(MAPIBitness_isOutlookBitnessCompatible()) - { - res = (MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString - (propId, nativeValue, nativeEntryId) == 1); - } - else + IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); + if(iServer) { - IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); - if(iServer) - { - LPWSTR unicodeValue - = StringUtils::MultiByteToWideChar(nativeValue); - BSTR comValue = SysAllocString(unicodeValue); - LPWSTR unicodeId = StringUtils::MultiByteToWideChar(nativeEntryId); - BSTR comId = SysAllocString(unicodeId); - - res = (iServer->IMAPIProp_SetPropString(propId, comValue, comId) - == S_OK); - - SysFreeString(comId); - free(unicodeId); - SysFreeString(comValue); - free(unicodeValue); - } + LPWSTR unicodeValue + = StringUtils::MultiByteToWideChar(nativeValue); + BSTR comValue = SysAllocString(unicodeValue); + LPWSTR unicodeId = StringUtils::MultiByteToWideChar(nativeEntryId); + BSTR comId = SysAllocString(unicodeId); + + res = (iServer->IMAPIProp_SetPropString(propId, comValue, comId) + == S_OK); + + SysFreeString(comId); + free(unicodeId); + SysFreeString(comValue); + free(unicodeValue); } jniEnv->ReleaseStringUTFChars(entryId, nativeEntryId); @@ -267,78 +227,64 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac if((propsType = (char*) malloc(propIdCount * sizeof(char))) != NULL) { - if(MAPIBitness_isOutlookBitnessCompatible()) + IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); + if(iServer) { - hr = MsOutlookAddrBookContactQuery_IMAPIProp_1GetProps( - nativeEntryId, + LPWSTR unicodeEntryId + = StringUtils::MultiByteToWideChar(nativeEntryId); + BSTR comEntryId = SysAllocString(unicodeEntryId); + + LPSAFEARRAY comPropIds + = SafeArrayCreateVector(VT_I4, 0, propIdCount); + SafeArrayLock(comPropIds); + comPropIds->pvData = nativePropIds; + SafeArrayUnlock(comPropIds); + + LPSAFEARRAY comProps; + LPSAFEARRAY comPropsLength; + LPSAFEARRAY comPropsType; + + hr = iServer->IMAPIProp_GetProps( + comEntryId, propIdCount, - nativePropIds, + comPropIds, flags, - props, + &comProps, + &comPropsLength, + &comPropsType); + + SafeArrayLock(comPropsType); + memcpy( + propsType, + comPropsType->pvData, + propIdCount * sizeof(char)); + SafeArrayUnlock(comPropsType); + SafeArrayDestroy(comPropsType); + + SafeArrayLock(comPropsLength); + memcpy( propsLength, - propsType); - } - else - { - IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); - if(iServer) + comPropsLength->pvData, + propIdCount * sizeof(unsigned long)); + SafeArrayUnlock(comPropsLength); + SafeArrayDestroy(comPropsLength); + + SafeArrayLock(comProps); + byte * data = (byte*) comProps->pvData; + for(int j = 0; j < propIdCount; ++j) { - LPWSTR unicodeEntryId - = StringUtils::MultiByteToWideChar(nativeEntryId); - BSTR comEntryId = SysAllocString(unicodeEntryId); - - LPSAFEARRAY comPropIds - = SafeArrayCreateVector(VT_I4, 0, propIdCount); - SafeArrayLock(comPropIds); - comPropIds->pvData = nativePropIds; - SafeArrayUnlock(comPropIds); - - LPSAFEARRAY comProps; - LPSAFEARRAY comPropsLength; - LPSAFEARRAY comPropsType; - - hr = iServer->IMAPIProp_GetProps( - comEntryId, - propIdCount, - comPropIds, - flags, - &comProps, - &comPropsLength, - &comPropsType); - - SafeArrayLock(comPropsType); - memcpy( - propsType, - comPropsType->pvData, - propIdCount * sizeof(char)); - SafeArrayUnlock(comPropsType); - SafeArrayDestroy(comPropsType); - - SafeArrayLock(comPropsLength); - memcpy( - propsLength, - comPropsLength->pvData, - propIdCount * sizeof(unsigned long)); - SafeArrayUnlock(comPropsLength); - SafeArrayDestroy(comPropsLength); - - SafeArrayLock(comProps); - byte * data = (byte*) comProps->pvData; - for(int j = 0; j < propIdCount; ++j) + if((props[j] = malloc(propsLength[j])) != NULL) { - if((props[j] = malloc(propsLength[j])) != NULL) - { - memcpy(props[j], data, propsLength[j]); - data += propsLength[j]; - } + memcpy(props[j], data, propsLength[j]); + data += propsLength[j]; } - SafeArrayUnlock(comProps); - SafeArrayDestroy(comProps); - - SafeArrayDestroy(comPropIds); - SysFreeString(comEntryId); - free(unicodeEntryId); } + SafeArrayUnlock(comProps); + SafeArrayDestroy(comProps); + + SafeArrayDestroy(comPropIds); + SysFreeString(comEntryId); + free(unicodeEntryId); } if(HR_SUCCEEDED(hr)) 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 531ed21..2bfc53b 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 @@ -24,16 +24,7 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac jniEnv,
notificationsDelegate);
- if(MAPIBitness_isOutlookBitnessCompatible())
- {
- hr = MsOutlookAddrBookContactSourceService_MAPIInitialize(
- version,
- flags);
- }
- else
- {
- hr = MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer();
- }
+ hr = MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer();
if (HR_FAILED(hr))
{
@@ -51,6 +42,6 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac {
MAPINotification_unregisterJniNotificationsDelegate(jniEnv);
- MsOutlookAddrBookContactSourceService_MAPIUninitialize();
+ MsOutlookAddrBookContactSourceService_MAPIUninitializeCOMServer();
}
|