//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (C) Microsoft Corporation, 1998.
//
//  File:
//      activate.idl
//
//  Contents:
//      Definition of (currently) private COM system activation interfaces.
//
//  History:
//              VinayKr     01-16-98        Created
//              SatishT     01-23-98        Added property interfaces
//              SatishT     02-03-98        Separated
//				JimLyon		02-18-98		Reworked and joined
//
//--------------------------------------------------------------------------

#ifndef DO_NO_IMPORTS
import "obase.idl";
import "wtypes.idl";
import "objidl.idl";
import "contxt.idl";
#endif


//--------------------------------------------------------------------------
//	A custom activator supports:
//		ISystemActivator
//
//	The activation properties object passed to an activator supports:
//		IInitActivationPropertiesIn
//		IActivationPropertiesIn
//		IServerLocationInfo
//		IActivationContextInfo
//		IActivationSecurityInfo
//      IActivationAgentInfo
//      IActivationStageInfo
//		IOpaqueDataInfo
//
//	The activation properties object returned by an activator supports:
//		IActivationPropertiesOut
//		IOpaqueDataInfo
//--------------------------------------------------------------------------

//--------------------------------------------------------------------------
//
//  Memory Management notes:
//
//  1.  Whenever any of the methods defined here return interface pointers,
//      they return counted references. The caller must eventually call Release ().
//
//  2.  Whenever any of the methods defined here have [out] parameters whose
//      type is something**, the method will set the caller's pointer to point to
//      data owned by the called object. The caller MUST NOT alter or free this data.
//      For example, IActivationPropertiesIn::GetActivationID returns a pointer to
//      a GUID. The actual GUID is in memory owned by the ActivationPropertiesIn
//      object; the caller must not alter the GUID or free the memory it occupies.
//
//  3.  Whenever any of these methods accept pointers to data structures from
//      their caller, they perform a deap copy of the data. The activation properties
//      objects NEVER retain pointers to data structures owned by their callers.
//
//--------------------------------------------------------------------------

// forward references:
interface IActivationPropertiesIn;
interface IActivationPropertiesOut;

[
    object,
    uuid(000001A0-0000-0000-C000-000000000046),
    pointer_default(unique)
]
interface ISystemActivator : IUnknown
{
    HRESULT GetClassObject(
                    [in,unique]  IActivationPropertiesIn *pActProperties,
                    [out] IActivationPropertiesOut **ppActProperties
                    );

    HRESULT CreateInstance(
                    [in,unique]  IUnknown *pUnkOuter,
                    [in,unique]  IActivationPropertiesIn *pActProperties,
                    [out] IActivationPropertiesOut **ppActProperties
                    );
}

//	These flags are used to indicate special activation requirements.
typedef enum tagACTIVATION_FLAGS {
	ACTVFLAGS_NONE = 0,
	ACTVFLAGS_WX86_CALLER = 1,
	ACTVFLAGS_DISABLE_AAA = 2
}  ACTIVATION_FLAGS;

[
    object,
    local,
    uuid(000001A1-0000-0000-C000-000000000046),
    pointer_default(unique)
]
interface IInitActivationPropertiesIn : IUnknown
{
	// These methods are legal only if IActivationPropertiesIn::Delegate...
	// has never been called.
	HRESULT SetClsctx ([in] DWORD clsctx);
	HRESULT SetActivationFlags([in] DWORD actvflags);
	HRESULT SetClassInfo ([in,unique] IUnknown* pUnkClassInfo);
	HRESULT SetContextInfo ([in,unique] IContext* pClientContext,
                            [in] IContext* pPrototypeContext);
	HRESULT SetConstructFromStorage ([in,unique] IStorage* pStorage);
	HRESULT SetConstructFromFile ([in] WCHAR* wszFileName, [in] DWORD dwMode);
}


[
    object,
    local,
    uuid(000001A2-0000-0000-C000-000000000046),
    pointer_default(unique)
]
interface IActivationPropertiesIn : IUnknown
{
    HRESULT GetActivationID([out] GUID *pActivationID);
    HRESULT GetClassInfo([in] REFIID riid, [out,iid_is(riid)] void** ppv);
    HRESULT GetClsctx([out] DWORD *pclsctx);
	HRESULT GetActivationFlags([out] DWORD *pactvflags);

	HRESULT AddRequestedIIDs([in] DWORD cIfs,
                             [in, size_is(cIfs)] IID *rgIID);

    HRESULT GetRequestedIIDs ([out] ULONG* pulCount, [out] IID** prgIID);

	// The following three methods are for activators who delegate onward.

    HRESULT DelegateGetClassObject([out] IActivationPropertiesOut **pActPropsOut);
    HRESULT DelegateCreateInstance([in] IUnknown *pUnkOuter,
                                   [out] IActivationPropertiesOut **pActPropsOut);

    //  Following can only be used in Server Context Stage
    //  and returns ClassFactory used in the Create Instance
    HRESULT DelegateCIAndGetCF([in] IUnknown *pUnkOuter,
                                   [out] IActivationPropertiesOut **pActPropsOut,
                                   [out] IClassFactory **ppCf);

	// The following method is for activators who do NOT delegate onward.

    HRESULT GetReturnActivationProperties([in] IUnknown *pUnk,
                                    [out] IActivationPropertiesOut **ppActOut);
}


[
    object,
    local,
    uuid(000001A3-0000-0000-C000-000000000046),
    pointer_default(unique)
]
interface IActivationPropertiesOut : IUnknown
{
    HRESULT GetActivationID([out] GUID *pActivationID);


    HRESULT GetObjectInterface([in] REFIID riid,
							   [in] DWORD actvflags,
                               [out, iid_is(riid)] void **ppv);
    HRESULT GetObjectInterfaces([in] DWORD cIfs,
							   [in] DWORD actvflags,
                               [in, size_is(cIfs)] MULTI_QI *multiQi);
	HRESULT RemoveRequestedIIDs([in] DWORD cIfs,
                                [in, size_is(cIfs)] IID *rgIID);
}



// Enumeration of activation stage constants
typedef enum tagACTIVATION_STAGE {
                                  CLIENT_CONTEXT_STAGE   = 1,
                                  CLIENT_MACHINE_STAGE   = 2,
                                  SERVER_MACHINE_STAGE   = 3,
                                  SERVER_PROCESS_STAGE   = 4,
                                  SERVER_CONTEXT_STAGE   = 5
              }  ACTIVATION_STAGE;


[
    object,
    uuid (000001A8-0000-0000-C000-000000000046),
    pointer_default (unique)
]
interface IActivationStageInfo : IUnknown
{
    HRESULT SetStageAndIndex ([in] ACTIVATION_STAGE stage, [in] int index);
    HRESULT GetStage ([out] ACTIVATION_STAGE* pstage);
    HRESULT GetIndex ([out] int* pindex);
}

//
//  Flags for the dwPRT parameter of Set/GetProcess
// 
typedef enum _PRT
{
  PRT_IGNORE = 0,
  PRT_CREATE_NEW = 1,
  PRT_USE_THIS = 2,
  PRT_USE_THIS_ONLY = 3
} PROCESS_REQUEST_TYPE;

[
    object,
    local,
    uuid(000001A4-0000-0000-C000-000000000046),
    pointer_default(unique)
]
interface IServerLocationInfo : IUnknown
{
	// SetRemoteServerName is allowed only prior to the server Machine stage.
    HRESULT SetRemoteServerName([in, string, unique] WCHAR *pswzMachineName);
    HRESULT GetRemoteServerName([out, string] WCHAR **pswzMachineName);
	// SetProcess 
    HRESULT SetProcess([in] DWORD pid, DWORD dwPRT);
    HRESULT GetProcess([out] DWORD* ppid, DWORD* pdwPRT);
	// SetApartment is allowed only in server process stage.
    HRESULT SetApartment([in] APTID apartmentId);
    HRESULT GetApartment([out] APTID *pApartmentId);
	// SetContext is allowed only in server process and server apartment stages.
    HRESULT SetContext([in] IObjContext* pContext);
    HRESULT GetContext([out] IObjContext** ppContext);
}


[
    object,
    local,
    uuid(000001A5-0000-0000-C000-000000000046),
    pointer_default(unique)
]
interface IActivationContextInfo : IUnknown
{
	// None of these methods is allowed in the server context stage.
    HRESULT GetClientContext([out] IContext **ppClientContext);
    HRESULT GetPrototypeContext([out] IContext **ppContext);
    HRESULT IsClientContextOK([out] BOOL *fYes);
    HRESULT SetClientContextNotOK();
}


[
    object,
    local,
    uuid(000001BA-0000-0000-C000-000000000046),
    pointer_default(unique)
]
interface IOverrideTargetContext : IUnknown
{
    HRESULT OverrideTargetContext([in] REFGUID guidTargetCtxtId);
}


[
    object,
    local,
    uuid(000001A6-0000-0000-C000-000000000046),
    pointer_default(unique)
]
interface IActivationSecurityInfo : IUnknown
{
	// These methods are only allowed prior to the server process stage.
    HRESULT SetAuthnFlags([in] DWORD dwAuthnFlags); // e.g., static/dynamic
    HRESULT GetAuthnFlags([out] DWORD *pdwAuthnFlags);
    HRESULT SetAuthnSvc([in] DWORD dwAuthnSvc);
    HRESULT GetAuthnSvc([out] DWORD *pdwAuthnSvc);
    HRESULT SetAuthzSvc([in] DWORD dwAuthzSvc);
    HRESULT GetAuthzSvc([out] DWORD *pdwAuthzSvc);
    HRESULT SetAuthnLevel([in] DWORD dwAuthnLevel);
    HRESULT GetAuthnLevel([out] DWORD *pdwAuthnLevel);
    HRESULT SetImpLevel([in] DWORD dwImpLevel);
    HRESULT GetImpLevel([out] DWORD *pdwImpLevel);
    HRESULT SetCapabilities([in] DWORD dwCapabilities);
    HRESULT GetCapabilities([out] DWORD *pdwCapabilities);
    HRESULT SetAuthIdentity([in, unique] COAUTHIDENTITY *pAuthIdentityData);
    HRESULT GetAuthIdentity([out] COAUTHIDENTITY **pAuthIdentityData);
    HRESULT SetServerPrincipalName([in, unique] WCHAR* pwszServerPrincName);
    HRESULT GetServerPrincipalName([out] WCHAR** pwszServerPrincName);
}

// A SIDLIST is a buffer composed as follows:
//      ULONG number of SIDs in the list
//      For each SID, the following:
//          ULONG number of bytes for the SID
//          contents of the SID
// The first SID in a SIDLIST is a user SID; the rest are GROUP SIDs.
//BUGBUG: needs definition
typedef LONG* PSIDLIST; // pointer to a SIDLIST

[
    object,
    uuid (000001A7-0000-0000-C000-000000000046),
    pointer_default (unique)
]
interface IActivationAgentInfo : IUnknown
{
    HRESULT AddActivationAgent ([in] PSIDLIST pSidList);
    HRESULT GetActivationAgentCount ([out] ULONG* pulCount);
    HRESULT GetActivationAgents ([out] PSIDLIST** prgSidList);
}

// 
//  ServerType -- an enumeration describing the various
//    types of servers that can be registered with the scm
//
typedef enum
{
  ST_SERVER = 1,    // normal server
  ST_OLDSURROGATE,  // legacy surrogate-style application
  ST_COMPLUSAPP,    // new COM+ application
  ST_SERVICE        // server implemented as an NT service
} ServerType;

// 
// ServerIDType -- an enumeration to differentiate 
//   between run-as-a-specific-user server and a run-as-
//   interactive-user server.    Does not apply to servers
//   implemented as NT services.
//
typedef enum
{
  SIT_RUNAS_SPECIFIC_USER = 1,
  SIT_RUNAS_INTERACTIVE
} ServerIDType;

// 
// SCMProcessInfoFlags -- an enumeration containing various
//   state bits for the dwState member of the SCMProcessInfo
//   struct.
//
typedef enum
{
  SPIF_COMPLUS       = 1,   // process is a com+ server
  SPIF_SUSPENDED     = 2,   // process has been suspended by an activator
  SPIF_RETIRED       = 4,   // process has been retired by an activator
  SPIF_READY         = 8,   // process is started and is ready for activations (if not set
                            // the process is in a sort-of "started-but-suspended" state)
  SPIF_PAUSED        = 16   // the process has paused itself (due to user action)
} SCMProcessInfoFlags;


// 
//  SCMProcessInfo -- describes a server process registered with 
//    the scm.
//
typedef struct
{
  ULONG        ulNumClasses;
  GUID*        pCLSIDs;
  DWORD        pidProcess;
  HANDLE       hProcess;       // will almost never be NULL, but caller should check anyway
  HANDLE       hImpersonationToken;
  WCHAR*       pwszWinstaDesktop;
  DWORD        dwState;        // see SCMProcessInfoFlags 
  GUID         AppId;          // valid only if SPIF_COMPLUS bit is set
  ServerType   ServerType;
  ServerIDType ServerID;
  FILETIME     ftCreated;
} SCMProcessInfo, *PSCMProcessInfo;


//
//  IEnumSCMProcessInfo
//
//  Interface for walking through a view of the SCM's server tables
// 
[
    local,
    object,
    uuid(8bbbd026-de4d-46b7-8a90-72c66eb64ad6),
    pointer_default(unique)
]
interface IEnumSCMProcessInfo : IUnknown
{
	// Fetch process info for next cElems processes
	HRESULT Next([in] ULONG cElems,
               [out, size_is (cElems), length_is (*pcFetched)] SCMProcessInfo** ppSCMProcessInfo,
               [out] ULONG *pcFetched);
	// advance cursor past cElems elements
	HRESULT Skip([in]ULONG cElems);
	// reset cursor to first element
	HRESULT Reset();
	// duplicate this enumerator
	HRESULT Clone([out]IEnumSCMProcessInfo **ppESPI);
}


//
//  ISCMProcessControl
//
//  Interface for querying & changing the SCM's server tables
// 
[
    local,
    object,
    uuid(7629798c-f1e6-4ef0-b521-dc466fded209),
    pointer_default(unique)
]
interface ISCMProcessControl : IUnknown
{
  // Find info for processes implementing an application
  HRESULT FindApplication ([in] REFGUID rappid, [out] IEnumSCMProcessInfo **ppESPI);
  // Find info for processes implementing a class
  HRESULT FindClass ([in] REFCLSID rclsid, [out] IEnumSCMProcessInfo **ppESPI);
  // Find info for a particular PID.
  HRESULT FindProcess ([in] DWORD pid, [out] SCMProcessInfo** pSCMProcessInfo);
  // Send no activations to COM+ applications implementing this APPID.
  HRESULT SuspendApplication ([in] REFGUID rappid);
  // Send no activations to processes implementing this CLSID.
  HRESULT SuspendClass ([in] REFCLSID rclsid);
  // Send no activations to this process.
  HRESULT SuspendProcess ([in] DWORD ppid);
  // Resume sending activations to COM+ applications implementing this APPID
  HRESULT ResumeApplication([in] REFGUID rappid);
  // Resume sending activations to processes implementing this CLSID
  HRESULT ResumeClass([in] REFCLSID rclsid);
  // Resumt sending activations to this process
  HRESULT ResumeProcess([in] DWORD pid);
  // Send no more activations to COM+ applications implementing this APPID.
  HRESULT RetireApplication ([in] REFGUID rappid);
  // Send no more activations to processes implementing this CLSID.
  HRESULT RetireClass ([in] REFCLSID rclsid);
  // Send no more activations to this process.
  HRESULT RetireProcess ([in] DWORD pid);
  // Free a SCMProcessInfo structure
  HRESULT FreeSCMProcessInfo(SCMProcessInfo** ppSCMProcessInfo);
}

// This clsid gets defined in prvidl.lib
cpp_quote("")
cpp_quote("EXTERN_C const CLSID CLSID_RPCSSInfo;")
cpp_quote("")

cpp_quote("")
cpp_quote("////////////////////////////////////////////////////////////////////////")
cpp_quote("//")
cpp_quote("// API for accessing SCM's objects (exported from rpcss.dll)")
cpp_quote("//")
cpp_quote("typedef HRESULT (__stdcall *PFNGETRPCSSINFO)(REFCLSID, REFIID, void**);")
cpp_quote("//")
cpp_quote("////////////////////////////////////////////////////////////////////////")
cpp_quote("")


