mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-07 20:00:20 +00:00
Make all RedChannelClient hierarchy a C++ class. This allows to use virtual methods. Added a normal contructor instead or properties and g_object_new. As we remove GObject conversion macros I added a macro XXX_CAST to create a function to replace the old macro. They will be removed when more type safety is introduced. There's a new SPICE_CXX_GLIB_ALLOCATOR macro in red-common.h. This macro, added to a class define the class allocator allowing to use, in this case, GLib for allocation. This to avoid C++ library dependency and to initialize all structure to 0 (not all fields are manually initialized, will be improved with more encapsulation). Currently the methods are mainly public, access will be modified when more encapsulation (all functions in method) are done. Some classes are now defined in the header, C++ uses access to limit accessibility but for efficiency and type safety/inline and other features require types to be defined in the headers. Some fields were moved from XxxPrivate structure to class, C++ has accessibility. Many destructors are defined as protected to forbid the use of stack, this as these objects uses internal reference counting to have normal pointers. Maybe in the future pointers like std::shared_ptr could be used instead. Reference counting is now implemented very easily using atomic operations. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
70 lines
2.5 KiB
C++
70 lines
2.5 KiB
C++
/*
|
|
Copyright (C) 2009-2015 Red Hat, Inc.
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
This library 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
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef INPUTS_CHANNEL_CLIENT_H_
|
|
#define INPUTS_CHANNEL_CLIENT_H_
|
|
|
|
#include "red-channel-client.h"
|
|
#include "inputs-channel.h"
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
// TODO: RECEIVE_BUF_SIZE used to be the same for inputs_channel and main_channel
|
|
// since it was defined once in reds.c which contained both.
|
|
// Now that they are split we can give a more fitting value for inputs - what
|
|
// should it be?
|
|
#define REDS_AGENT_WINDOW_SIZE 10
|
|
#define REDS_NUM_INTERNAL_AGENT_MESSAGES 1
|
|
|
|
// approximate max receive message size
|
|
#define RECEIVE_BUF_SIZE \
|
|
(4096 + (REDS_AGENT_WINDOW_SIZE + REDS_NUM_INTERNAL_AGENT_MESSAGES) * SPICE_AGENT_MAX_DATA_SIZE)
|
|
|
|
class InputsChannelClient final: public RedChannelClient
|
|
{
|
|
uint8_t recv_buf[RECEIVE_BUF_SIZE];
|
|
public:
|
|
uint16_t motion_count; // XXX private
|
|
|
|
using RedChannelClient::RedChannelClient;
|
|
|
|
virtual uint8_t *alloc_recv_buf(uint16_t type, uint32_t size) override;
|
|
virtual void release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg) override;
|
|
virtual void on_disconnect() override;
|
|
};
|
|
|
|
RedChannelClient* inputs_channel_client_create(RedChannel *channel,
|
|
RedClient *client,
|
|
RedStream *stream,
|
|
RedChannelCapabilities *caps);
|
|
|
|
void inputs_channel_client_on_mouse_motion(InputsChannelClient* self);
|
|
void inputs_channel_client_send_migrate_data(RedChannelClient *rcc,
|
|
SpiceMarshaller *m, RedPipeItem *item);
|
|
void inputs_channel_client_handle_migrate_data(InputsChannelClient *icc, uint16_t motion_count);
|
|
|
|
G_END_DECLS
|
|
|
|
enum {
|
|
RED_PIPE_ITEM_INPUTS_INIT = RED_PIPE_ITEM_TYPE_CHANNEL_BASE,
|
|
RED_PIPE_ITEM_MOUSE_MOTION_ACK,
|
|
RED_PIPE_ITEM_KEY_MODIFIERS,
|
|
RED_PIPE_ITEM_MIGRATE_DATA,
|
|
};
|
|
|
|
#endif /* INPUTS_CHANNEL_CLIENT_H_ */
|