Skip to content

Commit

Permalink
notebookbar: early init
Browse files Browse the repository at this point in the history
- read settings from loolwsd.xml
- in case of notebookbar activated send :notebookbar parameter
- for mobile apps I left empty parameter in setupKitEnvironment calls

Change-Id: I5813589564b37eecc1e77c5d0eb737eca5f92f04
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97233
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <[email protected]>
Reviewed-by: Szymon Kłos <[email protected]>
  • Loading branch information
eszkadev committed Jun 30, 2020
1 parent 981a103 commit 11965d0
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion android/lib/src/main/cpp/androidapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ JNI_OnLoad(JavaVM* vm, void*) {
return JNI_ERR; // JNI version not supported.
}

setupKitEnvironment();
setupKitEnvironment("");

// Uncomment the following to see the logs from the core too
//setenv("SAL_LOG", "+WARN+INFO", 0);
Expand Down
2 changes: 1 addition & 1 deletion ios/Mobile/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
if (!trace)
trace = strdup("warning");

setupKitEnvironment();
setupKitEnvironment("");

Log::initialize("Mobile", trace, false, false, {});
Util::setThreadName("main");
Expand Down
10 changes: 9 additions & 1 deletion kit/ForKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ static bool SingleKit = false;
#endif
#endif

static std::string UserInterface;

static bool DisplayVersion = false;
static std::string UnitTestLibrary;
static std::string LogLevel;
Expand Down Expand Up @@ -539,6 +541,12 @@ int main(int argc, char** argv)
LOG_ERR("Security: Running without the ability to filter system calls is ill advised.");
NoSeccomp = true;
}

else if (std::strstr(cmd, "--ui") == cmd)
{
eq = std::strchr(cmd, '=');
UserInterface = std::string(eq+1);
}
}

if (loSubPath.empty() || sysTemplate.empty() ||
Expand All @@ -555,7 +563,7 @@ int main(int argc, char** argv)
return EX_USAGE;
}

setupKitEnvironment();
setupKitEnvironment(UserInterface);

if (!std::getenv("LD_BIND_NOW")) // must be set by parent.
LOG_INF("Note: LD_BIND_NOW is not set.");
Expand Down
9 changes: 7 additions & 2 deletions kit/Kit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2505,7 +2505,7 @@ void wakeCallback(void* pData)
#endif
}

void setupKitEnvironment()
void setupKitEnvironment(const std::string& userInterface)
{
// Setup & check environment
const std::string layers(
Expand Down Expand Up @@ -2536,6 +2536,10 @@ void setupKitEnvironment()
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);
}
Expand All @@ -2555,6 +2559,7 @@ void lokit_main(
bool displayVersion,
#else
int docBrokerSocket,
const std::string& userInterface,
#endif
size_t numericIdentifier
)
Expand Down Expand Up @@ -2818,7 +2823,7 @@ void lokit_main(
#ifndef IOS
// Was not done by the preload.
// For iOS we call it in -[AppDelegate application: didFinishLaunchingWithOptions:]
setupKitEnvironment();
setupKitEnvironment(userInterface);
#endif

#if defined(__linux) && !defined(__ANDROID__)
Expand Down
3 changes: 2 additions & 1 deletion kit/Kit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void lokit_main(
bool displayVersion,
#else
int docBrokerSocket,
const std::string& userInterface,
#endif
size_t numericIdentifier
);
Expand All @@ -47,7 +48,7 @@ void runKitLoopInAThread();
#endif

/// We need to get several env. vars right
void setupKitEnvironment();
void setupKitEnvironment(const std::string& userInterface);

bool globalPreinit(const std::string& loTemplate);
/// Wrapper around private Document::ViewCallback().
Expand Down
9 changes: 8 additions & 1 deletion wsd/LOOLWSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ std::shared_ptr<ChildProcess> getNewChild_Blocks(unsigned mobileAppDocId)
#endif
// Ugly to have that static global LOOLWSD::prisonerServerSocketFD, Otoh we know
// there is just one LOOLWSD object. (Even in real Online.)
lokit_main(LOOLWSD::prisonerServerSocketFD, mobileAppDocId);
lokit_main(LOOLWSD::prisonerServerSocketFD, LOOLWSD::UserInterface, mobileAppDocId);
}).detach();
#endif

Expand Down Expand Up @@ -728,6 +728,7 @@ std::string LOOLWSD::HostIdentifier;
std::string LOOLWSD::ConfigFile = LOOLWSD_CONFIGDIR "/loolwsd.xml";
std::string LOOLWSD::ConfigDir = LOOLWSD_CONFIGDIR "/conf.d";
std::string LOOLWSD::LogLevel = "trace";
std::string LOOLWSD::UserInterface = "classic";
bool LOOLWSD::AnonymizeUserData = false;
bool LOOLWSD::CheckLoolUser = true;
bool LOOLWSD::IsProxyPrefixEnabled = false;
Expand Down Expand Up @@ -999,6 +1000,9 @@ void LOOLWSD::initialize(Application& self)
// Allow UT to manipulate before using configuration values.
UnitWSD::get().configure(config());

// Setup user interface mode
UserInterface = getConfigValue<std::string>(conf, "user_interface.mode", "classic");

// Set the log-level after complete initialization to force maximum details at startup.
LogLevel = getConfigValue<std::string>(conf, "logging.level", "trace");
setenv("LOOL_LOGLEVEL", LogLevel.c_str(), true);
Expand Down Expand Up @@ -1790,6 +1794,8 @@ bool LOOLWSD::createForKit()
if (NoSeccomp)
args.push_back("--noseccomp");

args.push_back("--ui=" + UserInterface);

if (!CheckLoolUser)
args.push_back("--disable-lool-user-checking");

Expand Down Expand Up @@ -3493,6 +3499,7 @@ class LOOLWSDServer
<< "\n CheckLoolUser: " << (LOOLWSD::CheckLoolUser ? "yes" : "no")
<< "\n IsProxyPrefixEnabled: " << (LOOLWSD::IsProxyPrefixEnabled ? "yes" : "no")
<< "\n OverrideWatermark: " << LOOLWSD::OverrideWatermark
<< "\n UserInterface: " << LOOLWSD::UserInterface
;

os << "\nServer poll:\n";
Expand Down
1 change: 1 addition & 0 deletions wsd/LOOLWSD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class LOOLWSD : public Poco::Util::ServerApplication
static bool DummyLOK;
static std::string FuzzFileName;
#endif
static std::string UserInterface;
static std::string ConfigFile;
static std::string ConfigDir;
static std::string SysTemplate;
Expand Down

0 comments on commit 11965d0

Please sign in to comment.