mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 08:24:16 +09:00
libfreerdp-utils/svc_plugin: add interval feature.
This commit is contained in:
@@ -35,9 +35,12 @@ struct rdp_svc_plugin
|
||||
CHANNEL_ENTRY_POINTS_EX channel_entry_points;
|
||||
CHANNEL_DEF channel_def;
|
||||
|
||||
int interval_ms;
|
||||
|
||||
void (*connect_callback)(rdpSvcPlugin* plugin);
|
||||
void (*receive_callback)(rdpSvcPlugin* plugin, STREAM* data_in);
|
||||
void (*event_callback)(rdpSvcPlugin* plugin, FRDP_EVENT* event);
|
||||
void (*interval_callback)(rdpSvcPlugin* plugin);
|
||||
void (*terminate_callback)(rdpSvcPlugin* plugin);
|
||||
|
||||
rdpSvcPluginPrivate* priv;
|
||||
|
||||
@@ -43,6 +43,7 @@ void freerdp_thread_start(freerdp_thread* thread, void* func, void* arg);
|
||||
void freerdp_thread_stop(freerdp_thread* thread);
|
||||
|
||||
#define freerdp_thread_wait(_t) wait_obj_select(_t->signals, _t->num_signals, -1)
|
||||
#define freerdp_thread_wait_timeout(_t, _timeout) wait_obj_select(_t->signals, _t->num_signals, _timeout)
|
||||
#define freerdp_thread_is_stopped(_t) wait_obj_is_set(_t->signals[0])
|
||||
#define freerdp_thread_quit(_t) _t->status = -1
|
||||
#define freerdp_thread_signal(_t) wait_obj_set(_t->signals[1])
|
||||
|
||||
@@ -237,9 +237,9 @@ static void svc_plugin_process_data_in(rdpSvcPlugin* plugin)
|
||||
{
|
||||
/* the ownership of the data is passed to the callback */
|
||||
if (item->data_in)
|
||||
plugin->receive_callback(plugin, item->data_in);
|
||||
IFCALL(plugin->receive_callback, plugin, item->data_in);
|
||||
if (item->event_in)
|
||||
plugin->event_callback(plugin, item->event_in);
|
||||
IFCALL(plugin->event_callback, plugin, item->event_in);
|
||||
xfree(item);
|
||||
}
|
||||
else
|
||||
@@ -253,17 +253,23 @@ static void* svc_plugin_thread_func(void* arg)
|
||||
|
||||
DEBUG_SVC("in");
|
||||
|
||||
plugin->connect_callback(plugin);
|
||||
IFCALL(plugin->connect_callback, plugin);
|
||||
|
||||
while (1)
|
||||
{
|
||||
freerdp_thread_wait(plugin->priv->thread);
|
||||
if (plugin->interval_ms > 0)
|
||||
freerdp_thread_wait_timeout(plugin->priv->thread, plugin->interval_ms);
|
||||
else
|
||||
freerdp_thread_wait(plugin->priv->thread);
|
||||
|
||||
if (freerdp_thread_is_stopped(plugin->priv->thread))
|
||||
break;
|
||||
|
||||
freerdp_thread_reset(plugin->priv->thread);
|
||||
svc_plugin_process_data_in(plugin);
|
||||
|
||||
if (plugin->interval_ms > 0)
|
||||
IFCALL(plugin->interval_callback, plugin);
|
||||
}
|
||||
|
||||
freerdp_thread_quit(plugin->priv->thread);
|
||||
@@ -314,7 +320,7 @@ static void svc_plugin_process_terminated(rdpSvcPlugin* plugin)
|
||||
xfree(plugin->priv);
|
||||
plugin->priv = NULL;
|
||||
|
||||
plugin->terminate_callback(plugin);
|
||||
IFCALL(plugin->terminate_callback, plugin);
|
||||
}
|
||||
|
||||
static void svc_plugin_init_event(void* pInitHandle, uint32 event, void* pData, uint32 dataLength)
|
||||
|
||||
Reference in New Issue
Block a user