Skip to content

Commit

Permalink
Topology fix and english error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
JPersson77 committed May 19, 2024
1 parent 13ce301 commit 183f02b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Common/common_app_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// common application definitions
#define APPNAME L"LGTV Companion"
#define APP_VERSION L"4.0.0"
#define APP_VERSION L"4.0.1"
#define CONFIG_FILE L"config.json"
#define LOG_FILE L"log.txt"
#define WINDOW_CLASS_UNIQUE L"YOLOx0x0x0181818"
Expand Down
3 changes: 3 additions & 0 deletions Common/restart_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ R"(
"yeniden başlat",
"Yeniden Başlat",
"Перезагрузка",
"Перезапустить",
"uruchomienie ponowne",
"다시 시작",
"Riavvia",
Expand Down Expand Up @@ -53,6 +54,8 @@ R"(
"kapat",
"Kapat",
"Завершение работы",
"Завершить работу",
"Выключение питания",
"wyłączenie zasilania",
"zamknięcie",
"전원 끄기",
Expand Down
30 changes: 16 additions & 14 deletions LGTV Companion Service/companion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SessionWrapper {
public:
WebOsClient client_;
Device device_;
bool topologyEnabled_ = false;
bool topology_enabled_ = false;
SessionWrapper(boost::asio::io_context& ioc, boost::asio::ssl::context& ctx, Device& dev, Logging& log)
: client_(ioc, ctx, dev, log)
{
Expand Down Expand Up @@ -100,6 +100,7 @@ class Companion::Impl : public std::enable_shared_from_this<Companion::Impl> {
Companion::Impl::Impl(Preferences& settings)
: prefs_(settings)
{
prefs_.topology_support_ = false; //disable initially
std::wstring file = tools::widen(prefs_.data_path_);
file += LOG_FILE;
log_ = std::make_shared<Logging>(settings.log_level_, file);
Expand All @@ -120,7 +121,7 @@ Companion::Impl::Impl(Preferences& settings)
else
DEBUG_(tools::narrow(CONFIG_FILE), "Default configuration loaded");

if (prefs_.topology_support_)
if (settings.topology_support_)
{
if (prefs_.topology_keep_on_boot_)
{
Expand Down Expand Up @@ -184,22 +185,22 @@ std::string Companion::Impl::setTopology(std::vector<std::string> device_names_o
std::string return_string;
for (auto& session : sessions_)
{
session->topologyEnabled_ = false;
session->topology_enabled_ = false;
for (auto& name_or_id : device_names_or_ids)
{
if (tools::tolower(session->device_.name) == tools::tolower(name_or_id) || tools::tolower(session->device_.id) == tools::tolower(name_or_id))
session->topologyEnabled_ = true;
session->topology_enabled_ = true;
}
return_string += session->device_.name;
return_string += ":";
return_string += session->topologyEnabled_ ? "ON " : "OFF ";
return_string += session->topology_enabled_ ? "ON " : "OFF ";
}
return return_string;
}
void Companion::Impl::clearTopology(void){
prefs_.topology_support_ = false;
for (auto& session : sessions_)
session->topologyEnabled_ = false;
session->topology_enabled_ = false;
}
std::string Companion::Impl::loadSavedTopologyConfiguration(void){
std::wstring file = tools::widen(prefs_.data_path_);
Expand Down Expand Up @@ -246,7 +247,7 @@ void Companion::Impl::saveTopologyConfiguration(void){
file += TOPOLOGY_CONFIG_FILE;
topology_json[PREFS_JSON_NODE][PREFS_JSON_VERSION] = (int)prefs_.version_;
for (auto& session : sessions_)
if (session->topologyEnabled_)
if (session->topology_enabled_)
topology_json[PREFS_JSON_NODE][PREFS_JSON_TOPOLOGY_NODE].push_back(tools::tolower(session->device_.id));
if (!topology_json.empty())
{
Expand Down Expand Up @@ -439,7 +440,7 @@ void Companion::Impl::processEvent(Event& event, SessionWrapper& session)
break;

case EVENT_SYSTEM_RESUMEAUTO:
if (prefs_.topology_support_ && !session.topologyEnabled_)
if (prefs_.topology_support_ && !session.topology_enabled_)
break;
if (session.device_.set_hdmi_input_on_power_on && time(0) - time_last_power_on < 10)
work_was_enqueued = setHdmiInput(event, session);
Expand All @@ -448,7 +449,7 @@ void Companion::Impl::processEvent(Event& event, SessionWrapper& session)
case EVENT_SYSTEM_DISPLAYON:
if (remote_client_connected_)
break;
if (prefs_.topology_support_ && !session.topologyEnabled_)
if (prefs_.topology_support_ && !session.topology_enabled_)
break;
work_was_enqueued = session.client_.powerOn();
if (session.device_.set_hdmi_input_on_power_on && time(0) - time_last_resume_or_boot_time < 10)
Expand Down Expand Up @@ -497,7 +498,7 @@ void Companion::Impl::processEvent(Event& event, SessionWrapper& session)
case EVENT_SYSTEM_USERIDLE:
if (remote_client_connected_)
break;
if (prefs_.topology_support_ && !session.topologyEnabled_)
if (prefs_.topology_support_ && !session.topology_enabled_)
break;
if (prefs_.user_idle_mode_ && windows_power_status_on_)
work_was_enqueued = session.client_.blankScreen();
Expand All @@ -506,14 +507,14 @@ void Companion::Impl::processEvent(Event& event, SessionWrapper& session)
case EVENT_SYSTEM_USERBUSY:
if (remote_client_connected_)
break;
if (prefs_.topology_support_ && !session.topologyEnabled_)
if (prefs_.topology_support_ && !session.topology_enabled_)
break;
if (prefs_.user_idle_mode_)
work_was_enqueued = session.client_.powerOn();
break;

case EVENT_SYSTEM_BOOT:
if (prefs_.topology_support_ && !session.topologyEnabled_)
if (prefs_.topology_support_ && !session.topology_enabled_)
break;
if (session.device_.set_hdmi_input_on_power_on && time(0) - time_last_power_on < 10)
work_was_enqueued = setHdmiInput(event, session);
Expand All @@ -522,7 +523,7 @@ void Companion::Impl::processEvent(Event& event, SessionWrapper& session)
if (remote_client_connected_)
break;
if (prefs_.topology_support_)
if (session.topologyEnabled_)
if (session.topology_enabled_)
work_was_enqueued = session.client_.powerOn();
else
work_was_enqueued = session.client_.powerOff();
Expand All @@ -548,6 +549,7 @@ void Companion::Impl::processEvent(Event& event, SessionWrapper& session)
thread_pool.emplace_back(
[self_ = shared_from_this()]
{
SetThreadUILanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
self_->ioc_.run();
});
thread_pool[i].detach();
Expand Down Expand Up @@ -1424,7 +1426,7 @@ void Companion::Impl::systemEvent(int e, std::string data) {
else
{
//This does happen sometimes, probably for timing reasons when shutting down the system.
ERR_("PWR", "Did not receive the expected event eubscription callback prior to shutting down. Unable to determine if system is shutting down or restarting!");
ERR_("PWR", "Did not receive the anticipated event subscription callback prior to shutting down. Unable to determine if system is shutting down or restarting!");
dispatched_event_type = EVENT_SYSTEM_UNSURE;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion LGTV Companion Setup/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<?define LGTV Companion Service_TargetDir=$(var.LGTV Companion Service.TargetDir)?><?define LGTV Companion UI_TargetDir=$(var.LGTV Companion UI.TargetDir)?>
<Product Id="908D76BB-50F0-42F4-940A-10FD1ECCF9B3" Name="LGTV Companion" Language="1033" Version="4.0.0" Manufacturer="J Persson" UpgradeCode="0BA17E5B-11CE-491D-B1A1-05DD2D9F610A">
<Product Id="199198DE-411A-424B-A661-C2C46CC53BC2" Name="LGTV Companion" Language="1033" Version="4.0.1" Manufacturer="J Persson" UpgradeCode="0BA17E5B-11CE-491D-B1A1-05DD2D9F610A">
<Package Id="*" InstallerVersion="301" Compressed="yes" InstallScope="perMachine" Platform='x64' Description="LGTV Companion installer" InstallPrivileges="elevated" AdminImage="yes"/>
<Media Id="1" Cabinet="LGTVapp.cab" EmbedCab="yes" />

Expand Down

0 comments on commit 183f02b

Please sign in to comment.