//  Copyright (C) 1995-1999 Microsoft Corporation.  All rights reserved.
#ifndef _CATSRV_IDL_
#define _CATSRV_IDL_

//catsrv.idl Interfaces and CoClass for the Catalog Server (Marshaller)

import "catalog.idl";
import "oaidl.idl";
import "unknwn.idl";

// The structure for marshalling the query
// It is different from STQueryCell by the type of pData
typedef struct
{
	DWORD pData;
	DWORD eOperator;
	ULONG iColumn;
	DWORD dbType;
	ULONG cbSize;
}STQueryCellForMarshalling;



// The CatalogSession interface. This should be exactly the same as the one in MTS 2.0
[
	uuid(182c40fa-32e4-11d0-818b-00a0c9231c29),
	dual,
	helpstring("ICatalogSession"),
]
interface ICatalogSession : IDispatch
{
		[id(1)] HRESULT InitializeSession	
									(
										[in]	float	i_flVerLower
									,	[in]	float	i_flVerUpper
									,	[in]	long	i_lcid
									,	[out]	float*	o_pflVerSession
									);

		[id(2)] HRESULT GetServerInformation	
									(
										[out]	long*	o_peOSId,
										[out]	long*	o_peOSVer,
										[out]	long*	o_peOSHardware,
										[out]	long*	o_peRes1,
										[out]	long*	o_peRes2,
										[out]	long*	o_peRes3
									);
};

//ICatalogTableRead		Implemented by Catalog Servers
//Clients use this interface to request tables from the catalog server.
//Note: The session must first have been initialized via ICatalogSession
[
	object,
	uuid(0E3D6630-B46B-11d1-9D2D-006008B0E5CA),
	helpstring ("ICatalogTableRead1"),
	pointer_default(unique)	
]
interface ICatalogTableRead1 : IUnknown
{
//ReadTable: Clients call this method in order to request a table from the Catalog Server.
//The client is typically a client table running on the client's machine 

	[id(1)] HRESULT ReadTable (
			[in] REFGUID i_DID,									// database id
			[in] REFGUID i_TID,									// table id
			[in] DWORD i_fTable,								// table flags

			[in, size_is(i_cbQuery1), unique] char * i_pQuery1,	// the first array in which we marshall the query
			[in] ULONG i_cbQuery1,								// size of the previous array
			[in, size_is(i_cbQuery2), unique] char * i_pQuery2, // the second array in which we marshall the query
			[in] ULONG i_cbQuery2,								// size of the previous array
			[in] DWORD i_fQueryFormat,							// query format

			[out, size_is( , *o_pcb1)] char ** o_ppv1,			// the first array in which we marshall the cahe buffers
			[out] ULONG * o_pcb1,								// size of the previous array
			[out, size_is( , *o_pcb2)] char ** o_ppv2,
			[out] ULONG * o_pcb2, 
			[out, size_is( , *o_pcb3)] char ** o_ppv3,
			[out] ULONG * o_pcb3, 
			[out, size_is( , *o_pcb4)] char ** o_ppv4,
			[out] ULONG * o_pcb4, 
			[out, size_is( , *o_pcb5)] char ** o_ppv5,
			[out] ULONG * o_pcb5
			);

}

//ICatalogTableWrite Implemented by the Catalog Server
//Clients use this interface in order to write changes back out to the catalog
[
	object,
	uuid(0E3D6631-B46B-11d1-9D2D-006008B0E5CA),
	helpstring ("ICatalogTableWrite1"),
	pointer_default(unique)
]
interface ICatalogTableWrite1 : IUnknown
{
//WriteTable: Clients call this method in order to request that the catalog
//server write changes back out to the data store.  
	[id(1)] HRESULT WriteTable (
			[in] REFGUID i_DID,							// database id
			[in] REFGUID i_TID,							// table id		
			[in] DWORD i_fTable,						// table flags

			[in, size_is(i_cbQuery1), unique] char * i_pQuery1,	// the first array in which we marshall the query
			[in] ULONG i_cbQuery1,								// size of the previous array
			[in, size_is(i_cbQuery2), unique] char * i_pQuery2, // the second array in which we marshall the query
			[in] ULONG i_cbQuery2,								// size of the previous array
			[in] DWORD i_fQueryFormat,							// query format

			[in, size_is(i_cb1), unique] char * i_pv1,	// the first array in which we marshall the data
			[in] ULONG i_cb1,							// size of the previous array
			[in, size_is(i_cb2), unique] char * i_pv2,
			[in] ULONG i_cb2,
			[in, size_is(i_cb3), unique] char * i_pv3,
			[in] ULONG i_cb3,
			[in, size_is(i_cb4), unique] char * i_pv4,
			[in] ULONG i_cb4,
			[in, size_is(i_cb5), unique] char * i_pv5,
			[in] ULONG i_cb5,

			[out, size_is( , *o_pcb1)] char ** o_ppv1,
			[out] ULONG * o_pcb1
			);
}

[
	object,
	uuid(A8927A41-D3CE-11d1-8472-006008B0E5CA),
	helpstring ("ICatalogTableInfo"),
	pointer_default(unique)
]
interface ICatalogTableInfo:IUnknown
{
	[id(1)] HRESULT GetClientTableInfo(
			[in] REFGUID i_did,													// database id
			[in] REFGUID i_tid,													// table id		
			[in] DWORD i_fTable,												// table flags

			[in, size_is(i_cbQuery1), unique] char * i_pQuery1,					// the first array in which we marshall the query
			[in] ULONG i_cbQuery1,												// size of the previous array
			[in, size_is(i_cbQuery2), unique] char * i_pQuery2,					// the second array in which we marshall the query
			[in] ULONG i_cbQuery2,												// size of the previous array
			[in] DWORD i_fQueryFormat,											// query format

			[out] CLSID * o_pclsidDataTableDispenser,							// clsid of the client table dispenser
			[out, size_is( , *cbLocator)] char ** o_pwszLocator,				// locator 
			[out] ULONG * cbLocator,											// size of the locator
			[out, size_is( , *o_pcLogicTableDispenser)] CLSID ** o_paclsidLogicTableDispenser,	// the array of clsids of logic table dispensers
			[out] ULONG *o_pcLogicTableDispenser,								// the count of logic table dispensers

			[out, size_is( , *o_pcColumns)] SimpleColumnMeta **o_paColumnMeta,  // meta information
			[out] ULONG * o_pcColumns,											// count of columns in the table
			[out] IID* o_piid,													// pointer to an interface on the catalog server, that will be called by the client table to populate itself
			[out, iid_is(o_piid)] LPVOID* o_pItf,								// the iid of that interface
			[out, size_is( , *o_pcbReserved)] char ** o_pReserved,				// reserved for future use
			[out] ULONG * o_pcbReserved
			);
}



typedef [helpstring("CatSrv Services Enumeration")]
enum {
    css_minService = 1, 
    [helpstring("Load Balancing Service")] css_lb = 1,
    [helpstring("IMDB Service")] css_imdb = 2, 
    css_maxService = 2 
} CatSrvServices;




typedef [helpstring("CatSrv Service States Enumeration")]
enum {
    css_minServiceState = 0, 
    css_serviceStopped = 0, 
    css_serviceStartPending, 
    css_serviceStopPending,
    css_serviceRunning, 
    css_serviceContinuePending, 
    css_servicePausePending, 
    css_servicePaused, 
    css_serviceUnknownState,
    css_maxServiceState, 
} CatSrvServiceStates;


[
	object,
	uuid(47CDE9A1-0BF6-11d2-8016-00C04FB9988E),
	helpstring("ICSServiceControl Interface"),
	pointer_default(unique)
]
interface ICSServiceControl : IUnknown
{
    HRESULT StartService([in] CatSrvServices i_css);
    HRESULT StopService([in] CatSrvServices i_css);
    HRESULT InstallService([in] CatSrvServices i_css, [in] LPWSTR szBinaryPath);
    HRESULT UninstallService([in] CatSrvServices i_css);
    HRESULT IsServiceInstalled([in] CatSrvServices i_css, [out] ULONG *pulStatus);
    HRESULT IsServiceRunning([in] CatSrvServices i_css, [out] CatSrvServiceStates *pulState);
    HRESULT RefreshServiceSettings([in] CatSrvServices i_css);
};

[
uuid(3F3B1B86-DBBE-11d1-9DA6-00805F85CFE3),
object,
helpstring("IApplicationControl Interface"),
pointer_default(unique)
]
interface IApplicationControl : IUnknown
{
	HRESULT StartApplication( [in] REFGUID	guidApplId );

	HRESULT ShutdownApplication( [in] REFGUID	guidApplId );

	HRESULT RefreshComponents();
};


//DEFINE_GUID(<<name>>, 0x456129e2, 0x1078, 0x11d2, 0xb0, 0xf9, 0x0, 0x80, 0x5f, 0xc7, 0x32, 0x4);
[
uuid(456129E2-1078-11d2-B0F9-00805FC73204),
object,
helpstring("ICatalogUtils Interface"),
pointer_default(unique)
]
interface ICatalogUtils : IUnknown
{
	HRESULT ValidateUser( [in] LPWSTR pwszPrincipalName,
						  [in] LPWSTR pwszPassword);

	HRESULT	WaitForEndWrites();
	
	HRESULT GetEventClassesForIID (
			[in,  string, unique]					LPWSTR wszIID, 
			[out]									DWORD	*pcClasses, 
			[out, string, size_is(, *pcClasses)]	LPWSTR** pawszCLSIDs, 
			[out, string, size_is(, *pcClasses)]	LPWSTR** pawszProgIDs, 
			[out, string, size_is(, *pcClasses)]	LPWSTR** pawszDescriptions);
};


//DEFINE_GUID(<<name>>, 0x9864f70d, 0x2cb3, 0x11d2, 0xb0, 0xfe, 0x0, 0x80, 0x5f, 0xc7, 0x32, 0x4);
[
uuid(9864F70D-2CB3-11d2-B0FE-00805FC73204),
object,
helpstring("ICatalogSetup Interface"),
pointer_default(unique)
]
interface ICatalogSetup : IUnknown
{
	HRESULT ConfigureSystemApp([in] LPWSTR i_wszUserName, [in] LPWSTR i_wszPassword, [in] LPWSTR i_wszProfileFileName);
	HRESULT MarkAppAsSystem([in, unique] ISimpleTableDispenser2 *i_pDispenser, [in] GUID i_applid);
	HRESULT MarkAppAsNotSystem([in, unique] ISimpleTableDispenser2 *i_pDispenser, [in] GUID i_applid);
}

//DEFINE_GUID(<<name>>, 0x98315903, 0x7be5, 0x11d2, 0xad, 0xc1, 0x0, 0xa0, 0x24, 0x63, 0xd6, 0xe7);
[
uuid(98315903-7BE5-11d2-ADC1-00A02463D6E7),
object,
helpstring("IReplication Interface"),
pointer_default(unique)
]
interface IReplicationUtil : IUnknown
{
	HRESULT CreateShare				( [in] LPCWSTR i_wszShareName, [in] LPCWSTR i_wszPath );
	HRESULT CreateEmptyDir			( [in] LPCWSTR i_wszBasePath );
	HRESULT RemoveShare				( [in] LPCWSTR i_wszShareName );
	HRESULT	MakeNewReplicaCurrent	( [in] LPCWSTR i_wszBasePath );
	HRESULT QueryApplication		( [in] REFGUID i_guidAppId
									, [out, size_is( , *o_pcb)] char ** o_ppv
									, [out] ULONG * o_pcb
									);
	HRESULT CreateReplicationDir	( [out] LPWSTR* o_pwszPath );
}


[
	uuid(e6be109b-165f-11d1-b22d-00c04fb9473f),
	version(1.0),
	helpstring("CatalogServer 1.0 Type Library")
]
library CatalogServerLib
{
	importlib("stdole32.tlb");
	importlib("stdole2.tlb");
	
	[
		uuid(182c40f0-32e4-11d0-818b-00a0c9231c29),
		helpstring("CatalogServer Class")
	]
	coclass CatalogServer
	{
				interface ICatalogSession;
				interface ICatalogTableInfo;
				interface ICatalogTableRead1;	
				interface ICatalogTableWrite1;
                interface ICSServiceControl;
				interface IApplicationControl;
				interface ICatalogUtils;
				interface ICatalogSetup;
				interface IReplicationUtil;
	};

};

#endif

