/* passphrase.c - GTK+ based passphrase callback
- * Copyright (C) 2001-2006 Werner Koch (dd9jn) and the Sylpheed-Claws team
+ * Copyright (C) 2001-2007 Werner Koch (dd9jn) and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#ifdef HAVE_CONFIG_H
#include <glib.h>
#include <glib/gi18n.h>
-#include <gdk/gdktypes.h>
+#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
-#include <gdk/gdkdisplay.h>
#ifdef GDK_WINDOWING_X11
# include <gdk/gdkx.h>
#endif /* GDK_WINDOWING_X11 */
-#include <gtk/gtkmain.h>
-#include <gtk/gtkwidget.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkhbbox.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkfilesel.h>
-#include <gtk/gtksignal.h>
+#include <gtk/gtk.h>
#include <string.h>
#include <sys/types.h>
#ifdef G_OS_WIN32
-#include <windows.h>
+#include <w32lib.h>
#else
#include <sys/mman.h>
#endif
gtk_menu_popdown(GTK_MENU(summaryview->popupmenu));
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "passphrase");
gtk_window_set_title(GTK_WINDOW(window), _("Passphrase"));
gtk_window_set_default_size(GTK_WINDOW(window), 375, 100);
gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
pass_entry = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(vbox), pass_entry, FALSE, FALSE, 0);
gtk_entry_set_visibility(GTK_ENTRY(pass_entry), FALSE);
+#ifdef MAEMO
+ hildon_gtk_entry_set_input_mode(GTK_ENTRY(pass_entry),
+ HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
+#endif
gtk_widget_grab_focus(pass_entry);
gtkut_stock_button_set_create(&confirm_box,
gpgmegtk_passphrase_cb(void *opaque, const char *uid_hint,
const char *passphrase_hint, int prev_bad, int fd)
{
- const char *pass;
+ char *pass = NULL;
if (prefs_gpg_get_config()->store_passphrase && last_pass && !prev_bad)
- pass = last_pass;
- else {
- gpgmegtk_set_passphrase_grab (prefs_gpg_get_config()->passphrase_grab);
- debug_print ("%% requesting passphrase for '%s'\n ", uid_hint);
- pass = passphrase_mbox (uid_hint, passphrase_hint, prev_bad, FALSE);
- gpgmegtk_free_passphrase();
- if (!pass) {
- debug_print ("%% cancel passphrase entry\n");
- write(fd, "\n", 1);
- return GPG_ERR_CANCELED;
- }
+ pass = g_strdup(last_pass);
else {
- if (prefs_gpg_get_config()->store_passphrase) {
- last_pass = g_strdup(pass);
+ gpgmegtk_set_passphrase_grab (prefs_gpg_get_config()->passphrase_grab);
+ debug_print ("%% requesting passphrase for '%s'\n ", uid_hint);
+ pass = passphrase_mbox (uid_hint, passphrase_hint, prev_bad, FALSE);
+ gpgmegtk_free_passphrase();
+ if (!pass) {
+ debug_print ("%% cancel passphrase entry\n");
+ write(fd, "\n", 1);
+ return GPG_ERR_CANCELED;
+ }
+ else {
+ if (prefs_gpg_get_config()->store_passphrase) {
+ last_pass = g_strdup(pass);
#ifndef G_PLATFORM_WIN32
- if (mlock(last_pass, strlen(last_pass)) == -1)
- debug_print("%% locking passphrase failed\n");
+ if (mlock(last_pass, strlen(last_pass)) == -1)
+ debug_print("%% locking passphrase failed\n");
#endif
- if (prefs_gpg_get_config()->store_passphrase_timeout > 0) {
- gtk_timeout_add(prefs_gpg_get_config()
- ->store_passphrase_timeout*60*1000,
- free_passphrase, NULL);
+ if (prefs_gpg_get_config()->store_passphrase_timeout > 0) {
+ g_timeout_add(prefs_gpg_get_config()
+ ->store_passphrase_timeout*60*1000,
+ free_passphrase, NULL);
+ }
}
- }
- debug_print ("%% sending passphrase\n");
- }
+ debug_print ("%% sending passphrase\n");
+ }
}
#ifdef G_OS_WIN32
write(fd, pass, strlen(pass));
write(fd, "\n", 1);
#endif
+ g_free(pass);
+
return GPG_ERR_NO_ERROR;
}