]> git.proxmox.com Git - spiceterm.git/blob - spiceterm.h
updates for debian jessie
[spiceterm.git] / spiceterm.h
1 #include <glib.h>
2 #include <spice.h>
3
4 #define IBUFSIZE 1024
5 #define MAX_ESC_PARAMS 16
6
7 typedef struct TextAttributes {
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;
15 unsigned int selected:1;
16 } TextAttributes;
17
18 typedef struct TextCell {
19 gunichar2 ch;
20 TextAttributes attrib;
21 } TextCell;
22
23 #define COMMANDS_SIZE (1024)
24 #define MAX_HEIGHT 1440
25 #define MAX_WIDTH 2560
26
27 typedef struct SpiceTermOptions {
28 guint timeout;
29 int port;
30 char *addr;
31 char *keymap;
32 gboolean noauth;
33 gboolean sasl;
34 } SpiceTermOptions;
35
36 typedef struct SpiceScreen SpiceScreen;
37
38 typedef struct CachedImage {
39 uint8_t *bitmap;
40 int cache_id;
41 } CachedImage;
42
43 struct SpiceScreen {
44 SpiceCoreInterface *core;
45 SpiceServer *server;
46
47 QXLInstance qxl_instance;
48 QXLWorker *qxl_worker;
49
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
57 // Current mode (set by create_primary)
58 int width;
59 int height;
60
61 GCond command_cond;
62 GMutex command_mutex;
63
64 int commands_end;
65 int commands_start;
66 struct QXLCommandExt* commands[COMMANDS_SIZE];
67
68 //cache for glyphs bitmaps
69 GHashTable *image_cache;
70
71 gboolean cursor_set;
72
73 // callbacks
74 void (*on_client_connected)(SpiceScreen *spice_screen);
75 void (*on_client_disconnected)(SpiceScreen *spice_screen);
76 };
77
78 SpiceScreen* spice_screen_new(SpiceCoreInterface* core, uint32_t width, uint32_t height, SpiceTermOptions *opts);
79
80 void spice_screen_resize(SpiceScreen *spice_screen, uint32_t width, uint32_t height);
81 void spice_screen_draw_char(SpiceScreen *spice_screen, int x, int y, gunichar2 ch, TextAttributes attrib);
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);
84 uint32_t spice_screen_get_width(void);
85 uint32_t spice_screen_get_height(void);
86
87 typedef struct spiceTerm {
88 int pty; // pty file descriptor
89
90 int width;
91 int height;
92
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
100 gunichar utf_char; // used by utf8 parser
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;
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
164 spiceTerm *spiceterm_create(uint32_t width, uint32_t height, SpiceTermOptions *opts);
165
166 gboolean vdagent_owns_clipboard(spiceTerm *vt);
167 void vdagent_request_clipboard(spiceTerm *vt);
168 void vdagent_grab_clipboard(spiceTerm *vt);
169
170 int pve_auth_verify(const char *clientip, const char *username, const char *passwd);
171 void pve_auth_set_path(char *path);
172 void pve_auth_set_permissions(char *perm);
173