//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (c) Microsoft Corporation. All rights reserved.
//
//  Component: WSDAPI - Microsoft Web Services for Devices API
// 
//  File: wsdhost.idl
//
//  Abstract: Host/Device interface definitions and typedefs for WSDAPI
//
//--------------------------------------------------------------------------

import "oaidl.idl";
import "ocidl.idl";
import "wsdxmldom.h";
import "wsdtypes.h";

//
// Dependencies
//
interface IWSDAddress;
interface IWSDXMLContext;

//
// Forward Declarations
//
interface IWSDDeviceHost;
interface IWSDDeviceHostNotify;
interface IWSDServiceMessaging;

cpp_quote("HRESULT WINAPI")
cpp_quote("WSDCreateDeviceHost(")
cpp_quote("    __in LPCWSTR pszLocalId,")
cpp_quote("    IWSDXMLContext* pContext,")
cpp_quote("    __deref_out IWSDDeviceHost** ppDeviceHost);")

cpp_quote("HRESULT WINAPI")
cpp_quote("WSDCreateDeviceHostAdvanced(")
cpp_quote("    __in LPCWSTR pszLocalId,")
cpp_quote("    IWSDXMLContext* pContext,")
cpp_quote("    __in_ecount_opt(dwHostAddressCount) IWSDAddress** ppHostAddresses,")
cpp_quote("    DWORD dwHostAddressCount,")
cpp_quote("    __deref_out IWSDDeviceHost** ppDeviceHost);")

cpp_quote("#if (WINVER >= _WIN32_WINNT_WIN7)")
cpp_quote("HRESULT WINAPI")
cpp_quote("WSDCreateDeviceHost2(")
cpp_quote("    __in LPCWSTR pszLocalId,")
cpp_quote("    IWSDXMLContext* pContext,")
cpp_quote("    __in_ecount_opt(dwConfigParamCount) WSD_CONFIG_PARAM* pConfigParams,")
cpp_quote("    DWORD dwConfigParamCount,")
cpp_quote("    __deref_out IWSDDeviceHost** ppDeviceHost);")
cpp_quote("#endif")
    
//+-------------------------------------------------------------------------
//  IWSDDeviceHost Interface
//  Description: Host-side representation of devices
//--------------------------------------------------------------------------
[
    object,
    uuid(917fe891-3d13-4138-9809-934c8abeb12c),
    helpstring("IWSDDeviceHost Interface"),
    pointer_default(unique),
    restricted,
    local
]
interface IWSDDeviceHost : IUnknown
{
    HRESULT Init(
        [in, annotation("__in")] LPCWSTR pszLocalId,
        [in, optional] IWSDXMLContext* pContext,
        [in, optional, annotation("__in_ecount_opt(dwHostAddressCount)")] IWSDAddress** ppHostAddresses,
        [in, optional] DWORD dwHostAddressCount);

    HRESULT Start(
        [in] ULONGLONG ullInstanceId,
        [in] const WSD_URI_LIST* pScopeList,
        [in, optional] IWSDDeviceHostNotify* pNotificationSink);
    
    HRESULT Stop();

    HRESULT Terminate();

    HRESULT RegisterPortType(
        [in] const WSD_PORT_TYPE* pPortType);

    HRESULT SetMetadata(
        [in] const WSD_THIS_MODEL_METADATA* pThisModelMetadata,
        [in] const WSD_THIS_DEVICE_METADATA* pThisDeviceMetadata,
        [in, optional] const WSD_HOST_METADATA* pHostMetadata,
        [in, optional] const WSD_METADATA_SECTION_LIST* pCustomMetadata);

    HRESULT RegisterService(
        [in, annotation("__in")] LPCWSTR pszServiceId,
        [in] IUnknown* pService);
    
    HRESULT RetireService(
        [in, annotation("__in")] LPCWSTR pszServiceId);

    HRESULT AddDynamicService(
        [in, annotation("__in")] LPCWSTR pszServiceId,
        [in, optional, annotation("__in_opt")] LPCWSTR pszEndpointAddress,
        [in, optional] const WSD_PORT_TYPE* pPortType,
        [in, optional] const WSDXML_NAME* pPortName,
        [in, optional] const WSDXML_ELEMENT* pAny,
        [in, optional] IUnknown* pService);
    
    HRESULT RemoveDynamicService(
        [in, annotation("__in")] LPCWSTR pszServiceId);

    HRESULT SetServiceDiscoverable(
        [in, annotation("__in")] LPCWSTR pszServiceId,
        [in] BOOL fDiscoverable);

    HRESULT SignalEvent(
        [in, annotation("__in")] LPCWSTR pszServiceId,
        [in, annotation("__in_opt")] const void* pBody,
        [in] const WSD_OPERATION* pOperation);
};

//+-------------------------------------------------------------------------
//  IWSDDeviceHostNotify Interface
//  Description: Provides device-related notifications for devices
//--------------------------------------------------------------------------
[
    object,
    uuid(b5bee9f9-eeda-41fe-96f7-f45e14990fb0),
    helpstring("IWSDDeviceHostNotify Interface"),
    pointer_default(unique),
    restricted
]
interface IWSDDeviceHostNotify : IUnknown
{
midl_pragma warning(disable:2495)
    HRESULT GetService(
        [in, annotation("__in")] LPCWSTR pszServiceId,
        [out, annotation("__deref_out")] IUnknown** ppService);
midl_pragma warning(disable:2495)
};

//+-------------------------------------------------------------------------
//  IWSDServiceMessaging Interface
//  Description: Provides response channels for dispatched service messages.
//               This interface is used only by generated stubs.
//--------------------------------------------------------------------------
[
    object,
    uuid(94974cf4-0cab-460d-a3f6-7a0ad623c0e6),
    helpstring("IWSDServiceMessaging Interface"),
    pointer_default(unique),
    restricted,
    local
]
interface IWSDServiceMessaging : IUnknown
{
    HRESULT SendResponse(
        [in, annotation("__in_opt")] void* pBody,
        [in] WSD_OPERATION* pOperation,
        [in] IWSDMessageParameters* pMessageParameters);
    
    HRESULT FaultRequest(
        [in] WSD_SOAP_HEADER* pRequestHeader,
        [in] IWSDMessageParameters* pMessageParameters,
        [in,optional] WSD_SOAP_FAULT* pFault);
};

