factory.c 2.43 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
/*
 * Class factory interface for Queue Manager (BITS)
 *
 * Copyright (C) 2007 Google (Roy Shea)
 *
 * 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 "qmgr.h"
#include "wine/debug.h"

WINE_DEFAULT_DEBUG_CHANNEL(qmgr);

static ULONG WINAPI
29
BITS_IClassFactory_AddRef(IClassFactory *iface)
30
{
31
    return 2; /* non-heap based object */
32 33 34
}

static HRESULT WINAPI
35
BITS_IClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppvObj)
36 37 38
{
    if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IClassFactory))
    {
39
        *ppvObj = &BITS_ClassFactory.IClassFactory_iface;
40 41 42 43 44 45 46 47
        return S_OK;
    }

    *ppvObj = NULL;
    return E_NOINTERFACE;
}

static ULONG WINAPI
48
BITS_IClassFactory_Release(IClassFactory *iface)
49
{
50
    return 1; /* non-heap based object */
51 52 53
}

static HRESULT WINAPI
54 55
BITS_IClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid,
                                  void **ppvObj)
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
{
    HRESULT res;
    IUnknown *punk = NULL;

    TRACE("IID: %s\n", debugstr_guid(riid));

    if (pUnkOuter)
        return CLASS_E_NOAGGREGATION;

    res = BackgroundCopyManagerConstructor(pUnkOuter, (LPVOID*) &punk);
    if (FAILED(res))
        return res;

    res = IUnknown_QueryInterface(punk, riid, ppvObj);
    IUnknown_Release(punk);
    return res;
}

static HRESULT WINAPI
75
BITS_IClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
{
    FIXME("Not implemented\n");
    return E_NOTIMPL;
}

static const IClassFactoryVtbl BITS_IClassFactory_Vtbl =
{
    BITS_IClassFactory_QueryInterface,
    BITS_IClassFactory_AddRef,
    BITS_IClassFactory_Release,
    BITS_IClassFactory_CreateInstance,
    BITS_IClassFactory_LockServer
};

ClassFactoryImpl BITS_ClassFactory =
{
92
    { &BITS_IClassFactory_Vtbl }
93
};