msctf: Starting implementation of ITfContext::RequestEditSession and ITextStoreACPSink::OnLockGranted.

This commit is contained in:
Aric Stewart 2009-05-18 08:58:43 -05:00 committed by Alexandre Julliard
parent 94945af556
commit 4bb8e9959a
3 changed files with 87 additions and 13 deletions

View File

@ -74,6 +74,7 @@ typedef struct tagContext {
ITfContextOwnerCompositionSink *pITfContextOwnerCompositionSink;
ITextStoreACPSink *pITextStoreACPSink;
ITfEditSession* currentEditSession;
/* kept as separate lists to reduce unnecessary iterations */
struct list pContextKeyEventSink;
@ -206,9 +207,53 @@ static HRESULT WINAPI Context_RequestEditSession (ITfContext *iface,
TfClientId tid, ITfEditSession *pes, DWORD dwFlags,
HRESULT *phrSession)
{
HRESULT hr;
Context *This = (Context *)iface;
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
DWORD dwLockFlags = 0x0;
TS_STATUS status;
TRACE("(%p) %i %p %x %p\n",This, tid, pes, dwFlags, phrSession);
if (!(dwFlags & TF_ES_READ) && !(dwFlags & TF_ES_READWRITE))
{
*phrSession = E_FAIL;
return E_INVALIDARG;
}
if (!This->pITextStoreACP)
{
FIXME("No ITextStoreACP avaliable\n");
*phrSession = E_FAIL;
return E_FAIL;
}
if (!(dwFlags & TF_ES_ASYNC))
dwLockFlags &= TS_LF_SYNC;
if (dwFlags & TF_ES_READ)
dwLockFlags &= TS_LF_READ;
else if ((dwFlags & TF_ES_READWRITE) == TF_ES_READWRITE)
dwLockFlags &= TS_LF_READWRITE;
/* TODO: cache this */
ITextStoreACP_GetStatus(This->pITextStoreACP, &status);
if (((dwFlags & TF_ES_READWRITE) == TF_ES_READWRITE) && (status.dwDynamicFlags & TS_SD_READONLY))
{
*phrSession = TS_E_READONLY;
return S_OK;
}
if (FAILED (ITfEditSession_QueryInterface(pes, &IID_ITfEditSession, (LPVOID*)&This->currentEditSession)))
{
*phrSession = E_FAIL;
return E_INVALIDARG;
}
hr = ITextStoreACP_RequestLock(This->pITextStoreACP, dwLockFlags, phrSession);
return hr;
}
static HRESULT WINAPI Context_InWriteSession (ITfContext *iface,
@ -597,8 +642,23 @@ static HRESULT WINAPI TextStoreACPSink_OnLockGranted(ITextStoreACPSink *iface,
DWORD dwLockFlags)
{
TextStoreACPSink *This = (TextStoreACPSink *)iface;
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
HRESULT hr;
TRACE("(%p) %x\n",This, dwLockFlags);
if (!This->pContext || !This->pContext->currentEditSession)
{
ERR("OnLockGranted called on a context without a current edit session\nZ");
return E_FAIL;
}
/* TODO: generate and use an edit cookie */
hr = ITfEditSession_DoEditSession(This->pContext->currentEditSession, 0xdeadcafe);
ITfEditSession_Release(This->pContext->currentEditSession);
This->pContext->currentEditSession = NULL;
return hr;
}
static HRESULT WINAPI TextStoreACPSink_OnStartEditTransaction(ITextStoreACPSink *iface)

View File

@ -149,8 +149,15 @@ static HRESULT WINAPI TextStoreACP_RequestLock(ITextStoreACP *iface,
static HRESULT WINAPI TextStoreACP_GetStatus(ITextStoreACP *iface,
TS_STATUS *pdcs)
{
ok(test_ACP_GetStatus == SINK_EXPECTED, "Unexpected TextStoreACP_GetStatus\n");
static UINT count = 0;
count ++;
if (count == 1)
ok(test_ACP_GetStatus == SINK_EXPECTED, "Unexpected TextStoreACP_GetStatus\n");
else
todo_wine ok(count == 1,"GetStatus called too many times\n");
test_ACP_GetStatus = SINK_FIRED;
pdcs->dwDynamicFlags = TS_SD_READONLY;
return S_OK;
}
static HRESULT WINAPI TextStoreACP_QueryInsert(ITextStoreACP *iface,
@ -1410,19 +1417,24 @@ static void test_TStoApplicationText(void)
hrSession = 0xfeedface;
/* Test no premissions flags */
hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC, &hrSession);
todo_wine ok(hr == E_INVALIDARG,"RequestEditSession should have failed with %x not %x\n",E_INVALIDARG,hr);
todo_wine ok(hrSession == E_FAIL,"hrSession should be %x not %x\n",E_FAIL,hrSession);
ok(hr == E_INVALIDARG,"RequestEditSession should have failed with %x not %x\n",E_INVALIDARG,hr);
ok(hrSession == E_FAIL,"hrSession should be %x not %x\n",E_FAIL,hrSession);
hrSession = 0xfeedface;
test_ACP_GetStatus = SINK_EXPECTED;
hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC|TF_ES_READWRITE, &hrSession);
ok(SUCCEEDED(hr),"ITfContext_RequestEditSession failed\n");
ok(hrSession == TS_E_READONLY,"Unexpected hrSession (%x)\n",hrSession);
ok(test_ACP_GetStatus == SINK_FIRED," expected GetStatus not fired\n");
test_ACP_GetStatus = SINK_UNEXPECTED;
test_ACP_RequestLock = SINK_EXPECTED;
hrSession = 0xfeedface;
hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC|TF_ES_READWRITE, &hrSession);
todo_wine ok(SUCCEEDED(hr),"ITfContext_RequestEditSession failed\n");
todo_wine ok(test_ACP_GetStatus == SINK_FIRED," expected GetStatus not fired\n");
todo_wine ok(test_ACP_RequestLock == SINK_FIRED," expected RequestLock not fired\n");
todo_wine ok(test_DoEditSession == SINK_FIRED," expected DoEditSession not fired\n");
todo_wine ok(hrSession == 0xdeadcafe,"Unexpected hrSession\n");
hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC|TF_ES_READ, &hrSession);
ok(SUCCEEDED(hr),"ITfContext_RequestEditSession failed\n");
ok(test_ACP_RequestLock == SINK_FIRED," expected RequestLock not fired\n");
ok(test_DoEditSession == SINK_FIRED," expected DoEditSession not fired\n");
ok(hrSession == 0xdeadcafe,"Unexpected hrSession (%x)\n",hrSession);
ITfContext_Release(cxt);
ITfDocumentMgr_Release(dm);

View File

@ -20,6 +20,8 @@
import "oaidl.idl";
#endif
cpp_quote("#define TS_E_READONLY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0209)")
const ULONG TS_DEFAULT_SELECTION = ~0u;
const DWORD TS_SD_READONLY = 0x001;