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

Alexandre Julliard julliard at winehq.org
Tue May 19 09:23:04 CDT 2009


Module: wine
Branch: master
Commit: 4bb8e9959a0c3088c5de014dcf59b87edf7549cc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4bb8e9959a0c3088c5de014dcf59b87edf7549cc

Author: Aric Stewart <aric at codeweavers.com>
Date:   Mon May 18 08:58:43 2009 -0500

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

---

 dlls/msctf/context.c              |   68 ++++++++++++++++++++++++++++++++++--
 dlls/msctf/tests/inputprocessor.c |   30 +++++++++++-----
 include/textstor.idl              |    2 +
 3 files changed, 87 insertions(+), 13 deletions(-)

diff --git a/dlls/msctf/context.c b/dlls/msctf/context.c
index 42ae71e..1f255c8 100644
--- a/dlls/msctf/context.c
+++ b/dlls/msctf/context.c
@@ -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)
diff --git a/dlls/msctf/tests/inputprocessor.c b/dlls/msctf/tests/inputprocessor.c
index a4d9979..318149b 100644
--- a/dlls/msctf/tests/inputprocessor.c
+++ b/dlls/msctf/tests/inputprocessor.c
@@ -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);
diff --git a/include/textstor.idl b/include/textstor.idl
index b603198..90e30ca 100644
--- a/include/textstor.idl
+++ b/include/textstor.idl
@@ -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;




More information about the wine-cvs mailing list