Aric Stewart : msctf: Add base dll framework.
Alexandre Julliard
julliard at winehq.org
Wed Jan 28 08:03:14 CST 2009
Module: wine
Branch: master
Commit: a74aeae6e4adb2e05de85ed78618cd9b6f8bbb50
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a74aeae6e4adb2e05de85ed78618cd9b6f8bbb50
Author: Aric Stewart <aric at codeweavers.com>
Date: Tue Jan 27 14:15:08 2009 -0600
msctf: Add base dll framework.
---
configure | 9 +++
configure.ac | 1 +
dlls/msctf/Makefile.in | 13 ++++
dlls/msctf/msctf.c | 189 ++++++++++++++++++++++++++++++++++++++++++++++++
dlls/msctf/msctf.spec | 7 ++
5 files changed, 219 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index 5053163..873aa21 100755
--- a/configure
+++ b/configure
@@ -25526,6 +25526,14 @@ dlls/mscoree/Makefile: dlls/mscoree/Makefile.in dlls/Makedll.rules"
ac_config_files="$ac_config_files dlls/mscoree/Makefile"
ALL_MAKEFILES="$ALL_MAKEFILES \\
+ dlls/msctf/Makefile"
+test "x$enable_msctf" != xno && ALL_DLL_DIRS="$ALL_DLL_DIRS \\
+ msctf"
+ALL_MAKEFILE_DEPENDS="$ALL_MAKEFILE_DEPENDS
+dlls/msctf/Makefile: dlls/msctf/Makefile.in dlls/Makedll.rules"
+ac_config_files="$ac_config_files dlls/msctf/Makefile"
+
+ALL_MAKEFILES="$ALL_MAKEFILES \\
dlls/msdmo/Makefile"
test "x$enable_msdmo" != xno && ALL_DLL_DIRS="$ALL_DLL_DIRS \\
msdmo"
@@ -28459,6 +28467,7 @@ do
"dlls/mscms/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/mscms/Makefile" ;;
"dlls/mscms/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/mscms/tests/Makefile" ;;
"dlls/mscoree/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/mscoree/Makefile" ;;
+ "dlls/msctf/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/msctf/Makefile" ;;
"dlls/msdmo/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/msdmo/Makefile" ;;
"dlls/msftedit/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/msftedit/Makefile" ;;
"dlls/msg711.acm/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/msg711.acm/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index 12cc8e2..acacf4c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1983,6 +1983,7 @@ WINE_CONFIG_MAKEFILE([dlls/mscat32/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DL
WINE_CONFIG_MAKEFILE([dlls/mscms/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/mscms/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests])
WINE_CONFIG_MAKEFILE([dlls/mscoree/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
+WINE_CONFIG_MAKEFILE([dlls/msctf/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/msdmo/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/msftedit/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/msg711.acm/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
diff --git a/dlls/msctf/Makefile.in b/dlls/msctf/Makefile.in
new file mode 100644
index 0000000..1505037
--- /dev/null
+++ b/dlls/msctf/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+MODULE = msctf.dll
+IMPORTS = uuid ole32 user32 advapi32 kernel32 ntdll
+
+C_SRCS = \
+ msctf.c
+
+ at MAKE_DLL_RULES@
+
+ at DEPENDENCIES@ # everything below this line is overwritten by make depend
diff --git a/dlls/msctf/msctf.c b/dlls/msctf/msctf.c
new file mode 100644
index 0000000..564eb73
--- /dev/null
+++ b/dlls/msctf/msctf.c
@@ -0,0 +1,189 @@
+/*
+ * MSCTF Server DLL
+ *
+ * Copyright 2008 Aric Stewart, CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#define COBJMACROS
+
+#include "wine/debug.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "shlwapi.h"
+#include "shlguid.h"
+#include "initguid.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msctf);
+
+LONG MSCTF_refCount = 0;
+
+HINSTANCE MSCTF_hinstance = 0;
+
+typedef HRESULT (*LPFNCONSTRUCTOR)(IUnknown *pUnkOuter, IUnknown **ppvOut);
+
+static const struct {
+ REFCLSID clsid;
+ LPFNCONSTRUCTOR ctor;
+} ClassesTable[] = {
+ {NULL, NULL}
+};
+
+typedef struct tagClassFactory
+{
+ const IClassFactoryVtbl *vtbl;
+ LONG ref;
+ LPFNCONSTRUCTOR ctor;
+} ClassFactory;
+
+static void ClassFactory_Destructor(ClassFactory *This)
+{
+ TRACE("Destroying class factory %p\n", This);
+ HeapFree(GetProcessHeap(),0,This);
+ MSCTF_refCount--;
+}
+
+static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppvOut)
+{
+ *ppvOut = NULL;
+ if (IsEqualIID(riid, &IID_IClassFactory) || IsEqualIID(riid, &IID_IUnknown)) {
+ IClassFactory_AddRef(iface);
+ *ppvOut = iface;
+ return S_OK;
+ }
+
+ WARN("Unknown interface %s\n", debugstr_guid(riid));
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
+{
+ ClassFactory *This = (ClassFactory *)iface;
+ return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
+{
+ ClassFactory *This = (ClassFactory *)iface;
+ ULONG ret = InterlockedDecrement(&This->ref);
+
+ if (ret == 0)
+ ClassFactory_Destructor(This);
+ return ret;
+}
+
+static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *punkOuter, REFIID iid, LPVOID *ppvOut)
+{
+ ClassFactory *This = (ClassFactory *)iface;
+ HRESULT ret;
+ IUnknown *obj;
+
+ TRACE("(%p, %p, %s, %p)\n", iface, punkOuter, debugstr_guid(iid), ppvOut);
+ ret = This->ctor(punkOuter, &obj);
+ if (FAILED(ret))
+ return ret;
+ ret = IUnknown_QueryInterface(obj, iid, ppvOut);
+ IUnknown_Release(obj);
+ return ret;
+}
+
+static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
+{
+ ClassFactory *This = (ClassFactory *)iface;
+
+ TRACE("(%p)->(%x)\n", This, fLock);
+
+ if(fLock)
+ InterlockedIncrement(&MSCTF_refCount);
+ else
+ InterlockedDecrement(&MSCTF_refCount);
+
+ return S_OK;
+}
+
+static const IClassFactoryVtbl ClassFactoryVtbl = {
+ /* IUnknown */
+ ClassFactory_QueryInterface,
+ ClassFactory_AddRef,
+ ClassFactory_Release,
+
+ /* IClassFactory*/
+ ClassFactory_CreateInstance,
+ ClassFactory_LockServer
+};
+
+static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut)
+{
+ ClassFactory *This = HeapAlloc(GetProcessHeap(),0,sizeof(ClassFactory));
+ This->vtbl = &ClassFactoryVtbl;
+ This->ref = 1;
+ This->ctor = ctor;
+ *ppvOut = (LPVOID)This;
+ TRACE("Created class factory %p\n", This);
+ MSCTF_refCount++;
+ return S_OK;
+}
+
+/*************************************************************************
+ * MSCTF DllMain
+ */
+BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
+{
+ TRACE("%p 0x%x %p\n", hinst, fdwReason, fImpLoad);
+ switch (fdwReason)
+ {
+ case DLL_WINE_PREATTACH:
+ return FALSE; /* prefer native version */
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls(hinst);
+ MSCTF_hinstance = hinst;
+ break;
+ }
+ return TRUE;
+}
+
+/*************************************************************************
+ * DllCanUnloadNow (MSCTF.@)
+ */
+HRESULT WINAPI DllCanUnloadNow(void)
+{
+ return MSCTF_refCount ? S_FALSE : S_OK;
+}
+
+/***********************************************************************
+ * DllGetClassObject (MSCTF.@)
+ */
+HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *ppvOut)
+{
+ int i;
+
+ *ppvOut = NULL;
+ if (!IsEqualIID(iid, &IID_IUnknown) && !IsEqualIID(iid, &IID_IClassFactory))
+ return E_NOINTERFACE;
+
+ for (i = 0; ClassesTable[i].clsid != NULL; i++)
+ if (IsEqualCLSID(ClassesTable[i].clsid, clsid)) {
+ return ClassFactory_Constructor(ClassesTable[i].ctor, ppvOut);
+ }
+ FIXME("CLSID %s not supported\n", debugstr_guid(clsid));
+ return CLASS_E_CLASSNOTAVAILABLE;
+}
diff --git a/dlls/msctf/msctf.spec b/dlls/msctf/msctf.spec
new file mode 100644
index 0000000..4d73291
--- /dev/null
+++ b/dlls/msctf/msctf.spec
@@ -0,0 +1,7 @@
+@ stdcall -private DllCanUnloadNow()
+@ stdcall -private DllGetClassObject(ptr ptr ptr)
+@ stub DllRegisterServer
+@ stub DllUnregisterServer
+@ stub SetInputScope
+@ stub SetInputScopeXML
+@ stub SetInputScopes
More information about the wine-cvs
mailing list