[DBus (name = "org.janet.Moonshot")]
public class MoonshotServer : Object {
- private static IdentityManagerView main_window;
+ private IdentityManagerApp parent_app;
+
+ public MoonshotServer (IdentityManagerApp app)
+ {
+ this.parent_app = app;
+ }
- public MoonshotServer (Gtk.Window window)
+ public bool show_ui()
{
- this.main_window = (IdentityManagerView) window;
+ 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;
}
}
- return 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);
- print ("install_from_file() file_name = %s", 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);
- }
-
-print ("install_from_file() result %s\n", result.to_string());
- return result;
+ 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;