/****************************************************************************/
// itssd.idl
//
// Terminal Server Session Directory Interface (ITSSessionDirectory) COM IDL.
//
// Copyright (C) 2000 Microsoft Corporation
/****************************************************************************/

import "basetsd.h";
import "oaidl.idl";


// Max number of disconnected sessions allowed from a disc session query.
#define TSSD_MaxDisconnectedSessions 10


/****************************************************************************/
// TSSD_CreateSessionInfo
//
// Data block passed to session directory that completely identifies a
// new TS session on the local machine. Combined with the local server address
// this information corresponds to a session record in the session directory.
/****************************************************************************/
typedef struct _TSSD_CreateSessionInfo
{
    WCHAR UserName[256];
    WCHAR Domain[128];
    DWORD SessionID;
    DWORD TSProtocol;
    WCHAR ApplicationType[256];
    DWORD ResolutionWidth;
    DWORD ResolutionHeight;
    DWORD ColorDepth;
    FILETIME CreateTime;
} TSSD_CreateSessionInfo, *PTSSD_CreateSessionInfo;


/****************************************************************************/
// TSSD_DisconnectedSessionInfo
//
// Data block that contains required information about disconnected
// sessions.
/****************************************************************************/
typedef struct _TSSD_DisconnectedSessionInfo
{
    WCHAR ServerAddress[64];
    DWORD SessionID;
    DWORD TSProtocol;
    WCHAR ApplicationType[256];
    DWORD ResolutionWidth;
    DWORD ResolutionHeight;
    DWORD ColorDepth;
    FILETIME CreateTime;
    FILETIME DisconnectionTime;
} TSSD_DisconnectedSessionInfo;


/****************************************************************************/
// TSSD_RepopulateSessionInfo
//
// Data block that contains required information about a session of any type.
/****************************************************************************/
typedef struct _TSSD_RepopulateSessionInfo
{
    WCHAR *UserName;
    WCHAR *Domain;
    DWORD SessionID;
    DWORD TSProtocol;
    WCHAR *ApplicationType;
    DWORD ResolutionWidth;
    DWORD ResolutionHeight;
    DWORD ColorDepth;
    DWORD CreateTimeLow;
    DWORD CreateTimeHigh;
    DWORD DisconnectionTimeLow;
    DWORD DisconnectionTimeHigh;
    DWORD State;
} TSSD_RepopulateSessionInfo;


/****************************************************************************/
// TSSD_ReconnectSessionInfo
//
// Data block that contains information that changes on session reconnection,
// used to update the session directory record for that session.
/****************************************************************************/
typedef struct _TSSD_ReconnectSessionInfo
{
    DWORD SessionID;
    DWORD TSProtocol;
    DWORD ResolutionWidth;
    DWORD ResolutionHeight;
    DWORD ColorDepth;
} TSSD_ReconnectSessionInfo;


/****************************************************************************/
// ITSSessionDirectoryEx
/****************************************************************************/
[
    local,
    object,
    uuid(012b47b7-2f06-4154-ad0c-c64bcdf0d512),
    helpstring("ITSSessionDirectoryEx"),
    pointer_default(unique)
]
interface ITSSessionDirectoryEx : IUnknown
{
   [ helpstring("Queries load balance info using server address.") ]
    HRESULT GetLoadBalanceInfo(
            [in, string] LPWSTR LocalServerAddress,
            [out, retval] BSTR* pLBInfo);
};

/****************************************************************************/
// ITSSessionDirectory
/****************************************************************************/
[
    local,
    object,
    uuid(0241e043-1cb6-4716-aa50-6a492049c3f3),
    helpstring("ITSSessionDirectory"),
    pointer_default(unique)
]
interface ITSSessionDirectory : IUnknown
{
    [ helpstring("Initializes the object post-creation.") ]
    HRESULT Initialize(
            [in, string] LPWSTR LocalServerAddress,
            [in, string] LPWSTR StoreServerName,  // Max 64 chars incl. null.
            [in, string] LPWSTR ClusterName,  // Max 64 incl null
            [in, string] LPWSTR OpaqueSettings,  // Max 256 incl null
            DWORD Flags,
            DWORD (*repopfn)() );  // pointer to repopulation function

    [ helpstring("Updates the object with new configuration information.") ]
    HRESULT Update(
            [in, string] LPWSTR LocalServerAddress,
            [in, string] LPWSTR StoreServerName,  // Max 64 chars incl. null.
            [in, string] LPWSTR ClusterName,  // Max 64 incl null
            [in, string] LPWSTR OpaqueSettings,
            DWORD Flags);  // Max 256 incl null

    [ helpstring("Queries disconnected sessions for a given user.") ]
    HRESULT GetUserDisconnectedSessions(
            [in, string] LPWSTR UserName,
            [in, string] LPWSTR Domain,
            [out] DWORD *pNumSessionsReturned,
            [out, length_is(*pNumSessionsReturned)]
                TSSD_DisconnectedSessionInfo SessionBuf[
                TSSD_MaxDisconnectedSessions]);

    [ helpstring("Called on a local-machine session creation.") ]
    HRESULT NotifyCreateLocalSession(TSSD_CreateSessionInfo *pCreateInfo);

    [ helpstring("Called on a local-machine session destruction.") ]
    HRESULT NotifyDestroyLocalSession(DWORD SessionID);

    [ helpstring("Called on a local-machine session disconnection.") ]
    HRESULT NotifyDisconnectLocalSession(DWORD SessionID, FILETIME DiscTime);

    [ helpstring("Called on a local-machine session reconnection.") ]
    HRESULT NotifyReconnectLocalSession(TSSD_ReconnectSessionInfo *pReconnInfo);

    [ helpstring("Called immediately after revectoring client.") ]
    HRESULT NotifyReconnectPending(WCHAR *);

    [ helpstring("Called when repopulating all sessions in the session directory.") ]
    HRESULT Repopulate(DWORD WinStationCount, TSSD_RepopulateSessionInfo *rsi);
};

