X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=libmoonshot%2Flibmoonshot-dbus.c;fp=libmoonshot%2Flibmoonshot-dbus.c;h=52d1b0e91e7acd7db11e2a898047d287c94c6bd3;hb=9129fbbed8cebdb35c59b0b0c576385e353e9d0d;hp=84f89752c051a461b4bfff7cec3aaea90aca00e9;hpb=66d9bc4540066d6938ac947b19e718427d6900b9;p=moonshot-ui.git diff --git a/libmoonshot/libmoonshot-dbus.c b/libmoonshot/libmoonshot-dbus.c index 84f8975..52d1b0e 100644 --- a/libmoonshot/libmoonshot-dbus.c +++ b/libmoonshot/libmoonshot-dbus.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -435,6 +436,9 @@ int moonshot_install_id_card (const char *display_name, G_TYPE_INVALID); g_object_unref (dbus_proxy); + g_free(rules_patterns_strv); + g_free(rules_always_confirm_strv); + g_free(services_strv); if (g_error != NULL) { *error = moonshot_error_new (MOONSHOT_ERROR_IPC_ERROR, @@ -444,3 +448,53 @@ int moonshot_install_id_card (const char *display_name, return success; } + +int moonshot_confirm_ca_certificate (const char *identity_name, + const char *realm, + const unsigned char *ca_hash, + int hash_len, + MoonshotError **error) +{ + GError *g_error = NULL; + int success = 99; + int confirmed = 99; + char hash_str[65]; + DBusGProxy *dbus_proxy = get_dbus_proxy (error); + int out = 0; + int i; + + if (*error != NULL) { + return FALSE; + } + + g_return_val_if_fail (DBUS_IS_G_PROXY (dbus_proxy), FALSE); + + /* Convert hash byte array to string */ + out = 0; + for (i = 0; i < hash_len; i++) { + sprintf(&(hash_str[out]), "%02X", ca_hash[i]); + out += 2; + } + + dbus_g_proxy_call_with_timeout (dbus_proxy, + "ConfirmCaCertificate", + INFINITE_TIMEOUT, + &g_error, + G_TYPE_STRING, identity_name, + G_TYPE_STRING, realm, + G_TYPE_STRING, hash_str, + G_TYPE_INVALID, + G_TYPE_INT, &confirmed, + G_TYPE_BOOLEAN, &success, + G_TYPE_INVALID); + + g_object_unref (dbus_proxy); + + if (g_error != NULL) { + *error = moonshot_error_new (MOONSHOT_ERROR_IPC_ERROR, + g_error->message); + return FALSE; + } + + return (int) confirmed; +}