Aric Stewart : msctf: Implement ITextStoreACPSink::OnStatusChange.
Alexandre Julliard
julliard at winehq.org
Mon May 25 10:06:29 CDT 2009
Module: wine
Branch: master
Commit: 6117ea47b32b77a488e3fbbd89ba310218e6cc51
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6117ea47b32b77a488e3fbbd89ba310218e6cc51
Author: Aric Stewart <aric at codeweavers.com>
Date: Fri May 22 14:49:30 2009 -0500
msctf: Implement ITextStoreACPSink::OnStatusChange.
Requires changes in the way document locking is implemented and tested.
---
dlls/msctf/context.c | 43 +++++++++++++++++++++++++++++-------
dlls/msctf/tests/inputprocessor.c | 37 +++++++++++++++----------------
2 files changed, 52 insertions(+), 28 deletions(-)
diff --git a/dlls/msctf/context.c b/dlls/msctf/context.c
index 8e14a72..35838c9 100644
--- a/dlls/msctf/context.c
+++ b/dlls/msctf/context.c
@@ -70,6 +70,7 @@ typedef struct tagContext {
TfClientId tidOwner;
TfEditCookie defaultCookie;
+ TS_STATUS documentStatus;
ITextStoreACP *pITextStoreACP;
ITfContextOwnerCompositionSink *pITfContextOwnerCompositionSink;
@@ -223,7 +224,6 @@ static HRESULT WINAPI Context_RequestEditSession (ITfContext *iface,
HRESULT hr;
Context *This = (Context *)iface;
DWORD dwLockFlags = 0x0;
- TS_STATUS status;
TRACE("(%p) %i %p %x %p\n",This, tid, pes, dwFlags, phrSession);
@@ -248,10 +248,10 @@ static HRESULT WINAPI Context_RequestEditSession (ITfContext *iface,
else if (dwFlags & TF_ES_READ)
dwLockFlags |= TS_LF_READ;
- /* TODO: cache this */
- ITextStoreACP_GetStatus(This->pITextStoreACP, &status);
+ if (!This->documentStatus.dwDynamicFlags)
+ ITextStoreACP_GetStatus(This->pITextStoreACP, &This->documentStatus);
- if (((dwFlags & TF_ES_READWRITE) == TF_ES_READWRITE) && (status.dwDynamicFlags & TS_SD_READONLY))
+ if (((dwFlags & TF_ES_READWRITE) == TF_ES_READWRITE) && (This->documentStatus.dwDynamicFlags & TS_SD_READONLY))
{
*phrSession = TS_E_READONLY;
return S_OK;
@@ -263,7 +263,6 @@ static HRESULT WINAPI Context_RequestEditSession (ITfContext *iface,
return E_INVALIDARG;
}
-
hr = ITextStoreACP_RequestLock(This->pITextStoreACP, dwLockFlags, phrSession);
return hr;
@@ -739,8 +738,28 @@ static HRESULT WINAPI TextStoreACPSink_OnStatusChange(ITextStoreACPSink *iface,
DWORD dwFlags)
{
TextStoreACPSink *This = (TextStoreACPSink *)iface;
- FIXME("STUB:(%p)\n",This);
- return E_NOTIMPL;
+ HRESULT hr, hrSession;
+
+ TRACE("(%p) %x\n",This, dwFlags);
+
+ if (!This->pContext)
+ {
+ ERR("No context?\n");
+ return E_FAIL;
+ }
+
+ if (!This->pContext->pITextStoreACP)
+ {
+ FIXME("Context does not have a ITextStoreACP\n");
+ return E_NOTIMPL;
+ }
+
+ hr = ITextStoreACP_RequestLock(This->pContext->pITextStoreACP, TS_LF_READ, &hrSession);
+
+ if(SUCCEEDED(hr) && SUCCEEDED(hrSession))
+ This->pContext->documentStatus.dwDynamicFlags = dwFlags;
+
+ return S_OK;
}
static HRESULT WINAPI TextStoreACPSink_OnAttrsChange(ITextStoreACPSink *iface,
@@ -761,12 +780,18 @@ static HRESULT WINAPI TextStoreACPSink_OnLockGranted(ITextStoreACPSink *iface,
TRACE("(%p) %x\n",This, dwLockFlags);
- if (!This->pContext || !This->pContext->currentEditSession)
+ if (!This->pContext)
{
- ERR("OnLockGranted called on a context without a current edit session\n");
+ ERR("OnLockGranted called without a context\n");
return E_FAIL;
}
+ if (!This->pContext->currentEditSession)
+ {
+ FIXME("OnLockGranted called for something other than an EditSession\n");
+ return S_OK;
+ }
+
cookie = HeapAlloc(GetProcessHeap(),0,sizeof(EditCookie));
if (!cookie)
return E_OUTOFMEMORY;
diff --git a/dlls/msctf/tests/inputprocessor.c b/dlls/msctf/tests/inputprocessor.c
index 5884a30..bdb9a62 100644
--- a/dlls/msctf/tests/inputprocessor.c
+++ b/dlls/msctf/tests/inputprocessor.c
@@ -38,6 +38,8 @@ static ITfDocumentMgr *g_dm = NULL;
static TfClientId cid = 0;
static TfClientId tid = 0;
+static ITextStoreACPSink *ACPSink;
+
#define SINK_UNEXPECTED 0
#define SINK_EXPECTED 1
#define SINK_FIRED 2
@@ -47,6 +49,7 @@ static BOOL test_ShouldDeactivate = FALSE;
static DWORD tmSinkCookie;
static DWORD tmSinkRefCount;
+static DWORD documentStatus;
static ITfDocumentMgr *test_CurrentFocus = NULL;
static ITfDocumentMgr *test_PrevFocus = NULL;
static INT test_OnSetFocus = SINK_UNEXPECTED;
@@ -70,7 +73,6 @@ typedef struct tagTextStoreACP
const ITextStoreACPVtbl *TextStoreACPVtbl;
LONG refCount;
- ITextStoreACPSink *sink;
} TextStoreACP;
static void TextStoreACP_Destructor(TextStoreACP *This)
@@ -117,13 +119,12 @@ static ULONG WINAPI TextStoreACP_Release(ITextStoreACP *iface)
static HRESULT WINAPI TextStoreACP_AdviseSink(ITextStoreACP *iface,
REFIID riid, IUnknown *punk, DWORD dwMask)
{
- TextStoreACP *This = (TextStoreACP *)iface;
HRESULT hr;
ok(test_ACP_AdviseSink == SINK_EXPECTED, "Unexpected TextStoreACP_AdviseSink sink\n");
test_ACP_AdviseSink = SINK_FIRED;
- hr = IUnknown_QueryInterface(punk, &IID_ITextStoreACPSink,(LPVOID*)(&This->sink));
+ hr = IUnknown_QueryInterface(punk, &IID_ITextStoreACPSink,(LPVOID*)(&ACPSink));
ok(SUCCEEDED(hr),"Unable to QueryInterface on sink\n");
return S_OK;
}
@@ -138,28 +139,17 @@ static HRESULT WINAPI TextStoreACP_UnadviseSink(ITextStoreACP *iface,
static HRESULT WINAPI TextStoreACP_RequestLock(ITextStoreACP *iface,
DWORD dwLockFlags, HRESULT *phrSession)
{
- TextStoreACP *This = (TextStoreACP *)iface;
-
ok(test_ACP_RequestLock == SINK_EXPECTED,"Unexpected TextStoreACP_RequestLock\n");
test_ACP_RequestLock = SINK_FIRED;
- test_DoEditSession = SINK_EXPECTED;
- *phrSession = ITextStoreACPSink_OnLockGranted(This->sink, TS_LF_READWRITE);
- ok(test_DoEditSession = SINK_FIRED,"expected DoEditSession not fired\n");
- ok(*phrSession == 0xdeadcafe,"Unexpected return from ITextStoreACPSink_OnLockGranted\n");
+ *phrSession = ITextStoreACPSink_OnLockGranted(ACPSink, dwLockFlags);
return S_OK;
}
static HRESULT WINAPI TextStoreACP_GetStatus(ITextStoreACP *iface,
TS_STATUS *pdcs)
{
- 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");
+ ok(test_ACP_GetStatus == SINK_EXPECTED, "Unexpected TextStoreACP_GetStatus\n");
test_ACP_GetStatus = SINK_FIRED;
- pdcs->dwDynamicFlags = TS_SD_READONLY;
+ pdcs->dwDynamicFlags = documentStatus;
return S_OK;
}
static HRESULT WINAPI TextStoreACP_QueryInsert(ITextStoreACP *iface,
@@ -1483,6 +1473,7 @@ static void test_TStoApplicationText(void)
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);
+ documentStatus = TS_SD_READONLY;
hrSession = 0xfeedface;
test_ACP_GetStatus = SINK_EXPECTED;
hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC|TF_ES_READWRITE, &hrSession);
@@ -1490,13 +1481,21 @@ static void test_TStoApplicationText(void)
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;
+ /* signal a change to allow readwrite sessions */
+ documentStatus = 0;
test_ACP_RequestLock = SINK_EXPECTED;
+ ITextStoreACPSink_OnStatusChange(ACPSink,documentStatus);
+ ok(test_ACP_RequestLock == SINK_FIRED," expected RequestLock not fired\n");
+
+ test_ACP_GetStatus = SINK_EXPECTED;
+ test_ACP_RequestLock = SINK_EXPECTED;
+ test_DoEditSession = SINK_EXPECTED;
hrSession = 0xfeedface;
- hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC|TF_ES_READ, &hrSession);
+ hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC|TF_ES_READWRITE, &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(test_ACP_GetStatus == SINK_FIRED," expected GetStatus not fired\n");
ok(hrSession == 0xdeadcafe,"Unexpected hrSession (%x)\n",hrSession);
ITfContext_Release(cxt);
More information about the wine-cvs
mailing list