cpp_quote("#pragma once")

import "unknwn.idl";
import "oaidl.idl";
import "SessdirPublicTypes.idl";

//
// Forward declarations
//
//Interfaces implemented by the client
interface ITsSbPlugin;
interface ITsSbResourcePlugin;
interface ITsSbLoadBalancing;
interface ITsSbPlacement;
interface ITsSbOrchestration;
interface ITsSbEnvironment;
interface ITsSbLoadBalanceResult;
interface ITsSbTarget;
interface ITsSbSession;
interface ITsSbResourceNotification;

//Interfaces implemented by the broker
interface ITsSbPropertySet;
interface ITsSbPluginPropertySet;
interface ITsSbClientConnectionPropertySet;
interface ITsSbTargetPropertySet;
interface ITsSbEnvironmentPropertySet;
interface ITsSbBaseNotifySink;
interface ITsSbPluginNotifySink;
interface ITsSbTargetNotifySink;
interface ITsSbSessionNotifySink;
interface ITsSbLoadBalancingNotifySink;
interface ITsSbPlacementNotifySink;
interface ITsSbOrchestrationNotifySink;
interface ITsSbClientConnection;
interface ITsSbProvider;
interface ITsSbResourcePluginStore;
interface ITsSbGlobalStore;

[
    object,
    uuid(48cd7406-caab-465f-a5d6-baa863b9ea4f),
    helpstring("interface ITsSbPlugin"),
    pointer_default(unique)
]
interface ITsSbPlugin : IUnknown
{
    [id(1), helpstring("method Initialize")]
    HRESULT 
    Initialize(
            [in] ITsSbProvider *pProvider,
            [in] ITsSbPluginNotifySink* pNotifySink,
            [in] ITsSbPluginPropertySet* pPropertySet
            );

    [id(2), helpstring("method Terminate")]
    HRESULT 
    Terminate(
            [in] HRESULT hr
            );
};

[
    object,
    uuid(7633f4e7-8a10-49a1-8413-e4783001b70e),
    helpstring("interface ITsSbResourcePlugin"),
    pointer_default(unique)
]
interface ITsSbResourcePlugin : ITsSbPlugin
{                      
    [id(1), helpstring("method Refresh")]
    HRESULT 
    Refresh(
            [in] DWORD dwFlags,
            [in] BSTR pEnvBindingStr
            );
};

[
    object,
    uuid(24329274-9EB7-11DC-AE98-F2B456D89593),
    helpstring("interface ITsSbLoadBalancing"),
    pointer_default(unique)
]
interface ITsSbLoadBalancing  : ITsSbPlugin
{
    [id(1), helpstring("method GetMostSuitableTarget")]
    HRESULT 
    GetMostSuitableTarget(
            [in] ITsSbClientConnection* pConnection,            
            [in] ITsSbLoadBalancingNotifySink* pLBSink
            );
};

[
    object,
    uuid(B937A478-9EB6-11DC-8377-D5B056D89593),
    helpstring("interface ITsSbPlacement"),
    pointer_default(unique)
]
interface ITsSbPlacement : ITsSbPlugin
{
    [id(1), helpstring("method QueryEnvironmentForTarget")]
    HRESULT 
    QueryEnvironmentForTarget(
            [in] ITsSbClientConnection* pConnection,
            [in] ITsSbPlacementNotifySink* pPlacementSink
            );
                
    [id(2), helpstring("method CreateEnvironmentForTarget")]
    HRESULT 
    CreateEnvironmentForTarget(
            [in] ITsSbClientConnection* pConnection,
            [in] ITsSbPlacementNotifySink* pPlacementSink
            );
};

[
    object,
    uuid(64FC1172-9EB7-11DC-8B00-3ABA56D89593),
    helpstring("interface ITsSbOrchestration"),
    pointer_default(unique)
]
interface ITsSbOrchestration  : ITsSbPlugin
{
    [id(1), helpstring("method PrepareTargetForConnect")]
    HRESULT 
    PrepareTargetForConnect(
            [in] ITsSbClientConnection* pConnection,
            [in] ITsSbOrchestrationNotifySink* pOrchestrationNotifySink
            );   
};

[
    object,
    uuid(8c87f7f7-bf51-4a5c-87bf-8e94fb6e2256),
    helpstring("interface ITsSbEnvironment "),
    pointer_default(unique)
]
interface ITsSbEnvironment  : IUnknown
{
    [propget, id(1), helpstring("property Name")]
    HRESULT Name(
            [out, retval] BSTR *pVal
            );        

    [propget, id(2), helpstring("property ServerWeight")]
    HRESULT ServerWeight(
            [out, retval] DWORD *pVal
            );

    [propget, id(3), helpstring("property EnvironmentPropertySet")]
    HRESULT 
    EnvironmentPropertySet(
            [out, retval] ITsSbEnvironmentPropertySet** ppPropertySet
            );

    [propput, id(3), helpstring("property EnvironmentPropertySet")]
    HRESULT 
    EnvironmentPropertySet(
            [in] ITsSbEnvironmentPropertySet* pVal
            );
};

[
    object,
    uuid(24FDB7AC-FEA6-11DC-9672-9A8956D89593),
    helpstring("interface ITsSbLoadBalanceResult"),
    pointer_default(unique)
]
interface ITsSbLoadBalanceResult: IUnknown
{ 

    [propget, id(1), helpstring("property TargetName")]
    HRESULT TargetName(
            [out, retval] BSTR *pVal
            );
}

[
    object,
    uuid(e85e10ea-db0b-4752-b456-5fd5840901c0),
    helpstring("interface ITsSbTarget"),
    pointer_default(unique)
]
interface ITsSbTarget : IUnknown
{
    [propget, id(1), helpstring("property TargetName")]
    HRESULT TargetName(
            [out, retval] BSTR *pVal
            );

    [propget, id(2), helpstring("property FarmName")]
    HRESULT FarmName(
            [out, retval] BSTR *pVal
            );

    [propput, id(2), helpstring("property FarmName")]
    HRESULT FarmName(
            [in] BSTR Val
            );
    
    [propget, id(3), helpstring("property TargetFQDN")]
    HRESULT 
    TargetFQDN(
            [out, retval] BSTR *TargetFqdnName
            );
  
    [propput, id(3), helpstring("property TargetFQDN")]
    HRESULT 
    TargetFQDN(
            [in] BSTR Val
            );
        
    [propget, id(4), helpstring("property TargetNetbios")]
    HRESULT 
    TargetNetbios(
            [out, retval] BSTR *TargetNetbiosName 
            );
  
    [propput, id(4), helpstring("property TargetNetbios")]
    HRESULT 
    TargetNetbios(
            [in] BSTR Val
            );
     
    [propget, id(5), helpstring("property TargetExternalIpAddresses")]
    HRESULT 
    TargetExternalIpAddresses(
            [out, size_is(*numAddresses)] TSSD_ConnectionPoint* sockaddr, 
            [in, out] DWORD* numAddresses
            );
   
    [propput, id(5), helpstring("property TargetExternalIpAddresses")]
    HRESULT 
    TargetExternalIpAddresses(
            [in, size_is(numAddresses)] TSSD_ConnectionPoint *sockaddr, 
            [in] DWORD numAddresses
            );
     
    [propget, id(6), helpstring("property TargetInternalIpAddresses")]
    HRESULT 
    TargetInternalIpAddresses(
            [out, size_is(*numAddresses)] TSSD_ConnectionPoint* sockaddr, 
            [in, out] DWORD* numAddresses
            );    
   
    [propput, id(6), helpstring("property TargetInternalIpAddresses")]
    HRESULT 
    TargetInternalIpAddresses(
            [in, size_is(numAddresses)] TSSD_ConnectionPoint *sockaddr, 
            [in] DWORD numAddresses
            );
    
    [propget, id(7), helpstring("property TargetState")]
    HRESULT 
    TargetState(
            [out, retval] TARGET_STATE* pState
            );
    
    [propput, id(7), helpstring("property TargetState")]
    HRESULT 
    TargetState(
            [in] TARGET_STATE State
            );
       
    [propget, id(8), helpstring("property TargetPropertySet")]
    HRESULT 
    TargetPropertySet(
            [out, retval] ITsSbTargetPropertySet** ppPropertySet
            );
    
    [propput, id(8), helpstring("property TargetPropertySet")]
    HRESULT 
    TargetPropertySet(
            [in] ITsSbTargetPropertySet *pVal
            ); 
};

[
    object,
    uuid(1ef3d5cf-8fbb-4a5a-ab4a-7f85b218bd8d),
    helpstring("interface ITsSbSession"),
    pointer_default(unique)
]
interface ITsSbSession : IUnknown
{
    [propget, id(1), helpstring("property SessionId")]
    HRESULT 
    SessionId(
        [out, retval] DWORD *pVal
        );
          
    [propget, id(2), helpstring("property TargetName")]
    HRESULT 
    TargetName(
        [out, retval] BSTR *targetName
        );
        
    [propget, id(3), helpstring("property Username")]
    HRESULT 
    Username(
        [out, retval] BSTR *userName
        );
        
    [propget, id(4), helpstring("property Domain")]
    HRESULT 
    Domain(
        [out, retval] BSTR *domain
        );
        
    [propget, id(5), helpstring("property State")]
    HRESULT 
    State(
        [out, retval] TSSESSION_STATE* pState
        );
    
    [propput, id(6), helpstring("property State")]
    HRESULT 
    State(
        [in] TSSESSION_STATE State
        );
            
    [propget, id(7), helpstring("property CreateTime")]
    HRESULT 
    CreateTime(
        [out, retval] FILETIME* pTime
        );
    
    [propput, id(8), helpstring("property CreateTime")]
    HRESULT 
    CreateTime(
            [in] FILETIME Time
            );
            
    [propget, id(9), helpstring("property DisconnectTime")]
    HRESULT 
    DisconnectTime(
        [out, retval] FILETIME* pTime
        );
    
    [propput, id(10), helpstring("property DisconnectTime")]
    HRESULT 
    DisconnectTime(
            [in] FILETIME Time
            );
            
    [propget, id(11), helpstring("property InitialProgram")]
    HRESULT 
    InitialProgram(
            [out, retval] BSTR *app
            );
    
    [propput, id(12), helpstring("property InitialProgram")]
    HRESULT 
    InitialProgram(
            [in] BSTR Application
            );
            
    [propget, id(13), helpstring("property ClientDisplay")]
    HRESULT 
    ClientDisplay(
            [out, retval] CLIENT_DISPLAY *pClientDisplay
            );
    
    [propput, id(14), helpstring("property ClientDisplay")]
    HRESULT 
    ClientDisplay(
            [in] CLIENT_DISPLAY pClientDisplay
            );        
    [propget, id(15), helpstring("property ProtocolType")]
    HRESULT 
    ProtocolType(
            [out, retval] DWORD *pVal
            );  
        
    [propput, id(16), helpstring("property ProtocolType")]
    HRESULT 
    ProtocolType(
            [in] DWORD Val
            );
};

[
    object,
    uuid(65D3E85A-C39B-11DC-B92D-3CD255D89593),
    helpstring("interface ITsSbResourceNotification"),
    pointer_default(unique)
]
interface ITsSbResourceNotification : IUnknown
{
     [id(1), helpstring("method NotifySessionChange")]
     HRESULT
     NotifySessionChange(
           [in] TSSESSION_STATE changeType,
           [in] ITsSbSession* pSession
       );

     [id(2), helpstring("method NotifyTargetChange")]
     HRESULT
     NotifyTargetChange(
           [in] DWORD  TargetChangeType,
           [in] ITsSbTarget* pTarget
       );     

     [id(3), helpstring("method NotifyClientConnectionStateChange")]
     HRESULT
     NotifyClientConnectionStateChange(
           [in] CONNECTION_CHANGE_NOTIFICATION ChangeType,
           [in] ITsSbClientConnection *pConnection
       );
};

//
//Interfaces implemented by the broker
//
[
    object,
    uuid(5c025171-bb1e-4baf-a212-6d5e9774b33b),
    helpstring("interface ITsSbPropertySet"),
    pointer_default(unique)
]
interface ITsSbPropertySet : IPropertyBag
{   
};

[
    object,
    uuid(95006e34-7eff-4b6c-bb40-49a4fda7cea6),
    helpstring("interface ITsSbPluginPropertySet"),
    pointer_default(unique)
]
interface ITsSbPluginPropertySet : ITsSbPropertySet
{
};

[
    object,
    uuid(E51995B0-46D6-11DD-AA21-CEDC55D89593),
    helpstring("interface ITsSbClientConnectionPropertySet"),
    pointer_default(unique)
]
interface ITsSbClientConnectionPropertySet : ITsSbPropertySet
{
};


[
    object,
    uuid(f7bda5d6-994c-4e11-a079-2763b61830ac),
    helpstring("interface ITsSbTargetPropertySet"),
    pointer_default(unique)
]
interface ITsSbTargetPropertySet : ITsSbPropertySet
{    
};

[
    object,
    uuid(D0D1BF7E-7ACF-11DD-A243-E51156D89593),
    helpstring("interface ITsSbEnvironmentPropertySet"),
    pointer_default(unique)
]
interface ITsSbEnvironmentPropertySet : ITsSbPropertySet
{    
};

[
    object,
    uuid(808a6537-1282-4989-9e09-f43938b71722),
    helpstring("interface ITsSbBaseNotifySink"),
    pointer_default(unique)
]
interface ITsSbBaseNotifySink: IUnknown
{
    [id(1), helpstring("method OnError")]
    HRESULT 
    OnError(
            [in] HRESULT hrError
            );

    [id(2), helpstring("method OnReportStatus")]
    HRESULT 
    OnReportStatus(
            [in] CLIENT_MESSAGE_TYPE messageType,
            [in] DWORD messageID
            );            
};

[
    object,
    uuid(44dfe30b-c3be-40f5-bf82-7a95bb795adf),
    helpstring("interface ITsSbPluginNotifySink"),
    pointer_default(unique)
]
interface ITsSbPluginNotifySink: ITsSbBaseNotifySink
{
    [id(1), helpstring("method OnInitialized")]
    HRESULT
    OnInitialized(
            [in] HRESULT hr
            );

    [id(2), helpstring("method OnTerminated")]
    HRESULT
    OnTerminated();    
};

[
    object,
    uuid(2be69924-ddf2-44b9-ab92-2c27aefb4379),
    helpstring("interface ITsSbTargetNotifySink"),
    pointer_default(unique)
]
interface ITsSbTargetNotifySink : ITsSbBaseNotifySink
{                
    [id(1), helpstring("method OnConfigChange")]
    HRESULT 
    OnConfigChange(
            [in] DWORD TargetConfigTypes
            );

    [id(2), helpstring("method OnStateChange")]
    HRESULT 
    OnStateChange();            
};

[
    object,
    uuid(a821601f-d822-4fe2-a2a3-cd4b00652a1a),
    helpstring("interface ITsSbSessionNotifySink"),
    pointer_default(unique)
]
interface ITsSbSessionNotifySink : ITsSbBaseNotifySink
{
    [id(1), helpstring("method OnStateChange")]
    HRESULT 
    OnStateChange();            
};

[
    object,
    uuid(7f3fdb2f-c8dc-4873-a600-8580787baa64),
    helpstring("interface ITsSbLoadBalancingNotifySink"),
    pointer_default(unique)
]
interface ITsSbLoadBalancingNotifySink : ITsSbBaseNotifySink
{
    [id(1), helpstring("method OnGetMostSuitableTarget")]
    HRESULT 
    OnGetMostSuitableTarget(
            [in] ITsSbLoadBalanceResult* pLBResult
            );    
};

[
    object,
    uuid(3a2da1d1-1ad9-4248-ac21-13bbc273dd42),
    helpstring("interface ITsSbPlacementNotifySink"),
    pointer_default(unique)
]
interface ITsSbPlacementNotifySink : ITsSbBaseNotifySink
{
    [id(1), helpstring("method OnQueryEnvironmentCompleted")]
    HRESULT 
    OnQueryEnvironmentCompleted(
            [in] ITsSbEnvironment* pEnvironment
            );    
                                
    [id(2), helpstring("method OnEnvironmentReady")]
    HRESULT 
    OnEnvironmentReady(
            [in] ITsSbEnvironment* pEnvironment
            );    
};

[
    object,
    uuid(36c37d61-926b-442f-bca5-118c6d50dcf2),
    helpstring("interface ITsSbOrchestrationNotifySink"),
    pointer_default(unique)
]
interface ITsSbOrchestrationNotifySink : ITsSbBaseNotifySink
{
    [id(1), helpstring("method OnReadyToConnect")]
    HRESULT 
    OnReadyToConnect(      
            [in] ITsSbTarget* pTarget    
           );                 
};

[
    object,
    uuid(da852238-59c8-481f-996b-301388d496d3),
    helpstring("interface ITsSbClientConnection"),
    pointer_default(unique)
]
interface ITsSbClientConnection : IUnknown
{            
    [propget, id(1), helpstring("property Username")]
    HRESULT 
    UserName(
            [out, retval] BSTR *pVal 
            );
            
    [propget, id(2), helpstring("property Domain")]
    HRESULT 
    Domain(
            [out, retval] BSTR *pVal 
            );
            
    [propget, id(3), helpstring("property InitialProgram")]
    HRESULT 
    InitialProgram(
            [out, retval] BSTR *pVal
            );

    [propget, id(4), helpstring("property LoadBalanceResult")]
    HRESULT 
    LoadBalanceResult(
        [out, retval] ITsSbLoadBalanceResult **ppVal
        );            
            
    [propget, id(5), helpstring("property TargetType")]
    HRESULT 
    TargetType(
            [out, retval] TARGET_TYPE* targetType 
            );

    [propget, id(6), helpstring("property TargetName")]
    HRESULT 
    TargetName(
            [out, retval] BSTR* pVal 
            );

    [local, id(7), helpstring("method PutContext")]
    HRESULT
    PutContext(
         [annotation("__in")] BSTR contextId,
         [annotation("__in")] VARIANT context,
         [annotation("__out_opt")] VARIANT *existingContext
         );          

    [id(8), helpstring("method GetContext")]
    HRESULT
    GetContext(
         [in] BSTR contextId,
         [out, retval] VARIANT *context
         );  
    
    [propget, id(9), helpstring("property Environment")]
    HRESULT 
    Environment(
            [out, retval] ITsSbEnvironment **ppEnvironment
            );

    [propget, id(10), helpstring("property IsDisconnectedSession")]
    HRESULT 
    IsDisconnectedSession(
            [out, retval] BOOL *pIsDisconnectionSession);

    [propget, id(12), helpstring("property ConnectionError")]
    HRESULT 
    ConnectionError(
            );

    // This is a helper method, returns domain\username
    [propget, id(13), helpstring("property SamUserAccount")]
    HRESULT 
    SamUserAccount(
            [out, retval] BSTR* pVal
            );  

    [propget, id(14), helpstring("property ClientConnectionPropertySet")]
    HRESULT 
    ClientConnectionPropertySet(
            [out, retval] ITsSbClientConnectionPropertySet** ppPropertySet
            );            
};

[
    object,
    uuid(67199246-f3a4-4035-a1f2-be2f16afb1af),
    helpstring("interface ITsSbProvider"),
    pointer_default(unique)
]
interface ITsSbProvider : IUnknown
{
    [id(1), helpstring("method CreateTargetObject")]
    HRESULT
    CreateTargetObject(
         [in]  BSTR TargetName,
         [out] ITsSbTarget **ppTarget
         );   

    [id(2), helpstring("method CreateLoadBalanceResultObject")]
    HRESULT
    CreateLoadBalanceResultObject(
         [in]  BSTR TargetName,
         [out] ITsSbLoadBalanceResult **ppLBResult
         );          
         
    [id(3), helpstring("method CreateSessionObject")]
    HRESULT
    CreateSessionObject(
         [in]  BSTR TargetName,
         [in]  BSTR UserName,
         [in]  BSTR Domain,
         [in]  DWORD SessionId,
         [out] ITsSbSession **ppSession
         );

    [id(4), helpstring("method CreatePluginPropertySet")]    
    HRESULT 
    CreatePluginPropertySet(
            [out, retval] ITsSbPluginPropertySet** ppPropertySet
            );

    [id(5), helpstring("method CreateTargetPropertySetObject")]
    HRESULT
    CreateTargetPropertySetObject(
         [out] ITsSbTargetPropertySet **ppPropertySet
         );
    
    [id(6), helpstring("method CreateEnvironmentObject")]
    HRESULT
    CreateEnvironmentObject(
         [in]  BSTR Name,
         [in] DWORD ServerWeight,
         [out] ITsSbEnvironment **ppEnvironment
         );

    [id(8), helpstring("method GetResourcePluginStore")]
    HRESULT
    GetResourcePluginStore(
         [in]  ITsSbResourcePlugin* pResourcePlugin,
         [out] ITsSbResourcePluginStore** ppStore
         );    

    [id(9), helpstring("method RegisterForNotification")]
    HRESULT
    RegisterForNotification(
         [in] DWORD notificationType,
         [in] BSTR ResourceToMonitor,
         [in] ITsSbResourceNotification *pPluginNotification
         );

    [id(10), helpstring("method UnRegisterForNotification")]
    HRESULT
    UnRegisterForNotification(
         [in] DWORD notificationType,
         [in] BSTR ResourceToMonitor
         );    
    
    [id(11), helpstring("method GetInstanceOfGlobalStore")]
    HRESULT
    GetInstanceOfGlobalStore(
         [out] ITsSbGlobalStore** ppGlobalStore
         );

    [id(12), helpstring("method CreateEnvironmentPropertySetObject")]
    HRESULT
    CreateEnvironmentPropertySetObject(
         [out] ITsSbEnvironmentPropertySet **ppPropertySet
         );
};

[
    object,
    uuid(03aba8da-3fdf-4c3f-9304-7842430cc606),
    helpstring("interface ITsSbResourcePluginStore"),
    pointer_default(unique)
]
interface ITsSbResourcePluginStore : IUnknown
{    
    [id(1), helpstring("method QueryTarget")]
    HRESULT
    QueryTarget(
         [in]  BSTR  TargetName,
         [in]  BSTR  FarmName, // if NULL, the first target found will be returned
         [out] ITsSbTarget  **ppTarget
         );   
    
    [id(2), helpstring("method GetTargetNotifySink")]
    HRESULT
    GetTargetNotifySink(
         [in]  ITsSbTarget  *pTarget,
         [out] ITsSbTargetNotifySink **ppTargetNotifySink
         );   

    [id(3), helpstring("method QuerySessionByUserName")]
    HRESULT
    QuerySessionByUserName(
         [in]  BSTR  UserName,
         [in]  TARGET_TYPE TargetType,
         [in]  BSTR  TargetName,
         [out] ITsSbSession **ppSession
         );   

    [id(4), helpstring("method QuerySessionBySessionId")]
    HRESULT
    QuerySessionBySessionId(
         [in]  DWORD  dwSessionId,
         [in]  BSTR  TargetName,
         [out] ITsSbSession **ppSession
         );   
    
    [id(5), helpstring("method GetSessionNotifySink")]
    HRESULT
    GetSessionNotifySink(
         [in]  ITsSbSession *pSession,
         [out] ITsSbSessionNotifySink **ppSessionNotifySink
         );   

    [id(6), helpstring("method AddTargetToStore")]
    HRESULT 
    AddTargetToStore(
            [in] ITsSbTarget* pTarget, 
            [out] ITsSbTargetNotifySink** ppTargetNotifySink
            );

    [id(7), helpstring("method AddSessionToStore")]
    HRESULT 
    AddSessionToStore(
            [in] ITsSbSession* pSession, 
            [out] ITsSbSessionNotifySink** ppSessionNotifySink
            );            

    [id(8), helpstring("method AddEnvironmentToStore")]
    HRESULT
    AddEnvironmentToStore(
             [in] ITsSbEnvironment *pEnvironment
             );

    [id(9), helpstring("method RemoveEnvironmentFromStore")]
    HRESULT
    RemoveEnvironmentFromStore(
             [in] BSTR EnvironmentName
             );         
        
    [id(10), helpstring("method EnumerateFarms")]
    HRESULT
    EnumerateFarms(
         [out] DWORD *pdwCount,
         [out] SAFEARRAY(BSTR) *pVal
         );  

    [id(11), helpstring("method EnumerateTargetsByFarm")]
    HRESULT
    EnumerateTargetsByFarm(
         [in]  BSTR FarmName,
         [in, out] DWORD *pdwCount,
         [out, size_is(*pdwCount)] IUnknown **pVal[]
         );    
    
    [id(12), helpstring("method EnumerateNonFarmTargets")]
    HRESULT
    EnumerateNonFarmTargets(
         [in, out] DWORD *pdwCount,
         [out, size_is(*pdwCount)] IUnknown **pVal[]
         );

    [id(13), helpstring("method QueryEnvironment")]
    HRESULT
    QueryEnvironment(
         [in]  BSTR  EnvironmentName,
         [out] ITsSbEnvironment **ppEnvironment
         );

    [id(14), helpstring("method EnumerateEnvironments")]
    HRESULT
    EnumerateEnvironments(
         [in, out] DWORD *pdwCount,
         [out, size_is(*pdwCount)] ITsSbEnvironment **pVal[]
         );

    [id(15), helpstring("method EnumerateSessionsByTargetName")]
    HRESULT
    EnumerateSessionsByTargetName(
    	[in]  BSTR  TargetName,
        [in, out] DWORD *pdwCount,
        [out, size_is(*pdwCount)] ITsSbSession **ppVal[]
        ); 
         
};

[
    object,
    uuid(d521ad43-7123-49a2-8622-8871a147439e),
    helpstring("interface ITsSbGlobalStore"),
    pointer_default(unique)
]
interface ITsSbGlobalStore : IUnknown
{    
    [id(1), helpstring("method QueryTarget")]
    HRESULT
    QueryTarget(
         [in]  BSTR  ProviderName,
         [in]  BSTR  TargetName,
         [in]  BSTR  FarmName, // if NULL, the first target found will be returned
         [out] ITsSbTarget  **ppTarget
         );   

    [id(2), helpstring("method QuerySessionByUserName")]
    HRESULT
    QuerySessionByUserName(
         [in]  BSTR  ProviderName,
         [in]  BSTR  UserName,
         [in]  TARGET_TYPE TargetType,
         [in]  BSTR  TargetName,
         [out] ITsSbSession **ppSession
         );   

    [id(3), helpstring("method QuerySessionBySessionId")]
    HRESULT
    QuerySessionBySessionId(
         [in]  BSTR  ProviderName,
         [in]  DWORD  dwSessionId,
         [in]  BSTR  TargetName,
         [out] ITsSbSession **ppSession
         );   
 
    [id(4), helpstring("method EnumerateFarms")]
    HRESULT
    EnumerateFarms(
         [in]  BSTR  ProviderName,
         [out] DWORD *pdwCount,
         [out] SAFEARRAY(BSTR) *pVal
         );  

    [id(5), helpstring("method EnumerateTargetsByFarm")]
    HRESULT
    EnumerateTargetsByFarm(
         [in]  BSTR  ProviderName,
         [in]  BSTR FarmName,
         [in, out] DWORD *pdwCount,
         [out, size_is(*pdwCount)] IUnknown **pVal[]
         );    
    
    [id(6), helpstring("method EnumerateNonFarmTargets")]
    HRESULT
    EnumerateNonFarmTargets(
         [in]  BSTR  ProviderName,
         [in, out] DWORD *pdwCount,
         [out, size_is(*pdwCount)] IUnknown **pVal[]
         );    
};

