gio-strigi r2 - in trunk: . src
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: gio-strigi r2 - in trunk: . src
- Date: Thu, 26 Feb 2009 22:29:44 +0000 (UTC)
Author: pvanhoof
Date: Thu Feb 26 22:29:44 2009
New Revision: 2
URL: http://svn.gnome.org/viewvc/gio-strigi?rev=2&view=rev
Log:
Added initial commit
Added:
trunk/MAINTAINERS
trunk/Makefile.am
trunk/autogen.sh (contents, props changed)
trunk/configure.ac
trunk/src/
trunk/src/Makefile.am
trunk/src/gio-strigi.pc.in
trunk/src/strigi-buffered-stream.cpp
trunk/src/strigi-buffered-stream.h
trunk/src/strigi-gio-inputstream.cpp
trunk/src/strigi-gio-inputstream.h
Added: trunk/MAINTAINERS
==============================================================================
--- (empty file)
+++ trunk/MAINTAINERS Thu Feb 26 22:29:44 2009
@@ -0,0 +1,7 @@
+Philip Van Hoof
+E-mail: philip codeminded be
+Userid: pvanhoof
+
+Jos van den Oever
+E-mail jvdoever gmail com
+
Added: trunk/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/Makefile.am Thu Feb 26 22:29:44 2009
@@ -0,0 +1 @@
+SUBDIRS = src
Added: trunk/autogen.sh
==============================================================================
--- (empty file)
+++ trunk/autogen.sh Thu Feb 26 22:29:44 2009
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -e
+
+if [ "$1" = "clean" ]; then
+ rm -f aclocal.m4 configure missing install-sh \
+ depcomp ltmain.sh config.guess config.sub \
+ `find . -name Makefile.in` compile \
+ docs/reference/gtk-doc.make
+ rm -rf autom4te.cache
+ exit
+fi
+
+libtoolize --automake
+aclocal
+automake --add-missing --foreign
+autoconf
+
+CFLAGS=${CFLAGS=-ggdb -Werror}
+LDFLAGS=${LDFLAGS=-Wl,-O1}
+export CFLAGS LDFLAGS
+
+./configure --enable-maintainer-mode "$@"
Added: trunk/configure.ac
==============================================================================
--- (empty file)
+++ trunk/configure.ac Thu Feb 26 22:29:44 2009
@@ -0,0 +1,88 @@
+AC_INIT(gio-strigi, alpha)
+AM_INIT_AUTOMAKE
+
+AC_PROG_LIBTOOL
+AC_PROG_CC
+AC_PROG_CPP
+
+PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
+PKG_CHECK_MODULES(GIO, gio-unix-2.0)
+PKG_CHECK_MODULES(STREAMANALYZER, libstreamanalyzer)
+
+AC_SUBST(GTHREAD_CFLAGS)
+AC_SUBST(GTHREAD_LIBS)
+AC_SUBST(GIO_CFLAGS)
+AC_SUBST(GIO_LIBS)
+AC_SUBST(STREAMANALYZER_CFLAGS)
+AC_SUBST(STREAMANALYZER_LIBS)
+
+
+AC_ARG_ENABLE(vala,
+ AS_HELP_STRING([--enable-vala],
+ [Enable vala (for .vapi output)]),
+ [], [
+ if test -n "`$PKG_CONFIG --variable=vapigen \
+ 'vala-1.0 >= 0.5.7'`"; then
+ enable_vala=yes
+ else
+ enable_vala=no
+ fi
+ ])
+
+if test "$enable_vala" = "yes"; then
+ PKG_CHECK_MODULES(vala, vala-1.0 >= 0.5.7)
+
+ vala_VAPIGEN="`$PKG_CONFIG --variable=vapigen vala-1.0`"
+ AC_SUBST(vala_VAPIGEN)
+
+ vala_GENINTROSPECT="`$PKG_CONFIG --variable=gen_introspect vala-1.0`"
+ AC_SUBST(vala_GENINTROSPECT)
+fi
+
+AM_CONDITIONAL(ENABLE_VALA, test "$enable_vala" = "yes")
+
+AC_ARG_ENABLE(introspection,
+ AS_HELP_STRING([--enable-introspection],
+ [Enable gobject-introspection (for .gir output)]),
+ [], [
+ enable_introspection=no
+ if $PKG_CONFIG --exists 'gobject-introspection-1.0 >= 0.6.3'
+ then
+ if grep -q g_inet_address_get_is_any \
+ "`$PKG_CONFIG --variable=girdir \
+ gobject-introspection-1.0`/Gio-2.0.gir"; then
+ enable_introspection=yes
+ else
+ AC_MSG_WARN(gobject-introspection is installed but your Gio-2.0.gir was not generated against your currently installed glib. Disabling gobject-introspection support.)
+ fi
+ fi
+ ])
+
+if test "$enable_introspection" = "yes"; then
+ PKG_CHECK_MODULES(gobject_introspection, gobject-introspection-1.0 >= 0.6.3)
+
+ _PKG_CONFIG(GIRSCANNER, [variable=g_ir_scanner], [gobject-introspection-1.0])
+ GIRSCANNER=$pkg_cv_GIRSCANNER
+ AC_SUBST(GIRSCANNER)
+fi
+AM_CONDITIONAL(ENABLE_INTROSPECTION, test "$enable_introspection" = "yes")
+
+
+AC_ARG_ENABLE(gir-vapi,
+ AS_HELP_STRING([--enable-gir-vapi],
+ [Enable experimental .vapi generation via .gir]),
+ [
+ if test "$enableval" = "yes"; then
+ if test "$enable_vala" != "yes" -o \
+ "$enable_introspection" != "yes"; then
+ AC_MSG_ERROR([vala and gobject-introspection must be enabled to support vapi generation via .gir])
+ fi
+ fi
+ ])
+AM_CONDITIONAL(ENABLE_GIR_VAPI, test "$enable_gir_vapi" = "yes")
+
+AC_OUTPUT([
+ src/Makefile
+ src/gio-strigi.pc
+ Makefile
+])
Added: trunk/src/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/src/Makefile.am Thu Feb 26 22:29:44 2009
@@ -0,0 +1,25 @@
+INCLUDES = -I. -I.. \
+ $(GTHREAD_CFLAGS) \
+ $(GIO_CFLAGS) \
+ $(STREAMANALYZER_CFLAGS)
+
+lib_LTLIBRARIES = libgio-strigi.la
+
+include_HEADERS = \
+ strigi-gio-inputstream.h \
+ strigi-buffered-stream.h
+
+libgio_strigi_la_SOURCES = $(include_HEADERS) \
+ strigi-gio-inputstream.cpp \
+ strigi-buffered-stream.cpp
+
+libgio_strigi_la_LDFLAGS = -version-info 0:0:0
+
+libgio_strigi_la_LIBADD = \
+ $(GTHREAD_LIBS) \
+ $(GIO_LIBS) \
+ $(STREAMANALYZER_LIBS)
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = gio-strigi.pc
+
Added: trunk/src/gio-strigi.pc.in
==============================================================================
--- (empty file)
+++ trunk/src/gio-strigi.pc.in Thu Feb 26 22:29:44 2009
@@ -0,0 +1,13 @@
+prefix= prefix@
+exec_prefix= prefix@/bin
+libdir= prefix@/lib
+includedir= prefix@/include/gio-strigi
+
+giostrigivapidir= prefix@/share/vala/vapi
+
+Name: gio-strigi
+Description: a GObject strigi binding
+Version: 0.1
+Requires: glib-2.0 gobject-2.0 gio-2.0
+Libs: -L${libdir} -lgio-strigi
+Cflags: -I${includedir}
Added: trunk/src/strigi-buffered-stream.cpp
==============================================================================
--- (empty file)
+++ trunk/src/strigi-buffered-stream.cpp Thu Feb 26 22:29:44 2009
@@ -0,0 +1,251 @@
+/* This file is part of Strigi Desktop Search
+ *
+ * Copyright (C) 2009 Philip Van Hoof <philip codeminded be>
+ *
+ * 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 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., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "strigi-buffered-stream.h"
+
+
+G_DEFINE_TYPE (StrigiBufferedStream, strigi_buffered_stream, G_TYPE_INPUT_STREAM);
+
+enum
+{
+ PROP_0,
+ PROP_CPPOBJ
+};
+
+struct _StrigiBufferedStreamPrivate
+{
+ Strigi::BufferedInputStream *cppobj;
+ /* pending operation metadata */
+ GSimpleAsyncResult *result;
+ GCancellable *cancellable;
+ GMutex *lock;
+ gpointer buffer;
+ gsize count;
+ gssize pos;
+};
+
+static void
+strigi_buffered_stream_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ StrigiBufferedStream *stream = STRIGI_BUFFERED_STREAM (object);
+
+ switch (prop_id)
+ {
+ case PROP_CPPOBJ:
+ g_value_set_pointer (value, stream->priv->cppobj);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+strigi_buffered_stream_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ StrigiBufferedStream *stream = STRIGI_BUFFERED_STREAM (object);
+
+ switch (prop_id)
+ {
+ case PROP_CPPOBJ:
+ stream->priv->cppobj = (Strigi::BufferedInputStream *) g_value_get_pointer (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+strigi_buffered_stream_finalize (GObject *object)
+{
+ StrigiBufferedStream *stream = STRIGI_BUFFERED_STREAM (object);
+
+ if (stream->priv->cppobj)
+ delete stream->priv->cppobj;
+
+ g_mutex_free (stream->priv->lock);
+
+ if (G_OBJECT_CLASS (strigi_buffered_stream_parent_class)->finalize)
+ (*G_OBJECT_CLASS (strigi_buffered_stream_parent_class)->finalize) (object);
+}
+
+static gssize
+cpp_read (StrigiBufferedStream *stream,
+ void *buffer, gsize count,
+ GCancellable *cancellable, GError **error)
+{
+ Strigi::BufferedInputStream *cppobj = stream->priv->cppobj;
+ const char* d;
+ int32_t n = cppobj->read(d, stream->priv->pos, count);
+ stream->priv->pos += n;
+}
+
+static gssize
+strigi_buffered_stream_read (GInputStream *stream,
+ void *buffer,
+ gsize count,
+ GCancellable *cancellable,
+ GError **error)
+{
+ StrigiBufferedStream *input_stream = STRIGI_BUFFERED_STREAM (stream);
+ gssize ret;
+
+ g_mutex_lock (input_stream->priv->lock);
+ cpp_read (input_stream, buffer, count, cancellable, error);
+ g_mutex_unlock (input_stream->priv->lock);
+
+ return ret;
+}
+
+static gpointer
+strigi_buffered_stream_read_ready (gpointer data)
+{
+ StrigiBufferedStream *stream = (StrigiBufferedStream *) data;
+ GSimpleAsyncResult *simple;
+ GError *error = NULL;
+
+ simple = stream->priv->result;
+ stream->priv->result = NULL;
+
+ if (!g_cancellable_set_error_if_cancelled (stream->priv->cancellable,
+ &error))
+ {
+ gssize result;
+
+ g_mutex_lock (stream->priv->lock);
+ cpp_read (stream, stream->priv->buffer,
+ stream->priv->count,
+ stream->priv->cancellable, &error);
+ g_mutex_unlock (stream->priv->lock);
+
+ if (result >= 0)
+ g_simple_async_result_set_op_res_gssize (simple, result);
+ }
+
+ if (error)
+ {
+ g_simple_async_result_set_from_error (simple, error);
+ g_error_free (error);
+ }
+
+ if (stream->priv->cancellable)
+ g_object_unref (stream->priv->cancellable);
+
+ g_simple_async_result_complete_in_idle (simple);
+
+ g_object_unref (simple);
+
+ return NULL;
+}
+
+
+static void
+strigi_buffered_stream_read_async (GInputStream *stream,
+ void *buffer,
+ gsize count,
+ gint io_priority,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ StrigiBufferedStream *input_stream = STRIGI_BUFFERED_STREAM (stream);
+ GThread *thread;
+
+ g_assert (input_stream->priv->result == NULL);
+
+ input_stream->priv->result =
+ g_simple_async_result_new (G_OBJECT (stream), callback, user_data,
+ (gpointer) strigi_buffered_stream_read_ready);
+
+ if (cancellable)
+ g_object_ref (cancellable);
+
+ input_stream->priv->cancellable = cancellable;
+ input_stream->priv->buffer = buffer;
+ input_stream->priv->count = count;
+
+ thread = g_thread_create (strigi_buffered_stream_read_ready,
+ stream,
+ FALSE, NULL);
+
+}
+
+static gssize
+strigi_buffered_stream_read_finish (GInputStream *stream,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple;
+ gssize count;
+
+ g_return_val_if_fail (STRIGI_IS_BUFFERED_STREAM (stream), -1);
+
+ simple = G_SIMPLE_ASYNC_RESULT (result);
+
+ g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == strigi_buffered_stream_read_async);
+
+ count = g_simple_async_result_get_op_res_gssize (simple);
+
+ return count;
+}
+
+static void
+strigi_buffered_stream_class_init (StrigiBufferedStreamClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GInputStreamClass *ginputstream_class = G_INPUT_STREAM_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (StrigiBufferedStreamPrivate));
+
+ gobject_class->finalize = strigi_buffered_stream_finalize;
+ gobject_class->get_property = strigi_buffered_stream_get_property;
+ gobject_class->set_property = strigi_buffered_stream_set_property;
+
+ ginputstream_class->read_fn = strigi_buffered_stream_read;
+ ginputstream_class->read_async = strigi_buffered_stream_read_async;
+ ginputstream_class->read_finish = strigi_buffered_stream_read_finish;
+
+ g_object_class_install_property (gobject_class, PROP_CPPOBJ,
+ g_param_spec_pointer ("cppobj", "cppobj",
+ "C++ object", (GParamFlags)
+ (G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE)));
+}
+
+static void
+strigi_buffered_stream_init (StrigiBufferedStream *stream)
+{
+ stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream, STRIGI_TYPE_BUFFERED_STREAM, StrigiBufferedStreamPrivate);
+ stream->priv->lock = g_mutex_new ();
+}
+
+GInputStream*
+strigi_buffered_stream_new (void *cppobj)
+{
+ return G_INPUT_STREAM (g_object_new (STRIGI_TYPE_BUFFERED_STREAM, "cppobj", cppobj, NULL));
+}
Added: trunk/src/strigi-buffered-stream.h
==============================================================================
--- (empty file)
+++ trunk/src/strigi-buffered-stream.h Thu Feb 26 22:29:44 2009
@@ -0,0 +1,55 @@
+/* This file is part of Strigi Desktop Search
+ *
+ * Copyright (C) 2009 Philip Van Hoof <philip codeminded be>
+ *
+ * This program 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 of the licence or (at
+ * your option) any later version.
+ *
+ * See the included COPYING file for more information.
+ *
+ */
+
+#ifndef _strigibufferedstream_h_
+#define _strigibufferedstream_h_
+
+#include <gio/gio.h>
+
+#include <strigi/bufferedstream.h>
+
+G_BEGIN_DECLS
+
+#define STRIGI_TYPE_BUFFERED_STREAM (strigi_buffered_stream_get_type ())
+#define STRIGI_BUFFERED_STREAM(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
+ STRIGI_TYPE_BUFFERED_STREAM, StrigiBufferedStream))
+#define STRIGI_BUFFERED_STREAM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
+ STRIGI_TYPE_BUFFERED_STREAM, StrigiBufferedStreamClass))
+#define STRIGI_IS_BUFFERED_STREAM(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
+ STRIGI_TYPE_BUFFERED_STREAM))
+#define STRIGI_IS_BUFFERED_STREAM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
+ STRIGI_TYPE_BUFFERED_STREAM))
+#define STRIGI_BUFFERED_STREAM_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
+ STRIGI_TYPE_BUFFERED_STREAM, StrigiBufferedStreamClass))
+
+typedef struct _StrigiBufferedStreamPrivate StrigiBufferedStreamPrivate;
+typedef struct _StrigiBufferedStreamClass StrigiBufferedStreamClass;
+typedef struct _StrigiBufferedStream StrigiBufferedStream;
+
+struct _StrigiBufferedStreamClass
+{
+ GInputStreamClass parent_class;
+};
+
+struct _StrigiBufferedStream
+{
+ GInputStream parent_instance;
+ StrigiBufferedStreamPrivate *priv;
+};
+
+GType strigi_buffered_stream_get_type (void);
+GInputStream* strigi_buffered_stream_new (void *cppobj);
+
+G_END_DECLS
+
+#endif /* _strigibufferedstream_h_ */
Added: trunk/src/strigi-gio-inputstream.cpp
==============================================================================
--- (empty file)
+++ trunk/src/strigi-gio-inputstream.cpp Thu Feb 26 22:29:44 2009
@@ -0,0 +1,47 @@
+/* This file is part of Strigi Desktop Search
+ *
+ * Copyright (C) 2009 Jos van den Oever <jos vandenoever info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#include "strigi-gio-inputstream.h"
+
+using namespace Tracker;
+
+GioInputStream::GioInputStream(GInputStream* input)
+ :p((Private*)input) {
+ // The private member would only contain a pointer to an input object,
+ // so we avoid an allocation by casting GInputStream to it.
+}
+GioInputStream::~GioInputStream() {
+}
+/**
+ * Implementation of abstract virtual function from Strigi::BufferedStream.
+ * See Strigi::BufferedStream for documentation.
+ **/
+int32_t
+GioInputStream::fillBuffer(char* start, int32_t space) {
+ GInputStream* const g((GInputStream*)p);
+ GError* error = NULL;
+ gsize nread = g_input_stream_read(g, start, space, 0, &error);
+ if (error != NULL) {
+ m_status = Strigi::Error;
+ m_error.assign(error->message);
+ g_error_free(error);
+ return -1;
+ }
+ return nread;
+}
Added: trunk/src/strigi-gio-inputstream.h
==============================================================================
--- (empty file)
+++ trunk/src/strigi-gio-inputstream.h Thu Feb 26 22:29:44 2009
@@ -0,0 +1,55 @@
+/* This file is part of Strigi Desktop Search
+ *
+ * Copyright (C) 2009 Jos van den Oever <jos vandenoever info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef GIOINPUTSTREAM_H
+#define GIOINPUTSTREAM_H
+
+#include <strigi/bufferedstream.h>
+#include <gio/gio.h>
+
+/**
+ * This class wraps a GInputStream in a Strigi::BufferedInputStream.
+ **/
+
+// can be used for exporting the class in a library
+#define TRACKER_EXPORT
+
+namespace Tracker {
+
+/**
+ * Simple wrapper of GInputStream in a Strigi stream.
+ * This enables analyzing gio streams with libstreamanalyzer.
+ **/
+class TRACKER_EXPORT GioInputStream : public Strigi::BufferedInputStream {
+private:
+ class Private;
+ Private* const p;
+ int32_t fillBuffer(char* start, int32_t space);
+public:
+ /**
+ * Construct a new GioInputStream.
+ * Note: GioInputStream does not take ownership of @p input.
+ **/
+ explicit GioInputStream(GInputStream* input);
+ ~GioInputStream();
+};
+
+} // end namespace Tracker
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]