source: mainline/uspace/srv/hid/remcons/user.h@ 09f41d3

Last change on this file since 09f41d3 was d3109ff, checked in by Jiri Svoboda <jiri@…>, 9 months ago

Cursor and color control in remote console + RGB

Move vt100 module from output server into separate vt library
Add cursor and color control to remcons using libvt
Add RGB color control to serial console and remote console

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*
2 * Copyright (c) 2024 Jiri Svoboda
3 * Copyright (c) 2012 Vojtech Horky
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup remcons
31 * @{
32 */
33/** @file
34 */
35
36#ifndef TELNET_USER_H_
37#define TELNET_USER_H_
38
39#include <adt/prodcons.h>
40#include <fibril_synch.h>
41#include <inet/tcp.h>
42#include <inttypes.h>
43#include <io/con_srv.h>
44
45#define BUFFER_SIZE 32
46
47/** Representation of a connected (human) user. */
48typedef struct {
49 /** Mutex guarding the whole structure. */
50 fibril_mutex_t guard;
51
52 /** Internal id, used for creating locfs entries. */
53 int id;
54 /** Associated connection. */
55 tcp_conn_t *conn;
56 /** Location service id assigned to the virtual terminal. */
57 service_id_t service_id;
58 /** Path name of the service. */
59 char *service_name;
60 /** Console service setup */
61 con_srvs_t srvs;
62
63 /** Producer-consumer of kbd_event_t. */
64 prodcons_t in_events;
65 link_t link;
66 char socket_buffer[BUFFER_SIZE];
67 size_t socket_buffer_len;
68 size_t socket_buffer_pos;
69
70 /** Task id of the launched application. */
71 task_id_t task_id;
72
73 /* Reference counting. */
74 fibril_condvar_t refcount_cv;
75 bool task_finished;
76 int locsrv_connection_count;
77 bool socket_closed;
78
79 /** X position of the cursor. */
80 int cursor_x;
81 /** Y position of the cursor. */
82 int cursor_y;
83 /** Total number of rows */
84 int rows;
85} telnet_user_t;
86
87extern telnet_user_t *telnet_user_create(tcp_conn_t *);
88extern void telnet_user_add(telnet_user_t *);
89extern void telnet_user_destroy(telnet_user_t *);
90extern telnet_user_t *telnet_user_get_for_client_connection(service_id_t);
91extern bool telnet_user_is_zombie(telnet_user_t *);
92extern void telnet_user_notify_client_disconnected(telnet_user_t *);
93extern errno_t telnet_user_get_next_keyboard_event(telnet_user_t *, kbd_event_t *);
94extern errno_t telnet_user_send_data(telnet_user_t *, const char *, size_t);
95extern errno_t telnet_user_recv(telnet_user_t *, void *, size_t, size_t *);
96extern void telnet_user_update_cursor_x(telnet_user_t *, int);
97
98/** Print informational message about connected user. */
99#ifdef CONFIG_DEBUG
100#define telnet_user_log(user, fmt, ...) \
101 printf(NAME " [console %d (%d)]: " fmt "\n", \
102 user->id, (int) user->service_id, ##__VA_ARGS__)
103#else
104#define telnet_user_log(user, fmt, ...) ((void) 0)
105#endif
106
107/** Print error message associated with connected user. */
108#define telnet_user_error(user, fmt, ...) \
109 fprintf(stderr, NAME " [console %d (%d)]: ERROR: " fmt "\n", \
110 user->id, (int) user->service_id, ##__VA_ARGS__)
111
112#endif
113
114/**
115 * @}
116 */
Note: See TracBrowser for help on using the repository browser.