/*
 * Deprecated shell interfaces
 *
 * Copyright (C) 2010 Nikolay Sivov for CodeWeavers
 *
 * 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 "objidl.idl";
import "ocidl.idl";
import "shtypes.idl";
import "shobjidl.idl";
import "hlink.idl";
import "exdisp.idl";

cpp_quote("#define TLOG_BACK    -1")
cpp_quote("#define TLOG_FORE    1")

cpp_quote("#define TLMENUF_INCLUDECURRENT   0x00000001")
cpp_quote("#define TLMENUF_CHECKCURRENT     (TLMENUF_INCLUDECURRENT | 0x00000002)")
cpp_quote("#define TLMENUF_BACK             0x00000010")
cpp_quote("#define TLMENUF_FORE             0x00000020")
cpp_quote("#define TLMENUF_BACKANDFORTH     (TLMENUF_BACK | TLMENUF_FORE | TLMENUF_INCLUDECURRENT)")

[
    hidden,
    local,
    object,
    uuid(F46EDB3B-BC2F-11d0-9412-00AA00A3EBD3)
]
interface ITravelEntry : IUnknown
{
    HRESULT Invoke(
        [in] IUnknown *punk);

    HRESULT Update(
        [in] IUnknown *punk,
        [in] BOOL fIsLocalAnchor);

    HRESULT GetPidl(
        [out] LPITEMIDLIST *ppidl);
}

[
    hidden,
    local,
    object,
    uuid(66A9CB08-4802-11d2-A561-00A0C92DBFE8)
]
interface ITravelLog : IUnknown
{
    HRESULT AddEntry(
        [in] IUnknown *punk,
        [in] BOOL fIsLocalAnchor);

    HRESULT UpdateEntry(
        [in] IUnknown *punk,
        [in] BOOL fIsLocalAnchor);

    HRESULT UpdateExternal(
        [in] IUnknown *punk,
        [in] IUnknown *punkHLBrowseContext);

    HRESULT Travel(
        [in] IUnknown *punk,
        [in] int iOffset);

    HRESULT GetTravelEntry(
        [in]  IUnknown *punk,
        [in]  int iOffset,
        [optional, out] ITravelEntry **ppte);

    HRESULT FindTravelEntry(
        [in]  IUnknown *punk,
        [in]  LPCITEMIDLIST pidl,
        [out] ITravelEntry **ppte);

    HRESULT GetToolTipText(
        [in]  IUnknown *punk,
        [in]  int iOffset,
        [in]  int idsTemplate,
        [out, size_is(cchText)] LPWSTR pwzText,
        [in]  DWORD cchText);

    HRESULT InsertMenuEntries(
        [in] IUnknown *punk,
        [in] HMENU hmenu,
        [in] int nPos,
        [in] int idFirst,
        [in] int idLast,
        [in] DWORD dwFlags);

    HRESULT Clone(
        [out] ITravelLog **pptl);

    DWORD CountEntries(
        [in] IUnknown *punk);

    HRESULT Revert();
}

typedef void *CIE4ConnectionPoint;

[
    local,
    object,
    uuid(0D7D1D00-6FC0-11D0-A974-00C04FD705A2)
]
interface IExpDispSupport : IUnknown
{
    HRESULT FindCIE4ConnectionPoint(
        REFIID riid,
        CIE4ConnectionPoint **ppccp);

    HRESULT OnTranslateAccelerator(
        MSG  *pMsg,
        DWORD grfModifiers);

    HRESULT OnInvoke(
        DISPID dispidMember,
        REFIID iid,
        LCID lcid,
        WORD wFlags,
        DISPPARAMS *pdispparams,
        VARIANT *pVarResult,
        EXCEPINFO *pexcepinfo,
        UINT *puArgErr);
}

typedef enum tagBNSTATE
{
    BNS_NORMAL = 0,
    BNS_BEGIN_NAVIGATE = 1,
    BNS_NAVIGATE = 2

} BNSTATE;

enum {
    SBSC_HIDE = 0,
    SBSC_SHOW = 1,
    SBSC_TOGGLE = 2,
    SBSC_QUERY =  3
};

cpp_quote("#define BSF_REGISTERASDROPTARGET     0x00000001")
cpp_quote("#define BSF_THEATERMODE              0x00000002")
cpp_quote("#define BSF_NOLOCALFILEWARNING       0x00000010")
cpp_quote("#define BSF_UISETBYAUTOMATION        0x00000100")
cpp_quote("#define BSF_RESIZABLE                0x00000200")
cpp_quote("#define BSF_CANMAXIMIZE              0x00000400")
cpp_quote("#define BSF_TOPBROWSER               0x00000800")
cpp_quote("#define BSF_NAVNOHISTORY             0x00001000")
cpp_quote("#define BSF_HTMLNAVCANCELED          0x00002000")
cpp_quote("#define BSF_DONTSHOWNAVCANCELPAGE    0x00004000")
cpp_quote("#define BSF_SETNAVIGATABLECODEPAGE   0x00008000")
cpp_quote("#define BSF_DELEGATEDNAVIGATION      0x00010000")
cpp_quote("#define BSF_TRUSTEDFORACTIVEX        0x00020000")

cpp_quote("#define HLNF_CALLERUNTRUSTED             0x00200000")
cpp_quote("#define HLNF_TRUSTEDFORACTIVEX           0x00400000")
cpp_quote("#define HLNF_DISABLEWINDOWRESTRICTIONS   0x00800000")
cpp_quote("#define HLNF_TRUSTFIRSTDOWNLOAD          0x01000000")
cpp_quote("#define HLNF_UNTRUSTEDFORDOWNLOAD        0x02000000")
cpp_quote("#define SHHLNF_NOAUTOSELECT              0x04000000")
cpp_quote("#define SHHLNF_WRITENOHISTORY            0x08000000")
cpp_quote("#define HLNF_EXTERNALNAVIGATE            0x10000000")
cpp_quote("#define HLNF_ALLOW_AUTONAVIGATE          0x20000000")
cpp_quote("#define HLNF_NEWWINDOWSMANAGED           0x80000000")

[
    local,
    object,
    uuid(02ba3b52-0547-11d1-b833-00c04fc9b31f)
]
interface IBrowserService : IUnknown
{
    HRESULT GetParentSite(
        [out] IOleInPlaceSite **ppipsite);

    HRESULT SetTitle(
        [in] IShellView *psv,
        [in] LPCWSTR pszName);

    HRESULT GetTitle(
        [in] IShellView *psv,
        [out, size_is(cchName)] LPWSTR pszName,
        [in] DWORD cchName);

    HRESULT GetOleObject(
        [out] IOleObject **ppobjv);

    HRESULT GetTravelLog(
        [out, optional] ITravelLog **pptl);

    HRESULT ShowControlWindow(
        [in] UINT id,
        [in] BOOL fShow);

    HRESULT IsControlWindowShown(
        [in] UINT id,
        [out] BOOL *pfShown);

    HRESULT IEGetDisplayName(
        [in] PCIDLIST_ABSOLUTE pidl,
        [out] LPWSTR pwszName,
        [in] UINT uFlags);

    HRESULT IEParseDisplayName(
        [in] UINT uiCP,
        [in] LPCWSTR pwszPath,
        [out] PIDLIST_ABSOLUTE *ppidlOut);

    HRESULT DisplayParseError(
        [in] HRESULT hres,
        [in] LPCWSTR pwszPath);

    HRESULT NavigateToPidl(
        [in] PCIDLIST_ABSOLUTE pidl,
        [in] DWORD grfHLNF);

    HRESULT SetNavigateState(
        [in] BNSTATE bnstate);

    HRESULT GetNavigateState(
        [out] BNSTATE *pbnstate);

    HRESULT NotifyRedirect(
        [in] IShellView *psv,
        [in] PCIDLIST_ABSOLUTE pidl,
        [out] BOOL *pfDidBrowse);

    HRESULT UpdateWindowList();

    HRESULT UpdateBackForwardState();

    HRESULT SetFlags(
        [in] DWORD dwFlags,
        [in] DWORD dwFlagMask);

    HRESULT GetFlags(
        [out] DWORD *pdwFlags);

    HRESULT CanNavigateNow();

    HRESULT GetPidl(
        [out] PIDLIST_ABSOLUTE *ppidl);

    HRESULT SetReferrer(
        [in] PCIDLIST_ABSOLUTE pidl);

    DWORD GetBrowserIndex();

    HRESULT GetBrowserByIndex(
        [in] DWORD dwID,
        [out] IUnknown **ppunk);

    HRESULT GetHistoryObject(
        [out] IOleObject **ppole,
        [out] IStream **pstm,
        [out] IBindCtx **ppbc);

    HRESULT SetHistoryObject(
        [in] IOleObject *pole,
        [in] BOOL fIsLocalAnchor);

    HRESULT CacheOLEServer(
        [in] IOleObject *pole);

    HRESULT GetSetCodePage(
        [in] VARIANT *pvarIn,
        [out] VARIANT *pvarOut);

    HRESULT OnHttpEquiv(
        [in] IShellView *psv,
        [in] BOOL fDone,
        [in] VARIANT *pvarargIn,
        [out] VARIANT *pvarargOut);

    HRESULT GetPalette(
        [out] HPALETTE *hpal);

    HRESULT RegisterWindow(
        [in] BOOL fForceRegister,
        [in] int swc);
}

[
    object,
    local,
    uuid(5836fb00-8187-11cf-a12b-00aa004ae837)
]
interface IShellService : IUnknown
{
    HRESULT SetOwner( [in] IUnknown *pUnk );
}

cpp_quote("#if 0")
typedef HANDLE HMONITOR;
cpp_quote("#endif")

enum {
    SECURELOCK_NOCHANGE                 = -1,
    SECURELOCK_SET_UNSECURE             = 0,
    SECURELOCK_SET_MIXED                = 1,
    SECURELOCK_SET_SECUREUNKNOWNBIT     = 2,
    SECURELOCK_SET_SECURE40BIT          = 3,
    SECURELOCK_SET_SECURE56BIT          = 4,
    SECURELOCK_SET_FORTEZZA             = 5,
    SECURELOCK_SET_SECURE128BIT         = 6,
    SECURELOCK_FIRSTSUGGEST             = 7,
    SECURELOCK_SUGGEST_UNSECURE         = SECURELOCK_FIRSTSUGGEST,
    SECURELOCK_SUGGEST_MIXED            = 8,
    SECURELOCK_SUGGEST_SECUREUNKNOWNBIT = 9,
    SECURELOCK_SUGGEST_SECURE40BIT      = 10,
    SECURELOCK_SUGGEST_SECURE56BIT      = 11,
    SECURELOCK_SUGGEST_FORTEZZA         = 12,
    SECURELOCK_SUGGEST_SECURE128BIT     = 13,
};


typedef struct {
    HWND _hwnd;
    ITravelLog *_ptl;
    IHlinkFrame *_phlf;
    IWebBrowser2 *_pautoWB2;
    IExpDispSupport *_pautoEDS;
    IShellService *_pautoSS;
    int _eSecureLockIcon;
    DWORD _fCreatingViewWindow;
    UINT _uActivateState;

    LPCITEMIDLIST _pidlNewShellView;

    IOleCommandTarget *_pctView;

    LPITEMIDLIST _pidlCur;
    IShellView *_psv;
    IShellFolder *_psf;
    HWND _hwndView;
    LPWSTR _pszTitleCur;

    LPITEMIDLIST _pidlPending;
    IShellView *_psvPending;
    IShellFolder *_psfPending;
    HWND _hwndViewPending;
    LPWSTR _pszTitlePending;

    BOOL _fIsViewMSHTML;
    BOOL _fPrivacyImpacted;

} BASEBROWSERDATA, *LPBASEBROWSERDATA;
typedef const BASEBROWSERDATA *LPCBASEBROWSERDATA;

cpp_quote("#define VIEW_PRIORITY_RESTRICTED         0x00000070")
cpp_quote("#define VIEW_PRIORITY_CACHEHIT           0x00000050")
cpp_quote("#define VIEW_PRIORITY_STALECACHEHIT      0x00000045")
cpp_quote("#define VIEW_PRIORITY_USEASDEFAULT       0x00000043")
cpp_quote("#define VIEW_PRIORITY_SHELLEXT           0x00000040")
cpp_quote("#define VIEW_PRIORITY_CACHEMISS          0x00000030")
cpp_quote("#define VIEW_PRIORITY_INHERIT            0x00000020")
cpp_quote("#define VIEW_PRIORITY_SHELLEXT_ASBACKUP  0x0015")
cpp_quote("#define VIEW_PRIORITY_DESPERATE          0x00000010")
cpp_quote("#define VIEW_PRIORITY_NONE               0x00000000")

typedef struct tagFolderSetData {
    FOLDERSETTINGS _fs;
    SHELLVIEWID _vidRestore;
    DWORD _dwViewPriority;
} FOLDERSETDATA, *LPFOLDERSETDATA;

typedef struct SToolbarItem {
    IDockingWindow *ptbar;
    BORDERWIDTHS rcBorderTool;
    LPWSTR pwszItem;
    BOOL fShow;
    HMONITOR hMon;
} TOOLBARITEM, *LPTOOLBARITEM;

cpp_quote("#define ITB_VIEW        ((UINT)-1)")

[
    local,
    object,
    uuid(68BD21CC-438B-11d2-A560-00A0C92DBFE8)
]
interface IBrowserService2 : IBrowserService
{
    LRESULT WndProcBS(
        [in] HWND hwnd,
        [in] UINT uMsg,
        [in] WPARAM wParam,
        [in] LPARAM lParam);

    HRESULT SetAsDefFolderSettings();

    HRESULT GetViewRect(
        [in, out] RECT *prc);

    HRESULT OnSize(
        [in] WPARAM wParam);

    HRESULT OnCreate(
        [in] struct tagCREATESTRUCTW *pcs);

    LRESULT OnCommand(
        [in] WPARAM wParam,
        [in] LPARAM lParam);

    HRESULT OnDestroy();

    LRESULT OnNotify(
        [in, out] struct tagNMHDR *pnm);

    HRESULT OnSetFocus();

    HRESULT OnFrameWindowActivateBS(
        [in] BOOL fActive);

    HRESULT ReleaseShellView();

    HRESULT ActivatePendingView();

    HRESULT CreateViewWindow(
        [in] IShellView *psvNew,
        [in] IShellView *psvOld,
        [out] LPRECT prcView,
        [out] HWND *phwnd);

    HRESULT CreateBrowserPropSheetExt(
        [in] REFIID riid,
        [out] void **ppv);

    HRESULT GetViewWindow(
        [out] HWND *phwndView);

    HRESULT GetBaseBrowserData(
        [in, out] LPCBASEBROWSERDATA *pbbd);

    LPBASEBROWSERDATA PutBaseBrowserData();

    HRESULT InitializeTravelLog(
        [in] ITravelLog *ptl,
        [in] DWORD dw);

    HRESULT SetTopBrowser();

    HRESULT Offline(
        [in] int iCmd);

    HRESULT AllowViewResize(
        [in] BOOL f);

    HRESULT SetActivateState(
        [in] UINT u);

    HRESULT UpdateSecureLockIcon(
        [in] int eSecureLock);

    HRESULT InitializeDownloadManager();

    HRESULT InitializeTransitionSite();

    HRESULT _Initialize(
        [in] HWND hwnd,
        [in] IUnknown *pauto);

    HRESULT _CancelPendingNavigationAsync();

    HRESULT _CancelPendingView();

    HRESULT _MaySaveChanges();

    HRESULT _PauseOrResumeView(
        [in] BOOL fPaused);

    HRESULT _DisableModeless();

    HRESULT _NavigateToPidl(
        [in] LPCITEMIDLIST pidl,
        [in] DWORD grfHLNF,
        [in] DWORD dwFlags);

    HRESULT _TryShell2Rename(
        [in] IShellView *psv,
        [in] LPCITEMIDLIST pidlNew);

    HRESULT _SwitchActivationNow();

    HRESULT _ExecChildren(
        [in] IUnknown *punkBar,
        [in] BOOL fBroadcast,
        [in] const GUID *pguidCmdGroup,
        [in] DWORD nCmdID,
        [in] DWORD nCmdexecopt,
        [in] VARIANTARG *pvarargIn,
        [in, out] VARIANTARG *pvarargOut);

    HRESULT _SendChildren(
        [in] HWND hwndBar,
        [in] BOOL fBroadcast,
        [in] UINT uMsg,
        [in] WPARAM wParam,
        [in] LPARAM lParam);

    HRESULT GetFolderSetData(
        [in, out] struct tagFolderSetData *pfsd);

    HRESULT _OnFocusChange(
        [in] UINT itb);

    HRESULT v_ShowHideChildWindows(
        [in] BOOL fChildOnly);

    UINT _get_itbLastFocus();

    HRESULT _put_itbLastFocus(
        [in] UINT itbLastFocus);

    HRESULT _UIActivateView(
        [in] UINT uState);

    HRESULT _GetViewBorderRect(
        [in, out] RECT* prc);

    HRESULT _UpdateViewRectSize();

    HRESULT _ResizeNextBorder(
        [in] UINT itb);

    HRESULT _ResizeView();

    HRESULT _GetEffectiveClientArea(
        [in, out] LPRECT lprectBorder,
        [in] HMONITOR hmon);

    IStream* v_GetViewStream(
        [in] LPCITEMIDLIST pidl,
        [in] DWORD grfMode,
        [in] LPCWSTR pwszName);

    LRESULT ForwardViewMsg(
        [in] UINT uMsg,
        [in] WPARAM wParam,
        [in] LPARAM lParam);

    HRESULT SetAcceleratorMenu(
        [in] HACCEL hacc);

    int _GetToolbarCount();

    LPTOOLBARITEM _GetToolbarItem(
        [in] int itb);

    HRESULT _SaveToolbars(
        [in] IStream *pstm);

    HRESULT _LoadToolbars(
        [in] IStream *pstm);

    HRESULT _CloseAndReleaseToolbars(
        [in] BOOL fClose);

    HRESULT v_MayGetNextToolbarFocus(
        [in] LPMSG lpMsg,
        [in] UINT itbNext,
        [in] int citb,
        [out] LPTOOLBARITEM *pptbi,
        [out] HWND *phwnd);

    HRESULT _ResizeNextBorderHelper(
        [in] UINT itb,
        [in] BOOL bUseHmonitor);

    UINT _FindTBar(
        [in] IUnknown *punkSrc);

    HRESULT _SetFocus(
        [in] LPTOOLBARITEM ptbi,
        [in] HWND hwnd,
        [in] LPMSG lpMsg);

    HRESULT v_MayTranslateAccelerator(
        [in] MSG* pmsg);

    HRESULT _GetBorderDWHelper(
        [in] IUnknown *punkSrc,
        [in] LPRECT lprectBorder,
        [in] BOOL bUseHmonitor);

    HRESULT v_CheckZoneCrossing(
        [in, out] LPCITEMIDLIST pidl);
}
