Add the IAutoComplete and IAutoComplete2 implementation (but methods
[wine.git] / dlls / shell32 / autocomplete.c
blob948c63019bfd6cab40a42f79d5a18a90e9ad33fd
1 /*
2 * AutoComplete interfaces implementation.
4 * Copyright 2004 Maxime Bellengé <maxime.bellenge@laposte.net>
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <stdarg.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include "wine/debug.h"
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winreg.h"
28 #include "undocshell.h"
29 #include "shlwapi.h"
30 #include "winerror.h"
31 #include "objbase.h"
33 #include "pidl.h"
34 #include "shlguid.h"
35 #include "shlobj.h"
36 #include "shldisp.h"
37 #include "debughlp.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(shell);
41 typedef struct
43 ICOM_VFIELD(IAutoComplete);
44 ICOM_VTABLE (IAutoComplete2) * lpvtblAutoComplete2;
45 DWORD ref;
46 BOOL enable;
47 AUTOCOMPLETEOPTIONS options;
48 } IAutoCompleteImpl;
50 static struct ICOM_VTABLE(IAutoComplete) acvt;
51 static struct ICOM_VTABLE(IAutoComplete2) ac2vt;
53 #define _IAutoComplete2_Offset ((int)(&(((IAutoCompleteImpl*)0)->lpvtblAutoComplete2)))
54 #define _ICOM_THIS_From_IAutoComplete2(class, name) class* This = (class*)(((char*)name)-_IAutoComplete2_Offset);
57 converts This to a interface pointer
59 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
60 #define _IAutoComplete2_(This) (IAutoComplete2*)&(This->lpvtblAutoComplete2)
62 /**************************************************************************
63 * IAutoComplete_Constructor
65 HRESULT WINAPI IAutoComplete_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
67 IAutoCompleteImpl *lpac;
69 if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown))
70 return CLASS_E_NOAGGREGATION;
72 lpac = (IAutoCompleteImpl*)HeapAlloc(GetProcessHeap(),
73 HEAP_ZERO_MEMORY, sizeof(IAutoCompleteImpl));
74 if (!lpac)
75 return E_OUTOFMEMORY;
77 lpac->ref = 1;
78 lpac->lpVtbl = &acvt;
79 lpac->lpvtblAutoComplete2 = &ac2vt;
80 lpac->enable = TRUE;
82 if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (lpac), riid, ppv))) {
83 IUnknown_Release (_IUnknown_ (lpac));
84 return E_NOINTERFACE;
87 TRACE("-- (%p)->\n",lpac);
89 return S_OK;
92 /**************************************************************************
93 * AutoComplete_QueryInterface
95 static HRESULT WINAPI IAutoComplete_fnQueryInterface(
96 IAutoComplete * iface,
97 REFIID riid,
98 LPVOID *ppvObj)
100 ICOM_THIS(IAutoCompleteImpl, iface);
102 TRACE("(%p)->(\n\tIID:\t%s,%p)\n", This, shdebugstr_guid(riid), ppvObj);
103 *ppvObj = NULL;
105 if(IsEqualIID(riid, &IID_IUnknown))
107 *ppvObj = This;
109 else if(IsEqualIID(riid, &IID_IAutoComplete))
111 *ppvObj = (IAutoComplete*)This;
113 else if(IsEqualIID(riid, &IID_IAutoComplete2))
115 *ppvObj = _IAutoComplete2_ (This);
118 if (*ppvObj)
120 IAutoComplete_AddRef((IAutoComplete*)*ppvObj);
121 TRACE("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
122 return S_OK;
124 TRACE("-- Interface: E_NOINTERFACE\n");
125 return E_NOINTERFACE;
128 /******************************************************************************
129 * IAutoComplete_fnAddRef
131 static ULONG WINAPI IAutoComplete_fnAddRef(
132 IAutoComplete * iface)
134 ICOM_THIS(IAutoCompleteImpl,iface);
136 TRACE("(%p)->(%lu)\n",This,This->ref);
137 return ++(This->ref);
140 /******************************************************************************
141 * IAutoComplete_fnRelease
143 static ULONG WINAPI IAutoComplete_fnRelease(
144 IAutoComplete * iface)
146 ICOM_THIS(IAutoCompleteImpl,iface);
148 TRACE("(%p)->(%lu)\n",This,This->ref);
150 if (!--(This->ref)) {
151 TRACE(" destroying IAutoComplete(%p)\n",This);
152 HeapFree(GetProcessHeap(), 0, This);
153 return 0;
155 return This->ref;
158 /******************************************************************************
159 * IAutoComplete_fnEnable
161 static HRESULT WINAPI IAutoComplete_fnEnable(
162 IAutoComplete * iface,
163 BOOL fEnable)
165 ICOM_THIS(IAutoCompleteImpl, iface);
167 HRESULT hr = S_OK;
169 TRACE("(%p)->(%s)\n", This, (fEnable)?"true":"false");
171 This->enable = fEnable;
173 return hr;
176 /******************************************************************************
177 * IAutoComplete_fnInit
179 static HRESULT WINAPI IAutoComplete_fnInit(
180 IAutoComplete * iface,
181 HWND hwndEdit,
182 IUnknown *punkACL,
183 LPCOLESTR pwzsRegKeyPath,
184 LPCOLESTR pwszQuickComplete)
186 ICOM_THIS(IAutoCompleteImpl, iface);
188 HRESULT hr = E_NOTIMPL;
190 FIXME("(%p)->(0x%08lx, %p, %s, %s) not implemented\n",
191 This, (long)hwndEdit, punkACL, debugstr_w(pwzsRegKeyPath), debugstr_w(pwszQuickComplete));
193 return hr;
196 /**************************************************************************
197 * IAutoComplete_fnVTable
199 static ICOM_VTABLE (IAutoComplete) acvt =
201 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
202 IAutoComplete_fnQueryInterface,
203 IAutoComplete_fnAddRef,
204 IAutoComplete_fnRelease,
205 IAutoComplete_fnInit,
206 IAutoComplete_fnEnable,
209 /**************************************************************************
210 * AutoComplete2_QueryInterface
212 static HRESULT WINAPI IAutoComplete2_fnQueryInterface(
213 IAutoComplete2 * iface,
214 REFIID riid,
215 LPVOID *ppvObj)
217 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl, iface);
219 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
221 return IAutoComplete_QueryInterface((IAutoComplete*)This, riid, ppvObj);
224 /******************************************************************************
225 * IAutoComplete2_fnAddRef
227 static ULONG WINAPI IAutoComplete2_fnAddRef(
228 IAutoComplete2 * iface)
230 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl,iface);
232 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
234 return IAutoComplete2_AddRef((IAutoComplete*)This);
237 /******************************************************************************
238 * IAutoComplete2_fnRelease
240 static ULONG WINAPI IAutoComplete2_fnRelease(
241 IAutoComplete2 * iface)
243 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl,iface);
245 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
247 return IAutoComplete_Release((IAutoComplete*)This);
250 /******************************************************************************
251 * IAutoComplete2_fnEnable
253 static HRESULT WINAPI IAutoComplete2_fnEnable(
254 IAutoComplete2 * iface,
255 BOOL fEnable)
257 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl, iface);
259 TRACE ("(%p)->(%s)\n", This, (fEnable)?"true":"false");
261 return IAutoComplete_Enable((IAutoComplete*)This, fEnable);
264 /******************************************************************************
265 * IAutoComplete2_fnInit
267 static HRESULT WINAPI IAutoComplete2_fnInit(
268 IAutoComplete2 * iface,
269 HWND hwndEdit,
270 IUnknown *punkACL,
271 LPCOLESTR pwzsRegKeyPath,
272 LPCOLESTR pwszQuickComplete)
274 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl, iface);
276 TRACE("(%p)\n", This);
278 return IAutoComplete_Init((IAutoComplete*)This, hwndEdit, punkACL, pwzsRegKeyPath, pwszQuickComplete);
281 /**************************************************************************
282 * IAutoComplete_fnGetOptions
284 static HRESULT WINAPI IAutoComplete2_fnGetOptions(
285 IAutoComplete2 * iface,
286 DWORD *pdwFlag)
288 HRESULT hr = S_OK;
290 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl, iface);
292 TRACE("(%p) -> (%p)\n", This, pdwFlag);
294 *pdwFlag = This->options;
296 return hr;
299 /**************************************************************************
300 * IAutoComplete_fnSetOptions
302 static HRESULT WINAPI IAutoComplete2_fnSetOptions(
303 IAutoComplete2 * iface,
304 DWORD dwFlag)
306 HRESULT hr = S_OK;
308 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl, iface);
310 FIXME("(%p) -> (0x%lx) not implemented\n", This, dwFlag);
312 return hr;
315 /**************************************************************************
316 * IAutoComplete2_fnVTable
318 static ICOM_VTABLE (IAutoComplete2) ac2vt =
320 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
321 IAutoComplete2_fnQueryInterface,
322 IAutoComplete2_fnAddRef,
323 IAutoComplete2_fnRelease,
324 IAutoComplete2_fnInit,
325 IAutoComplete2_fnEnable,
326 /* IAutoComplete2 */
327 IAutoComplete2_fnSetOptions,
328 IAutoComplete2_fnGetOptions,