sync with 0.9.10cvs11
[claws.git] / src / passphrase.c
index 184f349b2859f2183427e6fe63d2891052e2de70..8daad3e777eec090b3fd056aae7f507d0fd8117a 100644 (file)
 #include "passphrase.h"
 #include "prefs_common.h"
 #include "manage_window.h"
-
+#include "utils.h"
 
 static int grab_all = 0;
 
 static gboolean pass_ack;
-static gchar* lastPass = NULL;
+static gchar *last_pass = NULL;
 
 static void passphrase_ok_cb(GtkWidget *widget, gpointer data);
 static void passphrase_cancel_cb(GtkWidget *widget, gpointer data);
@@ -153,19 +153,22 @@ passphrase_mbox (const gchar *desc)
     
     gtk_widget_show_all(window);
 
+    /* don't use XIM on entering passphrase */
+    gtkut_editable_disable_im(GTK_EDITABLE(pass_entry));
+
     if (grab_all) {
         XGrabServer(GDK_DISPLAY());
         if ( gdk_pointer_grab ( window->window, TRUE, 0,
                                 NULL, NULL, GDK_CURRENT_TIME)) {
             XUngrabServer ( GDK_DISPLAY() );
-            g_message ("OOPS: Could not grab mouse\n");
+            g_warning ("OOPS: Could not grab mouse\n");
             gtk_widget_destroy (window);
             return NULL;
         }
         if ( gdk_keyboard_grab( window->window, FALSE, GDK_CURRENT_TIME )) {
             gdk_pointer_ungrab (GDK_CURRENT_TIME);
             XUngrabServer ( GDK_DISPLAY() );
-            g_message ("OOPS: Could not grab keyboard\n");
+            g_warning ("OOPS: Could not grab keyboard\n");
             gtk_widget_destroy (window);
             return NULL;
         }
@@ -269,11 +272,11 @@ create_description (const gchar *desc)
 
 static int free_passphrase(gpointer _unused)
 {
-    if (lastPass != NULL) {
-        munlock(lastPass, strlen(lastPass));
-        g_free(lastPass);
-        lastPass = NULL; // necessary?
-        g_message("%% passphrase removed");
+    if (last_pass != NULL) {
+        munlock(last_pass, strlen(last_pass));
+        g_free(last_pass);
+        last_pass = NULL;
+        debug_print("%% passphrase removed");
     }
     
     return FALSE;
@@ -290,38 +293,38 @@ gpgmegtk_passphrase_cb (void *opaque, const char *desc, void **r_hd)
         /* FIXME: cleanup by looking at *r_hd */
         return NULL;
     }
-    if (prefs_common.store_passphrase
-        && strncmp(desc, "TRY_AGAIN", 9) && (lastPass != NULL))
-        return g_strdup(lastPass);
+    if (prefs_common.store_passphrase && last_pass != NULL &&
+        strncmp(desc, "TRY_AGAIN", 9) != 0)
+        return g_strdup(last_pass);
 
     gpgmegtk_set_passphrase_grab (prefs_common.passphrase_grab);
-    g_message ("%% requesting passphrase for `%s': ", desc );
+    debug_print ("%% requesting passphrase for `%s': ", desc);
     pass = passphrase_mbox (desc);
     gpgmegtk_free_passphrase();
     if (!pass) {
-        g_message ("%% cancel passphrase entry");
+        debug_print ("%% cancel passphrase entry");
         gpgme_cancel (ctx);
     }
     else {
         if (prefs_common.store_passphrase) {
-            lastPass = g_strdup(pass);
-            if (mlock(lastPass, strlen(lastPass)) == -1)
-                g_message("%% locking passphrase failed");
+            last_pass = g_strdup(pass);
+            if (mlock(last_pass, strlen(last_pass)) == -1)
+                debug_print("%% locking passphrase failed");
 
             if (prefs_common.store_passphrase_timeout > 0) {
                 gtk_timeout_add(prefs_common.store_passphrase_timeout*60*1000,
                                 free_passphrase, NULL);
             }
         }
-        g_message ("%% sending passphrase");
+        debug_print ("%% sending passphrase");
     }
 
     return pass;
 }
 
-void gpgmegtk_free_passphrase()
+void gpgmegtk_free_passphrase(void)
 {
-    (void)free_passphrase(NULL); // could be inline
+    (void)free_passphrase(NULL); /* could be inline */
 }
 
 #endif /* USE_GPGME */