[Gpgoe-commits] r12 - in trunk: . doc po src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Apr 7 12:46:45 CEST 2006


Author: twoaday
Date: 2006-04-07 12:46:41 +0200 (Fri, 07 Apr 2006)
New Revision: 12

Added:
   trunk/po/Makevars
   trunk/po/build-utf-mo.sh
   trunk/src/OENLS.c
Modified:
   trunk/ChangeLog
   trunk/Makefile.am
   trunk/NEWS
   trunk/TODO
   trunk/configure.ac
   trunk/doc/gpgoe.texi
   trunk/po/de.po
   trunk/src/GPGOE.c
   trunk/src/GPGOE.h
   trunk/src/GPGOE.rc
   trunk/src/Makefile.am
   trunk/src/OECrypto.c
   trunk/src/OEDlgEncrypt.c
   trunk/src/OEDlgVerify.c
   trunk/src/OEDlgViewer.c
   trunk/src/OEMisc.c
   trunk/src/OEPassphraseCBDlg.c
   trunk/src/OEProc.c
Log:


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/ChangeLog	2006-04-07 10:46:41 UTC (rev 12)
@@ -1,3 +1,7 @@
+2006-04-06  Timo Schulz  <twoaday at freakmail.de>
+
+	* gettext support completed.
+	
 2006-03-25  Timo Schulz  <twoaday at freakmail.de>
 
 	* autoconf support completed.

Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/Makefile.am	2006-04-07 10:46:41 UTC (rev 12)
@@ -9,6 +9,6 @@
 
 EXTRA_DIST = autogen.sh GPGOE.dsp GPGOE.dsw
 
-SUBDIRS = src m4 init doc #po
+SUBDIRS = src m4 init doc po
 
 

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/NEWS	2006-04-07 10:46:41 UTC (rev 12)
@@ -1,7 +1,11 @@
-Noteworthy changes in version 0.6.1 (unreleased)
+Noteworthy changes in version 0.7.0 (2006-04-XX)
 ------------------------------------------------
 
+* UTF8 support for the message text.
+* The text viewer now allows to copy the text 
+  and to quote the text to make answers easier.
 
+
 Noteworthy changes in version 0.6.0 (2006-04-02)
 ------------------------------------------------
 

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/TODO	2006-04-07 10:46:41 UTC (rev 12)
@@ -1,4 +1,3 @@
-* Add w32-gettext support.
-* Maybe introduce support for the old 5.5 Express versions again (?)
 
 
+

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/configure.ac	2006-04-07 10:46:41 UTC (rev 12)
@@ -7,7 +7,7 @@
 # Version number: Remember to change it immediately *after* a release.
 #                 Make sure to run  "svn up" before a "make dist".
 #                 Add a "-cvs" prefix for non-released code.
-AC_INIT(gpgoe, 0.6.1-cvs, twoaday at freakmail.de)
+AC_INIT(gpgoe, 0.7.0, twoaday at freakmail.de)
 
 NEED_GPGME_API=1
 NEED_GPGME_VERSION=1.1.0
@@ -124,8 +124,8 @@
 
 
 # Note, that autogen.sh greps for the next line.
-#AM_GNU_GETTEXT_VERSION(0.12.1)
-#AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_VERSION(0.12.1)
+AM_GNU_GETTEXT([external])
 # We always want NLs, despite what the above macro figures out.
 USE_NLS=yes
 
@@ -187,5 +187,6 @@
 m4/Makefile
 init/Makefile
 doc/Makefile
+po/Makefile.in
 ])
 AC_OUTPUT

Modified: trunk/doc/gpgoe.texi
===================================================================
--- trunk/doc/gpgoe.texi	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/doc/gpgoe.texi	2006-04-07 10:46:41 UTC (rev 12)
@@ -96,7 +96,7 @@
 
 @item
 Even so the plug-in supports native line endings, which means you
-can properly exchange mails with Linux or MAC users, it is likely
+can properly exchange mails with Linux or Apple users, it is likely
 that there are problems with the charset.
 
 @item
@@ -104,7 +104,9 @@
 use an external key manager. WinPT is recommend in this case. It
 contains features to send public keys to mail recipients and also
 to export keys via the clipboard so you can easily paste the key
-into the text body of the message.
+into the text body of the message. The current version of the 
+plug-in automatically uses WinPT for key import if the program
+is available and running.
 
 @item
 Currently signing can be only done with the default signing key.

Added: trunk/po/Makevars
===================================================================
--- trunk/po/Makevars	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/po/Makevars	2006-04-07 10:46:41 UTC (rev 12)
@@ -0,0 +1,43 @@
+# Makefile variables for PO directory in any package using GNU gettext.
+
+# Usually the message domain is the same as the package name.
+DOMAIN = $(PACKAGE)
+
+# These two variables depend on the location of this directory.
+subdir = Po
+top_builddir = ..
+
+# These options get passed to xgettext.
+XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
+
+# This is the copyright holder that gets inserted into the header of the
+# $(DOMAIN).pot file.  Set this to the copyright holder of the surrounding
+# package.  (Note that the msgstr strings, extracted from the package's
+# sources, belong to the copyright holder of the package.)  Translators are
+# expected to transfer the copyright for their translations to this person
+# or entity, or to disclaim their copyright.  The empty string stands for
+# the public domain; in this case the translators are expected to disclaim
+# their copyright.
+#COPYRIGHT_HOLDER = Timo Schulz
+COPYRIGHT_HOLDER =
+
+# This is the email address or URL to which the translators shall report
+# bugs in the untranslated strings:
+# - Strings which are not entire sentences, see the maintainer guidelines
+#   in the GNU gettext documentation, section 'Preparing Strings'.
+# - Strings which use unclear terms or require additional context to be
+#   understood.
+# - Strings which make invalid assumptions about notation of date, time or
+#   money.
+# - Pluralisation problems.
+# - Incorrect English spelling.
+# - Incorrect formatting.
+# It can be your email address, or a mailing list address where translators
+# can write to without being subscribed, or the URL of a web page through
+# which the translators can contact you.
+MSGID_BUGS_ADDRESS = winpt at freakmail.de
+
+
+# This is the list of locale categories, beyond LC_MESSAGES, for which the
+# message catalogs shall be used.  It is usually empty.
+EXTRA_LOCALE_CATEGORIES =

Added: trunk/po/build-utf-mo.sh
===================================================================
--- trunk/po/build-utf-mo.sh	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/po/build-utf-mo.sh	2006-04-07 10:46:41 UTC (rev 12)
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+#iconv --silent --from-code=iso-8859-1 --to-code=utf-8 <de.po | \
+#sed "/^\"Content-Type:/ s/charset=[a-zA-Z0-9_-]*/charset=utf-8/"| 
+#msgfmt --output-file=winpt.mo -
+
+msgfmt -v --check --output-file=gpgoe.mo de.po
+
+


Property changes on: trunk/po/build-utf-mo.sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/po/de.po
===================================================================
--- trunk/po/de.po	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/po/de.po	2006-04-07 10:46:41 UTC (rev 12)
@@ -7,7 +7,7 @@
 msgstr ""
 "Project-Id-Version: GPGOE 0.6.0\n"
 "Report-Msgid-Bugs-To: winpt at freakmail.de\n"
-"POT-Creation-Date: 2006-03-25 09:52+0100\n"
+"POT-Creation-Date: 2006-04-06 16:45+0200\n"
 "PO-Revision-Date: 2006-03-24 22:40+0100\n"
 "Last-Translator: Timo Schulz <twoaday at freakmail.de>\n"
 "Language-Team: de <winpt-users at wald.intevation.org>\n"
@@ -15,27 +15,27 @@
 "Content-Type: text/plain; charset=iso-8859-1\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: src/OECrypto.c:469
+#: src/OECrypto.c:483
 #, c-format
 msgid ""
 "encrypted with %s key, ID %s\n"
-"decryption failed: secret keyn not available"
+"decryption failed: secret key not available"
 msgstr ""
 "verschlüsselt mit %s Schlüssel, ID %s\n"
 "Entschlüsselung fehlgeschlagen: geheimer Schlüssel nicht gefunden"
 
-#: src/OECrypto.c:475
+#: src/OECrypto.c:489
 #, c-format
 msgid ""
 "encrypted with %d-bit %s key, ID %s\n"
 "\t\"%s\"\n"
-"decryption failed: secret keyn not available"
+"decryption failed: secret key not available"
 msgstr ""
 "verschlüsselt mit %d-bit %s Schlüssel, ID %s\n"
 "\t\"%s\"\n"
 "Entschlüsselung fehlgeschlagen: geheimer Schlüssel nicht vorhanden"
 
-#: src/OECrypto.c:591
+#: src/OECrypto.c:641
 msgid ""
 "This mail contains one or more public or secret keys.\n"
 "\n"
@@ -45,78 +45,129 @@
 "\n"
 "Bitte speichern Sie die Mail ab und benutzen Sie WinPT zum Import."
 
-#: src/OECrypto.c:593 src/OEPassphraseCBDlg.c:104
+#: src/OECrypto.c:643 src/OEPassphraseCBDlg.c:109
 msgid "GPG Plug-in Info"
 msgstr "GPG Plug-in Information"
 
-#: src/OEDlgEncrypt.c:130
+#: src/OEDlgEncrypt.c:131
 msgid "User ID"
 msgstr "Benutzerkennung"
 
-#: src/OEDlgEncrypt.c:131
+#: src/OEDlgEncrypt.c:132
 msgid "Key ID"
 msgstr "Schlüssel ID"
 
-#: src/OEDlgEncrypt.c:132
+#: src/OEDlgEncrypt.c:133
 msgid "Algorithm"
 msgstr "Algorithmus"
 
-#: src/OEDlgEncrypt.c:158
+#: src/OEDlgEncrypt.c:160
+msgid "No keys found in the keyring"
+msgstr "Keine Schlüssel im Schlüsselbund gefunden"
+
+#: src/OEDlgEncrypt.c:161 src/OEProc.c:300
+msgid "GPG Plug-in Error"
+msgstr "GPG Plug-in Fehler"
+
+#: src/OEDlgEncrypt.c:164 src/OEDlgVerify.c:146 src/OEDlgViewer.c:88
+#: src/OEPassphraseCBDlg.c:81
+msgid "&OK"
+msgstr "&OK"
+
+#: src/OEDlgEncrypt.c:165 src/OEPassphraseCBDlg.c:82
+msgid "&Cancel"
+msgstr "&Abbrechen"
+
+#: src/OEDlgEncrypt.c:166
 msgid "Recipients which were NOT found"
 msgstr "Empfänger die NICHT gefunden worden"
 
-#: src/OEDlgEncrypt.c:164
+#: src/OEDlgEncrypt.c:172
 msgid "Select Recipient for Encryption"
 msgstr "Empfänger für Verschlüsselung auswählen"
 
-#: src/OEDlgVerify.c:56 src/OEDlgVerify.c:59 src/OEDlgVerify.c:60
+#: src/OEDlgVerify.c:59 src/OEDlgVerify.c:64
+msgid "undefined"
+msgstr "undefiniert"
+
+#: src/OEDlgVerify.c:60
+msgid "NEVER"
+msgstr "NIEMALS"
+
 #: src/OEDlgVerify.c:61
+msgid "marginal"
+msgstr "teilweise"
+
+#: src/OEDlgVerify.c:63
+msgid "full"
+msgstr "voll"
+
+#: src/OEDlgVerify.c:75 src/OEDlgVerify.c:79 src/OEDlgVerify.c:80
 msgid "Invalid signature"
 msgstr "Fehlerhafte Signatur"
 
-#: src/OEDlgVerify.c:57
+#: src/OEDlgVerify.c:76
 msgid "Good signature"
 msgstr "Gültige Signatur"
 
-#: src/OEDlgVerify.c:58
+#: src/OEDlgVerify.c:77
 msgid "BAD signature"
 msgstr "Ungültige Signatur"
 
-#: src/OEDlgVerify.c:62
+#: src/OEDlgVerify.c:78
+msgid "Can't check signature: key not found."
+msgstr "Konte Signatur nicht prüfen: Schlüssel nicht gefunden."
+
+#: src/OEDlgVerify.c:81
 msgid "Good signature (Expired Key)"
 msgstr "Gültige Signatur (Abgelaufener Schlüssel)"
 
-#: src/OEDlgVerify.c:63
+#: src/OEDlgVerify.c:82
 msgid "Good signature (Revoked Key)"
 msgstr "Gültige Signatur (Widerrufener Schlüssel)"
 
-#: src/OEDlgVerify.c:93
-#, c-format
-msgid "Error during verification: %s"
-msgstr "Fehler während Verifikation: %s"
-
-#: src/OEDlgVerify.c:100
+#: src/OEDlgVerify.c:114
 msgid "UserID not found"
 msgstr "Benutzerkennung nicht gefunden"
 
-#: src/OEDlgVerify.c:110
+#: src/OEDlgVerify.c:122
 #, c-format
 msgid ""
 "Signature made '%s' using key ID 0x%08X\r\n"
+"%s\r\n"
+"\"%s\""
+msgstr ""
+"Signatur erstellt am '%s' mit Schlüssel ID 0x%08X\r\n"
+"%s von \"%s\""
+
+#: src/OEDlgVerify.c:126
+#, c-format
+msgid ""
+"Signature made '%s' using key ID 0x%08X\r\n"
 "%s from \"%s\"\r\n"
+"Validity of the key: %s"
 msgstr ""
 "Signatur erstellt am '%s' mit Schlüssel ID 0x%08X\r\n"
 "%s von \"%s\"\r\n"
+"Gültigkeit des Schlüssels: %s"
 
-#: src/OEDlgVerify.c:131
+#: src/OEDlgVerify.c:147
 msgid "Signature Verification"
 msgstr "Überprüfung der Signatur"
 
-#: src/OEDlgViewer.c:59
+#: src/OEDlgViewer.c:86
+msgid "&Copy"
+msgstr "&Kopieren"
+
+#: src/OEDlgViewer.c:87
+msgid "&Quote"
+msgstr "&Quote"
+
+#: src/OEDlgViewer.c:89
 msgid "Message Viewer"
 msgstr "Betracher für Nachrichten"
 
-#: src/OEPassphraseCBDlg.c:74
+#: src/OEPassphraseCBDlg.c:75
 #, c-format
 msgid ""
 "%s\n"
@@ -125,32 +176,42 @@
 "%s\n"
 "%s Schlüssel, ID %s"
 
-#: src/OEPassphraseCBDlg.c:96
+#: src/OEPassphraseCBDlg.c:83 src/OEPassphraseCBDlg.c:104
+#: src/OEPassphraseCBDlg.c:108
+msgid "Please enter your passphrase"
+msgstr "Bitte geben Sie ihre Passphrase ein"
+
+#: src/OEPassphraseCBDlg.c:86
+msgid "Decryption"
+msgstr "Entschlüsselung"
+
+#: src/OEPassphraseCBDlg.c:101
 msgid "Invalid passphrase; please enter your passphrase again"
 msgstr "Ungültige Passphrase; Bitte geben Sie die Passphrase erneut ein"
 
-#: src/OEPassphraseCBDlg.c:99 src/OEPassphraseCBDlg.c:103
-msgid "Please enter your passphrase"
-msgstr "Bitte geben Sie ihre Passphrase ein"
+#: src/OEProc.c:77
+msgid ""
+"GPGOE is unable to secure attachments.\r\n"
+"As a result the data attached to this mail is NOT encrypted."
+msgstr ""
+"GPGOE kann keine Anhänge sichern.\r\n"
+"Als eine Konsequzenz daraus, werden diese NICHT verschlüsselt."
 
-#: src/OEProc.c:40
+#: src/OEProc.c:79 src/OEProc.c:96
+msgid "GPG Plug-in Warning"
+msgstr "GPG Plug-in Warnung"
+
+#: src/OEProc.c:91
 #, c-format
 msgid ""
 "WARNING: This message will be sent in cleartext.\r\n"
-"%s"
+"\r\n"
+"Error description: %s."
 msgstr ""
 "WARNUNG: Diese Nachricht wird im Klartext versendet.\r\n"
 "%s"
 
-#: src/OEProc.c:44
-msgid "GPG Plug-in Warning"
-msgstr "GPG Plug-in Warnung"
-
-#: src/OEProc.c:203
-msgid "GPG Plug-in Error"
-msgstr "GPG Plug-in Fehler"
-
-#: src/OEProc.c:204
+#: src/OEProc.c:301
 #, c-format
 msgid ""
 "decrypt/verify: %s\n"

Modified: trunk/src/GPGOE.c
===================================================================
--- trunk/src/GPGOE.c	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/src/GPGOE.c	2006-04-07 10:46:41 UTC (rev 12)
@@ -65,6 +65,23 @@
 }
 
 
+/* Quick and dirty check if the dialog is a common dialog
+   and the 'File Save' style. */
+static int 
+is_filesave_dlg (HWND h)
+{
+    HWND button = GetDlgItem (h, 1040);
+    char wclass[200];
+
+    if (button == NULL)
+	return 0;
+    if (GetClassName (button, wclass, 200) > 0
+	&& !stricmp (wclass, "Button"))
+	return -1;
+    return 0;
+}
+
+
 /* CTB hook procedure.
    Monitors the creation of all windows and subclass the window
    if it belongs to the Outlook Express message class. */
@@ -95,6 +112,21 @@
 		oe_hwnd = hwnd;
         }
 	break;
+
+#if 0
+    case HCBT_ACTIVATE:
+	if (plugin_active != NULL && 
+	    WaitForSingleObject (plugin_active, 0) == WAIT_OBJECT_0) {
+	    char wclass[200];
+
+	    if (GetClassName (hwnd, wclass, sizeof (wclass)-1) <= 0 ||
+		!strstr (wclass, "#32770") || !is_filesave_dlg (hwnd))
+		break;
+	    of_proc_old = (WNDPROC)GetWindowLong (hwnd, GWL_WNDPROC);
+	    SetWindowLong (hwnd, GWL_WNDPROC, (LONG)(WNDPROC)of_proc);
+	}
+	break;
+#endif
     }	
     return CallNextHookEx (ctb_hook, code, wparam, lparam);
 }

Modified: trunk/src/GPGOE.h
===================================================================
--- trunk/src/GPGOE.h	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/src/GPGOE.h	2006-04-07 10:46:41 UTC (rev 12)
@@ -21,9 +21,11 @@
 #ifndef GPGOE_H
 #define GPGOE_H
 
-/* dummy until gettext support is finished. */
-#define _(X) (X)
+/* gettext support. */
+const char *gettext (const char *msgid);
+#define _(X) gettext ((X))
 
+
 #include <malloc.h>
 /* wrapper around free. */
 #define free_if_alloc(ptr) \
@@ -43,19 +45,17 @@
 
 #define wipememory(_ptr,_len) wipememory2 (_ptr,0,_len)
 
-/* OE5 V5.x/V6 command id's. */ 
-#define ID_OE5_SELECTALL    40125
-#define ID_OE5_COPY	    40484
-#define ID_OE5_PASTE	    40231
-#define ID_OE5_ENCRYPT	    40260
-#define ID_OE5_SIGN	    40299
-#define ID_OE5_SEND	    40411
-#define ID_OE5_PREVMSG	    40145
-#define ID_OE5_NEXTMSG	    40146
+/* Dialog IDs for clipboard operations. */
+#define ID_OE_SELECTALL	    40125
+#define ID_OE_COPY	    40484
+#define ID_OE_PASTE	    40231
+#define ID_OE_SAVE_ATT	    40104
 
-/* Common dialogs (GetOpenFileName) */
-#define OF_IDOK			1
-#define OF_IDFILE	     1152
+/* Common dialogs (Get{Open,Save}FileName) */
+#define ID_OF_OK		1
+#define ID_OF_CANCEL		2
+#define ID_OF_OPEN_FILE	     1152
+#define ID_OF_SAVE_FILE	     1148
 
 
 /* Context for the recipient list. */
@@ -70,6 +70,7 @@
 struct plugin_ctx_s {
     HWND msg_wnd, main_wnd, addr_wnd;
     HWND to_wnd, cc_wnd, bcc_wnd;
+    HWND attach;
     char *to;
     char *cc;
     char *bcc;
@@ -78,6 +79,7 @@
     recip_list_t rset;
     char errbuf[256];
     char *orig_text;
+    int use_utf8;
 };
 typedef struct plugin_ctx_s *plugin_ctx_t;
 
@@ -95,19 +97,24 @@
 /*-- OEProc.c --*/
 extern HINSTANCE mod_hinst_dll;
 extern WNDPROC oe_proc_old;
+extern WNDPROC of_proc_old;
+extern HANDLE plugin_active;
 LRESULT CALLBACK oe_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
+LRESULT CALLBACK of_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
 
 /*-- OECrypto.c --*/
 gpgme_error_t oe_handle_mail (plugin_ctx_t ctx);
 
 /*-- OEMisc.c --*/
 char* utf8_to_native (const char *string);
+char* native_to_utf8 (const char *string);
 char* get_clip_text (HWND hwnd);
 int set_clip_text (HWND hwnd, const char *text, int nbytes);
 void show_error (HWND hwnd, const char *caption, 
 		 UINT type, const char *fmt, ...);
 void* xcalloc (size_t n, size_t m);
 char* xstrdup (const char *s);
+void xfree (void *p);
 
 /*-- dialogs --*/
 BOOL CALLBACK encrypt_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, 
@@ -128,4 +135,7 @@
 void free_pass_cb (pass_cb_t cb);
 pass_cb_t new_pass_cb (HWND main);
 
+/*-- OENLS.c --*/
+int setup_gettext (void);
+
 #endif /* GPGOE_H */

Modified: trunk/src/GPGOE.rc
===================================================================
--- trunk/src/GPGOE.rc	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/src/GPGOE.rc	2006-04-07 10:46:41 UTC (rev 12)
@@ -66,8 +66,8 @@
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 0,6,0,0
- PRODUCTVERSION 0,6,0,0
+ FILEVERSION 0,7,0,0
+ PRODUCTVERSION 0,7,0,0
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -85,14 +85,14 @@
             VALUE "Comments", "This is free software under the terms of the GNU LGPL v2.1\0"
             VALUE "CompanyName", "\0"
             VALUE "FileDescription", "GPG Outlook Express Plug-in\0"
-            VALUE "FileVersion", "0.6.0\0"
+            VALUE "FileVersion", "0.7.0\0"
             VALUE "InternalName", "GPGOE\0"
             VALUE "LegalCopyright", "Copyright © 2006 Timo Schulz\0"
             VALUE "LegalTrademarks", "\0"
             VALUE "OriginalFilename", "GPGOE.dll\0"
             VALUE "PrivateBuild", "\0"
             VALUE "ProductName", "GPGOE\0"
-            VALUE "ProductVersion", "0.6.0\0"
+            VALUE "ProductVersion", "0.7.0\0"
             VALUE "SpecialBuild", "\0"
         END
     END
@@ -126,7 +126,7 @@
 
 IDD_ENCRYPT DIALOG DISCARDABLE  0, 0, 280, 167
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Encryption"
+CAPTION "Select Recipient for Encryption"
 FONT 8, "MS Sans Serif"
 BEGIN
     CONTROL         "List1",IDC_ENCRYPT_KEYLIST,"SysListView32",LVS_REPORT | 
@@ -144,17 +144,17 @@
 CAPTION "Message Viewer"
 FONT 8, "MS Sans Serif"
 BEGIN
-    PUSHBUTTON      "&Quote",IDC_VIEWER_QUOTE,8,150,54,14,WS_DISABLED
+    PUSHBUTTON      "&Quote",IDC_VIEWER_QUOTE,5,150,54,14
     DEFPUSHBUTTON   "&OK",IDOK,186,152,54,14
     PUSHBUTTON      "&Copy",IDC_VIEWER_COPY,243,152,54,14
     CONTROL         "",IDC_VIEWER_TEXT2,"RICHEDIT",ES_MULTILINE | 
-                    ES_WANTRETURN | WS_BORDER | WS_VSCROLL | WS_TABSTOP,4,3,
+                    ES_WANTRETURN | WS_BORDER | WS_VSCROLL | WS_TABSTOP,5,3,
                     293,137
 END
 
 IDD_VERIFY DIALOG DISCARDABLE  0, 0, 266, 68
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Verification"
+CAPTION "Signature Verification"
 FONT 8, "MS Sans Serif"
 BEGIN
     DEFPUSHBUTTON   "&OK",IDOK,107,47,50,14

Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/src/Makefile.am	2006-04-07 10:46:41 UTC (rev 12)
@@ -14,9 +14,10 @@
 	OEDlgViewer.c \
 	OEMisc.c \
 	OEPassphraseCBDlg.c \
-	OEProc.c
+	OEProc.c \
+	OENLS.c
 
-gpgoe_LDADD = GPGOE.def $(GPGME_LIBS) -lkernel32
+gpgoe_LDADD = GPGOE.def $(GPGME_LIBS) -lkernel32 -ladvapi32
 
 resource.o: resource.rc resource.h
 

Modified: trunk/src/OECrypto.c
===================================================================
--- trunk/src/OECrypto.c	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/src/OECrypto.c	2006-04-07 10:46:41 UTC (rev 12)
@@ -23,6 +23,8 @@
 #endif
 #include <windows.h>
 #include <assert.h>
+#include <commctrl.h>
+
 #include "resource.h"
 #include "gpgme.h"
 #include "GPGOE.h"
@@ -30,10 +32,10 @@
 
 /* Valid OpenPGP message types. */
 enum {
-    PGP_MESSAGE      =  1,	
-    PGP_CLEARSIG     =  2,	
-    PGP_SIG          =  4,
-    PGP_KEY	     =  8,
+    PGP_MESSAGE	    =  1,	
+    PGP_CLEARSIG    =  2,	
+    PGP_SIG	    =  4,
+    PGP_KEY	    =  8,
 };
 
 
@@ -69,8 +71,8 @@
 {
     set_focus (main_hwnd);
     SetForegroundWindow (main_hwnd);
-    SendMessage (main_hwnd, WM_COMMAND, MAKEWPARAM(ID_OE5_SELECTALL, 0), 0);
-    SendMessage (main_hwnd, WM_COMMAND, MAKEWPARAM(ID_OE5_COPY, 0), 0);
+    SendMessage (main_hwnd, WM_COMMAND, MAKEWPARAM (ID_OE_SELECTALL, 0), 0);
+    SendMessage (main_hwnd, WM_COMMAND, MAKEWPARAM (ID_OE_COPY, 0), 0);
 
     /* even so SendMessage() should wait, we wait for safety reasons. */
     Sleep (200);
@@ -87,8 +89,8 @@
     set_clip_text (NULL, msg, strlen (msg));
     set_focus (main_hwnd);
     SetForegroundWindow (main_hwnd);
-    SendMessage (main_hwnd, WM_COMMAND, MAKEWPARAM (ID_OE5_SELECTALL, 0), 0);
-    SendMessage (main_hwnd, WM_COMMAND, MAKEWPARAM (ID_OE5_PASTE, 0), 0);
+    SendMessage (main_hwnd, WM_COMMAND, MAKEWPARAM (ID_OE_SELECTALL, 0), 0);
+    SendMessage (main_hwnd, WM_COMMAND, MAKEWPARAM (ID_OE_PASTE, 0), 0);
 }
 
 
@@ -231,6 +233,20 @@
 }
 
 
+/* Create gpgme input data object. If @encode is 1, use UTF8 conversion. */
+gpgme_error_t
+create_in_data (gpgme_data_t *in, const char *buf, int encode)
+{
+    gpgme_error_t err;
+    char *enc_buf;
+
+    enc_buf = encode? native_to_utf8 (buf) : xstrdup (buf);
+    err = gpgme_data_new_from_mem (in, enc_buf, strlen (enc_buf), 1);
+    free (enc_buf);
+    return err;
+}
+
+
 /* Map gpgme data object to a string. */
 void
 map_gpgme_data (gpgme_data_t out, char **r_msg)
@@ -309,7 +325,7 @@
 
     err = gpgme_new (&gctx);
     if (!err)
-	err = gpgme_data_new_from_mem (&in, msg, strlen (msg), 1);
+	err = create_in_data (&in, msg, ctx->use_utf8);
     if (!err)
 	err = gpgme_data_new (&out);
     if (!err) {
@@ -386,7 +402,7 @@
 
     err = gpgme_new (&gctx);
     if (!err)
-	err = gpgme_data_new_from_mem (&in, *r_msg, strlen (*r_msg), 1);
+	err = create_in_data (&in, *r_msg, ctx->use_utf8);
     if (!err)
 	err = gpgme_data_new (&out);
     if (!err) {
@@ -465,14 +481,14 @@
     algo = res->recipients->pubkey_algo;
     if (!key)
 	_snprintf (buf, buflen, _("encrypted with %s key, ID %s\n"
-				"decryption failed: secret keyn not available"),
+				"decryption failed: secret key not available"),
 				algo == 1? "RSA" : algo==16? "ELG": "???", 
 				res->recipients->keyid+8);
     else {
 	char *uid = utf8_to_native (key->uids->uid);
 	_snprintf (buf, buflen, _("encrypted with %d-bit %s key, ID %s\n"
 				"\t\"%s\"\n"
-				"decryption failed: secret keyn not available"),
+				"decryption failed: secret key not available"),
 				key->subkeys->length, 
 				algo == 1? "RSA" : algo==16? "ELG": "???",
 				key->subkeys->keyid+8, uid);
@@ -549,6 +565,48 @@
 }
 
 
+static int
+winpt_key_import (void)
+{
+    HWND winpt;
+
+    winpt = FindWindow ("WinPT", "WinPT");
+    if (winpt != NULL) {
+	PostMessage (winpt, WM_COMMAND, 40014, 0);
+	return 0;
+    }
+    return -1;
+}
+
+
+/* Try to decrypt a PGP/MIME message. */
+static gpgme_error_t
+oe_handle_pgp_mime_mail (plugin_ctx_t ctx)
+{
+    SetEvent (plugin_active);
+
+    /* Select attachment number 0. */
+    AttachThreadInput (GetCurrentThreadId (),
+                       GetWindowThreadProcessId (ctx->main_wnd, NULL),
+                       TRUE);
+
+    SetFocus (ctx->addr_wnd);
+    SetFocus (ctx->attach);
+    ListView_SetItemState (ctx->attach, 0, LVIS_SELECTED|LVIS_FOCUSED, 
+			   LVIS_FOCUSED|LVIS_SELECTED);
+
+    AttachThreadInput (GetCurrentThreadId (),
+                       GetWindowThreadProcessId (ctx->main_wnd, NULL),
+                       FALSE);
+    
+    SendMessage (ctx->addr_wnd, WM_COMMAND, ID_OE_SAVE_ATT, 0);
+
+    ResetEvent (plugin_active);
+
+    return 0;
+}
+
+
 /* This function can be use for all kind of OE messages.
    It automatically choose the right procedure to handle the data. */
 gpgme_error_t
@@ -561,6 +619,13 @@
     assert (ctx);
 
     msg = window_get_message (ctx->main_wnd);
+#if 0
+    if ((!msg || strlen (msg)) < 2 && 
+	ctx->attach && ListView_GetItemCount (ctx->attach) == 2) {
+	free_if_alloc (msg);
+	return oe_handle_pgp_mime_mail (ctx);
+    }
+#endif
     if (!msg || strlen (msg) == 2) {
 	free_if_alloc (msg);
         return 0;
@@ -571,7 +636,8 @@
 	msg_type = parse_pgp_id (msg);
 
     if (msg_type & PGP_KEY) {
-        MessageBox (ctx->main_wnd,
+	if (winpt_key_import ())
+	    MessageBox (ctx->main_wnd,
                     _("This mail contains one or more public or secret keys.\n\n"
                       "Please save the mail text in a file to use WinPT to import them."),
                       _("GPG Plug-in Info"), MB_ICONINFORMATION|MB_OK);

Modified: trunk/src/OEDlgEncrypt.c
===================================================================
--- trunk/src/OEDlgEncrypt.c	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/src/OEDlgEncrypt.c	2006-04-07 10:46:41 UTC (rev 12)
@@ -161,7 +161,8 @@
 		    _("GPG Plug-in Error"), MB_ICONERROR|MB_OK);
 	EndDialog (dlg, 0);
     }
-
+    SetDlgItemText (dlg, IDOK, _("&OK"));	
+    SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
     SetDlgItemText (dlg, IDC_ENCRYPT_RECPMSG, _("Recipients which were NOT found"));
     lb = GetDlgItem (dlg, IDC_ENCRYPT_INVLIST);
     for (t=((plugin_ctx_t)lparam)->rset; t; t = t->next) {

Modified: trunk/src/OEDlgVerify.c
===================================================================
--- trunk/src/OEDlgVerify.c	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/src/OEDlgVerify.c	2006-04-07 10:46:41 UTC (rev 12)
@@ -143,7 +143,7 @@
     case WM_INITDIALOG:
 	sig = (gpgme_signature_t)lparam;
 	assert (sig);
-
+	SetDlgItemText (dlg, IDOK, _("&OK"));
 	SetWindowText (dlg, _("Signature Verification"));
 	set_sig_info (dlg, sig);
 	SetForegroundWindow (dlg);

Modified: trunk/src/OEDlgViewer.c
===================================================================
--- trunk/src/OEDlgViewer.c	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/src/OEDlgViewer.c	2006-04-07 10:46:41 UTC (rev 12)
@@ -45,17 +45,47 @@
 }
 
 
+/* Prepend '> ' to line line in the buffer @inp
+   and store the result in @r_outp. */
+static void
+quote_msg_text (const char *inp, char **r_outp)
+{
+    size_t i, n=0;
+    char *p;
+    char *outp;
+
+    for (i=0; i < strlen (inp); i++) {
+	if (inp[i] == '\r')
+	    n += 4;
+    }
+    outp = xcalloc (1, strlen (inp) + 1 + n + 1);
+    p = strtok ((char *)inp, "\r");
+    while (p != NULL) {
+	if (*p == '\n')
+	    p++;
+	strcat (outp, "> ");
+	strcat (outp, p);
+	strcat (outp, "\r\n");
+	p = strtok (NULL, "\r");
+    }
+    *r_outp = outp;
+}
+
+
 /* Text viewer dialog box procedure. */
 BOOL CALLBACK
 viewer_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
 {    
     static viewer_ctx_t viewer;
-    char *p;
+    char *p, *out;
 
     switch (msg)  {
     case WM_INITDIALOG:
 	viewer = (viewer_ctx_t)lparam;
 	assert (viewer);
+	SetDlgItemText (dlg, IDC_VIEWER_COPY, _("&Copy"));
+	SetDlgItemText (dlg, IDC_VIEWER_QUOTE, _("&Quote"));
+	SetDlgItemText (dlg, IDOK, _("&OK"));
 	SetWindowText (dlg, _("Message Viewer"));
 	SetDlgItemText (dlg, IDC_VIEWER_TEXT2, viewer->msg);
 	SetForegroundWindow (dlg);
@@ -75,7 +105,12 @@
 
 	case IDC_VIEWER_QUOTE:
 	    p = get_item_text (dlg, IDC_VIEWER_TEXT2);
+	    if (!p)
+		return TRUE;
+	    quote_msg_text (p, &out);
+	    SetDlgItemText (dlg, IDC_VIEWER_TEXT2, out);
 	    free_if_alloc (p);
+	    free_if_alloc (out);
 	    return TRUE;
 
 	case IDC_VIEWER_COPY:

Modified: trunk/src/OEMisc.c
===================================================================
--- trunk/src/OEMisc.c	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/src/OEMisc.c	2006-04-07 10:46:41 UTC (rev 12)
@@ -30,6 +30,42 @@
 #include "GPGOE.h"
 
 
+char*
+native_to_utf8 (const char *string)
+{
+    wchar_t *result;
+    char *native;
+    int n;
+
+    n = MultiByteToWideChar (GetACP (), 0, string, -1, NULL, 0);
+    if (n < 0)
+	return NULL;
+
+    result = (wchar_t*)xcalloc (1, (n+1) * sizeof *result);
+
+    n = MultiByteToWideChar (GetACP (), 0, string, -1, result, n);
+    if (n < 0) {
+	free (result);
+	return NULL;
+    }
+
+    n = WideCharToMultiByte (CP_UTF8, 0, result, -1, NULL, 0, NULL, NULL);
+    if (n < 0)
+	return NULL;
+
+    native = (char*)xcalloc (1, n+1);
+
+    n = WideCharToMultiByte (CP_UTF8, 0, result, -1, native, n, NULL, NULL);
+    if (n < 0) {
+	free (result);
+	return NULL;
+    }
+
+    free (result);
+    return native;
+}
+
+
 /* Convert the UTF8 string @string into the native charset. */
 char*
 utf8_to_native (const char *string)
@@ -108,7 +144,6 @@
 set_clip_text (HWND hwnd, const char *text, int nbytes)
 {    
     HANDLE clipmem;
-    int rc = 0;
     char *p;
     
     if (OpenClipboard (hwnd) == FALSE)	
@@ -120,18 +155,18 @@
 	abort ();
     p = (char *) GlobalLock (clipmem);
     if (p == NULL) {
-	rc = -1;
-	goto leave;	
+	CloseClipboard ();
+	GlobalFree (clipmem);
+	return -1;
     }
     memcpy (p, text, nbytes);
     p[nbytes] = '\0';
     
+    SetClipboardData (CF_TEXT, clipmem);
     GlobalUnlock (clipmem);
-    SetClipboardData (CF_TEXT, clipmem);
+    CloseClipboard ();
     GlobalFree (clipmem);
     
-leave:
-    CloseClipboard ();
     return 0;
 }
 
@@ -158,6 +193,14 @@
 }
 
 
+void
+xfree (void *p)
+{
+    if (p != NULL)
+	free (p);
+}
+
+
 /* printf style message box. */
 void
 show_error (HWND hwnd, const char *caption, UINT type, const char *fmt, ...)

Added: trunk/src/OENLS.c
===================================================================
--- trunk/src/OENLS.c	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/src/OENLS.c	2006-04-07 10:46:41 UTC (rev 12)
@@ -0,0 +1,354 @@
+/* wptNLS.c - W32 Native Language Support
+ *	Copyright (C) 2001, 2002, 2003, 2006 Timo Schulz
+ *	Copyright (C) 1995-1999 Free Software Foundation, Inc.
+ *
+ * This code based on the simple-gettext.c code from the GnuPG 
+ * by Ulrich Drepper.
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2 
+ * of the License, or (at your option) any later version.
+ *  
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <windows.h>
+
+#include "gpgme.h"
+#include "GPGOE.h"
+
+
+/* The magic number of the GNU message catalog format.	*/
+#define MAGIC	      0x950412de
+#define MAGIC_SWAPPED 0xde120495
+
+/* Revision number of the currently used .mo (binary) file format.  */
+#define MO_REVISION_NUMBER 0
+
+#define SWAPIT(flag, data) ((flag) ? do_swap_u32(data) : (data) )
+
+
+/* We assume to have `unsigned long int' value with at least 32 bits.  */
+#define HASHWORDBITS 32
+
+/* The so called `hashpjw' function by P.J. Weinberger
+   [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
+   1986, 1987 Bell Telephone Laboratories, Inc.]  */
+
+/* Header for binary .mo file format.  */
+struct mo_file_header {
+    DWORD magic;	    /* The magic number.	*/
+    DWORD revision;	    /* The revision number of the file format.  */
+    DWORD nstrings;	    /* The number of strings pairs.  */
+    DWORD orig_tab_offset;  /* Offset of table with start offsets of original 
+				strings.  */
+    DWORD trans_tab_offset;   /* Offset of table with start offsets of translation
+			     strings.  */
+    DWORD hash_tab_size;	/* Size of hashing table.  */
+    DWORD hash_tab_offset;    /* Offset of first hashing entry.  */
+};
+
+struct string_desc {
+    DWORD length; /* Length of addressed string.  */  
+    DWORD offset; /* Offset of string in file.	*/
+};
+
+struct loaded_domain {
+  char *data;
+  int must_swap;
+  DWORD nstrings;
+  char *mapped;
+  struct string_desc *orig_tab;
+  struct string_desc *trans_tab;
+  DWORD hash_size;
+  DWORD *hash_tab;
+};
+
+
+/* The current domain. */
+static struct loaded_domain *the_domain;
+
+
+static DWORD
+do_swap_u32 (DWORD i)
+{
+    return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
+}
+
+
+/* Missing W32 functions. */
+static char*
+w32_stpcpy (char *a,const char *b)
+{
+    while (*b)
+	*a++ = *b++;
+    *a = 0;
+    return (char*)a;
+}
+
+
+
+static DWORD
+hash_string (const char *str_param)
+{
+    unsigned long int hval, g;
+    const char *str = str_param;
+
+    hval = 0;
+    while (*str != '\0') {
+	hval <<= 4;
+	hval += (unsigned long int) *str++;	
+	g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4));
+	if (g != 0) {
+	    hval ^= g >> (HASHWORDBITS - 8);
+	    hval ^= g;	
+	}
+    }
+    return hval;
+}
+
+
+static struct loaded_domain *
+load_domain( const char *filename )
+{
+    FILE *fp;
+    size_t size;
+    struct stat st;
+    struct mo_file_header *data = NULL;
+    struct loaded_domain *domain = NULL;
+    size_t to_read;
+    char *read_ptr;
+
+    fp = fopen( filename, "rb" );
+    if( !fp )
+       return NULL; /* can't open the file */
+    /* we must know about the size of the file */
+    if( fstat( fileno(fp ), &st )
+	|| (size = (size_t)st.st_size) != (size_t)st.st_size
+	|| size < sizeof (struct mo_file_header) ) {
+	fclose( fp );	
+	return NULL;
+    }
+
+    data = (struct mo_file_header *) xcalloc (1, size);
+    if( !data ) {
+	fclose( fp );
+	return NULL; /* out of memory */
+    }
+
+    to_read = size;
+    read_ptr = (char *) data;
+    do {
+	size_t nb = fread( read_ptr, 1, to_read, fp );
+	if( nb < to_read ) {
+	    fclose (fp);
+	    free(data);	
+	    return NULL; /* read error */
+		
+	}
+	read_ptr += nb;	
+	to_read -= nb;
+    } while( to_read > 0 );
+    fclose (fp);
+
+    /* Using the magic number we can test whether it really is a message
+     * catalog file.  */
+    if( data->magic != MAGIC && data->magic != MAGIC_SWAPPED ) {
+	/* The magic number is wrong: not a message catalog file.  */
+	free( data );
+	return NULL;
+    }
+
+    domain = (struct loaded_domain *)xcalloc( 1, sizeof *domain );
+    if( !domain )  {
+	free( data );	
+	return NULL;
+    }
+    domain->data = (char *) data;
+    domain->must_swap = data->magic != MAGIC;
+
+    /* Fill in the information about the available tables.  */
+    switch( SWAPIT(domain->must_swap, data->revision) ) {
+      case 0:
+	  domain->nstrings = SWAPIT(domain->must_swap, data->nstrings);
+	  domain->orig_tab = (struct string_desc *)
+	      ((char *) data + SWAPIT(domain->must_swap, data->orig_tab_offset));
+	  domain->trans_tab = (struct string_desc *)
+	      ((char *) data + SWAPIT(domain->must_swap, data->trans_tab_offset));
+	  domain->hash_size = SWAPIT(domain->must_swap, data->hash_tab_size);	
+	  domain->hash_tab = (DWORD *)	
+	      ((char *) data + SWAPIT(domain->must_swap, data->hash_tab_offset));	
+	  break;
+
+      default: /* This is an invalid revision.	*/
+	  free( data );
+	  free( domain );
+	  return NULL;
+    }
+
+    /* allocate an array to keep track of code page mappings */
+    domain->mapped = (char *)xcalloc( 1, domain->nstrings );
+    if( !domain->mapped ) {
+	free( data );
+	free( domain );	
+	return NULL;
+    }
+
+    return domain;
+} /* load_domain */
+
+
+static const char*
+get_string( struct loaded_domain *domain, DWORD idx )
+{
+    char *p = domain->data + SWAPIT(domain->must_swap,
+				    domain->trans_tab[idx].offset);
+    if( !domain->mapped[idx] ) {	
+	domain->mapped[idx] = 1;		
+    }
+    return (const char*)p;
+}
+
+
+const char *
+gettext( const char *msgid )
+{
+    struct loaded_domain *domain;
+    size_t act = 0;
+    size_t top, bottom;
+
+    if( !(domain = the_domain) )	
+	goto not_found;
+
+    /* Locate the MSGID and its translation.  */
+    if( domain->hash_size > 2 && domain->hash_tab ) {		
+	/* Use the hashing table.  */		
+	DWORD len = strlen (msgid);	
+	DWORD hash_val = hash_string (msgid);	
+	DWORD idx = hash_val % domain->hash_size;	
+	DWORD incr = 1 + (hash_val % (domain->hash_size - 2));	
+	DWORD nstr = SWAPIT (domain->must_swap, domain->hash_tab[idx]);
+
+	if ( !nstr ) /* Hash table entry is empty.  */	
+	    goto not_found;
+
+		
+	if( SWAPIT(domain->must_swap,	
+	    domain->orig_tab[nstr - 1].length) == len	
+	    && !strcmp( msgid,	
+	    domain->data + SWAPIT(domain->must_swap,
+				    domain->orig_tab[nstr - 1].offset)) )
+				    return get_string( domain, nstr - 1 );
+	for(;;) {
+	    if (idx >= domain->hash_size - incr)
+		idx -= domain->hash_size - incr;
+	    else
+		idx += incr;
+	    nstr = SWAPIT(domain->must_swap, domain->hash_tab[idx]);
+	    if( !nstr )	
+		goto not_found; /* Hash table entry is empty.  */
+
+	    if ( SWAPIT(domain->must_swap,
+				domain->orig_tab[nstr - 1].length) == len
+				&& !strcmp (msgid,
+				domain->data + SWAPIT(domain->must_swap,
+					   domain->orig_tab[nstr - 1].offset)))
+			
+					   return get_string( domain, nstr-1 );
+	} /* NOTREACHED */
+    }
+
+    /* Now we try the default method:  binary search in the sorted
+       array of messages.  */
+    bottom = 0;
+    top = domain->nstrings;
+    while( bottom < top ) {		
+	int cmp_val;
+	
+	act = (bottom + top) / 2;	
+	cmp_val = strcmp(msgid, domain->data + SWAPIT(domain->must_swap,
+			domain->orig_tab[act].offset));
+	if (cmp_val < 0)
+	    top = act;
+	else if (cmp_val > 0)
+	    bottom = act + 1;
+	else	
+	    return get_string( domain, act );
+    }
+
+not_found:
+    return msgid;
+}
+
+
+/* Set the file used for translations. Pass a NULL to disable translation.
+   A new filename may be set at anytime. */
+int
+set_gettext_file (const char *filename)
+{
+    struct loaded_domain *domain = NULL;
+
+    if (!filename)
+	return 0;
+
+    domain = load_domain (filename);
+    if (the_domain) {
+	free (the_domain->data);
+	free (the_domain->mapped);
+	free (the_domain);	
+	the_domain = NULL;
+    }
+    the_domain = domain;
+    return 0;
+}
+
+
+int
+read_gettext_entry (char *path, DWORD pathlen)
+{
+    HKEY hkey;
+    LONG err;
+    DWORD type = 0;
+    
+    err = RegOpenKeyEx (HKEY_CURRENT_USER, "Control Panel\\MingW32\\NLS", 0,
+			KEY_READ, &hkey);
+    if (err != ERROR_SUCCESS)
+	return -1;
+    err = RegQueryValueEx (hkey, "MODir", NULL, &type, (BYTE*)path, &pathlen);
+    RegCloseKey (hkey);
+    if (err != ERROR_SUCCESS)
+	return -1;
+    return 0;
+}
+
+
+int
+setup_gettext (void)
+{
+    struct stat st;
+    char modir[MAX_PATH+1+32];
+
+    memset (modir, 0, sizeof (modir));
+    if (read_gettext_entry (modir, MAX_PATH-1))
+	return -1;
+    strcat (modir, "\\gpgoe.mo");
+    if (stat (modir, &st))
+	return -1;
+    set_gettext_file (modir);
+    return 0;
+}

Modified: trunk/src/OEPassphraseCBDlg.c
===================================================================
--- trunk/src/OEPassphraseCBDlg.c	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/src/OEPassphraseCBDlg.c	2006-04-07 10:46:41 UTC (rev 12)
@@ -78,8 +78,12 @@
 	    free_if_alloc (utf8_uid);
 	    free_if_alloc (info);
 	}
+	SetDlgItemText (dlg, IDOK, _("&OK"));
+	SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
+	SetDlgItemText (dlg, IDC_DECRYPT_PWDINFO, _("Please enter your passphrase"));
 	SendDlgItemMessage (dlg, IDC_DECRYPT_PWD, EM_SETPASSWORDCHAR, 
 			    (WPARAM)(UINT)'*', 0);
+	SetWindowText (dlg, _("Decryption"));
 	SetForegroundWindow (dlg);
 	break;
 

Modified: trunk/src/OEProc.c
===================================================================
--- trunk/src/OEProc.c	2006-04-03 17:10:15 UTC (rev 11)
+++ trunk/src/OEProc.c	2006-04-07 10:46:41 UTC (rev 12)
@@ -28,14 +28,44 @@
 #include "gpgme.h"
 #include "GPGOE.h"
 
+/* Outlook V6.x command IDs. */ 
+#define ID_OE_ENCRYPT	    40260
+#define ID_OE_SIGN	    40299
+#define ID_OE_SEND	    40411
+#define ID_OE_PREVMSG	    40145
+#define ID_OE_NEXTMSG	    40146
 
+/* Outlook select charset IDs. */
+#define ID_OE_CP_UTF8		42540
+#define ID_OE_CP_WEUROPE_ISO	42544
+#define ID_OE_CP_WEUROPE_WINCP	42545
+#define ID_OE_CP_MEUROPE_ISO	42525
+#define ID_OE_CP_MEUROPE_WINCP	42526
+#define ID_OE_CP_LATIN9		42535
+
 /* Global plugin structure. */
 static plugin_ctx_t oe_plug;
 
 /* We show a warning for the attachment problem, but only once. */
 static int attach_warn_shown = 0;
 
+/* One time initialisation finished?. */
+static int plugin_preload_done = 0;
 
+/* Event to indicate if the plugin is active or not. */
+HANDLE plugin_active = NULL;
+
+
+/* Return the Outlook main window handle. */
+HWND
+outlook_get_main_window (void)
+{
+    if (!oe_plug)
+	return GetActiveWindow ();
+    return oe_plug->main_wnd;
+}
+
+
 /* Display a warning that the attachments of the mail will be
    sent in cleartext. */
 static void
@@ -68,7 +98,7 @@
 }
 
 
-/* Reset the plugin. */
+/* Reset the plugin state. */
 static void
 plugin_reset (plugin_ctx_t ctx)
 {
@@ -82,6 +112,7 @@
 }
 
 
+/* Release plugin context. */
 static void
 plugin_release (plugin_ctx_t ctx)
 {
@@ -92,6 +123,7 @@
 }
 
 
+/* Create new plugin context. */
 static int
 plugin_new (plugin_ctx_t *r_ctx)
 {    
@@ -119,8 +151,8 @@
                       GetWindowThreadProcessId (main, NULL),
                       FALSE);
 
-    SendMessage (main, WM_COMMAND, MAKEWPARAM (ID_OE5_SELECTALL, 0), 0);
-    SendMessage (main, WM_COMMAND, MAKEWPARAM (ID_OE5_COPY, 0), 0);
+    SendMessage (main, WM_COMMAND, MAKEWPARAM (ID_OE_SELECTALL, 0), 0);
+    SendMessage (main, WM_COMMAND, MAKEWPARAM (ID_OE_COPY, 0), 0);
     
     Sleep (200);
 
@@ -146,14 +178,13 @@
 
 
 /* Check if the attach listview control contains at least one entry.
-   Return 1 if the mail has attachments. */
+   Return the amount of attachments. */
 int
-mail_has_attachments (plugin_ctx_t ctx)
+mail_count_attachments (plugin_ctx_t ctx)
 {
-    HWND attach;
-
-    attach = FindWindowEx (ctx->addr_wnd, NULL, "SysListView32", NULL);
-    return attach && ListView_GetItemCount (attach) > 0;
+    if (!ctx->attach)
+	return 0;
+    return ListView_GetItemCount (ctx->attach);
 }
 
 
@@ -189,6 +220,8 @@
     ctx->cc = NULL;
     ctx->bcc = NULL;
 
+    ctx->attach = FindWindowEx (ctx->addr_wnd, NULL, "SysListView32", NULL);
+
     if (!is_inbox && !window_is_inbox (ctx->to_wnd)) {
         ctx->to = get_address_text (ctx->main_wnd, ctx->to_wnd);
         ctx->cc = get_address_text (ctx->main_wnd, ctx->cc_wnd);
@@ -209,7 +242,7 @@
 }
 
 
-/* Restore the clipboard data. */
+/* Restore the original clipboard data from the plugin context. */
 static void
 restore_clipboard (plugin_ctx_t ctx)
 {
@@ -234,14 +267,24 @@
 
     switch (msg) {
     case WM_CREATE:
-	/* we need to load this lib here otherwise the richedit 
-	   control would not be displayed. */
-	LoadLibrary ("RichEd32.Dll");
+	if (!plugin_preload_done) {
+	    /* we need to load this lib here otherwise the richedit 
+	       control would not be displayed. */
+	    LoadLibrary ("RichEd32.Dll");
+	    setup_gettext();
+	    plugin_active = CreateEvent (NULL, TRUE, /*TRUE*/FALSE, NULL);
+	    plugin_preload_done = 1;
+	}
+	/*
+	else
+	    SetEvent (plugin_active);
+	*/
 	initialized = 0;
 	plugin_new (&oe_plug);
 	break;
 
     case WM_DESTROY:
+	ResetEvent (plugin_active);
 	plugin_release (oe_plug);
 	encr_msg = sign_msg = 0;
 	break;
@@ -258,42 +301,56 @@
 			    _("decrypt/verify: %s\n%s"), 
 			    gpgme_strerror (rc), oe_plug->errbuf);
 	}
-	break;
-    }
+	break;   
 
-    switch (LOWORD (wparam)) {
-    case ID_OE5_PREVMSG:
-    case ID_OE5_NEXTMSG:
-	SetTimer (hwnd, 1, 1000, NULL);
-	break;
+    case WM_COMMAND:
+	switch (LOWORD (wparam)) {
+	case ID_OE_PREVMSG:
+	case ID_OE_NEXTMSG:
+	    SetTimer (hwnd, 1, 1000, NULL);
+	    break;
 
-    case ID_OE5_ENCRYPT:
-        encr_msg ^= 1;
-        break;
+	case ID_OE_CP_UTF8:
+	    oe_plug->use_utf8 = 1;
+	    break;
 
-    case ID_OE5_SIGN:
-        sign_msg ^= 1;
-        break;
+	case ID_OE_CP_WEUROPE_ISO:
+	case ID_OE_CP_WEUROPE_WINCP:
+	case ID_OE_CP_MEUROPE_ISO:
+	case ID_OE_CP_MEUROPE_WINCP:
+	case ID_OE_CP_LATIN9:
+	    oe_plug->use_utf8 = 0;
+	    break;
 
-    case ID_OE5_SEND:
-        if (encr_msg || sign_msg) {
-            plugin_init (oe_plug, hwnd, 0);
-            if (encr_msg) {
-                SendMessage (hwnd, WM_COMMAND, MAKEWPARAM (ID_OE5_ENCRYPT, 0), 0);
-                oe_plug->encrypt = 1;
-            }
-            if (sign_msg) {
-                SendMessage (hwnd, WM_COMMAND, MAKEWPARAM (ID_OE5_SIGN, 0), 0);
-                oe_plug->sign = 1;
-            }
-            rc = oe_handle_mail (oe_plug);
-            if (rc)
-		show_plaintext_warn (hwnd, rc);
-	    restore_clipboard (oe_plug);
-	    if (mail_has_attachments (oe_plug))
-		show_attachment_warn (hwnd);
-        }
-        break;	
+	case ID_OE_ENCRYPT:
+	    encr_msg ^= 1;
+	    break;
+
+	case ID_OE_SIGN:
+	    sign_msg ^= 1;
+	    break;
+
+	case ID_OE_SEND:
+	    if (encr_msg || sign_msg) {
+		plugin_init (oe_plug, hwnd, 0);
+		if (encr_msg) {
+		    SendMessage (hwnd, WM_COMMAND, MAKEWPARAM (ID_OE_ENCRYPT, 0), 0);
+		    oe_plug->encrypt = 1;
+		}
+		if (sign_msg) {
+		    SendMessage (hwnd, WM_COMMAND, MAKEWPARAM (ID_OE_SIGN, 0), 0);
+		    oe_plug->sign = 1;
+		}
+		rc = oe_handle_mail (oe_plug);
+		if (rc)
+		    show_plaintext_warn (hwnd, rc);
+		restore_clipboard (oe_plug);
+		if (mail_count_attachments (oe_plug) > 0)
+		    show_attachment_warn (hwnd);
+	    }
+	    break;
+	}
+	break;
     }
 
     return CallWindowProc (oe_proc_old, hwnd, msg, wparam, lparam);



More information about the Gpgoe-commits mailing list