1
/* history.c generated by valac 0.12.0, the Vala compiler
2
* generated from history.vala, do not modify */
6
#include <glib-object.h>
11
#include <gobject/gvaluecollector.h>
14
#define TYPE_HISTORY (history_get_type ())
15
#define HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HISTORY, History))
16
#define HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HISTORY, HistoryClass))
17
#define IS_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HISTORY))
18
#define IS_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HISTORY))
19
#define HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HISTORY, HistoryClass))
21
typedef struct _History History;
22
typedef struct _HistoryClass HistoryClass;
23
typedef struct _HistoryPrivate HistoryPrivate;
24
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
25
#define _sqlite3_close0(var) ((var == NULL) ? NULL : (var = (sqlite3_close (var), NULL)))
26
#define _g_free0(var) (var = (g_free (var), NULL))
27
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
28
#define _sqlite3_finalize0(var) ((var == NULL) ? NULL : (var = (sqlite3_finalize (var), NULL)))
29
#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))
31
#define TYPE_PGN (pgn_get_type ())
32
#define PGN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PGN, PGN))
33
#define PGN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PGN, PGNClass))
34
#define IS_PGN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PGN))
35
#define IS_PGN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PGN))
36
#define PGN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PGN, PGNClass))
38
typedef struct _PGN PGN;
39
typedef struct _PGNClass PGNClass;
40
typedef struct _PGNPrivate PGNPrivate;
42
#define TYPE_PGN_GAME (pgn_game_get_type ())
43
#define PGN_GAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PGN_GAME, PGNGame))
44
#define PGN_GAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PGN_GAME, PGNGameClass))
45
#define IS_PGN_GAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PGN_GAME))
46
#define IS_PGN_GAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PGN_GAME))
47
#define PGN_GAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PGN_GAME, PGNGameClass))
49
typedef struct _PGNGame PGNGame;
50
typedef struct _PGNGameClass PGNGameClass;
51
#define _pgn_game_unref0(var) ((var == NULL) ? NULL : (var = (pgn_game_unref (var), NULL)))
52
#define _pgn_unref0(var) ((var == NULL) ? NULL : (var = (pgn_unref (var), NULL)))
53
typedef struct _ParamSpecHistory ParamSpecHistory;
56
GTypeInstance parent_instance;
57
volatile int ref_count;
58
HistoryPrivate * priv;
61
struct _HistoryClass {
62
GTypeClass parent_class;
63
void (*finalize) (History *self);
66
struct _HistoryPrivate {
73
GTypeInstance parent_instance;
74
volatile int ref_count;
80
GTypeClass parent_class;
81
void (*finalize) (PGN *self);
84
struct _ParamSpecHistory {
85
GParamSpec parent_instance;
89
static gpointer history_parent_class = NULL;
91
gpointer history_ref (gpointer instance);
92
void history_unref (gpointer instance);
93
GParamSpec* param_spec_history (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
94
void value_set_history (GValue* value, gpointer v_object);
95
void value_take_history (GValue* value, gpointer v_object);
96
gpointer value_get_history (const GValue* value);
97
GType history_get_type (void) G_GNUC_CONST;
98
#define HISTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_HISTORY, HistoryPrivate))
100
HISTORY_DUMMY_PROPERTY
102
History* history_new (GFile* data_dir);
103
History* history_construct (GType object_type, GFile* data_dir);
104
GFile* history_add (History* self, const gchar* date, const gchar* _result_, GError** error);
105
static void history_load (History* self);
106
void history_remove (History* self, GFile* file);
107
void history_update (History* self, GFile* file, const gchar* fen, const gchar* _result_);
108
GList* history_get_unfinished (History* self);
109
static void _g_object_unref0_ (gpointer var);
110
static void _g_list_free__g_object_unref0_ (GList* self);
111
static void history_load_history_recursive (History* self, GFile* base_dir, GFile* dir, gboolean load_files, GError** error);
112
PGN* pgn_new_from_file (GFile* file, GError** error);
113
PGN* pgn_construct_from_file (GType object_type, GFile* file, GError** error);
114
gpointer pgn_ref (gpointer instance);
115
void pgn_unref (gpointer instance);
116
GParamSpec* param_spec_pgn (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
117
void value_set_pgn (GValue* value, gpointer v_object);
118
void value_take_pgn (GValue* value, gpointer v_object);
119
gpointer value_get_pgn (const GValue* value);
120
GType pgn_get_type (void) G_GNUC_CONST;
121
gpointer pgn_game_ref (gpointer instance);
122
void pgn_game_unref (gpointer instance);
123
GParamSpec* param_spec_pgn_game (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
124
void value_set_pgn_game (GValue* value, gpointer v_object);
125
void value_take_pgn_game (GValue* value, gpointer v_object);
126
gpointer value_get_pgn_game (const GValue* value);
127
GType pgn_game_get_type (void) G_GNUC_CONST;
128
const gchar* pgn_game_get_date (PGNGame* self);
129
const gchar* pgn_game_get_result (PGNGame* self);
130
static void history_finalize (History* obj);
131
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
132
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
133
static gint _vala_array_length (gpointer array);
136
History* history_construct (GType object_type, GFile* data_dir) {
137
History* self = NULL;
138
gchar* _tmp0_ = NULL;
140
gchar* _tmp2_ = NULL;
142
GFile* _tmp4_ = NULL;
143
g_return_val_if_fail (data_dir != NULL, NULL);
144
self = (History*) g_type_create_instance (object_type);
145
_tmp0_ = g_file_get_path (data_dir);
147
_tmp2_ = g_build_filename (_tmp1_, "history", NULL, NULL);
149
_tmp4_ = g_file_new_for_path (_tmp3_);
150
_g_object_unref0 (self->priv->history_dir);
151
self->priv->history_dir = _tmp4_;
158
History* history_new (GFile* data_dir) {
159
return history_construct (TYPE_HISTORY, data_dir);
163
static gpointer _g_error_copy0 (gpointer self) {
164
return self ? g_error_copy (self) : NULL;
168
GFile* history_add (History* self, const gchar* date, const gchar* _result_, GError** error) {
169
GFile* result = NULL;
171
gchar** _tmp1_ = NULL;
181
gchar* relative_path = NULL;
184
sqlite3_stmt* statement = NULL;
185
gchar* _tmp23_ = NULL;
187
sqlite3_stmt* _tmp25_ = NULL;
190
GError * _inner_error_ = NULL;
191
g_return_val_if_fail (self != NULL, NULL);
192
g_return_val_if_fail (date != NULL, NULL);
193
g_return_val_if_fail (_result_ != NULL, NULL);
195
_tmp1_ = _tmp0_ = g_strsplit (date, ".", 0);
197
tokens_length1 = _vala_array_length (_tmp0_);
198
_tokens_size_ = _vala_array_length (_tmp0_);
199
_tmp2_ = g_strdup ("????");
201
_tmp3_ = g_strdup ("??");
203
_tmp4_ = g_strdup ("??");
205
if (tokens_length1 == 3) {
209
_tmp5_ = g_strdup (tokens[0]);
212
_tmp6_ = g_strdup (tokens[1]);
215
_tmp7_ = g_strdup (tokens[2]);
221
gchar* filename = NULL;
222
gchar* _tmp10_ = NULL;
223
gchar* _tmp11_ = NULL;
225
gchar* _tmp13_ = NULL;
227
GFile* _tmp15_ = NULL;
228
gchar* _tmp16_ = NULL;
230
gchar* _tmp18_ = NULL;
232
GFileOutputStream* _tmp20_ = NULL;
233
GFileOutputStream* _tmp21_;
235
gchar* _tmp8_ = NULL;
236
_tmp8_ = g_strdup_printf ("%s-%s-%s.pgn", year, month, day);
240
gchar* _tmp9_ = NULL;
241
_tmp9_ = g_strdup_printf ("%s-%s-%s-%d.pgn", year, month, day, version);
245
_tmp10_ = g_build_filename (year, month, day, filename, NULL, NULL);
246
_g_free0 (relative_path);
247
relative_path = _tmp10_;
248
_tmp11_ = g_file_get_path (self->priv->history_dir);
250
_tmp13_ = g_build_filename (_tmp12_, relative_path, NULL, NULL);
252
_tmp15_ = g_file_new_for_path (_tmp14_);
253
_g_object_unref0 (file);
257
_tmp16_ = g_file_get_path (file);
259
_tmp18_ = g_path_get_dirname (_tmp17_);
261
g_mkdir_with_parents (_tmp19_, 0755);
264
_tmp20_ = g_file_create (file, G_FILE_CREATE_NONE, NULL, &_inner_error_);
266
_g_object_unref0 (_tmp21_);
267
if (_inner_error_ != NULL) {
268
goto __catch15_g_error;
277
_inner_error_ = NULL;
278
if (!g_error_matches (e, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
280
_tmp22_ = _g_error_copy0 (e);
281
_inner_error_ = _tmp22_;
288
if (_inner_error_ != NULL) {
289
g_propagate_error (error, _inner_error_);
291
_g_object_unref0 (file);
292
_g_free0 (relative_path);
296
tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
302
_tmp23_ = g_strdup_printf ("INSERT INTO GameTable (date, path, result) VALUES (0, \"%s\", \"%s\")", relative_path, _result_);
304
_tmp26_ = sqlite3_prepare_v2 (self->priv->db, _tmp24_, -1, &_tmp25_, NULL);
305
_sqlite3_finalize0 (statement);
307
g_assert (_tmp26_ == SQLITE_OK);
309
_tmp27_ = sqlite3_step (statement);
310
if (_tmp27_ != SQLITE_DONE) {
311
const gchar* _tmp28_ = NULL;
312
_tmp28_ = sqlite3_errmsg (self->priv->db);
313
g_warning ("history.vala:56: Failed to insert game into history index: %s", _tmp28_);
316
_sqlite3_finalize0 (statement);
317
_g_free0 (relative_path);
321
tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
326
void history_remove (History* self, GFile* file) {
327
gchar* _tmp0_ = NULL;
328
gchar* relative_path;
329
sqlite3_stmt* statement = NULL;
330
gchar* _tmp1_ = NULL;
332
sqlite3_stmt* _tmp3_ = NULL;
335
g_return_if_fail (self != NULL);
336
g_return_if_fail (file != NULL);
337
_tmp0_ = g_file_get_relative_path (self->priv->history_dir, file);
338
relative_path = _tmp0_;
339
_tmp1_ = g_strdup_printf ("DELETE FROM GameTable WHERE path=\"%s\"", relative_path);
341
_tmp4_ = sqlite3_prepare_v2 (self->priv->db, _tmp2_, -1, &_tmp3_, NULL);
342
_sqlite3_finalize0 (statement);
344
g_assert (_tmp4_ == SQLITE_OK);
346
_tmp5_ = sqlite3_step (statement);
347
if (_tmp5_ != SQLITE_DONE) {
348
const gchar* _tmp6_ = NULL;
349
_tmp6_ = sqlite3_errmsg (self->priv->db);
350
g_warning ("history.vala:68: Failed to remove game from history index: %s", _tmp6_);
352
_sqlite3_finalize0 (statement);
353
_g_free0 (relative_path);
357
void history_update (History* self, GFile* file, const gchar* fen, const gchar* _result_) {
358
gchar* _tmp0_ = NULL;
359
gchar* relative_path;
360
sqlite3_stmt* statement = NULL;
361
gchar* _tmp1_ = NULL;
363
sqlite3_stmt* _tmp3_ = NULL;
366
g_return_if_fail (self != NULL);
367
g_return_if_fail (file != NULL);
368
g_return_if_fail (fen != NULL);
369
g_return_if_fail (_result_ != NULL);
370
_tmp0_ = g_file_get_relative_path (self->priv->history_dir, file);
371
relative_path = _tmp0_;
372
_tmp1_ = g_strdup_printf ("UPDATE GameTable SET fen=\"%s\", result=\"%s\" WHERE path=\"%s\"", fen, _result_, relative_path);
374
_tmp4_ = sqlite3_prepare_v2 (self->priv->db, _tmp2_, -1, &_tmp3_, NULL);
375
_sqlite3_finalize0 (statement);
377
g_assert (_tmp4_ == SQLITE_OK);
379
_tmp5_ = sqlite3_step (statement);
380
if (_tmp5_ != SQLITE_DONE) {
381
const gchar* _tmp6_ = NULL;
382
_tmp6_ = sqlite3_errmsg (self->priv->db);
383
g_warning ("history.vala:78: Failed to update game in history index: %s", _tmp6_);
385
_sqlite3_finalize0 (statement);
386
_g_free0 (relative_path);
390
static void _g_object_unref0_ (gpointer var) {
391
(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
395
static void _g_list_free__g_object_unref0_ (GList* self) {
396
g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
401
GList* history_get_unfinished (History* self) {
402
GList* result = NULL;
404
sqlite3_stmt* statement = NULL;
405
sqlite3_stmt* _tmp0_ = NULL;
408
g_return_val_if_fail (self != NULL, NULL);
411
_tmp1_ = sqlite3_prepare_v2 (self->priv->db, "SELECT path FROM GameTable WHERE result=\"*\"", -1, &_tmp0_, NULL);
412
_sqlite3_finalize0 (statement);
415
g_assert (_result_ == SQLITE_OK);
418
const gchar* _tmp3_ = NULL;
421
gchar* _tmp5_ = NULL;
423
gchar* _tmp7_ = NULL;
425
GFile* _tmp9_ = NULL;
426
_tmp2_ = sqlite3_step (statement);
428
if (!(_result_ == SQLITE_ROW)) {
431
_tmp3_ = sqlite3_column_text (statement, 0);
432
_tmp4_ = g_strdup (_tmp3_);
434
g_debug ("history.vala:94: %s is unfinished", path);
435
_tmp5_ = g_file_get_path (self->priv->history_dir);
437
_tmp7_ = g_build_filename (_tmp6_, path, NULL, NULL);
439
_tmp9_ = g_file_new_for_path (_tmp8_);
440
values = g_list_append (values, _tmp9_);
445
if (_result_ != SQLITE_DONE) {
446
const gchar* _tmp10_ = NULL;
447
_tmp10_ = sqlite3_errmsg (self->priv->db);
448
g_warning ("history.vala:99: Failed to get unfinished games: %s", _tmp10_);
451
_sqlite3_finalize0 (statement);
456
static void history_load (History* self) {
458
gboolean have_history;
459
gchar* _tmp1_ = NULL;
461
gchar* _tmp3_ = NULL;
463
gchar* _tmp5_ = NULL;
465
sqlite3* _tmp7_ = NULL;
468
sqlite3_stmt* statement = NULL;
469
sqlite3_stmt* _tmp11_ = NULL;
473
const gchar* _tmp15_ = NULL;
474
gchar* _tmp16_ = NULL;
476
GFile* _tmp18_ = NULL;
478
GFile* old_history_dir;
479
gboolean _tmp20_ = FALSE;
480
GError * _inner_error_ = NULL;
481
g_return_if_fail (self != NULL);
482
if (self->priv->loaded) {
485
_tmp0_ = g_file_query_exists (self->priv->history_dir, NULL);
486
have_history = _tmp0_;
487
_tmp1_ = g_file_get_path (self->priv->history_dir);
489
g_mkdir_with_parents (_tmp2_, 0755);
491
_tmp3_ = g_file_get_path (self->priv->history_dir);
493
_tmp5_ = g_build_filename (_tmp4_, "index.db", NULL);
495
_tmp8_ = sqlite3_open_v2 (_tmp6_, &_tmp7_, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
496
_sqlite3_close0 (self->priv->db);
497
self->priv->db = _tmp7_;
498
_tmp9_ = _tmp8_ != SQLITE_OK;
502
const gchar* _tmp10_ = NULL;
503
_tmp10_ = sqlite3_errmsg (self->priv->db);
504
g_warning ("history.vala:114: Failed to load history index: %s", _tmp10_);
506
_tmp12_ = sqlite3_prepare_v2 (self->priv->db, "CREATE TABLE IF NOT EXISTS GameTable (id INTEGER PRIMARY KEY, date INT" \
507
"EGER, path TEXT, fen TEXT, result TEXT)", -1, &_tmp11_, NULL);
508
_sqlite3_finalize0 (statement);
511
g_assert (_result_ == SQLITE_OK);
512
_tmp13_ = sqlite3_step (statement);
513
if (_tmp13_ != SQLITE_DONE) {
514
const gchar* _tmp14_ = NULL;
515
_tmp14_ = sqlite3_errmsg (self->priv->db);
516
g_warning ("history.vala:121: Failed to create game table: %s", _tmp14_);
518
_tmp15_ = g_get_home_dir ();
519
_tmp16_ = g_build_filename (_tmp15_, ".gnome2", "glchess", "history", NULL, NULL);
521
_tmp18_ = g_file_new_for_path (_tmp17_);
524
old_history_dir = _tmp19_;
527
_tmp21_ = g_file_query_exists (old_history_dir, NULL);
533
gchar* _tmp22_ = NULL;
535
gchar* _tmp24_ = NULL;
537
_tmp22_ = g_file_get_path (old_history_dir);
539
_tmp24_ = g_file_get_path (self->priv->history_dir);
541
g_debug ("history.vala:127: Migrating history from %s to %s", _tmp23_, _tmp25_);
544
history_load_history_recursive (self, old_history_dir, old_history_dir, FALSE, &_inner_error_);
545
if (_inner_error_ != NULL) {
546
goto __catch16_g_error;
553
_inner_error_ = NULL;
554
g_warning ("history.vala:134: Failed to migrate history: %s", e->message);
558
if (_inner_error_ != NULL) {
559
_g_object_unref0 (old_history_dir);
560
_sqlite3_finalize0 (statement);
561
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
562
g_clear_error (&_inner_error_);
566
self->priv->loaded = TRUE;
567
_g_object_unref0 (old_history_dir);
568
_sqlite3_finalize0 (statement);
572
static gpointer _pgn_game_ref0 (gpointer self) {
573
return self ? pgn_game_ref (self) : NULL;
577
static void history_load_history_recursive (History* self, GFile* base_dir, GFile* dir, gboolean load_files, GError** error) {
578
GFileEnumerator* _tmp0_ = NULL;
579
GFileEnumerator* children;
580
GError * _inner_error_ = NULL;
581
g_return_if_fail (self != NULL);
582
g_return_if_fail (base_dir != NULL);
583
g_return_if_fail (dir != NULL);
584
_tmp0_ = g_file_enumerate_children (dir, "standard::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &_inner_error_);
586
if (_inner_error_ != NULL) {
587
g_propagate_error (error, _inner_error_);
591
GFileInfo* _tmp1_ = NULL;
594
_tmp1_ = g_file_enumerator_next_file (children, NULL, &_inner_error_);
596
if (_inner_error_ != NULL) {
597
g_propagate_error (error, _inner_error_);
598
_g_object_unref0 (children);
602
_g_object_unref0 (info);
603
_g_object_unref0 (children);
606
_tmp2_ = g_file_info_get_file_type (info);
608
case G_FILE_TYPE_REGULAR:
610
gchar* _tmp3_ = NULL;
612
const gchar* _tmp5_ = NULL;
613
gchar* _tmp6_ = NULL;
615
GFile* _tmp8_ = NULL;
618
gchar* _tmp10_ = NULL;
622
gconstpointer _tmp13_ = NULL;
625
const gchar* _tmp15_ = NULL;
626
const gchar* _tmp16_ = NULL;
627
GFile* _tmp17_ = NULL;
632
_tmp3_ = g_file_get_path (dir);
634
_tmp5_ = g_file_info_get_name (info);
635
_tmp6_ = g_build_filename (_tmp4_, _tmp5_, NULL, NULL);
637
_tmp8_ = g_file_new_for_path (_tmp7_);
642
_tmp10_ = g_file_get_path (f);
644
g_debug ("history.vala:158: Migrating %s", _tmp11_);
646
_tmp12_ = pgn_new_from_file (f, &_inner_error_);
648
if (_inner_error_ != NULL) {
649
goto __catch17_g_error;
651
_tmp13_ = g_list_nth_data (pgn->games, (guint) 0);
652
_tmp14_ = _pgn_game_ref0 ((PGNGame*) _tmp13_);
654
_tmp15_ = pgn_game_get_date (game);
655
_tmp16_ = pgn_game_get_result (game);
656
_tmp17_ = history_add (self, _tmp15_, _tmp16_, &_inner_error_);
658
if (_inner_error_ != NULL) {
659
_pgn_game_unref0 (game);
661
goto __catch17_g_error;
663
g_file_copy (f, new_file, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &_inner_error_);
664
if (_inner_error_ != NULL) {
665
_g_object_unref0 (new_file);
666
_pgn_game_unref0 (game);
668
goto __catch17_g_error;
670
_g_object_unref0 (new_file);
671
_pgn_game_unref0 (game);
678
_inner_error_ = NULL;
679
g_warning ("history.vala:171: Failed to migrate file: %s", e->message);
683
if (_inner_error_ != NULL) {
684
g_propagate_error (error, _inner_error_);
685
_g_object_unref0 (f);
686
_g_object_unref0 (info);
687
_g_object_unref0 (children);
690
_g_object_unref0 (f);
693
case G_FILE_TYPE_DIRECTORY:
695
gchar* _tmp18_ = NULL;
697
const gchar* _tmp20_ = NULL;
698
gchar* _tmp21_ = NULL;
701
GFile* _tmp23_ = NULL;
703
_tmp18_ = g_file_get_path (dir);
705
_tmp20_ = g_file_info_get_name (info);
706
_tmp21_ = g_build_filename (_tmp19_, _tmp20_, NULL, NULL);
710
_tmp23_ = g_file_new_for_path (path);
712
history_load_history_recursive (self, base_dir, _tmp24_, TRUE, &_inner_error_);
713
_g_object_unref0 (_tmp24_);
714
if (_inner_error_ != NULL) {
715
goto __catch18_g_error;
722
_inner_error_ = NULL;
723
g_warning ("history.vala:182: Couldn't open directory %s: %s", path, e->message);
727
if (_inner_error_ != NULL) {
728
g_propagate_error (error, _inner_error_);
730
_g_object_unref0 (info);
731
_g_object_unref0 (children);
742
_g_object_unref0 (info);
744
_g_object_unref0 (children);
748
static void value_history_init (GValue* value) {
749
value->data[0].v_pointer = NULL;
753
static void value_history_free_value (GValue* value) {
754
if (value->data[0].v_pointer) {
755
history_unref (value->data[0].v_pointer);
760
static void value_history_copy_value (const GValue* src_value, GValue* dest_value) {
761
if (src_value->data[0].v_pointer) {
762
dest_value->data[0].v_pointer = history_ref (src_value->data[0].v_pointer);
764
dest_value->data[0].v_pointer = NULL;
769
static gpointer value_history_peek_pointer (const GValue* value) {
770
return value->data[0].v_pointer;
774
static gchar* value_history_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
775
if (collect_values[0].v_pointer) {
777
object = collect_values[0].v_pointer;
778
if (object->parent_instance.g_class == NULL) {
779
return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
780
} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
781
return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
783
value->data[0].v_pointer = history_ref (object);
785
value->data[0].v_pointer = NULL;
791
static gchar* value_history_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
793
object_p = collect_values[0].v_pointer;
795
return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
797
if (!value->data[0].v_pointer) {
799
} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
800
*object_p = value->data[0].v_pointer;
802
*object_p = history_ref (value->data[0].v_pointer);
808
GParamSpec* param_spec_history (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
809
ParamSpecHistory* spec;
810
g_return_val_if_fail (g_type_is_a (object_type, TYPE_HISTORY), NULL);
811
spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
812
G_PARAM_SPEC (spec)->value_type = object_type;
813
return G_PARAM_SPEC (spec);
817
gpointer value_get_history (const GValue* value) {
818
g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY), NULL);
819
return value->data[0].v_pointer;
823
void value_set_history (GValue* value, gpointer v_object) {
825
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY));
826
old = value->data[0].v_pointer;
828
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_HISTORY));
829
g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
830
value->data[0].v_pointer = v_object;
831
history_ref (value->data[0].v_pointer);
833
value->data[0].v_pointer = NULL;
841
void value_take_history (GValue* value, gpointer v_object) {
843
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HISTORY));
844
old = value->data[0].v_pointer;
846
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_HISTORY));
847
g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
848
value->data[0].v_pointer = v_object;
850
value->data[0].v_pointer = NULL;
858
static void history_class_init (HistoryClass * klass) {
859
history_parent_class = g_type_class_peek_parent (klass);
860
HISTORY_CLASS (klass)->finalize = history_finalize;
861
g_type_class_add_private (klass, sizeof (HistoryPrivate));
865
static void history_instance_init (History * self) {
866
self->priv = HISTORY_GET_PRIVATE (self);
867
self->priv->loaded = FALSE;
872
static void history_finalize (History* obj) {
874
self = HISTORY (obj);
875
_g_object_unref0 (self->priv->history_dir);
876
_sqlite3_close0 (self->priv->db);
880
GType history_get_type (void) {
881
static volatile gsize history_type_id__volatile = 0;
882
if (g_once_init_enter (&history_type_id__volatile)) {
883
static const GTypeValueTable g_define_type_value_table = { value_history_init, value_history_free_value, value_history_copy_value, value_history_peek_pointer, "p", value_history_collect_value, "p", value_history_lcopy_value };
884
static const GTypeInfo g_define_type_info = { sizeof (HistoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) history_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (History), 0, (GInstanceInitFunc) history_instance_init, &g_define_type_value_table };
885
static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
886
GType history_type_id;
887
history_type_id = g_type_register_fundamental (g_type_fundamental_next (), "History", &g_define_type_info, &g_define_type_fundamental_info, 0);
888
g_once_init_leave (&history_type_id__volatile, history_type_id);
890
return history_type_id__volatile;
894
gpointer history_ref (gpointer instance) {
897
g_atomic_int_inc (&self->ref_count);
902
void history_unref (gpointer instance) {
905
if (g_atomic_int_dec_and_test (&self->ref_count)) {
906
HISTORY_GET_CLASS (self)->finalize (self);
907
g_type_free_instance ((GTypeInstance *) self);
912
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
913
if ((array != NULL) && (destroy_func != NULL)) {
915
for (i = 0; i < array_length; i = i + 1) {
916
if (((gpointer*) array)[i] != NULL) {
917
destroy_func (((gpointer*) array)[i]);
924
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
925
_vala_array_destroy (array, array_length, destroy_func);
930
static gint _vala_array_length (gpointer array) {
934
while (((gpointer*) array)[length]) {