2 * Copyright (c) 2009-2012 Zmanda, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Contact information: Zmanda Inc., 465 N Mathlida Ave, Suite 300
18 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
21 #ifndef DIRECTTCP_CONNECTION_H
22 #define DIRECTTCP_CONNECTION_H
25 #include <glib-object.h>
27 GType directtcp_connection_get_type (void);
28 #define TYPE_DIRECTTCP_CONNECTION (directtcp_connection_get_type())
29 #define DIRECTTCP_CONNECTION(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), directtcp_connection_get_type(), DirectTCPConnection)
30 #define IS_DIRECTTCP_CONNECTION(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), directtcp_connection_get_type ())
31 #define DIRECTTCP_CONNECTION_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), directtcp_connection_get_type(), DirectTCPConnectionClass)
34 * Parent class for connections
37 typedef struct DirectTCPConnection_ {
41 } DirectTCPConnection;
43 typedef struct DirectTCPConnectionClass_ {
44 GObjectClass __parent__;
46 /* The DirectTCPConnection object allows a particular connection to "span"
47 * multiple devices -- the caller gets the connection from one device,
48 * reads or writes as desired, then creates a new device and passes the
49 * connection to that device. If the new device cannot use the old
50 * connection, then it generates a suitable error message.
53 /* call this to close the connection (even if the Device that created
54 * it is long gone). Note that this will be called automatically by
55 * finalize, but it is a programming error to allow this to happen as
56 * any error will be fatal.
59 * @returns: error message on error, NULL for no error (caller should
60 * free the error message)
62 char *(* close)(struct DirectTCPConnection_ *self);
63 } DirectTCPConnectionClass;
67 char *directtcp_connection_close(
68 DirectTCPConnection *self);
71 * A simple connection subclass containing a local TCP socket, useful for testing
74 #define TYPE_DIRECTTCP_CONNECTION_SOCKET (directtcp_connection_socket_get_type())
75 #define DIRECTTCP_CONNECTION_SOCKET(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), directtcp_connection_socket_get_type(), DirectTCPConnectionSocket)
76 #define DIRECTTCP_CONNECTION_SOCKET_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), directtcp_connection_socket_get_type(), DirectTCPConnectionSocket const)
77 #define DIRECTTCP_CONNECTION_SOCKET_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), directtcp_connection_socket_get_type(), DirectTCPConnectionSocketClass)
78 #define IS_DIRECTTCP_CONNECTION_SOCKET(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), directtcp_connection_socket_get_type ())
79 #define DIRECTTCP_CONNECTION_SOCKET_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), directtcp_connection_socket_get_type(), DirectTCPConnectionSocketClass)
80 GType directtcp_connection_socket_get_type(void);
82 typedef struct DirectTCPConnectionSocket_ {
83 DirectTCPConnection __parent__;
85 } DirectTCPConnectionSocket;
87 typedef struct DirectTCPConnectionSocketClass_ {
88 DirectTCPConnectionClass __parent__;
89 } DirectTCPConnectionSocketClass;
93 DirectTCPConnectionSocket *directtcp_connection_socket_new(int socket);
95 #endif /* DIRECTTCP_CONNECTION_H */