summaryrefslogtreecommitdiff
path: root/server/common-graphics-channel.h
blob: b19f14138c3ac10fe9c91fc54362f248f38060e6 (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
/*
   Copyright (C) 2009-2016 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 COMMON_GRAPHICS_CHANNEL_H_
#define COMMON_GRAPHICS_CHANNEL_H_

#include <glib-object.h>

#include "red-channel.h"
#include "red-channel-client.h"

G_BEGIN_DECLS

#define COMMON_CLIENT_TIMEOUT (NSEC_PER_SEC * 30)

#define TYPE_COMMON_GRAPHICS_CHANNEL common_graphics_channel_get_type()

#define COMMON_GRAPHICS_CHANNEL(obj) \
    (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_COMMON_GRAPHICS_CHANNEL, CommonGraphicsChannel))
#define COMMON_GRAPHICS_CHANNEL_CLASS(klass) \
    (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_COMMON_GRAPHICS_CHANNEL, CommonGraphicsChannelClass))
#define COMMON_IS_GRAPHICS_CHANNEL(obj) \
    (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_COMMON_GRAPHICS_CHANNEL))
#define COMMON_IS_GRAPHICS_CHANNEL_CLASS(klass) \
    (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_COMMON_GRAPHICS_CHANNEL))
#define COMMON_GRAPHICS_CHANNEL_GET_CLASS(obj) \
    (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_COMMON_GRAPHICS_CHANNEL, CommonGraphicsChannelClass))

struct CommonGraphicsChannelPrivate;

struct CommonGraphicsChannel: public RedChannel
{
    CommonGraphicsChannelPrivate *priv;
};

struct CommonGraphicsChannelClass
{
    RedChannelClass parent_class;
};

GType common_graphics_channel_get_type(void) G_GNUC_CONST;

void common_graphics_channel_set_during_target_migrate(CommonGraphicsChannel *self, gboolean value);
gboolean common_graphics_channel_get_during_target_migrate(CommonGraphicsChannel *self);

enum {
    RED_PIPE_ITEM_TYPE_INVAL_ONE = RED_PIPE_ITEM_TYPE_CHANNEL_BASE,

    RED_PIPE_ITEM_TYPE_COMMON_LAST
};

class CommonGraphicsChannelClient: public RedChannelClient
{
    enum { CHANNEL_RECEIVE_BUF_SIZE = 1024 };
    uint8_t recv_buf[CHANNEL_RECEIVE_BUF_SIZE];

public:
    using RedChannelClient::RedChannelClient;

protected:
    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 bool config_socket() override;
};

G_END_DECLS

#endif /* COMMON_GRAPHICS_CHANNEL_H_ */