+
+ if (!card.store_password)
+ password_table.CachePassword(card, store);
+ else
+ password_table.RemovePassword(card, store);
+ retval = store.update_card(card);
+ card_list_changed();
+ return retval;
+ }
+
+ private bool remove_card_internal(IdCard card) {
+ if (card.temporary)
+ return false;
+ password_table.RemovePassword(card, store);
+ return store.remove_card(card);
+ }
+
+ public bool remove_card(IdCard card) {
+ if (remove_card_internal(card)) {
+ logger.trace(@"remove_card: Removed '$(card.display_name)'");
+ card_list_changed();
+ return true;
+ }
+ logger.warn(@"remove_card: Couldn't remove '$(card.display_name)'");
+ return false;
+ }
+
+ // The name is misleading: This not only sets the store type,
+ // it also creates a new store instance, which loads the card data.
+ public void set_store_type(IIdentityCardStore.StoreType type) {
+ if ((store != null) && (store.get_store_type() == type))
+ return;
+ switch (type) {
+ #if GNOME_KEYRING
+ case IIdentityCardStore.StoreType.KEYRING:
+ store = new KeyringStore();
+ break;
+ #endif
+ case IIdentityCardStore.StoreType.FLAT_FILE:
+ default:
+ store = new LocalFlatFileStore();
+ break;
+ }
+
+ // Loop through the loaded IDs. If any trust anchors are old enough that we didn't record
+ // the datetime_added, add it now.
+ string before_now = _("Before ") + TrustAnchor.format_datetime_now();
+ bool save_needed = false;
+ foreach (IdCard id in this.store.get_card_list()) {
+ if (!id.trust_anchor.is_empty() && id.trust_anchor.datetime_added == "") {
+ logger.trace("set_store_type : Set ta_datetime_added for old trust anchor on '%s' to '%s'".printf(id.display_name, before_now));
+ id.trust_anchor.set_datetime_added(before_now);
+ save_needed = true;
+ }
+ }
+ if (save_needed) {
+ this.store.store_id_cards();
+ }
+ }
+
+ public IIdentityCardStore.StoreType get_store_type() {
+ return store.get_store_type();
+ }
+
+ public bool HasNonTrivialIdentities() {
+ foreach (IdCard card in this.store.get_card_list()) {
+ // The 'NoIdentity' card is non-trivial if it has services or rules.
+ // All other cards are automatically non-trivial.
+ if ((!card.is_no_identity()) ||
+ (card.services.size > 0) ||
+ (card.rules.length > 0)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ private IdentityManagerApp parent;