| 150 | } |
| 151 | |
| 152 | void 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 | |
| 189 | void PipeServer::restartAllBackends() { |
| 190 | logger_->info("Restart all backends"); |
nothing calls this directly
no test coverage detected