Skip to content

Commit

Permalink
Merge pull request #204 from chewing/refactor-libime-cleanup
Browse files Browse the repository at this point in the history
Refactor: libime cleanup
  • Loading branch information
kanru authored Nov 9, 2024
2 parents f68cfb0 + 782a1dd commit d952111
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 1,099 deletions.
13 changes: 5 additions & 8 deletions ChewingTextService/ChewingTextService.def
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
LIBRARY ChewingTextService.dll

EXPORTS
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
ChewingSetup PRIVATE
LIBRARY ChewingTextService.dll

EXPORTS
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
45 changes: 1 addition & 44 deletions ChewingTextService/DllEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@
#include <VersionHelpers.h>

#include "ChewingImeModule.h"
#include "ChewingConfig.h"
#include "resource.h"

Chewing::ImeModule* g_imeModule = NULL;

// GUID of our language profile
// {CE45F71D-CE79-41D1-967D-640B65A380E3}
static const GUID g_profileGuid = {
0xce45f71d, 0xce79, 0x41d1, { 0x96, 0x7d, 0x64, 0xb, 0x65, 0xa3, 0x80, 0xe3 }
};

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
Expand All @@ -35,40 +28,4 @@ STDAPI DllCanUnloadNow(void) {

STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppvObj) {
return g_imeModule->getClassObject(rclsid, riid, ppvObj);
}

STDAPI DllUnregisterServer(void) {
return g_imeModule->unregisterServer();
}

STDAPI DllRegisterServer(void) {
wchar_t name[32];
::LoadStringW(g_imeModule->hInstance(), IDS_CHEWING, name, 32);

// get path of our module
wchar_t modulePath[MAX_PATH];
DWORD modulePathLen = GetModuleFileNameW(g_imeModule->hInstance(), modulePath, MAX_PATH);

int iconIndex = 0; // use classic icon
if(IsWindows8OrGreater())
iconIndex = 1; // use Windows 8 style IME icon

Ime::LangProfileInfo info;
info.name = name;
info.profileGuid = g_profileGuid;
info.locale = L"zh-Hant-TW";
info.fallbackLocale = L"zh-TW";
info.iconIndex = iconIndex;
info.iconFile = modulePath;

return g_imeModule->registerServer(name, &info, 1);
}

STDAPI ChewingSetup() {
// The directory is already created when the ImeModule object is constructed.
if(IsWindows8OrGreater()) {
// Grant permission to app containers
Chewing::Config::grantAppContainerAccess(g_imeModule->userDir().c_str(), SE_FILE_OBJECT, GENERIC_READ|GENERIC_WRITE|GENERIC_EXECUTE|DELETE);
}
return S_OK;
}
}
Loading

0 comments on commit d952111

Please sign in to comment.