add azimuth.[ch]
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Sun, 2 May 2010 10:32:07 +0000 (12:32 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Sun, 2 May 2010 10:51:27 +0000 (12:51 +0200)
src/Makefile.am
src/azimuth.c [new file with mode: 0644]
src/azimuth.h [new file with mode: 0644]

index f00246d..41bf042 100644 (file)
@@ -24,6 +24,8 @@ bin_PROGRAMS = \
        azimuth
 
 azimuth_SOURCES = \
        azimuth
 
 azimuth_SOURCES = \
+       azimuth.c \
+       azimuth.h \
        main.c \
        connection-watcher.c \
        position-publisher.c
        main.c \
        connection-watcher.c \
        position-publisher.c
diff --git a/src/azimuth.c b/src/azimuth.c
new file mode 100644 (file)
index 0000000..4176c5d
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * azimuth.c - Source for Azimith
+ * Copyright (C) 2010 Guillaume Desmottes
+ * @author Guillaume Desmottes <gdesmott@gnome.org>
+ *
+ * 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 "azimuth.h"
+#include "position-publisher.h"
+
+G_DEFINE_TYPE(Azimuth, azimuth, G_TYPE_OBJECT)
+
+/* private structure */
+typedef struct _AzimuthPrivate AzimuthPrivate;
+
+struct _AzimuthPrivate
+{
+  GMainLoop *loop;
+  PositionPublisher *publisher;
+};
+
+#define AZIMUTH_GET_PRIVATE(o)     (G_TYPE_INSTANCE_GET_PRIVATE ((o), AZIMUTH_TYPE, AzimuthPrivate))
+
+static void
+azimuth_init (Azimuth *obj)
+{
+  AzimuthPrivate *priv = AZIMUTH_GET_PRIVATE (obj);
+
+  priv->loop = g_main_loop_new (NULL, FALSE);
+  priv->publisher = NULL;
+}
+
+static void
+azimuth_dispose (GObject *object)
+{
+  Azimuth *self = AZIMUTH (object);
+  AzimuthPrivate *priv = AZIMUTH_GET_PRIVATE (self);
+
+  if (priv->publisher != NULL)
+    {
+      g_object_unref (priv->publisher);
+      priv->publisher = NULL;
+    }
+
+  if (priv->loop != NULL)
+    {
+      g_main_loop_unref (priv->loop);
+      priv->loop = NULL;
+    }
+
+  if (G_OBJECT_CLASS (azimuth_parent_class)->dispose)
+    G_OBJECT_CLASS (azimuth_parent_class)->dispose (object);
+}
+
+static void
+azimuth_class_init (AzimuthClass *azimuth_class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (azimuth_class);
+
+  g_type_class_add_private (azimuth_class, sizeof (AzimuthPrivate));
+
+  object_class->dispose = azimuth_dispose;
+}
+
+Azimuth *
+azimuth_new (void)
+{
+  return g_object_new (AZIMUTH_TYPE,
+      NULL);
+}
+
+void
+azimuth_run (Azimuth *self)
+{
+  AzimuthPrivate *priv = AZIMUTH_GET_PRIVATE (self);
+
+  g_assert (priv->publisher == NULL);
+  priv->publisher = position_publisher_new ();
+
+  g_print ("azimuth running\n");
+  g_main_loop_run (priv->loop);
+}
diff --git a/src/azimuth.h b/src/azimuth.h
new file mode 100644 (file)
index 0000000..5d96828
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * azimuth.h - Header for Azimith
+ * Copyright (C) 2010 Guillaume Desmottes
+ * @author Guillaume Desmottes <gdesmott@gnome.org>
+ *
+ * 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 __AZIMUTH_H__
+#define __AZIMUTH_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef struct _Azimuth Azimuth;
+typedef struct _AzimuthClass AzimuthClass;
+
+struct _AzimuthClass {
+    GObjectClass parent_class;
+};
+
+struct _Azimuth {
+    GObject parent;
+};
+
+GType azimuth_get_type (void);
+
+/* TYPE MACROS */
+#define AZIMUTH_TYPE \
+  (azimuth_get_type())
+#define AZIMUTH(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), AZIMUTH_TYPE, Azimuth))
+#define AZIMUTH_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), AZIMUTH_TYPE, AzimuthClass))
+#define IS_AZIMUTH(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), AZIMUTH_TYPE))
+#define IS_AZIMUTH_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), AZIMUTH_TYPE))
+#define AZIMUTH_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), AZIMUTH_TYPE, AzimuthClass))
+
+Azimuth * azimuth_new (void);
+
+void azimuth_run (Azimuth *self);
+
+G_END_DECLS
+
+#endif /* #ifndef __AZIMUTH_H__*/