aclsource.c 5.74 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
/*
 *	Shell AutoComplete list
 *
 *	Copyright 2008	CodeWeavers, Aric Stewart
 *
 * 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>

#define COBJMACROS

#include "wine/debug.h"
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "winuser.h"
#include "shlwapi.h"
#include "winerror.h"
#include "objbase.h"

#include "shlguid.h"
#include "shlobj.h"

#include "wine/unicode.h"

#include "browseui.h"

WINE_DEFAULT_DEBUG_CHANNEL(browseui);

45 46
typedef struct tagACLShellSource {
    IEnumString IEnumString_iface;
47
    IACList2 IACList2_iface;
48 49 50 51
    LONG refCount;
    DWORD dwOptions;
} ACLShellSource;

52 53 54 55 56
static inline ACLShellSource *impl_from_IACList2(IACList2 *iface)
{
    return CONTAINING_RECORD(iface, ACLShellSource, IACList2_iface);
}

57 58 59 60 61
static inline ACLShellSource *impl_from_IEnumString(IEnumString *iface)
{
    return CONTAINING_RECORD(iface, ACLShellSource, IEnumString_iface);
}

62 63 64 65 66 67
static void ACLShellSource_Destructor(ACLShellSource *This)
{
    TRACE("destroying %p\n", This);
    heap_free(This);
}

68
static HRESULT WINAPI ACLShellSource_QueryInterface(IEnumString *iface, REFIID iid, LPVOID *ppvOut)
69
{
70 71 72 73
    ACLShellSource *This = impl_from_IEnumString(iface);

    TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(iid), ppvOut);

74 75
    *ppvOut = NULL;

76 77 78 79 80
    if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_IEnumString))
    {
        *ppvOut = &This->IEnumString_iface;
    }
    else if (IsEqualIID(iid, &IID_IACList2) || IsEqualIID(iid, &IID_IACList))
81
    {
82
        *ppvOut = &This->IACList2_iface;
83 84 85 86
    }

    if (*ppvOut)
    {
87
        IEnumString_AddRef(iface);
88 89 90 91 92 93 94
        return S_OK;
    }

    WARN("unsupported interface: %s\n", debugstr_guid(iid));
    return E_NOINTERFACE;
}

95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
static ULONG WINAPI ACLShellSource_AddRef(IEnumString *iface)
{
    ACLShellSource *This = impl_from_IEnumString(iface);
    ULONG ref = InterlockedIncrement(&This->refCount);
    TRACE("(%p)->(%u)\n", This, ref);
    return ref;
}

static ULONG WINAPI ACLShellSource_Release(IEnumString *iface)
{
    ACLShellSource *This = impl_from_IEnumString(iface);
    ULONG ref = InterlockedDecrement(&This->refCount);

    TRACE("(%p)->(%u)\n", This, ref);

    if (ref == 0)
        ACLShellSource_Destructor(This);
    return ref;
}

static HRESULT WINAPI ACLShellSource_Next(IEnumString *iface, ULONG celt, LPOLESTR *rgelt,
    ULONG *fetched)
{
    ACLShellSource *This = impl_from_IEnumString(iface);
    FIXME("(%p)->(%u %p %p): stub\n", This, celt, rgelt, fetched);
    return E_NOTIMPL;
}

static HRESULT WINAPI ACLShellSource_Skip(IEnumString *iface, ULONG celt)
{
    ACLShellSource *This = impl_from_IEnumString(iface);
    FIXME("(%p)->(%u): stub\n", This, celt);
    return E_NOTIMPL;
}

static HRESULT WINAPI ACLShellSource_Reset(IEnumString *iface)
{
    ACLShellSource *This = impl_from_IEnumString(iface);
    FIXME("(%p): stub\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI ACLShellSource_Clone(IEnumString *iface, IEnumString **ppenum)
{
    ACLShellSource *This = impl_from_IEnumString(iface);
    FIXME("(%p)->(%p): stub\n", This, ppenum);
    return E_NOTIMPL;
}

static const IEnumStringVtbl ACLShellSourceVtbl = {
    ACLShellSource_QueryInterface,
    ACLShellSource_AddRef,
    ACLShellSource_Release,
    ACLShellSource_Next,
    ACLShellSource_Skip,
    ACLShellSource_Reset,
    ACLShellSource_Clone
};

static HRESULT WINAPI ACList_QueryInterface(IACList2 *iface, REFIID iid, void **ppvOut)
155
{
156
    ACLShellSource *This = impl_from_IACList2(iface);
157
    return IEnumString_QueryInterface(&This->IEnumString_iface, iid, ppvOut);
158 159
}

160
static ULONG WINAPI ACList_AddRef(IACList2 *iface)
161
{
162
    ACLShellSource *This = impl_from_IACList2(iface);
163 164
    return IEnumString_AddRef(&This->IEnumString_iface);
}
165

166 167 168 169
static ULONG WINAPI ACList_Release(IACList2 *iface)
{
    ACLShellSource *This = impl_from_IACList2(iface);
    return IEnumString_Release(&This->IEnumString_iface);
170 171
}

172
static HRESULT WINAPI ACList_Expand(IACList2 *iface, LPCWSTR wstr)
173
{
174
    ACLShellSource *This = impl_from_IACList2(iface);
175 176 177 178
    FIXME("STUB:(%p) %s\n",This,debugstr_w(wstr));
    return E_NOTIMPL;
}

179
static HRESULT WINAPI ACList_GetOptions(IACList2 *iface, DWORD *pdwFlag)
180
{
181
    ACLShellSource *This = impl_from_IACList2(iface);
182 183 184 185
    *pdwFlag = This->dwOptions;
    return S_OK;
}

186
static HRESULT WINAPI ACList_SetOptions(IACList2 *iface,
187 188
    DWORD dwFlag)
{
189
    ACLShellSource *This = impl_from_IACList2(iface);
190 191 192 193
    This->dwOptions = dwFlag;
    return S_OK;
}

194
static const IACList2Vtbl ACListVtbl =
195
{
196 197 198 199 200 201
    ACList_QueryInterface,
    ACList_AddRef,
    ACList_Release,
    ACList_Expand,
    ACList_SetOptions,
    ACList_GetOptions
202 203 204 205 206 207 208 209 210 211 212 213
};

HRESULT ACLShellSource_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
{
    ACLShellSource *This;
    if (pUnkOuter)
        return CLASS_E_NOAGGREGATION;

    This = heap_alloc_zero(sizeof(ACLShellSource));
    if (This == NULL)
        return E_OUTOFMEMORY;

214 215
    This->IEnumString_iface.lpVtbl = &ACLShellSourceVtbl;
    This->IACList2_iface.lpVtbl = &ACListVtbl;
216 217 218
    This->refCount = 1;

    TRACE("returning %p\n", This);
219
    *ppOut = (IUnknown *)&This->IEnumString_iface;
220 221
    return S_OK;
}