import "oaidl.idl";
import "wtypes.idl";

//
// join flags
// NOTE : High 16 bits are reserved by SB
//
cpp_quote("")
cpp_quote("#define SINGLE_SESSION 0x1") // legacy TS uses this value - so, do NOT change
cpp_quote("#define FORCE_REJOIN 0x2") // legacy TS uses this value - so, do NOT change
cpp_quote("#define FORCE_REJOIN_IN_CLUSTERMODE 0x3")
cpp_quote("#define RESERVED_FOR_LEGACY   0x4") // legacy TS uses this value - so, do NOT change
cpp_quote("#define KEEP_EXISTING_SESSIONS 0x8")
cpp_quote("")

//
// Plugin property strings specific to each plugin.
// These are available to plugins to query (they must be populated by plugin on registration)
//
cpp_quote("")
cpp_quote("#define SBPLUGIN_CLSID_PROP_STR     _T(\"CLSID\")")
cpp_quote("#define SBPLUGIN_ISENABLED_PROP_STR _T(\"IsEnabled\")")
cpp_quote("#define SBPLUGIN_PROVIDER_PROP_STR _T(\"Provider\")")
cpp_quote("")


// these are properties common to all plugins that 
// can be queried and provided to plugins by the broker.
cpp_quote("")
cpp_quote("#define SB_NAME_PROP_STR        _T(\"SbName\")") //bstr
cpp_quote("")

//
// these are properties set/get by SB on a target property set
// for each target
// can be queried and provided to plugins by/to the broker.
//
cpp_quote("")
cpp_quote("#define TARGET_GUID_STR                      _T(\"TargetGuid\")")        // string
cpp_quote("#define TARGET_ENVIRONMENT_STR               _T(\"TargetEnvironment\")") // string
cpp_quote("#define TARGET_ID_PROP_STR                   _T(\"TargetId\")")          // int
cpp_quote("#define FARM_ID_PROP_STR                     _T(\"FarmId\")")            // ulong
cpp_quote("#define TARGET_REPOPULATE                    _T(\"Repopulate\")") // bool
cpp_quote("#define TARGET_SINGLESESSION                 _T(\"SingleSession\")") //bool
cpp_quote("#define TARGET_SERVERCAPABILITY              _T(\"ServerCapability\")") //ulong
cpp_quote("#define TARGET_SERVERINDRAIN                 _T(\"ServerDrain\")") // int
cpp_quote("#define TARGET_CLIENT_CONNECTION_MONITORING  _T(\"TargetClientConnectionMonitoring\")") // bool
cpp_quote("#define TARGET_OWNER_PROP                    _T(\"TargetOwner\")") //long
cpp_quote("#define ENFORCE_SINGLE_SESSION_PER_POOL      _T(\"EnforceSingleSessionPerPool\")") //bool
cpp_quote("")

// These are optional params that plugins can provide
cpp_quote("")
cpp_quote("#define TARGET_SERVERRPC          _T(\"ServerRpcIpAddress\")") //bstr
cpp_quote("")

//
// these are properties set/get by SB on a connection request property set
// for each Connection Request (a.k.a. ITsSbClientConnection)
// can be queried and provided to plugins by/to the broker.
//
cpp_quote("#define CONN_REQUEST_CALLING_SERVER_NAME_STR       _T(\"CallingServerName\")") // string
cpp_quote("#define CONN_REQUEST_IS_CALL_FROM_TS_REDIRECTOR    _T(\"IsCallFromTSRedirector\")") // bool
cpp_quote("#define CONN_REQUEST_CALLING_SERVER_FARM_NAME_STR  _T(\"CallingServerFarmName\")") // string
cpp_quote("#define CONN_REQUEST_TSV_URL_STR                   _T(\"TsvUrl\")") // string
cpp_quote("#define CONN_REQUEST_TARGETTYPE_FROM_TSVURL        _T(\"TargetTypeFromTsvUrl\")") // ulong
cpp_quote("#define CONN_REQUEST_TARGETID_FROM_TSVURL          _T(\"TargetIdFromTsvUrl\")") // string
cpp_quote("#define CONN_REQUEST_RESOURCEPLUGIN_FROM_TSVURL    _T(\"ResourcePluginFromTsvUrl\")") // string
cpp_quote("#define CONN_REQUEST_GUID                          _T(\"ConnectionRequestGUID\")") // VT_ARRRAY | VT_UI1, use VariantToBuffer() to get the GUID
                 
//
// Structs imported from sbtsv.idl
//
typedef [v1_enum] enum 
{
    TSSD_ADDR_UNDEFINED                = 0, 
    TSSD_ADDR_IPv4                     = 4, 
    TSSD_ADDR_IPv6                     = 6,
} TSSD_AddrV46Type;

typedef [v1_enum] enum
{
	TSSB_NOTIFY_INVALID = 0x0,
	TSSB_NOTIFY_TARGET_CHANGE = 0x1,
	TSSB_NOTIFY_SESSION_CHANGE = 0x2,
	TSSB_NOTIFY_CONNECTION_REQUEST_CHANGE = 0x4
} TSSB_NOTIFICATION_TYPE;

typedef [v1_enum] enum 
{
    TARGET_UNKNOWN = 0x1,
    TARGET_INITIALIZING,
    TARGET_RUNNING,
    TARGET_DOWN,
    TARGET_HIBERNATED,
    TARGET_CHECKED_OUT,
    TARGET_STOPPED,
} TARGET_STATE;


typedef [v1_enum] enum 
{
    TARGET_CHANGE_UNSPEC      = 0x1,
    TARGET_EXTERNALIP_CHANGED = 0x2,
    TARGET_INTERNALIP_CHANGED = 0x4,
    TARGET_JOINED             = 0x8,
    TARGET_REMOVED            = 0x10,
    TARGET_STATE_CHANGED      = 0x20,
    TARGET_IDLE               = 0x40
} TARGET_CHANGE_TYPE;

typedef [v1_enum] enum
{ 
    UNKNOWN    = 0,
    FARM       = 1,
    NONFARM    = 2,
} TARGET_TYPE;

typedef [v1_enum] enum
{
    CLIENT_MESSAGE_CONNECTION_INVALID = 0,
    CLIENT_MESSAGE_CONNECTION_STATUS,
    CLIENT_MESSAGE_CONNECTION_ERROR,
} CLIENT_MESSAGE_TYPE;

typedef [v1_enum] enum
{
    CONNECTION_REQUEST_INVALID = 0,
    CONNECTION_REQUEST_PENDING,
    CONNECTION_REQUEST_FAILED,
    CONNECTION_REQUEST_TIMEDOUT,
    CONNECTION_REQUEST_SUCCEEDED,
    CONNECTION_REQUEST_CANCELLED,
} CONNECTION_CHANGE_NOTIFICATION;

typedef [v1_enum] enum
{ 
    UNKNOWN_PLUGIN           = 0,
    POLICY_PLUGIN            = 0x1,
    RESOURCE_PLUGIN          = 0x2,
    LOAD_BALANCING_PLUGIN    = 0x4,
    PLACEMENT_PLUGIN         = 0x8,
    ORCHESTRATION_PLUGIN     = 0x10,
} PLUGIN_TYPE;

typedef [v1_enum] enum 
{
    STATE_INVALID = -1,
    STATE_ACTIVE,              // User logged on to WinStation
    STATE_CONNECTED,           // WinStation connected to client (session reconnected)
    STATE_CONNECTQUERY,        // In the process of connecting to client (session reconnect pending)
    STATE_SHADOW,              // Shadowing another WinStation
    STATE_DISCONNECTED,        // WinStation logged on without client
    STATE_IDLE,                // Waiting for client to connect
    STATE_LISTEN,              // WinStation is listening for connection
    STATE_RESET,               // WinStation is being reset (session logged off)
    STATE_DOWN,                // WinStation is down due to error
    STATE_INIT,                // WinStation in initialization
} TSSESSION_STATE;

//
// Target owner property is added to a target prop set
// So that Filter plugins can filter out targets based on plugin name
typedef [v1_enum] enum
{ 
    OWNER_UNKNOWN           = 0,
    OWNER_MS_TS_PLUGIN      = 0x1,
    OWNER_MS_VM_PLUGIN      = 0x2
} TARGET_OWNER;

typedef struct 
{
    DWORD HorizontalResolution; // horizontal dimensions, in pixels
    DWORD VerticalResolution;   // vertical dimensions, in pixels
    DWORD ColorDepth;           // 1=16, 2=256, 4=64K, 8=16M
} CLIENT_DISPLAY, *PCLIENT_DISPLAY;

typedef struct {
    byte              ServerAddressB[16];
    TSSD_AddrV46Type  AddressType;
    USHORT            PortNumber;
    ULONG             AddressScope;
} TSSD_ConnectionPoint, *PTSSD_ConnectionPoint;

// ---- End of sbtsv data structs ---- 
