From 4b0fce19c0928ff33d81b40ffd63a1f37c33bb87 Mon Sep 17 00:00:00 2001 From: Pete Fotheringham Date: Tue, 17 Jan 2012 15:21:40 +0000 Subject: [PATCH] File open association works, but crashes if you choose not to import the card --- Makefile.am | 2 + mac/moonshot-ui.bundle | 6 +- mac/moonshot-ui.plist | 18 +-- src/moonshot-identity-manager-app.vala | 1 + src/moonshot-server.vala | 44 ++++++ src/moonshot-webp-parser.vala | 235 --------------------------------- vapi/gtk-mac-integration.vapi | 6 +- 7 files changed, 62 insertions(+), 250 deletions(-) diff --git a/Makefile.am b/Makefile.am index c9a64a1..d90b7b1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,10 +47,12 @@ src_moonshot_SOURCES = \ src/moonshot-identity-request.vala \ src/moonshot-server.vala \ src/moonshot-password-dialog.vala \ + src/moonshot-provisioning-common.vala \ src/moonshot-utils.vala src_moonshot_webp_SOURCES = \ src/moonshot-webp-parser.vala \ + src/moonshot-provisioning-common.vala \ src/moonshot-id.vala src_moonshot_VALAFLAGS = --pkg gdk-2.0 --pkg gtk+-2.0 --pkg gee-1.0 $(AM_VALAFLAGS) diff --git a/mac/moonshot-ui.bundle b/mac/moonshot-ui.bundle index ae0b2e7..923dd91 100644 --- a/mac/moonshot-ui.bundle +++ b/mac/moonshot-ui.bundle @@ -26,7 +26,7 @@ - + ${project}/launcher.sh - - gtk+-2.0 diff --git a/mac/moonshot-ui.plist b/mac/moonshot-ui.plist index 516af0a..40b27da 100644 --- a/mac/moonshot-ui.plist +++ b/mac/moonshot-ui.plist @@ -7,23 +7,23 @@ CFBundleExecutable moonshot-ui CFBundleGetInfoString - 0.3, Copyright 2006-2007 Imendio AB + Copyright (c) 2011, JANET(UK) CFBundleIconFile - Giggle.icns + moonshot-ui.icns CFBundleIdentifier - com.imendio.Giggle + net.ja.moonshot-ui CFBundleInfoDictionaryVersion - 6.0 + 0.1 CFBundlePackageType APPL CFBundleShortVersionString - 0.3 + 0.1 CFBundleSignature ???? CFBundleVersion - 0.3 + 0.1 NSHumanReadableCopyright - Copyright 2006-2007 Imendio AB, GNU General Public License. + Copyright (c) 2011, JANET(UK) LSMinimumSystemVersion 10.4 CFBundleDisplayName @@ -40,13 +40,13 @@ msht msht - CFBundleTypeRole - Editor CFBundleTypeMIMETypes application/msht application/msht + CFBundleTypeRole + Editor diff --git a/src/moonshot-identity-manager-app.vala b/src/moonshot-identity-manager-app.vala index 13b17a7..db0b08e 100644 --- a/src/moonshot-identity-manager-app.vala +++ b/src/moonshot-identity-manager-app.vala @@ -19,6 +19,7 @@ class IdentityManagerApp : Window { init_ipc_server (); #if OS_MACOS osxApp = OSXApplication.get_instance(); + osxApp.ns_application_open_file.connect(ipc_server.install_from_file); #endif view.show(); } diff --git a/src/moonshot-server.vala b/src/moonshot-server.vala index abae433..681d0dd 100644 --- a/src/moonshot-server.vala +++ b/src/moonshot-server.vala @@ -150,8 +150,50 @@ public class MoonshotServer : Object { return this.main_window.add_identity (idcard); } + + + public bool install_from_file (string file_name) + { + var webp = new WebProvisioning.Parser (file_name); + webp.parse(); + bool result = false; + + foreach (IdCard card in WebProvisioning.cards) + { + string[] rules_patterns = {}; + string[] rules_always_confirm = {}; + + if (card.rules.length > 0) + { + int i = 0; + rules_patterns = new string[card.rules.length]; + rules_always_confirm = new string[card.rules.length]; + foreach (Rule r in card.rules) + { + rules_patterns[i] = r.pattern; + rules_always_confirm[i] = r.always_confirm; + i++; + } + } + result = install_id_card (card.display_name, + card.username, + card.password, + card.issuer, + rules_patterns, + rules_always_confirm, + card.services, + card.trust_anchor.ca_cert, + card.trust_anchor.subject, + card.trust_anchor.subject_alt, + card.trust_anchor.server_cert); + } + + return true; + } + } + #elif IPC_MSRPC using Rpc; @@ -371,6 +413,8 @@ public class MoonshotServer : Object { return success; } + } + #endif diff --git a/src/moonshot-webp-parser.vala b/src/moonshot-webp-parser.vala index 94b8e52..5d9775f 100644 --- a/src/moonshot-webp-parser.vala +++ b/src/moonshot-webp-parser.vala @@ -2,242 +2,7 @@ using Moonshot; namespace WebProvisioning { - IdCard card; - IdCard[] cards; - bool - check_stack (SList stack, string[] reference) - { - if (stack.length () < reference.length) - return false; - - for (int i = 0; i stack) - { - string[] always_confirm_path = {"always-confirm", "rule", "selection-rules", "identity", "identities"}; - - return check_stack (stack, always_confirm_path); - } - - bool - pattern_handler (SList stack) - { - string[] pattern_path = {"pattern", "rule", "selection-rules", "identity", "identities"}; - - return check_stack (stack, pattern_path); - } - - bool - server_cert_handler (SList stack) - { - string[] server_cert_path = {"server-cert", "trust-anchor", "identity", "identities"}; - - return check_stack (stack, server_cert_path); - } - - bool - subject_alt_handler (SList stack) - { - string[] subject_alt_path = {"subject-alt", "trust-anchor", "identity", "identities"}; - - return check_stack (stack, subject_alt_path); - } - - bool - subject_handler (SList stack) - { - string[] subject_path = {"subject", "trust-anchor", "identity", "identities"}; - - return check_stack (stack, subject_path); - } - - bool - ca_cert_handler (SList stack) - { - string[] ca_path = {"ca-cert", "trust-anchor", "identity", "identities"}; - - return check_stack (stack, ca_path); - } - - bool - realm_handler (SList stack) - { - string[] realm_path = {"realm", "identity", "identities"}; - - return check_stack (stack, realm_path); - } - - bool - password_handler (SList stack) - { - string[] password_path = {"password", "identity", "identities"}; - - return check_stack (stack, password_path); - } - - bool - user_handler (SList stack) - { - string[] user_path = {"user", "identity", "identities"}; - - return check_stack (stack, user_path); - } - - bool - display_name_handler (SList stack) - { - string[] display_name_path = {"display-name", "identity", "identities"}; - - return check_stack (stack, display_name_path); - } - - public void - start_element_func (MarkupParseContext context, - string element_name, - string[] attribute_names, - string[] attribute_values) throws MarkupError - { - if (element_name == "identity") - { - IdCard[] tmp_cards = cards; - - cards = new IdCard[tmp_cards.length + 1]; - for (int i=0; i stack = context.get_element_stack (); - - if (text_len < 1) - return; - - if (stack.nth_data(0) == "display-name" && display_name_handler (stack)) - { - card.display_name = text; - } - else if (stack.nth_data(0) == "user" && user_handler (stack)) - { - card.username = text; - } - else if (stack.nth_data(0) == "password" && password_handler (stack)) - { - card.password = text; - } - else if (stack.nth_data(0) == "realm" && realm_handler (stack)) - { - card.issuer = text; - } - else if (stack.nth_data(0) == "service") - { - string[] services = card.services; - card.services = new string[services.length + 1]; - for (int i = 0; i