/*
 * Implementation of IPersist interfaces for IE Web Browser control
 *
 * 2001 John R. Sheets (for CodeWeavers)
 *
 * Copyright (c) TransGaming Technologies 2003
 * david@transgaming.com
 */

#include "wine/debug.h"
#include "shdocvw.h"

WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);

/**********************************************************************
 * Implement the IPersistStorage interface
 */

static HRESULT WINAPI WBPS_QueryInterface(LPPERSISTSTORAGE iface,
                                          REFIID riid, LPVOID *ppobj)
{
    ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PS, iface);

    TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppobj);
    return IWebBrowser_QueryInterface((LPWEBBROWSER) This, riid, ppobj);
}

static ULONG WINAPI WBPS_AddRef(LPPERSISTSTORAGE iface)
{
    ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PS, iface);
    TRACE("(%p)->()\n", iface);
    return IWebBrowser_AddRef((LPWEBBROWSER) This);
}

static ULONG WINAPI WBPS_Release(LPPERSISTSTORAGE iface)
{
    ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PS, iface);
    TRACE("(%p)->()\n", iface);
    return IWebBrowser_Release((LPWEBBROWSER) This);
}

static HRESULT WINAPI WBPS_GetClassID(LPPERSISTSTORAGE iface, CLSID *pClassID)
{
    /*ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PS, iface);*/
    FIXME("(%p)->(...): stub\n", iface);
    return S_OK;
}

static HRESULT WINAPI WBPS_IsDirty(LPPERSISTSTORAGE iface)
{
    /*ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PS, iface);*/
    FIXME("(%p)->(...): stub\n", iface);
    return S_OK;
}

static HRESULT WINAPI WBPS_InitNew(LPPERSISTSTORAGE iface, LPSTORAGE pStg)
{
    /*ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PS, iface);*/
    FIXME("(%p)->(...): stub\n", iface);
    return S_OK;
}

static HRESULT WINAPI WBPS_Load(LPPERSISTSTORAGE iface, LPSTORAGE pStg)
{
    /*ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PS, iface);*/
    FIXME("(%p)->(...): stub\n", iface);
    return S_OK;
}

static HRESULT WINAPI WBPS_Save(LPPERSISTSTORAGE iface, LPSTORAGE pStg,
                                BOOL fSameAsLoad)
{
    /*ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PS, iface);*/
    FIXME("(%p)->(...): stub\n", iface);
    return S_OK;
}

static HRESULT WINAPI WBPS_SaveCompleted(LPPERSISTSTORAGE iface, LPSTORAGE pStgNew)
{
    /*ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PS, iface);*/
    FIXME("(%p)->(...): stub\n", iface);
    return S_OK;
}

/**********************************************************************
 * IPersistStorage virtual function table for WebBrowser class
 */

ICOM_VTABLE(IPersistStorage) WBPS_Vtbl =
{
    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    WBPS_QueryInterface,
    WBPS_AddRef,
    WBPS_Release,
    WBPS_GetClassID,
    WBPS_IsDirty,
    WBPS_InitNew,
    WBPS_Load,
    WBPS_Save,
    WBPS_SaveCompleted
};

/**********************************************************************
 * Implement the IPersistStreamInit interface
 */

static HRESULT WINAPI WBPSI_QueryInterface(LPPERSISTSTREAMINIT iface,
                                           REFIID riid, LPVOID *ppobj)
{
    ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PSI, iface);

    TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppobj);
    return IWebBrowser_QueryInterface((LPWEBBROWSER) This, riid, ppobj);
}

static ULONG WINAPI WBPSI_AddRef(LPPERSISTSTREAMINIT iface)
{
    ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PSI, iface);
    TRACE("(%p)->()\n", iface);
    return IWebBrowser_AddRef((LPWEBBROWSER) This);
}

static ULONG WINAPI WBPSI_Release(LPPERSISTSTREAMINIT iface)
{
    ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PSI, iface);
    TRACE("(%p)->()\n", iface);
    return IWebBrowser_Release((LPWEBBROWSER) This);
}

static HRESULT WINAPI WBPSI_GetClassID(LPPERSISTSTREAMINIT iface, CLSID *pClassID)
{
    /*ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PSI, iface);*/
    FIXME("(%p)->(...): stub\n", iface);
    return S_OK;
}

static HRESULT WINAPI WBPSI_IsDirty(LPPERSISTSTREAMINIT iface)
{
    /*ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PSI, iface);*/
    FIXME("(%p)->(...): stub\n", iface);
    return S_OK;
}

static HRESULT WINAPI WBPSI_Load(LPPERSISTSTREAMINIT iface, LPSTREAM pStg)
{
    /*ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PSI, iface);*/
    FIXME("(%p)->(...): stub\n", iface);
    return S_OK;
}

static HRESULT WINAPI WBPSI_Save(LPPERSISTSTREAMINIT iface, LPSTREAM pStg,
                                BOOL fSameAsLoad)
{
    /*ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PSI, iface);*/
    FIXME("(%p)->(...): stub\n", iface);
    return S_OK;
}

static HRESULT WINAPI WBPSI_GetSizeMax(LPPERSISTSTREAMINIT iface,
                                       ULARGE_INTEGER *pcbSize)
{
    /*ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PSI, iface);*/
    FIXME("(%p)->(...): stub\n", iface);
    return S_OK;
}

static HRESULT WINAPI WBPSI_InitNew(LPPERSISTSTREAMINIT iface)
{
    /*ICOM_THIS_MULTI(IWebBrowserImpl, lpVtbl_PSI, iface);*/
    FIXME("(%p)->(...): stub\n", iface);
    return S_OK;
}

/**********************************************************************
 * IPersistStreamInit virtual function table for WebBrowser class
 */

ICOM_VTABLE(IPersistStreamInit) WBPSI_Vtbl =
{
    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    WBPSI_QueryInterface,
    WBPSI_AddRef,
    WBPSI_Release,
    WBPSI_GetClassID,
    WBPSI_IsDirty,
    WBPSI_Load,
    WBPSI_Save,
    WBPSI_GetSizeMax,
    WBPSI_InitNew
};

