[Gpgoe-commits] r18 - in trunk: . init po src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Apr 13 09:41:37 CEST 2006


Author: twoaday
Date: 2006-04-13 09:41:30 +0200 (Thu, 13 Apr 2006)
New Revision: 18

Added:
   trunk/init/ChangeLog
   trunk/src/OEMainProc.c
Modified:
   trunk/NEWS
   trunk/configure.ac
   trunk/init/GPGOEInit.c
   trunk/init/init.rc
   trunk/init/resource.h
   trunk/po/POTFILES.in
   trunk/po/de.po
   trunk/po/it.po
   trunk/src/ChangeLog
   trunk/src/GPGOE.c
   trunk/src/GPGOE.def
   trunk/src/GPGOE.h
   trunk/src/OECrypto.c
   trunk/src/OENLS.c
   trunk/src/OEPassphraseCBDlg.c
Log:
Prepare 0.8.1 release.



Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/NEWS	2006-04-13 07:41:30 UTC (rev 18)
@@ -1,3 +1,10 @@
+Noteworthy changes in version 0.8.1 (2006-04-11)
+------------------------------------------------
+
+* Disable all additional features by default because
+  on some systems they are in conflict with other programs.
+  
+
 Noteworthy changes in version 0.8.0 (2006-04-11)
 ------------------------------------------------
 

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/configure.ac	2006-04-13 07:41:30 UTC (rev 18)
@@ -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.8.0, twoaday at freakmail.de)
+AC_INIT(gpgoe, 0.8.1, twoaday at freakmail.de)
 
 NEED_GPGME_API=1
 NEED_GPGME_VERSION=1.1.0

Added: trunk/init/ChangeLog
===================================================================
--- trunk/init/ChangeLog	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/init/ChangeLog	2006-04-13 07:41:30 UTC (rev 18)
@@ -0,0 +1,7 @@
+2006-04-13  Timo Schulz  <twoaday at freakmail.de>
+
+	* GPGOEInit.c (outlook_is_running): New.
+	(put_gpgoe_option, get_gpgoe_option): New.
+	(check_for_conflict_apps): New.
+	(set_menu_state): New.
+	
\ No newline at end of file

Modified: trunk/init/GPGOEInit.c
===================================================================
--- trunk/init/GPGOEInit.c	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/init/GPGOEInit.c	2006-04-13 07:41:30 UTC (rev 18)
@@ -22,49 +22,221 @@
 #include <config.h>
 #endif
 #include <windows.h>
+#include <tlhelp32.h>
+#include <stdio.h>
+#include <ctype.h>
+
 #include "resource.h"
 
-/*-- GPGOE DLL calls --*/
-int gpgoe_initialize (void);
-int gpgoe_remove (void);
 
+/* Supported plug-in modes. */
+enum gpgoe_mode_t {
+    GPGOE_MODE_NORMAL	  = 0,
+    GPGOE_MODE_PLAINREPLY = 1
+};
 
-/* Global hinstance for this module. */
+/* DLL imports. */
+int  gpgoe_initialize (void);
+int  gpgoe_remove (void);
+void gpgoe_set_active_modes (int mode);
+int  gpgoe_get_active_modes (void);
+
+
+/* Global module handle. */
 static HINSTANCE glob_hinst = NULL;
 
+/* String array of programs which are known to cause trouble
+   with GPGoe. */
+static const char *conflict_apps[] = {
+    "DUMMY",	/* dummy entry. */
+    "SPYXX.EXE",
+    NULL
+};
 
-/* Main procedure for the taskbar program. */
+
+/* Enumerate all processes and figure out if a program
+   is running which could be a conflict for gpgoe. */
+static int
+check_for_conflict_apps (void)
+{
+    PROCESSENTRY32 pe;
+    HANDLE hd;
+    BOOL next;
+    int fnd = 0;
+
+    hd = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
+    if (hd == (HANDLE)-1)
+	return 0;
+
+    memset (&pe, 0, sizeof (pe));
+    pe.dwSize = sizeof (pe);
+    next = Process32First (hd, &pe);
+    while (next) {
+	size_t i;
+
+	for (i=0; i < strlen (pe.szExeFile); i++)
+	    pe.szExeFile[i] = (char)toupper ((int)pe.szExeFile[i]);
+	for (i=0; conflict_apps[i] != NULL; i++) {
+	    if (strstr (pe.szExeFile, conflict_apps[i])) {
+		fnd = i;
+		break;
+	    }
+	}
+	next = Process32Next (hd, &pe);
+	if (!next)
+	    break;
+    }
+    CloseHandle (hd);
+    return fnd;
+}
+
+
+/* Return -1 if there was a running instance of OE detected. */
+static int
+outlook_is_running (void)
+{
+    if (!FindWindowEx (NULL, NULL, "Outlook Express Browser Class", NULL))
+	return 0;
+    return -1;
+}
+
+
+/* Set the menu item @muid to the state @state. */
+void
+set_menu_state (HMENU menu, UINT muid, UINT state)
+{	
+    MENUITEMINFO mii;
+
+    memset (&mii, 0, sizeof (mii));
+    mii.cbSize = sizeof (mii);
+    mii.fMask = MIIM_STATE;
+    mii.fState = state;
+    SetMenuItemInfo (menu, muid, FALSE, &mii);
+}
+
+
+/* Get an option with the name @name from the registry. */
+int
+get_gpgoe_option (const char *name)
+{
+    HKEY hkey;
+    LONG err;
+    char val[32];
+    DWORD type = 0, vallen = sizeof (val);
+    
+    err = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\GNU\\GPGoe", 0,
+			KEY_READ, &hkey);
+    if (err != ERROR_SUCCESS)
+	return 0;
+    err = RegQueryValueEx (hkey, name, NULL, &type, (BYTE*)val, &vallen);
+    RegCloseKey (hkey);
+    if (err != ERROR_SUCCESS)
+	return 0;
+    return atoi (val);
+}
+
+
+/* Put an option with the name @name and the value @val in th registry. */
+int
+put_gpgoe_option (const char *name, int val)
+{    
+    HKEY hkey;
+    char buf[32];
+    LONG err;
+
+    sprintf (buf, "%d", val);
+    err = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\GNU\\GPGoe", 0, 
+			KEY_WRITE, &hkey);
+    if (err != ERROR_SUCCESS)
+	return -1;
+    err = RegSetValueEx (hkey, name, 0, REG_SZ, (BYTE *)buf, strlen (buf));
+    RegCloseKey (hkey);
+    return err != ERROR_SUCCESS? -1 : 0;
+}
+
+
+/* Create the GPGoe registry if needed. */
+static int
+create_registry_key (void)
+{
+    HKEY hkey;
+    LONG err;
+
+    err = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\GNU\\GPGoe", 
+			0, KEY_READ, &hkey);
+    if (err == ERROR_SUCCESS) {
+	RegCloseKey (hkey);
+	return 0;
+    }
+    err = RegCreateKey (HKEY_CURRENT_USER, "Software\\GNU\\GPGoe", &hkey);
+    if (err != ERROR_SUCCESS)
+	return -1;
+    RegCloseKey (hkey);
+    return 0;
+}
+
+
+/* Main window procedure for the taskbar program. */
 LRESULT CALLBACK
 gpgoe_main_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 {
+    static int decrypt_replies = 0;
     NOTIFYICONDATA NID;
+    POINT p;
+    HMENU hm, popup;
     int id;
 
     switch (msg) {
     case WM_CREATE:
 	NID.cbSize = sizeof (NID);
-	NID.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;	
+	NID.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
 	NID.uCallbackMessage = WM_USER;
 	NID.hWnd = hwnd;
 	NID.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_GPGOE));
-	strcpy (NID.szTip, "GPG for Outlook Express");
+	strcpy(NID.szTip, "GPG for Outlook Express");
 	Shell_NotifyIcon (NIM_ADD, &NID);
-	DestroyIcon (NID.hIcon);	
+	DestroyIcon (NID.hIcon);
+
+	decrypt_replies = get_gpgoe_option ("PlaintextReply");
+	if (decrypt_replies)
+	    gpgoe_set_active_modes (GPGOE_MODE_PLAINREPLY);
 	if (gpgoe_initialize ()) {
-	    MessageBox (hwnd, "Couldn't register GPG OE hook", 
-			"Error", MB_ICONERROR|MB_OK);
+	    MessageBox (hwnd, "Couldn't register GPG OE hook", "Error", MB_ICONERROR|MB_OK);
 	    ExitProcess (0);
 	}
 	break;
 
     case WM_DESTROY:
     case WM_ENDSESSION:
+	put_gpgoe_option ("PlaintextReply", decrypt_replies);
 	gpgoe_remove ();
 	Shell_NotifyIcon (NIM_DELETE, &NID);
 	PostQuitMessage (0);
 	ExitProcess (0);
         return 0;
 
+    case WM_COMMAND:
+	switch (LOWORD (wparam)) {
+	case ID_INIT_SUPP_PLAINREPLY:
+	    decrypt_replies ^= 1;
+	    if (!decrypt_replies) {
+		int modes = gpgoe_get_active_modes ();
+		gpgoe_set_active_modes (modes & (~GPGOE_MODE_PLAINREPLY));
+	    }
+	    else {
+		gpgoe_set_active_modes (GPGOE_MODE_PLAINREPLY);
+		if (outlook_is_running ())
+		    MessageBox (NULL, "You need to restart Outlook Express.",
+				"GPGOE Information", MB_ICONINFORMATION|MB_OK);
+	    }
+	    break;
+
+	case ID_INIT_QUIT:
+	    SendMessage (hwnd, WM_DESTROY, 0, 0);
+	    break;
+	}
+	break;
+
     case WM_USER:
 	switch (lparam) {
 	case WM_LBUTTONDBLCLK:
@@ -76,37 +248,50 @@
 	    break;
 
 	case WM_RBUTTONUP:
-	    {
-		POINT p;
-		HMENU hm, popup;
-
-		GetCursorPos (&p);
-		hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_INIT));
-		popup = GetSubMenu (hm, 0);
-		TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL);
-		DestroyMenu (popup);
-		DestroyMenu (hm);
-	    }
+	    SetForegroundWindow (hwnd);
+	    GetCursorPos (&p);
+	    hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_INIT));
+	    popup = GetSubMenu (hm, 0);
+	    set_menu_state (popup, ID_INIT_SUPP_PLAINREPLY,
+			    decrypt_replies? MFS_CHECKED : MFS_UNCHECKED);
+	    TrackPopupMenu (popup, TPM_RIGHTALIGN, p.x, p.y, 0, hwnd, NULL);
+	    PostMessage (hwnd, WM_USER, 0, 0);
+	    DestroyMenu (popup);
+	    DestroyMenu (hm);
 	    break;
 	}
 	break;
+    }
 
-	case WM_COMMAND:
-	    if (LOWORD (wparam) == ID_INIT_QUIT)
-		SendMessage (hwnd, WM_DESTROY, 0, 0);
-	    break;
-    }
     return DefWindowProc (hwnd, msg, wparam, lparam);
 }
 
 
+/* Main entry function. */
 int WINAPI
 WinMain (HINSTANCE hinst, HINSTANCE prev, LPSTR cmdline, int cmd_show)
 {
     WNDCLASS wc;
     HWND hwnd;
     MSG msg;
+    int idx;
+    
+    idx = check_for_conflict_apps ();
+    if (idx > 0) {
+	char buf[256];
+	_snprintf (buf, sizeof (buf)-1,
+		    "GPGoe found an instance of a program which\n"
+		    "might be effect the functionality of the plugin.\n"
+		    "\n"
+		    "Name of the process: %s\n"
+		    "\n"
+		    "Continue to load the plug-in?", conflict_apps[idx]);
+	idx = MessageBox (NULL, buf, "GPGOE Warning", MB_ICONWARNING|MB_YESNO);
+	if (idx == IDNO)
+	    return 0;
+    }
 
+    create_registry_key ();
     glob_hinst = hinst;
     CreateMutex (NULL, 1, "GPGOE");
     if (GetLastError () == ERROR_ALREADY_EXISTS)
@@ -117,16 +302,14 @@
     wc.lpszClassName = "GPGOE";
     wc.lpfnWndProc = (WNDPROC)gpgoe_main_proc;
     if (!RegisterClass (&wc)) {
-	MessageBox (NULL, "Couldn't register the window class", 
-		    "Error", MB_ICONERROR|MB_OK);
-	return 1;
+	MessageBox (NULL, "Couldn't register the window class", "Error",
+	    MB_ICONERROR|MB_OK);
+	return 1;	
     }
 
-    hwnd = CreateWindow ("GPGOE", "GPGOE", 0, 0, 0, 0, 0, 
-			 NULL, NULL, hinst, NULL);
+    hwnd = CreateWindow ("GPGOE", "GPGOE", 0, 0, 0, 0, 0, NULL, NULL, hinst, NULL);
     if (!hwnd) {
-	MessageBox (NULL, "Couldn't create window", 
-		    "Error", MB_ICONERROR|MB_OK);
+	MessageBox (NULL, "Couldn't create window", "Error", MB_ICONERROR|MB_OK);
 	return 1;
     }
     UpdateWindow (hwnd);

Modified: trunk/init/init.rc
===================================================================
--- trunk/init/init.rc	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/init/init.rc	2006-04-13 07:41:30 UTC (rev 18)
@@ -66,8 +66,8 @@
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 0,6,0,0
- PRODUCTVERSION 0,6,0,0
+ FILEVERSION 0,8,1,0
+ PRODUCTVERSION 0,8,1,0
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -85,14 +85,14 @@
             VALUE "Comments", "This is free software under the terms of the LGNU GPL v2.1\0"
             VALUE "CompanyName", "\0"
             VALUE "FileDescription", "GPGOE DLL loader\0"
-            VALUE "FileVersion", "0.8.0\0"
+            VALUE "FileVersion", "0.8.1\0"
             VALUE "InternalName", "Init\0"
             VALUE "LegalCopyright", "Copyright ©  2006 Timo Schulz\0"
             VALUE "LegalTrademarks", "\0"
-            VALUE "OriginalFilename", "Init.exe\0"
+            VALUE "OriginalFilename", "GPGOEInit.exe\0"
             VALUE "PrivateBuild", "\0"
             VALUE "ProductName", "GPGOEInit\0"
-            VALUE "ProductVersion", "0.8.0\0"
+            VALUE "ProductVersion", "0.8.1\0"
             VALUE "SpecialBuild", "\0"
         END
     END
@@ -114,6 +114,9 @@
 BEGIN
     POPUP "File"
     BEGIN
+        MENUITEM "Allow to plain text reply",   ID_INIT_SUPP_PLAINREPLY
+        , INACTIVE
+        MENUITEM SEPARATOR
         MENUITEM "Exit",                        ID_INIT_QUIT
     END
 END

Modified: trunk/init/resource.h
===================================================================
--- trunk/init/resource.h	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/init/resource.h	2006-04-13 07:41:30 UTC (rev 18)
@@ -4,15 +4,15 @@
 //
 #define IDR_INIT                        101
 #define IDI_GPGOE                       103
-#define ID_INIT_USEDEFKEY               40001
 #define ID_INIT_QUIT                    40002
+#define ID_INIT_SUPP_PLAINREPLY         40004
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        104
-#define _APS_NEXT_COMMAND_VALUE         40003
+#define _APS_NEXT_COMMAND_VALUE         40005
 #define _APS_NEXT_CONTROL_VALUE         1000
 #define _APS_NEXT_SYMED_VALUE           101
 #endif

Modified: trunk/po/POTFILES.in
===================================================================
--- trunk/po/POTFILES.in	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/po/POTFILES.in	2006-04-13 07:41:30 UTC (rev 18)
@@ -6,4 +6,5 @@
 src/OEMisc.c
 src/OEPassphraseCBDlg.c
 src/OEProc.c
+src/OEMainProc.c
 

Modified: trunk/po/de.po
===================================================================
--- trunk/po/de.po	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/po/de.po	2006-04-13 07:41:30 UTC (rev 18)
@@ -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-04-07 17:36+0200\n"
+"POT-Creation-Date: 2006-04-13 09:33+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,7 +15,7 @@
 "Content-Type: text/plain; charset=iso-8859-1\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: src/OECrypto.c:483
+#: src/OECrypto.c:485
 #, c-format
 msgid ""
 "encrypted with %s key, ID %s\n"
@@ -24,7 +24,7 @@
 "verschlüsselt mit %s Schlüssel, ID %s\n"
 "Entschlüsselung fehlgeschlagen: geheimer Schlüssel nicht gefunden"
 
-#: src/OECrypto.c:489
+#: src/OECrypto.c:491
 #, c-format
 msgid ""
 "encrypted with %d-bit %s key, ID %s\n"
@@ -35,7 +35,7 @@
 "\t\"%s\"\n"
 "Entschlüsselung fehlgeschlagen: geheimer Schlüssel nicht vorhanden"
 
-#: src/OECrypto.c:641
+#: src/OECrypto.c:684
 msgid ""
 "This mail contains one or more public or secret keys.\n"
 "\n"
@@ -45,7 +45,7 @@
 "\n"
 "Bitte speichern Sie die Mail ab und benutzen Sie WinPT zum Import."
 
-#: src/OECrypto.c:643 src/OEPassphraseCBDlg.c:109
+#: src/OECrypto.c:686 src/OEPassphraseCBDlg.c:193
 msgid "GPG Plug-in Info"
 msgstr "GPG Plug-in Information"
 
@@ -65,16 +65,16 @@
 msgid "No keys found in the keyring"
 msgstr "Keine Schlüssel im Schlüsselbund gefunden"
 
-#: src/OEDlgEncrypt.c:161 src/OEProc.c:300
+#: src/OEDlgEncrypt.c:161 src/OEProc.c:277
 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
+#: src/OEDlgEncrypt.c:164 src/OEDlgVerify.c:146 src/OEDlgViewer.c:61
+#: src/OEPassphraseCBDlg.c:152
 msgid "&OK"
 msgstr "&OK"
 
-#: src/OEDlgEncrypt.c:165 src/OEPassphraseCBDlg.c:82
+#: src/OEDlgEncrypt.c:165 src/OEPassphraseCBDlg.c:153
 msgid "&Cancel"
 msgstr "&Abbrechen"
 
@@ -155,19 +155,19 @@
 msgid "Signature Verification"
 msgstr "Überprüfung der Signatur"
 
-#: src/OEDlgViewer.c:86
+#: src/OEDlgViewer.c:59
 msgid "&Copy"
 msgstr "&Kopieren"
 
-#: src/OEDlgViewer.c:87
+#: src/OEDlgViewer.c:60
 msgid "&Quote"
 msgstr "&Quote"
 
-#: src/OEDlgViewer.c:89
+#: src/OEDlgViewer.c:62
 msgid "Message Viewer"
 msgstr "Betracher für Nachrichten"
 
-#: src/OEPassphraseCBDlg.c:75
+#: src/OEPassphraseCBDlg.c:146
 #, c-format
 msgid ""
 "%s\n"
@@ -176,20 +176,24 @@
 "%s\n"
 "%s Schlüssel, ID %s"
 
-#: src/OEPassphraseCBDlg.c:83 src/OEPassphraseCBDlg.c:104
-#: src/OEPassphraseCBDlg.c:108
+#: src/OEPassphraseCBDlg.c:154 src/OEPassphraseCBDlg.c:188
+#: src/OEPassphraseCBDlg.c:192
 msgid "Please enter your passphrase"
 msgstr "Bitte geben Sie ihre Passphrase ein"
 
-#: src/OEPassphraseCBDlg.c:86
+#: src/OEPassphraseCBDlg.c:158
+msgid "&Hide typing"
+msgstr "&Maskiere Eingabe"
+
+#: src/OEPassphraseCBDlg.c:159
 msgid "Decryption"
 msgstr "Entschlüsselung"
 
-#: src/OEPassphraseCBDlg.c:101
+#: src/OEPassphraseCBDlg.c:185
 msgid "Invalid passphrase; please enter your passphrase again"
 msgstr "Ungültige Passphrase; Bitte geben Sie die Passphrase erneut ein"
 
-#: src/OEProc.c:77
+#: src/OEProc.c:69
 msgid ""
 "GPGOE is unable to secure attachments.\r\n"
 "As a result the data attached to this mail is NOT encrypted."
@@ -197,11 +201,11 @@
 "GPGOE kann keine Anhänge sichern.\r\n"
 "Als eine Konsequzenz daraus, werden diese NICHT verschlüsselt."
 
-#: src/OEProc.c:79 src/OEProc.c:96
+#: src/OEProc.c:71 src/OEProc.c:88
 msgid "GPG Plug-in Warning"
 msgstr "GPG Plug-in Warnung"
 
-#: src/OEProc.c:91
+#: src/OEProc.c:83
 #, c-format
 msgid ""
 "WARNING: This message will be sent in cleartext.\r\n"
@@ -211,7 +215,7 @@
 "WARNUNG: Diese Nachricht wird im Klartext versendet.\r\n"
 "%s"
 
-#: src/OEProc.c:301
+#: src/OEProc.c:278
 #, c-format
 msgid ""
 "decrypt/verify: %s\n"

Modified: trunk/po/it.po
===================================================================
--- trunk/po/it.po	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/po/it.po	2006-04-13 07:41:30 UTC (rev 18)
@@ -5,7 +5,7 @@
 msgstr ""
 "Project-Id-Version: GPGoe 0.7.0\n"
 "Report-Msgid-Bugs-To: winpt at freakmail.de\n"
-"POT-Creation-Date: 2006-04-07 17:36+0200\n"
+"POT-Creation-Date: 2006-04-13 09:33+0200\n"
 "PO-Revision-Date: 2006-04-08 13:19+0100\n"
 "Last-Translator: Scire' Salvatore <salvatore.scire at fastwebnet.it>\n"
 "Language-Team: \n"
@@ -13,7 +13,7 @@
 "Content-Type: text/plain; charset=iso-8859-1\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: src/OECrypto.c:483
+#: src/OECrypto.c:485
 #, c-format
 msgid ""
 "encrypted with %s key, ID %s\n"
@@ -22,7 +22,7 @@
 "cifrata con chiave %s , ID %s\n"
 "decifratura fallita: chiave segreta non disponibile"
 
-#: src/OECrypto.c:489
+#: src/OECrypto.c:491
 #, c-format
 msgid ""
 "encrypted with %d-bit %s key, ID %s\n"
@@ -33,7 +33,7 @@
 "\t\"%s\"\n"
 "decifratura fallita: chiave segreta non disponibile"
 
-#: src/OECrypto.c:641
+#: src/OECrypto.c:684
 msgid ""
 "This mail contains one or more public or secret keys.\n"
 "\n"
@@ -43,7 +43,7 @@
 "\n"
 "Salva il testo della mail in un file al fine di usare  WinPT per importarlo."
 
-#: src/OECrypto.c:643 src/OEPassphraseCBDlg.c:109
+#: src/OECrypto.c:686 src/OEPassphraseCBDlg.c:193
 msgid "GPG Plug-in Info"
 msgstr "Info su GPG Plug-in "
 
@@ -63,16 +63,16 @@
 msgid "No keys found in the keyring"
 msgstr "Nessuna chiave trovata nel portachiavi"
 
-#: src/OEDlgEncrypt.c:161 src/OEProc.c:300
+#: src/OEDlgEncrypt.c:161 src/OEProc.c:277
 msgid "GPG Plug-in Error"
 msgstr "Errore di GPG Plug-in"
 
-#: src/OEDlgEncrypt.c:164 src/OEDlgVerify.c:146 src/OEDlgViewer.c:88
-#: src/OEPassphraseCBDlg.c:81
+#: src/OEDlgEncrypt.c:164 src/OEDlgVerify.c:146 src/OEDlgViewer.c:61
+#: src/OEPassphraseCBDlg.c:152
 msgid "&OK"
 msgstr "&OK"
 
-#: src/OEDlgEncrypt.c:165 src/OEPassphraseCBDlg.c:82
+#: src/OEDlgEncrypt.c:165 src/OEPassphraseCBDlg.c:153
 msgid "&Cancel"
 msgstr "&Annulla"
 
@@ -154,19 +154,19 @@
 msgid "Signature Verification"
 msgstr "Verifica della Firma "
 
-#: src/OEDlgViewer.c:86
+#: src/OEDlgViewer.c:59
 msgid "&Copy"
 msgstr "&Copia"
 
-#: src/OEDlgViewer.c:87
+#: src/OEDlgViewer.c:60
 msgid "&Quote"
 msgstr "&Quote"
 
-#: src/OEDlgViewer.c:89
+#: src/OEDlgViewer.c:62
 msgid "Message Viewer"
 msgstr "Visualizzatore Messaggio "
 
-#: src/OEPassphraseCBDlg.c:75
+#: src/OEPassphraseCBDlg.c:146
 #, c-format
 msgid ""
 "%s\n"
@@ -175,20 +175,24 @@
 "%s\n"
 "%s key, ID %s"
 
-#: src/OEPassphraseCBDlg.c:83 src/OEPassphraseCBDlg.c:104
-#: src/OEPassphraseCBDlg.c:108
+#: src/OEPassphraseCBDlg.c:154 src/OEPassphraseCBDlg.c:188
+#: src/OEPassphraseCBDlg.c:192
 msgid "Please enter your passphrase"
 msgstr "Immetti la tua passphrase"
 
-#: src/OEPassphraseCBDlg.c:86
+#: src/OEPassphraseCBDlg.c:158
+msgid "&Hide typing"
+msgstr ""
+
+#: src/OEPassphraseCBDlg.c:159
 msgid "Decryption"
 msgstr "Decifratura"
 
-#: src/OEPassphraseCBDlg.c:101
+#: src/OEPassphraseCBDlg.c:185
 msgid "Invalid passphrase; please enter your passphrase again"
 msgstr "Passphrase non corretta; immetti la tua passphrase di nuovo"
 
-#: src/OEProc.c:77
+#: src/OEProc.c:69
 msgid ""
 "GPGOE is unable to secure attachments.\r\n"
 "As a result the data attached to this mail is NOT encrypted."
@@ -196,11 +200,11 @@
 "GPGOE non può gestire la sicurezza degli allegati.\r\n"
 "Per tale motivo gli allegati di questo messaggio NON sono cifrati."
 
-#: src/OEProc.c:79 src/OEProc.c:96
+#: src/OEProc.c:71 src/OEProc.c:88
 msgid "GPG Plug-in Warning"
 msgstr "Avviso GPG Plug-in"
 
-#: src/OEProc.c:91
+#: src/OEProc.c:83
 #, c-format
 msgid ""
 "WARNING: This message will be sent in cleartext.\r\n"
@@ -211,7 +215,7 @@
 "\r\n"
 "Descrizione dell'errore: %s."
 
-#: src/OEProc.c:301
+#: src/OEProc.c:278
 #, c-format
 msgid ""
 "decrypt/verify: %s\n"

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/src/ChangeLog	2006-04-13 07:41:30 UTC (rev 18)
@@ -1,3 +1,10 @@
+2006-04-13  Timo Schulz  <twoaday at freakmail.de>
+
+	* OEPassphraseCBDlg.c (pass_cb_dlg_proc): Support 'hide typing'.
+	(pass_cb_cancelled): New.
+	* GPGOE.c (gpgoe_get_active_modes): New.
+	(gpgoe_set_active_modes): New.
+	
 2003-03-27  Timo Schulz  <twoaday at freakmail.de>
 
 	* OECrypto.c (sign_msg, encrypt_msg, decrypt_msg): Uniform

Modified: trunk/src/GPGOE.c
===================================================================
--- trunk/src/GPGOE.c	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/src/GPGOE.c	2006-04-13 07:41:30 UTC (rev 18)
@@ -39,7 +39,28 @@
 /* Outlook Express window handle. */
 static HWND oe_hwnd = NULL;
 
+/* We need a shared section to define variables which
+   will keep their values in all address spaces. */
+#ifdef __GNUC__
+#define ATTR_SEC __attribute__((section (".SHARDAT"), shared))
+#else
+#define ATTR_SEC
+#pragma data_seg(".SHARDAT")
+#endif
+static int gpgoe_active_modes ATTR_SEC = 0;
+#ifndef __GNUC__
+#pragma data_seg()
+#endif
+#undef ATTR_SEC
 
+
+/* Supported plug-in modes. */
+enum gpgoe_mode_t {
+    GPGOE_MODE_NORMAL	  = 0,
+    GPGOE_MODE_PLAINREPLY = 1	   /* decrypt mails before a reply. */
+};
+
+
 /* Main DLL entry point. */
 BOOL WINAPI
 DllMain (HINSTANCE hinst_dll, DWORD reason, LPVOID reserved)
@@ -112,7 +133,8 @@
 		oe_hwnd = hwnd;
         }
 
-	if (!strcmp (wclass, "Outlook Express Browser Class")) {
+	if ((gpgoe_active_modes & GPGOE_MODE_PLAINREPLY) &&
+	    !strcmp (wclass, "Outlook Express Browser Class")) {
 	    oe_main_proc_old = (WNDPROC)GetWindowLong (hwnd, GWL_WNDPROC);
 	    if (!oe_main_proc_old)
 		show_error (NULL, "GPGOE", MB_ICONERROR|MB_OK,
@@ -125,8 +147,8 @@
 	}
 	break;
 
+#if 0
     case HCBT_ACTIVATE:
-#if 0
 	if (plugin_active != NULL && 
 	    WaitForSingleObject (plugin_active, 0) == WAIT_OBJECT_0) {
 	    char wclass[200];
@@ -137,8 +159,8 @@
 	    of_proc_old = (WNDPROC)GetWindowLong (hwnd, GWL_WNDPROC);
 	    SetWindowLong (hwnd, GWL_WNDPROC, (LONG)(WNDPROC)of_proc);
 	}
-#endif
 	break;
+#endif	
     }	
     return CallNextHookEx (ctb_hook, code, wparam, lparam);
 }
@@ -175,3 +197,19 @@
     rc = UnhookWindowsHookEx (ctb_hook);
     return rc ? 0 : (int)GetLastError ();
 }
+
+
+/* Change the active plug-in modes, enable mode @mode. */
+void
+gpgoe_set_active_modes (int mode)
+{
+    gpgoe_active_modes = mode;
+}
+
+
+int
+gpgoe_get_active_modes (void)
+{
+    return gpgoe_active_modes;
+}
+

Modified: trunk/src/GPGOE.def
===================================================================
--- trunk/src/GPGOE.def	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/src/GPGOE.def	2006-04-13 07:41:30 UTC (rev 18)
@@ -1,8 +1,13 @@
 LIBRARY GPGOE
 DESCRIPTION 'GPGoe - GPG Plugin for Outlook Express'
+;SECTIONS
+;	.SHARDAT READ WRITE SHARED
 
 EXPORTS
 	gpgoe_initialize			@1
 	gpgoe_remove				@2
+	gpgoe_set_active_modes		@3
+	gpgoe_get_active_modes		@4
 
 
+

Modified: trunk/src/GPGOE.h
===================================================================
--- trunk/src/GPGOE.h	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/src/GPGOE.h	2006-04-13 07:41:30 UTC (rev 18)
@@ -151,6 +151,7 @@
 			     int prev_was_bad, int fd);
 void free_pass_cb (pass_cb_t cb);
 pass_cb_t new_pass_cb (HWND main);
+int pass_cb_cancelled (pass_cb_t cb);
 void free_pass_cache (void);
 
 /*-- OENLS.c --*/

Modified: trunk/src/OECrypto.c
===================================================================
--- trunk/src/OECrypto.c	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/src/OECrypto.c	2006-04-13 07:41:30 UTC (rev 18)
@@ -353,6 +353,7 @@
     gpgme_ctx_t gctx;
     gpgme_data_t in, out;
     pass_cb_t cb_val;
+    int cancel;
 
     cb_val = new_pass_cb (ctx->main_wnd);
 
@@ -366,16 +367,18 @@
 	err = gpgme_op_sign (gctx, in, out, GPGME_SIG_MODE_CLEAR);
     }
 
+    cancel = pass_cb_cancelled (cb_val);
+
     gpgme_release (gctx);
     gpgme_data_release (in);
     free_pass_cb (cb_val);
 
-    if (err)
+    if (err || cancel)
 	gpgme_data_release (out);
     else
 	map_gpgme_data (out, r_msg);
 
-    return err;
+    return cancel? 0 : err;
 }
 
 
@@ -389,6 +392,7 @@
     gpgme_key_t *keys;
     pass_cb_t cb_val;
     recip_list_t list = NULL;
+    int cancel;
 
     err = get_keys (ctx, &list, &keys);
     if (err)
@@ -409,17 +413,19 @@
 				     in, out);
     }
 
+    cancel = pass_cb_cancelled (cb_val);
+
     gpgme_release (gctx);
     gpgme_data_release (in);
     release_recipient (list);
     free_if_alloc (keys);
     free_pass_cb (cb_val);
 
-    if (err)
+    if (err || cancel)
 	gpgme_data_release (out);
     else
 	map_gpgme_data (out, r_msg);
-    return err;
+    return cancel? 0 : err;
 }
 
 
@@ -504,6 +510,7 @@
     gpgme_data_t in = NULL, out = NULL;
     gpgme_error_t err;
     pass_cb_t cb_val;
+    int cancel;
     char *msg = *r_msg;
 
     cb_val = new_pass_cb (main_wnd);
@@ -517,23 +524,25 @@
 	err = gpgme_op_decrypt (gctx, in, out);
     }
 
+    cancel = pass_cb_cancelled (cb_val);	
+
     gpgme_release (gctx);
     gpgme_data_release (in);
     free_pass_cb (cb_val);
     
-    if (err)
+    if (err || cancel)
 	gpgme_data_release (out);
     else
 	map_gpgme_data (out, r_msg);
 
-    return err;
+    return cancel? 0 : err;
 }
 
 
 /* Decrypt the message @r_msg. If the type @type is actually a signature,
    the verify function is called instead of decryption. */
 static gpgme_error_t
-decrypt_msg (plugin_ctx_t ctx, char **r_msg, int type)
+decrypt_msg (plugin_ctx_t ctx, char **r_msg, int type, int *r_cancel)
 {
     gpgme_ctx_t gctx = NULL;
     gpgme_data_t in = NULL, out = NULL;
@@ -560,7 +569,9 @@
 	    DialogBoxParam (mod_hinst_dll, (LPCTSTR)IDD_VERIFY, ctx->main_wnd,
 			    verify_dlg_proc, (LPARAM)res->signatures);
     }
-    if (err) {
+    *r_cancel = pass_cb_cancelled (cb_val);
+
+    if (!*r_cancel && err) {
 	gpgme_decrypt_result_t r = gpgme_op_decrypt_result (gctx);
 	store_decrypt_info (ctx->errbuf, sizeof (ctx->errbuf)-1, r);
     }
@@ -569,12 +580,12 @@
     gpgme_data_release (in);
     free_pass_cb (cb_val);
     
-    if (err)
+    if (err || *r_cancel)
 	gpgme_data_release (out);
     else
 	map_gpgme_data (out, r_msg);
 
-    return err;
+    return *r_cancel? 0 : err;
 }
 
 
@@ -646,6 +657,7 @@
     gpgme_error_t rc = 0;
     char *msg;
     int msg_type = 0;
+    int cancel;
 
     assert (ctx);
 
@@ -674,10 +686,11 @@
                       _("GPG Plug-in Info"), MB_ICONINFORMATION|MB_OK);
     }
     else if (msg_type) {
-        rc = decrypt_msg (ctx, &msg, msg_type);
+        rc = decrypt_msg (ctx, &msg, msg_type, &cancel);
         SendMessage (ctx->msg_wnd, WM_CLEAR, 0, 0);
         SendMessage (ctx->msg_wnd, WM_UNDO, 0, 0);
-	if (!rc && (msg_type & PGP_MESSAGE) && msg && strlen (msg) > 0) {
+	if (!cancel && !rc && (msg_type & PGP_MESSAGE) 
+	    && msg && strlen (msg) > 0) {
 	    struct viewer_ctx_s viewer;
 	    viewer.msg = msg;
 	    viewer.main_wnd = ctx->main_wnd;

Added: trunk/src/OEMainProc.c
===================================================================
--- trunk/src/OEMainProc.c	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/src/OEMainProc.c	2006-04-13 07:41:30 UTC (rev 18)
@@ -0,0 +1,147 @@
+/* OEMainProc.c - window procedure for the main window
+ *	 Copyright (C) 2006 Timo Schulz
+ *
+ * This file is part of GPGOE.
+ *
+ * GPGOE 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.1 of the License, or
+ * (at your option) any later version.
+ * 
+ * GPGOE 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 GPGOE; if not, write to the Free Software Foundation, 
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <windows.h>
+#include <stdio.h>
+
+#include "gpgme.h"
+#include "GPGOE.h"
+
+
+/* Outlook symbolic command IDs. */
+#define ID_OE_REPLY	40176
+#define ID_OE_REPLY_ALL 40177
+
+/* Original window procedure of the main window. */
+WNDPROC oe_main_proc_old;
+
+
+/* Move the keyboard focus to the message window 
+   to copy the text to the clipboard. */
+static HWND
+set_focus (int is_main_wnd)
+{	
+    HWND brows, msgv, doc, mime, msg;
+
+    if (is_main_wnd) {
+	brows = FindWindowEx (NULL, NULL, "Outlook Express Browser Class", NULL);
+	msgv = FindWindowEx (brows, NULL, "Outlook Express Message View", NULL);
+    }
+    else {	
+	msgv = FindWindowEx (NULL, NULL, "ATH_Note", NULL);
+	brows = msgv;
+    }
+    doc = FindWindowEx (msgv, NULL, "ME_DocHost", NULL );
+    mime = FindWindowEx (doc, NULL, "##MimeEdit_Server", NULL);
+    msg = FindWindowEx (mime, NULL, "Internet Explorer_Server", NULL);
+
+    SetForegroundWindow (brows);
+
+    AttachThreadInput (GetCurrentThreadId (),
+                       GetWindowThreadProcessId (brows, NULL),
+                       TRUE);
+
+    SetFocus (brows);
+    SetFocus (msg);
+    SetFocus (doc);
+    SetFocus (mime);
+    SetFocus (msg);
+
+    AttachThreadInput (GetCurrentThreadId (),
+                       GetWindowThreadProcessId (brows, NULL),
+                       FALSE);
+
+    return brows;
+}
+
+
+/* Copy body of the current message to the clipboard and then return 
+   the clipboard data (which is the message). */
+static char*
+get_current_message (void)
+{
+    HWND main_hwnd;
+
+    main_hwnd = set_focus (1);
+    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);
+    return get_clip_text (NULL);
+}
+
+
+/* Paste the quoted message text @body into the reply message window. */
+static void
+paste_quoted_text (const char *body)
+{
+    HWND msg_hwnd;
+
+    set_clip_text (NULL, body, strlen (body));
+    msg_hwnd = set_focus (0);
+    SetForegroundWindow (msg_hwnd);
+    SendMessage (msg_hwnd, WM_COMMAND, MAKEWPARAM (ID_OE_SELECTALL, 0), 0);
+    SendMessage (msg_hwnd, WM_COMMAND, MAKEWPARAM (ID_OE_PASTE, 0), 0);
+}
+
+
+/* Subclass dialog procedure for the outlook main window. */
+LRESULT CALLBACK
+oe_main_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+    static int timer = 0;
+    static char *body = NULL;
+    char *tmp;
+
+    switch (msg) {
+    case WM_DESTROY:
+	/*free_pass_cache ();*/
+	break;
+
+    case WM_COMMAND:
+	switch (LOWORD (wparam)) {
+	case ID_OE_REPLY:
+	case ID_OE_REPLY_ALL:
+	    tmp = get_current_message ();
+	    if (!tmp || !strstr (tmp, "BEGIN PGP MESSAGE")) {
+		xfree (tmp);
+		break;
+	    }
+	    if (oe_decrypt_msg (hwnd, &tmp)) {
+		xfree (tmp);
+		break;
+	    }
+	    quote_msg_text (tmp, &body);
+	    xfree (tmp);
+	    timer = SetTimer (hwnd, 1, 1000, NULL);
+	    break;
+	}
+	break;
+
+    case WM_TIMER:
+	KillTimer (hwnd, timer);
+	paste_quoted_text (body);
+	xfree (body); body = NULL;
+	break;
+    }
+
+    return CallWindowProc (oe_main_proc_old, hwnd, msg, wparam, lparam);
+}

Modified: trunk/src/OENLS.c
===================================================================
--- trunk/src/OENLS.c	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/src/OENLS.c	2006-04-13 07:41:30 UTC (rev 18)
@@ -91,18 +91,6 @@
 }
 
 
-/* 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)
 {

Modified: trunk/src/OEPassphraseCBDlg.c
===================================================================
--- trunk/src/OEPassphraseCBDlg.c	2006-04-11 19:05:05 UTC (rev 17)
+++ trunk/src/OEPassphraseCBDlg.c	2006-04-13 07:41:30 UTC (rev 18)
@@ -155,6 +155,7 @@
 	SendDlgItemMessage (dlg, IDC_DECRYPT_PWD, EM_SETPASSWORDCHAR, 
 			    (WPARAM)(UINT)'*', 0);
 	CheckDlgButton (dlg, IDC_DECRYPT_HIDE, BST_CHECKED);
+	SetDlgItemText (dlg, IDC_DECRYPT_HIDE, _("&Hide typing"));
 	SetWindowText (dlg, _("Decryption"));
 	SetForegroundWindow (dlg);
 	center_window (dlg, ctx->main_wnd);
@@ -272,6 +273,13 @@
 }
 
 
+int
+pass_cb_cancelled (pass_cb_t cb)
+{
+    return cb->cancel;
+}
+
+
 /* Release the passphrase cache. */
 void
 free_pass_cache (void)



More information about the Gpgoe-commits mailing list