1 /*
2  *  ITfDisplayAttributeMgr implementation
3  *
4  *  Copyright 2010 CodeWeavers, Aric Stewart
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #define WIN32_NO_STATUS
22 #define _INC_WINDOWS
23 #define COM_NO_WINDOWS_H
24 
25 #define COBJMACROS
26 
27 #include <wine/debug.h>
28 #include <winbase.h>
29 #include <winreg.h>
30 #include <shlwapi.h>
31 
32 #include <msctf.h>
33 //#include "msctf_internal.h"
34 
35 WINE_DEFAULT_DEBUG_CHANNEL(msctf);
36 
37 typedef struct tagDisplayAttributeMgr {
38     ITfDisplayAttributeMgr ITfDisplayAttributeMgr_iface;
39 
40     LONG refCount;
41 
42 } DisplayAttributeMgr;
43 
44 static inline DisplayAttributeMgr *impl_from_ITfDisplayAttributeMgr(ITfDisplayAttributeMgr *iface)
45 {
46     return CONTAINING_RECORD(iface, DisplayAttributeMgr, ITfDisplayAttributeMgr_iface);
47 }
48 
49 static void DisplayAttributeMgr_Destructor(DisplayAttributeMgr *This)
50 {
51     TRACE("destroying %p\n", This);
52 
53     HeapFree(GetProcessHeap(),0,This);
54 }
55 
56 static HRESULT WINAPI DisplayAttributeMgr_QueryInterface(ITfDisplayAttributeMgr *iface, REFIID iid, LPVOID *ppvOut)
57 {
58     DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
59     *ppvOut = NULL;
60 
61     if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfDisplayAttributeMgr))
62     {
63         *ppvOut = This;
64     }
65 
66     if (*ppvOut)
67     {
68         IUnknown_AddRef(iface);
69         return S_OK;
70     }
71 
72     WARN("unsupported interface: %s\n", debugstr_guid(iid));
73     return E_NOINTERFACE;
74 }
75 
76 static ULONG WINAPI DisplayAttributeMgr_AddRef(ITfDisplayAttributeMgr *iface)
77 {
78     DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
79     return InterlockedIncrement(&This->refCount);
80 }
81 
82 static ULONG WINAPI DisplayAttributeMgr_Release(ITfDisplayAttributeMgr *iface)
83 {
84     DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
85     ULONG ret;
86 
87     ret = InterlockedDecrement(&This->refCount);
88     if (ret == 0)
89         DisplayAttributeMgr_Destructor(This);
90     return ret;
91 }
92 
93 /*****************************************************
94  * ITfDisplayAttributeMgr functions
95  *****************************************************/
96 
97 static HRESULT WINAPI DisplayAttributeMgr_OnUpdateInfo(ITfDisplayAttributeMgr *iface)
98 {
99     DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
100 
101     FIXME("STUB:(%p)\n",This);
102     return E_NOTIMPL;
103 }
104 
105 static HRESULT WINAPI DisplayAttributeMgr_EnumDisplayAttributeInfo(ITfDisplayAttributeMgr *iface, IEnumTfDisplayAttributeInfo **ppEnum)
106 {
107     DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
108 
109     FIXME("STUB:(%p)\n",This);
110     return E_NOTIMPL;
111 }
112 
113 static HRESULT WINAPI DisplayAttributeMgr_GetDisplayAttributeInfo(ITfDisplayAttributeMgr *iface, REFGUID guid, ITfDisplayAttributeInfo **ppInfo, CLSID *pclsidOwner)
114 {
115     DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
116 
117     FIXME("STUB:(%p)\n",This);
118     return E_NOTIMPL;
119 }
120 
121 static const ITfDisplayAttributeMgrVtbl DisplayAttributeMgr_DisplayAttributeMgrVtbl =
122 {
123     DisplayAttributeMgr_QueryInterface,
124     DisplayAttributeMgr_AddRef,
125     DisplayAttributeMgr_Release,
126 
127     DisplayAttributeMgr_OnUpdateInfo,
128     DisplayAttributeMgr_EnumDisplayAttributeInfo,
129     DisplayAttributeMgr_GetDisplayAttributeInfo
130 };
131 
132 HRESULT DisplayAttributeMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
133 {
134     DisplayAttributeMgr *This;
135     if (pUnkOuter)
136         return CLASS_E_NOAGGREGATION;
137 
138     This = HeapAlloc(GetProcessHeap(),0,sizeof(DisplayAttributeMgr));
139     if (This == NULL)
140         return E_OUTOFMEMORY;
141 
142     This->ITfDisplayAttributeMgr_iface.lpVtbl = &DisplayAttributeMgr_DisplayAttributeMgrVtbl;
143     This->refCount = 1;
144 
145     TRACE("returning %p\n", This);
146     *ppOut = (IUnknown *)This;
147     return S_OK;
148 }
149