| 1 |
/* |
| 2 |
* Copyright (C) 2014 Red Hat, Inc. |
| 3 |
* SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef __COCKPIT_CHANNEL_H__ |
| 7 |
#define __COCKPIT_CHANNEL_H__ |
| 8 |
|
| 9 |
#include <glib-object.h> |
| 10 |
#include <json-glib/json-glib.h> |
| 11 |
|
| 12 |
#include "cockpittransport.h" |
| 13 |
|
| 14 |
G_BEGIN_DECLS |
| 15 |
|
| 16 |
#define COCKPIT_TYPE_CHANNEL (cockpit_channel_get_type ()) |
| 17 |
G_DECLARE_DERIVABLE_TYPE(CockpitChannel, cockpit_channel, COCKPIT, CHANNEL, GObject) |
| 18 |
|
| 19 |
struct _CockpitChannelClass |
| 20 |
{ |
| 21 |
GObjectClass parent_class; |
| 22 |
|
| 23 |
/* signal */ |
| 24 |
|
| 25 |
void (* closed) (CockpitChannel *channel, |
| 26 |
const gchar *problem); |
| 27 |
|
| 28 |
/* vfuncs */ |
| 29 |
|
| 30 |
void (* prepare) (CockpitChannel *channel); |
| 31 |
|
| 32 |
void (* recv) (CockpitChannel *channel, |
| 33 |
GBytes *message); |
| 34 |
|
| 35 |
gboolean (* control) (CockpitChannel *channel, |
| 36 |
const gchar *command, |
| 37 |
JsonObject *options); |
| 38 |
|
| 39 |
void (* close) (CockpitChannel *channel, |
| 40 |
const gchar *problem); |
| 41 |
}; |
| 42 |
|
| 43 |
void cockpit_channel_prepare (CockpitChannel *self); |
| 44 |
|
| 45 |
void cockpit_channel_close (CockpitChannel *self, |
| 46 |
const gchar *problem); |
| 47 |
|
| 48 |
void cockpit_channel_fail (CockpitChannel *self, |
| 49 |
const gchar *problem, |
| 50 |
const gchar *format, |
| 51 |
...) G_GNUC_PRINTF(3, 4); |
| 52 |
|
| 53 |
const gchar * cockpit_channel_get_id (CockpitChannel *self); |
| 54 |
|
| 55 |
CockpitTransport * cockpit_channel_get_transport (CockpitChannel *self); |
| 56 |
|
| 57 |
/* Used by implementations */ |
| 58 |
|
| 59 |
void cockpit_channel_control (CockpitChannel *self, |
| 60 |
const gchar *command, |
| 61 |
JsonObject *message); |
| 62 |
|
| 63 |
void cockpit_channel_ready (CockpitChannel *self, |
| 64 |
JsonObject *message); |
| 65 |
|
| 66 |
void cockpit_channel_send (CockpitChannel *self, |
| 67 |
GBytes *payload, |
| 68 |
gboolean valid_utf8); |
| 69 |
|
| 70 |
JsonObject * cockpit_channel_get_options (CockpitChannel *self); |
| 71 |
|
| 72 |
JsonObject * cockpit_channel_close_options (CockpitChannel *self); |
| 73 |
|
| 74 |
G_END_DECLS |
| 75 |
|
| 76 |
#endif /* __COCKPIT_CHANNEL_H__ */ |