Add GetRdpContext function pointer for dynamic channels

This commit is contained in:
akallabeth 2022-06-22 12:54:58 +02:00 committed by akallabeth
parent 90ce22283d
commit 5b163b7918
8 changed files with 32 additions and 21 deletions

View File

@ -1026,8 +1026,7 @@ UINT audin_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
audin->iface.Attached = audin_plugin_attached;
audin->iface.Detached = audin_plugin_detached;
args = pEntryPoints->GetPluginData(pEntryPoints);
audin->rdpcontext =
((freerdp*)((rdpSettings*)pEntryPoints->GetRdpSettings(pEntryPoints))->instance)->context;
audin->rdpcontext = pEntryPoints->GetRdpContext(pEntryPoints);
if (args)
{

View File

@ -172,9 +172,19 @@ static const ADDIN_ARGV* dvcman_get_plugin_data(IDRDYNVC_ENTRY_POINTS* pEntryPoi
return ((DVCMAN_ENTRY_POINTS*)pEntryPoints)->args;
}
static void* dvcman_get_rdp_settings(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
static rdpContext* dvcman_get_rdp_context(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
{
return (void*)((DVCMAN_ENTRY_POINTS*)pEntryPoints)->settings;
DVCMAN_ENTRY_POINTS* entry = (DVCMAN_ENTRY_POINTS*)pEntryPoints;
WINPR_ASSERT(entry);
return entry->context;
}
static rdpSettings* dvcman_get_rdp_settings(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
{
rdpContext* context = dvcman_get_rdp_context(pEntryPoints);
WINPR_ASSERT(context);
return context->settings;
}
static UINT32 dvcman_get_channel_id(IWTSVirtualChannel* channel)
@ -280,23 +290,28 @@ fail:
* @return 0 on success, otherwise a Win32 error code
*/
static UINT dvcman_load_addin(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChannelMgr,
const ADDIN_ARGV* args, rdpSettings* settings)
const ADDIN_ARGV* args, rdpContext* context)
{
DVCMAN_ENTRY_POINTS entryPoints;
PDVC_PLUGIN_ENTRY pDVCPluginEntry = NULL;
WINPR_ASSERT(drdynvc);
WINPR_ASSERT(pChannelMgr);
WINPR_ASSERT(args);
WINPR_ASSERT(context);
WLog_Print(drdynvc->log, WLOG_INFO, "Loading Dynamic Virtual Channel %s", args->argv[0]);
pDVCPluginEntry = (PDVC_PLUGIN_ENTRY)freerdp_load_channel_addin_entry(
args->argv[0], NULL, NULL, FREERDP_ADDIN_CHANNEL_DYNAMIC);
if (pDVCPluginEntry)
{
DVCMAN_ENTRY_POINTS entryPoints = { 0 };
entryPoints.iface.RegisterPlugin = dvcman_register_plugin;
entryPoints.iface.GetPlugin = dvcman_get_plugin;
entryPoints.iface.GetPluginData = dvcman_get_plugin_data;
entryPoints.iface.GetRdpSettings = dvcman_get_rdp_settings;
entryPoints.iface.GetRdpContext = dvcman_get_rdp_context;
entryPoints.dvcman = (DVCMAN*)pChannelMgr;
entryPoints.args = args;
entryPoints.settings = settings;
entryPoints.context = context;
return pDVCPluginEntry(&entryPoints.iface);
}
@ -1520,7 +1535,7 @@ static UINT drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVO
index++)
{
const ADDIN_ARGV* args = settings->DynamicChannelArray[index];
error = dvcman_load_addin(drdynvc, drdynvc->channel_mgr, args, settings);
error = dvcman_load_addin(drdynvc, drdynvc->channel_mgr, args, drdynvc->rdpcontext);
if (CHANNEL_RC_OK != error)
goto error;

View File

@ -67,7 +67,7 @@ typedef struct
DVCMAN* dvcman;
const ADDIN_ARGV* args;
rdpSettings* settings;
rdpContext* context;
} DVCMAN_ENTRY_POINTS;
typedef struct

View File

@ -1467,9 +1467,7 @@ UINT rdpei_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
rdpei->previousFrameTime = 0;
rdpei->maxTouchContacts = MAX_CONTACTS;
rdpei->maxPenContacts = MAX_PEN_CONTACTS;
rdpei->rdpcontext =
((freerdp*)((rdpSettings*)pEntryPoints->GetRdpSettings(pEntryPoints))->instance)
->context;
rdpei->rdpcontext = pEntryPoints->GetRdpContext(pEntryPoints);
context = (RdpeiClientContext*)calloc(1, sizeof(RdpeiClientContext));

View File

@ -2399,8 +2399,7 @@ UINT rdpgfx_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
if (!gfx)
{
context =
rdpgfx_client_context_new((rdpSettings*)pEntryPoints->GetRdpSettings(pEntryPoints));
context = rdpgfx_client_context_new(pEntryPoints->GetRdpSettings(pEntryPoints));
if (!context)
{

View File

@ -365,9 +365,7 @@ UINT sshagent_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
sshagent->iface.Connected = NULL;
sshagent->iface.Disconnected = NULL;
sshagent->iface.Terminated = sshagent_plugin_terminated;
sshagent->rdpcontext =
((freerdp*)((rdpSettings*)pEntryPoints->GetRdpSettings(pEntryPoints))->instance)
->context;
sshagent->rdpcontext = pEntryPoints->GetRdpContext(pEntryPoints);
status = pEntryPoints->RegisterPlugin(pEntryPoints, "sshagent", &sshagent->iface);
}

View File

@ -575,9 +575,7 @@ UINT tsmf_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
tsmf->iface.Connected = NULL;
tsmf->iface.Disconnected = NULL;
tsmf->iface.Terminated = tsmf_plugin_terminated;
tsmf->rdpcontext =
((freerdp*)((rdpSettings*)pEntryPoints->GetRdpSettings(pEntryPoints))->instance)
->context;
tsmf->rdpcontext = pEntryPoints->GetRdpContext(pEntryPoints);
context = (TsmfClientContext*)calloc(1, sizeof(TsmfClientContext));
if (!context)

View File

@ -139,6 +139,9 @@ struct s_IWTSVirtualChannelCallback
};
/* The DVC Plugin entry points */
typedef struct rdp_context rdpContext; /* forward declaration, necessary to avoid
* circular includes */
typedef struct S_IDRDYNVC_ENTRY_POINTS IDRDYNVC_ENTRY_POINTS;
struct S_IDRDYNVC_ENTRY_POINTS
{
@ -146,7 +149,8 @@ struct S_IDRDYNVC_ENTRY_POINTS
(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const char* name, IWTSPlugin* pPlugin);
IWTSPlugin* (*GetPlugin)(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const char* name);
const ADDIN_ARGV* (*GetPluginData)(IDRDYNVC_ENTRY_POINTS* pEntryPoints);
void* (*GetRdpSettings)(IDRDYNVC_ENTRY_POINTS* pEntryPoints);
rdpSettings* (*GetRdpSettings)(IDRDYNVC_ENTRY_POINTS* pEntryPoints);
rdpContext* (*GetRdpContext)(IDRDYNVC_ENTRY_POINTS* pEntryPoints);
};
typedef UINT (*PDVC_PLUGIN_ENTRY)(IDRDYNVC_ENTRY_POINTS*);