MCPcopy Create free account
hub / github.com/EasyIME/PIME / initInputMethods

Method initInputMethods

PIMELauncher/PipeServer.cpp:152–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152void PipeServer::initInputMethods(const std::wstring& topDirPath) {
153 // maps language profiles to backend names
154 for (auto& backend : backends_) {
155 std::wstring dirPath = topDirPath + L"\\" + utf8Codec.from_bytes(backend->name_) + L"\\input_methods";
156 // scan the dir for lang profile definition files (ime.json)
157 WIN32_FIND_DATA findData = { 0 };
158 HANDLE hFind = ::FindFirstFile((dirPath + L"\\*").c_str(), &findData);
159 if (hFind != INVALID_HANDLE_VALUE) {
160 do {
161 if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { // this is a subdir
162 if (findData.cFileName[0] == '.') {
163 continue;
164 }
165
166 std::wstring imejson = dirPath;
167 imejson += '\\';
168 imejson += findData.cFileName;
169 imejson += L"\\ime.json";
170 // Make sure the file exists
171 DWORD fileAttrib = GetFileAttributesW(imejson.c_str());
172 if (fileAttrib != INVALID_FILE_ATTRIBUTES) {
173 // load the json file to get the info of input method
174 Json::Value json;
175 if (loadJsonFile(imejson, json)) {
176 std::string guid = json["guid"].asString();
177 transform(guid.begin(), guid.end(), guid.begin(), tolower); // convert GUID to lwoer case
178 // map text service GUID to its backend server
179 backendMap_.insert(std::make_pair(guid, backendFromName(backend->name_.c_str())));
180 }
181 }
182 }
183 } while (::FindNextFile(hFind, &findData));
184 ::FindClose(hFind);
185 }
186 }
187}
188
189void PipeServer::restartAllBackends() {
190 logger_->info("Restart all backends");

Callers

nothing calls this directly

Calls 4

loadJsonFileFunction · 0.85
c_strMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected