/*
 * Copyright 2017 Owen Rudge 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 "wsdxmldom.h";
import "wsdtypes.h";

interface IWSDScopeMatchingRule;
interface IWSDiscoveryPublisherNotify;
interface IWSDiscoveryPublisher;
interface IWSDXMLContext;
interface IWSDiscoveryProvider;
interface IWSDiscoveryProviderNotify;
interface IWSDiscoveredService;

[
uuid(fcafe424-fef5-481a-bd9f-33ce0574256f),
object,
local,
restricted,
pointer_default(unique)
]
interface IWSDScopeMatchingRule : IUnknown
{
  HRESULT GetScopeRule([out] LPCWSTR *ppszScopeMatchingRule);
  HRESULT MatchScopes([in] LPCWSTR pszScope1, [in] LPCWSTR pszScope2, [out] BOOL *pfMatch);
}

[
uuid(73ee3ced-b6e6-4329-a546-3e8ad46563d2),
object,
local,
restricted,
pointer_default(unique)
]
interface IWSDiscoveryProviderNotify : IUnknown
{
  HRESULT Add([in] IWSDiscoveredService *service);
  HRESULT Remove([in] IWSDiscoveredService *service);
  HRESULT SearchFailed([in] HRESULT hr,[in, optional] LPCWSTR tag);
  HRESULT SearchComplete([in, optional] LPCWSTR tag);
}

[
uuid(4bad8a3b-b374-4420-9632-aac945b374aa),
object,
local,
restricted,
pointer_default(unique)
]
interface IWSDiscoveredService : IUnknown
{
  HRESULT GetEndpointReference([out] WSD_ENDPOINT_REFERENCE **endpoint_reference);
  HRESULT GetTypes([out] WSD_NAME_LIST **types_list);
  HRESULT GetScopes([out] WSD_URI_LIST **scopes_list);
  HRESULT GetXAddrs([out] WSD_URI_LIST **x_addrs_list);
  HRESULT GetMetadataVersion([out] ULONGLONG *metadata_version);
  HRESULT GetExtendedDiscoXML([out] WSDXML_ELEMENT **header_any,[out] WSDXML_ELEMENT **body_any);
  HRESULT GetProbeResolveTag([out] LPCWSTR *tag);
  HRESULT GetRemoteTransportAddress([out] LPCWSTR *remote_transport_address);
  HRESULT GetLocalTransportAddress([out] LPCWSTR *local_transport_address);
  HRESULT GetLocalInterfaceGUID([out] GUID *guid);
  HRESULT GetInstanceId([out] ULONGLONG *instance_id);
}

[
uuid (8ffc8e55-f0eb-480f-88b7-b435dd281d45),
object,
local,
restricted,
pointer_default(unique)
]
interface IWSDiscoveryProvider : IUnknown
{
  HRESULT SetAddressFamily([in] DWORD address_family);
  HRESULT Attach([in] IWSDiscoveryProviderNotify *sink);
  HRESULT Detach(void);
  HRESULT SearchById([in] LPCWSTR id,[in, optional] LPCWSTR tag);
  HRESULT SearchByAddress([in] LPCWSTR address,[in, optional] LPCWSTR tag);
  HRESULT SearchByType([in, optional] const WSD_NAME_LIST *types_list, \
          [in, optional] const WSD_URI_LIST *scopes_list,[in, optional] LPCWSTR match_by,[in, optional] LPCWSTR tag);
  HRESULT GetXMLContext([out] IWSDXMLContext **context);
}

[
uuid(e67651b0-337a-4b3c-9758-733388568251),
object,
local,
restricted,
pointer_default(unique)
]
interface IWSDiscoveryPublisherNotify : IUnknown
{
  HRESULT ProbeHandler([in] const WSD_SOAP_MESSAGE *pSoap, [in] IWSDMessageParameters *pMessageParameters);
  HRESULT ResolveHandler([in] const WSD_SOAP_MESSAGE *pSoap, [in] IWSDMessageParameters *pMessageParameters);
}

[
uuid(AE01E1A8-3ff9-4148-8116-057cc616fe13),
object,
local,
restricted,
pointer_default(unique)
]
interface IWSDiscoveryPublisher : IUnknown
{
    HRESULT SetAddressFamily([in] DWORD dwAddressFamily);
    HRESULT RegisterNotificationSink([in] IWSDiscoveryPublisherNotify *pSink);
    HRESULT UnRegisterNotificationSink([in] IWSDiscoveryPublisherNotify *pSink);

    HRESULT Publish([in] LPCWSTR pszId, [in] ULONGLONG ullMetadataVersion, [in] ULONGLONG ullInstanceId, [in] ULONGLONG ullMessageNumber,
        [in, optional] LPCWSTR pszSessionId, [in, optional] const WSD_NAME_LIST *pTypesList, [in, optional] const WSD_URI_LIST *pScopesList,
        [in, optional] const WSD_URI_LIST *pXAddrsList);

    HRESULT UnPublish([in] LPCWSTR pszId, [in] ULONGLONG ullInstanceId, [in] ULONGLONG ullMessageNumber, [in, optional] LPCWSTR pszSessionId,
        [in, optional] const WSDXML_ELEMENT *pAny);

    HRESULT MatchProbe([in] const WSD_SOAP_MESSAGE *pProbeMessage, [in] IWSDMessageParameters *pMessageParameters, [in] LPCWSTR pszId,
        [in] ULONGLONG ullMetadataVersion, [in] ULONGLONG ullInstanceId, [in] ULONGLONG ullMessageNumber, [in, optional] LPCWSTR pszSessionId,
        [in, optional] const WSD_NAME_LIST *pTypesList, [in, optional] const WSD_URI_LIST *pScopesList, [in, optional] const WSD_URI_LIST *pXAddrsList);

    HRESULT MatchResolve([in] const WSD_SOAP_MESSAGE *pResolveMessage, [in] IWSDMessageParameters *pMessageParameters, [in] LPCWSTR pszId,
        [in] ULONGLONG ullMetadataVersion, [in] ULONGLONG ullInstanceId, [in] ULONGLONG ullMessageNumber, [in, optional] LPCWSTR pszSessionId,
        [in, optional] const WSD_NAME_LIST *pTypesList, [in, optional] const WSD_URI_LIST *pScopesList, [in, optional] const WSD_URI_LIST *pXAddrsList);

    HRESULT PublishEx([in] LPCWSTR pszId, [in] ULONGLONG ullMetadataVersion, [in] ULONGLONG ullInstanceId, [in] ULONGLONG ullMessageNumber,
        [in, optional] LPCWSTR pszSessionId, [in, optional] const WSD_NAME_LIST *pTypesList, [in, optional] const WSD_URI_LIST *pScopesList,
        [in, optional] const WSD_URI_LIST *pXAddrsList, [in, optional] const WSDXML_ELEMENT *pHeaderAny,
        [in, optional] const WSDXML_ELEMENT *pReferenceParameterAny, [in, optional] const WSDXML_ELEMENT *pPolicyAny,
        [in, optional] const WSDXML_ELEMENT *pEndpointReferenceAny, [in, optional] const WSDXML_ELEMENT *pAny);

    HRESULT MatchProbeEx([in] const WSD_SOAP_MESSAGE *pProbeMessage, [in] IWSDMessageParameters *pMessageParameters, [in] LPCWSTR pszId,
        [in] ULONGLONG ullMetadataVersion, [in] ULONGLONG ullInstanceId, [in] ULONGLONG ullMessageNumber, [in, optional] LPCWSTR pszSessionId,
        [in, optional] const WSD_NAME_LIST *pTypesList, [in, optional] const WSD_URI_LIST *pScopesList, [in, optional] const WSD_URI_LIST *pXAddrsList,
        [in, optional] const WSDXML_ELEMENT *pHeaderAny, [in, optional] const WSDXML_ELEMENT *pReferenceParameterAny,
        [in, optional] const WSDXML_ELEMENT *pPolicyAny, [in, optional] const WSDXML_ELEMENT *pEndpointReferenceAny,
        [in, optional] const WSDXML_ELEMENT *pAny);

    HRESULT MatchResolveEx([in] const WSD_SOAP_MESSAGE *pResolveMessage, [in] IWSDMessageParameters *pMessageParameters, [in] LPCWSTR pszId,
        [in] ULONGLONG ullMetadataVersion, [in] ULONGLONG ullInstanceId, [in] ULONGLONG ullMessageNumber, [in, optional] LPCWSTR pszSessionId,
        [in, optional] const WSD_NAME_LIST *pTypesList, [in, optional] const WSD_URI_LIST *pScopesList, [in, optional] const WSD_URI_LIST *pXAddrsList,
        [in, optional] const WSDXML_ELEMENT *pHeaderAny, [in, optional] const WSDXML_ELEMENT *pReferenceParameterAny,
        [in, optional] const WSDXML_ELEMENT *pPolicyAny, [in, optional] const WSDXML_ELEMENT *pEndpointReferenceAny,
        [in, optional] const WSDXML_ELEMENT *pAny);

    HRESULT RegisterScopeMatchingRule([in] IWSDScopeMatchingRule *pScopeMatchingRule);
    HRESULT UnRegisterScopeMatchingRule([in] IWSDScopeMatchingRule *pScopeMatchingRule);
    HRESULT GetXMLContext([out] IWSDXMLContext **ppContext);
}

cpp_quote("HRESULT WINAPI WSDCreateDiscoveryProvider(IWSDXMLContext *context, IWSDiscoveryProvider **provider);")
cpp_quote("HRESULT WINAPI WSDCreateDiscoveryPublisher(IWSDXMLContext* pContext, IWSDiscoveryPublisher **ppPublisher);")
