summaryrefslogtreecommitdiff
path: root/src/tspi/gtk/main.c
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2012-11-25 14:36:20 +0000
committerIgor Pashev <pashev.igor@gmail.com>2012-11-25 14:36:20 +0000
commitc3649a2def02c41d837ae1f79dda729ccb91e677 (patch)
treebea46dff212fdef977fe9094a70a939e8cc21885 /src/tspi/gtk/main.c
downloadtrousers-upstream.tar.gz
Imported Upstream version 0.3.9upstream/0.3.9upstream
Diffstat (limited to 'src/tspi/gtk/main.c')
-rw-r--r--src/tspi/gtk/main.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/tspi/gtk/main.c b/src/tspi/gtk/main.c
new file mode 100644
index 0000000..3b76402
--- /dev/null
+++ b/src/tspi/gtk/main.c
@@ -0,0 +1,117 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+/*
+ * Initial main.c file generated by Glade. Edit as required.
+ * Glade will not overwrite this file.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <string.h>
+
+#include <gtk/gtk.h>
+
+#undef TRUE
+#undef FALSE
+
+#include "trousers/tss.h"
+#include "tsplog.h"
+
+#include "interface.h"
+#include "support.h"
+
+/*
+ * DisplayPINWindow()
+ *
+ * Popup the dialog to collect an existing password.
+ *
+ * string - buffer that the password will be passed back to caller in
+ * popup - UTF-8 string to be displayed in the title bar of the dialog box
+ *
+ */
+TSS_RESULT
+DisplayPINWindow(BYTE *string, UINT32 *string_len, BYTE *popup)
+{
+ GtkWidget *dialog1;
+ struct userdata ud;
+
+ ud.string_len = 0;
+
+#ifdef ENABLE_NLS
+ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+#endif
+
+ gtk_set_locale();
+ gtk_init_check((int *)NULL, (char ***)NULL);
+
+ LogDebug("address of string_len: %p", &ud.string_len);
+ dialog1 = create_password_dialog(&ud, (char *)popup);
+ gtk_widget_show(dialog1);
+
+ gtk_main();
+
+ if (ud.string_len) {
+ memcpy(string, ud.string, ud.string_len);
+ memset(ud.string, 0, ud.string_len);
+ free(ud.string);
+ }
+ *string_len = ud.string_len;
+
+ return TSS_SUCCESS;
+}
+
+/*
+ * DisplayNewPINWindow()
+ *
+ * Popup the dialog to collect a new password.
+ *
+ * string - buffer that the password will be passed back to caller in
+ * popup - UTF-8 string to be displayed in the title bar of the dialog box
+ *
+ */
+TSS_RESULT
+DisplayNewPINWindow(BYTE *string, UINT32 *string_len, BYTE *popup)
+{
+ GtkWidget *dialog1;
+ struct userdata ud;
+
+ ud.string_len = 0;
+
+#ifdef ENABLE_NLS
+ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+#endif
+
+ gtk_set_locale();
+ gtk_init_check((int *)NULL, (char ***)NULL);
+
+ LogDebug("address of string_len: %p", &ud.string_len);
+ dialog1 = create_new_password_dialog(&ud, (char *)popup);
+ gtk_widget_show(dialog1);
+
+ gtk_main();
+
+ if (ud.string_len) {
+ memcpy(string, ud.string, ud.string_len);
+ memset(ud.string, 0, ud.string_len);
+ free(ud.string);
+ }
+ *string_len = ud.string_len;
+
+ return TSS_SUCCESS;
+}
+