Skip to content

Commit

Permalink
Revert "feat(install): combine IME and TSF (rime#257)"
Browse files Browse the repository at this point in the history
This reverts commit 91cbd2c.
  • Loading branch information
mrhso committed Dec 4, 2018
1 parent 4431b71 commit 69191c7
Show file tree
Hide file tree
Showing 15 changed files with 319 additions and 157 deletions.
10 changes: 0 additions & 10 deletions WeaselSetup/TSFRegister.h

This file was deleted.

2 changes: 0 additions & 2 deletions WeaselSetup/WeaselSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "stdafx.h"
#include "WeaselSetup.h"
#include "InstallOptionsDialog.h"
#include <VersionHelpers.hpp>

CAppModule _Module;

Expand All @@ -15,7 +14,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
InitVersion();
UNREFERENCED_PARAMETER(hPrevInstance);

HRESULT hRes = ::CoInitialize(NULL);
Expand Down
2 changes: 0 additions & 2 deletions WeaselSetup/WeaselSetup.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
<ClInclude Include="Resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="TSFRegister.h" />
<ClInclude Include="WeaselSetup.h" />
</ItemGroup>
<ItemGroup>
Expand All @@ -107,7 +106,6 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="TSFRegister.cpp" />
<ClCompile Include="WeaselSetup.cpp" />
</ItemGroup>
<ItemGroup>
Expand Down
6 changes: 0 additions & 6 deletions WeaselSetup/WeaselSetup.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
<ClInclude Include="InstallOptionsDialog.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TSFRegister.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
Expand All @@ -56,9 +53,6 @@
<ClCompile Include="InstallOptionsDialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TSFRegister.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WeaselSetup.rc">
Expand Down
58 changes: 37 additions & 21 deletions WeaselSetup/imesetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
#include <vector>
#include <StringAlgorithm.hpp>
#include <WeaselCommon.h>

#include "TSFRegister.h"
#include <msctf.h>


// {A3F4CDED-B1E9-41EE-9CA6-7B4D0DE6CB0A}
const GUID c_clsidTextService =
static const GUID c_clsidTextService =
{ 0xa3f4cded, 0xb1e9, 0x41ee, { 0x9c, 0xa6, 0x7b, 0x4d, 0xd, 0xe6, 0xcb, 0xa } };

// {3D02CAB6-2B8E-4781-BA20-1C9267529467}
const GUID c_guidProfile =
static const GUID c_guidProfile =
{ 0x3d02cab6, 0x2b8e, 0x4781, { 0xba, 0x20, 0x1c, 0x92, 0x67, 0x52, 0x94, 0x67 } };

HKL ImeHKL = 0;

using boost::filesystem::wpath;

BOOL copy_file(const std::wstring& src, const std::wstring& dest)
{
Expand Down Expand Up @@ -252,7 +252,6 @@ int register_ime(const std::wstring& ime_path, bool register_ime, bool is_wow64,
if (!silent) MessageBox(NULL, msg, L"安裝失敗", MB_ICONERROR | MB_OK);
return 1;
}
ImeHKL = hKL;
return 0;
}

Expand Down Expand Up @@ -366,28 +365,45 @@ void enable_profile(BOOL fEnable, bool hant) {
pProfiles->Release();
}
}
void unregister_text_service()
{
UnregisterProfiles();
UnregisterCategories();
UnregisterServer();
}

// 注册TSF输入法
int register_text_service(const std::wstring& tsf_path, bool register_ime, bool is_wow64, bool hant, bool silent)
{
if (!register_ime)
enable_profile(FALSE, hant);

if (register_ime) {
if (!RegisterServer(tsf_path, is_wow64) || !RegisterProfiles(tsf_path, ImeHKL) || !RegisterCategories())
{
unregister_text_service();
MessageBox(NULL, L"註冊輸入法錯誤", L"安装/卸載失败", MB_ICONERROR | MB_OK);
return 1;
}
std::wstring params = L" \"" + tsf_path.wstring() + L"\"";
if (!register_ime)
{
params = L" /u " + params; // unregister
}
//if (silent) // always silent
{
params = L" /s " + params;
}
else {
unregister_text_service();

SHELLEXECUTEINFO shExInfo = {0};
shExInfo.cbSize = sizeof(shExInfo);
shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shExInfo.hwnd = 0;
shExInfo.lpVerb = L"open"; // Operation to perform
shExInfo.lpFile = L"regsvr32.exe"; // Application to start
shExInfo.lpParameters = params.c_str(); // Additional parameters
shExInfo.lpDirectory = 0;
shExInfo.nShow = SW_SHOW;
shExInfo.hInstApp = 0;

if (ShellExecuteEx(&shExInfo))
{
WaitForSingleObject(shExInfo.hProcess, INFINITE);
CloseHandle(shExInfo.hProcess);
}
else
{
WCHAR msg[100];
wsprintf(msg, L"註冊輸入法錯誤 regsvr32.exe %s", params.c_str());
if (!silent) MessageBox(NULL, msg, L"安装/卸載失败", MB_ICONERROR | MB_OK);
return 1;
}

if (register_ime)
Expand Down
21 changes: 1 addition & 20 deletions WeaselSetup/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <windows.h>
#include <ShellAPI.h>
#include <Imm.h>
#include <msctf.h>

#include <atlbase.h>
#include <atlwin.h>
Expand All @@ -24,25 +23,7 @@
#include <wtl/atlmisc.h>
#include <wtl/atldlgs.h>

// {A3F4CDED-B1E9-41EE-9CA6-7B4D0DE6CB0A}
extern const GUID c_clsidTextService;

// {3D02CAB6-2B8E-4781-BA20-1C9267529467}
extern const GUID c_guidProfile;

#ifndef TF_IPP_CAPS_IMMERSIVESUPPORT

#define WEASEL_USING_OLDER_TSF_SDK

/* for Windows 8 */
#define TF_TMF_IMMERSIVEMODE 0x40000000
#define TF_IPP_CAPS_IMMERSIVESUPPORT 0x00010000
#define TF_IPP_CAPS_SYSTRAYSUPPORT 0x00020000

extern const GUID GUID_TFCAT_TIPCAP_IMMERSIVESUPPORT;
extern const GUID GUID_TFCAT_TIPCAP_SYSTRAYSUPPORT;

#endif
#include <boost/filesystem.hpp>

// TODO: reference additional headers your program requires here

Expand Down
11 changes: 11 additions & 0 deletions WeaselTSF/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
#include "stdafx.h"
#include <WeaselCommon.h>

#ifdef WEASEL_HANT
#define TEXTSERVICE_LANGID MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
#else
#define TEXTSERVICE_LANGID MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)
#endif

#define TEXTSERVICE_DESC WEASEL_IME_NAME L" (TSF)"
#define TEXTSERVICE_DESC_A "Weasel (TSF)"
#define TEXTSERVICE_MODEL "Apartment"

#define TEXTSERVICE_ICON_INDEX 0

void DllAddRef();
void DllRelease();
Expand Down
Loading

0 comments on commit 69191c7

Please sign in to comment.