Next: Reader Plugin API, Previous: Building and Installing, Up: Writing Plugins [Contents]
Override on STCSTransportClass:
configureParse the transport’s XML children; return FALSE on error.
start_writeBegin one write. The base class guarantees at most one in flight. When
done, call stcs_transport_finish_write() or
stcs_transport_finish_write_error() with the same op_id.
The GBytes remains valid until finish.
For reads, emit stcs_transport_emit_data_ready() with the payload,
or stcs_transport_emit_data_error() on failure. Writers enqueue
via stcs_transport_write() (queue depth 1).
G_DECLARE_FINAL_TYPE (MyTransport, my_transport,
MY, TRANSPORT, STCSTransport)
static gboolean
my_transport_configure (STCSTransport *t,
xmlNodePtr node,
GError **error)
{
/* parse <path>, <mode>, … from node */
return TRUE;
}
static void
my_transport_start_write (STCSTransport *t,
guint64 op_id,
GBytes *data)
{
/* send bytes; then: */
stcs_transport_finish_write (t, op_id,
g_bytes_get_size (data));
}
/* On a successful read: */
/* stcs_transport_emit_data_ready (t, bytes); */
static void
my_transport_class_init (MyTransportClass *klass)
{
STCSTransportClass *tc = STCS_TRANSPORT_CLASS (klass);
tc->configure = my_transport_configure;
tc->start_write = my_transport_start_write;
}
G_MODULE_EXPORT STCSPluginInfo *
stcs_plugin_get_info (void)
{
return stcs_plugin_info_new ("my-transport",
STCS_PLUGIN_CATEGORY_TRANSPORT,
"0.1.0");
}