From 489c2b5df8b0bcb06707392991d085a25793adcf Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Wed, 10 Aug 2011 10:33:44 +0200 Subject: [PATCH 2/4] Get rid of IdleServerConnectionIface and IdleSSLServerConnection Thanks to GIO IdleServerConnection can now handle both encrypted and unencrypted connections. One can use idle_server_connection_set_tls to choose among the two. Fixes: https://bugs.freedesktop.org/37145 --- src/Makefile.am | 10 +- src/idle-connection.c | 29 +- ...le-server-connection-iface-signals-marshal.list | 1 - src/idle-server-connection-iface.c | 87 --- src/idle-server-connection-iface.h | 84 --- src/idle-server-connection-signals-marshal.list | 1 + src/idle-server-connection.c | 64 ++- src/idle-server-connection.h | 19 + src/idle-ssl-server-connection.c | 650 -------------------- src/idle-ssl-server-connection.h | 61 -- 10 files changed, 75 insertions(+), 931 deletions(-) delete mode 100644 src/idle-server-connection-iface-signals-marshal.list delete mode 100644 src/idle-server-connection-iface.c delete mode 100644 src/idle-server-connection-iface.h create mode 100644 src/idle-server-connection-signals-marshal.list delete mode 100644 src/idle-ssl-server-connection.c delete mode 100644 src/idle-ssl-server-connection.h diff --git a/src/Makefile.am b/src/Makefile.am index 712f5da..5cd1c0d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ BUILT_SOURCES = \ - idle-server-connection-iface-signals-marshal.h \ - idle-server-connection-iface-signals-marshal.c + idle-server-connection-signals-marshal.h \ + idle-server-connection-signals-marshal.c # correctly clean the generated source files CLEANFILES = $(BUILT_SOURCES) $(man_MANS) @@ -36,13 +36,9 @@ libidle_convenience_la_SOURCES = \ protocol.h \ idle-server-connection.c \ idle-server-connection.h \ - idle-server-connection-iface.c \ - idle-server-connection-iface.h \ - idle-ssl-server-connection.h \ - idle-ssl-server-connection.c \ idle-text.h \ idle-text.c \ - idle-server-connection-iface-signals-marshal.list + idle-server-connection-signals-marshal.list nodist_libidle_convenience_la_SOURCES = \ $(BUILT_SOURCES) diff --git a/src/idle-connection.c b/src/idle-connection.c index 1565f31..2db8a65 100644 --- a/src/idle-connection.c +++ b/src/idle-connection.c @@ -48,8 +48,6 @@ #include "idle-muc-manager.h" #include "idle-parser.h" #include "idle-server-connection.h" -#include "idle-server-connection-iface.h" -#include "idle-ssl-server-connection.h" #include "extensions/extensions.h" /* Renaming */ @@ -141,7 +139,7 @@ struct _IdleConnectionPrivate { * network connection */ - IdleServerConnectionIface *conn; + IdleServerConnection *conn; guint sconn_status; /* IRC connection properties */ @@ -208,8 +206,8 @@ static IdleParserHandlerResult _version_privmsg_handler(IdleParser *parser, Idle static IdleParserHandlerResult _welcome_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data); static IdleParserHandlerResult _whois_user_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data); -static void sconn_status_changed_cb(IdleServerConnectionIface *sconn, IdleServerConnectionState state, IdleServerConnectionStateReason reason, IdleConnection *conn); -static void sconn_received_cb(IdleServerConnectionIface *sconn, gchar *raw_msg, IdleConnection *conn); +static void sconn_status_changed_cb(IdleServerConnection *sconn, IdleServerConnectionState state, IdleServerConnectionStateReason reason, IdleConnection *conn); +static void sconn_received_cb(IdleServerConnection *sconn, gchar *raw_msg, IdleConnection *conn); static void irc_handshakes(IdleConnection *conn); static void send_quit_request(IdleConnection *conn); @@ -540,7 +538,7 @@ _force_disconnect (gpointer data) { IdleConnection *conn = IDLE_CONNECTION(data); IdleConnectionPrivate *priv = IDLE_CONNECTION_GET_PRIVATE(conn); - idle_server_connection_iface_disconnect(priv->conn, NULL); + idle_server_connection_disconnect(priv->conn, NULL); return FALSE; } @@ -572,7 +570,7 @@ static void _iface_shut_down(TpBaseConnection *self) { return; if (priv->sconn_status != SERVER_CONNECTION_STATE_NOT_CONNECTED) { - if (!idle_server_connection_iface_disconnect(priv->conn, &error)) + if (!idle_server_connection_disconnect(priv->conn, &error)) g_error_free(error); } else { g_idle_add(_finish_shutdown_idle_func, self);; @@ -637,8 +635,7 @@ static void _start_connecting_continue(IdleConnection *conn) { TpBaseConnection *base_conn = TP_BASE_CONNECTION(conn); IdleConnectionPrivate *priv = IDLE_CONNECTION_GET_PRIVATE(conn); GError *conn_error = NULL; - IdleServerConnectionIface *sconn; - GType connection_type = (priv->use_ssl) ? IDLE_TYPE_SSL_SERVER_CONNECTION : IDLE_TYPE_SERVER_CONNECTION; + IdleServerConnection *sconn; if (!priv->realname || !priv->realname[0]) { const gchar *g_realname = g_get_real_name(); @@ -656,11 +653,13 @@ static void _start_connecting_continue(IdleConnection *conn) { priv->username = g_strdup(g_get_user_name()); } - sconn = IDLE_SERVER_CONNECTION_IFACE(g_object_new(connection_type, "host", priv->server, "port", priv->port, NULL)); + sconn = g_object_new(IDLE_TYPE_SERVER_CONNECTION, "host", priv->server, "port", priv->port, NULL); + if (priv->use_ssl) + idle_server_connection_set_tls(sconn, TRUE); g_signal_connect(sconn, "status-changed", (GCallback)(sconn_status_changed_cb), conn); - if (!idle_server_connection_iface_connect(sconn, &conn_error)) { + if (!idle_server_connection_connect(sconn, &conn_error)) { IDLE_DEBUG("server connection failed to connect: %s", conn_error->message); tp_base_connection_disconnect_with_dbus_error(base_conn, @@ -693,7 +692,7 @@ static void _start_connecting_continue(IdleConnection *conn) { static gboolean keepalive_timeout_cb(gpointer user_data); static gboolean msg_queue_timeout_cb(gpointer user_data); -static void sconn_status_changed_cb(IdleServerConnectionIface *sconn, IdleServerConnectionState state, IdleServerConnectionStateReason reason, IdleConnection *conn) { +static void sconn_status_changed_cb(IdleServerConnection *sconn, IdleServerConnectionState state, IdleServerConnectionStateReason reason, IdleConnection *conn) { IdleConnectionPrivate *priv = IDLE_CONNECTION_GET_PRIVATE(conn); TpConnectionStatusReason tp_reason; @@ -756,7 +755,7 @@ static void sconn_status_changed_cb(IdleServerConnectionIface *sconn, IdleServer priv->sconn_status = state; } -static void sconn_received_cb(IdleServerConnectionIface *sconn, gchar *raw_msg, IdleConnection *conn) { +static void sconn_received_cb(IdleServerConnection *sconn, gchar *raw_msg, IdleConnection *conn) { gchar *converted; idle_connection_ntoh(conn, raw_msg, &converted); @@ -819,7 +818,7 @@ static gboolean msg_queue_timeout_cb(gpointer user_data) { break; } - if (idle_server_connection_iface_send(priv->conn, msg, &error)) { + if (idle_server_connection_send(priv->conn, msg, &error)) { for (j = 0; j < i; j++) { output_msg = g_queue_pop_head(priv->msg_queue); idle_output_pending_msg_free(output_msg); @@ -871,7 +870,7 @@ static void _send_with_priority(IdleConnection *conn, const gchar *msg, guint pr if ((priority == SERVER_CMD_MAX_PRIORITY) || ((conn->parent.status == TP_CONNECTION_STATUS_CONNECTED) && (priv->msg_queue_timeout == 0) && (curr_time - priv->last_msg_sent > MSG_QUEUE_TIMEOUT))) { priv->last_msg_sent = curr_time; - if (!idle_server_connection_iface_send(priv->conn, converted, &error)) { + if (!idle_server_connection_send(priv->conn, converted, &error)) { IDLE_DEBUG("server connection failed to send: %s", error->message); g_error_free(error); } else { diff --git a/src/idle-server-connection-iface-signals-marshal.list b/src/idle-server-connection-iface-signals-marshal.list deleted file mode 100644 index 6cb7431..0000000 --- a/src/idle-server-connection-iface-signals-marshal.list +++ /dev/null @@ -1 +0,0 @@ -VOID:UINT,UINT diff --git a/src/idle-server-connection-iface.c b/src/idle-server-connection-iface.c deleted file mode 100644 index 63621ae..0000000 --- a/src/idle-server-connection-iface.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This file is part of telepathy-idle - * - * Copyright (C) 2006-2007 Collabora Limited - * Copyright (C) 2006-2007 Nokia Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "idle-server-connection-iface.h" - -#include "idle-server-connection-iface-signals-marshal.h" - -static void idle_server_connection_iface_base_init(gpointer klass) { - static gboolean initialized = FALSE; - - if (!initialized) { - initialized = TRUE; - - g_signal_new("status-changed", - G_OBJECT_CLASS_TYPE(klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - idle_server_connection_iface_marshal_VOID__UINT_UINT, - G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); - - g_signal_new("received", - G_OBJECT_CLASS_TYPE(klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); - } -} - -GType idle_server_connection_iface_get_type(void) { - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof (IdleServerConnectionIfaceClass), - idle_server_connection_iface_base_init, - NULL, - NULL, - NULL, - NULL, - 0, - 0, - NULL, - NULL - }; - - type = g_type_register_static(G_TYPE_INTERFACE, "IdleServerConnectionIface", &info, 0); - } - - return type; -} - -gboolean idle_server_connection_iface_connect(IdleServerConnectionIface *iface, GError **error) { - return IDLE_SERVER_CONNECTION_IFACE_GET_CLASS(iface)->connect(iface, error); -} - -gboolean idle_server_connection_iface_disconnect(IdleServerConnectionIface *iface, GError **error) { - return IDLE_SERVER_CONNECTION_IFACE_GET_CLASS(iface)->disconnect(iface, error); -} - -gboolean idle_server_connection_iface_send(IdleServerConnectionIface *iface, const gchar *cmd, GError **error) { - return IDLE_SERVER_CONNECTION_IFACE_GET_CLASS(iface)->send(iface, cmd, error); -} - -IdleServerConnectionState idle_server_connection_iface_get_state(IdleServerConnectionIface *iface) { - return IDLE_SERVER_CONNECTION_IFACE_GET_CLASS(iface)->get_state(iface); -} - diff --git a/src/idle-server-connection-iface.h b/src/idle-server-connection-iface.h deleted file mode 100644 index 5ee5acd..0000000 --- a/src/idle-server-connection-iface.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file is part of telepathy-idle - * - * Copyright (C) 2006-2007 Collabora Limited - * Copyright (C) 2006-2007 Nokia Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __IDLE_SERVER_CONNECTION_IFACE_H__ -#define __IDLE_SERVER_CONNECTION_IFACE_H__ - -#include - -G_BEGIN_DECLS - -#define IDLE_TYPE_SERVER_CONNECTION_IFACE idle_server_connection_iface_get_type() - -#define IDLE_SERVER_CONNECTION_IFACE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), \ - IDLE_TYPE_SERVER_CONNECTION_IFACE, IdleServerConnectionIface)) - -#define IDLE_SERVER_CONNECTION_IFACE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((obj), \ - IDLE_TYPE_SERVER_CONNECTION_IFACE, IdleServerConnectionIfaceClass)) - -#define IDLE_IS_SERVER_CONNECTION_IFACE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), IDLE_TYPE_SERVER_CONNECTION_IFACE)) - -#define IDLE_IS_SERVER_CONNECTION_IFACE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), IDLE_TYPE_SERVER_CONNECTION_IFACE)) - -#define IDLE_SERVER_CONNECTION_IFACE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_INTERFACE((obj), \ - IDLE_TYPE_SERVER_CONNECTION_IFACE, IdleServerConnectionIfaceClass)) - -typedef struct _IdleServerConnectionIface IdleServerConnectionIface; -typedef struct _IdleServerConnectionIfaceClass IdleServerConnectionIfaceClass; - -typedef enum { - SERVER_CONNECTION_STATE_NOT_CONNECTED, - SERVER_CONNECTION_STATE_CONNECTING, - SERVER_CONNECTION_STATE_CONNECTED, -} IdleServerConnectionState; - -typedef enum { - SERVER_CONNECTION_STATE_REASON_ERROR, - SERVER_CONNECTION_STATE_REASON_REQUESTED -} IdleServerConnectionStateReason; - -struct _IdleServerConnectionIfaceClass { - GTypeInterface parent_class; - - gboolean (*connect) (IdleServerConnectionIface *, GError **error); - gboolean (*disconnect) (IdleServerConnectionIface *, GError **error); - - gboolean (*send) (IdleServerConnectionIface *, const gchar *cmd, GError **error); - - IdleServerConnectionState (*get_state) (IdleServerConnectionIface *); -}; - -GType idle_server_connection_iface_get_type(void); - -gboolean idle_server_connection_iface_connect(IdleServerConnectionIface *, GError **error); -gboolean idle_server_connection_iface_disconnect(IdleServerConnectionIface *, GError **error); - -gboolean idle_server_connection_iface_send(IdleServerConnectionIface *, const gchar *cmd, GError **error); - -IdleServerConnectionState idle_server_connection_iface_get_state(IdleServerConnectionIface *); - -G_END_DECLS - -#endif diff --git a/src/idle-server-connection-signals-marshal.list b/src/idle-server-connection-signals-marshal.list new file mode 100644 index 0000000..6cb7431 --- /dev/null +++ b/src/idle-server-connection-signals-marshal.list @@ -0,0 +1 @@ +VOID:UINT,UINT diff --git a/src/idle-server-connection.c b/src/idle-server-connection.c index 9118bae..5f8b981 100644 --- a/src/idle-server-connection.c +++ b/src/idle-server-connection.c @@ -29,17 +29,21 @@ #define IDLE_DEBUG_FLAG IDLE_DEBUG_NETWORK #include "idle-connection.h" #include "idle-debug.h" -#include "idle-server-connection-iface.h" +#include "idle-server-connection-signals-marshal.h" -static void _server_connection_iface_init(gpointer, gpointer); typedef struct _IdleServerConnectionPrivate IdleServerConnectionPrivate; typedef struct _CloseAsyncData CloseAsyncData; typedef struct _WriteAsyncData WriteAsyncData; #define IDLE_SERVER_CONNECTION_GET_PRIVATE(conn) (G_TYPE_INSTANCE_GET_PRIVATE((conn), IDLE_TYPE_SERVER_CONNECTION, IdleServerConnectionPrivate)) -G_DEFINE_TYPE_WITH_CODE(IdleServerConnection, idle_server_connection, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(IDLE_TYPE_SERVER_CONNECTION_IFACE, _server_connection_iface_init)); +G_DEFINE_TYPE(IdleServerConnection, idle_server_connection, G_TYPE_OBJECT) + +enum { + STATUS_CHANGED, + RECEIVED, + LAST_SIGNAL +}; enum { PROP_HOST = 1, @@ -67,6 +71,8 @@ struct _IdleServerConnectionPrivate { static GObject *idle_server_connection_constructor(GType type, guint n_props, GObjectConstructParam *props); +static guint signals[LAST_SIGNAL] = {0}; + static void idle_server_connection_init(IdleServerConnection *conn) { IdleServerConnectionPrivate *priv = IDLE_SERVER_CONNECTION_GET_PRIVATE(conn); @@ -101,7 +107,7 @@ static void idle_server_connection_dispose(GObject *obj) { priv->dispose_has_run = TRUE; if (priv->state == SERVER_CONNECTION_STATE_CONNECTED) - idle_server_connection_iface_disconnect(IDLE_SERVER_CONNECTION_IFACE(obj), NULL); + idle_server_connection_disconnect(conn, NULL); if (priv->cancellable != NULL) { g_cancellable_cancel(priv->cancellable); @@ -196,6 +202,23 @@ static void idle_server_connection_class_init(IdleServerConnectionClass *klass) G_PARAM_STATIC_BLURB); g_object_class_install_property(object_class, PROP_PORT, pspec); + + signals[STATUS_CHANGED] = g_signal_new("status-changed", + G_OBJECT_CLASS_TYPE(klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, + NULL, NULL, + idle_server_connection_marshal_VOID__UINT_UINT, + G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); + + signals[RECEIVED] = g_signal_new("received", + G_OBJECT_CLASS_TYPE(klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); + } static void change_state(IdleServerConnection *conn, IdleServerConnectionState state, guint reason) { @@ -210,12 +233,10 @@ static void change_state(IdleServerConnection *conn, IdleServerConnectionState s g_signal_emit_by_name(conn, "status-changed", state, reason); } -static gboolean iface_disconnect_impl_full(IdleServerConnectionIface *iface, GError **error, guint reason); - static void io_err_cleanup_func(gpointer data) { GError *error = NULL; - if (!iface_disconnect_impl_full(IDLE_SERVER_CONNECTION_IFACE(data), &error, SERVER_CONNECTION_STATE_REASON_ERROR)) { + if (!idle_server_connection_disconnect_full(IDLE_SERVER_CONNECTION(data), &error, SERVER_CONNECTION_STATE_REASON_ERROR)) { IDLE_DEBUG("disconnect: %s", error->message); g_error_free(error); } @@ -283,8 +304,7 @@ static void _connect_to_host_ready(GObject *source_object, GAsyncResult *res, gp change_state(conn, SERVER_CONNECTION_STATE_CONNECTED, SERVER_CONNECTION_STATE_REASON_REQUESTED); } -static gboolean iface_connect_impl(IdleServerConnectionIface *iface, GError **error) { - IdleServerConnection *conn = IDLE_SERVER_CONNECTION(iface); +gboolean idle_server_connection_connect(IdleServerConnection *conn, GError **error) { IdleServerConnectionPrivate *priv = IDLE_SERVER_CONNECTION_GET_PRIVATE(conn); if (priv->state != SERVER_CONNECTION_STATE_NOT_CONNECTED) { @@ -329,12 +349,11 @@ static void _close_ready(GObject *source_object, GAsyncResult *res, gpointer use } } -static gboolean iface_disconnect_impl(IdleServerConnectionIface *iface, GError **error) { - return iface_disconnect_impl_full(iface, error, SERVER_CONNECTION_STATE_REASON_REQUESTED); +gboolean idle_server_connection_disconnect(IdleServerConnection *conn, GError **error) { + return idle_server_connection_disconnect_full(conn, error, SERVER_CONNECTION_STATE_REASON_REQUESTED); } -static gboolean iface_disconnect_impl_full(IdleServerConnectionIface *iface, GError **error, guint reason) { - IdleServerConnection *conn = IDLE_SERVER_CONNECTION(iface); +gboolean idle_server_connection_disconnect_full(IdleServerConnection *conn, GError **error, guint reason) { IdleServerConnectionPrivate *priv = IDLE_SERVER_CONNECTION_GET_PRIVATE(conn); g_assert(priv != NULL); @@ -381,8 +400,7 @@ cleanup: g_object_unref(conn); } -static gboolean iface_send_impl(IdleServerConnectionIface *iface, const gchar *cmd, GError **error) { - IdleServerConnection *conn = IDLE_SERVER_CONNECTION(iface); +gboolean idle_server_connection_send(IdleServerConnection *conn, const gchar *cmd, GError **error) { IdleServerConnectionPrivate *priv = IDLE_SERVER_CONNECTION_GET_PRIVATE(conn); GOutputStream *output_stream; @@ -408,18 +426,12 @@ static gboolean iface_send_impl(IdleServerConnectionIface *iface, const gchar *c return TRUE; } -static IdleServerConnectionState iface_get_state_impl(IdleServerConnectionIface *iface) { - IdleServerConnection *conn = IDLE_SERVER_CONNECTION(iface); +IdleServerConnectionState idle_server_connection_get_state(IdleServerConnection *conn) { IdleServerConnectionPrivate *priv = IDLE_SERVER_CONNECTION_GET_PRIVATE(conn); - return priv->state; } -static void _server_connection_iface_init(gpointer g_iface, gpointer iface_data) { - IdleServerConnectionIfaceClass *klass = (IdleServerConnectionIfaceClass *)(g_iface); - - klass->connect = iface_connect_impl; - klass->disconnect = iface_disconnect_impl; - klass->send = iface_send_impl; - klass->get_state = iface_get_state_impl; +void idle_server_connection_set_tls(IdleServerConnection *conn, gboolean tls) { + IdleServerConnectionPrivate *priv = IDLE_SERVER_CONNECTION_GET_PRIVATE(conn); + g_socket_client_set_tls(priv->socket_client, tls); } diff --git a/src/idle-server-connection.h b/src/idle-server-connection.h index d5124e4..9402ab9 100644 --- a/src/idle-server-connection.h +++ b/src/idle-server-connection.h @@ -3,6 +3,7 @@ * * Copyright (C) 2006-2007 Collabora Limited * Copyright (C) 2006-2007 Nokia Corporation + * Copyright (C) 2011 Debarshi Ray * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -28,6 +29,17 @@ G_BEGIN_DECLS typedef struct _IdleServerConnection IdleServerConnection; typedef struct _IdleServerConnectionClass IdleServerConnectionClass; +typedef enum { + SERVER_CONNECTION_STATE_NOT_CONNECTED, + SERVER_CONNECTION_STATE_CONNECTING, + SERVER_CONNECTION_STATE_CONNECTED +} IdleServerConnectionState; + +typedef enum { + SERVER_CONNECTION_STATE_REASON_ERROR, + SERVER_CONNECTION_STATE_REASON_REQUESTED +} IdleServerConnectionStateReason; + struct _IdleServerConnection { GObject parent; }; @@ -56,6 +68,13 @@ GType idle_server_connection_get_type(void); #define IDLE_SERVER_CONNECTION_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS((obj), IDLE_TYPE_SERVER_CONNECTION, IdleServerConnectionClass)) +gboolean idle_server_connection_connect(IdleServerConnection *conn, GError **error); +gboolean idle_server_connection_disconnect(IdleServerConnection *conn, GError **error); +gboolean idle_server_connection_disconnect_full(IdleServerConnection *conn, GError **error, guint reason); +gboolean idle_server_connection_send(IdleServerConnection *conn, const gchar *cmd, GError **error); +IdleServerConnectionState idle_server_connection_get_state(IdleServerConnection *conn); +void idle_server_connection_set_tls(IdleServerConnection *conn, gboolean tls); + G_END_DECLS #endif diff --git a/src/idle-ssl-server-connection.c b/src/idle-ssl-server-connection.c deleted file mode 100644 index 66737cf..0000000 --- a/src/idle-ssl-server-connection.c +++ /dev/null @@ -1,650 +0,0 @@ -/* - * This file is part of telepathy-idle - * - * Copyright (C) 2006-2007 Collabora Limited - * Copyright (C) 2006-2007 Nokia Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "idle-ssl-server-connection.h" -#include "idle-server-connection-iface.h" -#include "idle-connection.h" - -#include "idle-dns-resolver.h" - -#define IDLE_DEBUG_FLAG IDLE_DEBUG_NETWORK -#include "idle-debug.h" - -static void _server_connection_iface_init(gpointer, gpointer); -typedef struct _IdleSSLServerConnectionPrivate IdleSSLServerConnectionPrivate; - -#define IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn) \ - (G_TYPE_INSTANCE_GET_PRIVATE((conn), IDLE_TYPE_SSL_SERVER_CONNECTION, \ - IdleSSLServerConnectionPrivate)) - -G_DEFINE_TYPE_WITH_CODE(IdleSSLServerConnection, idle_ssl_server_connection, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(IDLE_TYPE_SERVER_CONNECTION_IFACE, _server_connection_iface_init)); - -enum { - PROP_HOST = 1, - PROP_PORT, -}; - -typedef void (*async_connecting_finished_cb)(IdleSSLServerConnection *conn, gboolean success); - -typedef struct _AsyncConnectData AsyncConnectData; -struct _AsyncConnectData { - IdleSSLServerConnection *conn; - - guint watch_id; - GIOChannel *io_chan; - - IdleDNSResult *res; - IdleDNSResult *cur; - - async_connecting_finished_cb finished_cb; -}; - -#define async_connect_data_new() \ - (g_slice_new(AsyncConnectData)) -#define async_connect_data_new0() \ - (g_slice_new0(AsyncConnectData)) - -static void async_connect_data_destroy(AsyncConnectData *data) { - if (data->watch_id) { - g_source_remove(data->watch_id); - data->watch_id = 0; - } - - if (data->io_chan) { - g_io_channel_shutdown(data->io_chan, FALSE, NULL); - g_io_channel_unref(data->io_chan); - data->io_chan = NULL; - } - - if (data->res) { - idle_dns_result_destroy(data->res); - data->res = NULL; - data->cur = NULL; - } - - g_slice_free(AsyncConnectData, data); -} - -struct _IdleSSLServerConnectionPrivate { - gchar *host; - guint16 port; - - GIOChannel *io_chan; - SSL *ssl; - BIO *bio; - - guint read_watch_id; - guint last_message_sent; - - IdleDNSResolver *resolver; - AsyncConnectData *connect_data; - - IdleServerConnectionState state; - - gboolean dispose_has_run; -}; - -static GObject *idle_ssl_server_connection_constructor(GType type, guint n_props, GObjectConstructParam *props); - -static void idle_ssl_server_connection_init(IdleSSLServerConnection *conn) { - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn); - - priv->host = NULL; - priv->port = 0; - - priv->io_chan = NULL; - priv->ssl = NULL; - priv->bio = NULL; - - priv->read_watch_id = 0; - priv->last_message_sent = 0; - - priv->resolver = idle_dns_resolver_new(); - priv->connect_data = NULL; - - priv->state = SERVER_CONNECTION_STATE_NOT_CONNECTED; - - priv->dispose_has_run = FALSE; -} - -static GObject *idle_ssl_server_connection_constructor(GType type, guint n_props, GObjectConstructParam *props) { - GObject *ret; - - ret = G_OBJECT_CLASS(idle_ssl_server_connection_parent_class)->constructor(type, n_props, props); - - return ret; -} - -static void idle_ssl_server_connection_dispose(GObject *obj) { - IdleSSLServerConnection *conn = IDLE_SSL_SERVER_CONNECTION(obj); - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn); - - if (priv->dispose_has_run) - return; - - IDLE_DEBUG("dispose called"); - priv->dispose_has_run = TRUE; - - if (priv->state == SERVER_CONNECTION_STATE_CONNECTED) { - GError *error = NULL; - g_warning("%s: connection was open when the object was deleted, it'll probably crash now..", G_STRFUNC); - - if (!idle_server_connection_iface_disconnect(IDLE_SERVER_CONNECTION_IFACE(obj), &error)) { - g_error_free(error); - } - } - - if (priv->ssl) - SSL_free(priv->ssl); - - if (priv->bio) - BIO_free(priv->bio); - - if (priv->read_watch_id) - g_source_remove(priv->read_watch_id); -} - -static void idle_ssl_server_connection_finalize(GObject *obj) { - IdleSSLServerConnection *conn = IDLE_SSL_SERVER_CONNECTION(obj); - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn); - - g_free(priv->host); - - idle_dns_resolver_destroy(priv->resolver); - - if (priv->connect_data) - async_connect_data_destroy(priv->connect_data); -} - -static void idle_ssl_server_connection_get_property(GObject *obj, guint prop_id, GValue *value, GParamSpec *pspec) { - IdleSSLServerConnection *conn = IDLE_SSL_SERVER_CONNECTION(obj); - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn); - - switch (prop_id) { - case PROP_HOST: - g_value_set_string(value, priv->host); - break; - - case PROP_PORT: - g_value_set_uint(value, priv->port); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec); - break; - } -} - -static void idle_ssl_server_connection_set_property(GObject *obj, guint prop_id, const GValue *value, GParamSpec *pspec) { - IdleSSLServerConnection *conn = IDLE_SSL_SERVER_CONNECTION(obj); - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn); - - switch (prop_id) { - case PROP_HOST: - g_free(priv->host); - priv->host = g_value_dup_string(value); - break; - - case PROP_PORT: - priv->port = (guint16) g_value_get_uint(value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec); - break; - } -} - -static void idle_ssl_server_connection_class_init(IdleSSLServerConnectionClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS(klass); - GParamSpec *pspec; - - g_type_class_add_private(klass, sizeof(IdleSSLServerConnectionPrivate)); - - object_class->constructor = idle_ssl_server_connection_constructor; - object_class->dispose = idle_ssl_server_connection_dispose; - object_class->finalize = idle_ssl_server_connection_finalize; - - object_class->get_property = idle_ssl_server_connection_get_property; - object_class->set_property = idle_ssl_server_connection_set_property; - - pspec = g_param_spec_string("host", "Remote host", - "Hostname of the remote service to connect to.", - NULL, - G_PARAM_READABLE| - G_PARAM_WRITABLE| - G_PARAM_STATIC_NICK| - G_PARAM_STATIC_BLURB); - - g_object_class_install_property(object_class, PROP_HOST, pspec); - - pspec = g_param_spec_uint("port", "Remote port", - "Port number of the remote service to connect to.", - 0, G_MAXUINT16, 0, - G_PARAM_READABLE| - G_PARAM_WRITABLE| - G_PARAM_STATIC_NICK| - G_PARAM_STATIC_BLURB); - - g_object_class_install_property(object_class, PROP_PORT, pspec); -} - -static void ssl_conn_change_state(IdleSSLServerConnection *conn, guint state, guint reason) { - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn); - - if (state == priv->state) - return; - - priv->state = state; - - g_signal_emit_by_name(conn, "status-changed", state, reason); -} - -static SSL_CTX *ssl_conn_get_ctx() { - static SSL_CTX *ctx = NULL; - - if (!ctx) { - SSL_library_init(); - SSL_load_error_strings(); - - ctx = SSL_CTX_new(SSLv23_client_method()); - - if (!ctx) { - IDLE_DEBUG("OpenSSL initialization failed!"); - } - } - - return ctx; -} - -static gboolean iface_ssl_disconnect_impl_full(IdleServerConnectionIface *iface, guint reason, GError **error); - -static gboolean ssl_io_err_cleanup_func(gpointer user_data) { - IdleServerConnectionIface *iface = IDLE_SERVER_CONNECTION_IFACE(user_data); - GError *error = NULL; - - if (!iface_ssl_disconnect_impl_full(iface, SERVER_CONNECTION_STATE_REASON_ERROR, &error)) { - IDLE_DEBUG("disconnect: %s", error->message); - g_error_free(error); - } - - return FALSE; -} - -static gboolean ssl_io_func(GIOChannel *src, GIOCondition cond, gpointer data) { - IdleSSLServerConnection *conn = IDLE_SSL_SERVER_CONNECTION(data); - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(data); - gchar buf[IRC_MSG_MAXLEN + 3]; - int err; - - if ((cond == G_IO_ERR) || (cond == G_IO_HUP)) { - IDLE_DEBUG("got G_IO_ERR || G_IO_HUP"); - ssl_conn_change_state(conn, SERVER_CONNECTION_STATE_NOT_CONNECTED, SERVER_CONNECTION_STATE_REASON_ERROR); - - priv->read_watch_id = 0; - return FALSE; - } - - memset(buf, 0, IRC_MSG_MAXLEN + 3); - - do { - err = SSL_read(priv->ssl, buf, IRC_MSG_MAXLEN + 2); - } while ((err <= 0) && (SSL_get_error(priv->ssl, err) == SSL_ERROR_WANT_READ)); - - if (err <= 0) { - IDLE_DEBUG("SSL_read failed with error %i", SSL_get_error(priv->ssl, err)); - - g_idle_add(ssl_io_err_cleanup_func, conn); - - priv->read_watch_id = 0; - return FALSE; - } - - g_signal_emit_by_name(conn, "received", buf); - - return TRUE; -} - -static void ssl_async_connecting_finished_cb(IdleSSLServerConnection *conn, gboolean success) { - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn); - SSL_CTX *ctx; - X509 *cert; - int status; - int opt; - - if (!success) { - ssl_conn_change_state(conn, SERVER_CONNECTION_STATE_NOT_CONNECTED, SERVER_CONNECTION_STATE_REASON_ERROR); - return; - } - - priv->io_chan = priv->connect_data->io_chan; - priv->connect_data->io_chan = NULL; - - if (priv->connect_data->watch_id) { - g_source_remove(priv->connect_data->watch_id); - priv->connect_data->watch_id = 0; - } - - priv->read_watch_id = g_io_add_watch(priv->io_chan, G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP, ssl_io_func, conn); - - gint fd = g_io_channel_unix_get_fd(priv->io_chan); - if (fcntl(fd, F_SETFL, 0)) - IDLE_DEBUG("failed to set socket back to blocking mode"); - - opt = 1; - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt)); - - opt = 1; - setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &opt, sizeof(opt)); - - ctx = ssl_conn_get_ctx(); - - if (!ctx) { - IDLE_DEBUG("failed to get SSL context object"); - ssl_async_connecting_finished_cb(conn, FALSE); - return; - } - - priv->ssl = SSL_new(ctx); - - if (!priv->ssl) { - IDLE_DEBUG("failed to create SSL object"); - ssl_async_connecting_finished_cb(conn, FALSE); - return; - } - - status = SSL_set_fd(priv->ssl, fd); - - if (!status) { - IDLE_DEBUG("failed to set SSL socket"); - ssl_async_connecting_finished_cb(conn, FALSE); - return; - } - - status = SSL_connect(priv->ssl); - - if (status <= 0) { - IDLE_DEBUG("SSL_connect failed with status %i (error %i)", status, SSL_get_error(priv->ssl, status)); - ssl_async_connecting_finished_cb(conn, FALSE); - return; - } - - cert = SSL_get_peer_certificate(priv->ssl); - - if (!cert) { - IDLE_DEBUG("failed to get SSL peer certificate"); - ssl_async_connecting_finished_cb(conn, FALSE); - return; - } - - /* TODO sometime in the future implement certificate verification */ - - X509_free(cert); - - ssl_conn_change_state(conn, SERVER_CONNECTION_STATE_CONNECTED, SERVER_CONNECTION_STATE_REASON_REQUESTED); -} - -static void ssl_do_connect(AsyncConnectData *data); - -static gboolean ssl_connect_io_func(GIOChannel *src, GIOCondition cond, gpointer user_data) { - AsyncConnectData *data = (AsyncConnectData *)(user_data); - int optval; - socklen_t optlen = sizeof(optval); - gint fd = g_io_channel_unix_get_fd(data->io_chan); - - g_assert(getsockopt(fd, SOL_SOCKET, SO_ERROR, &optval, &optlen) == 0); - - if (optval == 0) { - data->finished_cb(data->conn, TRUE); - } else { - g_source_remove(data->watch_id); - data->watch_id = 0; - - g_io_channel_shutdown(data->io_chan, FALSE, NULL); - g_io_channel_unref(data->io_chan); - data->io_chan = NULL; - - /* try the next address */ - data->cur = data->cur->ai_next; - - ssl_do_connect(data); - } - - return FALSE; -} - -static void ssl_do_connect(AsyncConnectData *data) { - int fd = -1, rc = -1; - GIOChannel *io_chan; - - for (; data->cur != NULL; data->cur = data->cur->ai_next) { - fd = socket(data->cur->ai_family, data->cur->ai_socktype, data->cur->ai_protocol); - - if (fd == -1) - IDLE_DEBUG("socket() failed: %s", g_strerror(errno)); - else - break; - } - - if (fd == -1) { - IDLE_DEBUG("failed: %s", g_strerror(errno)); - data->finished_cb(data->conn, FALSE); - return; - } - - rc = fcntl(fd, F_SETFL, O_NONBLOCK); - - if (rc != 0) { - IDLE_DEBUG("failed to set socket to non-blocking mode: %s", g_strerror(errno)); - close(fd); - data->finished_cb(data->conn, FALSE); - return; - } - - rc = connect(fd, data->cur->ai_addr, data->cur->ai_addrlen); - - if ((errno != EINPROGRESS) && (rc == -1)) { - IDLE_DEBUG("connect() failed: %s", g_strerror(errno)); - close(fd); - data->finished_cb(data->conn, FALSE); - return; - } - - io_chan = g_io_channel_unix_new(fd); - g_io_channel_set_encoding(io_chan, NULL, NULL); - g_io_channel_set_buffered(io_chan, FALSE); - - data->io_chan = io_chan; - data->watch_id = g_io_add_watch(io_chan, G_IO_OUT | G_IO_ERR, ssl_connect_io_func, data); -} - -static void ssl_dns_result_cb(guint unused, IdleDNSResult *results, gpointer user_data) { - IdleSSLServerConnection *conn = IDLE_SSL_SERVER_CONNECTION(user_data); - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn); - AsyncConnectData *data; - - if (priv->connect_data) { - async_connect_data_destroy(priv->connect_data); - } - - priv->connect_data = data = async_connect_data_new0(); - - data->conn = conn; - data->res = results; - data->cur = results; - data->finished_cb = ssl_async_connecting_finished_cb; - - ssl_do_connect(data); -} - -static gboolean iface_ssl_connect_impl(IdleServerConnectionIface *iface, GError **error) { - IdleSSLServerConnection *conn = IDLE_SSL_SERVER_CONNECTION(iface); - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn); - - if (priv->state != SERVER_CONNECTION_STATE_NOT_CONNECTED) { - IDLE_DEBUG("connection was not in state NOT_CONNECTED"); - - g_set_error(error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "connection was not in state NOT_CONNECTED"); - - return FALSE; - } - - if (!priv->host || !priv->host[0]) { - IDLE_DEBUG("no hostname provided"); - - g_set_error(error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "no hostname provided"); - - return FALSE; - } - - if (!priv->port) { - IDLE_DEBUG("no port provided"); - - g_set_error(error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "no port provided"); - - return FALSE; - } - - idle_dns_resolver_query(priv->resolver, priv->host, priv->port, ssl_dns_result_cb, conn); - - ssl_conn_change_state(conn, SERVER_CONNECTION_STATE_CONNECTING, SERVER_CONNECTION_STATE_REASON_REQUESTED); - - return TRUE; -} - -static gboolean iface_ssl_disconnect_impl_full(IdleServerConnectionIface *iface, guint reason, GError **error) { - IdleSSLServerConnection *conn = IDLE_SSL_SERVER_CONNECTION(iface); - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn); - - if (priv->state == SERVER_CONNECTION_STATE_NOT_CONNECTED) { - IDLE_DEBUG("not connected"); - - g_set_error(error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "not connected"); - - return FALSE; - } - - if (priv->read_watch_id) { - g_source_remove(priv->read_watch_id); - priv->read_watch_id = 0; - } - - if (priv->io_chan) { - GError *io_error = NULL; - - g_io_channel_shutdown(priv->io_chan, FALSE, &io_error); - - if (io_error) { - IDLE_DEBUG("g_io_channel_shutdown failed: %s", io_error->message); - - g_error_free(io_error); - } - - g_io_channel_unref(priv->io_chan); - - priv->io_chan = NULL; - } - - ssl_conn_change_state(conn, SERVER_CONNECTION_STATE_NOT_CONNECTED, reason); - - return TRUE; -} - -static gboolean iface_ssl_disconnect_impl(IdleServerConnectionIface *iface, GError **error) { - return iface_ssl_disconnect_impl_full(iface, SERVER_CONNECTION_STATE_REASON_REQUESTED, error); -} - -static gboolean iface_ssl_send_impl(IdleServerConnectionIface *iface, const gchar *cmd, GError **error) { - IdleSSLServerConnection *conn = IDLE_SSL_SERVER_CONNECTION(iface); - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn); - gsize len; - int rc; - - g_assert(cmd != NULL); - - if (priv->state != SERVER_CONNECTION_STATE_CONNECTED) { - IDLE_DEBUG("connection was not in state CONNECTED"); - - g_set_error(error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "connection was not in state CONNECTED"); - - return FALSE; - } - - len = strlen(cmd); - - if (!len) { - return TRUE; - } - - rc = SSL_write(priv->ssl, cmd, len); - - if (rc <= 0) { - GError *local_error = NULL; - - IDLE_DEBUG("SSL_write failed with status %i (error %i)", rc, SSL_get_error(priv->ssl, rc)); - - if (!iface_ssl_disconnect_impl_full(IDLE_SERVER_CONNECTION_IFACE(conn), SERVER_CONNECTION_STATE_REASON_ERROR, &local_error)) { - g_error_free(local_error); - } - - g_set_error(error, TP_ERRORS, TP_ERROR_NETWORK_ERROR, "SSL_write failed"); - - return FALSE; - } - - return TRUE; -} - -IdleServerConnectionState iface_ssl_get_state_impl(IdleServerConnectionIface *iface) { - IdleSSLServerConnection *conn = IDLE_SSL_SERVER_CONNECTION(iface); - IdleSSLServerConnectionPrivate *priv = IDLE_SSL_SERVER_CONNECTION_GET_PRIVATE(conn); - - return priv->state; -} - -static void _server_connection_iface_init(gpointer g_iface, gpointer iface_data) { - IdleServerConnectionIfaceClass *klass = (IdleServerConnectionIfaceClass *)(g_iface); - - klass->connect = iface_ssl_connect_impl; - klass->disconnect = iface_ssl_disconnect_impl; - klass->send = iface_ssl_send_impl; - klass->get_state = iface_ssl_get_state_impl; -} diff --git a/src/idle-ssl-server-connection.h b/src/idle-ssl-server-connection.h deleted file mode 100644 index 094efef..0000000 --- a/src/idle-ssl-server-connection.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of telepathy-idle - * - * Copyright (C) 2006-2007 Collabora Limited - * Copyright (C) 2006-2007 Nokia Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __IDLE_SSL_SERVER_CONNECTION_H__ -#define __IDLE_SSL_SERVER_CONNECTION_H__ - -#include - -G_BEGIN_DECLS - -typedef struct _IdleSSLServerConnection IdleSSLServerConnection; -typedef struct _IdleSSLServerConnectionClass IdleSSLServerConnectionClass; - -struct _IdleSSLServerConnection { - GObject parent; -}; - -struct _IdleSSLServerConnectionClass { - GObjectClass parent; -}; - -GType idle_ssl_server_connection_get_type(void); - -#define IDLE_TYPE_SSL_SERVER_CONNECTION \ - (idle_ssl_server_connection_get_type()) - -#define IDLE_SSL_SERVER_CONNECTION(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), IDLE_TYPE_SSL_SERVER_CONNECTION, IdleSSLServerConnection)) - -#define IDLE_SSL_SERVER_CONNECTION_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), IDLE_TYPE_SSL_SERVER_CONNECTION, IdleSSLServerConnection)) - -#define IDLE_IS_SSL_SERVER_CONNECTION(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), IDLE_TYPE_SSL_SERVER_CONNECTION)) - -#define IDLE_IS_SSL_SERVER_CONNECTION_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), IDLE_TYPE_SSL_SERVER_CONNECTION)) - -#define IDLE_SSL_SERVER_CONNECTION_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj), IDLE_TYPE_SSL_SERVER_CONNECTION, IdleSSLServerConnectionClass)) - -G_END_DECLS - -#endif -- 1.7.6