1 /* moonshot-local-flat-file-store.c generated by valac 0.10.4, the Vala compiler
2 * generated from moonshot-local-flat-file-store.vala, do not modify */
6 #include <glib-object.h>
11 #include <gdk-pixbuf/gdk-pixdata.h>
13 #include <glib/gstdio.h>
16 #define TYPE_IIDENTITY_CARD_STORE (iidentity_card_store_get_type ())
17 #define IIDENTITY_CARD_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_IIDENTITY_CARD_STORE, IIdentityCardStore))
18 #define IS_IIDENTITY_CARD_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_IIDENTITY_CARD_STORE))
19 #define IIDENTITY_CARD_STORE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_IIDENTITY_CARD_STORE, IIdentityCardStoreIface))
21 typedef struct _IIdentityCardStore IIdentityCardStore;
22 typedef struct _IIdentityCardStoreIface IIdentityCardStoreIface;
24 #define TYPE_ID_CARD (id_card_get_type ())
25 #define ID_CARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ID_CARD, IdCard))
26 #define ID_CARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ID_CARD, IdCardClass))
27 #define IS_ID_CARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ID_CARD))
28 #define IS_ID_CARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ID_CARD))
29 #define ID_CARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ID_CARD, IdCardClass))
31 typedef struct _IdCard IdCard;
32 typedef struct _IdCardClass IdCardClass;
34 #define TYPE_LOCAL_FLAT_FILE_STORE (local_flat_file_store_get_type ())
35 #define LOCAL_FLAT_FILE_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LOCAL_FLAT_FILE_STORE, LocalFlatFileStore))
36 #define LOCAL_FLAT_FILE_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LOCAL_FLAT_FILE_STORE, LocalFlatFileStoreClass))
37 #define IS_LOCAL_FLAT_FILE_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LOCAL_FLAT_FILE_STORE))
38 #define IS_LOCAL_FLAT_FILE_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LOCAL_FLAT_FILE_STORE))
39 #define LOCAL_FLAT_FILE_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LOCAL_FLAT_FILE_STORE, LocalFlatFileStoreClass))
41 typedef struct _LocalFlatFileStore LocalFlatFileStore;
42 typedef struct _LocalFlatFileStoreClass LocalFlatFileStoreClass;
43 typedef struct _LocalFlatFileStorePrivate LocalFlatFileStorePrivate;
44 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
45 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
46 #define _g_free0(var) (var = (g_free (var), NULL))
47 #define _g_key_file_free0(var) ((var == NULL) ? NULL : (var = (g_key_file_free (var), NULL)))
49 #define TYPE_RULE (rule_get_type ())
50 typedef struct _Rule Rule;
52 #define TYPE_TRUST_ANCHOR (trust_anchor_get_type ())
53 #define TRUST_ANCHOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TRUST_ANCHOR, TrustAnchor))
54 #define TRUST_ANCHOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TRUST_ANCHOR, TrustAnchorClass))
55 #define IS_TRUST_ANCHOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TRUST_ANCHOR))
56 #define IS_TRUST_ANCHOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TRUST_ANCHOR))
57 #define TRUST_ANCHOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TRUST_ANCHOR, TrustAnchorClass))
59 typedef struct _TrustAnchor TrustAnchor;
60 typedef struct _TrustAnchorClass TrustAnchorClass;
62 struct _IIdentityCardStoreIface {
63 GTypeInterface parent_iface;
64 void (*add_card) (IIdentityCardStore* self, IdCard* card);
65 void (*remove_card) (IIdentityCardStore* self, IdCard* card);
66 void (*update_card) (IIdentityCardStore* self, IdCard* card);
67 GeeLinkedList* (*get_card_list) (IIdentityCardStore* self);
70 struct _LocalFlatFileStore {
71 GObject parent_instance;
72 LocalFlatFileStorePrivate * priv;
75 struct _LocalFlatFileStoreClass {
76 GObjectClass parent_class;
79 struct _LocalFlatFileStorePrivate {
80 GeeLinkedList* id_card_list;
89 static gpointer local_flat_file_store_parent_class = NULL;
90 static IIdentityCardStoreIface* local_flat_file_store_iidentity_card_store_parent_iface = NULL;
92 GType id_card_get_type (void) G_GNUC_CONST;
93 GType iidentity_card_store_get_type (void) G_GNUC_CONST;
94 GType local_flat_file_store_get_type (void) G_GNUC_CONST;
95 #define LOCAL_FLAT_FILE_STORE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_LOCAL_FLAT_FILE_STORE, LocalFlatFileStorePrivate))
97 LOCAL_FLAT_FILE_STORE_DUMMY_PROPERTY
99 #define LOCAL_FLAT_FILE_STORE_FILE_NAME "identities.txt"
100 static void local_flat_file_store_real_add_card (IIdentityCardStore* base, IdCard* card);
101 void local_flat_file_store_store_id_cards (LocalFlatFileStore* self);
102 static void local_flat_file_store_real_update_card (IIdentityCardStore* base, IdCard* card);
103 static void local_flat_file_store_real_remove_card (IIdentityCardStore* base, IdCard* card);
104 static GeeLinkedList* local_flat_file_store_real_get_card_list (IIdentityCardStore* base);
105 static void local_flat_file_store_load_id_cards (LocalFlatFileStore* self);
106 static char* local_flat_file_store_get_data_dir (LocalFlatFileStore* self);
107 IdCard* id_card_new (void);
108 IdCard* id_card_construct (GType object_type);
109 void id_card_set_issuer (IdCard* self, const char* value);
110 void id_card_set_username (IdCard* self, const char* value);
111 void id_card_set_password (IdCard* self, const char* value);
112 void id_card_set_services (IdCard* self, char** value, int value_length1);
113 void id_card_set_display_name (IdCard* self, const char* value);
114 GdkPixbuf* find_icon (const char* name, gint size);
115 GType rule_get_type (void) G_GNUC_CONST;
116 Rule* rule_dup (const Rule* self);
117 void rule_free (Rule* self);
118 void rule_copy (const Rule* self, Rule* dest);
119 void rule_destroy (Rule* self);
120 void id_card_set_rules (IdCard* self, Rule* value, int value_length1);
121 static void _vala_Rule_array_free (Rule* array, gint array_length);
122 GType trust_anchor_get_type (void) G_GNUC_CONST;
123 TrustAnchor* id_card_get_trust_anchor (IdCard* self);
124 void trust_anchor_set_ca_cert (TrustAnchor* self, const char* value);
125 void trust_anchor_set_subject (TrustAnchor* self, const char* value);
126 void trust_anchor_set_subject_alt (TrustAnchor* self, const char* value);
127 void trust_anchor_set_server_cert (TrustAnchor* self, const char* value);
128 Rule* id_card_get_rules (IdCard* self, int* result_length1);
129 const char* id_card_get_issuer (IdCard* self);
130 const char* id_card_get_display_name (IdCard* self);
131 const char* id_card_get_username (IdCard* self);
132 const char* id_card_get_password (IdCard* self);
133 char** id_card_get_services (IdCard* self, int* result_length1);
134 static char** _vala_array_dup1 (char** self, int length);
135 const char* trust_anchor_get_ca_cert (TrustAnchor* self);
136 const char* trust_anchor_get_subject (TrustAnchor* self);
137 const char* trust_anchor_get_subject_alt (TrustAnchor* self);
138 const char* trust_anchor_get_server_cert (TrustAnchor* self);
139 LocalFlatFileStore* local_flat_file_store_new (void);
140 LocalFlatFileStore* local_flat_file_store_construct (GType object_type);
141 static void local_flat_file_store_finalize (GObject* obj);
142 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
143 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
147 static void local_flat_file_store_real_add_card (IIdentityCardStore* base, IdCard* card) {
148 LocalFlatFileStore * self;
149 self = (LocalFlatFileStore*) base;
150 g_return_if_fail (card != NULL);
151 gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->id_card_list, card);
152 local_flat_file_store_store_id_cards (self);
156 static void local_flat_file_store_real_update_card (IIdentityCardStore* base, IdCard* card) {
157 LocalFlatFileStore * self;
158 self = (LocalFlatFileStore*) base;
159 g_return_if_fail (card != NULL);
160 gee_abstract_collection_remove ((GeeAbstractCollection*) self->priv->id_card_list, card);
161 gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->id_card_list, card);
162 local_flat_file_store_store_id_cards (self);
166 static void local_flat_file_store_real_remove_card (IIdentityCardStore* base, IdCard* card) {
167 LocalFlatFileStore * self;
168 self = (LocalFlatFileStore*) base;
169 g_return_if_fail (card != NULL);
170 gee_abstract_collection_remove ((GeeAbstractCollection*) self->priv->id_card_list, card);
171 local_flat_file_store_store_id_cards (self);
175 static gpointer _g_object_ref0 (gpointer self) {
176 return self ? g_object_ref (self) : NULL;
180 static GeeLinkedList* local_flat_file_store_real_get_card_list (IIdentityCardStore* base) {
181 LocalFlatFileStore * self;
182 GeeLinkedList* result = NULL;
183 self = (LocalFlatFileStore*) base;
184 result = _g_object_ref0 (self->priv->id_card_list);
189 static void _vala_Rule_array_free (Rule* array, gint array_length) {
192 for (i = 0; i < array_length; i = i + 1) {
193 rule_destroy (&array[i]);
200 static void local_flat_file_store_load_id_cards (LocalFlatFileStore* self) {
204 gint identities_uris_length1;
205 gint _identities_uris_size_;
208 char** identities_uris;
209 GError * _inner_error_ = NULL;
210 g_return_if_fail (self != NULL);
211 gee_abstract_collection_clear ((GeeAbstractCollection*) self->priv->id_card_list);
212 key_file = g_key_file_new ();
213 path = local_flat_file_store_get_data_dir (self);
214 filename = g_build_filename (path, LOCAL_FLAT_FILE_STORE_FILE_NAME, NULL);
216 g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, &_inner_error_);
217 if (_inner_error_ != NULL) {
218 goto __catch2_g_error;
226 _inner_error_ = NULL;
228 fprintf (stdout, "Error: %s\n", e->message);
232 _g_key_file_free0 (key_file);
237 if (_inner_error_ != NULL) {
240 _g_key_file_free0 (key_file);
241 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);
242 g_clear_error (&_inner_error_);
245 identities_uris = (_tmp1_ = g_key_file_get_groups (key_file, &_tmp0_), identities_uris_length1 = _tmp0_, _identities_uris_size_ = identities_uris_length1, _tmp1_);
247 char** identity_collection;
248 int identity_collection_length1;
250 identity_collection = identities_uris;
251 identity_collection_length1 = identities_uris_length1;
252 for (identity_it = 0; identity_it < identities_uris_length1; identity_it = identity_it + 1) {
254 identity = g_strdup (identity_collection[identity_it]);
270 gint _tmp11__length1;
274 gboolean _tmp15_ = FALSE;
284 id_card = id_card_new ();
285 _tmp2_ = g_key_file_get_string (key_file, identity, "Issuer", &_inner_error_);
286 if (_inner_error_ != NULL) {
287 _g_object_unref0 (id_card);
288 goto __catch3_g_error;
290 id_card_set_issuer (id_card, _tmp3_ = _tmp2_);
292 _tmp4_ = g_key_file_get_string (key_file, identity, "Username", &_inner_error_);
293 if (_inner_error_ != NULL) {
294 _g_object_unref0 (id_card);
295 goto __catch3_g_error;
297 id_card_set_username (id_card, _tmp5_ = _tmp4_);
299 _tmp6_ = g_key_file_get_string (key_file, identity, "Password", &_inner_error_);
300 if (_inner_error_ != NULL) {
301 _g_object_unref0 (id_card);
302 goto __catch3_g_error;
304 id_card_set_password (id_card, _tmp7_ = _tmp6_);
306 _tmp9_ = (_tmp10_ = g_key_file_get_string_list (key_file, identity, "Services", &_tmp8_, &_inner_error_), _tmp9__length1 = _tmp8_, __tmp9__size_ = _tmp9__length1, _tmp10_);
307 if (_inner_error_ != NULL) {
308 _g_object_unref0 (id_card);
309 goto __catch3_g_error;
311 _tmp12_ = (_tmp11_ = _tmp9_, _tmp11__length1 = _tmp9__length1, _tmp11_);
312 id_card_set_services (id_card, _tmp12_, _tmp9__length1);
313 _tmp11_ = (_vala_array_free (_tmp11_, _tmp11__length1, (GDestroyNotify) g_free), NULL);
314 _tmp13_ = g_key_file_get_string (key_file, identity, "DisplayName", &_inner_error_);
315 if (_inner_error_ != NULL) {
316 _g_object_unref0 (id_card);
317 goto __catch3_g_error;
319 id_card_set_display_name (id_card, _tmp14_ = _tmp13_);
321 g_object_set_data_full ((GObject*) id_card, "pixbuf", find_icon ("avatar-default", 48), g_object_unref);
322 _tmp16_ = g_key_file_has_key (key_file, identity, "Rules-Patterns", &_inner_error_);
323 if (_inner_error_ != NULL) {
324 _g_object_unref0 (id_card);
325 goto __catch3_g_error;
329 _tmp17_ = g_key_file_has_key (key_file, identity, "Rules-AlwaysConfirm", &_inner_error_);
330 if (_inner_error_ != NULL) {
331 _g_object_unref0 (id_card);
332 goto __catch3_g_error;
339 gint rules_patterns_length1;
340 gint _rules_patterns_size_;
343 char** rules_patterns;
344 gint rules_always_conf_length1;
345 gint _rules_always_conf_size_;
348 char** rules_always_conf;
349 rules_patterns = (_tmp19_ = g_key_file_get_string_list (key_file, identity, "Rules-Patterns", &_tmp18_, &_inner_error_), rules_patterns_length1 = _tmp18_, _rules_patterns_size_ = rules_patterns_length1, _tmp19_);
350 if (_inner_error_ != NULL) {
351 _g_object_unref0 (id_card);
352 goto __catch3_g_error;
354 rules_always_conf = (_tmp21_ = g_key_file_get_string_list (key_file, identity, "Rules-AlwaysConfirm", &_tmp20_, &_inner_error_), rules_always_conf_length1 = _tmp20_, _rules_always_conf_size_ = rules_always_conf_length1, _tmp21_);
355 if (_inner_error_ != NULL) {
356 rules_patterns = (_vala_array_free (rules_patterns, rules_patterns_length1, (GDestroyNotify) g_free), NULL);
357 _g_object_unref0 (id_card);
358 goto __catch3_g_error;
360 if (rules_patterns_length1 == rules_always_conf_length1) {
366 rules = (_tmp22_ = g_new0 (Rule, rules_patterns_length1), rules_length1 = rules_patterns_length1, _rules_size_ = rules_length1, _tmp22_);
380 if (!(i < rules_patterns_length1)) {
383 rules[i] = (_tmp25_ = (_tmp24_.pattern = g_strdup (rules_patterns[i]), _tmp24_.always_confirm = g_strdup (rules_always_conf[i]), _tmp24_), rule_destroy (&rules[i]), _tmp25_);
388 id_card_set_rules (id_card, _tmp26_, rules_length1);
389 rules = (_vala_Rule_array_free (rules, rules_length1), NULL);
391 rules_always_conf = (_vala_array_free (rules_always_conf, rules_always_conf_length1, (GDestroyNotify) g_free), NULL);
392 rules_patterns = (_vala_array_free (rules_patterns, rules_patterns_length1, (GDestroyNotify) g_free), NULL);
394 _tmp27_ = g_key_file_get_string (key_file, identity, "CA-Cert", &_inner_error_);
395 if (_inner_error_ != NULL) {
396 _g_object_unref0 (id_card);
397 goto __catch3_g_error;
399 trust_anchor_set_ca_cert (id_card_get_trust_anchor (id_card), _tmp28_ = _tmp27_);
401 _tmp29_ = g_key_file_get_string (key_file, identity, "Subject", &_inner_error_);
402 if (_inner_error_ != NULL) {
403 _g_object_unref0 (id_card);
404 goto __catch3_g_error;
406 trust_anchor_set_subject (id_card_get_trust_anchor (id_card), _tmp30_ = _tmp29_);
408 _tmp31_ = g_key_file_get_string (key_file, identity, "SubjectAlt", &_inner_error_);
409 if (_inner_error_ != NULL) {
410 _g_object_unref0 (id_card);
411 goto __catch3_g_error;
413 trust_anchor_set_subject_alt (id_card_get_trust_anchor (id_card), _tmp32_ = _tmp31_);
415 _tmp33_ = g_key_file_get_string (key_file, identity, "ServerCert", &_inner_error_);
416 if (_inner_error_ != NULL) {
417 _g_object_unref0 (id_card);
418 goto __catch3_g_error;
420 trust_anchor_set_server_cert (id_card_get_trust_anchor (id_card), _tmp34_ = _tmp33_);
422 gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->id_card_list, id_card);
423 _g_object_unref0 (id_card);
430 _inner_error_ = NULL;
432 fprintf (stdout, "Error: %s\n", e->message);
437 if (_inner_error_ != NULL) {
439 identities_uris = (_vala_array_free (identities_uris, identities_uris_length1, (GDestroyNotify) g_free), NULL);
442 _g_key_file_free0 (key_file);
443 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);
444 g_clear_error (&_inner_error_);
451 identities_uris = (_vala_array_free (identities_uris, identities_uris_length1, (GDestroyNotify) g_free), NULL);
454 _g_key_file_free0 (key_file);
458 static char* local_flat_file_store_get_data_dir (LocalFlatFileStore* self) {
462 g_return_val_if_fail (self != NULL, NULL);
464 path = (_tmp0_ = g_build_filename (g_get_user_data_dir (), PACKAGE_TARNAME, NULL), _g_free0 (path), _tmp0_);
465 if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
466 g_mkdir_with_parents (path, 0700);
473 static char** _vala_array_dup1 (char** self, int length) {
476 result = g_new0 (char*, length + 1);
477 for (i = 0; i < length; i++) {
478 result[i] = g_strdup (self[i]);
484 void local_flat_file_store_store_id_cards (LocalFlatFileStore* self) {
487 GError * _inner_error_ = NULL;
488 g_return_if_fail (self != NULL);
489 key_file = g_key_file_new ();
491 GeeIterator* _id_card_it;
492 _id_card_it = gee_abstract_collection_iterator ((GeeAbstractCollection*) self->priv->id_card_list);
495 gint rules_patterns_length1;
496 gint _rules_patterns_size_;
499 char** rules_patterns;
500 gint rules_always_conf_length1;
501 gint _rules_always_conf_size_;
504 char** rules_always_conf;
509 gint _tmp20__length1;
520 if (!gee_iterator_next (_id_card_it)) {
523 id_card = (IdCard*) gee_iterator_get (_id_card_it);
524 rules_patterns = (_tmp1_ = g_new0 (char*, _tmp0_ + 1), rules_patterns_length1 = _tmp0_, _rules_patterns_size_ = rules_patterns_length1, _tmp1_);
525 rules_always_conf = (_tmp3_ = g_new0 (char*, _tmp2_ + 1), rules_always_conf_length1 = _tmp2_, _rules_always_conf_size_ = rules_always_conf_length1, _tmp3_);
545 rules_patterns[i] = (_tmp7_ = g_strdup (id_card_get_rules (id_card, &_tmp6_)[i].pattern), _g_free0 (rules_patterns[i]), _tmp7_);
546 rules_always_conf[i] = (_tmp9_ = g_strdup (id_card_get_rules (id_card, &_tmp8_)[i].always_confirm), _g_free0 (rules_always_conf[i]), _tmp9_);
550 _tmp10_ = g_strdup (id_card_get_issuer (id_card));
551 if (_tmp10_ == NULL) {
553 _tmp10_ = (_tmp11_ = g_strdup (""), _g_free0 (_tmp10_), _tmp11_);
555 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "Issuer", _tmp10_);
556 _tmp12_ = g_strdup (id_card_get_display_name (id_card));
557 if (_tmp12_ == NULL) {
559 _tmp12_ = (_tmp13_ = g_strdup (""), _g_free0 (_tmp12_), _tmp13_);
561 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "DisplayName", _tmp12_);
562 _tmp14_ = g_strdup (id_card_get_username (id_card));
563 if (_tmp14_ == NULL) {
565 _tmp14_ = (_tmp15_ = g_strdup (""), _g_free0 (_tmp14_), _tmp15_);
567 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "Username", _tmp14_);
568 _tmp16_ = g_strdup (id_card_get_password (id_card));
569 if (_tmp16_ == NULL) {
571 _tmp16_ = (_tmp17_ = g_strdup (""), _g_free0 (_tmp16_), _tmp17_);
573 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "Password", _tmp16_);
574 _tmp20_ = (_tmp21_ = (_tmp19_ = id_card_get_services (id_card, &_tmp18_), (_tmp19_ == NULL) ? ((gpointer) _tmp19_) : _vala_array_dup1 (_tmp19_, _tmp18_)), _tmp20__length1 = _tmp18_, __tmp20__size_ = _tmp20__length1, _tmp21_);
575 if (_tmp20_ == NULL) {
576 char** _tmp22_ = NULL;
578 _tmp20_ = (_tmp23_ = (_tmp22_ = g_new0 (char*, 0 + 1), _tmp22_), _tmp20_ = (_vala_array_free (_tmp20_, _tmp20__length1, (GDestroyNotify) g_free), NULL), _tmp20__length1 = 0, __tmp20__size_ = _tmp20__length1, _tmp23_);
580 g_key_file_set_string_list (key_file, id_card_get_display_name (id_card), "Services", (const gchar* const*) _tmp20_, _tmp20__length1);
582 g_key_file_set_string_list (key_file, id_card_get_display_name (id_card), "Rules-Patterns", (const gchar* const*) rules_patterns, rules_patterns_length1);
583 g_key_file_set_string_list (key_file, id_card_get_display_name (id_card), "Rules-AlwaysConfirm", (const gchar* const*) rules_always_conf, rules_always_conf_length1);
585 _tmp25_ = g_strdup (trust_anchor_get_ca_cert (id_card_get_trust_anchor (id_card)));
586 if (_tmp25_ == NULL) {
588 _tmp25_ = (_tmp26_ = g_strdup (""), _g_free0 (_tmp25_), _tmp26_);
590 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "CA-Cert", _tmp25_);
591 _tmp27_ = g_strdup (trust_anchor_get_subject (id_card_get_trust_anchor (id_card)));
592 if (_tmp27_ == NULL) {
594 _tmp27_ = (_tmp28_ = g_strdup (""), _g_free0 (_tmp27_), _tmp28_);
596 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "Subject", _tmp27_);
597 _tmp29_ = g_strdup (trust_anchor_get_subject_alt (id_card_get_trust_anchor (id_card)));
598 if (_tmp29_ == NULL) {
600 _tmp29_ = (_tmp30_ = g_strdup (""), _g_free0 (_tmp29_), _tmp30_);
602 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "SubjectAlt", _tmp29_);
603 _tmp31_ = g_strdup (trust_anchor_get_server_cert (id_card_get_trust_anchor (id_card)));
604 if (_tmp31_ == NULL) {
606 _tmp31_ = (_tmp32_ = g_strdup (""), _g_free0 (_tmp31_), _tmp32_);
608 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "ServerCert", _tmp31_);
613 _tmp20_ = (_vala_array_free (_tmp20_, _tmp20__length1, (GDestroyNotify) g_free), NULL);
618 rules_always_conf = (_vala_array_free (rules_always_conf, rules_always_conf_length1, (GDestroyNotify) g_free), NULL);
619 rules_patterns = (_vala_array_free (rules_patterns, rules_patterns_length1, (GDestroyNotify) g_free), NULL);
620 _g_object_unref0 (id_card);
622 _g_object_unref0 (_id_card_it);
624 text = g_key_file_to_data (key_file, NULL, NULL);
628 path = local_flat_file_store_get_data_dir (self);
629 filename = g_build_filename (path, LOCAL_FLAT_FILE_STORE_FILE_NAME, NULL);
630 g_file_set_contents (filename, text, (gssize) (-1), &_inner_error_);
631 if (_inner_error_ != NULL) {
634 goto __catch4_g_error;
644 _inner_error_ = NULL;
646 fprintf (stdout, "Error: %s\n", e->message);
651 if (_inner_error_ != NULL) {
653 _g_key_file_free0 (key_file);
654 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);
655 g_clear_error (&_inner_error_);
658 local_flat_file_store_load_id_cards (self);
660 _g_key_file_free0 (key_file);
664 LocalFlatFileStore* local_flat_file_store_construct (GType object_type) {
665 LocalFlatFileStore * self = NULL;
666 GeeLinkedList* _tmp0_;
667 self = (LocalFlatFileStore*) g_object_new (object_type, NULL);
668 self->priv->id_card_list = (_tmp0_ = gee_linked_list_new (TYPE_ID_CARD, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL), _g_object_unref0 (self->priv->id_card_list), _tmp0_);
669 local_flat_file_store_load_id_cards (self);
674 LocalFlatFileStore* local_flat_file_store_new (void) {
675 return local_flat_file_store_construct (TYPE_LOCAL_FLAT_FILE_STORE);
679 static void local_flat_file_store_class_init (LocalFlatFileStoreClass * klass) {
680 local_flat_file_store_parent_class = g_type_class_peek_parent (klass);
681 g_type_class_add_private (klass, sizeof (LocalFlatFileStorePrivate));
682 G_OBJECT_CLASS (klass)->finalize = local_flat_file_store_finalize;
686 static void local_flat_file_store_iidentity_card_store_interface_init (IIdentityCardStoreIface * iface) {
687 local_flat_file_store_iidentity_card_store_parent_iface = g_type_interface_peek_parent (iface);
688 iface->add_card = local_flat_file_store_real_add_card;
689 iface->update_card = local_flat_file_store_real_update_card;
690 iface->remove_card = local_flat_file_store_real_remove_card;
691 iface->get_card_list = local_flat_file_store_real_get_card_list;
695 static void local_flat_file_store_instance_init (LocalFlatFileStore * self) {
696 self->priv = LOCAL_FLAT_FILE_STORE_GET_PRIVATE (self);
700 static void local_flat_file_store_finalize (GObject* obj) {
701 LocalFlatFileStore * self;
702 self = LOCAL_FLAT_FILE_STORE (obj);
703 _g_object_unref0 (self->priv->id_card_list);
704 G_OBJECT_CLASS (local_flat_file_store_parent_class)->finalize (obj);
708 GType local_flat_file_store_get_type (void) {
709 static volatile gsize local_flat_file_store_type_id__volatile = 0;
710 if (g_once_init_enter (&local_flat_file_store_type_id__volatile)) {
711 static const GTypeInfo g_define_type_info = { sizeof (LocalFlatFileStoreClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) local_flat_file_store_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LocalFlatFileStore), 0, (GInstanceInitFunc) local_flat_file_store_instance_init, NULL };
712 static const GInterfaceInfo iidentity_card_store_info = { (GInterfaceInitFunc) local_flat_file_store_iidentity_card_store_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
713 GType local_flat_file_store_type_id;
714 local_flat_file_store_type_id = g_type_register_static (G_TYPE_OBJECT, "LocalFlatFileStore", &g_define_type_info, 0);
715 g_type_add_interface_static (local_flat_file_store_type_id, TYPE_IIDENTITY_CARD_STORE, &iidentity_card_store_info);
716 g_once_init_leave (&local_flat_file_store_type_id__volatile, local_flat_file_store_type_id);
718 return local_flat_file_store_type_id__volatile;
722 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
723 if ((array != NULL) && (destroy_func != NULL)) {
725 for (i = 0; i < array_length; i = i + 1) {
726 if (((gpointer*) array)[i] != NULL) {
727 destroy_func (((gpointer*) array)[i]);
734 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
735 _vala_array_destroy (array, array_length, destroy_func);