Skip to content

Commit

Permalink
[MSCTFIME][SDK] Implement CFunctionProvider (reactos#6269)
Browse files Browse the repository at this point in the history
Supporting TIPs...
JIRA issue: CORE-19360
Define CFunctionProviderBase class.
Define CFunctionProvider class.
Strengthen <cicero/cictf.h>.
  • Loading branch information
katahiromz authored Jan 1, 2024
1 parent e5548aa commit 88107ad
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 11 deletions.
233 changes: 222 additions & 11 deletions dll/ime/msctfime/msctfime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include "msctfime.h"
#include <ndk/ldrfuncs.h> /* for RtlDllShutdownInProgress */

WINE_DEFAULT_DEBUG_CHANNEL(msctfime);

Expand Down Expand Up @@ -1071,42 +1072,252 @@ HRESULT CThreadMgrEventSink::_Unadvise()
return hr;
}

/* FIXME */
class CFunctionProvider : public IUnknown
class CFunctionProviderBase : public ITfFunctionProvider
{
protected:
TfClientId m_clientId;
GUID m_guid;
BSTR m_bstr;
LONG m_cRefs;

public:
CFunctionProvider(_In_ TfClientId clientId)
{
}
CFunctionProviderBase(_In_ TfClientId clientId);
virtual ~CFunctionProviderBase();

// IUnknown interface
STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppvObj) override;
STDMETHODIMP QueryInterface(_In_ REFIID riid, _Out_ LPVOID* ppvObj) override;
STDMETHODIMP_(ULONG) AddRef() override;
STDMETHODIMP_(ULONG) Release() override;

// ITfFunctionProvider interface
STDMETHODIMP GetType(_Out_ GUID *guid) override;
STDMETHODIMP GetDescription(_Out_ BSTR *desc) override;
//STDMETHODIMP GetFunction(_In_ REFGUID guid, _In_ REFIID riid, _Out_ IUnknown **func) = 0;

BOOL Init(_In_ REFGUID rguid, _In_ LPCWSTR psz);
};

/**
* @implemented
*/
CFunctionProviderBase::CFunctionProviderBase(_In_ TfClientId clientId)
{
m_clientId = clientId;
m_guid = GUID_NULL;
m_bstr = NULL;
m_cRefs = 1;
}

/**
* @implemented
*/
CFunctionProviderBase::~CFunctionProviderBase()
{
if (!RtlDllShutdownInProgress())
::SysFreeString(m_bstr);
}

/**
* @implemented
*/
BOOL
CFunctionProviderBase::Init(
_In_ REFGUID rguid,
_In_ LPCWSTR psz)
{
m_bstr = ::SysAllocString(psz);
m_guid = rguid;
return (m_bstr != NULL);
}

class CFnDocFeed : public IAImmFnDocFeed
{
LONG m_cRefs;

public:
CFnDocFeed();
virtual ~CFnDocFeed();

// IUnknown interface
STDMETHODIMP QueryInterface(_In_ REFIID riid, _Out_ LPVOID* ppvObj) override;
STDMETHODIMP_(ULONG) AddRef() override;
STDMETHODIMP_(ULONG) Release() override;

// IAImmFnDocFeed interface
STDMETHODIMP DocFeed() override;
STDMETHODIMP ClearDocFeedBuffer() override;
STDMETHODIMP StartReconvert() override;
STDMETHODIMP StartUndoCompositionString() override;
};

CFnDocFeed::CFnDocFeed()
{
m_cRefs = 1;
}

CFnDocFeed::~CFnDocFeed()
{
}

/**
* @implemented
*/
STDMETHODIMP CFnDocFeed::QueryInterface(_In_ REFIID riid, _Out_ LPVOID* ppvObj)
{
if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IAImmFnDocFeed))
{
*ppvObj = this;
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}

/**
* @implemented
*/
STDMETHODIMP_(ULONG) CFnDocFeed::AddRef()
{
return ::InterlockedIncrement(&m_cRefs);
}

/**
* @implemented
*/
STDMETHODIMP_(ULONG) CFnDocFeed::Release()
{
if (::InterlockedDecrement(&m_cRefs) == 0)
{
delete this;
return 0;
}
return m_cRefs;
}

/**
* @unimplemented
*/
STDMETHODIMP CFunctionProvider::QueryInterface(REFIID riid, LPVOID* ppvObj)
STDMETHODIMP CFnDocFeed::DocFeed()
{
return E_NOTIMPL;
}

/**
* @unimplemented
*/
STDMETHODIMP_(ULONG) CFunctionProvider::AddRef()
STDMETHODIMP CFnDocFeed::ClearDocFeedBuffer()
{
return 1;
return E_NOTIMPL;
}

/**
* @unimplemented
*/
STDMETHODIMP_(ULONG) CFunctionProvider::Release()
STDMETHODIMP CFnDocFeed::StartReconvert()
{
return 0;
return E_NOTIMPL;
}

/**
* @unimplemented
*/
STDMETHODIMP CFnDocFeed::StartUndoCompositionString()
{
return E_NOTIMPL;
}

/**
* @implemented
*/
STDMETHODIMP
CFunctionProviderBase::QueryInterface(
_In_ REFIID riid,
_Out_ LPVOID* ppvObj)
{
if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfFunctionProvider))
{
*ppvObj = this;
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}

/**
* @implemented
*/
STDMETHODIMP_(ULONG) CFunctionProviderBase::AddRef()
{
return ::InterlockedIncrement(&m_cRefs);
}

/**
* @implemented
*/
STDMETHODIMP_(ULONG) CFunctionProviderBase::Release()
{
if (::InterlockedDecrement(&m_cRefs) == 0)
{
delete this;
return 0;
}
return m_cRefs;
}

/**
* @implemented
*/
STDMETHODIMP CFunctionProviderBase::GetType(_Out_ GUID *guid)
{
*guid = m_guid;
return S_OK;
}

/**
* @implemented
*/
STDMETHODIMP CFunctionProviderBase::GetDescription(_Out_ BSTR *desc)
{
*desc = ::SysAllocString(m_bstr);
return (*desc ? S_OK : E_OUTOFMEMORY);
}

class CFunctionProvider : public CFunctionProviderBase
{
public:
CFunctionProvider(_In_ TfClientId clientId);

STDMETHODIMP GetFunction(_In_ REFGUID guid, _In_ REFIID riid, _Out_ IUnknown **func) override;
};

/**
* @implemented
*/
CFunctionProvider::CFunctionProvider(_In_ TfClientId clientId) : CFunctionProviderBase(clientId)
{
Init(CLSID_CAImmLayer, L"MSCTFIME::Function Provider");
}

/**
* @implemented
*/
STDMETHODIMP
CFunctionProvider::GetFunction(
_In_ REFGUID guid,
_In_ REFIID riid,
_Out_ IUnknown **func)
{
*func = NULL;

if (IsEqualGUID(guid, GUID_NULL) &&
IsEqualIID(riid, IID_IAImmFnDocFeed))
{
*func = new CFnDocFeed();
if (*func)
return S_OK;
}

return E_NOINTERFACE;
}

/* FIXME */
Expand Down
13 changes: 13 additions & 0 deletions sdk/include/reactos/cicero/cictf.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,16 @@ struct ITfThreadMgr_P : ITfThreadMgr
};

DEFINE_GUID(IID_ITfKeystrokeMgr_P, 0x53FA1BEC, 0x5BE1, 0x458E, 0xAE, 0x70, 0xA9, 0xF1, 0xDC, 0x84, 0x3E, 0x81);

// FIXME: ITfKeystrokeMgr_P

DEFINE_GUID(IID_IAImmFnDocFeed, 0x6E098993, 0x9577, 0x499A, 0xA8, 0x30, 0x52, 0x34, 0x4F, 0x3E, 0x20, 0x0D);
DEFINE_GUID(CLSID_CAImmLayer, 0xB676DB87, 0x64DC, 0x4651, 0x99, 0xEC, 0x91, 0x07, 0x0E, 0xA4, 0x87, 0x90);

struct IAImmFnDocFeed : IUnknown
{
STDMETHOD(DocFeed)() = 0;
STDMETHOD(ClearDocFeedBuffer)() = 0;
STDMETHOD(StartReconvert)() = 0;
STDMETHOD(StartUndoCompositionString)() = 0;
};

0 comments on commit 88107ad

Please sign in to comment.