session.h 2.78 KB
Newer Older
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
/*
    Copyright (C) 2016  Jeremy White <jwhite@codeweavers.com>
    All rights reserved.

    This file is part of x11spice

    x11spice is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    x11spice is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with x11spice.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SESSION_H_
#define SESSION_H_

#include "options.h"
#include "display.h"
#include "local_spice.h"
Jeremy White's avatar
Jeremy White committed
27
#include "agent.h"
28
#include "gui.h"
29
#include "scan.h"
30 31 32 33

/*----------------------------------------------------------------------------
**  Structure definitions
**--------------------------------------------------------------------------*/
34 35 36 37 38 39 40 41 42
typedef struct session_struct {
    options_t options;
    display_t display;
    spice_t spice;
    agent_t agent;
    gui_t gui;
    scanner_t scanner;
    int running;

43 44 45 46
    int connected;
    int connect_pid;
    int disconnect_pid;

47 48 49 50
#if defined(HAVE_LIBAUDIT_H)
    int audit_id;
#endif

51
    GMutex *lock;
52
    int draw_command_in_progress;
Jeremy White's avatar
Jeremy White committed
53

Jeremy White's avatar
Jeremy White committed
54 55
    GAsyncQueue *cursor_queue;
    GAsyncQueue *draw_queue;
56 57 58 59 60
} session_t;

/*----------------------------------------------------------------------------
**  Prototypes
**--------------------------------------------------------------------------*/
61
int session_create(session_t *s);
62
void session_destroy(session_t *s);
63 64
int session_start(session_t *s);
void session_end(session_t *s);
65
int session_alive(session_t *s);
Jeremy White's avatar
Jeremy White committed
66

Jeremy White's avatar
Jeremy White committed
67 68
void session_handle_resize(session_t *s);

69 70
void *session_pop_draw(session_t *session);
int session_draw_waiting(session_t *session);
Jeremy White's avatar
Jeremy White committed
71 72 73 74

void *session_pop_cursor(session_t *session);
int session_cursor_waiting(session_t *session);

75 76 77 78
void session_handle_key(session_t *session, uint8_t keycode, int is_press);
void session_handle_mouse_position(session_t *session, int x, int y, uint32_t buttons_state);
void session_handle_mouse_buttons(session_t *session, uint32_t buttons_state);
void session_handle_mouse_wheel(session_t *session, int wheel_motion, uint32_t buttons_state);
Jeremy White's avatar
Jeremy White committed
79

80 81
int session_get_one_led(session_t *session, const char *name);

Jeremy White's avatar
Jeremy White committed
82
int session_push_cursor_image(session_t *s,
83 84
                              int x, int y, int w, int h, int xhot, int yhot,
                              int imglen, uint8_t *imgdata);
Jeremy White's avatar
Jeremy White committed
85

Jeremy White's avatar
Jeremy White committed
86 87 88
void session_remote_connected(const char *from);
void session_remote_disconnected(void);

89
void session_disconnect_client(session_t *session);
90
#endif