Mitigate the following issue with the support for the Address Book of Mac OS X: if Microsoft Office is not installed or a 32-bit version of Microsoft Office is installed on 64-bit Windows and SIP Communicator, a dialog may appear to notify the SIP Communicator user that there is no default e-mail program.

cusax-fix
Lyubomir Marinov 15 years ago
parent 167d74256d
commit c0b0337671

@ -11,7 +11,7 @@ endif
CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/win32 -I$(OUTLOOK_MAPI_HEADERS) -I..
LDFLAGS = -shared -Wl,--kill-at
LIBS = -lmapi32 -luuid
LIBS = -lmapi32 -luuid -ladvapi32
TARGET = ../../../../lib/native/windows$(ARCH)/$(TARGET_BASENAME).dll
$(TARGET): \

@ -15,4 +15,7 @@
#include <mapitags.h>
#include <mapix.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif /* #ifndef _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_MSOUTLOOKMAPI_H_ */

@ -10,14 +10,138 @@
#include "MsOutlookMAPI.h"
#include "MsOutlookMAPIHResultException.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
JNIEXPORT void JNICALL
Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_MAPIInitialize
(JNIEnv *jniEnv, jclass clazz, jlong version, jlong flags)
{
MAPIINIT_0 mapiInit = { (ULONG) version, (ULONG) flags };
HRESULT hResult;
HKEY officeKey;
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,
_TEXT("Software\\Microsoft\\Office"),
0,
KEY_ENUMERATE_SUB_KEYS,
&officeKey))
{
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(
officeKey,
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, _TEXT("\\Outlook\\InstallRoot"), 20 * sizeof(TCHAR));
*(str + 20) = 0;
if ((ERROR_SUCCESS
== RegOpenKeyEx(
officeKey,
installRootKeyName,
0,
KEY_QUERY_VALUE,
&installRootKey))
&& (ERROR_SUCCESS
== RegQueryValueEx(
installRootKey,
_TEXT("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 */);
hResult = MAPIInitialize(&mapiInit);
if (pathValueSize <= sizeof(installRootKeyName))
pathValue = installRootKeyName;
else
{
pathValue = (TCHAR *) malloc(pathValueSize);
if (!pathValue)
continue;
}
if (ERROR_SUCCESS
== RegQueryValueEx(
installRootKey,
_TEXT("Path"),
NULL,
NULL,
(LPBYTE) pathValue, &pathValueSize))
{
DWORD pathValueLength = pathValueSize / sizeof(TCHAR);
if (pathValueLength)
{
DWORD fileAttributes;
str = pathValue + (pathValueLength - 1);
if (*str)
str++;
memcpy(str, "\\Outlook.exe", 12 * sizeof(TCHAR));
*(str + 12) = 0;
fileAttributes = GetFileAttributes(pathValue);
if (INVALID_FILE_ATTRIBUTES != fileAttributes)
{
MAPIINIT_0 mapiInit
= { (ULONG) version, (ULONG) flags };
hResult = MAPIInitialize(&mapiInit);
}
}
}
if (pathValue != installRootKeyName)
free(pathValue);
}
}
}
if (HR_FAILED(hResult))
{

@ -69,7 +69,17 @@ else if (OSUtils.IS_MAC)
else
return;
css = (ContactSourceService) Class.forName(cssClassName).newInstance();
try
{
css
= (ContactSourceService)
Class.forName(cssClassName).newInstance();
}
catch (Exception ex)
{
logger.error("Failed to instantiate " + cssClassName, ex);
return;
}
try
{
cssServiceRegistration

Loading…
Cancel
Save