mirror of
https://github.com/LibreOffice/online.git
synced 2025-08-06 10:45:45 +00:00
tdf#130568 - Add server os pretty name to help->about
Change-Id: Id6de533dfb8e34a05d348f8ae701bf3c524c9b95
This commit is contained in:

committed by
Michael Meeks

parent
3e67e434e4
commit
a486bad79b
@ -929,6 +929,30 @@ namespace Util
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> stringVectorToMap(std::vector<std::string> sVector, const char delimiter)
|
||||
{
|
||||
std::map<std::string, std::string> result;
|
||||
|
||||
for (std::vector<std::string>::iterator it = sVector.begin(); it != sVector.end(); it++)
|
||||
{
|
||||
size_t delimiterPosition = 0;
|
||||
delimiterPosition = (*it).find(delimiter, 0);
|
||||
if (delimiterPosition != std::string::npos)
|
||||
{
|
||||
std::string key = (*it).substr(0, delimiterPosition);
|
||||
delimiterPosition++;
|
||||
std::string value = (*it).substr(delimiterPosition);
|
||||
result[key] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WRN("Util::stringVectorToMap => record is misformed: " << (*it));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@ -972,6 +972,32 @@ int main(int argc, char**argv)
|
||||
* test tool targets (typically fuzzing) where start-up speed is critical.
|
||||
*/
|
||||
bool isFuzzing();
|
||||
|
||||
/**
|
||||
* Splits string into vector<string>. Does not accept referenced variables for easy
|
||||
* usage like (splitString("test", ..)) or (splitString(getStringOnTheFly(), ..))
|
||||
*/
|
||||
inline std::vector<std::string> splitStringToVector(std::string const str, const char delim)
|
||||
{
|
||||
size_t start;
|
||||
size_t end = 0;
|
||||
|
||||
std::vector<std::string> result;
|
||||
|
||||
while ((start = str.find_first_not_of(delim, end)) != std::string::npos)
|
||||
{
|
||||
end = str.find(delim, start);
|
||||
result.push_back(str.substr(start, end - start));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts vector of strings to map. Strings should have formed like this: key + delimiter + value.
|
||||
* In case of a misformed string or zero length vector, returns an empty map.
|
||||
*/
|
||||
std::map<std::string, std::string> stringVectorToMap(std::vector<std::string> sVector, const char delimiter);
|
||||
|
||||
} // end namespace Util
|
||||
|
||||
#endif
|
||||
|
@ -220,6 +220,7 @@ m4_ifelse(MOBILEAPP,[true],
|
||||
<div id="loolwsd-id"></div>
|
||||
<h3>LOKit</h3>
|
||||
<div id="lokit-version"></div>
|
||||
<div id="os-name" style="text-align:center"><label>%OS_INFO%</label></div>
|
||||
<p>Copyright © _YEAR_, VENDOR.</p>
|
||||
</div>
|
||||
|
||||
|
@ -649,6 +649,7 @@ void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, Poco::
|
||||
Poco::replaceInPlace(preprocess, std::string("%HOST%"), host);
|
||||
Poco::replaceInPlace(preprocess, std::string("%VERSION%"), std::string(LOOLWSD_VERSION_HASH));
|
||||
Poco::replaceInPlace(preprocess, std::string("%SERVICE_ROOT%"), LOOLWSD::ServiceRoot);
|
||||
Poco::replaceInPlace(preprocess, std::string("%OS_INFO%"), LOOLWSD::OSInfo);
|
||||
|
||||
std::string protocolDebug = "false";
|
||||
if (config.getBool("logging.protocol"))
|
||||
|
@ -726,6 +726,7 @@ std::string LOOLWSD::ServerName;
|
||||
std::string LOOLWSD::FileServerRoot;
|
||||
std::string LOOLWSD::ServiceRoot;
|
||||
std::string LOOLWSD::LOKitVersion;
|
||||
std::string LOOLWSD::OSInfo;
|
||||
std::string LOOLWSD::HostIdentifier;
|
||||
std::string LOOLWSD::ConfigFile = LOOLWSD_CONFIGDIR "/loolwsd.xml";
|
||||
std::string LOOLWSD::ConfigDir = LOOLWSD_CONFIGDIR "/conf.d";
|
||||
@ -749,6 +750,25 @@ std::unique_ptr<TraceFileWriter> LOOLWSD::TraceDumper;
|
||||
std::unique_ptr<ClipboardCache> LOOLWSD::SavedClipboards;
|
||||
#endif
|
||||
|
||||
void LOOLWSD::getOSInfo(){
|
||||
#if !MOBILEAPP
|
||||
// It might be neither mobile nor linux (in the future). That is not handled. If it is not mobile, it is Linux.
|
||||
|
||||
// Read operating system info. We can read "os-release" file, located in /etc.
|
||||
std::ifstream ifs("/etc/os-release");
|
||||
std::string str(std::istreambuf_iterator<char>{ifs}, {});
|
||||
std::vector<std::string> infoList = Util::splitStringToVector(str, '\n');
|
||||
std::map<std::string, std::string> releaseInfo = Util::stringVectorToMap(infoList, '=');
|
||||
LOOLWSD::OSInfo = "unknown";
|
||||
|
||||
if (releaseInfo.find("PRETTY_NAME") != releaseInfo.end()) {
|
||||
LOOLWSD::OSInfo = releaseInfo["PRETTY_NAME"];
|
||||
}
|
||||
#else
|
||||
// Some more cases might be added in the future.
|
||||
#endif
|
||||
}
|
||||
|
||||
/// This thread polls basic web serving, and handling of
|
||||
/// websockets before upgrade: when upgraded they go to the
|
||||
/// relevant DocumentBroker poll instead.
|
||||
@ -886,6 +906,8 @@ void LOOLWSD::initialize(Application& self)
|
||||
AutoPtr<AppConfigMap> defConfig(new AppConfigMap(DefAppConfig));
|
||||
conf.addWriteable(defConfig, PRIO_SYSTEM); // Lowest priority
|
||||
|
||||
LOOLWSD::getOSInfo();
|
||||
|
||||
#if !MOBILEAPP
|
||||
|
||||
// Load default configuration files, if present.
|
||||
|
@ -70,6 +70,7 @@ public:
|
||||
static std::string FileServerRoot;
|
||||
static std::string ServiceRoot; ///< There are installations that need prefixing every page with some path.
|
||||
static std::string LOKitVersion;
|
||||
static std::string OSInfo;
|
||||
static std::string HostIdentifier; ///< A unique random hash that identifies this server
|
||||
static std::string LogLevel;
|
||||
static bool AnonymizeUserData;
|
||||
@ -219,6 +220,9 @@ public:
|
||||
|
||||
static std::string getVersionJSON();
|
||||
|
||||
/// Reads OS information, puts them into LOOLWSD::OSInfo variable
|
||||
static void getOSInfo();
|
||||
|
||||
int innerMain();
|
||||
|
||||
protected:
|
||||
|
Reference in New Issue
Block a user