@@ -1,4 +1,3 @@
|
|||||||
#define SYSTEM_NAME "${CMAKE_SYSTEM}"
|
|
||||||
#cmakedefine ICONV_SECOND_ARGUMENT_IS_CONST
|
#cmakedefine ICONV_SECOND_ARGUMENT_IS_CONST
|
||||||
#cmakedefine LIBIDN_FOUND
|
#cmakedefine LIBIDN_FOUND
|
||||||
#cmakedefine SYSTEMD_FOUND
|
#cmakedefine SYSTEMD_FOUND
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#include <logger/logger.hpp>
|
||||||
|
#include <utils/system.hpp>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
using namespace std::string_literals;
|
||||||
|
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
std::string get_system_name()
|
||||||
|
{
|
||||||
|
struct utsname uts;
|
||||||
|
const int res = ::uname(&uts);
|
||||||
|
if (res == -1)
|
||||||
|
{
|
||||||
|
log_error("uname failed: ", std::strerror(errno));
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
return uts.sysname + " "s + uts.release;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
std::string get_system_name();
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <xmpp/xmpp_component.hpp>
|
#include <xmpp/xmpp_component.hpp>
|
||||||
#include <config/config.hpp>
|
#include <config/config.hpp>
|
||||||
|
#include <utils/system.hpp>
|
||||||
#include <utils/time.hpp>
|
#include <utils/time.hpp>
|
||||||
#include <xmpp/auth.hpp>
|
#include <xmpp/auth.hpp>
|
||||||
#include <xmpp/jid.hpp>
|
#include <xmpp/jid.hpp>
|
||||||
@@ -585,7 +586,7 @@ void XmppComponent::send_version(const std::string& id, const std::string& jid_t
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
XmlSubNode os(query, "os");
|
XmlSubNode os(query, "os");
|
||||||
os.set_inner(SYSTEM_NAME);
|
os.set_inner(utils::get_system_name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <utils/empty_if_fixed_server.hpp>
|
#include <utils/empty_if_fixed_server.hpp>
|
||||||
#include <utils/get_first_non_empty.hpp>
|
#include <utils/get_first_non_empty.hpp>
|
||||||
#include <utils/time.hpp>
|
#include <utils/time.hpp>
|
||||||
|
#include <utils/system.hpp>
|
||||||
#include <utils/scopeguard.hpp>
|
#include <utils/scopeguard.hpp>
|
||||||
|
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
@@ -151,3 +152,9 @@ TEST_CASE("scope_guard")
|
|||||||
}
|
}
|
||||||
CHECK(res);
|
CHECK(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("system_name")
|
||||||
|
{
|
||||||
|
CHECK(utils::get_system_name() != "Unknown");
|
||||||
|
CHECK(!utils::get_system_name().empty());
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user