cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

dvc.h (5720B)


      1/**
      2 * FreeRDP: A Remote Desktop Protocol Implementation
      3 * Dynamic Virtual Channel Interface
      4 *
      5 * Copyright 2010-2011 Vic Lee
      6 * Copyright 2015 Thincast Technologies GmbH
      7 * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
      8 *
      9 * Licensed under the Apache License, Version 2.0 (the "License");
     10 * you may not use this file except in compliance with the License.
     11 * You may obtain a copy of the License at
     12 *
     13 *     http://www.apache.org/licenses/LICENSE-2.0
     14 *
     15 * Unless required by applicable law or agreed to in writing, software
     16 * distributed under the License is distributed on an "AS IS" BASIS,
     17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     18 * See the License for the specific language governing permissions and
     19 * limitations under the License.
     20 */
     21
     22/**
     23 * DVC Plugin API: See the original MS DVC Client API:
     24 * http://msdn.microsoft.com/en-us/library/bb540880%28v=VS.85%29.aspx
     25 *
     26 * The FreeRDP DVC Plugin API is a simulation of the MS DVC Client API in C.
     27 * The main difference is that every interface method must take an instance
     28 * pointer as the first parameter.
     29 */
     30
     31/**
     32 * Implemented by DRDYNVC:
     33 * o IWTSVirtualChannelManager
     34 * o IWTSListener
     35 * o IWTSVirtualChannel
     36 *
     37 * Implemented by DVC plugin:
     38 * o IWTSPlugin
     39 * o IWTSListenerCallback
     40 * o IWTSVirtualChannelCallback
     41 *
     42 * A basic DVC plugin implementation:
     43 * 1. DVCPluginEntry:
     44 *    The plugin entry point, which creates and initializes a new IWTSPlugin
     45 *    instance
     46 * 2. IWTSPlugin.Initialize:
     47 *    Call IWTSVirtualChannelManager.CreateListener with a newly created
     48 *    IWTSListenerCallback instance
     49 * 3. IWTSListenerCallback.OnNewChannelConnection:
     50 *    Create IWTSVirtualChannelCallback instance if the new channel is accepted
     51 */
     52
     53#ifndef FREERDP_DVC_H
     54#define FREERDP_DVC_H
     55
     56#include <freerdp/types.h>
     57#include <freerdp/addin.h>
     58
     59typedef struct _IWTSVirtualChannelManager IWTSVirtualChannelManager;
     60typedef struct _IWTSListener IWTSListener;
     61typedef struct _IWTSVirtualChannel IWTSVirtualChannel;
     62
     63typedef struct _IWTSPlugin IWTSPlugin;
     64typedef struct _IWTSListenerCallback IWTSListenerCallback;
     65typedef struct _IWTSVirtualChannelCallback IWTSVirtualChannelCallback;
     66
     67struct _IWTSListener
     68{
     69	/* Retrieves the listener-specific configuration. */
     70	UINT (*GetConfiguration)(IWTSListener* pListener, void** ppPropertyBag);
     71
     72	void* pInterface;
     73};
     74
     75struct _IWTSVirtualChannel
     76{
     77	/* Starts a write request on the channel. */
     78	UINT (*Write)(IWTSVirtualChannel* pChannel, ULONG cbSize, const BYTE* pBuffer, void* pReserved);
     79	/* Closes the channel. */
     80	UINT (*Close)(IWTSVirtualChannel* pChannel);
     81};
     82
     83struct _IWTSVirtualChannelManager
     84{
     85	/* Returns an instance of a listener object that listens on a specific
     86	   endpoint, or creates a static channel. */
     87	UINT(*CreateListener)
     88	(IWTSVirtualChannelManager* pChannelMgr, const char* pszChannelName, ULONG ulFlags,
     89	 IWTSListenerCallback* pListenerCallback, IWTSListener** ppListener);
     90	/* Find the channel or ID to send data to a specific endpoint. */
     91	UINT32 (*GetChannelId)(IWTSVirtualChannel* channel);
     92	IWTSVirtualChannel* (*FindChannelById)(IWTSVirtualChannelManager* pChannelMgr,
     93	                                       UINT32 ChannelId);
     94	const char* (*GetChannelName)(IWTSVirtualChannel* channel);
     95	UINT (*DestroyListener)(IWTSVirtualChannelManager* pChannelMgr, IWTSListener* ppListener);
     96};
     97
     98struct _IWTSPlugin
     99{
    100	/* Used for the first call that is made from the client to the plug-in. */
    101	UINT (*Initialize)(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr);
    102	/* Notifies the plug-in that the Remote Desktop Connection (RDC) client
    103	   has successfully connected to the Remote Desktop Session Host (RD
    104	   Session Host) server. */
    105	UINT (*Connected)(IWTSPlugin* pPlugin);
    106	/* Notifies the plug-in that the Remote Desktop Connection (RDC) client
    107	   has disconnected from the RD Session Host server. */
    108	UINT (*Disconnected)(IWTSPlugin* pPlugin, DWORD dwDisconnectCode);
    109	/* Notifies the plug-in that the Remote Desktop Connection (RDC) client
    110	   has terminated. */
    111	UINT (*Terminated)(IWTSPlugin* pPlugin);
    112
    113	UINT (*Attached)(IWTSPlugin* pPlugin);
    114
    115	UINT (*Detached)(IWTSPlugin* pPlugin);
    116
    117	/* Extended */
    118
    119	void* pInterface;
    120};
    121
    122struct _IWTSListenerCallback
    123{
    124	/* Accepts or denies a connection request for an incoming connection to
    125	   the associated listener. */
    126	UINT(*OnNewChannelConnection)
    127	(IWTSListenerCallback* pListenerCallback, IWTSVirtualChannel* pChannel, BYTE* Data,
    128	 BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback);
    129};
    130
    131struct _IWTSVirtualChannelCallback
    132{
    133	/* Notifies the user about data that is being received. */
    134	UINT (*OnDataReceived)(IWTSVirtualChannelCallback* pChannelCallback, wStream* data);
    135	/* Notifies the user that the channel has been opened. */
    136	UINT (*OnOpen)(IWTSVirtualChannelCallback* pChannelCallback);
    137	/* Notifies the user that the channel has been closed. */
    138	UINT (*OnClose)(IWTSVirtualChannelCallback* pChannelCallback);
    139};
    140
    141/* The DVC Plugin entry points */
    142typedef struct _IDRDYNVC_ENTRY_POINTS IDRDYNVC_ENTRY_POINTS;
    143struct _IDRDYNVC_ENTRY_POINTS
    144{
    145	UINT(*RegisterPlugin)
    146	(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const char* name, IWTSPlugin* pPlugin);
    147	IWTSPlugin* (*GetPlugin)(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const char* name);
    148	ADDIN_ARGV* (*GetPluginData)(IDRDYNVC_ENTRY_POINTS* pEntryPoints);
    149	void* (*GetRdpSettings)(IDRDYNVC_ENTRY_POINTS* pEntryPoints);
    150};
    151
    152typedef UINT (*PDVC_PLUGIN_ENTRY)(IDRDYNVC_ENTRY_POINTS*);
    153
    154void* get_callback_by_name(const char* name, void** context);
    155void add_callback_by_name(const char* name, void* fkt, void* context);
    156void remove_callback_by_name(const char* name, void* context);
    157
    158#endif /* FREERDP_DVC_H */