////////////////////////////////////////////////////////////
//
// Copyright (c) Microsoft Corporation.
//
// SYNOPSIS
//
//    IDL source for common interfaces.
//
////////////////////////////////////////////////////////////

#ifndef NAPCOMMON_IDL
#define NAPCOMMON_IDL

import "NapTypes.idl";
import "unknwn.idl";


// NAP plug-in components (such as SHAs and SHVs) must 
// implement this interface so that the NAP system can 
// retrieve static administrative-type information 
// (eg. friendly name, localized strings, etc.)
// 
[object, 
uuid(B475F925-E3F7-414c-8C72-1CEE64B9D8F6), 
pointer_default(unique)]
interface INapComponentInfo : IUnknown
{
   // Used to get the friendly name, company name,
   // version info and icon of health clients.
   //
   HRESULT
   GetFriendlyName([out] MessageId* friendlyName) const;
   HRESULT
   GetDescription([out] MessageId* description) const;
   HRESULT
   GetVendorName([out] MessageId* vendorName) const;
   HRESULT
   GetVersion([out] MessageId* version) const;

   // The icon should be localized according to the thread
   // lang-id.
   HRESULT
   GetIcon(
      [out] CountedString** dllFilePath,
      [out] UINT32* iconResourceId
      ) const;

   // Used to convert HRESULT to message id, which can then
   // be used to retrieve a localized string.
   // 
   HRESULT
   ConvertErrorCodeToMessageId(
      [in] HRESULT errorCode,
      [out] MessageId* msgId
      ) const;

   // Used to get localized strings. Strings should be
   // localized to the thread's language-id.
   // 
   HRESULT
   GetLocalizedString(
      [in] MessageId msgId,
      [out] CountedString** string
      ) const;
};


// Currently, implemented by the SHVs only.
//                      
[object,
uuid(a9e0af1a-3713-478e-ae03-8edd272d21fa),
pointer_default(unique)]
interface INapComponentConfig : IUnknown
{
   // Used to determine if the component supports
   // custom UI.
   //
   HRESULT
   IsUISupported([out] BOOL* isSupported) const;

   // Used to launch the component specific UI
   // Note:- The call should block until the UI exits
   //        and any updated config is persisted.
   // 
   HRESULT
   InvokeUI([in, unique] HWND hwndParent) const;
 
   // Used to extract the configuration for
   // migration purposes
   // Any versioning information should be part of the 
   // byte blob
   //
   HRESULT
   GetConfig(
      [out] UINT16* bCount, 
      [out, size_is(, *bCount)] BYTE** data
      ) const;

   // Used to set the configuration
   // 
   HRESULT
   SetConfig(
      [in] UINT16 bCount, 
      [in, size_is(bCount)] BYTE* data
      );
};

// Currently implemented by SHVs only.
// Used to manage remote configuration of SHVs
// 
[object,
uuid(47cbdb9e-1972-4f5e-bd3c-5eb6230614b5),
pointer_default(unique)]
interface INapComponentConfig2 : INapComponentConfig
{

   // If neither of InvokeUIForMachine and InvokeUIFromConfigBlob is
   // implemented, remote configuration of the SHV is not possible
   //
   HRESULT 
   IsRemoteConfigSupported(
      [out] BOOL* isSupported, 
      [out] UINT8* remoteConfigType
      );

   // Implemented by SHVs that want to manage the remote configuration
   // directly on the machine specified
   //
   HRESULT 
   InvokeUIForMachine(
      [in, unique] HWND hwndParent,
      [in, unique] CountedString* machineName
      );

   // Implemented by SHVs that want to load the configuration on the
   // remote/local machine in memory and display UI that can manipulate 
   // the data in memory. The outData parameter is used to return the 
   // modified data, and the flag fConfigChanged indicates if any 
   // changes were made in the configuration.
   // The data passed in is the exported configuration on the remote/local 
   // machine and the data passed out will be imported on the remote/local
   // machine.
   // Note that if used for a local machine, this function can be used for 
   // Per Policy SHV Configuration. It provides a way to invoke SHV UI
   // and edit an existing SHV configuration.
   //
   HRESULT 
   InvokeUIFromConfigBlob(
      [in, unique] HWND hwndParent,
      [in] UINT16 inbCount,
      [in, size_is(inbCount)] BYTE* inData, 
      [out] UINT16* outbCount, 
      [out, size_is(, *outbCount)] BYTE** outdata, 
      [out] BOOL *fConfigChanged
      );
};

// Currently implemented by SHVs only.
// Used to support multiple configuration
// 
[object,
uuid(9C4A8101-8CFE-4332-876E-C4A49D1D3F77),
pointer_default(unique)]
interface INapComponentConfig3 : INapComponentConfig2
{
	// NewConfig provides the way to create configuration for specific ConfigID.
	// ConfigID is assigned by NPS Config and it's unique within the SHV. 
	// When this function is called, SHV must allocate a new configuration and 
	// populate it with a copy of the global configuration data.
	// GetConfig, InvokeUIFromConfigBlob, and SetConfig will be used after
	// when modifications are needed to the configuration
	// If the ConfigID is 0 (a reserved value for global config), then
       // E_INVALIDARG should be returned.
       // If the ConfigID already exists, that means the list of IDs known to NPS 
	// is different from what SHV has. That would be a bug. In that case, 
	// NAP_E_SHV_CONFIG_EXISTED should be returned.
	HRESULT
	NewConfig(UINT32 configID);

	// DeleteConfig provides the way to delete configuration for specific ConfigID.  
	// The ConfigID  can be reused for other configurations after it has been deleted.
	// If the ConfigID is 0 (a reserved value for global config), then
       // E_INVALIDARG should be returned - global config must not be deleted.
	// If ConfigID is not found, SHV should return NAP_E_SHV_CONFIG_NOT_FOUND.
	HRESULT
	DeleteConfig(UINT32 configID);

	// DeleteAllConfig provides the way to reset SHV store to its original state after 
	// setup. All configurations except for the default configuration must be deleted.
	HRESULT
	DeleteAllConfig();

	// GetConfig provides the way to obtain configuration for specific ConfigID from 
	// SHV.  If 0 is used, SHV should return the global configuration. If ConfigID is
	// not found, SHV should return NAP_E_SHV_CONFIG_NOT_FOUND
	HRESULT
	GetConfigFromID(
		[in]  UINT32 configID, 
		[out] UINT16* count,
		[out, size_is(,*count)]BYTE** outdata
		);
		
	// SetConfig provides the way to set configuration for specific ConfigID. 
	// ConfigID is assigned by NPS Config and it's unique within the SHV. If ConfigID 
	// is not found, SHV should return NAP_E_SHV_CONFIG_NOT_FOUND 	
	HRESULT
	SetConfigToID(
		[in] UINT32 configID, 
		[in] UINT16 count,
		[in, size_is(count)]BYTE* data
		);
};
#endif // NAPCOMMON_IDL

