[Telepathy-commits] [telepathy-salut/master] Add GibberUnixTransport, child of GibberFdTransport

Alban Crequy alban.crequy at collabora.co.uk
Tue Nov 4 04:51:07 PST 2008


---
 lib/gibber/Makefile.am             |    2 +
 lib/gibber/gibber-unix-transport.c |  112 ++++++++++++++++++++++++++++++++++++
 lib/gibber/gibber-unix-transport.h |   75 ++++++++++++++++++++++++
 3 files changed, 189 insertions(+), 0 deletions(-)
 create mode 100644 lib/gibber/gibber-unix-transport.c
 create mode 100644 lib/gibber/gibber-unix-transport.h

diff --git a/lib/gibber/Makefile.am b/lib/gibber/Makefile.am
index 891a749..7e89840 100644
--- a/lib/gibber/Makefile.am
+++ b/lib/gibber/Makefile.am
@@ -38,6 +38,8 @@ HANDWRITTEN_SOURCES =             \
   gibber-fd-transport.h           \
   gibber-tcp-transport.c          \
   gibber-tcp-transport.h          \
+  gibber-unix-transport.c         \
+  gibber-unix-transport.h         \
   gibber-multicast-transport.c    \
   gibber-multicast-transport.h    \
   gibber-r-multicast-transport.c  \
diff --git a/lib/gibber/gibber-unix-transport.c b/lib/gibber/gibber-unix-transport.c
new file mode 100644
index 0000000..cc40d37
--- /dev/null
+++ b/lib/gibber/gibber-unix-transport.c
@@ -0,0 +1,112 @@
+/*
+ * gibber-linklocal-transport.c - Source for GibberLLTransport
+ * Copyright (C) 2006 Collabora Ltd.
+ *   @author: Sjoerd Simons <sjoerd at luon.net>
+ *
+ * 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 <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+
+#include "gibber-unix-transport.h"
+#include "gibber-util.h"
+
+#define DEBUG_FLAG DEBUG_NET
+#include "gibber-debug.h"
+
+/* Buffer size used for reading input */
+#define BUFSIZE 1024
+
+G_DEFINE_TYPE(GibberUnixTransport, gibber_unix_transport, \
+    GIBBER_TYPE_FD_TRANSPORT)
+
+GQuark
+gibber_unix_transport_error_quark (void)
+{
+  static GQuark quark = 0;
+
+  if (!quark)
+    quark = g_quark_from_static_string ("gibber_unix_transport_error");
+
+  return quark;
+}
+
+/* private structure */
+typedef struct _GibberUnixTransportPrivate GibberUnixTransportPrivate;
+
+struct _GibberUnixTransportPrivate
+{
+  gboolean incoming;
+  gboolean dispose_has_run;
+};
+
+#define GIBBER_UNIX_TRANSPORT_GET_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GIBBER_TYPE_UNIX_TRANSPORT, \
+     GibberUnixTransportPrivate))
+
+static void gibber_unix_transport_finalize (GObject *object);
+
+static void
+gibber_unix_transport_init (GibberUnixTransport *self)
+{
+  GibberUnixTransportPrivate *priv = GIBBER_UNIX_TRANSPORT_GET_PRIVATE (self);
+  priv->incoming = FALSE;
+}
+
+static void gibber_unix_transport_dispose (GObject *object);
+static void
+gibber_unix_transport_class_init (
+    GibberUnixTransportClass *gibber_unix_transport_class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (gibber_unix_transport_class);
+
+  g_type_class_add_private (gibber_unix_transport_class,
+                            sizeof (GibberUnixTransportPrivate));
+
+  object_class->dispose = gibber_unix_transport_dispose;
+  object_class->finalize = gibber_unix_transport_finalize;
+}
+
+void
+gibber_unix_transport_dispose (GObject *object)
+{
+  GibberUnixTransport *self = GIBBER_UNIX_TRANSPORT (object);
+  GibberUnixTransportPrivate *priv = GIBBER_UNIX_TRANSPORT_GET_PRIVATE (self);
+
+  if (priv->dispose_has_run)
+    return;
+
+  priv->dispose_has_run = TRUE;
+
+  if (G_OBJECT_CLASS (gibber_unix_transport_parent_class)->dispose)
+    G_OBJECT_CLASS (gibber_unix_transport_parent_class)->dispose (object);
+}
+
+void
+gibber_unix_transport_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (gibber_unix_transport_parent_class)->finalize (object);
+}
+
+GibberUnixTransport *
+gibber_unix_transport_new (void)
+{
+  return g_object_new (GIBBER_TYPE_UNIX_TRANSPORT, NULL);
+}
diff --git a/lib/gibber/gibber-unix-transport.h b/lib/gibber/gibber-unix-transport.h
new file mode 100644
index 0000000..9a9742a
--- /dev/null
+++ b/lib/gibber/gibber-unix-transport.h
@@ -0,0 +1,75 @@
+/*
+ * gibber-unix-transport.h - Header for GibberUnixTransport
+ * Copyright (C) 2006, 2008 Collabora Ltd.
+ *   @author: Sjoerd Simons <sjoerd at luon.net>
+ *   @author: Alban Crequy <alban.crequy at 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
+ */
+
+#ifndef __GIBBER_UNIX_TRANSPORT_H__
+#define __GIBBER_UNIX_TRANSPORT_H__
+
+#include <glib-object.h>
+
+#include "gibber-fd-transport.h"
+
+G_BEGIN_DECLS
+
+GQuark gibber_unix_transport_error_quark (void);
+#define GIBBER_UNIX_TRANSPORT_ERROR gibber_unix_transport_error_quark()
+
+typedef enum
+{
+  GIBBER_UNIX_TRANSPORT_ERROR_CONNECT_FAILED,
+  GIBBER_UNIX_TRANSPORT_ERROR_FAILED,
+} GibberUnixTransportError;
+
+typedef struct _GibberUnixTransport GibberUnixTransport;
+typedef struct _GibberUnixTransportClass GibberUnixTransportClass;
+
+
+struct _GibberUnixTransportClass {
+    GibberFdTransportClass parent_class;
+};
+
+struct _GibberUnixTransport {
+    GibberFdTransport parent;
+};
+
+GType gibber_unix_transport_get_type (void);
+
+/* TYPE MACROS */
+#define GIBBER_TYPE_UNIX_TRANSPORT \
+  (gibber_unix_transport_get_type ())
+#define GIBBER_UNIX_TRANSPORT(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), GIBBER_TYPE_UNIX_TRANSPORT, \
+   GibberUnixTransport))
+#define GIBBER_UNIX_TRANSPORT_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), GIBBER_TYPE_UNIX_TRANSPORT,  \
+   GibberUnixTransportClass))
+#define GIBBER_IS_UNIX_TRANSPORT(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), GIBBER_TYPE_UNIX_TRANSPORT))
+#define GIBBER_IS_UNIX_TRANSPORT_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), GIBBER_TYPE_UNIX_TRANSPORT))
+#define GIBBER_UNIX_TRANSPORT_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIBBER_TYPE_UNIX_TRANSPORT, \
+   GibberUnixTransportClass))
+
+GibberUnixTransport * gibber_unix_transport_new (void);
+
+G_END_DECLS
+
+#endif /* #ifndef __GIBBER_UNIX_TRANSPORT_H__*/
-- 
1.5.6.5




More information about the Telepathy-commits mailing list