Crash happens if a dialog is displayed in the signal_handler function. This seems toi be a bug in the gtk-mac-integration whihc will be raised with the authors. For now, on Mac we will installe the cards without confirmation
public bool add_identity (IdCard id_card)
{
- /* TODO: Check if display name already exists */
+#if OS_MACOS
+ /*
+ * TODO: We should have a confirmation dialog, but currently it will crash on Mac OS
+ * so for now we will install silently
+ */
+ var ret = Gtk.ResponseType.YES;
+#else
+ public OSXApplication osxApp;
var dialog = new Gtk.MessageDialog (this,
Gtk.DialogFlags.DESTROY_WITH_PARENT,
_("Would you like to add '%s' ID Card to the ID Card Organizer?"),
id_card.display_name);
- dialog.show_all ();
var ret = dialog.run ();
- dialog.hide ();
+ dialog.destroy ();
+#endif
if (ret == Gtk.ResponseType.YES) {
id_card.set_data ("pixbuf", find_icon ("avatar-default", 48));
{
var id_card = id_card_widget.id_card;
- var dialog = new MessageDialog (null,
+ var dialog = new MessageDialog (this,
DialogFlags.DESTROY_WITH_PARENT,
MessageType.QUESTION,
Gtk.ButtonsType.YES_NO,
public IdentityManagerModel model;
private IdentityManagerView view;
private MoonshotServer ipc_server;
+
#if OS_MACOS
public OSXApplication osxApp;
- public bool on_osx_open_files (string file_name ) {
- print ("on_osx_open_files() file_name = %s\n", file_name);
- return ipc_server.install_from_file(file_name);
+
+ // the signal handler function.
+ // the current instance of our app class is passed in the
+ // id_manager_app_instanceparameter
+ public static bool on_osx_open_files (OSXApplication osx_app_instance,
+ string file_name,
+ IdentityManagerApp id_manager_app_instance ) {
+ int added_cards = id_manager_app_instance.ipc_server.install_from_file(file_name);
+ return true;
}
#endif
+
private const int WINDOW_WIDTH = 400;
private const int WINDOW_HEIGHT = 500;
public void show() {
model = new IdentityManagerModel(this);
view = new IdentityManagerView(this);
init_ipc_server ();
+
#if OS_MACOS
- osxApp = OSXApplication.get_instance();
-// This wont work with Vala 0.12
-// osxApp.ns_application_open_file.connect(ipc_server.install_from_file);
-// so we have to use this old way
- Signal.connect(osxApp, "NSApplicationOpenFile", (GLib.Callback)(on_osx_open_files), ipc_server);
-// Signal.connect_data(osxApp, "NSApplicationOpenFile", (GLib.Callback)(ipc_server.install_from_file), ipc_server, null, 0);
+
+ osxApp = OSXApplication.get_instance();
+ // The 'correct' way of connrcting wont work in Mac OS with Vala 0.12 e.g.
+ // osxApp.ns_application_open_file.connect(install_from_file);
+ // so we have to use this old way
+ Signal.connect(osxApp, "NSApplicationOpenFile", (GLib.Callback)(on_osx_open_files), this);
#endif
view.show();
[DBus (name = "org.janet.Moonshot")]
public class MoonshotServer : Object {
- private static IdentityManagerView main_window;
+ private IdentityManagerView main_window;
public MoonshotServer (Gtk.Window window)
{
}
- 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;
+ }
}