diff --git a/lib/native/windows-64/jmsofficecomm.dll b/lib/native/windows-64/jmsofficecomm.dll index 974b6172a..6ce390164 100755 Binary files a/lib/native/windows-64/jmsofficecomm.dll and b/lib/native/windows-64/jmsofficecomm.dll differ diff --git a/lib/native/windows/jmsofficecomm.dll b/lib/native/windows/jmsofficecomm.dll index 7d59f640a..e51bc3b46 100755 Binary files a/lib/native/windows/jmsofficecomm.dll and b/lib/native/windows/jmsofficecomm.dll differ diff --git a/src/native/build.xml b/src/native/build.xml index 3fe779417..ad408af37 100644 --- a/src/native/build.xml +++ b/src/native/build.xml @@ -1,4 +1,4 @@ - + @@ -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= -Darch=32 ant msofficecomm -DOCS2007SDK= -Darch=64 @@ -652,6 +652,15 @@ if="is.running.windows" depends="init-native"> + + + + + + + + + + diff --git a/src/native/windows/msofficecomm/OutOfProcessServer.cxx b/src/native/windows/msofficecomm/OutOfProcessServer.cxx index 531147139..416ba76d8 100644 --- a/src/native/windows/msofficecomm/OutOfProcessServer.cxx +++ b/src/native/windows/msofficecomm/OutOfProcessServer.cxx @@ -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; } diff --git a/src/native/windows/msofficecomm/msofficecomm.vcxproj b/src/native/windows/msofficecomm/msofficecomm.vcxproj index 96391dfb6..b74f1d909 100644 --- a/src/native/windows/msofficecomm/msofficecomm.vcxproj +++ b/src/native/windows/msofficecomm/msofficecomm.vcxproj @@ -74,11 +74,13 @@ true C:\Program Files (x86)\Microsoft Office Communicator\SDK;C:\Java\jdk8\include;C:\Java\jdk8\include\win32;$(IncludePath) j$(ProjectName) + ..\..\..\..\lib\native\windows\ true j$(ProjectName) C:\Program Files %28x86%29\Microsoft Office Communicator\SDK;C:\Java\JDK8x64\include;C:\Java\JDK8x64\include\win32;$(IncludePath) + ..\..\..\..\lib\native\windows-64\ false diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java b/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java index 264f830c8..28754e4d7 100644 --- a/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java +++ b/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java @@ -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); } } diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java b/src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java index 2b108f86c..632a933fe 100644 --- a/src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java +++ b/src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java @@ -88,7 +88,6 @@ public void start(BundleContext bundleContext) } finally { - RegistryHandler.checkRegistryKeys(); if (stopMessenger) Messenger.stop(bundleContext); } diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/OutOfProcessServer.java b/src/net/java/sip/communicator/plugin/msofficecomm/OutOfProcessServer.java index 7415163f1..c412e6690 100644 --- a/src/net/java/sip/communicator/plugin/msofficecomm/OutOfProcessServer.java +++ b/src/net/java/sip/communicator/plugin/msofficecomm/OutOfProcessServer.java @@ -25,11 +25,6 @@ */ class OutOfProcessServer { - static - { - System.loadLibrary("jmsofficecomm"); - } - static native int start(); static native int stop(); diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/RegistryHandler.java b/src/net/java/sip/communicator/plugin/msofficecomm/RegistryHandler.java deleted file mode 100644 index 1cb11f630..000000000 --- a/src/net/java/sip/communicator/plugin/msofficecomm/RegistryHandler.java +++ /dev/null @@ -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"); - } -}