[yelp/wip/webkit2-port: 2/18] yelp-document: Add yelp_document_lookup_document_uri()
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp/wip/webkit2-port: 2/18] yelp-document: Add yelp_document_lookup_document_uri()
- Date: Sat, 14 Feb 2015 10:32:14 +0000 (UTC)
commit 012c501ae6a9749e46884a2f73ea26ed3d23ebcd
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Wed Aug 29 14:58:18 2012 +0200
yelp-document: Add yelp_document_lookup_document_uri()
It allows to get the YelpDocument for a given doc URI string, without
having to create and resolve a YelpUri.
libyelp/yelp-document.c | 11 +++-
libyelp/yelp-document.h | 203 ++++++++++++++++++++++++-----------------------
2 files changed, 112 insertions(+), 102 deletions(-)
---
diff --git a/libyelp/yelp-document.c b/libyelp/yelp-document.c
index aa1d82b..04f98fb 100644
--- a/libyelp/yelp-document.c
+++ b/libyelp/yelp-document.c
@@ -152,13 +152,22 @@ static void str_unref (const gchar *str);
static GMutex str_mutex;
static GHashTable *str_refs = NULL;
+static GHashTable *documents = NULL;
/******************************************************************************/
YelpDocument *
+yelp_document_lookup_document_uri (const gchar *docuri)
+{
+ if (!documents)
+ return NULL;
+
+ return g_hash_table_lookup (documents, docuri);
+}
+
+YelpDocument *
yelp_document_get_for_uri (YelpUri *uri)
{
- static GHashTable *documents = NULL;
YelpUriDocumentType doctype;
gchar *docuri = NULL;
gchar *page_id, *tmp;
diff --git a/libyelp/yelp-document.h b/libyelp/yelp-document.h
index 002bab1..75157d5 100644
--- a/libyelp/yelp-document.h
+++ b/libyelp/yelp-document.h
@@ -59,110 +59,111 @@ struct _YelpDocumentClass {
GObjectClass parent_class;
/* Virtual Functions */
- gboolean (*request_page) (YelpDocument *document,
- const gchar *page_id,
- GCancellable *cancellable,
- YelpDocumentCallback callback,
- gpointer user_data);
- const gchar * (*read_contents) (YelpDocument *document,
- const gchar *page_id);
- void (*finish_read) (YelpDocument *document,
- const gchar *contents);
- gchar * (*get_mime_type) (YelpDocument *document,
- const gchar *page_id);
- void (*index) (YelpDocument *document);
+ gboolean (*request_page) (YelpDocument *document,
+ const gchar *page_id,
+ GCancellable *cancellable,
+ YelpDocumentCallback callback,
+ gpointer user_data);
+ const gchar * (*read_contents) (YelpDocument *document,
+ const gchar *page_id);
+ void (*finish_read) (YelpDocument *document,
+ const gchar *contents);
+ gchar * (*get_mime_type) (YelpDocument *document,
+ const gchar *page_id);
+ void (*index) (YelpDocument *document);
};
-GType yelp_document_get_type (void);
-
-YelpDocument * yelp_document_get_for_uri (YelpUri *uri);
-
-YelpUri * yelp_document_get_uri (YelpDocument *document);
-
-gboolean yelp_document_request_page (YelpDocument *document,
- const gchar *page_id,
- GCancellable *cancellable,
- YelpDocumentCallback callback,
- gpointer user_data);
-void yelp_document_clear_contents (YelpDocument *document);
-gchar ** yelp_document_get_requests (YelpDocument *document);
-
-void yelp_document_give_contents (YelpDocument *document,
- const gchar *page_id,
- gchar *contents,
- const gchar *mime);
-gchar * yelp_document_get_mime_type (YelpDocument *document,
- const gchar *page_id);
-const gchar * yelp_document_read_contents (YelpDocument *document,
- const gchar *page_id);
-void yelp_document_finish_read (YelpDocument *document,
- const gchar *contents);
-
-void yelp_document_index (YelpDocument *document);
-
-gchar ** yelp_document_list_page_ids (YelpDocument *document);
-
-gchar * yelp_document_get_page_id (YelpDocument *document,
- const gchar *id);
-void yelp_document_set_page_id (YelpDocument *document,
- const gchar *id,
- const gchar *page_id);
-
-gchar * yelp_document_get_root_id (YelpDocument *document,
- const gchar *page_id);
-void yelp_document_set_root_id (YelpDocument *document,
- const gchar *page_id,
- const gchar *root_id);
-
-gchar * yelp_document_get_prev_id (YelpDocument *document,
- const gchar *page_id);
-void yelp_document_set_prev_id (YelpDocument *document,
- const gchar *page_id,
- const gchar *prev_id);
-
-char * yelp_document_get_next_id (YelpDocument *document,
- const gchar *page_id);
-void yelp_document_set_next_id (YelpDocument *document,
- const gchar *page_id,
- const gchar *next_id);
-
-gchar * yelp_document_get_up_id (YelpDocument *document,
- const gchar *page_id);
-void yelp_document_set_up_id (YelpDocument *document,
- const gchar *page_id,
- const gchar *up_id);
-
-gchar * yelp_document_get_root_title (YelpDocument *document,
- const gchar *page_id);
-
-gchar * yelp_document_get_page_title (YelpDocument *document,
- const gchar *page_id);
-void yelp_document_set_page_title (YelpDocument *document,
- const gchar *page_id,
- const gchar *title);
-
-gchar * yelp_document_get_page_desc (YelpDocument *document,
- const gchar *page_id);
-void yelp_document_set_page_desc (YelpDocument *document,
- const gchar *page_id,
- const gchar *desc);
-
-gchar * yelp_document_get_page_icon (YelpDocument *document,
- const gchar *page_id);
-void yelp_document_set_page_icon (YelpDocument *document,
- const gchar *page_id,
- const gchar *icon);
-
-gboolean yelp_document_has_page (YelpDocument *document,
- const gchar *page_id);
-
-void yelp_document_signal (YelpDocument *document,
- const gchar *page_id,
- YelpDocumentSignal signal,
- const GError *error);
-void yelp_document_error_pending (YelpDocument *document,
- const GError *error);
+GType yelp_document_get_type (void);
+
+YelpDocument * yelp_document_get_for_uri (YelpUri *uri);
+YelpDocument * yelp_document_lookup_document_uri (const gchar *docuri);
+
+YelpUri * yelp_document_get_uri (YelpDocument *document);
+
+gboolean yelp_document_request_page (YelpDocument *document,
+ const gchar *page_id,
+ GCancellable *cancellable,
+ YelpDocumentCallback callback,
+ gpointer user_data);
+void yelp_document_clear_contents (YelpDocument *document);
+gchar ** yelp_document_get_requests (YelpDocument *document);
+
+void yelp_document_give_contents (YelpDocument *document,
+ const gchar *page_id,
+ gchar *contents,
+ const gchar *mime);
+gchar * yelp_document_get_mime_type (YelpDocument *document,
+ const gchar *page_id);
+const gchar * yelp_document_read_contents (YelpDocument *document,
+ const gchar *page_id);
+void yelp_document_finish_read (YelpDocument *document,
+ const gchar *contents);
+
+void yelp_document_index (YelpDocument *document);
+
+gchar ** yelp_document_list_page_ids (YelpDocument *document);
+
+gchar * yelp_document_get_page_id (YelpDocument *document,
+ const gchar *id);
+void yelp_document_set_page_id (YelpDocument *document,
+ const gchar *id,
+ const gchar *page_id);
+
+gchar * yelp_document_get_root_id (YelpDocument *document,
+ const gchar *page_id);
+void yelp_document_set_root_id (YelpDocument *document,
+ const gchar *page_id,
+ const gchar *root_id);
+
+gchar * yelp_document_get_prev_id (YelpDocument *document,
+ const gchar *page_id);
+void yelp_document_set_prev_id (YelpDocument *document,
+ const gchar *page_id,
+ const gchar *prev_id);
+
+char * yelp_document_get_next_id (YelpDocument *document,
+ const gchar *page_id);
+void yelp_document_set_next_id (YelpDocument *document,
+ const gchar *page_id,
+ const gchar *next_id);
+
+gchar * yelp_document_get_up_id (YelpDocument *document,
+ const gchar *page_id);
+void yelp_document_set_up_id (YelpDocument *document,
+ const gchar *page_id,
+ const gchar *up_id);
+
+gchar * yelp_document_get_root_title (YelpDocument *document,
+ const gchar *page_id);
+
+gchar * yelp_document_get_page_title (YelpDocument *document,
+ const gchar *page_id);
+void yelp_document_set_page_title (YelpDocument *document,
+ const gchar *page_id,
+ const gchar *title);
+
+gchar * yelp_document_get_page_desc (YelpDocument *document,
+ const gchar *page_id);
+void yelp_document_set_page_desc (YelpDocument *document,
+ const gchar *page_id,
+ const gchar *desc);
+
+gchar * yelp_document_get_page_icon (YelpDocument *document,
+ const gchar *page_id);
+void yelp_document_set_page_icon (YelpDocument *document,
+ const gchar *page_id,
+ const gchar *icon);
+
+gboolean yelp_document_has_page (YelpDocument *document,
+ const gchar *page_id);
+
+void yelp_document_signal (YelpDocument *document,
+ const gchar *page_id,
+ YelpDocumentSignal signal,
+ const GError *error);
+void yelp_document_error_pending (YelpDocument *document,
+ const GError *error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]