diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-03-02 15:30:06 +0000 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-03-02 15:30:06 +0000 |
commit | f8bc814ca4f1343080f5e5b384143cc63ee81f08 (patch) | |
tree | 6a7cba978cd9515fc632983b36e08b940ad8e5f3 /lib/gibber | |
parent | 423253450d567702bd427448f52bb14992c4321e (diff) | |
download | telepathy-salut-f8bc814ca4f1343080f5e5b384143cc63ee81f08.tar.gz |
gibber-xmpp-connection-listener: removed
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'lib/gibber')
-rw-r--r-- | lib/gibber/Makefile.am | 2 | ||||
-rw-r--r-- | lib/gibber/gibber-xmpp-connection-listener.c | 194 | ||||
-rw-r--r-- | lib/gibber/gibber-xmpp-connection-listener.h | 74 | ||||
-rw-r--r-- | lib/gibber/tests/Makefile.am | 1 | ||||
-rw-r--r-- | lib/gibber/tests/check-gibber-xmpp-connection-listener.c | 123 |
5 files changed, 0 insertions, 394 deletions
diff --git a/lib/gibber/Makefile.am b/lib/gibber/Makefile.am index 4b6ce8f4..75c27dd0 100644 --- a/lib/gibber/Makefile.am +++ b/lib/gibber/Makefile.am @@ -60,8 +60,6 @@ HANDWRITTEN_SOURCES = \ gibber-oob-file-transfer.h \ gibber-listener.c \ gibber-listener.h \ - gibber-xmpp-connection-listener.c \ - gibber-xmpp-connection-listener.h \ gibber-xmpp-error.h \ gibber-xmpp-error.c \ gibber-sockets.c \ diff --git a/lib/gibber/gibber-xmpp-connection-listener.c b/lib/gibber/gibber-xmpp-connection-listener.c deleted file mode 100644 index 729efde1..00000000 --- a/lib/gibber/gibber-xmpp-connection-listener.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * gibber-xmpp-connection-listener.c - Source for GibberXmppConnectionListener - * Copyright (C) 2007 Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * 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 "gibber-xmpp-connection-listener.h" - -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <sys/types.h> -#include <unistd.h> -#include <errno.h> - -#include <glib.h> - -#include "gibber-sockets.h" -#include "gibber-xmpp-connection.h" -#include "gibber-linklocal-transport.h" -#include "gibber-util.h" -#include "gibber-listener.h" - -#define DEBUG_FLAG DEBUG_NET -#include "gibber-debug.h" - -#include "gibber-signals-marshal.h" - -G_DEFINE_TYPE (GibberXmppConnectionListener, gibber_xmpp_connection_listener, \ - G_TYPE_OBJECT); - -/* signals */ -enum -{ - NEW_CONNECTION, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -typedef struct _GibberXmppConnectionListenerPrivate \ - GibberXmppConnectionListenerPrivate; -struct _GibberXmppConnectionListenerPrivate -{ - GibberListener *listener; - - gboolean dispose_has_run; -}; - -#define GIBBER_XMPP_CONNECTION_LISTENER_GET_PRIVATE(obj) \ - ((GibberXmppConnectionListenerPrivate *) obj->priv) - -GQuark -gibber_xmpp_connection_listener_error_quark (void) -{ - static GQuark quark = 0; - - if (!quark) - quark = g_quark_from_static_string ( - "gibber_xmpp_connection_listener_error"); - - return quark; -} - -static void -gibber_xmpp_connection_listener_init (GibberXmppConnectionListener *self) -{ - GibberXmppConnectionListenerPrivate *priv = - G_TYPE_INSTANCE_GET_PRIVATE (self, GIBBER_TYPE_XMPP_CONNECTION_LISTENER, - GibberXmppConnectionListenerPrivate); - - self->priv = priv; - - priv->listener = NULL; - - priv->dispose_has_run = FALSE; -} - -static void -gibber_xmpp_connection_listener_dispose (GObject *object) -{ - GibberXmppConnectionListener *self = - GIBBER_XMPP_CONNECTION_LISTENER (object); - GibberXmppConnectionListenerPrivate *priv = - GIBBER_XMPP_CONNECTION_LISTENER_GET_PRIVATE (self); - - if (priv->listener != NULL) - { - g_object_unref (priv->listener); - priv->listener = NULL; - } - - G_OBJECT_CLASS (gibber_xmpp_connection_listener_parent_class)->dispose ( - object); -} - -static void -gibber_xmpp_connection_listener_class_init ( - GibberXmppConnectionListenerClass *gibber_xmpp_connection_listener_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS ( - gibber_xmpp_connection_listener_class); - - g_type_class_add_private (gibber_xmpp_connection_listener_class, - sizeof (GibberXmppConnectionListenerPrivate)); - - object_class->dispose = gibber_xmpp_connection_listener_dispose; - - signals[NEW_CONNECTION] = - g_signal_new ( - "new-connection", - G_OBJECT_CLASS_TYPE (gibber_xmpp_connection_listener_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - _gibber_signals_marshal_VOID__OBJECT_POINTER_UINT, - G_TYPE_NONE, 3, GIBBER_TYPE_XMPP_CONNECTION, G_TYPE_POINTER, - G_TYPE_UINT); -} - -GibberXmppConnectionListener * -gibber_xmpp_connection_listener_new (void) -{ - return g_object_new (GIBBER_TYPE_XMPP_CONNECTION_LISTENER, - NULL); -} - -static gboolean -new_connection_cb (GibberListener *listener, - GibberTransport *transport, - struct sockaddr *address, - socklen_t addrlen, - gpointer user_data) -{ - GibberXmppConnectionListener *self = - GIBBER_XMPP_CONNECTION_LISTENER (user_data); - GibberXmppConnection *connection; - connection = gibber_xmpp_connection_new (transport); - - g_signal_emit (self, signals[NEW_CONNECTION], 0, connection, - address, addrlen); - - g_object_unref (connection); - return TRUE; -} - -/** - * port: the port, or 0 to choose a random port - */ -gboolean -gibber_xmpp_connection_listener_listen (GibberXmppConnectionListener *self, - int port, - GError **error) -{ - GibberXmppConnectionListenerPrivate *priv = - GIBBER_XMPP_CONNECTION_LISTENER_GET_PRIVATE (self); - int ret; - - if (priv->listener == NULL) - { - priv->listener = gibber_listener_new (); - g_signal_connect (priv->listener, "new-connection", - G_CALLBACK (new_connection_cb), self); - } - - ret = gibber_listener_listen_tcp (priv->listener, port, error); - - return ret; -} - -int -gibber_xmpp_connection_listener_get_port ( - GibberXmppConnectionListener *self) -{ - GibberXmppConnectionListenerPrivate *priv = - GIBBER_XMPP_CONNECTION_LISTENER_GET_PRIVATE (self); - - g_return_val_if_fail (priv->listener != NULL, 0); - - return gibber_listener_get_port (priv->listener); -} diff --git a/lib/gibber/gibber-xmpp-connection-listener.h b/lib/gibber/gibber-xmpp-connection-listener.h deleted file mode 100644 index 1f542547..00000000 --- a/lib/gibber/gibber-xmpp-connection-listener.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * gibber-xmpp-connection-listener.h - Header for GibberXmppConnectionListener - * Copyright (C) 2007 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * 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 __GIBBER_XMPP_CONNECTION_LISTENER_H__ -#define __GIBBER_XMPP_CONNECTION_LISTENER_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef struct _GibberXmppConnectionListener GibberXmppConnectionListener; -typedef struct _GibberXmppConnectionListenerClass - GibberXmppConnectionListenerClass; - -struct _GibberXmppConnectionListenerClass { - GObjectClass parent_class; -}; - -struct _GibberXmppConnectionListener { - GObject parent; - - gpointer priv; -}; - -GType gibber_xmpp_connection_listener_get_type (void); - -/* TYPE MACROS */ -#define GIBBER_TYPE_XMPP_CONNECTION_LISTENER \ - (gibber_xmpp_connection_listener_get_type ()) -#define GIBBER_XMPP_CONNECTION_LISTENER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), GIBBER_TYPE_XMPP_CONNECTION_LISTENER,\ - GibberXmppConnectionListener)) -#define GIBBER_XMPP_CONNECTION_LISTENER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), GIBBER_TYPE_XMPP_CONNECTION_LISTENER,\ - GibberXmppConnectionListenerClass)) -#define GIBBER_IS_XMPP_CONNECTION_LISTENER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIBBER_TYPE_XMPP_CONNECTION_LISTENER)) -#define GIBBER_IS_XMPP_CONNECTION_LISTENER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), GIBBER_TYPE_XMPP_CONNECTION_LISTENER)) -#define GIBBER_XMPP_CONNECTION_LISTENER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), GIBBER_TYPE_XMPP_CONNECTION_LISTENER,\ - GibberXmppConnectionListenerClass)) - -GQuark gibber_xmpp_connection_listener_error_quark (void); - -GibberXmppConnectionListener * -gibber_xmpp_connection_listener_new (void); - -gboolean gibber_xmpp_connection_listener_listen ( - GibberXmppConnectionListener *listener, int port, GError **error); - -int gibber_xmpp_connection_listener_get_port ( - GibberXmppConnectionListener *listener); - - -G_END_DECLS - -#endif /* #ifndef __GIBBER_XMPP_CONNECTION_LISTENER_H__ */ diff --git a/lib/gibber/tests/Makefile.am b/lib/gibber/tests/Makefile.am index 2c241565..cf40c475 100644 --- a/lib/gibber/tests/Makefile.am +++ b/lib/gibber/tests/Makefile.am @@ -81,7 +81,6 @@ check_PROGRAMS = \ check-gibber-r-multicast-sender \ check-gibber-iq-helper \ check-gibber-listener \ - check-gibber-xmpp-connection-listener \ check-gibber-xmpp-error \ check-gibber-unix-transport diff --git a/lib/gibber/tests/check-gibber-xmpp-connection-listener.c b/lib/gibber/tests/check-gibber-xmpp-connection-listener.c deleted file mode 100644 index 96bdb17f..00000000 --- a/lib/gibber/tests/check-gibber-xmpp-connection-listener.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * check-gibber-xmpp-connection-listener.c - Test for - * GibberXmppConnectionListener - * Copyright (C) 2007 Collabora Ltd. - * @author Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * 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 <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> - -#include <gibber/gibber-linklocal-transport.h> -#include <gibber/gibber-listener.h> -#include <gibber/gibber-xmpp-connection.h> -#include <gibber/gibber-xmpp-connection-listener.h> - -gboolean got_connection; - -static void -new_connection_cb (GibberXmppConnectionListener *listener, - GibberXmppConnection *connection, - struct sockaddr *addr, - guint size, - gpointer user_data) -{ - got_connection = TRUE; -} - -static gboolean -connect_to_port (int port) -{ - GibberLLTransport *transport; - struct sockaddr_in addr; - gboolean result; - - transport = gibber_ll_transport_new (); - - memset (&addr, 0, sizeof (addr)); - addr.sin_family = AF_INET; - addr.sin_port = htons (port); - addr.sin_addr.s_addr = inet_addr ("127.0.0.1"); - - result = gibber_ll_transport_open_sockaddr (transport, - (struct sockaddr_storage *) &addr, NULL); - - g_object_unref (transport); - return result; -} - -static void -test_listen (void) -{ - GibberXmppConnectionListener *listener; - int port; - gboolean result; - - got_connection = FALSE; - - listener = gibber_xmpp_connection_listener_new (); - g_assert (listener != NULL); - - g_signal_connect (listener, "new-connection", G_CALLBACK (new_connection_cb), - NULL); - - for (port = 5298; port < 5400; port++) - { - GError *error = NULL; - if (gibber_xmpp_connection_listener_listen (listener, port, &error)) - break; - - g_assert_error (error, GIBBER_LISTENER_ERROR, - GIBBER_LISTENER_ERROR_ADDRESS_IN_USE); - g_error_free (error); - error = NULL; - } - g_assert (port < 5400); - - result = connect_to_port (port); - g_assert (result != FALSE); - - while (g_main_context_iteration (NULL, FALSE)) - ; - g_assert (got_connection); - - g_object_unref (listener); - - /* listener is destroyed, connection should be refused now */ - got_connection = FALSE; - result = connect_to_port (port); - g_assert (result != TRUE); -} - -int -main (int argc, - char **argv) -{ - g_test_init (&argc, &argv, NULL); - g_type_init (); - - g_test_add_func ("/gibber/xmpp-connection-listener/listen", - test_listen); - - return g_test_run (); -} |