1 /**
2  * xrdp: A Remote Desktop Protocol server.
3  *
4  * Copyright (C) Jay Sorg 2004-2015
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * libxup main header file
19  */
20 
21 /* include other h files */
22 #include "arch.h"
23 #include "parse.h"
24 #include "os_calls.h"
25 #include "defines.h"
26 #include "log.h"
27 #include "xrdp_client_info.h"
28 #include "xrdp_constants.h"
29 #include "xrdp_rail.h"
30 
31 #define CURRENT_MOD_VER 4
32 
33 struct source_info;
34 
35 struct mod
36 {
37     int size; /* size of this struct */
38     int version; /* internal version */
39     /* client functions */
40     int (*mod_start)(struct mod *v, int w, int h, int bpp);
41     int (*mod_connect)(struct mod *v);
42     int (*mod_event)(struct mod *v, int msg, tbus param1, tbus param2,
43                      tbus param3, tbus param4);
44     int (*mod_signal)(struct mod *v);
45     int (*mod_end)(struct mod *v);
46     int (*mod_set_param)(struct mod *v, const char *name, const char *value);
47     int (*mod_session_change)(struct mod *v, int, int);
48     int (*mod_get_wait_objs)(struct mod *v, tbus *read_objs, int *rcount,
49                              tbus *write_objs, int *wcount, int *timeout);
50     int (*mod_check_wait_objs)(struct mod *v);
51     int (*mod_frame_ack)(struct mod *v, int flags, int frame_id);
52     int (*mod_suppress_output)(struct mod *v, int suppress,
53                                int left, int top, int right, int bottom);
54     int (*mod_server_monitor_resize)(struct mod *v,
55                                      int width, int height);
56     int (*mod_server_monitor_full_invalidate)(struct mod *v,
57             int width, int height);
58     int (*mod_server_version_message)(struct mod *v);
59     tintptr mod_dumby[100 - 14]; /* align, 100 minus the number of mod
60                                  functions above */
61     /* server functions */
62     int (*server_begin_update)(struct mod *v);
63     int (*server_end_update)(struct mod *v);
64     int (*server_fill_rect)(struct mod *v, int x, int y, int cx, int cy);
65     int (*server_screen_blt)(struct mod *v, int x, int y, int cx, int cy,
66                              int srcx, int srcy);
67     int (*server_paint_rect)(struct mod *v, int x, int y, int cx, int cy,
68                              char *data, int width, int height,
69                              int srcx, int srcy);
70     int (*server_set_cursor)(struct mod *v, int x, int y, char *data, char *mask);
71     int (*server_palette)(struct mod *v, int *palette);
72     int (*server_msg)(struct mod *v, const char *msg, int code);
73     int (*server_is_term)(struct mod *v);
74     int (*server_set_clip)(struct mod *v, int x, int y, int cx, int cy);
75     int (*server_reset_clip)(struct mod *v);
76     int (*server_set_fgcolor)(struct mod *v, int fgcolor);
77     int (*server_set_bgcolor)(struct mod *v, int bgcolor);
78     int (*server_set_opcode)(struct mod *v, int opcode);
79     int (*server_set_mixmode)(struct mod *v, int mixmode);
80     int (*server_set_brush)(struct mod *v, int x_origin, int y_origin,
81                             int style, char *pattern);
82     int (*server_set_pen)(struct mod *v, int style,
83                           int width);
84     int (*server_draw_line)(struct mod *v, int x1, int y1, int x2, int y2);
85     int (*server_add_char)(struct mod *v, int font, int character,
86                            int offset, int baseline,
87                            int width, int height, char *data);
88     int (*server_draw_text)(struct mod *v, int font,
89                             int flags, int mixmode, int clip_left, int clip_top,
90                             int clip_right, int clip_bottom,
91                             int box_left, int box_top,
92                             int box_right, int box_bottom,
93                             int x, int y, char *data, int data_len);
94     int (*server_reset)(struct mod *v, int width, int height, int bpp);
95     int (*server_query_channel)(struct mod *v, int index,
96                                 char *channel_name,
97                                 int *channel_flags);
98     int (*server_get_channel_id)(struct mod *v, const char *name);
99     int (*server_send_to_channel)(struct mod *v, int channel_id,
100                                   char *data, int data_len,
101                                   int total_data_len, int flags);
102     int (*server_bell_trigger)(struct mod *v);
103     int (*server_chansrv_in_use)(struct mod *v);
104     /* off screen bitmaps */
105     int (*server_create_os_surface)(struct mod *v, int rdpindex,
106                                     int width, int height);
107     int (*server_switch_os_surface)(struct mod *v, int rdpindex);
108     int (*server_delete_os_surface)(struct mod *v, int rdpindex);
109     int (*server_paint_rect_os)(struct mod *v, int x, int y,
110                                 int cx, int cy,
111                                 int rdpindex, int srcx, int srcy);
112     int (*server_set_hints)(struct mod *v, int hints, int mask);
113     /* rail */
114     int (*server_window_new_update)(struct mod *v, int window_id,
115                                     struct rail_window_state_order *window_state,
116                                     int flags);
117     int (*server_window_delete)(struct mod *v, int window_id);
118     int (*server_window_icon)(struct mod *v,
119                               int window_id, int cache_entry, int cache_id,
120                               struct rail_icon_info *icon_info,
121                               int flags);
122     int (*server_window_cached_icon)(struct mod *v,
123                                      int window_id, int cache_entry,
124                                      int cache_id, int flags);
125     int (*server_notify_new_update)(struct mod *v,
126                                     int window_id, int notify_id,
127                                     struct rail_notify_state_order *notify_state,
128                                     int flags);
129     int (*server_notify_delete)(struct mod *v, int window_id,
130                                 int notify_id);
131     int (*server_monitored_desktop)(struct mod *v,
132                                     struct rail_monitored_desktop_order *mdo,
133                                     int flags);
134     int (*server_set_cursor_ex)(struct mod *v, int x, int y, char *data,
135                                 char *mask, int bpp);
136     int (*server_add_char_alpha)(struct mod *v, int font, int character,
137                                  int offset, int baseline,
138                                  int width, int height, char *data);
139     int (*server_create_os_surface_bpp)(struct mod *v, int rdpindex,
140                                         int width, int height, int bpp);
141     int (*server_paint_rect_bpp)(struct mod *v, int x, int y, int cx, int cy,
142                                  char *data, int width, int height,
143                                  int srcx, int srcy, int bpp);
144     int (*server_composite)(struct mod *v, int srcidx, int srcformat, int srcwidth,
145                             int srcrepeat, int *srctransform, int mskflags, int mskidx,
146                             int mskformat, int mskwidth, int mskrepeat, int op,
147                             int srcx, int srcy, int mskx, int msky,
148                             int dstx, int dsty, int width, int height, int dstformat);
149     int (*server_paint_rects)(struct mod *v,
150                               int num_drects, short *drects,
151                               int num_crects, short *crects,
152                               char *data, int width, int height,
153                               int flags, int frame_id);
154 
155     tintptr server_dumby[100 - 44]; /* align, 100 minus the number of server
156                                      functions above */
157     /* common */
158     tintptr handle; /* pointer to self as long */
159     tintptr wm;
160     tintptr painter;
161     struct source_info *si;
162     /* mod data */
163     int width;
164     int height;
165     int bpp;
166     int sck_closed;
167     char username[INFO_CLIENT_MAX_CB_LEN];
168     char password[INFO_CLIENT_MAX_CB_LEN];
169     char ip[256];
170     char port[256];
171     int shift_state;
172     struct xrdp_client_info client_info;
173     int screen_shmem_id;
174     int screen_shmem_id_mapped; /* boolean */
175     char *screen_shmem_pixels;
176     struct trans *trans;
177 };
178