summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@src.gnome.org>2003-11-19 04:53:40 +0000
committerShaun McCance <shaunm@src.gnome.org>2003-11-19 04:53:40 +0000
commit8010abca201c80f31f00c9ff9f0a5110bdb34c3b (patch)
tree1daffb4f229598078bd65a17e537bd8bcff74313
parente372900584273001b24b7fe2a3ebcbb8746c1f17 (diff)
downloadyelp-8010abca201c80f31f00c9ff9f0a5110bdb34c3b.tar.gz
- Removing YelpReader
* src/Makefile.am: * src/yelp-reader.c: * src/yelp-reader.h: - Removing YelpReader
-rw-r--r--ChangeLog7
-rw-r--r--src/Makefile.am14
-rw-r--r--src/yelp-reader.c971
-rw-r--r--src/yelp-reader.h70
4 files changed, 8 insertions, 1054 deletions
diff --git a/ChangeLog b/ChangeLog
index 62df7a0c..1518d182 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2003-11-18 Shaun McCance <shaunm@gnome.org>
+ * src/Makefile.am:
+ * src/yelp-reader.c:
+ * src/yelp-reader.h:
+ - Removing YelpReader
+
+2003-11-18 Shaun McCance <shaunm@gnome.org>
+
* src/yelp-toc-pager.c:
- Only read files ending in .omf
diff --git a/src/Makefile.am b/src/Makefile.am
index 3a7d8a40..69a0f63d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,7 +18,7 @@ INCLUDES = \
libexec_PROGRAMS = yelp-db2html
bin_PROGRAMS = yelp yelp-pregenerate
-noinst_PROGRAMS = test-uri test-reader test-pager
+noinst_PROGRAMS = test-uri test-pager
test_uri_SOURCES = \
test-uri.c \
yelp-uri.c yelp-uri.h
@@ -26,18 +26,6 @@ test_uri_SOURCES = \
test_uri_LDADD = \
@YELP_LIBS@
-test_reader_SOURCES = \
- test-reader.c \
- yelp-uri.c yelp-uri.h \
- yelp-cache.c yelp-cache.h \
- yelp-reader.c yelp-reader.h \
- yelp-error.c yelp-error.h \
- yelp-util.c yelp-util.h \
- yelp-marshal-main.c
-
-test_reader_LDADD = \
- @YELP_LIBS@
-
test_pager_SOURCES = \
test-pager.c \
yelp-pager.c yelp-pager.h \
diff --git a/src/yelp-reader.c b/src/yelp-reader.c
deleted file mode 100644
index b018fd7b..00000000
--- a/src/yelp-reader.c
+++ /dev/null
@@ -1,971 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2002 Mikael Hallendal <micke@imendio.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Mikael Hallendal <micke@imendio.com>
- */
-
-#include <libgnome/gnome-url.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <libxml/xmlIO.h>
-#include <libxslt/xslt.h>
-#include <libxslt/xsltInternals.h>
-#include <libxslt/transform.h>
-#include <libxslt/xsltutils.h>
-#include <string.h>
-
-#include "yelp-cache.h"
-#include "yelp-marshal.h"
-#include "yelp-reader.h"
-
-#define d(x)
-
-#define BUFFER_SIZE 16384
-
-#define STAMP_MUTEX_LOCK g_mutex_lock(priv->stamp_mutex);
-#define STAMP_MUTEX_UNLOCK g_mutex_unlock(priv->stamp_mutex);
-
-struct _YelpReaderPriv {
- gint stamp;
-
- gboolean active;
-
- /* Locks */
- GMutex *stamp_mutex;
- GAsyncQueue *thread_queue;
-};
-
-typedef struct {
- YelpReader *reader;
- gint stamp;
- YelpURI *uri;
-} ReaderThreadData;
-
-typedef enum {
- READER_QUEUE_TYPE_START,
- READER_QUEUE_TYPE_DATA,
- READER_QUEUE_TYPE_CANCELLED,
- READER_QUEUE_TYPE_FINISHED
-} ReaderQueueType;
-
-typedef struct {
- YelpReader *reader;
- gint stamp;
- gchar *data;
- ReaderQueueType type;
-} ReaderQueueData;
-
-static void reader_class_init (YelpReaderClass *klass);
-static void reader_init (YelpReader *reader);
-
-static void reader_convert_start (ReaderThreadData *th_data);
-
-static void reader_file_start (ReaderThreadData *th_data);
-
-static gboolean reader_check_cancelled (YelpReader *reader,
- gint stamp);
-static gpointer reader_start (ReaderThreadData *th_data);
-static void reader_change_stamp (YelpReader *reader);
-static gboolean reader_idle_check_queue (ReaderThreadData *th_data);
-
-static ReaderQueueData *
-reader_q_data_new (YelpReader *reader,
- gint stamp,
- ReaderQueueType type);
-static void reader_q_data_free (ReaderQueueData *q_data);
-
-#if 0
-/* FIXME: Solve this so we don't leak */
-static void reader_th_data_free (ReaderThreadData *th_data);
-#endif
-static gchar * reader_get_chunk (const gchar *document,
- const gchar *section);
-static gchar *
-reader_look_for_cached_help_file (const gchar *url);
-
-enum {
- START,
- DATA,
- FINISHED,
- CANCELLED,
- ERROR,
- LAST_SIGNAL
-};
-
-static gint signals[LAST_SIGNAL] = { 0 };
-
-GType
-yelp_reader_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info =
- {
- sizeof (YelpReaderClass),
- NULL,
- NULL,
- (GClassInitFunc) reader_class_init,
- NULL,
- NULL,
- sizeof (YelpReader),
- 0,
- (GInstanceInitFunc) reader_init,
- };
-
- type = g_type_register_static (G_TYPE_OBJECT,
- "YelpReader",
- &info, 0);
- }
-
- return type;
-}
-
-static void
-reader_class_init (YelpReaderClass *klass)
-{
- signals[START] =
- g_signal_new ("start",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (YelpReaderClass,
- start),
- NULL, NULL,
- yelp_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- signals[DATA] =
- g_signal_new ("data",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (YelpReaderClass,
- data),
- NULL, NULL,
- yelp_marshal_VOID__STRING_INT,
- G_TYPE_NONE,
- 2, G_TYPE_STRING, G_TYPE_INT);
-
- signals[FINISHED] =
- g_signal_new ("finished",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (YelpReaderClass,
- finished),
- NULL, NULL,
- yelp_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1, G_TYPE_POINTER);
- signals[CANCELLED] =
- g_signal_new ("cancelled",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (YelpReaderClass,
- cancelled),
- NULL, NULL,
- yelp_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals[ERROR] =
- g_signal_new ("error",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (YelpReaderClass,
- error),
- NULL, NULL,
- yelp_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1, G_TYPE_POINTER);
-}
-
-static void
-reader_init (YelpReader *reader)
-{
- YelpReaderPriv *priv;
-
- priv = g_new0 (YelpReaderPriv, 1);
- reader->priv = priv;
-
- priv->active = FALSE;
- priv->stamp = 0;
- priv->stamp_mutex = g_mutex_new ();
- priv->thread_queue = g_async_queue_new ();
-}
-
-static void
-reader_convert_start (ReaderThreadData *th_data)
-{
- YelpReader *reader;
- YelpReaderPriv *priv;
- YelpURI *uri;
- gchar *command_line = NULL;
- GError *error = NULL;
- gint exit_status;
- ReaderQueueData *q_data;
- gint stamp;
-
- g_return_if_fail (th_data != NULL);
-
- reader = th_data->reader;
- priv = reader->priv;
- uri = th_data->uri;
- stamp = th_data->stamp;
-
- d(g_print ("convert_start\n"));
-
- STAMP_MUTEX_LOCK;
-
- if (reader_check_cancelled (reader, th_data->stamp)) {
-
- STAMP_MUTEX_UNLOCK;
- return;
- }
-
- STAMP_MUTEX_UNLOCK;
-
- switch (yelp_uri_get_type (uri)) {
- case YELP_URI_TYPE_MAN:
- command_line = g_strdup_printf ("%s/yelp-man2html %s",
- SERVERDIR,
- yelp_uri_get_path (uri));
- break;
- case YELP_URI_TYPE_INFO:
- if (yelp_uri_get_section (uri)) {
- command_line =
- g_strdup_printf ("%s/yelp-info2html %s?%s",
- SERVERDIR,
- yelp_uri_get_path (uri),
- yelp_uri_get_section (uri));
- } else {
- command_line =
- g_strdup_printf ("%s/yelp-info2html %s",
- SERVERDIR,
- yelp_uri_get_path (uri));
- }
-
- break;
- case YELP_URI_TYPE_DOCBOOK_XML:
- case YELP_URI_TYPE_DOCBOOK_SGML:
- command_line = g_strdup_printf ("%s/yelp-db2html %s",
- SERVERDIR,
- yelp_uri_get_path (uri));
- break;
- default:
- /* Set error */
- break;
- }
-
- q_data = reader_q_data_new (reader, priv->stamp,
- READER_QUEUE_TYPE_START);
-
- g_async_queue_push (priv->thread_queue, q_data);
-
- q_data = reader_q_data_new (reader, priv->stamp,
- READER_QUEUE_TYPE_DATA);
-
- g_spawn_command_line_sync (command_line,
- &q_data->data,
- NULL,
- &exit_status,
- &error /* FIXME */);
- if (yelp_uri_get_type (uri) == YELP_URI_TYPE_DOCBOOK_XML ||
- yelp_uri_get_type (uri) == YELP_URI_TYPE_DOCBOOK_SGML) {
- yelp_cache_add (yelp_uri_get_path (uri), q_data->data);
- }
-
- g_free (command_line);
-
- STAMP_MUTEX_LOCK;
-
- if (reader_check_cancelled (reader, stamp)) {
-
- STAMP_MUTEX_UNLOCK;
-
- reader_q_data_free (q_data);
-
- return;
- }
-
- STAMP_MUTEX_UNLOCK;
-
- if (error) {
- /* FIXME: Don't do this */
- g_signal_emit (reader, signals[ERROR], 0, error);
- g_error_free (error);
- } else {
- if (yelp_uri_get_type (uri) == YELP_URI_TYPE_DOCBOOK_XML ||
- yelp_uri_get_type (uri) == YELP_URI_TYPE_DOCBOOK_SGML) {
- gchar *chunk;
-
- if (yelp_uri_get_section (uri) &&
- strcmp (yelp_uri_get_section (uri), "")) {
- chunk = reader_get_chunk (q_data->data,
- yelp_uri_get_section (uri));
- } else {
- chunk = reader_get_chunk (q_data->data,
- "toc");
- }
-
- g_free (q_data->data);
- q_data->data = chunk;
-
- if (!q_data->data) {
- q_data->data = g_strdup ("<html><body></body></html>");
- }
- }
-
- g_async_queue_push (priv->thread_queue, q_data);
-
- q_data = reader_q_data_new (reader, priv->stamp,
- READER_QUEUE_TYPE_FINISHED);
-
- g_async_queue_push (priv->thread_queue, q_data);
- }
-}
-
-static void
-reader_file_start (ReaderThreadData *th_data)
-{
- YelpReader *reader;
- YelpReaderPriv *priv;
- YelpURI *uri;
- gint stamp;
- GnomeVFSHandle *handle;
- GnomeVFSResult result;
- ReaderQueueData *q_data;
- gchar buffer[BUFFER_SIZE];
- GnomeVFSFileSize n;
-
- g_return_if_fail (th_data != NULL);
-
- reader = th_data->reader;
- priv = reader->priv;
- uri = th_data->uri;
- stamp = th_data->stamp;
-
- d(g_print ("file_start\n"));
-
- STAMP_MUTEX_LOCK;
-
- if (reader_check_cancelled (reader, stamp)) {
- STAMP_MUTEX_UNLOCK;
- return;
- }
-
- STAMP_MUTEX_UNLOCK;
-
- result = gnome_vfs_open (&handle,
- yelp_uri_get_path (uri),
- GNOME_VFS_OPEN_READ);
-
- if (result != GNOME_VFS_OK) {
- /* FIXME: Signal error */
- return;
- }
-
- while (TRUE) {
- result = gnome_vfs_read (handle, buffer, BUFFER_SIZE, &n);
-
- /* FIXME: Do some error checking */
- if (result != GNOME_VFS_OK) {
- break;
- }
-
- q_data = reader_q_data_new (reader, stamp,
- READER_QUEUE_TYPE_DATA);
- q_data->data = g_strdup (buffer);
-
- g_async_queue_push (priv->thread_queue, q_data);
-
- STAMP_MUTEX_LOCK;
-
- if (reader_check_cancelled (reader, stamp)) {
- gnome_vfs_close (handle);
- STAMP_MUTEX_UNLOCK;
- return;
- }
-
- STAMP_MUTEX_UNLOCK;
- }
- gnome_vfs_close (handle);
- q_data = reader_q_data_new (reader, stamp, READER_QUEUE_TYPE_FINISHED);
-
- g_async_queue_push (priv->thread_queue, q_data);
-}
-
-static gboolean
-reader_check_cancelled (YelpReader *reader, gint stamp)
-{
- YelpReaderPriv *priv;
-
- g_return_val_if_fail (YELP_IS_READER (reader), TRUE);
-
- priv = reader->priv;
-
- d(g_print ("check_cancelled\n"));
-
- if (priv->stamp != stamp) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gpointer
-reader_start (ReaderThreadData *th_data)
-{
- YelpReader *reader;
- YelpReaderPriv *priv;
- YelpURI *uri;
-
- g_return_val_if_fail (th_data != NULL, NULL);
-
- reader = th_data->reader;
- priv = reader->priv;
- uri = th_data->uri;
-
- d(g_print ("reader_start\n"));
-
- if (!yelp_uri_exists (uri)) {
- return NULL;
- }
-
- STAMP_MUTEX_LOCK;
-
- if (reader_check_cancelled (reader, th_data->stamp)) {
- STAMP_MUTEX_UNLOCK;
-
- /* FIXME: refs??? */
-/* reader_th_data_free(th_data); */
-
- return NULL;
- }
-
- if (priv->active) {
- reader_change_stamp (reader);
- }
-
- STAMP_MUTEX_UNLOCK;
-
- switch (yelp_uri_get_type (uri)) {
-/* reader_db_start (th_data); */
-/* break; */
- case YELP_URI_TYPE_DOCBOOK_XML:
- case YELP_URI_TYPE_DOCBOOK_SGML:
- case YELP_URI_TYPE_MAN:
- case YELP_URI_TYPE_INFO:
- reader_convert_start (th_data);
- break;
- case YELP_URI_TYPE_HTML:
- reader_file_start (th_data);
- break;
- case YELP_URI_TYPE_TOC:
- /* Should this be handled here?? */
- break;
- case YELP_URI_TYPE_INDEX:
- case YELP_URI_TYPE_PATH:
- /* Hmm .. is this wrong or what?? */
- break;
- default:
- g_assert_not_reached ();
-
- break;
- }
-
- return NULL;
-}
-
-static void
-reader_change_stamp (YelpReader *reader)
-{
- YelpReaderPriv *priv;
-
- g_return_if_fail (YELP_IS_READER (reader));
-
- priv = reader->priv;
-
- if ((priv->stamp++) >= G_MAXINT) {
- priv->stamp = 1;
- }
-}
-
-static gboolean
-reader_idle_check_queue (ReaderThreadData *th_data)
-{
- YelpReader *reader;
- YelpReaderPriv *priv;
- ReaderQueueData *q_data;
- gboolean ret_val = TRUE;
-
- g_return_val_if_fail (th_data != NULL, FALSE);
-
- reader = th_data->reader;
- priv = reader->priv;
-
- if (!g_mutex_trylock (priv->stamp_mutex)) {
- return TRUE;
- }
-
- if (th_data->stamp != priv->stamp) {
- STAMP_MUTEX_UNLOCK;
-
-/* reader_th_data_free (th_data); */
-
- return FALSE;
- }
-
- d(g_print ("Poping from queue... "));
- q_data = (ReaderQueueData *)
- g_async_queue_try_pop (priv->thread_queue);
- d(g_print ("done\n"));
-
- if (q_data) {
- if (priv->stamp != q_data->stamp) {
- /* Some old data */
- reader_q_data_free (q_data);
- ret_val = TRUE;
-
- q_data = NULL;
- }
- }
-
- if (q_data) {
- switch (q_data->type) {
- case READER_QUEUE_TYPE_START:
- g_signal_emit (reader, signals[START], 0);
- ret_val = TRUE;
- break;
- case READER_QUEUE_TYPE_DATA:
- d(g_print ("queue_type_data\n"));
-
- if (q_data->data != NULL) {
- g_signal_emit (reader, signals[DATA], 0,
- q_data->data, -1);
- }
- ret_val = TRUE;
- break;
- case READER_QUEUE_TYPE_CANCELLED:
- priv->active = FALSE;
-
- if ((priv->stamp++) >= G_MAXINT) {
- priv->stamp = 1;
- }
-
- g_signal_emit (reader, signals[CANCELLED], 0);
-
- ret_val = FALSE;
- break;
- case READER_QUEUE_TYPE_FINISHED:
- priv->active = FALSE;
-
- d(g_print ("queue_type_finished\n"));
-
- if ((priv->stamp++) >= G_MAXINT) {
- priv->stamp = 1;
- }
-
- g_signal_emit (reader, signals[FINISHED], 0,
- th_data->uri);
-
- ret_val = FALSE;
- break;
- default:
- g_assert_not_reached ();
- }
-
- reader_q_data_free (q_data);
- }
-
- STAMP_MUTEX_UNLOCK;
-
- return ret_val;
-}
-
-static ReaderQueueData *
-reader_q_data_new (YelpReader *reader, gint stamp, ReaderQueueType type)
-{
- ReaderQueueData *q_data;
-
- q_data = g_new0 (ReaderQueueData, 1);
- q_data->reader = g_object_ref (reader);
- q_data->stamp = stamp;
- q_data->type = type;
- q_data->data = NULL;
-
- return q_data;
-}
-
-static void
-reader_q_data_free (ReaderQueueData *q_data)
-{
- g_return_if_fail (q_data != NULL);
-
- g_object_unref (q_data->reader);
- g_free (q_data->data);
- g_free (q_data);
-}
-
-#if 0
-static void
-reader_th_data_free (ReaderThreadData *th_data)
-{
- g_return_if_fail (th_data != NULL);
-
- g_object_unref (th_data->reader);
- yelp_uri_unref (th_data->uri);
-
- g_free (th_data);
-}
-#endif
-
-static gchar *
-reader_get_chunk (const gchar *document, const gchar *section)
-{
- gchar *header;
- gchar *chunk;
- const gchar *footer;
- gchar *ret_val;
- const gchar *start;
- const gchar *end;
- gchar *tag;
- GTimer *timer;
-
-/* g_print ("%s\n", document); */
-
- timer = g_timer_new ();
-
- end = strstr (document, "<!-- End of header -->");
-
- if (!end) {
-/* g_warning ("Wrong type of document\n"); */
- return g_strdup (document);
- }
-
- header = g_strndup (document, end - document);
-
- tag = g_strdup_printf ("<!-- Start of chunk: [%s] -->", section);
- start = strstr (document, tag);
- g_free (tag);
-
- if (!start) {
-/* g_warning ("Document doesn't include section: '%s'", section); */
- g_free (header);
-
- return g_strdup (document);
- }
-
- end = strstr (start, "<!-- End of chunk -->");
-
- if (!end) {
-/* g_warning ("Document is doesn't contain end tag for section: %s", */
-/* section); */
- g_free (header);
-
- return g_strdup (document);
- }
-
- chunk = g_strndup (start, end - start);
-
- footer = strstr (document, "<!-- Start of footer -->");
-
- if (!footer) {
-/* g_warning ("Couldn't find footer in document"); */
- g_free (header);
- g_free (chunk);
-
- return g_strdup (document);
- }
-
- ret_val = g_strconcat (header, chunk, footer, NULL);
-
- g_free (header);
- g_free (chunk);
-
-/* g_print ("Finding chunk took: %f seconds\n", */
-/* g_timer_elapsed (timer, 0)); */
-
- return ret_val;
-}
-
-/* Given an XML file, look if there is a cached HTML file. If the HTML is
- * newer than XML, return it. Else return XML only.
- */
-static gchar *
-reader_look_for_cached_help_file (const gchar *url)
-{
- gchar *sect, *pos;
- int len=0;
- GString *path;
- char *html_url, *xml_url;
- char *scheme;
- struct stat html_stat, xml_stat;
-
- if (g_strrstr (url, ".xml") == NULL) {
- return g_strdup (url);
- }
-
- path = g_string_new (url);
- sect = g_strrstr (url, "?");
-
- len = sect - url;
- path = g_string_truncate (path, len);
-
- scheme = g_strrstr (path->str, ":");
-
- xml_url = g_strdup (scheme + 1);
-
- pos = g_strrstr (path->str, ".xml");
-
- if (pos == NULL) {
- g_string_free (path, TRUE);
- g_free (xml_url);
-
- return g_strdup (url);
- }
-
- len = pos - path->str;
-
- path = g_string_truncate (path, len);
- path = g_string_append (path, ".html");
-
- scheme = g_strrstr (path->str, ":");
- html_url = g_strdup (scheme + 1);
-
- if (g_file_test (html_url, G_FILE_TEST_EXISTS)) {
- stat (html_url, &html_stat);
- stat (xml_url, &xml_stat);
-
- g_free (xml_url);
- g_free (html_url);
-
- if (html_stat.st_mtime >= xml_stat.st_mtime) {
- if (sect) {
- path = g_string_append (path, sect);
- }
-
- return g_string_free (path, FALSE);
- } else {
- g_string_free (path, TRUE);
- return g_strdup (url);
- }
- } else {
- g_free (xml_url);
- g_free (html_url);
- g_string_free (path, TRUE);
-
- return g_strdup (url);
- }
-}
-
-YelpReader *
-yelp_reader_new ()
-{
- YelpReader *reader;
- YelpReaderPriv *priv;
-
- reader = g_object_new (YELP_TYPE_READER, NULL);
-
- priv = reader->priv;
-
- return reader;
-}
-
-gboolean
-yelp_reader_start (YelpReader *reader, YelpURI *uri)
-{
- YelpReaderPriv *priv;
- ReaderThreadData *th_data;
- gint stamp;
- const gchar *cached_document = NULL;
- gchar *read_document = NULL;
- gchar *chunk = NULL;
- gchar *str_uri = NULL;
- gchar buffer[BUFFER_SIZE];
- YelpURI *new_uri;
-
- g_return_val_if_fail (YELP_IS_READER (reader), FALSE);
- g_return_val_if_fail (uri != NULL, FALSE);
-
- priv = reader->priv;
-
- d(g_print ("yelp_reader_start\n"));
-
- STAMP_MUTEX_LOCK;
-
- if (priv->active) {
- reader_change_stamp (reader);
- }
-
- stamp = priv->stamp;
-
- STAMP_MUTEX_UNLOCK;
-
- th_data = g_new0 (ReaderThreadData, 1);
- th_data->reader = g_object_ref (reader);
- th_data->uri = yelp_uri_ref (uri);
- th_data->stamp = stamp;
-
- str_uri = yelp_uri_to_string (uri);
- if (str_uri && *str_uri) {
- gchar *tmp_str_uri;
- tmp_str_uri = reader_look_for_cached_help_file (str_uri);
- new_uri = yelp_uri_new (tmp_str_uri);
- g_free (str_uri);
- g_free (tmp_str_uri);
- } else {
- new_uri = yelp_uri_copy (uri);
- }
-
- if (yelp_uri_get_type (new_uri) == YELP_URI_TYPE_FILE ||
- yelp_uri_get_type (new_uri) == YELP_URI_TYPE_UNKNOWN ||
- yelp_uri_get_type (new_uri) == YELP_URI_TYPE_GHELP_OTHER) {
- gboolean ret_val;
-
- str_uri = yelp_uri_to_string (new_uri);
- ret_val = gnome_url_show (str_uri, NULL);
- g_free (str_uri);
-
- return ret_val;
- }
-
- if (yelp_uri_get_type (new_uri) == YELP_URI_TYPE_DOCBOOK_XML ||
- yelp_uri_get_type (new_uri) == YELP_URI_TYPE_DOCBOOK_SGML) {
-
- /* check if there is HTML cache. If found, use the HTML cache. */
- cached_document = yelp_cache_lookup (yelp_uri_get_path (new_uri));
- }
- else if (yelp_uri_get_type (new_uri) == YELP_URI_TYPE_HTML) {
- GnomeVFSHandle *handle;
- GnomeVFSResult result;
- GString *html_buffer;
- GnomeVFSFileSize n;
-
- result = gnome_vfs_open (&handle,
- yelp_uri_get_path (new_uri),
- GNOME_VFS_OPEN_READ);
-
- if (result != GNOME_VFS_OK) {
- /* FIXME: Signal error */
- yelp_uri_unref (new_uri);
- return FALSE;
- }
-
- html_buffer = NULL;
-
- while (TRUE) {
- gchar *temp_buffer;
-
- result = gnome_vfs_read (handle, buffer,
- BUFFER_SIZE, &n);
-
- /* FIXME: Do some error checking */
- if (result != GNOME_VFS_OK) {
- break;
- }
-
- temp_buffer = g_strndup (buffer, n);
-
- if (html_buffer == NULL) {
- html_buffer = g_string_new (temp_buffer);
- } else {
- html_buffer = g_string_append (html_buffer,
- temp_buffer);
- }
-
- g_free (temp_buffer);
- }
-
- gnome_vfs_close (handle);
- read_document = g_string_free (html_buffer, FALSE);
- }
-
- if (cached_document || read_document) {
- gchar *document;
-
- if (cached_document) {
- document = (gchar *) cached_document;
- } else {
- document = read_document;
- }
-
- if (yelp_uri_get_section (new_uri) &&
- strcmp (yelp_uri_get_section (new_uri), "")) {
- chunk = reader_get_chunk (document,
- yelp_uri_get_section (new_uri));
- } else {
- chunk = reader_get_chunk (document, "toc");
- }
-
- g_free (read_document);
- yelp_uri_unref (new_uri);
-
- if (chunk) {
- ReaderQueueData *q_data;
-
- q_data = reader_q_data_new (reader, stamp,
- READER_QUEUE_TYPE_START);
- g_async_queue_push (priv->thread_queue,
- q_data);
-
- q_data = reader_q_data_new (reader, stamp,
- READER_QUEUE_TYPE_DATA);
-
- q_data->data = chunk;
- g_async_queue_push (priv->thread_queue,
- q_data);
-
- q_data = reader_q_data_new (reader, stamp,
- READER_QUEUE_TYPE_FINISHED);
- g_async_queue_push (priv->thread_queue,
- q_data);
-
- g_idle_add ((GSourceFunc) reader_idle_check_queue,
- th_data);
-
- return TRUE;
- }
- } else {
- yelp_uri_unref (new_uri);
- }
-
- g_timeout_add (100, (GSourceFunc) reader_idle_check_queue, th_data);
-
- g_thread_create_full ((GThreadFunc) reader_start, th_data,
- 2 * BUFFER_SIZE,
- TRUE,
- FALSE, G_THREAD_PRIORITY_NORMAL,
- NULL /* FIXME: check for errors */);
-
- return FALSE;
-}
-
-void
-yelp_reader_cancel (YelpReader *reader)
-{
- YelpReaderPriv *priv;
-
- g_return_if_fail (YELP_IS_READER (reader));
-
- priv = reader->priv;
-
- STAMP_MUTEX_LOCK;
-
- reader_change_stamp (reader);
-
- STAMP_MUTEX_UNLOCK;
-}
diff --git a/src/yelp-reader.h b/src/yelp-reader.h
deleted file mode 100644
index 2c687275..00000000
--- a/src/yelp-reader.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2002 Mikael Hallendal <micke@imendio.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Mikael Hallendal <micke@imendio.com>
- */
-
-#ifndef __YELP_READER_H__
-#define __YELP_READER_H__
-
-#include <glib-object.h>
-
-#include "yelp-uri.h"
-
-#define YELP_TYPE_READER (yelp_reader_get_type ())
-#define YELP_READER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), YELP_TYPE_READER, YelpReader))
-#define YELP_READER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), YELP_TYPE_READER, YelpReaderClass))
-#define YELP_IS_READER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), YELP_TYPE_READER))
-#define YELP_IS_READER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), YELP_TYPE_READER))
-#define YELP_READER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), YELP_TYPE_READER, YelpReaderClass))
-
-typedef struct _YelpReader YelpReader;
-typedef struct _YelpReaderClass YelpReaderClass;
-typedef struct _YelpReaderPriv YelpReaderPriv;
-
-struct _YelpReader {
- GObject parent;
-
- YelpReaderPriv *priv;
-};
-
-struct _YelpReaderClass {
- GObjectClass parent_class;
-
- /* Signals */
- void (*start) (YelpReader *reader);
- void (*data) (YelpReader *reader,
- const gchar *buffer,
- gint len);
- void (*finished) (YelpReader *reader,
- YelpURI *read_uri);
- void (*cancelled) (YelpReader *reader);
- void (*error) (YelpReader *reader,
- GError *error);
-};
-
-GType yelp_reader_get_type (void);
-YelpReader * yelp_reader_new (void);
-
-gboolean yelp_reader_start (YelpReader *reader,
- YelpURI *uri);
-void yelp_reader_cancel (YelpReader *reader);
-gchar * look_for_html_help_file (gchar *xml_uri);
-
-#endif /* __YELP_READER_H__ */