2003-01-08 Havoc Pennington <hp@pobox.com>
[platform/upstream/dbus.git] / dbus / dbus-transport-protected.h
1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-transport-protected.h Used by subclasses of DBusTransport object (internal to D-BUS implementation)
3  *
4  * Copyright (C) 2002  Red Hat Inc.
5  *
6  * Licensed under the Academic Free License version 1.2
7  * 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  * 
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  */
23 #ifndef DBUS_TRANSPORT_PROTECTED_H
24 #define DBUS_TRANSPORT_PROTECTED_H
25
26 #include <dbus/dbus-internals.h>
27 #include <dbus/dbus-errors.h>
28 #include <dbus/dbus-transport.h>
29 #include <dbus/dbus-message-internal.h>
30 #include <dbus/dbus-auth.h>
31
32 DBUS_BEGIN_DECLS;
33
34 typedef struct DBusTransportVTable DBusTransportVTable;
35
36 struct DBusTransportVTable
37 {
38   void (* finalize)           (DBusTransport *transport);
39   /**< The finalize method must free the transport. */
40
41   void (* handle_watch)       (DBusTransport *transport,
42                                DBusWatch     *watch,
43                                unsigned int   flags);
44   /**< The handle_watch method handles reading/writing
45    * data as indicated by the flags.
46    */
47
48   void (* disconnect)         (DBusTransport *transport);
49   /**< Disconnect this transport. */
50
51   void (* connection_set)     (DBusTransport *transport);
52   /**< Called when transport->connection has been filled in */
53
54   void (* messages_pending)   (DBusTransport *transport,
55                                int            queue_length);
56   /**< Called when the outgoing message queue goes from empty
57    * to non-empty or vice versa.
58    */
59
60   void (* do_iteration)       (DBusTransport *transport,
61                                unsigned int   flags,
62                                int            timeout_milliseconds);
63   /**< Called to do a single "iteration" (block on select/poll
64    * followed by reading or writing data).
65    */
66 };
67
68 struct DBusTransport
69 {
70   int refcount;                               /**< Reference count. */
71
72   const DBusTransportVTable *vtable;          /**< Virtual methods for this instance. */
73
74   DBusConnection *connection;                 /**< Connection owning this transport. */
75
76   DBusMessageLoader *loader;                  /**< Message-loading buffer. */
77
78   DBusAuth *auth;                             /**< Authentication conversation */
79
80   DBusCredentials credentials;                /**< Credentials of other end */
81   
82   unsigned int disconnected : 1;              /**< #TRUE if we are disconnected. */
83   unsigned int authenticated : 1;             /**< Cache of auth state; use _dbus_transport_get_is_authenticated() to query value */
84   unsigned int messages_need_sending : 1;     /**< #TRUE if we need to write messages out */
85   unsigned int send_credentials_pending : 1;  /**< #TRUE if we need to send credentials */
86   unsigned int receive_credentials_pending : 1; /**< #TRUE if we need to receive credentials */
87   unsigned int is_server : 1;                 /**< #TRUE if on the server side */
88 };
89
90 dbus_bool_t _dbus_transport_init_base     (DBusTransport             *transport,
91                                            const DBusTransportVTable *vtable,
92                                            dbus_bool_t                server);
93 void        _dbus_transport_finalize_base (DBusTransport             *transport);
94
95
96
97 DBUS_END_DECLS;
98
99 #endif /* DBUS_TRANSPORT_PROTECTED_H */