MCPcopy Create free account
hub / github.com/RGAA-Software/GoDesk / Init

Method Init

src/client/ct_client_context.cpp:34–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 }
33
34 void ClientContext::Init() {
35 auto data_path = QString::fromStdWString(FolderUtil::GetProgramDataPath()).toStdString();
36
37 //auto base_dir = QApplication::applicationDirPath();
38
39 auto log_path = std::format("{}/gr_logs/app.{}.log", data_path, this->name_);
40 std::cout << "log path: " << log_path << std::endl;
41
42 if (this->name_ == kClientEmbedName) {
43 // embed in main panel
44 // log to gammaray.log
45 // will set device id by SetDeviceId
46 }
47 else {
48 // single running
49 Logger::InitLog(log_path, true);
50 }
51 LOGI("ClientContext in {}", this->name_);
52
53 sp_ = SharedPreference::Instance();
54 auto sp_name = std::format("app.{}.dat", this->name_);
55 if (!sp_->Init(data_path + "/gr_data", sp_name)) {
56 LOGE("!! Init sp failed: {}", sp_name);
57 }
58 else {
59 LOGI("** Init app data success: {}", sp_name);
60 }
61
62 auto settings = Settings::Instance();
63 //if (!render) {
64 // settings->LoadMainSettings();
65 //} else {
66 settings->LoadSettings();
67 //}
68
69 task_thread_ = Thread::Make("context_thread", 128);
70 task_thread_->Poll();
71
72 LOGI("Client params for: {}", this->name_);
73 settings->Dump();
74
75 PostTask([=, this]() {
76 auto hardware = Hardware::Instance();
77 hardware->Detect(false, true, false);
78 hardware->Dump();
79 });
80 }
81
82 void ClientContext::PostTask(std::function<void()>&& task) {
83 task_thread_->Post(SimpleThreadTask::Make(std::move(task)));

Callers

nothing calls this directly

Calls 2

LoadSettingsMethod · 0.45
DumpMethod · 0.45

Tested by

no test coverage detected