//+---------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (C) Microsoft Corporation, 1997.
//
//  File:       H O S T P . I D L
//
//  Contents:   Private objects for the UPnP Device Host
//
//  Notes:
//
//  Author:     danielwe   7 Aug 2000
//
//----------------------------------------------------------------------------


cpp_quote("//+-------------------------------------------------------------------------")
cpp_quote("//")
cpp_quote("//  Microsoft Windows")
cpp_quote("//  Copyright (C) Microsoft Corporation, 1992-2000.")
cpp_quote("//")
cpp_quote("//--------------------------------------------------------------------------")

cpp_quote("#if ( _MSC_VER >= 800 )")
cpp_quote("#pragma warning(disable:4201)")
cpp_quote("#endif")

#ifndef DO_NO_IMPORTS
import "ocidl.idl";
#endif

// We want to be a proxy/stub DLL for all of the interfaces in
// the following IDL files.  Therefore we #include them instead of importing
// them.
//
//#define DO_NO_IMPORTS
import "upnphost.idl";

// Reserved GUIDS for our use
//
// 6d8ff8d0-730d-11d4-bf42-00b0d0118b56
// 6d8ff8d1-730d-11d4-bf42-00b0d0118b56   IID_IUPnPEventingManager
// 6d8ff8d2-730d-11d4-bf42-00b0d0118b56   CLSID_UPnPEventingManager
// 6d8ff8d3-730d-11d4-bf42-00b0d0118b56   IID_IUPnPContainer
// 6d8ff8d4-730d-11d4-bf42-00b0d0118b56   IID_IUPnPContainerManager
// 6d8ff8d5-730d-11d4-bf42-00b0d0118b56   IID_IUPnPDynamicContentProvider
// 6d8ff8d6-730d-11d4-bf42-00b0d0118b56   IID_IUPnPDynamicContentSource
// 6d8ff8d7-730d-11d4-bf42-00b0d0118b56   IID_IUPnPDescriptionManager
// 6d8ff8d8-730d-11d4-bf42-00b0d0118b56   IID_IUPnPAutomationProxy
// 6d8ff8d9-730d-11d4-bf42-00b0d0118b56   IID_IUPnPDevicePersistenceManager
// 6d8ff8da-730d-11d4-bf42-00b0d0118b56   IID_IUPnPRegistrarLookup
// 6d8ff8db-730d-11d4-bf42-00b0d0118b56   IID_IUPnPRegistrarPrivate
// 6d8ff8dc-730d-11d4-bf42-00b0d0118b56   CLSID_UPnPDynamicContentSource
// 6d8ff8dd-730d-11d4-bf42-00b0d0118b56   CLSID_UPnPDescriptionManager
// 6d8ff8de-730d-11d4-bf42-00b0d0118b56   IID_IUPnPRegistrarICSSupport
// 6d8ff8df-730d-11d4-bf42-00b0d0118b56   CLSID_UPnPDevicePersistenceManager
// 6d8ff8e0-730d-11d4-bf42-00b0d0118b56   CLSID_UPnPContainer
// 6d8ff8e1-730d-11d4-bf42-00b0d0118b56   CLSID_UPnPContainerManager
// 6d8ff8e2-730d-11d4-bf42-00b0d0118b56   CLSID_UPnPEventingManagerDiag (obsoleted)
// 6d8ff8e4-730d-11d4-bf42-00b0d0118b56   IID_IUPnPValidationManager
// 6d8ff8e5-730d-11d4-bf42-00b0d0118b56   CLSID_UPnPValidationManager
// 6d8ff8e6-730d-11d4-bf42-00b0d0118b56
// 6d8ff8e7-730d-11d4-bf42-00b0d0118b56
// 6d8ff8e8-730d-11d4-bf42-00b0d0118b56
// 6d8ff8e9-730d-11d4-bf42-00b0d0118b56
// ...
// 6d8ffcb0-730d-11d4-bf42-00b0d0118b56
// 6d8ffcb1-730d-11d4-bf42-00b0d0118b56

cpp_quote("EXTERN_C const CLSID CLSID_UPnPEventingManager;")
cpp_quote("EXTERN_C const CLSID CLSID_UPnPAutomationProxy;")
cpp_quote("EXTERN_C const CLSID CLSID_UPnPDynamicContentSource;")
cpp_quote("EXTERN_C const CLSID CLSID_UPnPDescriptionManager;")
cpp_quote("EXTERN_C const CLSID CLSID_UPnPRegistrar;")
cpp_quote("EXTERN_C const CLSID CLSID_UPnPDevicePersistenceManager;")
cpp_quote("EXTERN_C const CLSID CLSID_UPnPContainer;")
cpp_quote("EXTERN_C const CLSID CLSID_UPnPContainerManager;")
cpp_quote("EXTERN_C const CLSID CLSID_UPnPValidationManager;")

////////////////////////////////////
// Error definitions
cpp_quote("#define UPNP_E_INVALID_CONTENT_TYPE        MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0xA200)")
cpp_quote("#define UPNP_E_MISSING_SOAP_ACTION         MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0xA201)")
cpp_quote("#define UPNP_E_MISSING_CONTENT_LENGTH      MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0xA202)")
cpp_quote("#define UPNP_E_METHOD_NOT_IMPLEMENTED      MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0xA203)")
cpp_quote("#define UPNP_E_METHOD_NOT_ALLOWED          MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0xA204)")
cpp_quote("#define UPNP_E_BAD_REQUEST                 MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0xA205)")

////////////////////////////////////////
// Interface forward declarations

interface IUPnPEventingManager;
interface IUPnPContainer;
interface IUPnPContainerManager;
interface IUPnPDynamicContentProvider;
interface IUPnPDynamicContentSource;
interface IUPnPDescriptionManager;
interface IUPnPDevicePersistenceManager;
interface IUPnPRegistrarLookup;
interface IUPnPRegistrarPrivate;
interface IUPnPAutomationProxy;
interface IUPnPServiceDescriptionInfo;
interface IUPnPRegistrarICSSupport;

////////////////////////////////////////
// Interface definitions

[
    uuid(6d8ff8d1-730d-11d4-bf42-00b0d0118b56),
    pointer_default(unique)
]
interface IUPnPEventingManager : IUnknown
{
    [helpstring("method Initialize")]
    HRESULT Initialize(
        [in] LPCWSTR                    szUdn,
        [in] LPCWSTR                    szSid,
        [in] IUPnPAutomationProxy *     puap,
        [in] IUnknown *                 punkSvc,
        [in] BOOL                       bRunning);

    [helpstring("method AddSubscriber")]
    HRESULT AddSubscriber(
        [in] DWORD                      cszUrl,
        [in, size_is(cszUrl)] LPCWSTR *  rgszCallbackUrl,
        [in] DWORD                      dwIpAddr,
        [in, out] DWORD *               pcsecTimeout,
        [out] LPWSTR *                  pszSid);

    [helpstring("method RenewSubscriber")]
    HRESULT RenewSubscriber(
        [in, out] DWORD *        pcsecTimeout,
        [in] LPWSTR              szSid);

    [helpstring("method RemoveSubscriber")]
    HRESULT RemoveSubscriber(
        [in] LPWSTR              szSid);

    [helpstring("method Shutdown")]
    HRESULT Shutdown();
}

[
    uuid(6d8ff8d3-730d-11d4-bf42-00b0d0118b56),
    pointer_default(unique)
]
interface IUPnPContainer : IUnknown
{
    HRESULT CreateInstance(
        [in] REFCLSID clsid,
        [in] REFIID riid,
        [out, iid_is(riid)] void ** ppv);
    HRESULT Shutdown();
    HRESULT SetParent(
        [in] DWORD pid);
}

[
    uuid(6d8ff8d4-730d-11d4-bf42-00b0d0118b56),
    pointer_default(unique)
]
interface IUPnPContainerManager : IUnknown
{
    HRESULT ReferenceContainer(
        [in, string] const wchar_t * szContainer);
    HRESULT UnreferenceContainer(
        [in, string] const wchar_t * szContainer);
    HRESULT CreateInstance(
        [in, string] const wchar_t * szContainer,
        [in] REFCLSID clsid,
        [in] REFIID riid,
        [out, iid_is(riid)] void ** ppv);
    HRESULT CreateInstanceWithProgId(
        [in, string] const wchar_t * szContainer,
        [in, string] const wchar_t * szProgId,
        [in] REFIID riid,
        [out, iid_is(riid)] void ** ppv);
    HRESULT Shutdown();
}

[
    uuid(6d8ff8d5-730d-11d4-bf42-00b0d0118b56),
    pointer_default(unique)
]
interface IUPnPDynamicContentProvider : IUnknown
{
    HRESULT GetContent(
        [in] REFGUID guidContent,
        [out] long * pnHeaderCount,
        [out, string, size_is(,*pnHeaderCount,)] wchar_t *** parszHeaders,
        [out] long * pnBytes,
        [out, size_is(,*pnBytes)] byte ** parBytes);
}

[
    uuid(6d8ff8d6-730d-11d4-bf42-00b0d0118b56),
    pointer_default(unique)
]
interface IUPnPDynamicContentSource : IUnknown
{
    HRESULT GetContent(
        [in] REFGUID guidContent,
        [out] long * pnHeaderCount,
        [out, string, size_is(,*pnHeaderCount,)] wchar_t *** parszHeaders,
        [out] long * pnBytes,
        [out, size_is(,*pnBytes)] byte ** parBytes);
    HRESULT RegisterProvider(
        [in] IUPnPDynamicContentProvider * pProvider);
    HRESULT UnregisterProvider(
        [in] IUPnPDynamicContentProvider * pProvider);
}

[
    uuid(6d8ff8d7-730d-11d4-bf42-00b0d0118b56),
    pointer_default(unique)
]
interface IUPnPDescriptionManager : IUnknown
{
    HRESULT ProcessDescriptionTemplate(
        [in] BSTR bstrTemplate,
        [in, string] const wchar_t * szResourcePath,
        [in, out] GUID * pguidPhysicalDeviceIdentifier,
        [in] BOOL bPersist,
        [in] BOOL bReregister);
    HRESULT PublishDescription(
        [in] REFGUID guidPhysicalDeviceIdentifier,
        [in] long nLifeTime);
    HRESULT LoadDescription(
        [in] REFGUID guidPhysicalDeviceIdentifier);
    HRESULT RemoveDescription(
        [in] REFGUID guidPhysicalDeviceIdentifier,
        [in] BOOL bPermanent);
    HRESULT GetDescriptionText(
        [in] REFGUID guidPhysicalDeviceIdentifier,
        [out] BSTR * pbstrDescriptionDocument);
    HRESULT GetUDNs(
        [in] REFGUID guidPhysicalDeviceIdentifier,
        [out] long * pnUDNCount,
        [out, size_is(,*pnUDNCount,), string]
            wchar_t *** parszUDNs);
    HRESULT GetUniqueDeviceName(
        [in] REFGUID guidPhysicalDeviceIdentifier,
        [in, string] const wchar_t * szTemplateUDN,
        [out, string] wchar_t ** pszUDN);
    HRESULT GetSCPDText(
        [in] REFGUID guidPhysicalDeviceIdentifier,
        [in, string] const wchar_t * szUDN,
        [in, string] const wchar_t * szServiceId,
        [out, string] wchar_t ** pszSCPDText,
        [out, string] wchar_t ** pszServiceType);
}

[
    uuid(6d8ff8d9-730d-11d4-bf42-00b0d0118b56),
    pointer_default(unique)
]
interface IUPnPDevicePersistenceManager : IUnknown
{
    HRESULT SavePhyisicalDevice(
        [in] REFGUID guidPhysicalDeviceIdentifier,
        [in, string] const wchar_t * szProgIdDeviceControlClass,
        [in, string] const wchar_t * szInitString,
        [in, string] const wchar_t * szContainerId,
        [in, string] const wchar_t * szResourcePath,
        [in] long nLifeTime);
    HRESULT LookupPhysicalDevice(
        [in] REFGUID guidPhysicalDeviceIdentifier,
        [out, string] wchar_t ** pszProgIdDeviceControlClass,
        [out, string] wchar_t ** pszInitString,
        [out, string] wchar_t ** pszContainerId,
        [out, string] wchar_t ** pszResourcePath,
        [out] long * pnLifeTime);
    HRESULT RemovePhysicalDevice(
        [in] REFGUID guidPhysicalDeviceIdentifier);
    HRESULT GetPhysicalDevices(
        [out] long * pnDevices,
        [out, size_is(,*pnDevices)]
            GUID ** parguidPhysicalDeviceIdentifiers);
    HRESULT SaveDeviceProvider(
        [in, string] const wchar_t * szProviderName,
        [in, string] const wchar_t * szProgIdProviderClass,
        [in, string] const wchar_t * szInitString,
        [in, string] const wchar_t * szContainerId);
    HRESULT LookupDeviceProvider(
        [in, string] const wchar_t * szProviderName,
        [out, string] wchar_t ** pszProgIdProviderClass,
        [out, string] wchar_t ** pszInitString,
        [out, string] wchar_t ** pszContainerId);
    HRESULT RemoveDeviceProvider(
        [in, string] const wchar_t * szProviderName);
    HRESULT GetDeviceProviders(
        [out] long * pnProviders,
        [out, string, size_is(,*pnProviders,)]
            wchar_t *** parszProviderNames);
}

[
    uuid(6d8ff8da-730d-11d4-bf42-00b0d0118b56),
    pointer_default(unique)
]
interface IUPnPRegistrarLookup : IUnknown
{
    HRESULT GetEventingManager(
        [in, string] const wchar_t * szUDN,
        [in, string] const wchar_t * szServiceId,
        [out] IUPnPEventingManager ** ppEventingManager);
    HRESULT GetAutomationProxy(
        [in, string] const wchar_t * szUDN,
        [in, string] const wchar_t * szServiceId,
        [out] IUPnPAutomationProxy ** ppAutomationProxy);
}

[
    uuid(6d8ff8db-730d-11d4-bf42-00b0d0118b56),
    pointer_default(unique)
]
interface IUPnPRegistrarPrivate : IUnknown
{
    HRESULT Initialize();
    HRESULT Shutdown();
    HRESULT GetSCPDText(
        [in] REFGUID guidPhysicalDeviceIdentifier,
        [in, string] const wchar_t * szUDN,
        [in, string] const wchar_t * szServiceId,
        [out, string] wchar_t ** pszSCPDText,
        [out, string] wchar_t ** pszServerType);
    HRESULT GetDescriptionText(
        [in] REFGUID guidPhysicalDeviceIdentifier,
        [out] BSTR * pbstrDescriptionDocument);
}


typedef struct tagUPNP_CONTROL_REQUEST
{
   BSTR     bstrActionName;
   DWORD        cInputArgs;
   [size_is(cInputArgs)] VARIANT    * rgvarInputArgs;
} UPNP_CONTROL_REQUEST;


typedef [switch_type(BOOL)] union tagUPNP_CONTROL_RESPONSE_DATA
{
   [case(TRUE)] struct
   {
      DWORD     cOutputArgs;
      [size_is(cOutputArgs)] VARIANT    * rgvarOutputArgs;
   } Success;

   [case(FALSE)] struct
   {
      BSTR      bstrFaultCode;
      BSTR      bstrFaultString;
      BSTR      bstrUPnPErrorCode;
      BSTR      bstrUPnPErrorString;
   } Fault;

   [default];
} UPNP_CONTROL_RESPONSE_DATA;

typedef struct tagUPNP_CONTROL_RESPONSE
{
   BSTR      bstrActionName;
   BOOL    fSucceeded;
   [switch_is(fSucceeded)] UPNP_CONTROL_RESPONSE_DATA ucrData;
} UPNP_CONTROL_RESPONSE;


[
   uuid(c4ab1fea-d0dd-44fd-96cb-41b41b5f718a),
    helpstring("IUPnPAutomationProxy Interface"),
    pointer_default(unique)
]
interface IUPnPAutomationProxy : IUnknown
{
   [helpstring("method Initialize")]
   HRESULT Initialize(
      [in] IUnknown    * punkSvcObject,
      [in] LPWSTR      pszSvcDescription,
      [in] LPWSTR      pszSvcType,
      [in] BOOL        bRunning);

   [helpstring("method GetDispIdsOfEventedVariables")]
      HRESULT GetDispIdsOfEventedVariables(
         [out]                             DWORD   * pcEventedVars,
         [out, size_is(, *pcEventedVars)]  DISPID  ** prgdispidEventedVars);

    [helpstring("method QueryStateVariablesByDispId")]
    HRESULT QueryStateVariablesByDispIds(
        [in]                            DWORD    cDispIds,
        [in, size_is(cDispIds)]         DISPID   * rgDispIds,
        [out]                           DWORD    * pcVariables,
        [out, size_is(, *pcVariables)]  LPWSTR   ** prgszVariableNames,
        [out, size_is(, *pcVariables)]  VARIANT  ** prgvarVariableValues,
        [out, size_is(, *pcVariables)]  LPWSTR   ** prgszVariableDataTypes);

    [helpstring("method ExecuteRequest")]
    HRESULT ExecuteRequest(
        [in] UPNP_CONTROL_REQUEST * pucreq,
        [out] UPNP_CONTROL_RESPONSE * pucresp);

    [helpstring("method GetServiceType")]
    HRESULT GetServiceType(
       [out] LPWSTR * pszSvcType);
};


[
   uuid(f5b63656-069d-4e80-b4fd-9e0db16604d8),
    helpstring("IUPnPServiceDescriptionInfo Interface"),
    pointer_default(unique)
]
interface IUPnPServiceDescriptionInfo : IUnknown
{
    [helpstring("method GetVariableType")]
    HRESULT GetVariableType(
        [in]  LPWSTR    pszVarName,
     [out] BSTR      * pbstrType);

    [helpstring("method GetInputArgumentNamesAndTypes")]
    HRESULT GetInputArgumentNamesAndTypes(
        [in]                              LPWSTR  pszActionName,
        [out]                             DWORD   * pcInArguments,
        [out, size_is(, *pcInArguments)]  BSTR    ** prgbstrNames,
        [out, size_is(, *pcInArguments)]  BSTR    ** prgbstrTypes);


    [helpstring("method GetOutputArgumentNamesAndTypes")]
    HRESULT GetOutputArgumentNamesAndTypes(
        [in]                              LPWSTR  pszActionName,
        [out]                             DWORD   * pcOutArguments,
        [out, size_is(, *pcOutArguments)] BSTR    ** prgbstrNames,
        [out, size_is(, *pcOutArguments)] BSTR    ** prgbstrTypes);
};


//
// Debug only
//

typedef struct _UDH_SUBSCRIBER_INFO {
    [string] LPWSTR szDestUrl;
    FILETIME        ftTimeout;
    DWORD           csecTimeout;
    DWORD           iSeq;
    [string] LPWSTR szSid;
} UDH_SUBSCRIBER_INFO;

typedef struct _UDH_EVTSRC_INFO {
    [string] LPWSTR szEsid;
    DWORD cSubs;
    [size_is(cSubs)] UDH_SUBSCRIBER_INFO *rgSubs;
} UDH_EVTSRC_INFO;

[
    uuid(6d8ff8e4-730d-11d4-bf42-00b0d0118b56),
    pointer_default(unique)
]
interface IUPnPValidationManager : IUnknown
{
    HRESULT ValidateDescriptionDocument(
        [in] BSTR bstrTemplate,
        [out, string] wchar_t ** pszErrorString);
    HRESULT ValidateServiceDescription(
        [in, string] const wchar_t * szFullPath,
        [out, string] wchar_t ** pszErrorString);
    HRESULT ValidateDescriptionDocumentAndReferences(
        [in] BSTR bstrTemplate,
        [in, string] const wchar_t * szResourcePath,
        [out, string] wchar_t ** pszErrorString);
}

[
    uuid(6d8ff8de-730d-11d4-bf42-00b0d0118b56),
    pointer_default(unique)
]
interface IUPnPRegistrarICSSupport : IUnknown
{
    HRESULT SetICSInterfaces([in] long nCount, [in, size_is(nCount)] GUID * arPrivateInterfaceGuids);
    HRESULT SetICSOff();
}

///////////////////////////////////////////
// coclasses

[
    uuid(6d8ff8d2-730d-11d4-bf42-00b0d0118b56),
    helpstring("UPnPEventingManagerClass")
]
coclass UPnPEventingManager
{
    [default] interface IUPnPEventingManager;
    interface IUPnPEventSink;
};


[
    uuid(0fb40f0d-1021-4022-8da0-aab0588dfc8b),
    helpstring("UPnPAutomationProxy Class")
]
coclass UPnPAutomationProxy
{
    [default] interface IUPnPAutomationProxy;
    interface IUPnPServiceDescriptionInfo;
};

[
    uuid(6d8ff8dc-730d-11d4-bf42-00b0d0118b56)
]
coclass UPnPDynamicContentSource
{
    [default] interface IUnknown;
};

[
    uuid(6d8ff8dd-730d-11d4-bf42-00b0d0118b56)
]
coclass UPnPDescriptionManager
{
    [default] interface IUnknown;
};

[
    uuid(6d8ff8df-730d-11d4-bf42-00b0d0118b56)
]
coclass UPnPDevicePersistenceManager
{
    [default] interface IUnknown;
};

[
    uuid(6d8ff8e0-730d-11d4-bf42-00b0d0118b56)
]
coclass UPnPContainer
{
    [default] interface IUnknown;
}

[
    uuid(6d8ff8e1-730d-11d4-bf42-00b0d0118b56)
]
coclass UPnPContainerManager
{
    [default] interface IUnknown;
}

[
    uuid(6d8ff8e5-730d-11d4-bf42-00b0d0118b56)
]
coclass UPnPValidationManager
{
    [default] interface IUnknown;
}