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