summaryrefslogtreecommitdiff
path: root/src/core/SourceInterfaces.c
blob: 5cfc5a9234e2a6f7beb1c488afb82e86067bad06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/* SourceInterfaces.c generated by valac 0.32.1, the Vala compiler
 * generated from SourceInterfaces.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */
/* See the note in MediaInterfaces.vala for some thoughts on the theory of expanding Shotwell's*/
/* features via interfaces rather than class heirarchies.*/
/* Indexable DataSources provide raw strings that may be searched against (and, in the future,*/
/* indexed) for free-text search queries.  DataSources implementing Indexable must prepare and*/
/* store (i.e. cache) these strings using prepare_indexable_string(s), as preparing the strings*/
/* for each call is expensive.*/
/**/
/* When the indexable string has changed, the object should fire an alteration of*/
/* "indexable:keywords".  The prepare methods will not do this.*/

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>


#define TYPE_DATA_OBJECT (data_object_get_type ())
#define DATA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATA_OBJECT, DataObject))
#define DATA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATA_OBJECT, DataObjectClass))
#define IS_DATA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATA_OBJECT))
#define IS_DATA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATA_OBJECT))
#define DATA_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATA_OBJECT, DataObjectClass))

typedef struct _DataObject DataObject;
typedef struct _DataObjectClass DataObjectClass;

#define TYPE_DATA_SOURCE (data_source_get_type ())
#define DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DATA_SOURCE, DataSource))
#define DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DATA_SOURCE, DataSourceClass))
#define IS_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DATA_SOURCE))
#define IS_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DATA_SOURCE))
#define DATA_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DATA_SOURCE, DataSourceClass))

typedef struct _DataSource DataSource;
typedef struct _DataSourceClass DataSourceClass;

#define TYPE_INDEXABLE (indexable_get_type ())
#define INDEXABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_INDEXABLE, Indexable))
#define IS_INDEXABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_INDEXABLE))
#define INDEXABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_INDEXABLE, IndexableIface))

typedef struct _Indexable Indexable;
typedef struct _IndexableIface IndexableIface;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

struct _IndexableIface {
	GTypeInterface parent_iface;
	const gchar* (*get_indexable_keywords) (Indexable* self);
};



GType data_object_get_type (void) G_GNUC_CONST;
GType data_source_get_type (void) G_GNUC_CONST;
GType indexable_get_type (void) G_GNUC_CONST;
const gchar* indexable_get_indexable_keywords (Indexable* self);
gchar* indexable_prepare_indexable_string (const gchar* str);
gboolean is_string_empty (const gchar* s);
gchar* string_remove_diacritics (const gchar* istring);
gchar* indexable_prepare_indexable_strings (gchar** strs, int strs_length1);


const gchar* indexable_get_indexable_keywords (Indexable* self) {
#line 19 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	g_return_val_if_fail (IS_INDEXABLE (self), NULL);
#line 19 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	return INDEXABLE_GET_INTERFACE (self)->get_indexable_keywords (self);
#line 78 "SourceInterfaces.c"
}


gchar* indexable_prepare_indexable_string (const gchar* str) {
	gchar* result = NULL;
	const gchar* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
#line 22 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp0_ = str;
#line 22 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp1_ = is_string_empty (_tmp0_);
#line 22 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	if (_tmp1_) {
#line 23 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		result = NULL;
#line 23 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		return result;
#line 101 "SourceInterfaces.c"
	}
#line 24 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp2_ = str;
#line 24 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp3_ = g_utf8_strdown (_tmp2_, (gssize) -1);
#line 24 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp4_ = _tmp3_;
#line 24 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp5_ = string_remove_diacritics (_tmp4_);
#line 24 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp6_ = _tmp5_;
#line 24 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_g_free0 (_tmp4_);
#line 24 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	result = _tmp6_;
#line 24 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	return result;
#line 119 "SourceInterfaces.c"
}


gchar* indexable_prepare_indexable_strings (gchar** strs, int strs_length1) {
	gchar* result = NULL;
	gboolean _tmp0_ = FALSE;
	gchar** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	GString* builder = NULL;
	GString* _tmp3_ = NULL;
	gint ctr = 0;
	const gchar* _tmp21_ = NULL;
	GString* _tmp22_ = NULL;
	const gchar* _tmp23_ = NULL;
	gboolean _tmp24_ = FALSE;
	gchar* _tmp27_ = NULL;
#line 28 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp1_ = strs;
#line 28 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp1__length1 = strs_length1;
#line 28 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	if (_tmp1_ == NULL) {
#line 28 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		_tmp0_ = TRUE;
#line 144 "SourceInterfaces.c"
	} else {
		gchar** _tmp2_ = NULL;
		gint _tmp2__length1 = 0;
#line 28 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		_tmp2_ = strs;
#line 28 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		_tmp2__length1 = strs_length1;
#line 28 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		_tmp0_ = _tmp2__length1 == 0;
#line 154 "SourceInterfaces.c"
	}
#line 28 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	if (_tmp0_) {
#line 29 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		result = NULL;
#line 29 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		return result;
#line 162 "SourceInterfaces.c"
	}
#line 31 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp3_ = g_string_new ("");
#line 31 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	builder = _tmp3_;
#line 32 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	ctr = 0;
#line 170 "SourceInterfaces.c"
	{
		gboolean _tmp4_ = FALSE;
#line 33 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		_tmp4_ = TRUE;
#line 33 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		while (TRUE) {
#line 177 "SourceInterfaces.c"
			gchar** _tmp8_ = NULL;
			gint _tmp8__length1 = 0;
			gint _tmp9_ = 0;
			const gchar* _tmp10_ = NULL;
			gboolean _tmp11_ = FALSE;
#line 33 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
			if (!_tmp4_) {
#line 185 "SourceInterfaces.c"
				gint _tmp5_ = 0;
				gint _tmp6_ = 0;
				gchar** _tmp7_ = NULL;
				gint _tmp7__length1 = 0;
#line 39 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp5_ = ctr;
#line 39 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				ctr = _tmp5_ + 1;
#line 39 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp6_ = ctr;
#line 39 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp7_ = strs;
#line 39 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp7__length1 = strs_length1;
#line 39 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				if (!(_tmp6_ < _tmp7__length1)) {
#line 39 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
					break;
#line 204 "SourceInterfaces.c"
				}
			}
#line 33 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
			_tmp4_ = FALSE;
#line 34 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
			_tmp8_ = strs;
#line 34 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
			_tmp8__length1 = strs_length1;
#line 34 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
			_tmp9_ = ctr;
#line 34 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
			_tmp10_ = _tmp8_[_tmp9_];
#line 34 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
			_tmp11_ = is_string_empty (_tmp10_);
#line 34 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
			if (!_tmp11_) {
#line 221 "SourceInterfaces.c"
				GString* _tmp12_ = NULL;
				gchar** _tmp13_ = NULL;
				gint _tmp13__length1 = 0;
				gint _tmp14_ = 0;
				const gchar* _tmp15_ = NULL;
				gchar* _tmp16_ = NULL;
				gchar* _tmp17_ = NULL;
				gint _tmp18_ = 0;
				gchar** _tmp19_ = NULL;
				gint _tmp19__length1 = 0;
#line 35 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp12_ = builder;
#line 35 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp13_ = strs;
#line 35 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp13__length1 = strs_length1;
#line 35 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp14_ = ctr;
#line 35 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp15_ = _tmp13_[_tmp14_];
#line 35 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp16_ = g_utf8_strdown (_tmp15_, (gssize) -1);
#line 35 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp17_ = _tmp16_;
#line 35 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				g_string_append (_tmp12_, _tmp17_);
#line 35 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_g_free0 (_tmp17_);
#line 36 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp18_ = ctr;
#line 36 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp19_ = strs;
#line 36 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				_tmp19__length1 = strs_length1;
#line 36 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
				if (_tmp18_ < (_tmp19__length1 - 1)) {
#line 258 "SourceInterfaces.c"
					GString* _tmp20_ = NULL;
#line 37 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
					_tmp20_ = builder;
#line 37 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
					g_string_append_c (_tmp20_, ' ');
#line 264 "SourceInterfaces.c"
				}
			}
		}
	}
#line 41 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp22_ = builder;
#line 41 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp23_ = _tmp22_->str;
#line 41 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp24_ = is_string_empty (_tmp23_);
#line 41 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	if (!_tmp24_) {
#line 277 "SourceInterfaces.c"
		GString* _tmp25_ = NULL;
		const gchar* _tmp26_ = NULL;
#line 41 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		_tmp25_ = builder;
#line 41 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		_tmp26_ = _tmp25_->str;
#line 41 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		_tmp21_ = _tmp26_;
#line 286 "SourceInterfaces.c"
	} else {
#line 41 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		_tmp21_ = NULL;
#line 290 "SourceInterfaces.c"
	}
#line 41 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_tmp27_ = g_strdup (_tmp21_);
#line 41 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	result = _tmp27_;
#line 41 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	_g_string_free0 (builder);
#line 41 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	return result;
#line 300 "SourceInterfaces.c"
}


static void indexable_base_init (IndexableIface * iface) {
#line 18 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	static gboolean initialized = FALSE;
#line 18 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
	if (!initialized) {
#line 18 "/home/jens/Source/shotwell/src/core/SourceInterfaces.vala"
		initialized = TRUE;
#line 311 "SourceInterfaces.c"
	}
}


GType indexable_get_type (void) {
	static volatile gsize indexable_type_id__volatile = 0;
	if (g_once_init_enter (&indexable_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (IndexableIface), (GBaseInitFunc) indexable_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType indexable_type_id;
		indexable_type_id = g_type_register_static (G_TYPE_INTERFACE, "Indexable", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (indexable_type_id, TYPE_DATA_SOURCE);
		g_once_init_leave (&indexable_type_id__volatile, indexable_type_id);
	}
	return indexable_type_id__volatile;
}