Move the setupKitEnvironment() function into a file of its own

A small re-factoring to help planned re-plumbing of the iOS app.

Change-Id: I21f09216a7c5adf965179765a75f5a0d521cd7f3
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97771
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
private/tml/ios-gen2
Tor Lillqvist 2020-07-02 16:57:22 +03:00
parent 9041f14f00
commit 3edc4d2201
7 changed files with 61 additions and 42 deletions

View File

@ -275,6 +275,7 @@ kit_headers = kit/ChildSession.hpp \
kit/DummyLibreOfficeKit.hpp \
kit/Kit.hpp \
kit/KitHelper.hpp \
kit/SetupKitEnvironment.hpp \
kit/Watermark.hpp
noinst_HEADERS = $(wsd_headers) $(shared_headers) $(kit_headers) \

View File

@ -19,6 +19,7 @@
#include <Log.hpp>
#include <LOOLWSD.hpp>
#include <Protocol.hpp>
#include <SetupKitEnvironment.hpp>
#include <Util.hpp>
#include <osl/detail/android-bootstrap.h>

View File

@ -28,6 +28,7 @@
#import "Kit.hpp"
#import "Log.hpp"
#import "LOOLWSD.hpp"
#import "SetupKitEnvironment.hpp"
#import "Util.hpp"
NSString *app_locale;

View File

@ -30,6 +30,7 @@
#include <Common.hpp>
#include "Kit.hpp"
#include "SetupKitEnvironment.hpp"
#include <Log.hpp>
#include <Unit.hpp>
#include <Util.hpp>

View File

@ -67,6 +67,7 @@
#include <Util.hpp>
#include "Delta.hpp"
#include "Watermark.hpp"
#include "SetupKitEnvironment.hpp"
#if !MOBILEAPP
#include <common/SigUtil.hpp>
@ -2475,45 +2476,6 @@ void wakeCallback(void* pData)
#endif
}
void setupKitEnvironment(const std::string& userInterface)
{
// Setup & check environment
const std::string layers(
"xcsxcu:${BRAND_BASE_DIR}/share/registry "
"res:${BRAND_BASE_DIR}/share/registry "
"bundledext:${${BRAND_BASE_DIR}/program/lounorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
"sharedext:${${BRAND_BASE_DIR}/program/lounorc:SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
"userext:${${BRAND_BASE_DIR}/program/lounorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
#ifdef IOS
"user:*${BRAND_BASE_DIR}/loolkitconfig.xcu "
#elif ENABLE_DEBUG && !defined(ANDROID) // '*' denotes non-writable.
"user:*file://" DEBUG_ABSSRCDIR "/loolkitconfig.xcu "
#else
"user:*file://" LOOLWSD_CONFIGDIR "/loolkitconfig.xcu "
#endif
);
::setenv("CONFIGURATION_LAYERS", layers.c_str(),
1 /* override */);
#if !MOBILEAPP
// No-caps tracing can spawn eg. glxinfo & other oddness.
unsetenv("DISPLAY");
#endif
// Set various options we need.
std::string options = "unipoll";
#if !MOBILEAPP
if (Log::logger().trace())
options += ":profile_events";
#endif
if (userInterface == "notebookbar")
options += ":notebookbar";
// options += ":sc_no_grid_bg"; // leave this disabled for now, merged-cells needs more work.
::setenv("SAL_LOK_OPTIONS", options.c_str(), 0);
}
#ifndef BUILDING_TESTS
void lokit_main(

View File

@ -47,9 +47,6 @@ void lokit_main(
void runKitLoopInAThread();
#endif
/// We need to get several env. vars right
void setupKitEnvironment(const std::string& userInterface);
bool globalPreinit(const std::string& loTemplate);
/// Wrapper around private Document::ViewCallback().
void documentViewCallback(const int type, const char* p, void* data);

View File

@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* 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/.
*/
#pragma once
#include <cstdlib>
#include <string>
#include <Log.hpp>
inline void setupKitEnvironment(const std::string& userInterface)
{
// Setup & check environment
const std::string layers(
"xcsxcu:${BRAND_BASE_DIR}/share/registry "
"res:${BRAND_BASE_DIR}/share/registry "
"bundledext:${${BRAND_BASE_DIR}/program/lounorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
"sharedext:${${BRAND_BASE_DIR}/program/lounorc:SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
"userext:${${BRAND_BASE_DIR}/program/lounorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
#ifdef IOS
"user:*${BRAND_BASE_DIR}/loolkitconfig.xcu "
#elif ENABLE_DEBUG && !defined(ANDROID) // '*' denotes non-writable.
"user:*file://" DEBUG_ABSSRCDIR "/loolkitconfig.xcu "
#else
"user:*file://" LOOLWSD_CONFIGDIR "/loolkitconfig.xcu "
#endif
);
::setenv("CONFIGURATION_LAYERS", layers.c_str(),
1 /* override */);
#if !MOBILEAPP
// No-caps tracing can spawn eg. glxinfo & other oddness.
unsetenv("DISPLAY");
#endif
// Set various options we need.
std::string options = "unipoll";
#if !MOBILEAPP
if (Log::logger().trace())
options += ":profile_events";
#endif
if (userInterface == "notebookbar")
options += ":notebookbar";
// options += ":sc_no_grid_bg"; // leave this disabled for now, merged-cells needs more work.
::setenv("SAL_LOK_OPTIONS", options.c_str(), 0);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */