//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (C) Microsoft Corporation, 1992 - 1996.
//
//  File:   odeath.idl
//
//+-------------------------------------------------------------------------

#ifndef DO_NO_IMPORTS
    import "unknwn.idl";
    import "obase.idl";
    import "wtypes.idl";
    import "objidl.idl";
    import "objidl.idl";
#endif

//+-------------------------------------------------------------------------
//
// Struct:    XAptCallback
//
// Synopsys:  An object context's DoCallback method must switch to its
//            apartment if it resides in a different apartment than the
//            caller.  The context calls its apartment's remote unknown
//            to accomplish the switch.  This structure is a parameter
//            block the object context passes to the remote unknown's
//            DoCallback method.
//
//--------------------------------------------------------------------------

typedef __int64 PTRMEM;

typedef struct tagXAptCallback
{
    PTRMEM    pfnCallback;
    PTRMEM    pParam;
    PTRMEM    pServerCtx;
    PTRMEM    pUnk;
    GUID      iid;
    int       iMethod;
} XAptCallback;


//+-------------------------------------------------------------------------
//
//  Interface:  IRemUnknownN
//
//  Synopsys:   This is a local interface used to convert strong references
//              to weak references and vice versa. It is needed for the
//              container/link/embedding aspects of OLE.
//
//              It inherits from the highest numbered IRemUnknown version
//              that is known for the current machine.
//
//  Notes:      Weak references are not permitted remotely.
//
//+-------------------------------------------------------------------------
[
    object,
    uuid(0000013C-0000-0000-C000-000000000046)
]

interface IRemUnknownN : IRemUnknown2
{
#ifndef DO_NO_IMPORTS
    import "remunk.idl";
#endif
    const unsigned long IRUF_CONVERTTOWEAK          = 0x01;// make refs weak
    const unsigned long IRUF_CONVERTTOSTRONG        = 0x02;// make refs strong
    const unsigned long IRUF_DISCONNECTIFLASTSTRONG = 0x04;// disconnect the
                                                // object if last strong ref
    HRESULT RemChangeRef
    (
        [in] unsigned long  flags,
        [in] unsigned short cInterfaceRefs,
        [in, size_is(cInterfaceRefs)] REMINTERFACEREF InterfaceRefs[]
    );

    HRESULT DoCallback
    (
        [in] XAptCallback  *pCallbackData
    );
}

//
// Enumeration to describe status of trying to run an oid down
//
typedef enum 
{
    ORS_DONTRUNDOWN      = 0x0,  // rundown refused
    ORS_OK_TO_RUNDOWN    = 0x1,  // rundown accepted
    ORS_OID_PINNED       = 0x2   // rundown refused because stub is locked
} OID_RUNDOWN_STATUS;

//+-------------------------------------------------------------------------
//
//  Interface:  IRundown
//
//  Synopsys:   This is the local OID rundown interface. The object exporter
//              calls it to notify the server which OIDs are no longer being
//              pinged.
//
//  Notes:      This inherits from IRemUnknownN so that we can use the same
//              IPID for all three interfaces. This is strictly a local
//              implementation decision and does not affect remote protocol.
//
//+-------------------------------------------------------------------------
[
    uuid(00000134-0000-0000-C000-000000000046)
#ifndef RAW
  , object
#endif
 ]

interface IRundown
#ifndef RAW
          : IRemUnknownN
#endif

{
#ifndef DO_NO_IMPORTS
    import "iface.idl";
    import "obase.idl";
    import "remunk.idl";
#endif
    #include "comhndl.h"

    COM_DEFINES(IOSCM)

#ifdef RAW
    // Define the functions in IRemUnknown2
    HRESULT DummyRemQuery( handle_t handle );
    HRESULT DummyRemAddRef( handle_t handle );
    HRESULT DummyRemRelease( handle_t handle );
    HRESULT DummyRemChangeRef( handle_t handle );
    HRESULT DummyRemQueryInterface2( handle_t handle);
    HRESULT DummyDoCallBack( handle_t handle);

    error_status_t RawRundownOid
#else
    HRESULT RundownOid
#endif
    (
        COM_HANDLE
        [in] ULONG     cOid,
        [in, size_is(cOid)] OID     aOid[],
        [out, size_is(cOid)] BYTE aRundownStatus[]  // see OID_RUNDOWN_STATUS above
    );
}
