Class
ValentChannel
since: 1.0
Description [src]
class Valent.Channel : Valent.Object {
parent_instance: ValentObject
}
A base class for device connections.
ValentChannel
is a base class for the primary communication channel in
Valent. It is effectively an abstraction layer around a GIOStream
.
Packet Exchange
The core of the KDE Connect protocol is built on the exchange of JSON
packets, similar to JSON-RPC. Packets can be queued concurrently from
different threads with valent_channel_write_packet()
and read
sequentially with valent_channel_read_packet()
.
Packets may contain payload information, allowing devices to negotiate
auxiliary connections. Incoming connections can be accepted by passing the
packet to valent_channel_download()
, or opened by passing the packet
to valent_channel_upload()
.
Implementation Notes
Implementations should override Valent.ChannelClass.download
and
Valent.ChannelClass.upload
to support accepting and opening auxiliary
connections, respectively. If pairing involves exchanging a key, override
Valent.ChannelClass.get_verification_key
. To know when to store persistent
data related to the connection, override Valent.ChannelClass.store_data
.
Available since: 1.0
Instance methods
valent_channel_download_finish
Finish an operation started with valent_channel_download_async()
.
since: 1.0
valent_channel_read_packet_finish
Finish an operation started by valent_channel_read_packet()
.
since: 1.0
valent_channel_upload_finish
Finish an operation started with valent_channel_upload_async()
.
since: 1.0
valent_channel_write_packet_finish
Finish an operation started by valent_channel_write_packet()
.
since: 1.0
Methods inherited from ValentObject (8)
valent_object_chain_cancellable
Chain a cancellable to the object’s cancellable.
since: 1.0
valent_object_destroy
Destroy the object.
since: 1.0
valent_object_in_destruction
Get whether the object is destroyed or in destruction.
since: 1.0
valent_object_lock
Acquire a lock on object
.
since: 1.0
valent_object_notify
Emit GObject::notify
on object
, on the main thread.
since: 1.0
valent_object_notify_by_pspec
Emit GObject::notify
on object
, on the main thread.
since: 1.0
valent_object_ref_cancellable
Get a GCancellable
for the object.
since: 1.0
valent_object_unlock
Release a lock on object
.
since: 1.0
Signals
Signals inherited from ValentObject (1)
Signals inherited from GObject (1)
GObject::notify
The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.
Class structure
struct ValentChannelClass {
ValentObjectClass parent_class;
const char* (* get_verification_key) (
ValentChannel* channel
);
GIOStream* (* download) (
ValentChannel* channel,
JsonNode* packet,
GCancellable* cancellable,
GError** error
);
void (* download_async) (
ValentChannel* channel,
JsonNode* packet,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer user_data
);
GIOStream* (* download_finish) (
ValentChannel* channel,
GAsyncResult* result,
GError** error
);
GIOStream* (* upload) (
ValentChannel* channel,
JsonNode* packet,
GCancellable* cancellable,
GError** error
);
void (* upload_async) (
ValentChannel* channel,
JsonNode* packet,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer user_data
);
GIOStream* (* upload_finish) (
ValentChannel* channel,
GAsyncResult* result,
GError** error
);
void (* store_data) (
ValentChannel* channel,
ValentContext* context
);
}
The virtual function table for ValentChannel
.
Class members
parent_class: ValentObjectClass
- No description available.
get_verification_key: const char* (* get_verification_key) ( ValentChannel* channel )
- No description available.
download: GIOStream* (* download) ( ValentChannel* channel, JsonNode* packet, GCancellable* cancellable, GError** error )
- No description available.
download_async: void (* download_async) ( ValentChannel* channel, JsonNode* packet, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data )
- No description available.
download_finish: GIOStream* (* download_finish) ( ValentChannel* channel, GAsyncResult* result, GError** error )
- No description available.
upload: GIOStream* (* upload) ( ValentChannel* channel, JsonNode* packet, GCancellable* cancellable, GError** error )
- No description available.
upload_async: void (* upload_async) ( ValentChannel* channel, JsonNode* packet, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data )
- No description available.
upload_finish: GIOStream* (* upload_finish) ( ValentChannel* channel, GAsyncResult* result, GError** error )
- No description available.
store_data: void (* store_data) ( ValentChannel* channel, ValentContext* context )
- No description available.
Virtual methods
Valent.ChannelClass.download_async
Open an auxiliary connection, usually to download data.
since: 1.0
Valent.ChannelClass.download_finish
Finish an operation started with valent_channel_download_async()
.
since: 1.0
Valent.ChannelClass.upload_finish
Finish an operation started with valent_channel_upload_async()
.
since: 1.0