summaryrefslogtreecommitdiff
path: root/gtk/spice-channel.h
blob: 0b1fb258e3adcc7ba3f194ce9b390e1c689a3b6b (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
G_BEGIN_DECLS

#define SPICE_TYPE_CHANNEL            (spice_channel_get_type ())
#define SPICE_CHANNEL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPICE_TYPE_CHANNEL, SpiceChannel))
#define SPICE_CHANNEL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SPICE_TYPE_CHANNEL, SpiceChannelClass))
#define SPICE_IS_CHANNEL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPICE_TYPE_CHANNEL))
#define SPICE_IS_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPICE_TYPE_CHANNEL))
#define SPICE_CHANNEL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), SPICE_TYPE_CHANNEL, SpiceChannelClass))

enum SpiceChannelEvent {
    SPICE_CHANNEL_OPENED = 10,
    SPICE_CHANNEL_CLOSED,
    SPICE_CHANNEL_ERROR_CONNECT = 20,
    SPICE_CHANNEL_ERROR_AUTH,
    SPICE_CHANNEL_ERROR_IO,
};

struct _SpiceChannel
{
    GObject parent;
    spice_channel *priv;
    /* Do not add fields to this struct */
};

struct _SpiceChannelClass
{
    GObjectClass parent_class;

    /* common signals */
    void (*spice_channel_event)(SpiceChannel *channel, enum SpiceChannelEvent event);

    /* main signals */
    void (*spice_main_mouse_mode)(SpiceChannel *channel, enum SpiceMouseMode mode);

    /* display signals */
    void (*spice_display_primary_create)(SpiceChannel *channel, gint format,
                                         gint width, gint height, gint stride,
                                         gint shmid, gpointer data);
    void (*spice_display_primary_destroy)(SpiceChannel *channel);
    void (*spice_display_invalidate)(SpiceChannel *channel,
                                     gint x, gint y, gint w, gint h);

    /* cursor signals */
    void (*spice_cursor_set)(SpiceChannel *channel, gint width, gint height,
                             gint hot_x, gint hot_y, gpointer rgba);

#if 0
    /*
     * If adding fields to this struct, remove corresponding
     * amount of padding to avoid changing overall struct size
     */
    gpointer _spice_reserved[42];
#endif
};

GType spice_channel_get_type(void) G_GNUC_CONST;

G_END_DECLS

typedef struct spice_msg_in  spice_msg_in;
typedef struct spice_msg_out spice_msg_out;

typedef void (*spice_msg_handler)(SpiceChannel *channel, spice_msg_in *in);
typedef void (*spice_channel_func)(SpiceChannel *channel);
typedef struct spice_channel_info spice_channel_info;

SpiceChannel *spice_channel_new(SpiceSession *s, spice_channel_info *info, int id);
gboolean spice_channel_connect(SpiceChannel *channel);
void spice_channel_disconnect(SpiceChannel *channel, enum SpiceChannelEvent event);
int spice_channel_type(SpiceChannel *channel);
int spice_channel_id(SpiceChannel *channel);

enum SpiceMouseMode spice_main_get_mouse_mode(SpiceChannel *channel);
void spice_main_set_display(SpiceChannel *channel, int id,
                            int x, int y, int width, int height);

void spice_inputs_motion(SpiceChannel *channel, gint dx, gint dy, gint button_state);
void spice_inputs_position(SpiceChannel *channel, gint x, gint y,
                           gint display, gint button_state);
void spice_inputs_button_press(SpiceChannel *channel, gint button, gint button_state);
void spice_inputs_button_release(SpiceChannel *channel, gint button, gint button_state);
void spice_inputs_key_press(SpiceChannel *channel, guint keyval);
void spice_inputs_key_release(SpiceChannel *channel, guint keyval);

spice_msg_in *spice_msg_in_new(SpiceChannel *channel);
void spice_msg_in_get(spice_msg_in *in);
void spice_msg_in_put(spice_msg_in *in);
void *spice_msg_in_parsed(spice_msg_in *in);
void spice_msg_in_hexdump(spice_msg_in *in);

spice_msg_out *spice_msg_out_new(SpiceChannel *channel, int type);
void spice_msg_out_get(spice_msg_out *out);
void spice_msg_out_put(spice_msg_out *out);
void spice_msg_out_send(spice_msg_out *out);
void spice_msg_out_hexdump(spice_msg_out *out, unsigned char *data, int len);