summaryrefslogtreecommitdiff
path: root/src/tspi/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'src/tspi/gtk')
-rw-r--r--src/tspi/gtk/callbacks.c163
-rw-r--r--src/tspi/gtk/callbacks.h58
-rw-r--r--src/tspi/gtk/interface.c299
-rw-r--r--src/tspi/gtk/interface.h30
-rw-r--r--src/tspi/gtk/main.c117
-rw-r--r--src/tspi/gtk/support.c157
-rw-r--r--src/tspi/gtk/support.h81
7 files changed, 905 insertions, 0 deletions
diff --git a/src/tspi/gtk/callbacks.c b/src/tspi/gtk/callbacks.c
new file mode 100644
index 0000000..86570fc
--- /dev/null
+++ b/src/tspi/gtk/callbacks.c
@@ -0,0 +1,163 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <string.h>
+
+#undef TRUE
+#undef FALSE
+
+#include "callbacks.h"
+#include "interface.h"
+#include "support.h"
+#include "trousers/tss.h"
+#include "trousers/trousers.h"
+#include "tsplog.h"
+
+
+/* Callbacks for the simple password dialog */
+
+void
+on_inputdialog1_destroy(GtkObject *object, struct userdata *user_data)
+{
+ gtk_widget_destroy(user_data->window);
+ gtk_main_quit();
+}
+
+
+void
+on_dialog1_close(GtkDialog *dialog, struct userdata *user_data)
+{
+ gtk_widget_destroy(user_data->window);
+ gtk_main_quit();
+}
+
+
+void
+on_cancelbutton1_clicked(GtkButton *button, struct userdata *user_data)
+{
+ LogDebugFn();
+ gtk_widget_destroy(user_data->window);
+ user_data->string_len = 0;
+ gtk_main_quit();
+}
+
+
+void
+on_okbutton1_clicked(GtkButton *button, struct userdata *user_data)
+{
+ const gchar *entry_text = gtk_entry_get_text (GTK_ENTRY(user_data->entry));
+
+ LogDebugFn();
+ user_data->string = (char *)Trspi_Native_To_UNICODE((BYTE *)entry_text,
+ &user_data->string_len);
+ gtk_widget_destroy(user_data->window);
+
+ gtk_main_quit();
+}
+
+
+gboolean
+enter_event(GtkWidget *widget, struct userdata *user_data)
+{
+ const gchar *entry_text = gtk_entry_get_text (GTK_ENTRY(user_data->entry));
+
+ LogDebugFn();
+ user_data->string = (char *)Trspi_Native_To_UNICODE((BYTE *)entry_text,
+ &user_data->string_len);
+ gtk_widget_destroy(user_data->window);
+
+ gtk_main_quit();
+ return TRUE;
+}
+
+
+/* Callbacks for the new password dialog */
+void
+on_entryPassword_activate(GtkEntry *entry, struct userdata *user_data)
+{
+ const gchar *entryPass_text = gtk_entry_get_text (GTK_ENTRY(user_data->entryPass));
+ const gchar *entryConf_text = gtk_entry_get_text (GTK_ENTRY(user_data->entryConf));
+ int len = strlen(entryConf_text);
+
+ if (strlen(entryConf_text) == strlen(entryPass_text)) {
+ if (!memcmp(entryPass_text, entryConf_text, len)) {
+ user_data->string = (char *)Trspi_Native_To_UNICODE((BYTE *)entryConf_text,
+ &user_data->string_len);
+ gtk_widget_destroy(user_data->window);
+ gtk_main_quit();
+
+ LogDebugFn("string len ptr: %p, value = %u", &user_data->string_len,
+ user_data->string_len);
+ return;
+ }
+ }
+
+ gtk_widget_grab_focus(user_data->entryConf);
+}
+
+void
+on_entryConfirm_activate(GtkEntry *entry, struct userdata *user_data)
+{
+ const gchar *entryPass_text = gtk_entry_get_text (GTK_ENTRY(user_data->entryPass));
+ const gchar *entryConf_text = gtk_entry_get_text (GTK_ENTRY(user_data->entryConf));
+ unsigned len = strlen(entryConf_text);
+
+ if (strlen(entryConf_text) == strlen(entryPass_text)) {
+ if (!memcmp(entryPass_text, entryConf_text, len)) {
+ user_data->string = (char *)Trspi_Native_To_UNICODE((BYTE *)entryConf_text,
+ &user_data->string_len);
+ gtk_widget_destroy(user_data->window);
+ gtk_main_quit();
+
+ LogDebugFn("string len ptr: %p, value = %u", &user_data->string_len,
+ user_data->string_len);
+ return;
+ }
+ }
+
+ gtk_widget_grab_focus(user_data->entryPass);
+}
+
+void
+on_cancelbutton2_clicked(GtkButton *button, struct userdata *user_data)
+{
+ LogDebugFn();
+ gtk_widget_destroy(user_data->window);
+ user_data->string_len = 0;
+ gtk_main_quit();
+}
+
+void
+on_okbutton2_clicked(GtkButton *button, struct userdata *user_data)
+{
+ const gchar *entryPass_text = gtk_entry_get_text (GTK_ENTRY(user_data->entryPass));
+ const gchar *entryConf_text = gtk_entry_get_text (GTK_ENTRY(user_data->entryConf));
+ unsigned len = strlen(entryConf_text);
+
+ if (strlen(entryConf_text) == strlen(entryPass_text)) {
+ if (!memcmp(entryPass_text, entryConf_text, len)) {
+ user_data->string = (char *)Trspi_Native_To_UNICODE((BYTE *)entryConf_text,
+ &user_data->string_len);
+ gtk_widget_destroy(user_data->window);
+ gtk_main_quit();
+
+ LogDebugFn("string len ptr: %p, value = %u", &user_data->string_len,
+ user_data->string_len);
+ return;
+ }
+ }
+
+ gtk_widget_grab_focus(user_data->entryPass);
+}
diff --git a/src/tspi/gtk/callbacks.h b/src/tspi/gtk/callbacks.h
new file mode 100644
index 0000000..1fca617
--- /dev/null
+++ b/src/tspi/gtk/callbacks.h
@@ -0,0 +1,58 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+#ifndef _CALLBACKS_H_
+#define _CALLBACKS_H_
+
+#include <gtk/gtk.h>
+
+#include "interface.h"
+
+/* Callbacks for the simple text imput dialog */
+
+void
+on_dialog1_close (GtkDialog *dialog,
+ struct userdata *user_data);
+
+void
+on_cancelbutton1_clicked (GtkButton *button,
+ struct userdata *user_data);
+
+void
+on_okbutton1_clicked (GtkButton *button,
+ struct userdata *user_data);
+
+gboolean
+enter_event (GtkWidget *widget,
+ struct userdata *user_data);
+
+void
+on_inputdialog1_destroy (GtkObject *object,
+ struct userdata *user_data);
+
+/* Callbacks for the new password dialog */
+
+void
+on_entryPassword_activate (GtkEntry *entry,
+ struct userdata *user_data);
+
+void
+on_entryConfirm_activate (GtkEntry *entry,
+ struct userdata *user_data);
+
+void
+on_cancelbutton2_clicked (GtkButton *button,
+ struct userdata *user_data);
+
+void
+on_okbutton2_clicked (GtkButton *button,
+ struct userdata *user_data);
+
+#endif
diff --git a/src/tspi/gtk/interface.c b/src/tspi/gtk/interface.c
new file mode 100644
index 0000000..c295beb
--- /dev/null
+++ b/src/tspi/gtk/interface.c
@@ -0,0 +1,299 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004, 2005
+ *
+ */
+
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+
+#include "callbacks.h"
+#include "interface.h"
+#include "support.h"
+
+#define GLADE_HOOKUP_OBJECT(component,widget,name) \
+ g_object_set_data_full (G_OBJECT (component), name, \
+ gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
+
+#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
+ g_object_set_data (G_OBJECT (component), name, widget)
+
+GtkWidget*
+create_password_dialog (struct userdata *ud, char *message)
+{
+ GtkWidget *dialog1;
+ GtkWidget *dialog_vbox1;
+ GtkWidget *vbox1;
+ GtkWidget *entry;
+ GtkWidget *alignment1;
+ GtkWidget *table2;
+ GtkWidget *label1;
+ GtkWidget *alignment2;
+ GtkWidget *table1;
+ GtkWidget *dialog_action_area1;
+ GtkWidget *cancelbutton1;
+ GtkWidget *okbutton1;
+ GtkTooltips *tooltips;
+
+ tooltips = gtk_tooltips_new ();
+
+ dialog1 = gtk_dialog_new ();
+ gtk_widget_set_size_request (dialog1, 300, 150);
+ //gtk_tooltips_set_tip (tooltips, dialog1, _("This is a box for entering dialogue"), NULL);
+ gtk_window_set_title (GTK_WINDOW (dialog1), _("TSS Password"));
+ //gtk_window_set_title (GTK_WINDOW (dialog1), message);
+ gtk_window_set_position (GTK_WINDOW (dialog1), GTK_WIN_POS_CENTER);
+ gtk_window_set_default_size (GTK_WINDOW (dialog1), 300, 150);
+
+ dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
+ gtk_widget_show (dialog_vbox1);
+
+ vbox1 = gtk_vbox_new (TRUE, 0);
+ gtk_widget_show (vbox1);
+ gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);
+
+ alignment1 = gtk_alignment_new (0.5, 0.5, 1, 1);
+ gtk_widget_show (alignment1);
+ gtk_box_pack_start (GTK_BOX (vbox1), alignment1, FALSE, FALSE, 0);
+
+ table2 = gtk_table_new (3, 3, FALSE);
+ gtk_widget_show (table2);
+ gtk_container_add (GTK_CONTAINER (alignment1), table2);
+
+ //label1 = gtk_label_new (_("Please enter a password, or not."));
+ label1 = gtk_label_new (message);
+ gtk_widget_show (label1);
+ gtk_table_attach (GTK_TABLE (table2), label1, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);
+ gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5);
+
+ alignment2 = gtk_alignment_new (0.5, 0.5, 1, 1);
+ gtk_widget_show (alignment2);
+ gtk_box_pack_start (GTK_BOX (vbox1), alignment2, TRUE, TRUE, 0);
+
+ table1 = gtk_table_new (2, 3, FALSE);
+ gtk_widget_show (table1);
+ gtk_container_add (GTK_CONTAINER (alignment2), table1);
+
+ entry = gtk_entry_new ();
+ gtk_widget_show (entry);
+ gtk_table_attach (GTK_TABLE (table1), entry, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ //gtk_tooltips_set_tip (tooltips, entry, _("This is where you enter the characters of your password, using the computer input device of your choice."), NULL);
+ gtk_entry_set_max_length (GTK_ENTRY (entry), 255);
+ gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
+
+ dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
+ gtk_widget_show (dialog_action_area1);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
+
+ cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
+ gtk_widget_show (cancelbutton1);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), cancelbutton1, GTK_RESPONSE_CANCEL);
+ GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);
+ //gtk_tooltips_set_tip (tooltips, cancelbutton1, _("Depress this button in order to indicate that you would like to cancel the submitting of authorization data at this time."), NULL);
+
+ okbutton1 = gtk_button_new_from_stock ("gtk-ok");
+ gtk_widget_show (okbutton1);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), okbutton1, GTK_RESPONSE_OK);
+ GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
+ //gtk_tooltips_set_tip (tooltips, okbutton1, _("Depress this button in order to indicate that you have completed the entry of your authorization data."), NULL);
+
+ /* We need to pass the window in to destroy it */
+ ud->window = dialog1;
+ /* Here we need a pointer to the entry to grab the text out of it */
+ ud->entry = entry;
+
+ g_signal_connect ((gpointer) dialog1, "close",
+ G_CALLBACK (on_dialog1_close),
+ ud);
+
+ g_signal_connect ((gpointer) dialog1, "destroy",
+ G_CALLBACK (on_inputdialog1_destroy),
+ ud);
+
+ g_signal_connect ((gpointer) entry, "activate",
+ G_CALLBACK (enter_event),
+ ud);
+
+ g_signal_connect ((gpointer) cancelbutton1, "clicked",
+ G_CALLBACK (on_cancelbutton1_clicked),
+ ud);
+
+ g_signal_connect ((gpointer) okbutton1, "clicked",
+ G_CALLBACK (on_okbutton1_clicked),
+ ud);
+
+ /* Store pointers to all widgets, for use by lookup_widget(). */
+ GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog1, "dialog1");
+ GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog_vbox1, "dialog_vbox1");
+ GLADE_HOOKUP_OBJECT (dialog1, vbox1, "vbox1");
+ GLADE_HOOKUP_OBJECT (dialog1, alignment1, "alignment1");
+ GLADE_HOOKUP_OBJECT (dialog1, table2, "table2");
+ GLADE_HOOKUP_OBJECT (dialog1, label1, "label1");
+ GLADE_HOOKUP_OBJECT (dialog1, alignment2, "alignment2");
+ GLADE_HOOKUP_OBJECT (dialog1, table1, "table1");
+ GLADE_HOOKUP_OBJECT (dialog1, entry, "entry");
+ GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog_action_area1, "dialog_action_area1");
+ GLADE_HOOKUP_OBJECT (dialog1, cancelbutton1, "cancelbutton1");
+ GLADE_HOOKUP_OBJECT (dialog1, okbutton1, "okbutton1");
+ GLADE_HOOKUP_OBJECT_NO_REF (dialog1, tooltips, "tooltips");
+
+ return dialog1;
+}
+
+GtkWidget*
+create_new_password_dialog (struct userdata *ud, char *message)
+{
+ GtkWidget *dialog1;
+ GtkWidget *dialog_vbox1;
+ GtkWidget *vbox1;
+ GtkWidget *table2;
+ GtkWidget *label7;
+ GtkWidget *table1;
+ GtkWidget *label5;
+ GtkWidget *label6;
+ GtkWidget *entryPassword;
+ GtkWidget *entryConfirm;
+ GtkWidget *dialog_action_area1;
+ GtkWidget *cancelbutton2;
+ GtkWidget *okbutton2;
+
+ dialog1 = gtk_dialog_new ();
+ gtk_widget_set_size_request (dialog1, 300, 150);
+ gtk_window_set_title (GTK_WINDOW (dialog1), "TSS Password");
+ //gtk_window_set_title (GTK_WINDOW (dialog1), message);
+
+ dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
+ gtk_widget_show (dialog_vbox1);
+
+ vbox1 = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (vbox1);
+ gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);
+
+ table2 = gtk_table_new (3, 3, FALSE);
+ gtk_widget_show (table2);
+ gtk_box_pack_start (GTK_BOX (vbox1), table2, TRUE, TRUE, 0);
+
+ //label7 = gtk_label_new (_("Please enter a new password below."));
+ label7 = gtk_label_new (message);
+ gtk_widget_show (label7);
+ gtk_table_attach (GTK_TABLE (table2), label7, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_label_set_justify (GTK_LABEL (label7), GTK_JUSTIFY_LEFT);
+ gtk_misc_set_alignment (GTK_MISC (label7), 0, 0.5);
+
+ table1 = gtk_table_new (5, 5, FALSE);
+ gtk_widget_show (table1);
+ gtk_box_pack_start (GTK_BOX (vbox1), table1, TRUE, TRUE, 0);
+
+ label5 = gtk_label_new (_("Password:"));
+ gtk_widget_show (label5);
+ gtk_table_attach (GTK_TABLE (table1), label5, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_label_set_justify (GTK_LABEL (label5), GTK_JUSTIFY_LEFT);
+ gtk_misc_set_alignment (GTK_MISC (label5), 0, 0.5);
+
+ label6 = gtk_label_new (_("Confirm:"));
+ gtk_widget_show (label6);
+ gtk_table_attach (GTK_TABLE (table1), label6, 1, 2, 3, 4,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_label_set_justify (GTK_LABEL (label6), GTK_JUSTIFY_LEFT);
+ gtk_misc_set_alignment (GTK_MISC (label6), 0, 0.5);
+
+ entryPassword = gtk_entry_new ();
+ gtk_widget_show (entryPassword);
+ gtk_table_attach (GTK_TABLE (table1), entryPassword, 3, 4, 1, 2,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_entry_set_max_length (GTK_ENTRY (entryPassword), 255);
+ gtk_entry_set_visibility (GTK_ENTRY (entryPassword), FALSE);
+
+ entryConfirm = gtk_entry_new ();
+ gtk_widget_show (entryConfirm);
+ gtk_table_attach (GTK_TABLE (table1), entryConfirm, 3, 4, 3, 4,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_entry_set_max_length (GTK_ENTRY (entryConfirm), 255);
+ gtk_entry_set_visibility (GTK_ENTRY (entryConfirm), FALSE);
+
+ dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
+ gtk_widget_show (dialog_action_area1);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
+
+ cancelbutton2 = gtk_button_new_from_stock ("gtk-cancel");
+ gtk_widget_show (cancelbutton2);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), cancelbutton2, GTK_RESPONSE_CANCEL);
+ GTK_WIDGET_SET_FLAGS (cancelbutton2, GTK_CAN_DEFAULT);
+
+ okbutton2 = gtk_button_new_from_stock ("gtk-ok");
+ gtk_widget_show (okbutton2);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), okbutton2, GTK_RESPONSE_OK);
+ GTK_WIDGET_SET_FLAGS (okbutton2, GTK_CAN_DEFAULT);
+
+ /* We need to pass the window in to destroy it */
+ ud->window = dialog1;
+ /* Here we need a pointer to the entries to grab text out of them */
+ ud->entryPass = entryPassword;
+ ud->entryConf = entryConfirm;
+
+ g_signal_connect ((gpointer) dialog1, "destroy",
+ G_CALLBACK (on_inputdialog1_destroy),
+ ud);
+
+ g_signal_connect ((gpointer) entryPassword, "activate",
+ G_CALLBACK (on_entryPassword_activate),
+ ud);
+ g_signal_connect ((gpointer) entryConfirm, "activate",
+ G_CALLBACK (on_entryConfirm_activate),
+ ud);
+ g_signal_connect ((gpointer) cancelbutton2, "clicked",
+ G_CALLBACK (on_cancelbutton2_clicked),
+ ud);
+ g_signal_connect ((gpointer) okbutton2, "clicked",
+ G_CALLBACK (on_okbutton2_clicked),
+ ud);
+
+ /* Store pointers to all widgets, for use by lookup_widget(). */
+ GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog1, "dialog1");
+ GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog_vbox1, "dialog_vbox1");
+ GLADE_HOOKUP_OBJECT (dialog1, vbox1, "vbox1");
+ GLADE_HOOKUP_OBJECT (dialog1, table2, "table2");
+ GLADE_HOOKUP_OBJECT (dialog1, label7, "label7");
+ GLADE_HOOKUP_OBJECT (dialog1, table1, "table1");
+ GLADE_HOOKUP_OBJECT (dialog1, label5, "label5");
+ GLADE_HOOKUP_OBJECT (dialog1, label6, "label6");
+ GLADE_HOOKUP_OBJECT (dialog1, entryPassword, "entryPassword");
+ GLADE_HOOKUP_OBJECT (dialog1, entryConfirm, "entryConfirm");
+ GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog_action_area1, "dialog_action_area1");
+ GLADE_HOOKUP_OBJECT (dialog1, cancelbutton2, "cancelbutton2");
+ GLADE_HOOKUP_OBJECT (dialog1, okbutton2, "okbutton2");
+
+ return dialog1;
+}
+
+
diff --git a/src/tspi/gtk/interface.h b/src/tspi/gtk/interface.h
new file mode 100644
index 0000000..9950fe7
--- /dev/null
+++ b/src/tspi/gtk/interface.h
@@ -0,0 +1,30 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifndef _INTERFACE_H_
+#define _INTERFACE_H_
+
+struct userdata {
+ char *string;
+ unsigned string_len;
+ GtkWidget *window;
+ GtkWidget *entry;
+ GtkWidget *entryPass;
+ GtkWidget *entryConf;
+};
+
+GtkWidget* create_password_dialog (struct userdata *, char *);
+GtkWidget* create_new_password_dialog (struct userdata *, char *);
+
+#endif
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;
+}
+
diff --git a/src/tspi/gtk/support.c b/src/tspi/gtk/support.c
new file mode 100644
index 0000000..6ce3870
--- /dev/null
+++ b/src/tspi/gtk/support.c
@@ -0,0 +1,157 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <gtk/gtk.h>
+
+#include "trousers/tss.h"
+#include "tsplog.h"
+
+#include "support.h"
+
+GtkWidget*
+lookup_widget (GtkWidget *widget,
+ const gchar *widget_name)
+{
+ GtkWidget *parent, *found_widget;
+
+ for (;;)
+ {
+ if (GTK_IS_MENU (widget))
+ parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
+ else
+ parent = widget->parent;
+ if (!parent)
+ parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
+ if (parent == NULL)
+ break;
+ widget = parent;
+ }
+
+ found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
+ widget_name);
+ if (!found_widget)
+ g_warning ("Widget not found: %s", widget_name);
+ return found_widget;
+}
+
+static GList *pixmaps_directories = NULL;
+
+/* Use this function to set the directory containing installed pixmaps. */
+void
+__tspi_add_pixmap_directory (const gchar *directory)
+{
+ pixmaps_directories = g_list_prepend (pixmaps_directories,
+ g_strdup (directory));
+}
+
+/* This is an internally used function to find pixmap files. */
+static gchar*
+find_pixmap_file (const gchar *filename)
+{
+ GList *elem;
+
+ /* We step through each of the pixmaps directory to find it. */
+ elem = pixmaps_directories;
+ while (elem)
+ {
+ gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
+ G_DIR_SEPARATOR_S, filename);
+ if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+ return pathname;
+ g_free (pathname);
+ elem = elem->next;
+ }
+ return NULL;
+}
+
+/* This is an internally used function to create pixmaps. */
+GtkWidget*
+create_pixmap (GtkWidget *widget,
+ const gchar *filename)
+{
+ gchar *pathname = NULL;
+ GtkWidget *pixmap;
+
+ if (!filename || !filename[0])
+ return gtk_image_new ();
+
+ pathname = find_pixmap_file (filename);
+
+ if (!pathname)
+ {
+ g_warning (_("Couldn't find pixmap file: %s"), filename);
+ return gtk_image_new ();
+ }
+
+ pixmap = gtk_image_new_from_file (pathname);
+ g_free (pathname);
+ return pixmap;
+}
+
+/* This is an internally used function to create pixmaps. */
+GdkPixbuf*
+create_pixbuf (const gchar *filename)
+{
+ gchar *pathname = NULL;
+ GdkPixbuf *pixbuf;
+ GError *error = NULL;
+
+ if (!filename || !filename[0])
+ return NULL;
+
+ pathname = find_pixmap_file (filename);
+
+ if (!pathname)
+ {
+ g_warning (_("Couldn't find pixmap file: %s"), filename);
+ return NULL;
+ }
+
+ pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
+ if (!pixbuf)
+ {
+ LogError ("Failed to load pixbuf file: %s: %s\n",
+ pathname, error->message);
+ g_error_free (error);
+ }
+ g_free (pathname);
+ return pixbuf;
+}
+
+/* This is used to set ATK action descriptions. */
+void
+glade_set_atk_action_description (AtkAction *action,
+ const gchar *action_name,
+ const gchar *description)
+{
+ gint n_actions, i;
+
+ n_actions = atk_action_get_n_actions (action);
+ for (i = 0; i < n_actions; i++)
+ {
+ if (!strcmp (atk_action_get_name (action, i), action_name))
+ atk_action_set_description (action, i, description);
+ }
+}
+
diff --git a/src/tspi/gtk/support.h b/src/tspi/gtk/support.h
new file mode 100644
index 0000000..3b8186a
--- /dev/null
+++ b/src/tspi/gtk/support.h
@@ -0,0 +1,81 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004
+ *
+ */
+
+#ifndef _SUPPORT_H_
+#define _SUPPOR_H_
+
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+/*
+ * Standard gettext macros.
+ */
+#ifdef ENABLE_NLS
+# include <libintl.h>
+# undef _
+# define _(String) dgettext (PACKAGE, String)
+# ifdef gettext_noop
+# define N_(String) gettext_noop (String)
+# else
+# define N_(String) (String)
+# endif
+#else
+# define textdomain(String) (String)
+# define gettext(String) (String)
+# define dgettext(Domain,Message) (Message)
+# define dcgettext(Domain,Message,Type) (Message)
+# define bindtextdomain(Domain,Directory) (Domain)
+# define _(String) (String)
+# define N_(String) (String)
+#endif
+
+
+/*
+ * Public Functions.
+ */
+
+/*
+ * This function returns a widget in a component created by Glade.
+ * Call it with the toplevel widget in the component (i.e. a window/dialog),
+ * or alternatively any widget in the component, and the name of the widget
+ * you want returned.
+ */
+GtkWidget* lookup_widget (GtkWidget *widget,
+ const gchar *widget_name);
+
+
+/* Use this function to set the directory containing installed pixmaps. */
+void __tspi_add_pixmap_directory (const gchar *directory);
+
+
+/*
+ * Private Functions.
+ */
+
+/* This is used to create the pixmaps used in the interface. */
+GtkWidget* create_pixmap (GtkWidget *widget,
+ const gchar *filename);
+
+/* This is used to create the pixbufs used in the interface. */
+GdkPixbuf* create_pixbuf (const gchar *filename);
+
+/* This is used to set ATK action descriptions. */
+void glade_set_atk_action_description (AtkAction *action,
+ const gchar *action_name,
+ const gchar *description);
+
+#endif