wiadevmgr.c 9.64 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
/*
 * WiaDevMgr functions
 *
 * Copyright 2009 Damjan Jovanovic
 *
 * 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
 */

#define COBJMACROS

#include "objbase.h"
#include "wia_lh.h"

#include "wiaservc_private.h"

#include "wine/debug.h"

WINE_DEFAULT_DEBUG_CHANNEL(wia);

32 33 34 35 36 37
typedef struct
{
    IEnumWIA_DEV_INFO IEnumWIA_DEV_INFO_iface;
    LONG ref;
} enumwiadevinfo;

38
static inline wiadevmgr *impl_from_IWiaDevMgr(IWiaDevMgr *iface)
39
{
40
    return CONTAINING_RECORD(iface, wiadevmgr, IWiaDevMgr_iface);
41 42
}

43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 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
static inline enumwiadevinfo *impl_from_IEnumWIA_DEV_INFO(IEnumWIA_DEV_INFO *iface)
{
    return CONTAINING_RECORD(iface, enumwiadevinfo, IEnumWIA_DEV_INFO_iface);
}

static HRESULT WINAPI enumwiadevinfo_QueryInterface(IEnumWIA_DEV_INFO *iface, REFIID riid, void **obj)
{
    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);

    TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), obj);

    if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IEnumWIA_DEV_INFO))
        *obj = iface;
    else
    {
        FIXME("interface %s not implemented\n", debugstr_guid(riid));
        *obj = NULL;
        return E_NOINTERFACE;
    }
    IUnknown_AddRef((IUnknown*)*obj);
    return S_OK;
}

static ULONG WINAPI enumwiadevinfo_AddRef(IEnumWIA_DEV_INFO *iface)
{
    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);
    ULONG ref = InterlockedIncrement(&This->ref);
    TRACE("(%p)->(%u)\n", This, ref);
    return ref;
}

static ULONG WINAPI enumwiadevinfo_Release(IEnumWIA_DEV_INFO *iface)
{
    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);
    ULONG ref = InterlockedDecrement(&This->ref);

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

    if (ref == 0)
        HeapFree(GetProcessHeap(), 0, This);
    return ref;
}

static HRESULT WINAPI enumwiadevinfo_Next(IEnumWIA_DEV_INFO *iface, ULONG count, IWiaPropertyStorage **elem, ULONG *fetched)
{
    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);

    FIXME("(%p, %d, %p, %p): stub\n", This, count, elem, fetched);

    *fetched = 0;
    return E_NOTIMPL;
}

static HRESULT WINAPI enumwiadevinfo_Skip(IEnumWIA_DEV_INFO *iface, ULONG count)
{
    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);

    FIXME("(%p, %u): stub\n", This, count);

    return E_NOTIMPL;
}

static HRESULT WINAPI enumwiadevinfo_Reset(IEnumWIA_DEV_INFO *iface)
{
    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);

    FIXME("(%p): stub\n", This);

    return E_NOTIMPL;
}

static HRESULT WINAPI enumwiadevinfo_Clone(IEnumWIA_DEV_INFO *iface, IEnumWIA_DEV_INFO **ret)
{
    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);

    FIXME("(%p, %p): stub\n", This, ret);

    return E_NOTIMPL;
}

static HRESULT WINAPI enumwiadevinfo_GetCount(IEnumWIA_DEV_INFO *iface, ULONG *count)
{
    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);

    FIXME("(%p, %p): stub\n", This, count);

    *count = 0;
    return E_NOTIMPL;
}

static const IEnumWIA_DEV_INFOVtbl EnumWIA_DEV_INFOVtbl =
{
    enumwiadevinfo_QueryInterface,
    enumwiadevinfo_AddRef,
    enumwiadevinfo_Release,
    enumwiadevinfo_Next,
    enumwiadevinfo_Skip,
    enumwiadevinfo_Reset,
    enumwiadevinfo_Clone,
    enumwiadevinfo_GetCount
};

145 146
static HRESULT WINAPI wiadevmgr_QueryInterface(IWiaDevMgr *iface, REFIID riid, void **ppvObject)
{
147
    wiadevmgr *This = impl_from_IWiaDevMgr(iface);
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

    TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObject);

    if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IWiaDevMgr))
        *ppvObject = iface;
    else
    {
        FIXME("interface %s not implemented\n", debugstr_guid(riid));
        *ppvObject = NULL;
        return E_NOINTERFACE;
    }
    IUnknown_AddRef((IUnknown*) *ppvObject);
    return S_OK;
}

static ULONG WINAPI wiadevmgr_AddRef(IWiaDevMgr *iface)
{
165
    wiadevmgr *This = impl_from_IWiaDevMgr(iface);
166 167 168 169 170 171
    return InterlockedIncrement(&This->ref);
}

static ULONG WINAPI wiadevmgr_Release(IWiaDevMgr *iface)
{
    ULONG ref;
172
    wiadevmgr *This = impl_from_IWiaDevMgr(iface);
173 174 175 176 177 178 179

    ref = InterlockedDecrement(&This->ref);
    if (ref == 0)
        HeapFree(GetProcessHeap(), 0, This);
    return ref;
}

180
static HRESULT WINAPI wiadevmgr_EnumDeviceInfo(IWiaDevMgr *iface, LONG flag, IEnumWIA_DEV_INFO **ret)
181
{
182
    wiadevmgr *This = impl_from_IWiaDevMgr(iface);
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
    enumwiadevinfo *enuminfo;

    TRACE("(%p)->(%x, %p)\n", This, flag, ret);

    *ret = NULL;

    enuminfo = HeapAlloc(GetProcessHeap(), 0, sizeof(*enuminfo));
    if (!enuminfo)
        return E_OUTOFMEMORY;

    enuminfo->IEnumWIA_DEV_INFO_iface.lpVtbl = &EnumWIA_DEV_INFOVtbl;
    enuminfo->ref = 1;

    *ret = &enuminfo->IEnumWIA_DEV_INFO_iface;
    return S_OK;
198 199 200 201
}

static HRESULT WINAPI wiadevmgr_CreateDevice(IWiaDevMgr *iface, BSTR bstrDeviceID, IWiaItem **ppWiaItemRoot)
{
202
    wiadevmgr *This = impl_from_IWiaDevMgr(iface);
203 204 205 206 207 208 209
    FIXME("(%p, %s, %p): stub\n", This, debugstr_w(bstrDeviceID), ppWiaItemRoot);
    return E_NOTIMPL;
}

static HRESULT WINAPI wiadevmgr_SelectDeviceDlg(IWiaDevMgr *iface, HWND hwndParent, LONG lDeviceType,
                                                LONG lFlags, BSTR *pbstrDeviceID, IWiaItem **ppItemRoot)
{
210
    wiadevmgr *This = impl_from_IWiaDevMgr(iface);
211 212 213 214 215 216 217
    FIXME("(%p, %p, %d, 0x%x, %p, %p): stub\n", This, hwndParent, lDeviceType, lFlags, pbstrDeviceID, ppItemRoot);
    return E_NOTIMPL;
}

static HRESULT WINAPI wiadevmgr_SelectDeviceDlgID(IWiaDevMgr *iface, HWND hwndParent, LONG lDeviceType,
                                                  LONG lFlags, BSTR *pbstrDeviceID)
{
218
    wiadevmgr *This = impl_from_IWiaDevMgr(iface);
219 220 221 222 223 224 225 226
    FIXME("(%p, %p, %d, 0x%x, %p): stub\n", This, hwndParent, lDeviceType, lFlags, pbstrDeviceID);
    return E_NOTIMPL;
}

static HRESULT WINAPI wiadevmgr_GetImageDlg(IWiaDevMgr *iface, HWND hwndParent, LONG lDeviceType,
                                            LONG lFlags, LONG lIntent, IWiaItem *pItemRoot,
                                            BSTR bstrFilename, GUID *pguidFormat)
{
227
    wiadevmgr *This = impl_from_IWiaDevMgr(iface);
228 229 230 231 232 233 234 235 236
    FIXME("(%p, %p, %d, 0x%x, %d, %p, %s, %s): stub\n", This, hwndParent, lDeviceType, lFlags,
        lIntent, pItemRoot, debugstr_w(bstrFilename), debugstr_guid(pguidFormat));
    return E_NOTIMPL;
}

static HRESULT WINAPI wiadevmgr_RegisterEventCallbackProgram(IWiaDevMgr *iface, LONG lFlags, BSTR bstrDeviceID,
                                                             const GUID *pEventGUID, BSTR bstrCommandline,
                                                             BSTR bstrName, BSTR bstrDescription, BSTR bstrIcon)
{
237
    wiadevmgr *This = impl_from_IWiaDevMgr(iface);
238 239 240 241 242 243 244 245 246 247
    FIXME("(%p, 0x%x, %s, %s, %s, %s, %s, %s): stub\n", This, lFlags, debugstr_w(bstrDeviceID),
        debugstr_guid(pEventGUID), debugstr_w(bstrCommandline), debugstr_w(bstrName),
        debugstr_w(bstrDescription), debugstr_w(bstrIcon));
    return E_NOTIMPL;
}

static HRESULT WINAPI wiadevmgr_RegisterEventCallbackInterface(IWiaDevMgr *iface, LONG lFlags, BSTR bstrDeviceID,
                                                               const GUID *pEventGUID, IWiaEventCallback *pIWiaEventCallback,
                                                               IUnknown **pEventObject)
{
248
    wiadevmgr *This = impl_from_IWiaDevMgr(iface);
249 250 251 252 253 254 255 256 257
    FIXME("(%p, 0x%x, %s, %s, %p, %p): stub\n", This, lFlags, debugstr_w(bstrDeviceID),
        debugstr_guid(pEventGUID), pIWiaEventCallback, pEventObject);
    return E_NOTIMPL;
}

static HRESULT WINAPI wiadevmgr_RegisterEventCallbackCLSID(IWiaDevMgr *iface, LONG lFlags, BSTR bstrDeviceID,
                                                           const GUID *pEventGUID, const GUID *pClsID, BSTR bstrName,
                                                           BSTR bstrDescription, BSTR bstrIcon)
{
258
    wiadevmgr *This = impl_from_IWiaDevMgr(iface);
259 260 261 262 263 264 265 266
    FIXME("(%p, 0x%x, %s, %s, %s, %s, %s, %s): stub\n", This, lFlags, debugstr_w(bstrDeviceID),
        debugstr_guid(pEventGUID), debugstr_guid(pClsID), debugstr_w(bstrName),
        debugstr_w(bstrDescription), debugstr_w(bstrIcon));
    return E_NOTIMPL;
}

static HRESULT WINAPI wiadevmgr_AddDeviceDlg(IWiaDevMgr *iface, HWND hwndParent, LONG lFlags)
{
267
    wiadevmgr *This = impl_from_IWiaDevMgr(iface);
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
    FIXME("(%p, %p, 0x%x): stub\n", This, hwndParent, lFlags);
    return E_NOTIMPL;
}

static const IWiaDevMgrVtbl WIASERVC_IWiaDevMgr_Vtbl =
{
    wiadevmgr_QueryInterface,
    wiadevmgr_AddRef,
    wiadevmgr_Release,
    wiadevmgr_EnumDeviceInfo,
    wiadevmgr_CreateDevice,
    wiadevmgr_SelectDeviceDlg,
    wiadevmgr_SelectDeviceDlgID,
    wiadevmgr_GetImageDlg,
    wiadevmgr_RegisterEventCallbackProgram,
    wiadevmgr_RegisterEventCallbackInterface,
    wiadevmgr_RegisterEventCallbackCLSID,
    wiadevmgr_AddDeviceDlg
};

288
HRESULT wiadevmgr_Constructor(IWiaDevMgr **ppObj)
289 290
{
    wiadevmgr *This;
291
    TRACE("(%p)\n", ppObj);
292 293 294
    This = HeapAlloc(GetProcessHeap(), 0, sizeof(wiadevmgr));
    if (This)
    {
295
        This->IWiaDevMgr_iface.lpVtbl = &WIASERVC_IWiaDevMgr_Vtbl;
296
        This->ref = 1;
297
        *ppObj = &This->IWiaDevMgr_iface;
298 299 300 301 302
        return S_OK;
    }
    *ppObj = NULL;
    return E_OUTOFMEMORY;
}