summaryrefslogtreecommitdiff
path: root/src/core/include/webrdp_core_api.h
blob: 36ef9480dcc830bd1ebc047ba0d1ad312cdfa713 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#pragma once
/* API functions exported by core which can be used in backend modules will
 * be defined here.
 */

#include "webrdp_api_shared_structures.h"
#include "webrdp_api_utils.h"

typedef struct
{
	/* Send text message */
	void (*send_text_msg)(const char *msg, void *task_info);

	/* Send text info message */
	void (*send_text_info_msg)(const char *msg, void *task_info);

	/* Send text warning message */
	void (*send_text_warning_msg)(const char *msg, void *task_info);

	/* Send text debug message */
	void (*send_text_debug_msg)(const char *msg, void *task_info);

	/* Send error message, this also causing disconnect
	 * TODO: do not send termination message on errors, use this instead
	 * OR disable automatic disconnect on errors
	 */
	void (*send_error_msg)(const char *msg, void *task_info);

	/* Send control message to js client
	 * TODO: do we need to provide it for backend modules ?
	 */
	void (*send_ctl_msg)(const char *msg, void *task_info);

	/* Send session termination message on quit */
	void (*send_termination_msg)(void *task_info);
} wrdp_core_cb_msgs;

typedef struct
{
	void (*send_begin_paint)(void *task_info);
	void (*send_end_paint)(void *task_info);

	/* Single bitmap */
	void (*send_bitmap)(const wrdp_core_display_bmp *bmp, uint8_t *bmp_data,
	    void *task_info);

	/* Primary: OPAQUE_RECT_ORDER */
	void (*send_opaque_rect_order)(
	    const wrdp_core_display_opaque_rect_order *oro, void *task_info);

	/* SetBounds */
	void (*send_set_bounds)(
	    const wrdp_core_display_bounds *bounds, void *task_info);

	/* PatBlt */
	void (*send_pat_blt)(
	    const wrdp_core_display_patblt_order *patblt, void *task_info);

	/* Multi Opaque rect */
	void (*send_multi_opaque_rect)(
	    const wrdp_core_display_m_opaque_rect *mrect, void *task_info);

	/* ScrBlt */
	void (*send_scr_blt)(
	    const wrdp_core_display_scr_blt *scr_blt, void *task_info);

	/* PTR_NEW
	 * uint32_t id, xhot, yhot
	 */
	void (*send_ptr_new)(
	    const wrdp_core_display_cursor_info *ptr, void *task_info);

	/* PTR_FREE
	 * uint32_t id
	 */
	void (*send_ptr_free)(uint32_t ptr_id, void *task_info);

	/* PTR_SET
	 * uint32_t id
	 */
	void (*send_ptr_set)(uint32_t ptr_id, void *task_info);

	/* PTR_SETNULL
	 */
	void (*send_ptr_set_null)(void *task_info);

	/* PTR_SETDEFAULT
	 */
	void (*send_ptr_set_default)(void *task_info);

} wrdp_core_cb_paint;

typedef struct
{
	/* DRAFT! */
	/* TODO: */

	/*
	 * uint8_t* wrdp_enum_clip_format array
	 */
	void (*clipboard_changed)(
	    uint8_t *fmts, size_t fmts_count, void *task_info);

	/*
	 * clipboard data array
	 */
	void (*send_data)(uint8_t *buf, size_t buf_size, void *task_info);

	/*
	 * request clipboard data from client
	 */
	void (*request_data)(uint8_t data_fmt, void *task_info);

} wrdp_core_cb_clipboard;

typedef struct
{
	/* DRAFT! */

	/*
	 * TODO:
	 */

	void (*ft_request)(
	    const wrdp_backend_ft_file_request *req, void *task_info);

	/*
	 * TODO:
	 */
	void (*ft_send_chunk)(
	    const wrdp_backend_ft_chunk *chunk, uint8_t *data, void *task_info);

	/*
	 * TODO:
	 */
	void (*ft_finish)(
	    const wrdp_backend_ft_status *status, void *task_info);

} wrdp_core_cb_filetransfer;

typedef struct
{
	/* access to variables allocated by core: */

	/* get libev ev_loop* for calling thread */
	void *(*get_libev_loop)(void *task_info);

	/* task runtime state functions: */

	/* inform core about task is finished */
	void (*task_finished)(bool success, void *task_info);

	/* reset task idle time to 0 */
	void (*reset_idle)();
} wrdp_core_cb_core;

typedef struct
{
	/* print raw data buffer to stdout */
	void (*hex_print)(const uint8_t *buf, size_t buf_len);

	/* print log message, currently only stdout is supported */
	void (*log_msg)(const uint8_t *buf, size_t buf_len,
	    wrdp_log_level_e type, uint16_t flags);
	/* print log message extended, currently only stdout is supported */
	void (*log_msg_ex)(log_msg_info *i);
} wrdp_core_cb_utils;

typedef struct
{
	/* client<>server protocol functions: */
	wrdp_core_cb_msgs *api_msgs;

	/* Painting functions: */
	wrdp_core_cb_paint *api_paint;

	wrdp_core_cb_core *api_core;

	wrdp_core_cb_clipboard *api_clipboard;

	wrdp_core_cb_filetransfer *api_filetransfers;

	wrdp_core_cb_utils *api_utils;

} wrdp_core_exports;