1 2 /* 3 * Licensed Materials - Property of IBM 4 * 5 * trousers - An open source TCG Software Stack 6 * 7 * (C) Copyright International Business Machines Corp. 2004 8 * 9 */ 10 11 /* 12 * Initial main.c file generated by Glade. Edit as required. 13 * Glade will not overwrite this file. 14 */ 15 16 #ifdef HAVE_CONFIG_H 17 # include <config.h> 18 #endif 19 20 #include <sys/types.h> 21 #include <string.h> 22 23 #include <gtk/gtk.h> 24 25 #undef TRUE 26 #undef FALSE 27 28 #include "trousers/tss.h" 29 #include "tsplog.h" 30 31 #include "interface.h" 32 #include "support.h" 33 34 /* 35 * DisplayPINWindow() 36 * 37 * Popup the dialog to collect an existing password. 38 * 39 * string - buffer that the password will be passed back to caller in 40 * popup - UTF-8 string to be displayed in the title bar of the dialog box 41 * 42 */ 43 TSS_RESULT 44 DisplayPINWindow(BYTE *string, UINT32 *string_len, BYTE *popup) 45 { 46 GtkWidget *dialog1; 47 struct userdata ud; 48 49 ud.string_len = 0; 50 51 #ifdef ENABLE_NLS 52 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); 53 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); 54 textdomain (GETTEXT_PACKAGE); 55 #endif 56 57 gtk_set_locale(); 58 gtk_init_check((int *)NULL, (char ***)NULL); 59 60 LogDebug("address of string_len: %p", &ud.string_len); 61 dialog1 = create_password_dialog(&ud, (char *)popup); 62 gtk_widget_show(dialog1); 63 64 gtk_main(); 65 66 if (ud.string_len) { 67 memcpy(string, ud.string, ud.string_len); 68 memset(ud.string, 0, ud.string_len); 69 free(ud.string); 70 } 71 *string_len = ud.string_len; 72 73 return TSS_SUCCESS; 74 } 75 76 /* 77 * DisplayNewPINWindow() 78 * 79 * Popup the dialog to collect a new password. 80 * 81 * string - buffer that the password will be passed back to caller in 82 * popup - UTF-8 string to be displayed in the title bar of the dialog box 83 * 84 */ 85 TSS_RESULT 86 DisplayNewPINWindow(BYTE *string, UINT32 *string_len, BYTE *popup) 87 { 88 GtkWidget *dialog1; 89 struct userdata ud; 90 91 ud.string_len = 0; 92 93 #ifdef ENABLE_NLS 94 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); 95 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); 96 textdomain (GETTEXT_PACKAGE); 97 #endif 98 99 gtk_set_locale(); 100 gtk_init_check((int *)NULL, (char ***)NULL); 101 102 LogDebug("address of string_len: %p", &ud.string_len); 103 dialog1 = create_new_password_dialog(&ud, (char *)popup); 104 gtk_widget_show(dialog1); 105 106 gtk_main(); 107 108 if (ud.string_len) { 109 memcpy(string, ud.string, ud.string_len); 110 memset(ud.string, 0, ud.string_len); 111 free(ud.string); 112 } 113 *string_len = ud.string_len; 114 115 return TSS_SUCCESS; 116 } 117 118