1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * Copyright (C) 2003-2009 Shaun McCance  <shaunm@gnome.org>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, see <http://www.gnu.org/licenses/>.
17  *
18  * Author: Shaun McCance  <shaunm@gnome.org>
19  */
20 
21 #ifndef __YELP_DOCUMENT_H__
22 #define __YELP_DOCUMENT_H__
23 
24 #include <glib-object.h>
25 #include <gio/gio.h>
26 
27 #include "yelp-uri.h"
28 
29 G_BEGIN_DECLS
30 
31 #define YELP_TYPE_DOCUMENT         (yelp_document_get_type ())
32 #define YELP_DOCUMENT(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), YELP_TYPE_DOCUMENT, YelpDocument))
33 #define YELP_DOCUMENT_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), YELP_TYPE_DOCUMENT, YelpDocumentClass))
34 #define YELP_IS_DOCUMENT(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), YELP_TYPE_DOCUMENT))
35 #define YELP_IS_DOCUMENT_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), YELP_TYPE_DOCUMENT))
36 #define YELP_DOCUMENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), YELP_TYPE_DOCUMENT, YelpDocumentClass))
37 
38 typedef struct _YelpDocument         YelpDocument;
39 typedef struct _YelpDocumentClass    YelpDocumentClass;
40 typedef struct _YelpDocumentPrivate  YelpDocumentPrivate;
41 
42 typedef enum {
43     YELP_DOCUMENT_SIGNAL_CONTENTS,
44     YELP_DOCUMENT_SIGNAL_INFO,
45     YELP_DOCUMENT_SIGNAL_ERROR
46 } YelpDocumentSignal;
47 
48 typedef void      (*YelpDocumentCallback)      (YelpDocument         *document,
49                                                 YelpDocumentSignal    signal,
50                                                 gpointer              user_data,
51                                                 GError               *error);
52 
53 struct _YelpDocument {
54     GObject              parent;
55     YelpDocumentPrivate *priv;
56 };
57 
58 struct _YelpDocumentClass {
59     GObjectClass      parent_class;
60 
61     /* Virtual Functions */
62     gboolean      (*request_page)                   (YelpDocument         *document,
63                                                      const gchar          *page_id,
64                                                      GCancellable         *cancellable,
65                                                      YelpDocumentCallback  callback,
66                                                      gpointer              user_data,
67                                                      GDestroyNotify        notify);
68     const gchar * (*read_contents)                  (YelpDocument         *document,
69                                                      const gchar          *page_id);
70     void          (*finish_read)                    (YelpDocument         *document,
71                                                      const gchar          *contents);
72     gchar *       (*get_mime_type)                  (YelpDocument         *document,
73                                                      const gchar          *page_id);
74     void          (*index)                          (YelpDocument         *document);
75 
76 };
77 
78 GType             yelp_document_get_type            (void);
79 
80 YelpDocument *    yelp_document_get_for_uri         (YelpUri              *uri);
81 YelpDocument *    yelp_document_lookup_document_uri (const gchar          *docuri);
82 
83 YelpUri *         yelp_document_get_uri             (YelpDocument         *document);
84 
85 gboolean          yelp_document_request_page        (YelpDocument         *document,
86                                                      const gchar          *page_id,
87                                                      GCancellable         *cancellable,
88                                                      YelpDocumentCallback  callback,
89                                                      gpointer              user_data,
90                                                      GDestroyNotify        notify);
91 void              yelp_document_clear_contents      (YelpDocument         *document);
92 gchar **          yelp_document_get_requests        (YelpDocument         *document);
93 
94 void              yelp_document_give_contents       (YelpDocument         *document,
95                                                      const gchar          *page_id,
96                                                      gchar                *contents,
97                                                      const gchar          *mime);
98 gchar *           yelp_document_get_mime_type       (YelpDocument         *document,
99                                                      const gchar          *page_id);
100 const gchar *     yelp_document_read_contents       (YelpDocument         *document,
101                                                      const gchar          *page_id);
102 void              yelp_document_finish_read         (YelpDocument         *document,
103                                                      const gchar          *contents);
104 
105 void              yelp_document_index               (YelpDocument         *document);
106 
107 gchar **          yelp_document_list_page_ids       (YelpDocument         *document);
108 
109 gchar *           yelp_document_get_page_id         (YelpDocument         *document,
110                                                      const gchar          *id);
111 void              yelp_document_set_page_id         (YelpDocument         *document,
112                                                      const gchar          *id,
113                                                      const gchar          *page_id);
114 
115 gchar *           yelp_document_get_root_id         (YelpDocument         *document,
116                                                      const gchar          *page_id);
117 void              yelp_document_set_root_id         (YelpDocument         *document,
118                                                      const gchar          *page_id,
119                                                      const gchar          *root_id);
120 
121 gchar *           yelp_document_get_prev_id         (YelpDocument         *document,
122                                                      const gchar          *page_id);
123 void              yelp_document_set_prev_id         (YelpDocument         *document,
124                                                      const gchar          *page_id,
125                                                      const gchar          *prev_id);
126 
127 char *            yelp_document_get_next_id         (YelpDocument         *document,
128                                                      const gchar          *page_id);
129 void              yelp_document_set_next_id         (YelpDocument         *document,
130                                                      const gchar          *page_id,
131                                                      const gchar          *next_id);
132 
133 gchar *           yelp_document_get_up_id           (YelpDocument         *document,
134                                                      const gchar          *page_id);
135 void              yelp_document_set_up_id           (YelpDocument         *document,
136                                                      const gchar          *page_id,
137                                                      const gchar          *up_id);
138 
139 gchar *           yelp_document_get_root_title      (YelpDocument         *document,
140                                                      const gchar          *page_id);
141 
142 gchar *           yelp_document_get_page_title      (YelpDocument         *document,
143                                                      const gchar          *page_id);
144 void              yelp_document_set_page_title      (YelpDocument         *document,
145                                                      const gchar          *page_id,
146                                                      const gchar          *title);
147 
148 gchar *           yelp_document_get_page_desc       (YelpDocument         *document,
149                                                      const gchar          *page_id);
150 void              yelp_document_set_page_desc       (YelpDocument         *document,
151                                                      const gchar          *page_id,
152                                                      const gchar          *desc);
153 
154 gchar *           yelp_document_get_page_keywords   (YelpDocument         *document,
155                                                      const gchar          *page_id);
156 void              yelp_document_set_page_keywords   (YelpDocument         *document,
157                                                      const gchar          *page_id,
158                                                      const gchar          *keywords);
159 
160 gchar *           yelp_document_get_page_icon       (YelpDocument         *document,
161                                                      const gchar          *page_id);
162 void              yelp_document_set_page_icon       (YelpDocument         *document,
163                                                      const gchar          *page_id,
164                                                      const gchar          *icon);
165 
166 gboolean          yelp_document_has_page            (YelpDocument         *document,
167                                                      const gchar          *page_id);
168 
169 void              yelp_document_signal              (YelpDocument         *document,
170                                                      const gchar          *page_id,
171                                                      YelpDocumentSignal    signal,
172                                                      const GError         *error);
173 void              yelp_document_error_pending       (YelpDocument         *document,
174                                                      const GError         *error);
175 
176 G_END_DECLS
177 
178 #endif /* __YELP_DOCUMENT_H__ */
179