/* dpnet.dll
 *
 * Copyright 2002, 2003 TransGaming Technologies
 *
 * David Hammerton (david@transgaming.com)
 */

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

#include "dplay8.h"
#include "dplobby8.h"
#include "dplay8_private.h"

WINE_DEFAULT_DEBUG_CHANNEL(dplay);

static ICOM_VTABLE(IDirectPlay8LobbyClient) directPlay8LobbyClientVT;

HRESULT WINAPI
DirectPlay8LobbyClient_QueryInterface(PDIRECTPLAY8LOBBYCLIENT iface,
                                      REFIID riid, LPVOID *obj)
{
    ICOM_THIS(IDirectPlay8LobbyClientImpl, iface);
    TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), obj);
    if (IsEqualGUID(&IID_IUnknown, riid) ||
        IsEqualGUID(&IID_IDirectPlay8LobbyClient, riid))
    {
        This->ref++;
        *obj = This;
        return S_OK;
    }
    else
    {
        FIXME("(%p)->(%s, %p): no interface\n", iface, debugstr_guid(riid), obj);
        return E_NOINTERFACE;
    }
}

ULONG WINAPI
DirectPlay8LobbyClient_AddRef(PDIRECTPLAY8LOBBYCLIENT iface)
{
    ICOM_THIS(IDirectPlay8LobbyClientImpl, iface);
    TRACE("(%p)->()\n", iface);
    return ++This->ref;
}

ULONG WINAPI
DirectPlay8LobbyClient_Release(PDIRECTPLAY8LOBBYCLIENT iface)
{
    ICOM_THIS(IDirectPlay8LobbyClientImpl, iface);
    TRACE("(%p)->()\n", iface);
    if (--This->ref) return This->ref;

    FIXME("destroy this and everything\n");

    HeapFree(GetProcessHeap(), 0, This);
    return 0;
}

HRESULT
DPNET_CreateDirectPlay8LobbyClient(IUnknown *pOuter, REFIID riid, LPVOID *ppobj)
{
    IDirectPlay8LobbyClientImpl *ipDP8LC;
    HRESULT hr;
    TRACE("()\n");
    ipDP8LC = (IDirectPlay8LobbyClientImpl *)
        HeapAlloc(GetProcessHeap(),
                  HEAP_ZERO_MEMORY,
                  sizeof(IDirectPlay8LobbyClientImpl));
    if (ipDP8LC == NULL) return E_OUTOFMEMORY;
    ICOM_VTBL(ipDP8LC) = &directPlay8LobbyClientVT;
    IDirectPlay8LobbyClient_AddRef((IDirectPlay8LobbyClient *)ipDP8LC);
    TRACE("Created new interface: %p\n", ipDP8LC);
    hr = IDirectPlay8LobbyClient_QueryInterface((IDirectPlay8LobbyClient *)ipDP8LC, riid, ppobj);
    IDirectPlay8LobbyClient_Release((IDirectPlay8LobbyClient *)ipDP8LC);
    if (SUCCEEDED(hr))
        return S_OK;
    else
        return E_NOINTERFACE;
}

static ICOM_VTABLE(IDirectPlay8LobbyClient) directPlay8LobbyClientVT =
{
    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    DirectPlay8LobbyClient_QueryInterface,
    DirectPlay8LobbyClient_AddRef,
    DirectPlay8LobbyClient_Release,
    (void*)0xdead6004, /* Initialize */
    (void*)0xdead6005, /* EnumLocalPrograms */
    (void*)0xdead6006, /* ConnectApplication */
    (void*)0xdead6007, /* Send */
    (void*)0xdead6008, /* ReleaseApplication */
    (void*)0xdead6009, /* Close */
    (void*)0xdead600a, /* GetConnectionSettings */
    (void*)0xdead600b  /* SetConnectionSettings */
};

