1 |
ikezoe |
2693 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
2 |
|
|
|
3 |
|
|
/* |
4 |
|
|
* Copyright (C) 2004 Hiroyuki Ikezoe |
5 |
|
|
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2, or (at your option) |
9 |
|
|
* any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include <ctype.h> |
22 |
|
|
#include <glib/gi18n.h> |
23 |
|
|
#include <glib.h> |
24 |
|
|
#include <glib/gstdio.h> |
25 |
|
|
|
26 |
|
|
#include "kazehakase.h" |
27 |
|
|
#include "utils/utils.h" |
28 |
|
|
#include "glib-utils.h" |
29 |
|
|
#include "kz-search-rast.h" |
30 |
|
|
#include "egg-pixbuf-thumbnail.h" |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
typedef struct _KzSearchRastPrivate KzSearchRastPrivate; |
34 |
|
|
struct _KzSearchRastPrivate |
35 |
|
|
{ |
36 |
|
|
}; |
37 |
|
|
|
38 |
|
|
typedef struct _KzSearchRastClass KzSearchRastClass; |
39 |
|
|
struct _KzSearchRastClass |
40 |
|
|
{ |
41 |
|
|
KzSearchClass parent_class; |
42 |
|
|
}; |
43 |
|
|
|
44 |
|
|
#define KZ_SEARCH_RAST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KZ_TYPE_SEARCH_RAST, KzSearchRastPrivate)) |
45 |
|
|
|
46 |
|
|
#define KZ_SEARCH_RAST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KZ_TYPE_SEARCH_RAST, KzSearchRastClass)) |
47 |
|
|
#define KZ_IS_SEARCH_RAST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KZ_TYPE_SEARCH_RAST)) |
48 |
|
|
#define KZ_SEARCH_RAST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KZ_TYPE_SEARCH_RAST, KzSearchRastClass)) |
49 |
|
|
|
50 |
|
|
/* for module */ |
51 |
|
|
void kz_search_module_init (GTypeModule *module); |
52 |
|
|
void kz_search_module_exit (void); |
53 |
|
|
KzSearch *kz_search_module_create (void); |
54 |
|
|
|
55 |
|
|
/* KzSearchRast Class */ |
56 |
|
|
static void kz_search_rast_class_init (KzSearchRastClass *klass); |
57 |
|
|
static void kz_search_rast_init (KzSearchRast *search); |
58 |
|
|
|
59 |
|
|
/* GObject Class */ |
60 |
|
|
static GObject *constructor (GType type, |
61 |
|
|
guint n_props, |
62 |
|
|
GObjectConstructParam *props); |
63 |
|
|
static void dispose (GObject *object); |
64 |
|
|
|
65 |
|
|
/* KzSearch Class */ |
66 |
|
|
static gchar *get_search_result_html (KzSearch *search, const gchar *text); |
67 |
|
|
static KzBookmark *get_search_result_bookmark (KzSearch *search, const gchar *text); |
68 |
|
|
static gboolean register_document (KzSearch *search, |
69 |
|
|
const gchar *uri, |
70 |
|
|
const gchar *title, |
71 |
|
|
const gchar *contents, |
72 |
|
|
GTime mtime); |
73 |
|
|
static gboolean unregister_document (KzSearch *search, const gchar *uri); |
74 |
|
|
static GPid optimize_index (KzSearch *search); |
75 |
|
|
static void make_index (KzSearch *search); |
76 |
|
|
static gboolean exist_index_dir (KzSearch *search); |
77 |
|
|
|
78 |
|
|
static KzSearchRast *the_kz_search_rast = NULL; |
79 |
|
|
|
80 |
|
|
static GObjectClass *parent_class; |
81 |
|
|
static GType kz_search_rast_type = 0; |
82 |
|
|
|
83 |
|
|
static void |
84 |
|
|
kz_search_rast_register_type (GTypeModule *module) |
85 |
|
|
{ |
86 |
|
|
static const GTypeInfo kz_search_rast_info = |
87 |
|
|
{ |
88 |
|
|
sizeof (KzSearchRastClass), |
89 |
|
|
NULL, /* base_init */ |
90 |
|
|
NULL, /* base_finalize */ |
91 |
|
|
(GClassInitFunc) kz_search_rast_class_init, |
92 |
|
|
NULL, /* class_finalize */ |
93 |
|
|
NULL, /* class_data */ |
94 |
|
|
sizeof (KzSearchRast), |
95 |
|
|
0, /* n_preallocs */ |
96 |
|
|
(GInstanceInitFunc) kz_search_rast_init, |
97 |
|
|
}; |
98 |
|
|
|
99 |
|
|
kz_search_rast_type = g_type_module_register_type (module, |
100 |
|
|
KZ_TYPE_SEARCH, |
101 |
|
|
"KzSearchRast", |
102 |
|
|
&kz_search_rast_info, 0); |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
G_MODULE_EXPORT void |
106 |
|
|
kz_search_module_init (GTypeModule *module) |
107 |
|
|
{ |
108 |
|
|
kz_search_rast_register_type(module); |
109 |
|
|
} |
110 |
|
|
|
111 |
|
|
G_MODULE_EXPORT void |
112 |
|
|
kz_search_module_exit (void) |
113 |
|
|
{ |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
G_MODULE_EXPORT KzSearch * |
117 |
|
|
kz_search_module_create (void) |
118 |
|
|
{ |
119 |
|
|
return kz_search_rast_new(); |
120 |
|
|
} |
121 |
|
|
|
122 |
|
|
GType |
123 |
|
|
kz_search_rast_get_type (void) |
124 |
|
|
{ |
125 |
|
|
return kz_search_rast_type; |
126 |
|
|
} |
127 |
|
|
|
128 |
|
|
static void |
129 |
|
|
kz_search_rast_class_init (KzSearchRastClass *klass) |
130 |
|
|
{ |
131 |
|
|
GObjectClass *object_class; |
132 |
|
|
KzSearchClass *search_class; |
133 |
|
|
|
134 |
|
|
parent_class = g_type_class_peek_parent (klass); |
135 |
|
|
object_class = (GObjectClass *) klass; |
136 |
|
|
search_class = (KzSearchClass *) klass; |
137 |
|
|
|
138 |
|
|
object_class->constructor = constructor; |
139 |
|
|
object_class->dispose = dispose; |
140 |
|
|
|
141 |
|
|
search_class->get_search_result_html = get_search_result_html; |
142 |
|
|
search_class->get_search_result_bookmark = get_search_result_bookmark; |
143 |
|
|
search_class->register_document = register_document; |
144 |
|
|
search_class->unregister_document = unregister_document; |
145 |
|
|
search_class->optimize_index = optimize_index; |
146 |
|
|
search_class->make_index = make_index; |
147 |
|
|
search_class->exist_index_dir = exist_index_dir; |
148 |
|
|
|
149 |
|
|
g_type_class_add_private (object_class, sizeof(KzSearchRastPrivate)); |
150 |
|
|
} |
151 |
|
|
|
152 |
|
|
|
153 |
|
|
static void |
154 |
|
|
kz_search_rast_init (KzSearchRast *search) |
155 |
|
|
{ |
156 |
|
|
KzSearchRastPrivate *priv = KZ_SEARCH_RAST_GET_PRIVATE(search); |
157 |
|
|
} |
158 |
|
|
|
159 |
|
|
static GObject * |
160 |
|
|
constructor (GType type, |
161 |
|
|
guint n_props, |
162 |
|
|
GObjectConstructParam *props) |
163 |
|
|
{ |
164 |
|
|
GObject *object; |
165 |
|
|
|
166 |
|
|
if (!the_kz_search_rast) |
167 |
|
|
{ |
168 |
|
|
GObjectClass *klass = G_OBJECT_CLASS(parent_class); |
169 |
|
|
object = klass->constructor(type, n_props, props); |
170 |
|
|
the_kz_search_rast = KZ_SEARCH_RAST(object); |
171 |
|
|
} |
172 |
|
|
else |
173 |
|
|
{ |
174 |
|
|
object = g_object_ref(G_OBJECT(the_kz_search_rast)); |
175 |
|
|
} |
176 |
|
|
return object; |
177 |
|
|
} |
178 |
|
|
|
179 |
|
|
static void |
180 |
|
|
dispose (GObject *object) |
181 |
|
|
{ |
182 |
|
|
KzSearchRastPrivate *priv = KZ_SEARCH_RAST_GET_PRIVATE(object); |
183 |
|
|
|
184 |
|
|
if (G_OBJECT_CLASS(parent_class)->dispose) |
185 |
|
|
G_OBJECT_CLASS(parent_class)->dispose(object); |
186 |
|
|
} |
187 |
|
|
|
188 |
|
|
|
189 |
|
|
KzSearch * |
190 |
|
|
kz_search_rast_new (void) |
191 |
|
|
{ |
192 |
|
|
return KZ_SEARCH(g_object_new(KZ_TYPE_SEARCH_RAST, NULL)); |
193 |
|
|
} |
194 |
|
|
|
195 |
|
|
gchar * |
196 |
|
|
get_search_result_html (KzSearch *search, const gchar *text) |
197 |
|
|
{ |
198 |
|
|
if (!text) return NULL; |
199 |
|
|
|
200 |
|
|
return NULL; |
201 |
|
|
} |
202 |
|
|
|
203 |
|
|
gboolean |
204 |
|
|
register_document (KzSearch *search, const gchar *uri, const gchar *title, const gchar *contents, GTime mtime) |
205 |
|
|
{ |
206 |
|
|
return FALSE; |
207 |
|
|
} |
208 |
|
|
|
209 |
|
|
gboolean |
210 |
|
|
unregister_document (KzSearch *search, const gchar *uri) |
211 |
|
|
{ |
212 |
|
|
return FALSE; |
213 |
|
|
} |
214 |
|
|
|
215 |
|
|
static GPid |
216 |
|
|
optimize_index (KzSearch *search) |
217 |
|
|
{ |
218 |
|
|
return 0; |
219 |
|
|
} |
220 |
|
|
|
221 |
|
|
static KzBookmark * |
222 |
|
|
get_search_result_bookmark (KzSearch *search, const gchar *text) |
223 |
|
|
{ |
224 |
|
|
/* not implemented yet */ |
225 |
|
|
return NULL; |
226 |
|
|
} |
227 |
|
|
|
228 |
|
|
static void |
229 |
|
|
make_index (KzSearch *search) |
230 |
|
|
{ |
231 |
|
|
KzSearchRastPrivate *priv = KZ_SEARCH_RAST_GET_PRIVATE(search); |
232 |
|
|
} |
233 |
|
|
|
234 |
|
|
static gboolean |
235 |
|
|
exist_index_dir(KzSearch *search) |
236 |
|
|
{ |
237 |
|
|
gboolean exist = FALSE; |
238 |
|
|
|
239 |
|
|
return exist; |
240 |
|
|
} |