]>
Commit | Line | Data |
---|---|---|
e3759a34 DM |
1 | #include <glib.h> |
2 | #include <spice.h> | |
22e5ba02 DM |
3 | |
4 | #define IBUFSIZE 1024 | |
5 | #define MAX_ESC_PARAMS 16 | |
6 | ||
e3759a34 | 7 | typedef struct TextAttributes { |
44a22215 DM |
8 | unsigned int fgcol:4; |
9 | unsigned int bgcol:4; | |
10 | unsigned int bold:1; | |
11 | unsigned int uline:1; | |
12 | unsigned int blink:1; | |
13 | unsigned int invers:1; | |
14 | unsigned int unvisible:1; | |
1d11aa12 | 15 | unsigned int selected:1; |
e3759a34 | 16 | } TextAttributes; |
22e5ba02 DM |
17 | |
18 | typedef struct TextCell { | |
44a22215 DM |
19 | gunichar2 ch; |
20 | TextAttributes attrib; | |
22e5ba02 DM |
21 | } TextCell; |
22 | ||
c783f726 | 23 | #define COMMANDS_SIZE (1024) |
baa9598b DM |
24 | #define MAX_HEIGHT 1440 |
25 | #define MAX_WIDTH 2560 | |
e3759a34 | 26 | |
68c2b067 DM |
27 | typedef struct SpiceTermOptions { |
28 | guint timeout; | |
29 | int port; | |
30 | char *addr; | |
7f3ff8c0 | 31 | char *keymap; |
68c2b067 DM |
32 | gboolean noauth; |
33 | gboolean sasl; | |
34 | } SpiceTermOptions; | |
35 | ||
64bc7a2f | 36 | typedef struct SpiceScreen SpiceScreen; |
e3759a34 | 37 | |
e70e45a9 DM |
38 | typedef struct CachedImage { |
39 | uint8_t *bitmap; | |
40 | int cache_id; | |
41 | } CachedImage; | |
42 | ||
64bc7a2f | 43 | struct SpiceScreen { |
e3759a34 DM |
44 | SpiceCoreInterface *core; |
45 | SpiceServer *server; | |
46 | ||
47 | QXLInstance qxl_instance; | |
48 | QXLWorker *qxl_worker; | |
49 | ||
e3759a34 DM |
50 | uint8_t primary_surface[MAX_HEIGHT * MAX_WIDTH * 4]; |
51 | int primary_height; | |
52 | int primary_width; | |
53 | ||
54 | SpiceTimer *conn_timeout_timer; | |
55 | SpiceWatch *mwatch; /* watch master pty */ | |
56 | ||
e3759a34 DM |
57 | // Current mode (set by create_primary) |
58 | int width; | |
59 | int height; | |
60 | ||
b52b9534 DM |
61 | GCond command_cond; |
62 | GMutex command_mutex; | |
e3759a34 DM |
63 | |
64 | int commands_end; | |
65 | int commands_start; | |
66 | struct QXLCommandExt* commands[COMMANDS_SIZE]; | |
67 | ||
e70e45a9 DM |
68 | //cache for glyphs bitmaps |
69 | GHashTable *image_cache; | |
6508981f DM |
70 | |
71 | gboolean cursor_set; | |
e70e45a9 | 72 | |
e3759a34 | 73 | // callbacks |
64bc7a2f DM |
74 | void (*on_client_connected)(SpiceScreen *spice_screen); |
75 | void (*on_client_disconnected)(SpiceScreen *spice_screen); | |
e3759a34 DM |
76 | }; |
77 | ||
68c2b067 | 78 | SpiceScreen* spice_screen_new(SpiceCoreInterface* core, uint32_t width, uint32_t height, SpiceTermOptions *opts); |
e3759a34 | 79 | |
8f53ae81 | 80 | void spice_screen_resize(SpiceScreen *spice_screen, uint32_t width, uint32_t height); |
b052e9c7 | 81 | void spice_screen_draw_char(SpiceScreen *spice_screen, int x, int y, gunichar2 ch, TextAttributes attrib); |
64bc7a2f DM |
82 | void spice_screen_scroll(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2, int src_x, int src_y); |
83 | void spice_screen_clear(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2); | |
64bc7a2f DM |
84 | uint32_t spice_screen_get_width(void); |
85 | uint32_t spice_screen_get_height(void); | |
e3759a34 | 86 | |
d6a5f5a9 | 87 | typedef struct spiceTerm { |
8f53ae81 | 88 | int pty; // pty file descriptor |
22e5ba02 | 89 | |
44a22215 DM |
90 | int width; |
91 | int height; | |
22e5ba02 | 92 | |
44a22215 DM |
93 | int total_height; |
94 | int scroll_height; | |
95 | int y_base; | |
96 | int y_displ; | |
97 | int altbuf:1; | |
98 | ||
99 | unsigned int utf8:1; // utf8 mode | |
05f253a6 | 100 | gunichar utf_char; // used by utf8 parser |
44a22215 DM |
101 | int utf_count; // used by utf8 parser |
102 | ||
103 | TextAttributes default_attrib; | |
104 | ||
105 | TextCell *cells; | |
106 | TextCell *altcells; | |
107 | ||
108 | SpiceScreen *screen; | |
109 | SpiceKbdInstance keyboard_sin; | |
110 | SpiceCharDeviceInstance vdagent_sin; | |
111 | ||
112 | // cursor | |
113 | TextAttributes cur_attrib; | |
114 | TextAttributes cur_attrib_saved; | |
115 | int tty_state; // 0 - normal, 1 - ESC, 2 - CSI | |
116 | int cx; // cursor x position | |
117 | int cy; // cursor y position | |
118 | int cx_saved; // saved cursor x position | |
119 | int cy_saved; // saved cursor y position | |
120 | int esc_buf[MAX_ESC_PARAMS]; | |
121 | int esc_count; | |
122 | int esc_ques; | |
123 | int esc_has_par; | |
124 | char osc_textbuf[4096]; | |
125 | char osc_cmd; | |
126 | int region_top; | |
127 | int region_bottom; | |
128 | ||
129 | unsigned int charset:1; // G0 or G1 | |
130 | unsigned int charset_saved:1; // G0 or G1 | |
131 | unsigned int g0enc:2; | |
132 | unsigned int g0enc_saved:2; | |
133 | unsigned int g1enc:2; | |
134 | unsigned int g1enc_saved:2; | |
135 | unsigned int cur_enc:2; | |
136 | unsigned int cur_enc_saved:2; | |
137 | ||
138 | // input buffer | |
139 | char ibuf[IBUFSIZE]; | |
140 | int ibuf_count; | |
141 | ||
142 | gunichar2 *selection; | |
143 | int selection_len; | |
144 | ||
145 | unsigned int mark_active:1; | |
146 | ||
147 | unsigned int report_mouse:1; | |
148 | ||
149 | } spiceTerm; | |
f424be98 DM |
150 | |
151 | void init_spiceterm(spiceTerm *vt, uint32_t width, uint32_t height); | |
152 | void spiceterm_refresh(spiceTerm *vt); | |
153 | ||
154 | void spiceterm_resize(spiceTerm *vt, uint32_t width, uint32_t height); | |
155 | void spiceterm_virtual_scroll(spiceTerm *vt, int lines); | |
156 | void spiceterm_clear_selection(spiceTerm *vt); | |
157 | void spiceterm_motion_event(spiceTerm *vt, uint32_t x, uint32_t y, | |
158 | uint32_t buttons); | |
159 | ||
160 | void spiceterm_respond_esc(spiceTerm *vt, const char *esc); | |
161 | void spiceterm_respond_data(spiceTerm *vt, int len, uint8_t *data); | |
162 | void spiceterm_update_watch_mask(spiceTerm *vt, gboolean writable); | |
163 | ||
68c2b067 | 164 | spiceTerm *spiceterm_create(uint32_t width, uint32_t height, SpiceTermOptions *opts); |
f424be98 DM |
165 | |
166 | gboolean vdagent_owns_clipboard(spiceTerm *vt); | |
167 | void vdagent_request_clipboard(spiceTerm *vt); | |
168 | void vdagent_grab_clipboard(spiceTerm *vt); | |
169 | ||
1631c5a9 | 170 | int pve_auth_verify(const char *clientip, const char *username, const char *passwd); |
68c2b067 DM |
171 | void pve_auth_set_path(char *path); |
172 | void pve_auth_set_permissions(char *perm); | |
f424be98 | 173 |