Merge branch 'office-im-registry'

Closes #159
sip-call-params
Ingo Bauersachs 10 years ago
commit e705f005f9

@ -1,4 +1,4 @@
<project name="jitsi-native" default="help-native">
<project name="jitsi-native" default="help-native" xmlns:if="ant:if">
<import file="../../build.xml"/>
<!-- additionnal property -->
@ -641,7 +641,7 @@
http://www.microsoft.com/en-us/download/details.aspx?id=10176
- compile the tlb:
cd src/native/windows/msofficecomm
midl "C:\Program Files (x86)\Microsoft Office Communicator\SDK\"
midl "C:\Program Files (x86)\Microsoft Office Communicator\SDK\msgrua.idl"
- run ant:
ant msofficecomm -DOCS2007SDK=<path here, escape \ with \\> -Darch=32
ant msofficecomm -DOCS2007SDK=<path here, escape \ with \\> -Darch=64
@ -652,6 +652,15 @@
if="is.running.windows"
depends="init-native">
<fail message="OCS 2007 SDK not set!" unless="OCS2007SDK" />
<exec executable="windres">
<arg value="-i"/>
<arg value="${src}\native\windows\msofficecomm\Resources.rc"/>
<arg value="-o"/>
<arg value="${obj}\jmsofficecommtlb.o"/>
<arg value="-F"/>
<arg value="pe-i386" if:set="cross_32"/>
<arg value="pe-x86-64" if:set="cross_64"/>
</exec>
<cc
name="gcc"
objdir="${obj}"
@ -679,6 +688,7 @@
<libset libs="advapi32, uuid, ole32, oleaut32, msi, stdc++" />
<fileset dir="${src}\native\windows\msofficecomm" includes="*.cxx" />
<fileset dir="${obj}" includes="jmsofficecommtlb.o"/>
</cc>
<exec executable="strip">
<arg value="-x"/>

@ -244,6 +244,11 @@ HRESULT OutOfProcessServer::loadRegTypeLib()
LPTYPELIB iTypeLib;
HRESULT hr = ::LoadRegTypeLib(LIBID_CommunicatorUA, 1, 0, 0, &iTypeLib);
Log::d(
_T("OutOfProcessServer::loadRegTypeLib:")
_T(" LoadRegTypeLib=%08X;")
_T("\n"),
hr);
if (SUCCEEDED(hr))
_iTypeLib = iTypeLib;
else
@ -261,50 +266,41 @@ HRESULT OutOfProcessServer::loadRegTypeLib()
WCHAR path[MAX_PATH + 1];
DWORD pathCapacity = sizeof(path) / sizeof(WCHAR);
DWORD pathLength = ::GetModuleFileNameW(module, path, pathCapacity);
if (pathLength && (pathLength < pathCapacity))
{
hr = ::LoadTypeLibEx(path, REGKIND_NONE, &iTypeLib);
Log::d(
_T("OutOfProcessServer::loadRegTypeLib:")
_T(" LoadTypeLibEx(%s)=%08X;")
_T("\n"),
path,
hr);
if (SUCCEEDED(hr))
{
HMODULE oleaut32 = ::GetModuleHandle(_T("oleaut32.dll"));
if (oleaut32)
hr = ::RegisterTypeLibForUser(iTypeLib, path, NULL);
Log::d(
_T("OutOfProcessServer::loadRegTypeLib:")
_T(" RegisterTypeLibForUser=%08X;")
_T("\n"),
hr);
if (SUCCEEDED(hr))
{
typedef HRESULT (WINAPI *RTLFU)(LPTYPELIB,LPOLESTR,LPOLESTR);
RTLFU registerTypeLibForUser
= (RTLFU)
::GetProcAddress(
oleaut32,
"RegisterTypeLibForUser");
if (registerTypeLibForUser)
{
hr = registerTypeLibForUser(iTypeLib, path, NULL);
if (SUCCEEDED(hr))
{
/*
* The whole point of what has been done till
* now is securing the success of future calls
* to LoadRegTypeLib. Make sure that is indeed
* the case.
*/
iTypeLib->Release();
hr
= ::LoadRegTypeLib(
LIBID_CommunicatorUA,
1,
0,
0,
&iTypeLib);
if (SUCCEEDED(hr))
_iTypeLib = iTypeLib;
}
}
else
hr = E_UNEXPECTED;
/*
* The whole point of what has been done till
* now is securing the success of future calls
* to LoadRegTypeLib. Make sure that is indeed
* the case.
*/
iTypeLib->Release();
hr = ::LoadRegTypeLib(
LIBID_CommunicatorUA, 1, 0, 0, &iTypeLib);
Log::d(
_T("OutOfProcessServer::loadRegTypeLib:")
_T(" LoadRegTypeLib=%08X;")
_T("\n"),
hr);
if (SUCCEEDED(hr))
_iTypeLib = iTypeLib;
}
else
hr = E_UNEXPECTED;
@ -429,12 +425,28 @@ unsigned __stdcall OutOfProcessServer::run(void *)
HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
unsigned ret = 0;
Log::d(
_T("OutOfProcessServer::run:")
_T(" CoInitializeEx=%08X;")
_T("\n"),
hr);
if (SUCCEEDED(hr))
{
hr = loadRegTypeLib();
Log::d(
_T("OutOfProcessServer::run:")
_T(" loadRegTypeLib=%08X;")
_T("\n"),
hr);
if (SUCCEEDED(hr))
{
if (ERROR_SUCCESS == setIMProvidersCommunicatorUpAndRunning(1))
hr = setIMProvidersCommunicatorUpAndRunning(1);
Log::d(
_T("OutOfProcessServer::run:")
_T(" setIMProvidersCommunicatorUpAndRunning(1)=%08X;")
_T("\n"),
hr);
if (ERROR_SUCCESS == hr)
{
MSG msg;
@ -446,10 +458,20 @@ unsigned __stdcall OutOfProcessServer::run(void *)
::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
hr = registerClassObjects();
Log::d(
_T("OutOfProcessServer::run:")
_T(" registerClassObjects=%08X;")
_T("\n"),
hr);
if (SUCCEEDED(hr))
{
if (ERROR_SUCCESS
== setIMProvidersCommunicatorUpAndRunning(2))
hr = setIMProvidersCommunicatorUpAndRunning(2);
Log::d(
_T("OutOfProcessServer::run:")
_T(" setIMProvidersCommunicatorUpAndRunning(2)=%08X;")
_T("\n"),
hr);
if (ERROR_SUCCESS == hr)
{
HANDLE threadHandle = _threadHandle;
BOOL logMsgWaitForMultipleObjectsExFailed = TRUE;
@ -526,51 +548,12 @@ unsigned __stdcall OutOfProcessServer::run(void *)
DWORD OutOfProcessServer::setIMProvidersCommunicatorUpAndRunning(DWORD dw)
{
DWORD lastError;
if (dw)
{
/*
* Testing on various machines/setups has shown that the following may
* or may not succeed without affecting the presence integration so just
* try them and then go on with the rest regardless of their success.
*/
lastError = ERROR_SUCCESS;
regCreateKeyAndSetValue(
_T("Software\\Microsoft\\Office\\11.0\\Common\\PersonaMenu"),
_T("RTCApplication"),
3);
regCreateKeyAndSetValue(
_T("Software\\Microsoft\\Office\\12.0\\Common\\PersonaMenu"),
_T("RTCApplication"),
3);
regCreateKeyAndSetValue(
_T("Software\\Microsoft\\Office\\11.0\\Common\\PersonaMenu"),
_T("QueryServiceForStatus"),
2);
regCreateKeyAndSetValue(
_T("Software\\Microsoft\\Office\\12.0\\Common\\PersonaMenu"),
_T("QueryServiceForStatus"),
2);
regCreateKeyAndSetValue(
_T("Software\\Microsoft\\Office\\11.0\\Outlook\\IM"),
_T("SetOnlineStatusLevel"),
3);
regCreateKeyAndSetValue(
_T("Software\\Microsoft\\Office\\12.0\\Outlook\\IM"),
_T("SetOnlineStatusLevel"),
3);
}
else
lastError = ERROR_SUCCESS;
if (ERROR_SUCCESS == lastError)
{
lastError
DWORD lastError
= regCreateKeyAndSetValue(
_T("Software\\IM Providers\\Communicator"),
_T("Software\\IM Providers\\Jitsi"),
_T("UpAndRunning"),
dw);
}
return lastError;
}

@ -74,11 +74,13 @@
<LinkIncremental>true</LinkIncremental>
<IncludePath>C:\Program Files (x86)\Microsoft Office Communicator\SDK;C:\Java\jdk8\include;C:\Java\jdk8\include\win32;$(IncludePath)</IncludePath>
<TargetName>j$(ProjectName)</TargetName>
<OutDir>..\..\..\..\lib\native\windows\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<TargetName>j$(ProjectName)</TargetName>
<IncludePath>C:\Program Files %28x86%29\Microsoft Office Communicator\SDK;C:\Java\JDK8x64\include;C:\Java\JDK8x64\include\win32;$(IncludePath)</IncludePath>
<OutDir>..\..\..\..\lib\native\windows-64\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>

@ -168,18 +168,16 @@ public void serviceChanged(ServiceEvent event)
static
{
String lib = "jmsofficecomm";
try
{
System.loadLibrary(lib);
System.loadLibrary("jmsofficecomm");
}
catch (Throwable t)
{
logger.error(
"Failed to load native library " + lib + ": "
+ t.getMessage());
RegistryHandler.checkRegistryKeys();
logger.error("Couldn't load jmsofficecomm. If you are debugging,"
+ " make sure that HKLM\\SOFTWARE[\\Wow6432Node]\\Microsoft\\"
+ "Office\\Outlook\\Call Integration\\IMApplication is set to"
+ " javaw.exe; " + t.getMessage());
throw new RuntimeException(t);
}
}

@ -88,7 +88,6 @@ public void start(BundleContext bundleContext)
}
finally
{
RegistryHandler.checkRegistryKeys();
if (stopMessenger)
Messenger.stop(bundleContext);
}

@ -25,11 +25,6 @@
*/
class OutOfProcessServer
{
static
{
System.loadLibrary("jmsofficecomm");
}
static native int start();
static native int stop();

@ -1,262 +0,0 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.java.sip.communicator.plugin.msofficecomm;
import net.java.sip.communicator.util.Logger;
import com.sun.jna.platform.win32.*;
/**
* Checks the registry keys used by
* Outlook.
*
* @author Hristo Terezov
*/
public class RegistryHandler
{
/**
* The logger.
*/
private static Logger logger = Logger.getLogger(RegistryHandler.class);
/**
* The key under which the IM application is placed.
*/
private static String REGISTRY_IM_APPLICATION_KEY
= "Software\\IM Providers";
/**
* The value under which the default IM application is placed.
*/
private static String REGISTRY_DEFAULT_IM_APPLICATION_VALUE
= "DefaultIMApp";
/**
* The key for the outlook call integration.
*/
private static String REGISTRY_CALL_INTEGRATION
= "Software\\Microsoft\\Office\\Outlook\\Call Integration";
/**
* The value for the outlook call integration.
*/
private static String REGISTRY_CALL_INTEGRATION_VALUE
= "IMApplication";
/**
* The key for the outlook rtc application.
*/
private static String REGISTRY_OFFICE11_RTC_APPLICATION
= "Software\\Microsoft\\Office\\11.0\\Common\\PersonaMenu";
/**
* The key for the outlook rtc application.
*/
private static String REGISTRY_OFFICE12_RTC_APPLICATION
= "Software\\Microsoft\\Office\\12.0\\Common\\PersonaMenu";
/**
* The value for the rtc application.
*/
private static String REGISTRY_RTC_APPLICATION_VALUE = "RTCApplication";
/**
* The key for Communicator IM App.
*/
private static String REGISTRY_COMMUNICATOR_UP
= "Software\\IM Providers\\Communicator";
/**
* Up and running value.
*/
private static String REGISTRY_UP_RUNNING_VALUE = "UpAndRunning";
/**
* Checks the existence of the registry keys for outlook call integration.
*/
private static void checkCallIntegration()
{
if(!Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE,
REGISTRY_CALL_INTEGRATION)
|| !Advapi32Util.registryValueExists(WinReg.HKEY_LOCAL_MACHINE,
REGISTRY_CALL_INTEGRATION,
REGISTRY_CALL_INTEGRATION_VALUE))
{
logger.error(REGISTRY_CALL_INTEGRATION +
" doesn't exists in registry");
return;
}
logger.info("Call integration: " +
Advapi32Util.registryGetStringValue(
WinReg.HKEY_LOCAL_MACHINE,
REGISTRY_CALL_INTEGRATION,
REGISTRY_CALL_INTEGRATION_VALUE));
}
/**
* Checks the existence of the registry keys for outlook rtc application.
*/
private static void checkRTCApplication()
{
if(!Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER,
REGISTRY_OFFICE11_RTC_APPLICATION)
|| !Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER,
REGISTRY_OFFICE11_RTC_APPLICATION,
REGISTRY_RTC_APPLICATION_VALUE))
{
logger.error(REGISTRY_OFFICE11_RTC_APPLICATION +
" doesn't exists in registry");
}
else
{
logger.info("RTC application: " +
Advapi32Util.registryGetIntValue(
WinReg.HKEY_CURRENT_USER,
REGISTRY_OFFICE11_RTC_APPLICATION,
REGISTRY_RTC_APPLICATION_VALUE));
}
if(!Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER,
REGISTRY_OFFICE12_RTC_APPLICATION)
|| !Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER,
REGISTRY_OFFICE12_RTC_APPLICATION,
REGISTRY_RTC_APPLICATION_VALUE))
{
logger.error(REGISTRY_OFFICE12_RTC_APPLICATION +
" doesn't exists in registry");
}
else
{
logger.info("RTC application: " +
Advapi32Util.registryGetIntValue(
WinReg.HKEY_CURRENT_USER,
REGISTRY_OFFICE12_RTC_APPLICATION,
REGISTRY_RTC_APPLICATION_VALUE));
}
}
/**
* Checks if the registry key for running Jitsi and Communicator.
*/
private static void checkUpAndRunning()
{
if(!Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER,
REGISTRY_COMMUNICATOR_UP)
|| !Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER,
REGISTRY_COMMUNICATOR_UP,
REGISTRY_UP_RUNNING_VALUE))
{
logger.error(REGISTRY_COMMUNICATOR_UP +
" doesn't exists in registry");
}
else
{
logger.info("Communicator up and running value: " +
Advapi32Util.registryGetIntValue(
WinReg.HKEY_CURRENT_USER,
REGISTRY_COMMUNICATOR_UP,
REGISTRY_UP_RUNNING_VALUE));
}
if(!Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER,
REGISTRY_IM_APPLICATION_KEY + "\\" + getApplicationName())
|| !Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER,
REGISTRY_IM_APPLICATION_KEY + "\\" + getApplicationName(),
REGISTRY_UP_RUNNING_VALUE))
{
logger.error(REGISTRY_IM_APPLICATION_KEY +
" doesn't exists in registry");
}
else
{
logger.info("Up and running value: " +
Advapi32Util.registryGetIntValue(
WinReg.HKEY_CURRENT_USER,
REGISTRY_IM_APPLICATION_KEY + "\\"
+ getApplicationName(),
REGISTRY_UP_RUNNING_VALUE));
}
}
/**
* Logs registry information.
*/
public static void checkRegistryKeys()
{
checkDefaultIMApp();
checkRegisteredIMApp();
checkCallIntegration();
checkRTCApplication();
checkUpAndRunning();
}
/**
* Checks whether Jitsi is the default IM application.
*/
private static void checkDefaultIMApp()
{
if(!Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER,
REGISTRY_IM_APPLICATION_KEY) ||
!Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER,
REGISTRY_IM_APPLICATION_KEY,
REGISTRY_DEFAULT_IM_APPLICATION_VALUE))
{
logger.error(REGISTRY_IM_APPLICATION_KEY
+ " doesn't extsts");
return;
}
logger.info("Default IM App: " + Advapi32Util.registryGetStringValue(
WinReg.HKEY_CURRENT_USER,
REGISTRY_IM_APPLICATION_KEY,
REGISTRY_DEFAULT_IM_APPLICATION_VALUE));
}
/**
* Checks whether Jitsi is registered as IM provider.
*/
private static void checkRegisteredIMApp()
{
if(!Advapi32Util.registryKeyExists(
WinReg.HKEY_LOCAL_MACHINE,
REGISTRY_IM_APPLICATION_KEY + "\\" + getApplicationName()))
{
logger.error(REGISTRY_IM_APPLICATION_KEY + "\\" +
getApplicationName() + " doesn;t exsts");
return;
}
logger.info("Registered IM App friendly name: "
+ Advapi32Util.registryGetStringValue(
WinReg.HKEY_LOCAL_MACHINE,
REGISTRY_IM_APPLICATION_KEY + "\\" +
getApplicationName(),
"FriendlyName"));
}
/**
* Returns the application name.
* @return the application name
*/
private static String getApplicationName()
{
return MsOfficeCommActivator.getResources().getSettingsString(
"service.gui.APPLICATION_NAME");
}
}
Loading…
Cancel
Save