'-f' is the switch. Fixed usage statement.
const char *subject,
const char *subject_alt,
const char *server_cert,
+ int force_flat_file_store,
MoonshotError **error)
{
GError *g_error = NULL;
G_TYPE_STRING, subject,
G_TYPE_STRING, subject_alt,
G_TYPE_STRING, server_cert,
+ G_TYPE_INT, force_flat_file_store,
G_TYPE_INVALID,
G_TYPE_BOOLEAN, &success,
G_TYPE_INVALID);
const char *subject,
const char *subject_alt,
const char *server_cert,
+ int force_flat_file_store,
MoonshotError **error);
#endif
string? subject,
string? subject_alt,
string? server_cert,
+ int force_flat_file_store,
out Moonshot.Error error);
}
return true;
}
- public void add_card(IdCard card) {
+ public void add_card(IdCard card, bool force_flat_file_store) {
string candidate;
+ IIdentityCardStore.StoreType saved_store_type = get_store_type();
+
+ if (force_flat_file_store)
+ set_store_type(IIdentityCardStore.StoreType.FLAT_FILE);
if (!display_name_is_valid (card.display_name, out candidate))
{
}
store.add_card(card);
+ set_store_type(saved_store_type);
card_list_changed();
}
id_card_widget.expanded.connect (fill_details);
}
- public bool add_identity (IdCard id_card)
+ public bool add_identity (IdCard id_card, bool force_flat_file_store)
{
#if OS_MACOS
/*
if (ret == Gtk.ResponseType.YES) {
id_card.set_data ("pixbuf", find_icon ("avatar-default", 48));
- this.identities_manager.add_card (id_card);
+ this.identities_manager.add_card (id_card, force_flat_file_store);
return true;
}
switch (result) {
case ResponseType.OK:
- this.identities_manager.add_card (get_id_card_data (dialog));
+ this.identities_manager.add_card (get_id_card_data (dialog), false);
break;
default:
break;
#endif
}
- public bool add_identity (IdCard id) {
- if (view != null) return view.add_identity(id);
- model.add_card(id);
+ public bool add_identity (IdCard id, bool force_flat_file_store) {
+ if (view != null) return view.add_identity(id, force_flat_file_store);
+ model.add_card(id, force_flat_file_store);
return true;
}
string ?ca_cert,
string ?subject,
string ?subject_alt,
- string ?server_cert)
+ string ?server_cert,
+ int force_flat_file_store)
{
IdCard idcard = new IdCard ();
}
}
- return parent_app.add_identity (idcard);
+ return parent_app.add_identity (idcard, force_flat_file_store!=0);
}
card.trust_anchor.ca_cert,
card.trust_anchor.subject,
card.trust_anchor.subject_alt,
- card.trust_anchor.server_cert);
+ card.trust_anchor.server_cert,
+ 0);
if (result) {
installed_cards++;
}
string ca_cert,
string subject,
string subject_alt,
- string server_cert)
+ string server_cert,
+ bool force_flat_file_store)
{
IdCard idcard = new IdCard ();
bool success = false;
// Defer addition to the main loop thread.
Idle.add (() => {
mutex.lock ();
- success = parent_app.add_identity (idcard);
+ success = parent_app.add_identity (idcard, force_flat_file_store);
cond.signal ();
mutex.unlock ();
return false;
public static int main (string[] args)
{
- if (args.length < 2)
+ int arg_index = -1;
+ int force_flat_file_store = 0;
+ bool bad_switch = false;
+ for (arg_index = 1; arg_index < args.length; arg_index++) {
+ int index = 0;
+ unichar c = 0;
+ string arg = args[arg_index];
+ if (arg.get_next_char(ref index, out c)) {
+ if ((c=='-') && arg.get_next_char(ref index, out c)) {
+ switch (c) {
+ case 'f':
+ force_flat_file_store = 1;
+ break;
+ default:
+ bad_switch = true;
+ break;
+ }
+ } else
+ break; // arg is not a switch; presume it's the file
+ }
+ }
+ if (bad_switch || (arg_index != args.length - 1))
{
- error ("Usage %s [-a] WEB_PROVISIONING_FILE", args[0]);
+ error ("Usage %s [-f] WEB_PROVISIONING_FILE\n -f: add identities to flat file store", args[0]);
}
+ string webp_file = args[arg_index];
- if (!FileUtils.test (args[1], FileTest.EXISTS | FileTest.IS_REGULAR))
+ if (!FileUtils.test (webp_file, FileTest.EXISTS | FileTest.IS_REGULAR))
{
- error ("%s does not exist", args[1]);
+ error ("%s does not exist", webp_file);
}
- var webp = new Parser (args[1]);
+ var webp = new Parser (webp_file);
webp.parse();
foreach (IdCard card in cards)
card.trust_anchor.subject,
card.trust_anchor.subject_alt,
card.trust_anchor.server_cert,
+ force_flat_file_store,
out error);
if (error != null)