/*
 * Copyright 2005 Jacek Caban
 *
 * 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
 */

import "urlmon.idl";

interface IHlink;
interface IHlinkSite;
interface IHlinkFrame;
interface IHlinkBrowseContext;

cpp_quote("HRESULT WINAPI HlinkCreateFromMoniker(IMoniker*, LPCWSTR, LPCWSTR, IHlinkSite*, DWORD, IUnknown*, REFIID, void**);")
cpp_quote("HRESULT WINAPI HlinkCreateFromString(LPCWSTR, LPCWSTR, LPCWSTR, IHlinkSite*, DWORD, IUnknown*, REFIID, void**);")
cpp_quote("HRESULT WINAPI HlinkCreateFromData(IDataObject*, IHlinkSite*, DWORD dwSiteData, IUnknown*, REFIID, void**);")
cpp_quote("HRESULT WINAPI HlinkCreateExtensionServices(LPCWSTR, HWND, LPCWSTR, LPCWSTR, IUnknown*, REFIID, void**);")
cpp_quote("HRESULT WINAPI HlinkQueryCreateFromData(IDataObject*);")
cpp_quote("HRESULT WINAPI HlinkClone(IHlink*, REFIID, IHlinkSite*, DWORD, void **);")
cpp_quote("HRESULT WINAPI HlinkCreateBrowseContext(IUnknown*, REFIID, void **);")
cpp_quote("HRESULT WINAPI HlinkNavigateToStringReference(LPCWSTR, LPCWSTR, IHlinkSite*, DWORD, IHlinkFrame*, DWORD, LPBC, IBindStatusCallback*, IHlinkBrowseContext*);")
cpp_quote("HRESULT WINAPI HlinkNavigate(IHlink*, IHlinkFrame*, DWORD, LPBC, IBindStatusCallback*, IHlinkBrowseContext*);")
cpp_quote("HRESULT WINAPI HlinkOnNavigate(IHlinkFrame*, IHlinkBrowseContext*, DWORD, IMoniker*, LPCWSTR, LPCWSTR, ULONG*);")
cpp_quote("HRESULT WINAPI HlinkIsShortcut(LPCWSTR);")
cpp_quote("HRESULT WINAPI HlinkTranslateURL(LPCWSTR,DWORD,LPWSTR*);")
cpp_quote("HRESULT WINAPI HlinkParseDisplayName(LPBC,LPCWSTR,BOOL,ULONG*,IMoniker**);")
cpp_quote("HRESULT WINAPI HlinkResolveMonikerForData(LPMONIKER,DWORD,LPBC,ULONG,FORMATETC*,IBindStatusCallback*,LPMONIKER);")
cpp_quote("HRESULT WINAPI HlinkUpdateStackItem(IHlinkFrame*, IHlinkBrowseContext*, ULONG, IMoniker*, LPCWSTR, LPCWSTR);")

typedef enum _HLSR_NOREDEF10 {
    HLSR_HOME,
    HLSR_SEARCHPAGE,
    HLSR_HISTORYFOLDER
} HLSR;

cpp_quote("HRESULT WINAPI HlinkSetSpecialReference(ULONG uReference, LPCWSTR pwzReference);")
cpp_quote("HRESULT WINAPI HlinkGetSpecialReference(ULONG uReference, LPWSTR *ppwzReference);")

cpp_quote("#define SID_SHlinkFrame IID_IHlinkFrame")

/*****************************************************************************
 *    IHlink interface
 */
[
    object,
    uuid(79EAC9C3-BAF9-11CE-8C82-00AA004BA90B),
    pointer_default(unique)
]
interface IHlink: IUnknown
{
    typedef [unique] IHlink *LPHLINK;

    typedef enum {
        HLNF_INTERNALJUMP          = 0x00000001,
        HLNF_OPENINNEWWINDOW       = 0x00000002,
        HLNF_NAVIGATINGBACK        = 0x00000004,
        HLNF_NAVIGATINGFORWARD     = 0x00000008,
        HLNF_NAVIGATINGTOSTACKITEM = 0x00000010,
        HLNF_CREATENOHISTORY       = 0x00000020
    } HLNF;

    typedef enum {
        HLINKGETREF_DEFAULT  = 0,
        HLINKGETREF_ABSOLUTE = 1,
        HLINKGETREF_RELATIVE = 2,
    } HLINKGETREF;

    typedef enum {
        HLFNAMEF_DEFAULT          = 0x00000000,
        HLFNAMEF_TRYCACHE         = 0x00000001,
        HLFNAMEF_TRYPRETTYTARGET  = 0x00000002,
        HLFNAMEF_TRYFULLTARGET    = 0x00000004,
        HLFNAMEF_TRYWIN95SHORTCUT = 0x00000008
    } HLFNAMEF;

    typedef enum {
        HLINKMISC_RELATIVE = 0x00000001,
    } HLINKMISC;

    typedef enum {
        HLINKSETF_TARGET   = 0x00000001,
        HLINKSETF_LOCATION = 0x00000002
    } HLINKSETF;

    HRESULT SetHlinkSite(
        [in, unique] IHlinkSite *pihlSite,
        [in] DWORD dwSiteData);

    HRESULT GetHlinkSite(
        [out] IHlinkSite **ppihlSite,
        [out] DWORD *pdwSiteData);

    HRESULT SetMonikerReference(
        [in] DWORD grfHLSETF,
        [in, unique] IMoniker *pimkTarget,
        [in, unique] LPCWSTR pwzLocation);

    HRESULT GetMonikerReference(
        [in]  DWORD dwWhichRef,
        [out] IMoniker **ppimkTarget,
        [out] LPWSTR *ppwzLocation);

    HRESULT SetStringReference(
        [in] DWORD grfHLSETF,
        [in, unique] LPCWSTR pwzTarget,
        [in, unique] LPCWSTR pwzLocation);

    HRESULT GetStringReference(
        [in]  DWORD dwWhichRef,
        [out] LPWSTR *ppwzTarget,
        [out] LPWSTR *ppwzLocation);

    HRESULT SetFriendlyName(
        [in, unique] LPCWSTR pwzFriendlyName);

    HRESULT GetFriendlyName(
        [in]  DWORD grfHLFNAMEF,
        [out] LPWSTR *ppwzFriendlyName);

    HRESULT SetTargetFrameName(
        [in, unique] LPCWSTR pwzTargetFrameName);

    HRESULT GetTargetFrameName(
        [out] LPWSTR *ppwzTargetFrameName);

    HRESULT GetMiscStatus(
        [out] DWORD *pdwStatus);

    HRESULT Navigate(
        [in] DWORD grfHLNF,
        [in, unique] LPBC pibc,
        [in, unique] IBindStatusCallback *pibsc,
        [in, unique] IHlinkBrowseContext *pihlbc);

    HRESULT SetAdditionalParams(
        [in, unique] LPCWSTR pwzAdditionalParams);

    HRESULT GetAdditionalParams(
        [out] LPWSTR *ppwzAdditionalParams);
}

/*****************************************************************************
 *    IHlinkSite interface
 */
[
    object,
    uuid(79EAC9C2-BAF9-11CE-8C82-00AA004BA90B),
    pointer_default(unique)
]
interface IHlinkSite: IUnknown
{
    typedef [unique] IHlinkSite *LPHLINKSITE;

    typedef enum {
        HLINKWHICHMK_CONTAINER = 1,
        HLINKWHICHMK_BASE      = 2,
    } HLINKWHICHMK;

    HRESULT QueryService(
        [in] DWORD dwSiteData,
        [in] REFGUID guidService,
        [in] REFIID riid,
        [out, iid_is(riid)] IUnknown **ppiunk);

    HRESULT GetMoniker(
        [in] DWORD dwSiteData,
        [in] DWORD dwAssign,
        [in] DWORD dwWhich,
        [out] IMoniker **ppimk);

    HRESULT ReadyToNavigate(
        [in] DWORD dwSiteData,
        [in] DWORD dwReserved);

    HRESULT OnNavigationComplete(
        [in] DWORD dwSiteData,
        [in] DWORD dwreserved,
        [in] HRESULT hrError,
        [in, unique] LPCWSTR pwzError);
}

/*****************************************************************************
 *    IEnumHLITEM interface
 */
[
    local,
    object,
    uuid(79EAC9C6-BAF9-11CE-8C82-00AA004BA90B),
    pointer_default(unique)
]
interface IEnumHLITEM : IUnknown
{
    typedef [unique] IEnumHLITEM *LPENUMHLITEM;

    typedef struct tagHLITEM {
        ULONG  uHLID;
        LPWSTR pwzFriendlyName;
    } HLITEM;
    typedef [unique] HLITEM *LPHLITEM;

    HRESULT Next(
        [in]  ULONG celt,
        [out] HLITEM *rgelt,
        [out] ULONG *pceltFetched);

    HRESULT Skip(
        [in] ULONG celt);

    HRESULT Reset();

    HRESULT Clone(
        [out] IEnumHLITEM **ppienumhlitem);
}

/*****************************************************************************
 *    IHlinkBrowseContext interface
 */
[
    local,
    object,
    uuid(79EAC9C7-BAF9-11CE-8C82-00AA004BA90B),
    pointer_default(unique)
]
interface IHlinkBrowseContext : IUnknown
{
    typedef [unique] IHlinkBrowseContext *LPHLINKBROWSECONTEXT;

    enum {
        HLTB_DOCKEDLEFT    = 0,
        HLTB_DOCKEDTOP     = 1,
        HLTB_DOCKEDRIGHT   = 2,
        HLTB_DOCKEDBOTTOM  = 3,
        HLTB_FLOATING      = 4
    };

    typedef struct _tagHLTBINFO {
        ULONG uDockType;
        RECT  rcTbPos;
    } HLTBINFO;

    enum {
        HLBWIF_HASFRAMEWNDINFO   = 0x00000001,
        HLBWIF_HASDOCWNDINFO     = 0x00000002,
        HLBWIF_FRAMEWNDMAXIMIZED = 0x00000004,
        HLBWIF_DOCWNDMAXIMIZED   = 0x00000008,
        HLBWIF_HASWEBTOOLBARINFO = 0x00000010,
        HLBWIF_WEBTOOLBARHIDDEN  = 0x00000020
    };

    typedef struct _tagHLBWINFO {
        ULONG    cbSize;
        DWORD    grfHLBWIF;
        RECT     rcFramePos;
        RECT     rcDocPos;
        HLTBINFO hltbinfo;
    } HLBWINFO;

    typedef [unique] HLBWINFO *LPHLBWINFO;

    enum {
        HLID_INVALID     = 0x00000000,
        HLID_PREVIOUS    = 0xFFFFFFFF,
        HLID_NEXT        = 0xFFFFFFFE,
        HLID_CURRENT     = 0xFFFFFFFD,
        HLID_STACKBOTTOM = 0xFFFFFFFC,
        HLID_STACKTOP    = 0xFFFFFFFB
    };

    enum {
        HLQF_ISVALID   = 0x00000001,
        HLQF_ISCURRENT = 0x00000002
    };

    HRESULT Register(
        [in] DWORD reserved,
        [in, unique] IUnknown *piunk,
        [in, unique] IMoniker *pimk,
        [out] DWORD *pdwRegister);

cpp_quote("#ifdef WINE_NO_UNICODE_MACROS")
cpp_quote("#undef GetObject")
cpp_quote("#endif")

    HRESULT GetObject(
        [in, unique] IMoniker *pimk,
        [in] BOOL fBindIfRootRegistered,
        [out] IUnknown **ppiunk);

    HRESULT Revoke(
        [in] DWORD dwRegister);

    HRESULT SetBrowseWindowInfo(
        [in, unique] HLBWINFO *phlbwi);

    HRESULT GetBrowseWindowInfo(
        [out] HLBWINFO *phlbwi);

    HRESULT SetInitialHlink(
        [in, unique] IMoniker * pimkTarget,
        [in, unique] LPCWSTR pwzLocation,
        [in, unique] LPCWSTR pwzFriendlyName);

    HRESULT OnNavigateHlink(
        [in] DWORD grfHLNF,
        [in, unique] IMoniker *pimkTarget,
        [in, unique] LPCWSTR pwzLocation,
        [in, unique] LPCWSTR pwzFriendlyName,
        [out] ULONG *puHLID);

    HRESULT UpdateHlink(
        [in] ULONG uHLID,
        [in, unique] IMoniker *pimkTarget,
        [in, unique] LPCWSTR pwzLocation,
        [in, unique] LPCWSTR pwzFriendlyName);

    HRESULT EnumNavigationStack(
        [in] DWORD dwReserved,
        [in] DWORD grfHLFNAMEF,
        [out] IEnumHLITEM **ppienumhlitem);

    HRESULT QueryHlink(
        [in] DWORD grfHLQF,
        [in] ULONG uHLID);

    HRESULT GetHlink(
        [in] ULONG uHLID,
        [out] IHlink **ppihl);

    HRESULT SetCurrentHlink(
        [in] ULONG uHLID);

    HRESULT Clone(
        [in, unique] IUnknown *piunkOuter,
        [in] REFIID riid,
        [out, iid_is(riid)] IUnknown **ppiunkObj);

    HRESULT Close(
        [in] DWORD reserved);
}


/*****************************************************************************
 *    IHlinkTarget interface
 */
[
    object,
    uuid(79EAC9C4-BAF9-11CE-8C82-00AA004BA90B),
    pointer_default(unique)
]
interface IHlinkTarget : IUnknown
{
    typedef [unique] IHlinkTarget *LPHLINKTARGET;

    HRESULT SetBrowseContext(
        [in, unique] IHlinkBrowseContext *pihlbc);

    HRESULT GetBrowseContext(
        [out] IHlinkBrowseContext **ppihlbc);

    HRESULT Navigate(
        [in] DWORD grfHLNF,
        [in, unique] LPCWSTR pwzJumpLocation);

    HRESULT GetMoniker(
        [in,unique]  LPCWSTR pwzLocation,
        [in] DWORD dwAssign,
        [out] IMoniker **ppimkLocation);

    HRESULT GetFriendlyName(
        [in,unique]  LPCWSTR pwzLocation,
        [out] LPWSTR *ppwzFriendlyName);
}

/*****************************************************************************
 *    IHlinkFrame interface
 */
[
    object,
    uuid(79eac9c5-baf9-11ce-8c82-00aa004ba90b),
    pointer_default(unique)
]

interface IHlinkFrame : IUnknown
{
    typedef IHlinkFrame *LPHLINKFRAME;

    HRESULT SetBrowseContext( 
        [in, unique] IHlinkBrowseContext * pihlbc);
    HRESULT GetBrowseContext( 
        [out] IHlinkBrowseContext ** ppihlbc);
    HRESULT Navigate( 
        [in] DWORD grfHLNF, 
        [in, unique] LPBC pbc, 
        [in, unique] IBindStatusCallback *pibsc, 
        [in, unique] IHlink *pihlNavigate);
    HRESULT OnNavigate( 
        [in] DWORD grfHLNF, 
        [in, unique] IMoniker *pimkTarget, 
        [in, unique] LPCWSTR pwzLocation, 
        [in, unique] LPCWSTR pwzFriendlyName, 
        [in] DWORD dwreserved);
    HRESULT UpdateHlink( 
        [in] ULONG uHLID, 
        [in, unique] IMoniker *pimkTarget, 
        [in, unique] LPCWSTR pwzLocation, 
        [in, unique] LPCWSTR pwzFriendlyName);
}

/*****************************************************************************
 *    IExtensionServices interface
 */
[
    object,
    uuid(79eac9cb-baf9-11ce-8c82-00aa004ba90b),
    pointer_default(unique)
]

interface IExtensionServices: IUnknown
{
    typedef IExtensionServices *LPEXTENSIONSERVICES;

    HRESULT SetAdditionalHeaders(
        [in] LPCWSTR pwzAdditionalHeaders);

    HRESULT SetAuthenticateData(
        [in] HWND phwnd,
        [in] LPCWSTR pwzUsername,
        [in] LPCWSTR pwzPassword);
}
