[DBus (name = "org.janet.Moonshot")]
public class MoonshotServer : Object {
- private IdentityManagerView main_window;
+ private IdentityManagerApp parent_app;
- public MoonshotServer (Gtk.Window window)
+ public MoonshotServer (IdentityManagerApp app)
{
- this.main_window = (IdentityManagerView) window;
+ this.parent_app = app;
+ }
+
+ public bool show_ui()
+ {
+ if (parent_app.view == null) {
+ return false;
+ }
+ parent_app.show();
+ parent_app.explicitly_launched = true;
+ return true;
}
public async bool get_identity (string nai,
out string subject_name_constraint,
out string subject_alt_name_constraint)
{
- var request = new IdentityRequest (main_window,
+ var request = new IdentityRequest (parent_app,
nai,
password,
service);
var id_card = request.id_card;
- if (id_card != null) {
+ if ((id_card != null) && (id_card.display_name != IdCard.NO_IDENTITY)) {
nai_out = id_card.nai;
password_out = id_card.password;
out string subject_name_constraint,
out string subject_alt_name_constraint)
{
- var request = new IdentityRequest.default (main_window);
+ var request = new IdentityRequest.default (parent_app);
request.set_callback ((IdentityRequest) => get_default_identity.callback());
request.execute ();
yield;
public bool install_id_card (string display_name,
string user_name,
- string password,
- string realm,
- string[] rules_patterns,
- string[] rules_always_confirm,
- string[] services,
- string ca_cert,
- string subject,
- string subject_alt,
- string server_cert)
+ string ?password,
+ string ?realm,
+ string[] ?rules_patterns,
+ string[] ?rules_always_confirm,
+ string[] ?services,
+ string ?ca_cert,
+ string ?subject,
+ string ?subject_alt,
+ string ?server_cert)
{
IdCard idcard = new IdCard ();
}
}
- return this.main_window.add_identity (idcard);
+ return parent_app.add_identity (idcard);
}
- public bool install_from_file (string file_name)
+ public int install_from_file (string file_name)
{
var webp = new WebProvisioning.Parser (file_name);
+
webp.parse();
bool result = false;
-
+ int installed_cards = 0;
foreach (IdCard card in WebProvisioning.cards)
{
string[] rules_patterns = {};
i++;
}
}
+
result = install_id_card (card.display_name,
card.username,
card.password,
card.trust_anchor.subject,
card.trust_anchor.subject_alt,
card.trust_anchor.server_cert);
- }
-
- return true;
+ if (result) {
+ installed_cards++;
+ }
}
-
+ return installed_cards;
+ }
}
var id_card = request.id_card;
- if (id_card == null) {
+ if (id_card != null) {
// The strings are freed by the RPC runtime
nai_out = id_card.nai;
password_out = id_card.password;