Unify sal plugin loaders

Change-Id: Ic099761eaff80349e985ccf62e3f4aa6b2e98022
Reviewed-on: https://gerrit.libreoffice.org/61103
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
This commit is contained in:
Jan-Marek Glogowski
2018-10-02 11:24:38 +02:00
parent 3af4e1a082
commit 0f3be2e19f
16 changed files with 115 additions and 481 deletions
-5
View File
@@ -259,8 +259,6 @@ public:
platform specific data structures.
@attention The initialization of the application itself is done in Init()
@see InitSalData is implemented by platform specific code.
*/
Application();
@@ -268,9 +266,6 @@ public:
Deinitializes the LibreOffice global instance data structure, then
deinitializes any platform specific data structures.
@see ImplDeInitSVData deinitializes the global instance data,
DeInitSalData is implemented by platform specific code
*/
virtual ~Application();
+1 -3
View File
@@ -17915,7 +17915,6 @@ vcl/osx/salinst.cxx
vcl/osx/salmenu.cxx
vcl/osx/salnativewidgets.cxx
vcl/osx/salobj.cxx
vcl/osx/salplug.cxx
vcl/osx/salprn.cxx
vcl/osx/salsys.cxx
vcl/osx/saltimer.cxx
@@ -17958,6 +17957,7 @@ vcl/source/app/dndhelp.cxx
vcl/source/app/help.cxx
vcl/source/app/i18nhelp.cxx
vcl/source/app/idle.cxx
vcl/source/app/salplug.cxx
vcl/source/app/salusereventlist.cxx
vcl/source/app/salvtables.cxx
vcl/source/app/scheduler.cxx
@@ -18323,7 +18323,6 @@ vcl/unx/generic/gdi/xrender_peer.cxx
vcl/unx/generic/gdi/xrender_peer.hxx
vcl/unx/generic/glyphs/freetype_glyphcache.cxx
vcl/unx/generic/glyphs/glyphcache.cxx
vcl/unx/generic/plugadapt/salplug.cxx
vcl/unx/generic/print/bitmap_gfx.cxx
vcl/unx/generic/print/common_gfx.cxx
vcl/unx/generic/print/genprnpsp.cxx
@@ -18450,7 +18449,6 @@ vcl/unx/x11/xlimits.cxx
vcl/win/app/saldata.cxx
vcl/win/app/salinfo.cxx
vcl/win/app/salinst.cxx
vcl/win/app/salplug.cxx
vcl/win/app/salshl.cxx
vcl/win/app/saltimer.cxx
vcl/win/gdi/DWriteTextRenderer.cxx
+12 -8
View File
@@ -106,6 +106,7 @@ $(eval $(call gb_Library_use_externals,vcl,\
lcms2 \
mdds_headers \
))
ifeq ($(DISABLE_GUI),)
$(eval $(call gb_Library_use_externals,vcl,\
epoxy \
@@ -474,7 +475,7 @@ vcl_headless_freetype_code=\
ifeq ($(USING_X11),TRUE)
$(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/unx/generic/plugadapt/salplug \
vcl/source/app/salplug \
vcl/unx/generic/printer/jobdata \
vcl/unx/generic/printer/ppdparser \
vcl/unx/generic/gdi/nativewindowhandleprovider \
@@ -520,8 +521,10 @@ $(eval $(call gb_Library_add_libs,vcl,\
-lpthread \
))
endif
else
$(eval $(call gb_Library_add_exception_objects,vcl,\
else # ! DISABLE_GUI
$(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/opengl/DeviceInfo \
vcl/opengl/gdiimpl \
vcl/opengl/salbmp \
@@ -547,7 +550,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/opengl/x11/X11DeviceInfo \
))
endif
endif
endif # ! DISABLE_GUI
ifeq ($(OS),HAIKU)
$(eval $(call gb_Library_add_exception_objects,vcl,\
@@ -563,7 +567,7 @@ $(eval $(call gb_Library_add_libs,vcl,\
))
$(eval $(call gb_Library_add_exception_objects,vcl, \
$(if $(or $(ENABLE_QT5),$(ENABLE_KDE5)),vcl/unx/generic/plugadapt/salplug) \
$(if $(or $(ENABLE_QT5),$(ENABLE_KDE5)),vcl/source/app/salplug) \
))
$(eval $(call gb_Library_use_externals,vcl,\
@@ -574,6 +578,7 @@ $(eval $(call gb_Library_use_externals,vcl,\
))
endif
ifeq ($(OS),ANDROID)
$(eval $(call gb_Library_add_libs,vcl,\
-llog \
@@ -605,7 +610,6 @@ $(eval $(call gb_Library_add_cxxflags,vcl,\
$(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/ios/iosinst \
vcl/ios/dummies \
$(vcl_really_generic_code) \
$(vcl_coretext_code) \
$(vcl_quartz_code) \
$(vcl_headless_code) \
@@ -624,7 +628,7 @@ $(eval $(call gb_Library_use_system_darwin_frameworks,vcl,\
))
$(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/osx/salplug \
vcl/source/app/salplug \
))
endif
@@ -633,7 +637,7 @@ ifeq ($(OS),WNT)
$(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/opengl/win/WinDeviceInfo \
vcl/opengl/win/blocklist_parser \
vcl/win/app/salplug \
vcl/source/app/salplug \
))
$(eval $(call gb_Library_use_system_win32_libs,vcl,\
+1 -1
View File
@@ -80,7 +80,7 @@ LibreOffice (and OpenOffice).
== COM threading ==
The way COM is used in LO generally:
- vcl InitSalData() puts main thread into Single-threaded Apartment (STA)
- vcl puts main thread into Single-threaded Apartment (STA)
- oslWorkerWrapperFunction() puts every thread spawned via oslCreateThread()
into MTA (free-threaded)
-5
View File
@@ -152,11 +152,6 @@ SalFrame *AndroidSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags
return new AndroidSalFrame( this, pParent, nStyle );
}
// All the interesting stuff is slaved from the AndroidSalInstance
void InitSalData() {}
void DeInitSalData() {}
void InitSalMain() {}
void SalAbort( const OUString& rErrorText, bool bDumpCore )
{
OUString aError( rErrorText );
-5
View File
@@ -51,11 +51,6 @@ public:
virtual bool ErrorTrapPop( bool ) override { return false; }
};
// All the interesting stuff is slaved from the AndroidSalInstance
void InitSalData() {}
void DeInitSalData() {}
void InitSalMain() {}
void SalAbort( const OUString& rErrorText, bool bDumpCore )
{
OUString aError( rErrorText );
+1 -1
View File
@@ -57,7 +57,7 @@ class SystemFontList;
#define INVALID_CURSOR_PTR reinterpret_cast<NSCursor*>(0xdeadbeef)
// Singleton, instantiated from Application::Application() in
// vcl/source/app/svapp.cxx through InitSalData().
// vcl/source/app/svapp.cxx.
class SalData
{
+1 -6
View File
@@ -77,7 +77,7 @@ enum class SalFrameStyleFlags;
typedef struct _cairo_font_options cairo_font_options_t;
class VCL_PLUGIN_PUBLIC SalInstance
class VCL_DLLPUBLIC SalInstance
{
private:
rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst;
@@ -211,11 +211,6 @@ void SalAbort( const OUString& rErrorText, bool bDumpCore );
VCL_DLLPUBLIC const OUString& SalGetDesktopEnvironment();
void InitSalData(); // called from Application-Ctor
void DeInitSalData(); // called from Application-Dtor
void InitSalMain();
#endif // INCLUDED_VCL_INC_SALINST_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-1
View File
@@ -118,7 +118,6 @@ public:
std::set< HMENU > mhMenuSet; // keeps track of menu handles created by VCL, used by IsKnownMenuHandle()
std::map< UINT,sal_uInt16 > maVKMap; // map some dynamic VK_* entries
// must be deleted before exit(), so delete it in DeInitSalData()
std::unique_ptr<TextOutRenderer> m_pD2DWriteTextOutRenderer;
// tdf#107205 need 2 instances because D2DWrite can't rotate text
std::unique_ptr<TextOutRenderer> m_pExTextOutRenderer;
-5
View File
@@ -138,11 +138,6 @@ SalFrame *IosSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nSt
return new IosSalFrame( this, pParent, nStyle );
}
// All the interesting stuff is slaved from the IosSalInstance
void InitSalData() {}
void DeInitSalData() {}
void InitSalMain() {}
void SalAbort( const OUString& rErrorText, bool bDumpCore )
{
(void) bDumpCore;
-6
View File
@@ -192,12 +192,6 @@ void SalAbort( const OUString& rErrorText, bool bDumpCore )
_exit(1);
}
const OUString& SalGetDesktopEnvironment()
{
static OUString aDesktopEnvironment( "MacOSX" );
return aDesktopEnvironment;
}
SalYieldMutex::SalYieldMutex()
: m_aCodeBlock( nullptr )
{
-167
View File
@@ -1,167 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you 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 .
*/
#include <osl/module.hxx>
#include <osl/process.h>
#include <rtl/bootstrap.hxx>
#include <rtl/process.h>
#include <sal/log.hxx>
#include <salinst.hxx>
#include <saldatabasic.hxx>
#include <config_vclplug.h>
#include <desktop/crashreport.hxx>
#include <cstdio>
extern "C" {
typedef SalInstance*(*salFactoryProc)();
}
static oslModule pCloseModule = nullptr;
static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = false )
{
SalInstance* pInst = nullptr;
OUString aModule(
#ifdef SAL_DLLPREFIX
SAL_DLLPREFIX
#endif
"vclplug_" + rModuleBase + "lo" SAL_DLLEXTENSION );
osl::Module aMod;
if (aMod.loadRelative(reinterpret_cast<oslGenericFunction>(&tryInstance), aModule, SAL_LOADMODULE_GLOBAL))
{
salFactoryProc aProc = reinterpret_cast<salFactoryProc>(aMod.getFunctionSymbol("create_SalInstance"));
if (aProc)
{
pInst = aProc();
SAL_INFO(
"vcl.plugadapt",
"sal plugin " << aModule << " produced instance " << pInst);
if (pInst)
{
pCloseModule = static_cast<oslModule>(aMod);
aMod.release();
}
}
else
{
SAL_WARN(
"vcl.plugadapt",
"could not load symbol create_SalInstance from shared object "
<< aModule);
}
}
else if (bForce)
{
SAL_WARN("vcl.plugadapt", "could not load shared object " << aModule);
}
else
{
SAL_INFO("vcl.plugadapt", "could not load shared object " << aModule);
}
// coverity[leaked_storage] - this is on purpose
return pInst;
}
SalInstance *CreateSalInstance()
{
SalInstance *pInst = nullptr;
OUString aUsePlugin;
rtl::Bootstrap::get( "SAL_USE_VCLPLUGIN", aUsePlugin );
if( !aUsePlugin.isEmpty() )
pInst = tryInstance( aUsePlugin, true );
// fallback, try everything
static const char* const pPlugin[] = { "osx" };
for ( int i = 0; !pInst && i != SAL_N_ELEMENTS(pPlugin); ++i )
pInst = tryInstance( OUString::createFromAscii( pPlugin[ i ] ) );
if( ! pInst )
{
std::fprintf( stderr, "no suitable windowing system found, exiting.\n" );
_exit( 1 );
}
// acquire SolarMutex
pInst->AcquireYieldMutex();
return pInst;
}
void DestroySalInstance( SalInstance *pInst )
{
// release SolarMutex
pInst->ReleaseYieldMutexAll();
delete pInst;
if( pCloseModule )
osl_unloadModule( pCloseModule );
}
void InitSalData()
{
}
void DeInitSalData()
{
}
void InitSalMain()
{
}
void SalAbort( const OUString& rErrorText, bool bDumpCore )
{
if( rErrorText.isEmpty() )
std::fprintf( stderr, "Application Error\n" );
else
{
CrashReporter::AddKeyValue("AbortMessage", rErrorText);
std::fprintf( stderr, "%s\n", OUStringToOString(rErrorText, osl_getThreadTextEncoding()).getStr() );
}
if( bDumpCore )
abort();
else
_exit(1);
}
const OUString& SalGetDesktopEnvironment()
{
static OUString aDesktopEnvironment( "Windows" );
return aDesktopEnvironment;
}
SalData::SalData() :
m_pInstance(nullptr),
m_pPIManager(nullptr)
{
}
SalData::~SalData() COVERITY_NOEXCEPT_FALSE
{
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -25,16 +25,32 @@
#include <sal/log.hxx>
#include <salinst.hxx>
#include <unx/gensys.h>
#include <unx/gendata.hxx>
#include <headless/svpinst.hxx>
#include <unx/desktops.hxx>
#include <printerinfomanager.hxx>
#include <config_vclplug.h>
#include <desktop/crashreport.hxx>
#include <cstdio>
#ifndef _WIN32
#include <headless/svpinst.hxx>
#include <printerinfomanager.hxx>
#include <unx/desktops.hxx>
#include <unx/gensys.h>
#include <unx/gendata.hxx>
#include <unistd.h>
#else
#include <saldatabasic.hxx>
#include <Windows.h>
#endif
#include <cstdio>
#ifdef ANDROID
#error "Android has no plugin infrastructure!"
#endif
#if !(defined _WIN32 || defined MACOSX)
#define DESKTOPDETECT
#define HEADLESS_VCLPLUG
#endif
extern "C" {
typedef SalInstance*(*salFactoryProc)();
@@ -42,32 +58,14 @@ typedef SalInstance*(*salFactoryProc)();
namespace {
// HACK to obtain Application::IsHeadlessModeEnabled early on, before
// Application::EnableHeadlessMode has potentially been called:
bool IsHeadlessModeRequested()
{
if (Application::IsHeadlessModeEnabled()) {
return true;
}
sal_uInt32 n = rtl_getAppCommandArgCount();
for (sal_uInt32 i = 0; i < n; ++i) {
OUString arg;
rtl_getAppCommandArg(i, &arg.pData);
if ( arg == "--headless" || arg == "-headless" ) {
return true;
}
}
return false;
}
oslModule pCloseModule = nullptr;
}
static oslModule pCloseModule = nullptr;
static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = false )
SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = false )
{
#ifdef HEADLESS_VCLPLUG
if (rModuleBase == "svp")
return svp_create_SalInstance();
#endif
SalInstance* pInst = nullptr;
OUString aModule(
@@ -91,7 +89,6 @@ static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = fals
pCloseModule = static_cast<oslModule>(aMod);
aMod.release();
#ifndef ANDROID
/*
* Recent GTK+ versions load their modules with RTLD_LOCAL, so we can
* not access the 'gnome_accessibility_module_shutdown' anymore.
@@ -100,11 +97,10 @@ static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = fals
* #i109007# KDE3 seems to have the same problem.
* And same applies for KDE4.
*/
if( rModuleBase == "gtk" || rModuleBase == "gtk3" || rModuleBase == "kde4" || rModuleBase == "gtk3_kde5")
if( rModuleBase == "gtk" || rModuleBase == "gtk3" || rModuleBase == "kde4" || rModuleBase == "gtk3_kde5" || rModuleBase == "win" )
{
pCloseModule = nullptr;
}
#endif
}
}
else
@@ -128,15 +124,10 @@ static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = fals
return pInst;
}
#if !defined(ANDROID)
namespace {
#ifdef DESKTOPDETECT
extern "C" typedef DesktopType Fn_get_desktop_environment();
}
static DesktopType get_desktop_environment()
DesktopType get_desktop_environment()
{
OUString aModule(DESKTOP_DETECTOR_DLL_NAME);
oslModule aMod = osl_loadModuleRelative(
@@ -155,18 +146,12 @@ static DesktopType get_desktop_environment()
return ret;
}
#else
#define get_desktop_environment() DESKTOP_NONE // For now...
#endif
static SalInstance* autodetect_plugin()
SalInstance* autodetect_plugin()
{
static const char* const pKDEFallbackList[] =
{
#if ENABLE_KDE5
"kde5",
"kde5",
#endif
#if ENABLE_GTK3_KDE5
"gtk3_kde5",
@@ -182,19 +167,24 @@ static SalInstance* autodetect_plugin()
"gtk3", "gtk", "gen", nullptr
};
#ifdef HEADLESS_VCLPLUG
static const char* const pHeadlessFallbackList[] =
{
"svp", nullptr
};
#endif
DesktopType desktop = get_desktop_environment();
const char * const * pList = pStandardFallbackList;
int nListEntry = 0;
#ifdef HEADLESS_VCLPLUG
// no server at all: dummy plugin
if ( desktop == DESKTOP_NONE )
pList = pHeadlessFallbackList;
else if ( desktop == DESKTOP_GNOME ||
else
#endif
if ( desktop == DESKTOP_GNOME ||
desktop == DESKTOP_UNITY ||
desktop == DESKTOP_XFCE ||
desktop == DESKTOP_MATE )
@@ -215,28 +205,62 @@ static SalInstance* autodetect_plugin()
return pInst;
}
#endif // DESKTOPDETECT
#ifdef HEADLESS_VCLPLUG
// HACK to obtain Application::IsHeadlessModeEnabled early on, before
// Application::EnableHeadlessMode has potentially been called:
bool IsHeadlessModeRequested()
{
if (Application::IsHeadlessModeEnabled()) {
return true;
}
sal_uInt32 n = rtl_getAppCommandArgCount();
for (sal_uInt32 i = 0; i < n; ++i) {
OUString arg;
rtl_getAppCommandArg(i, &arg.pData);
if ( arg == "--headless" || arg == "-headless" ) {
return true;
}
}
return false;
}
#endif
} // anonymous namespace
SalInstance *CreateSalInstance()
{
SalInstance *pInst = nullptr;
OUString aUsePlugin;
#ifdef HEADLESS_VCLPLUG
if( IsHeadlessModeRequested() )
aUsePlugin = "svp";
else
{
#endif
rtl::Bootstrap::get( "SAL_USE_VCLPLUGIN", aUsePlugin );
}
if( !aUsePlugin.isEmpty() )
pInst = tryInstance( aUsePlugin, true );
#ifdef DESKTOPDETECT
if( ! pInst )
pInst = autodetect_plugin();
#endif
// fallback, try everything
static const char* const pPlugin[] = {
"gtk3", "gtk", "kde5", "kde4", "gen" };
#ifdef _WIN32
"win"
#else
#ifdef MACOSX
"osx"
#else
"gtk3", "gtk", "kde5", "kde4", "gen"
#endif
#endif
};
for ( int i = 0; !pInst && i != SAL_N_ELEMENTS(pPlugin); ++i )
pInst = tryInstance( OUString::createFromAscii( pPlugin[ i ] ) );
@@ -263,18 +287,6 @@ void DestroySalInstance( SalInstance *pInst )
osl_unloadModule( pCloseModule );
}
void InitSalData()
{
}
void DeInitSalData()
{
}
void InitSalMain()
{
}
void SalAbort( const OUString& rErrorText, bool bDumpCore )
{
if( rErrorText.isEmpty() )
@@ -292,17 +304,26 @@ void SalAbort( const OUString& rErrorText, bool bDumpCore )
const OUString& SalGetDesktopEnvironment()
{
#ifdef _WIN32
static OUString aDesktopEnvironment( "Windows" );
#else
#ifdef MACOSX
static OUString aDesktopEnvironment( "MacOSX" );
#else
// Order to match desktops.hxx' DesktopType
static const char * const desktop_strings[] = {
"none", "unknown", "GNOME", "UNITY",
"XFCE", "MATE", "KDE4", "KDE5" };
static OUString aRet;
if( aRet.isEmpty())
static OUString aDesktopEnvironment;
if( aDesktopEnvironment.isEmpty())
{
aRet = OUString::createFromAscii(
aDesktopEnvironment = OUString::createFromAscii(
desktop_strings[get_desktop_environment()]);
}
return aRet;
#endif
#endif
return aDesktopEnvironment;
}
SalData::SalData() :
@@ -313,7 +334,19 @@ SalData::SalData() :
SalData::~SalData() COVERITY_NOEXCEPT_FALSE
{
#if (defined UNX && !defined MACOSX)
psp::PrinterInfoManager::release();
#endif
}
#ifdef _WIN32
bool HasAtHook()
{
BOOL bIsRunning = FALSE;
// pvParam must be BOOL
return SystemParametersInfoW(SPI_GETSCREENREADER, 0, &bIsRunning, 0)
&& bIsRunning;
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-2
View File
@@ -182,13 +182,11 @@ Application::Application()
osl_setEnvironment(aVar.pData, aValue.pData);
ImplGetSVData()->mpApp = this;
InitSalData();
}
Application::~Application()
{
ImplDeInitSVData();
DeInitSalData();
ImplGetSVData()->mpApp = nullptr;
}
-1
View File
@@ -299,7 +299,6 @@ bool InitVCL()
{
pOwnSvApp = new Application();
}
InitSalMain();
ImplSVData* pSVData = ImplGetSVData();
-199
View File
@@ -1,199 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you 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 .
*/
#include <osl/module.hxx>
#include <osl/process.h>
#include <rtl/bootstrap.hxx>
#include <rtl/process.h>
#include <sal/log.hxx>
#include <salinst.hxx>
#include <saldatabasic.hxx>
#include <config_vclplug.h>
#include <desktop/crashreport.hxx>
#include <cstdio>
#include <Windows.h>
extern "C" {
typedef SalInstance*(*salFactoryProc)();
}
namespace {
// HACK to obtain Application::IsHeadlessModeEnabled early on, before
// Application::EnableHeadlessMode has potentially been called:
bool IsHeadlessModeRequested()
{
if (Application::IsHeadlessModeEnabled()) {
return true;
}
sal_uInt32 n = rtl_getAppCommandArgCount();
for (sal_uInt32 i = 0; i < n; ++i) {
OUString arg;
rtl_getAppCommandArg(i, &arg.pData);
if ( arg == "--headless" || arg == "-headless" ) {
return true;
}
}
return false;
}
}
static oslModule pCloseModule = nullptr;
static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = false )
{
SalInstance* pInst = nullptr;
OUString aModule(
#ifdef SAL_DLLPREFIX
SAL_DLLPREFIX
#endif
"vclplug_" + rModuleBase + "lo" SAL_DLLEXTENSION );
osl::Module aMod;
if (aMod.loadRelative(reinterpret_cast<oslGenericFunction>(&tryInstance), aModule, SAL_LOADMODULE_GLOBAL))
{
salFactoryProc aProc = reinterpret_cast<salFactoryProc>(aMod.getFunctionSymbol("create_SalInstance"));
if (aProc)
{
pInst = aProc();
SAL_INFO(
"vcl.plugadapt",
"sal plugin " << aModule << " produced instance " << pInst);
if (pInst)
{
pCloseModule = static_cast<oslModule>(aMod);
aMod.release();
pCloseModule = nullptr;
}
}
else
{
SAL_WARN(
"vcl.plugadapt",
"could not load symbol create_SalInstance from shared object "
<< aModule);
}
}
else if (bForce)
{
SAL_WARN("vcl.plugadapt", "could not load shared object " << aModule);
}
else
{
SAL_INFO("vcl.plugadapt", "could not load shared object " << aModule);
}
// coverity[leaked_storage] - this is on purpose
return pInst;
}
SalInstance *CreateSalInstance()
{
SalInstance *pInst = nullptr;
OUString aUsePlugin;
rtl::Bootstrap::get( "SAL_USE_VCLPLUGIN", aUsePlugin );
if( !aUsePlugin.isEmpty() )
pInst = tryInstance( aUsePlugin, true );
// fallback, try everything
static const char* const pPlugin[] = { "win" };
for ( int i = 0; !pInst && i != SAL_N_ELEMENTS(pPlugin); ++i )
pInst = tryInstance( OUString::createFromAscii( pPlugin[ i ] ) );
if( ! pInst )
{
std::fprintf( stderr, "no suitable windowing system found, exiting.\n" );
_exit( 1 );
}
// acquire SolarMutex
pInst->AcquireYieldMutex();
return pInst;
}
void DestroySalInstance( SalInstance *pInst )
{
// release SolarMutex
pInst->ReleaseYieldMutexAll();
delete pInst;
if( pCloseModule )
osl_unloadModule( pCloseModule );
}
void InitSalData()
{
}
void DeInitSalData()
{
}
void InitSalMain()
{
}
void SalAbort( const OUString& rErrorText, bool bDumpCore )
{
if( rErrorText.isEmpty() )
std::fprintf( stderr, "Application Error\n" );
else
{
CrashReporter::AddKeyValue("AbortMessage", rErrorText);
std::fprintf( stderr, "%s\n", OUStringToOString(rErrorText, osl_getThreadTextEncoding()).getStr() );
}
if( bDumpCore )
abort();
else
_exit(1);
}
const OUString& SalGetDesktopEnvironment()
{
static OUString aDesktopEnvironment( "Windows" );
return aDesktopEnvironment;
}
SalData::SalData() :
m_pInstance(nullptr),
m_pPIManager(nullptr)
{
}
SalData::~SalData() COVERITY_NOEXCEPT_FALSE
{
}
bool HasAtHook()
{
BOOL bIsRunning = FALSE;
// pvParam must be BOOL
return SystemParametersInfoW(SPI_GETSCREENREADER, 0, &bIsRunning, 0)
&& bIsRunning;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */