MCPcopy Create free account
hub / github.com/Apache553/SubtitleFontHelper / OnInit

Method OnInit

SubtitleFontAutoLoaderDaemon/Main.cpp:141–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139
140 private:
141 void OnInit(const std::vector<std::wstring>& cmdline)
142 {
143 {
144 std::unique_lock lg(m_queueLock);
145 while (!m_msgQueue.empty())
146 m_msgQueue.pop();
147 }
148 m_service = std::make_unique<Service>();
149 std::filesystem::path selfPath{wil::GetModuleFileNameW<wil::unique_hlocal_string>().get()};
150 selfPath.remove_filename();
151 auto configPath = selfPath / L"SubtitleFontHelper.xml";
152 auto lruCachePath = selfPath / L"lruCache.txt";
153 auto cfg = ConfigFile::ReadFromFile(configPath);
154
155 m_service->m_systemTray = std::make_unique<SystemTray>(this);
156 std::vector<std::unique_ptr<FontDatabase>> dbs;
157 for (auto& indexFile : cfg->m_indexFile)
158 {
159 dbs.emplace_back(FontDatabase::ReadFromFile(indexFile.m_path));
160 }
161 m_service->m_prefetch = std::make_unique<Prefetch>(this, cfg->lruSize, lruCachePath);
162 m_service->m_queryService = std::make_unique<QueryService>(this);
163 m_service->m_rpcServer = std::make_unique<RpcServer>(
164 this,
165 m_service->m_queryService->GetRpcRequestHandler(),
166 m_service->m_prefetch->GetRpcFeedbackHandler());
167 m_service->m_queryService->Load(std::move(dbs));
168 m_service->m_processMonitor = std::make_unique<ProcessMonitor>(
169 this, std::chrono::milliseconds(cfg->wmiPollInterval));
170 std::vector<std::wstring> monitorProcess;
171 for (auto& process : cfg->m_monitorProcess)
172 {
173 monitorProcess.emplace_back(process.m_name);
174 }
175 m_service->m_processMonitor->SetMonitorList(std::move(monitorProcess));
176 m_service->m_systemTray->NotifyFinishLoad();
177 }
178
179 void OnException(std::exception_ptr exception)
180 {

Callers

nothing calls this directly

Calls 5

GetRpcRequestHandlerMethod · 0.45
GetRpcFeedbackHandlerMethod · 0.45
LoadMethod · 0.45
SetMonitorListMethod · 0.45
NotifyFinishLoadMethod · 0.45

Tested by

no test coverage detected