Waltham  0.1.0
waltham-connection.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 DENSO CORPORATION
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #ifndef WALTHAM_CONNECTION_H
25 #define WALTHAM_CONNECTION_H
26 
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <unistd.h>
30 #include <sys/types.h>
31 #include <sys/socket.h>
32 
33 #include <waltham-object.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
86 struct wth_connection;
87 
88 
108 struct wth_connection *
109 wth_connect_to_server(const char *host, const char *port);
110 
127 struct wth_connection *
128 wth_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
129 
137 };
138 
157 struct wth_connection *
159 
174 int
176 
189 void
191 
212 int
214 
234 int
235 wth_connection_read(struct wth_connection *conn);
236 
260 int
262 
285 int
287 
301 void
302 wth_connection_set_error(struct wth_connection *conn, int err);
303 
315 void
316 wth_connection_set_protocol_error(struct wth_connection *conn,
317  uint32_t object_id,
318  const char *interface,
319  uint32_t error_code);
320 
332 int
334 
352 uint32_t
354  const char **interface,
355  uint32_t *object_id);
356 
368 struct wthp_registry *
370 
382 struct wthp_callback *
383 wth_connection_sync(struct wth_connection *conn);
384 
403 typedef void (*wth_registry_callback_func)(struct wthp_registry *registry,
404  void *user_data);
405 
421 void
423  wth_registry_callback_func registry_callback,
424  void *user_data);
425 
435 void
437 
438 #ifdef __cplusplus
439 }
440 #endif
441 
442 #endif
void wth_connection_post_error_no_memory(struct wth_connection *conn)
Post an out of memory display error.
Client-side object.
Definition: waltham-connection.h:135
struct wthp_registry * wth_connection_create_registry(struct wth_connection *conn)
Creates a new registry using the internal wth_display.
int wth_connection_dispatch(struct wth_connection *conn)
Dispatch incoming messages.
A Waltham connection.
void wth_connection_set_registry_callback(struct wth_connection *conn, wth_registry_callback_func registry_callback, void *user_data)
Set the callback to be called once a client creates a registry.
struct wth_connection * wth_connection_from_fd(int fd, enum wth_connection_side side)
Use an already connected socket.
Server-side object.
Definition: waltham-connection.h:136
int wth_connection_roundtrip(struct wth_connection *conn)
Make a roundtrip from a client.
struct wth_connection * wth_connect_to_server(const char *host, const char *port)
Connect to a remote Waltham server.
uint32_t wth_connection_get_protocol_error(struct wth_connection *conn, const char **interface, uint32_t *object_id)
Return protocol error details.
struct wthp_callback * wth_connection_sync(struct wth_connection *conn)
Return a callback using the internal wth_display.
Waltham generic protocol object interface.
int wth_connection_read(struct wth_connection *conn)
Read data received from the network.
void wth_connection_destroy(struct wth_connection *conn)
Disconnect.
int wth_connection_flush(struct wth_connection *conn)
Flush buffered messages to the network.
int wth_connection_get_fd(struct wth_connection *conn)
Get connection file descriptor.
wth_connection_side
Define which side we are on.
Definition: waltham-connection.h:134
void(* wth_registry_callback_func)(struct wthp_registry *registry, void *user_data)
Prototype of the callback to be called whenever a client creates a registry.
Definition: waltham-connection.h:403
struct wth_connection * wth_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
Accept a Waltham client connection.
int wth_connection_get_error(struct wth_connection *conn)
Return the connection error state.