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 #line 7 "moonshot-local-flat-file-store.vala"
148 static void local_flat_file_store_real_add_card (IIdentityCardStore* base, IdCard* card) {
149 #line 150 "moonshot-local-flat-file-store.c"
150 LocalFlatFileStore * self;
151 self = (LocalFlatFileStore*) base;
152 #line 7 "moonshot-local-flat-file-store.vala"
153 g_return_if_fail (card != NULL);
154 #line 8 "moonshot-local-flat-file-store.vala"
155 gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->id_card_list, card);
156 #line 9 "moonshot-local-flat-file-store.vala"
157 local_flat_file_store_store_id_cards (self);
158 #line 159 "moonshot-local-flat-file-store.c"
162 #line 12 "moonshot-local-flat-file-store.vala"
163 static void local_flat_file_store_real_update_card (IIdentityCardStore* base, IdCard* card) {
164 #line 165 "moonshot-local-flat-file-store.c"
165 LocalFlatFileStore * self;
166 self = (LocalFlatFileStore*) base;
167 #line 12 "moonshot-local-flat-file-store.vala"
168 g_return_if_fail (card != NULL);
169 #line 13 "moonshot-local-flat-file-store.vala"
170 gee_abstract_collection_remove ((GeeAbstractCollection*) self->priv->id_card_list, card);
171 #line 14 "moonshot-local-flat-file-store.vala"
172 gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->id_card_list, card);
173 #line 15 "moonshot-local-flat-file-store.vala"
174 local_flat_file_store_store_id_cards (self);
175 #line 176 "moonshot-local-flat-file-store.c"
179 #line 18 "moonshot-local-flat-file-store.vala"
180 static void local_flat_file_store_real_remove_card (IIdentityCardStore* base, IdCard* card) {
181 #line 182 "moonshot-local-flat-file-store.c"
182 LocalFlatFileStore * self;
183 self = (LocalFlatFileStore*) base;
184 #line 18 "moonshot-local-flat-file-store.vala"
185 g_return_if_fail (card != NULL);
186 #line 19 "moonshot-local-flat-file-store.vala"
187 gee_abstract_collection_remove ((GeeAbstractCollection*) self->priv->id_card_list, card);
188 #line 20 "moonshot-local-flat-file-store.vala"
189 local_flat_file_store_store_id_cards (self);
190 #line 191 "moonshot-local-flat-file-store.c"
194 static gpointer _g_object_ref0 (gpointer self) {
195 return self ? g_object_ref (self) : NULL;
199 #line 23 "moonshot-local-flat-file-store.vala"
200 static GeeLinkedList* local_flat_file_store_real_get_card_list (IIdentityCardStore* base) {
201 #line 202 "moonshot-local-flat-file-store.c"
202 LocalFlatFileStore * self;
203 GeeLinkedList* result = NULL;
204 self = (LocalFlatFileStore*) base;
205 result = _g_object_ref0 (self->priv->id_card_list);
206 #line 24 "moonshot-local-flat-file-store.vala"
208 #line 209 "moonshot-local-flat-file-store.c"
212 static void _vala_Rule_array_free (Rule* array, gint array_length) {
215 for (i = 0; i < array_length; i = i + 1) {
216 rule_destroy (&array[i]);
223 #line 27 "moonshot-local-flat-file-store.vala"
224 static void local_flat_file_store_load_id_cards (LocalFlatFileStore* self) {
225 #line 226 "moonshot-local-flat-file-store.c"
229 gint identities_uris_length1;
230 gint _identities_uris_size_;
233 char** identities_uris;
234 GError * _inner_error_ = NULL;
235 #line 27 "moonshot-local-flat-file-store.vala"
236 g_return_if_fail (self != NULL);
237 #line 28 "moonshot-local-flat-file-store.vala"
238 gee_abstract_collection_clear ((GeeAbstractCollection*) self->priv->id_card_list);
239 #line 29 "moonshot-local-flat-file-store.vala"
240 key_file = g_key_file_new ();
241 #line 30 "moonshot-local-flat-file-store.vala"
242 path = local_flat_file_store_get_data_dir (self);
243 #line 31 "moonshot-local-flat-file-store.vala"
244 filename = g_build_filename (path, LOCAL_FLAT_FILE_STORE_FILE_NAME, NULL);
245 #line 246 "moonshot-local-flat-file-store.c"
247 #line 34 "moonshot-local-flat-file-store.vala"
248 g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, &_inner_error_);
249 #line 250 "moonshot-local-flat-file-store.c"
250 if (_inner_error_ != NULL) {
251 goto __catch2_g_error;
259 _inner_error_ = NULL;
261 #line 37 "moonshot-local-flat-file-store.vala"
262 fprintf (stdout, "Error: %s\n", e->message);
263 #line 264 "moonshot-local-flat-file-store.c"
267 _g_key_file_free0 (key_file);
268 #line 38 "moonshot-local-flat-file-store.vala"
270 #line 271 "moonshot-local-flat-file-store.c"
274 if (_inner_error_ != NULL) {
277 _g_key_file_free0 (key_file);
278 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);
279 g_clear_error (&_inner_error_);
282 identities_uris = (_tmp1_ = g_key_file_get_groups (key_file, &_tmp0_), identities_uris_length1 = _tmp0_, _identities_uris_size_ = identities_uris_length1, _tmp1_);
284 char** identity_collection;
285 int identity_collection_length1;
287 #line 42 "moonshot-local-flat-file-store.vala"
288 identity_collection = identities_uris;
289 #line 290 "moonshot-local-flat-file-store.c"
290 identity_collection_length1 = identities_uris_length1;
291 for (identity_it = 0; identity_it < identities_uris_length1; identity_it = identity_it + 1) {
293 identity = g_strdup (identity_collection[identity_it]);
309 gint _tmp11__length1;
313 gboolean _tmp15_ = FALSE;
323 #line 44 "moonshot-local-flat-file-store.vala"
324 id_card = id_card_new ();
325 #line 46 "moonshot-local-flat-file-store.vala"
326 _tmp2_ = g_key_file_get_string (key_file, identity, "Issuer", &_inner_error_);
327 #line 328 "moonshot-local-flat-file-store.c"
328 if (_inner_error_ != NULL) {
329 _g_object_unref0 (id_card);
330 goto __catch3_g_error;
332 #line 46 "moonshot-local-flat-file-store.vala"
333 id_card_set_issuer (id_card, _tmp3_ = _tmp2_);
334 #line 335 "moonshot-local-flat-file-store.c"
336 #line 47 "moonshot-local-flat-file-store.vala"
337 _tmp4_ = g_key_file_get_string (key_file, identity, "Username", &_inner_error_);
338 #line 339 "moonshot-local-flat-file-store.c"
339 if (_inner_error_ != NULL) {
340 _g_object_unref0 (id_card);
341 goto __catch3_g_error;
343 #line 47 "moonshot-local-flat-file-store.vala"
344 id_card_set_username (id_card, _tmp5_ = _tmp4_);
345 #line 346 "moonshot-local-flat-file-store.c"
347 #line 48 "moonshot-local-flat-file-store.vala"
348 _tmp6_ = g_key_file_get_string (key_file, identity, "Password", &_inner_error_);
349 #line 350 "moonshot-local-flat-file-store.c"
350 if (_inner_error_ != NULL) {
351 _g_object_unref0 (id_card);
352 goto __catch3_g_error;
354 #line 48 "moonshot-local-flat-file-store.vala"
355 id_card_set_password (id_card, _tmp7_ = _tmp6_);
356 #line 357 "moonshot-local-flat-file-store.c"
358 _tmp9_ = (_tmp10_ = g_key_file_get_string_list (key_file, identity, "Services", &_tmp8_, &_inner_error_), _tmp9__length1 = _tmp8_, __tmp9__size_ = _tmp9__length1, _tmp10_);
359 if (_inner_error_ != NULL) {
360 _g_object_unref0 (id_card);
361 goto __catch3_g_error;
363 #line 49 "moonshot-local-flat-file-store.vala"
364 _tmp12_ = (_tmp11_ = _tmp9_, _tmp11__length1 = _tmp9__length1, _tmp11_);
365 #line 49 "moonshot-local-flat-file-store.vala"
366 id_card_set_services (id_card, _tmp12_, _tmp9__length1);
367 #line 368 "moonshot-local-flat-file-store.c"
368 _tmp11_ = (_vala_array_free (_tmp11_, _tmp11__length1, (GDestroyNotify) g_free), NULL);
369 #line 50 "moonshot-local-flat-file-store.vala"
370 _tmp13_ = g_key_file_get_string (key_file, identity, "DisplayName", &_inner_error_);
371 #line 372 "moonshot-local-flat-file-store.c"
372 if (_inner_error_ != NULL) {
373 _g_object_unref0 (id_card);
374 goto __catch3_g_error;
376 #line 50 "moonshot-local-flat-file-store.vala"
377 id_card_set_display_name (id_card, _tmp14_ = _tmp13_);
378 #line 379 "moonshot-local-flat-file-store.c"
380 #line 51 "moonshot-local-flat-file-store.vala"
381 g_object_set_data_full ((GObject*) id_card, "pixbuf", find_icon ("avatar-default", 48), g_object_unref);
382 #line 54 "moonshot-local-flat-file-store.vala"
383 _tmp16_ = g_key_file_has_key (key_file, identity, "Rules-Patterns", &_inner_error_);
384 #line 385 "moonshot-local-flat-file-store.c"
385 if (_inner_error_ != NULL) {
386 _g_object_unref0 (id_card);
387 goto __catch3_g_error;
389 #line 54 "moonshot-local-flat-file-store.vala"
391 #line 392 "moonshot-local-flat-file-store.c"
393 #line 55 "moonshot-local-flat-file-store.vala"
394 _tmp17_ = g_key_file_has_key (key_file, identity, "Rules-AlwaysConfirm", &_inner_error_);
395 #line 396 "moonshot-local-flat-file-store.c"
396 if (_inner_error_ != NULL) {
397 _g_object_unref0 (id_card);
398 goto __catch3_g_error;
400 #line 55 "moonshot-local-flat-file-store.vala"
402 #line 403 "moonshot-local-flat-file-store.c"
404 #line 54 "moonshot-local-flat-file-store.vala"
406 #line 407 "moonshot-local-flat-file-store.c"
408 #line 54 "moonshot-local-flat-file-store.vala"
410 #line 411 "moonshot-local-flat-file-store.c"
411 gint rules_patterns_length1;
412 gint _rules_patterns_size_;
415 char** rules_patterns;
416 gint rules_always_conf_length1;
417 gint _rules_always_conf_size_;
420 char** rules_always_conf;
421 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_);
422 if (_inner_error_ != NULL) {
423 _g_object_unref0 (id_card);
424 goto __catch3_g_error;
426 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_);
427 if (_inner_error_ != NULL) {
428 rules_patterns = (_vala_array_free (rules_patterns, rules_patterns_length1, (GDestroyNotify) g_free), NULL);
429 _g_object_unref0 (id_card);
430 goto __catch3_g_error;
432 #line 59 "moonshot-local-flat-file-store.vala"
433 if (rules_patterns_length1 == rules_always_conf_length1) {
434 #line 435 "moonshot-local-flat-file-store.c"
440 rules = (_tmp22_ = g_new0 (Rule, rules_patterns_length1), rules_length1 = rules_patterns_length1, _rules_size_ = rules_length1, _tmp22_);
443 #line 61 "moonshot-local-flat-file-store.vala"
445 #line 446 "moonshot-local-flat-file-store.c"
448 #line 61 "moonshot-local-flat-file-store.vala"
450 #line 61 "moonshot-local-flat-file-store.vala"
452 #line 453 "moonshot-local-flat-file-store.c"
455 #line 61 "moonshot-local-flat-file-store.vala"
457 #line 61 "moonshot-local-flat-file-store.vala"
459 #line 460 "moonshot-local-flat-file-store.c"
461 #line 61 "moonshot-local-flat-file-store.vala"
463 #line 61 "moonshot-local-flat-file-store.vala"
464 if (!(i < rules_patterns_length1)) {
465 #line 61 "moonshot-local-flat-file-store.vala"
467 #line 468 "moonshot-local-flat-file-store.c"
469 #line 62 "moonshot-local-flat-file-store.vala"
470 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_);
471 #line 472 "moonshot-local-flat-file-store.c"
475 #line 64 "moonshot-local-flat-file-store.vala"
477 #line 64 "moonshot-local-flat-file-store.vala"
478 id_card_set_rules (id_card, _tmp26_, rules_length1);
479 #line 480 "moonshot-local-flat-file-store.c"
480 rules = (_vala_Rule_array_free (rules, rules_length1), NULL);
482 rules_always_conf = (_vala_array_free (rules_always_conf, rules_always_conf_length1, (GDestroyNotify) g_free), NULL);
483 rules_patterns = (_vala_array_free (rules_patterns, rules_patterns_length1, (GDestroyNotify) g_free), NULL);
485 #line 69 "moonshot-local-flat-file-store.vala"
486 _tmp27_ = g_key_file_get_string (key_file, identity, "CA-Cert", &_inner_error_);
487 #line 488 "moonshot-local-flat-file-store.c"
488 if (_inner_error_ != NULL) {
489 _g_object_unref0 (id_card);
490 goto __catch3_g_error;
492 #line 69 "moonshot-local-flat-file-store.vala"
493 trust_anchor_set_ca_cert (id_card_get_trust_anchor (id_card), _tmp28_ = _tmp27_);
494 #line 495 "moonshot-local-flat-file-store.c"
496 #line 70 "moonshot-local-flat-file-store.vala"
497 _tmp29_ = g_key_file_get_string (key_file, identity, "Subject", &_inner_error_);
498 #line 499 "moonshot-local-flat-file-store.c"
499 if (_inner_error_ != NULL) {
500 _g_object_unref0 (id_card);
501 goto __catch3_g_error;
503 #line 70 "moonshot-local-flat-file-store.vala"
504 trust_anchor_set_subject (id_card_get_trust_anchor (id_card), _tmp30_ = _tmp29_);
505 #line 506 "moonshot-local-flat-file-store.c"
507 #line 71 "moonshot-local-flat-file-store.vala"
508 _tmp31_ = g_key_file_get_string (key_file, identity, "SubjectAlt", &_inner_error_);
509 #line 510 "moonshot-local-flat-file-store.c"
510 if (_inner_error_ != NULL) {
511 _g_object_unref0 (id_card);
512 goto __catch3_g_error;
514 #line 71 "moonshot-local-flat-file-store.vala"
515 trust_anchor_set_subject_alt (id_card_get_trust_anchor (id_card), _tmp32_ = _tmp31_);
516 #line 517 "moonshot-local-flat-file-store.c"
518 #line 72 "moonshot-local-flat-file-store.vala"
519 _tmp33_ = g_key_file_get_string (key_file, identity, "ServerCert", &_inner_error_);
520 #line 521 "moonshot-local-flat-file-store.c"
521 if (_inner_error_ != NULL) {
522 _g_object_unref0 (id_card);
523 goto __catch3_g_error;
525 #line 72 "moonshot-local-flat-file-store.vala"
526 trust_anchor_set_server_cert (id_card_get_trust_anchor (id_card), _tmp34_ = _tmp33_);
527 #line 528 "moonshot-local-flat-file-store.c"
529 #line 74 "moonshot-local-flat-file-store.vala"
530 gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->id_card_list, id_card);
531 #line 532 "moonshot-local-flat-file-store.c"
532 _g_object_unref0 (id_card);
539 _inner_error_ = NULL;
541 #line 77 "moonshot-local-flat-file-store.vala"
542 fprintf (stdout, "Error: %s\n", e->message);
543 #line 544 "moonshot-local-flat-file-store.c"
548 if (_inner_error_ != NULL) {
550 identities_uris = (_vala_array_free (identities_uris, identities_uris_length1, (GDestroyNotify) g_free), NULL);
553 _g_key_file_free0 (key_file);
554 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);
555 g_clear_error (&_inner_error_);
562 identities_uris = (_vala_array_free (identities_uris, identities_uris_length1, (GDestroyNotify) g_free), NULL);
565 _g_key_file_free0 (key_file);
569 #line 82 "moonshot-local-flat-file-store.vala"
570 static char* local_flat_file_store_get_data_dir (LocalFlatFileStore* self) {
571 #line 572 "moonshot-local-flat-file-store.c"
575 #line 82 "moonshot-local-flat-file-store.vala"
576 g_return_val_if_fail (self != NULL, NULL);
577 #line 578 "moonshot-local-flat-file-store.c"
579 #line 84 "moonshot-local-flat-file-store.vala"
580 path = (_tmp0_ = g_build_filename (g_get_user_data_dir (), PACKAGE_TARNAME, NULL), _g_free0 (path), _tmp0_);
581 #line 87 "moonshot-local-flat-file-store.vala"
582 if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
583 #line 88 "moonshot-local-flat-file-store.vala"
584 g_mkdir_with_parents (path, 0700);
585 #line 586 "moonshot-local-flat-file-store.c"
588 #line 90 "moonshot-local-flat-file-store.vala"
590 #line 591 "moonshot-local-flat-file-store.c"
594 static char** _vala_array_dup1 (char** self, int length) {
597 result = g_new0 (char*, length + 1);
598 for (i = 0; i < length; i++) {
599 result[i] = g_strdup (self[i]);
605 #line 93 "moonshot-local-flat-file-store.vala"
606 void local_flat_file_store_store_id_cards (LocalFlatFileStore* self) {
607 #line 608 "moonshot-local-flat-file-store.c"
610 GError * _inner_error_ = NULL;
611 #line 93 "moonshot-local-flat-file-store.vala"
612 g_return_if_fail (self != NULL);
613 #line 94 "moonshot-local-flat-file-store.vala"
614 key_file = g_key_file_new ();
615 #line 616 "moonshot-local-flat-file-store.c"
617 GeeIterator* _id_card_it;
618 #line 95 "moonshot-local-flat-file-store.vala"
619 _id_card_it = gee_abstract_collection_iterator ((GeeAbstractCollection*) self->priv->id_card_list);
620 #line 95 "moonshot-local-flat-file-store.vala"
622 #line 623 "moonshot-local-flat-file-store.c"
624 gint rules_patterns_length1;
625 gint _rules_patterns_size_;
628 char** rules_patterns;
629 gint rules_always_conf_length1;
630 gint _rules_always_conf_size_;
633 char** rules_always_conf;
638 gint _tmp20__length1;
649 #line 95 "moonshot-local-flat-file-store.vala"
650 if (!gee_iterator_next (_id_card_it)) {
651 #line 95 "moonshot-local-flat-file-store.vala"
653 #line 654 "moonshot-local-flat-file-store.c"
655 #line 95 "moonshot-local-flat-file-store.vala"
656 id_card = (IdCard*) gee_iterator_get (_id_card_it);
657 #line 658 "moonshot-local-flat-file-store.c"
658 rules_patterns = (_tmp1_ = g_new0 (char*, _tmp0_ + 1), rules_patterns_length1 = _tmp0_, _rules_patterns_size_ = rules_patterns_length1, _tmp1_);
659 rules_always_conf = (_tmp3_ = g_new0 (char*, _tmp2_ + 1), rules_always_conf_length1 = _tmp2_, _rules_always_conf_size_ = rules_always_conf_length1, _tmp3_);
662 #line 99 "moonshot-local-flat-file-store.vala"
664 #line 665 "moonshot-local-flat-file-store.c"
667 #line 99 "moonshot-local-flat-file-store.vala"
669 #line 99 "moonshot-local-flat-file-store.vala"
671 #line 672 "moonshot-local-flat-file-store.c"
677 #line 99 "moonshot-local-flat-file-store.vala"
679 #line 99 "moonshot-local-flat-file-store.vala"
681 #line 682 "moonshot-local-flat-file-store.c"
683 #line 99 "moonshot-local-flat-file-store.vala"
685 #line 99 "moonshot-local-flat-file-store.vala"
687 #line 99 "moonshot-local-flat-file-store.vala"
689 #line 690 "moonshot-local-flat-file-store.c"
691 #line 100 "moonshot-local-flat-file-store.vala"
692 rules_patterns[i] = (_tmp7_ = g_strdup (id_card_get_rules (id_card, &_tmp6_)[i].pattern), _g_free0 (rules_patterns[i]), _tmp7_);
693 #line 101 "moonshot-local-flat-file-store.vala"
694 rules_always_conf[i] = (_tmp9_ = g_strdup (id_card_get_rules (id_card, &_tmp8_)[i].always_confirm), _g_free0 (rules_always_conf[i]), _tmp9_);
695 #line 696 "moonshot-local-flat-file-store.c"
699 #line 104 "moonshot-local-flat-file-store.vala"
700 _tmp10_ = g_strdup (id_card_get_issuer (id_card));
701 #line 104 "moonshot-local-flat-file-store.vala"
702 if (_tmp10_ == NULL) {
703 #line 704 "moonshot-local-flat-file-store.c"
705 #line 104 "moonshot-local-flat-file-store.vala"
706 _tmp10_ = (_tmp11_ = g_strdup (""), _g_free0 (_tmp10_), _tmp11_);
707 #line 708 "moonshot-local-flat-file-store.c"
709 #line 104 "moonshot-local-flat-file-store.vala"
710 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "Issuer", _tmp10_);
711 #line 105 "moonshot-local-flat-file-store.vala"
712 _tmp12_ = g_strdup (id_card_get_display_name (id_card));
713 #line 105 "moonshot-local-flat-file-store.vala"
714 if (_tmp12_ == NULL) {
715 #line 716 "moonshot-local-flat-file-store.c"
717 #line 105 "moonshot-local-flat-file-store.vala"
718 _tmp12_ = (_tmp13_ = g_strdup (""), _g_free0 (_tmp12_), _tmp13_);
719 #line 720 "moonshot-local-flat-file-store.c"
721 #line 105 "moonshot-local-flat-file-store.vala"
722 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "DisplayName", _tmp12_);
723 #line 106 "moonshot-local-flat-file-store.vala"
724 _tmp14_ = g_strdup (id_card_get_username (id_card));
725 #line 106 "moonshot-local-flat-file-store.vala"
726 if (_tmp14_ == NULL) {
727 #line 728 "moonshot-local-flat-file-store.c"
729 #line 106 "moonshot-local-flat-file-store.vala"
730 _tmp14_ = (_tmp15_ = g_strdup (""), _g_free0 (_tmp14_), _tmp15_);
731 #line 732 "moonshot-local-flat-file-store.c"
733 #line 106 "moonshot-local-flat-file-store.vala"
734 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "Username", _tmp14_);
735 #line 107 "moonshot-local-flat-file-store.vala"
736 _tmp16_ = g_strdup (id_card_get_password (id_card));
737 #line 107 "moonshot-local-flat-file-store.vala"
738 if (_tmp16_ == NULL) {
739 #line 740 "moonshot-local-flat-file-store.c"
741 #line 107 "moonshot-local-flat-file-store.vala"
742 _tmp16_ = (_tmp17_ = g_strdup (""), _g_free0 (_tmp16_), _tmp17_);
743 #line 744 "moonshot-local-flat-file-store.c"
745 #line 107 "moonshot-local-flat-file-store.vala"
746 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "Password", _tmp16_);
747 #line 748 "moonshot-local-flat-file-store.c"
748 _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_);
749 #line 108 "moonshot-local-flat-file-store.vala"
750 if (_tmp20_ == NULL) {
751 #line 752 "moonshot-local-flat-file-store.c"
752 char** _tmp22_ = NULL;
754 #line 108 "moonshot-local-flat-file-store.vala"
755 _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_);
756 #line 757 "moonshot-local-flat-file-store.c"
758 #line 108 "moonshot-local-flat-file-store.vala"
759 g_key_file_set_string_list (key_file, id_card_get_display_name (id_card), "Services", (const gchar* const*) _tmp20_, _tmp20__length1);
760 #line 110 "moonshot-local-flat-file-store.vala"
762 #line 111 "moonshot-local-flat-file-store.vala"
763 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);
764 #line 112 "moonshot-local-flat-file-store.vala"
765 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);
766 #line 767 "moonshot-local-flat-file-store.c"
768 #line 116 "moonshot-local-flat-file-store.vala"
769 _tmp25_ = g_strdup (trust_anchor_get_ca_cert (id_card_get_trust_anchor (id_card)));
770 #line 116 "moonshot-local-flat-file-store.vala"
771 if (_tmp25_ == NULL) {
772 #line 773 "moonshot-local-flat-file-store.c"
774 #line 116 "moonshot-local-flat-file-store.vala"
775 _tmp25_ = (_tmp26_ = g_strdup (""), _g_free0 (_tmp25_), _tmp26_);
776 #line 777 "moonshot-local-flat-file-store.c"
778 #line 116 "moonshot-local-flat-file-store.vala"
779 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "CA-Cert", _tmp25_);
780 #line 117 "moonshot-local-flat-file-store.vala"
781 _tmp27_ = g_strdup (trust_anchor_get_subject (id_card_get_trust_anchor (id_card)));
782 #line 117 "moonshot-local-flat-file-store.vala"
783 if (_tmp27_ == NULL) {
784 #line 785 "moonshot-local-flat-file-store.c"
786 #line 117 "moonshot-local-flat-file-store.vala"
787 _tmp27_ = (_tmp28_ = g_strdup (""), _g_free0 (_tmp27_), _tmp28_);
788 #line 789 "moonshot-local-flat-file-store.c"
790 #line 117 "moonshot-local-flat-file-store.vala"
791 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "Subject", _tmp27_);
792 #line 118 "moonshot-local-flat-file-store.vala"
793 _tmp29_ = g_strdup (trust_anchor_get_subject_alt (id_card_get_trust_anchor (id_card)));
794 #line 118 "moonshot-local-flat-file-store.vala"
795 if (_tmp29_ == NULL) {
796 #line 797 "moonshot-local-flat-file-store.c"
798 #line 118 "moonshot-local-flat-file-store.vala"
799 _tmp29_ = (_tmp30_ = g_strdup (""), _g_free0 (_tmp29_), _tmp30_);
800 #line 801 "moonshot-local-flat-file-store.c"
802 #line 118 "moonshot-local-flat-file-store.vala"
803 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "SubjectAlt", _tmp29_);
804 #line 119 "moonshot-local-flat-file-store.vala"
805 _tmp31_ = g_strdup (trust_anchor_get_server_cert (id_card_get_trust_anchor (id_card)));
806 #line 119 "moonshot-local-flat-file-store.vala"
807 if (_tmp31_ == NULL) {
808 #line 809 "moonshot-local-flat-file-store.c"
810 #line 119 "moonshot-local-flat-file-store.vala"
811 _tmp31_ = (_tmp32_ = g_strdup (""), _g_free0 (_tmp31_), _tmp32_);
812 #line 813 "moonshot-local-flat-file-store.c"
814 #line 119 "moonshot-local-flat-file-store.vala"
815 g_key_file_set_string (key_file, id_card_get_display_name (id_card), "ServerCert", _tmp31_);
816 #line 817 "moonshot-local-flat-file-store.c"
821 _tmp20_ = (_vala_array_free (_tmp20_, _tmp20__length1, (GDestroyNotify) g_free), NULL);
826 rules_always_conf = (_vala_array_free (rules_always_conf, rules_always_conf_length1, (GDestroyNotify) g_free), NULL);
827 rules_patterns = (_vala_array_free (rules_patterns, rules_patterns_length1, (GDestroyNotify) g_free), NULL);
828 _g_object_unref0 (id_card);
830 _g_object_unref0 (_id_card_it);
832 #line 122 "moonshot-local-flat-file-store.vala"
833 text = g_key_file_to_data (key_file, NULL, NULL);
834 #line 835 "moonshot-local-flat-file-store.c"
838 #line 125 "moonshot-local-flat-file-store.vala"
839 path = local_flat_file_store_get_data_dir (self);
840 #line 126 "moonshot-local-flat-file-store.vala"
841 filename = g_build_filename (path, LOCAL_FLAT_FILE_STORE_FILE_NAME, NULL);
842 #line 127 "moonshot-local-flat-file-store.vala"
843 g_file_set_contents (filename, text, (gssize) (-1), &_inner_error_);
844 #line 845 "moonshot-local-flat-file-store.c"
845 if (_inner_error_ != NULL) {
848 goto __catch4_g_error;
858 _inner_error_ = NULL;
860 #line 130 "moonshot-local-flat-file-store.vala"
861 fprintf (stdout, "Error: %s\n", e->message);
862 #line 863 "moonshot-local-flat-file-store.c"
867 if (_inner_error_ != NULL) {
869 _g_key_file_free0 (key_file);
870 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);
871 g_clear_error (&_inner_error_);
874 #line 133 "moonshot-local-flat-file-store.vala"
875 local_flat_file_store_load_id_cards (self);
876 #line 877 "moonshot-local-flat-file-store.c"
878 _g_key_file_free0 (key_file);
882 #line 136 "moonshot-local-flat-file-store.vala"
883 LocalFlatFileStore* local_flat_file_store_construct (GType object_type) {
884 #line 885 "moonshot-local-flat-file-store.c"
885 LocalFlatFileStore * self = NULL;
886 GeeLinkedList* _tmp0_;
887 #line 136 "moonshot-local-flat-file-store.vala"
888 self = (LocalFlatFileStore*) g_object_new (object_type, NULL);
889 #line 137 "moonshot-local-flat-file-store.vala"
890 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_);
891 #line 138 "moonshot-local-flat-file-store.vala"
892 local_flat_file_store_load_id_cards (self);
893 #line 894 "moonshot-local-flat-file-store.c"
898 #line 136 "moonshot-local-flat-file-store.vala"
899 LocalFlatFileStore* local_flat_file_store_new (void) {
900 #line 136 "moonshot-local-flat-file-store.vala"
901 return local_flat_file_store_construct (TYPE_LOCAL_FLAT_FILE_STORE);
902 #line 903 "moonshot-local-flat-file-store.c"
906 static void local_flat_file_store_class_init (LocalFlatFileStoreClass * klass) {
907 local_flat_file_store_parent_class = g_type_class_peek_parent (klass);
908 g_type_class_add_private (klass, sizeof (LocalFlatFileStorePrivate));
909 G_OBJECT_CLASS (klass)->finalize = local_flat_file_store_finalize;
913 static void local_flat_file_store_iidentity_card_store_interface_init (IIdentityCardStoreIface * iface) {
914 local_flat_file_store_iidentity_card_store_parent_iface = g_type_interface_peek_parent (iface);
915 iface->add_card = local_flat_file_store_real_add_card;
916 iface->update_card = local_flat_file_store_real_update_card;
917 iface->remove_card = local_flat_file_store_real_remove_card;
918 iface->get_card_list = local_flat_file_store_real_get_card_list;
922 static void local_flat_file_store_instance_init (LocalFlatFileStore * self) {
923 self->priv = LOCAL_FLAT_FILE_STORE_GET_PRIVATE (self);
927 static void local_flat_file_store_finalize (GObject* obj) {
928 LocalFlatFileStore * self;
929 self = LOCAL_FLAT_FILE_STORE (obj);
930 _g_object_unref0 (self->priv->id_card_list);
931 G_OBJECT_CLASS (local_flat_file_store_parent_class)->finalize (obj);
935 GType local_flat_file_store_get_type (void) {
936 static volatile gsize local_flat_file_store_type_id__volatile = 0;
937 if (g_once_init_enter (&local_flat_file_store_type_id__volatile)) {
938 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 };
939 static const GInterfaceInfo iidentity_card_store_info = { (GInterfaceInitFunc) local_flat_file_store_iidentity_card_store_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
940 GType local_flat_file_store_type_id;
941 local_flat_file_store_type_id = g_type_register_static (G_TYPE_OBJECT, "LocalFlatFileStore", &g_define_type_info, 0);
942 g_type_add_interface_static (local_flat_file_store_type_id, TYPE_IIDENTITY_CARD_STORE, &iidentity_card_store_info);
943 g_once_init_leave (&local_flat_file_store_type_id__volatile, local_flat_file_store_type_id);
945 return local_flat_file_store_type_id__volatile;
949 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
950 if ((array != NULL) && (destroy_func != NULL)) {
952 for (i = 0; i < array_length; i = i + 1) {
953 if (((gpointer*) array)[i] != NULL) {
954 destroy_func (((gpointer*) array)[i]);
961 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
962 _vala_array_destroy (array, array_length, destroy_func);