[Gpgoe-commits] r11 - in trunk: . doc src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Apr 3 19:10:19 CEST 2006
Author: twoaday
Date: 2006-04-03 19:10:15 +0200 (Mon, 03 Apr 2006)
New Revision: 11
Modified:
trunk/Makefile.am
trunk/NEWS
trunk/configure.ac
trunk/doc/Makefile.am
trunk/src/GPGOE.h
trunk/src/GPGOE.rc
trunk/src/OECrypto.c
trunk/src/OEDlgEncrypt.c
trunk/src/OEDlgVerify.c
trunk/src/OEDlgViewer.c
trunk/src/OEPassphraseCBDlg.c
trunk/src/OEProc.c
trunk/src/resource.h
Log:
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/Makefile.am 2006-04-03 17:10:15 UTC (rev 11)
@@ -9,6 +9,6 @@
EXTRA_DIST = autogen.sh GPGOE.dsp GPGOE.dsw
-SUBDIRS = po src m4 init doc
+SUBDIRS = src m4 init doc #po
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/NEWS 2006-04-03 17:10:15 UTC (rev 11)
@@ -1,6 +1,10 @@
-Noteworthy changes in version 0.6.0 (unreleased)
+Noteworthy changes in version 0.6.1 (unreleased)
------------------------------------------------
+
+Noteworthy changes in version 0.6.0 (2006-04-02)
+------------------------------------------------
+
* Rewrote much of the internal plug-in code.
* Correct UTF8 support.
* Sign+Encrypt does now really work.
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/configure.ac 2006-04-03 17:10:15 UTC (rev 11)
@@ -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.0-cvs, twoaday at freakmail.de)
+AC_INIT(gpgoe, 0.6.1-cvs, 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
@@ -184,7 +184,6 @@
AC_CONFIG_FILES([ Makefile
src/Makefile
-po/Makefile.in
m4/Makefile
init/Makefile
doc/Makefile
Modified: trunk/doc/Makefile.am
===================================================================
--- trunk/doc/Makefile.am 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/doc/Makefile.am 2006-04-03 17:10:15 UTC (rev 11)
@@ -1,3 +1,4 @@
+# implement check if tex env is available
EXTRA_DIST = gpgoe.texi
@@ -3,14 +4,14 @@
AUTOMAKE_OPTIONS = no-texinfo.tex
-info_TEXINFOS = gpgoe.texi
-
-pkgdata_DATA = gpgoe.pdf
-
-BUILT_SOURCES = gpgoe.pdf
-
-gpgoe.pdf:
- texi2pdf --clean gpgoe.texi
-
-clean:
- rm -f gpgoe.pdf
- rm -f GPGOE
+#info_TEXINFOS = gpgoe.texi
+#
+#pkgdata_DATA = gpgoe.pdf
+#
+#BUILT_SOURCES = gpgoe.pdf
+#
+#gpgoe.pdf:
+# texi2pdf --clean gpgoe.texi
+#
+#clean:
+# rm -f gpgoe.pdf
+# rm -f GPGOE
Modified: trunk/src/GPGOE.h
===================================================================
--- trunk/src/GPGOE.h 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/src/GPGOE.h 2006-04-03 17:10:15 UTC (rev 11)
@@ -21,20 +21,16 @@
#ifndef GPGOE_H
#define GPGOE_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* dummy until gettext support is finished. */
#define _(X) (X)
#include <malloc.h>
/* wrapper around free. */
#define free_if_alloc(ptr) \
- do { \
+do { \
if (ptr) free (ptr); \
ptr = NULL; \
- } while (0)
+} while (0)
/* Wrapper for memory deallocation but overwrite the buffer before.
@@ -61,14 +57,7 @@
#define OF_IDOK 1
#define OF_IDFILE 1152
-/* Config dialog id's */
-#define ID_OE5_CFGENCRYPT 1053
-#define ID_OE5_CFGSIGN 1052
-#define ID_OE5_CFGDETAILS 2118
-#define ID_OE5_CFGUID 2112
-#define ID_OE5_UIDREQ 2117
-
/* Context for the recipient list. */
struct recip_list_s {
struct recip_list_s *next;
@@ -88,6 +77,7 @@
int encrypt;
recip_list_t rset;
char errbuf[256];
+ char *orig_text;
};
typedef struct plugin_ctx_s *plugin_ctx_t;
@@ -98,15 +88,15 @@
typedef struct viewer_ctx_s *viewer_ctx_t;
+/*-- GPGOE.c --*/
+/*EXPORT*/ int gpgoe_initialize (void);
+/*EXPORT*/ int gpgoe_remove (void);
+
/*-- OEProc.c --*/
extern HINSTANCE mod_hinst_dll;
extern WNDPROC oe_proc_old;
LRESULT CALLBACK oe_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
-/*-- GPGOE.c --*/
-int gpgoe_initialize (void);
-int gpgoe_remove (void);
-
/*-- OECrypto.c --*/
gpgme_error_t oe_handle_mail (plugin_ctx_t ctx);
@@ -126,9 +116,8 @@
LPARAM lparam);
BOOL CALLBACK verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam,
LPARAM lparam);
-BOOL CALLBACK pass_cb_dlg_proc (HWND dlg, UINT msg, WPARAM wparam,
- LPARAM lparam);
+/* Opaque passphrase callback handle. */
struct pass_cb_s;
typedef struct pass_cb_s *pass_cb_t;
@@ -139,8 +128,4 @@
void free_pass_cb (pass_cb_t cb);
pass_cb_t new_pass_cb (HWND main);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GPGOE_H */
Modified: trunk/src/GPGOE.rc
===================================================================
--- trunk/src/GPGOE.rc 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/src/GPGOE.rc 2006-04-03 17:10:15 UTC (rev 11)
@@ -144,20 +144,21 @@
CAPTION "Message Viewer"
FONT 8, "MS Sans Serif"
BEGIN
- EDITTEXT IDC_VIEWER_TEXT,8,6,288,140,ES_MULTILINE |
- ES_AUTOVSCROLL | ES_WANTRETURN
- PUSHBUTTON "&Quote",IDC_VIEWER_QUOTE,8,150,54,14
+ PUSHBUTTON "&Quote",IDC_VIEWER_QUOTE,8,150,54,14,WS_DISABLED
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,
+ 293,137
END
-IDD_VERIFY DIALOG DISCARDABLE 0, 0, 266, 61
+IDD_VERIFY DIALOG DISCARDABLE 0, 0, 266, 68
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Verification"
FONT 8, "MS Sans Serif"
BEGIN
- DEFPUSHBUTTON "&OK",IDOK,107,38,50,14
- EDITTEXT IDC_VERIFY_STATUS,5,6,247,27,ES_MULTILINE |
+ DEFPUSHBUTTON "&OK",IDOK,107,47,50,14
+ EDITTEXT IDC_VERIFY_STATUS,5,6,247,33,ES_MULTILINE |
ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN
END
@@ -199,7 +200,7 @@
LEFTMARGIN, 3
RIGHTMARGIN, 259
TOPMARGIN, 3
- BOTTOMMARGIN, 54
+ BOTTOMMARGIN, 61
END
END
#endif // APSTUDIO_INVOKED
Modified: trunk/src/OECrypto.c
===================================================================
--- trunk/src/OECrypto.c 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/src/OECrypto.c 2006-04-03 17:10:15 UTC (rev 11)
@@ -559,7 +559,7 @@
int msg_type = 0;
assert (ctx);
-
+
msg = window_get_message (ctx->main_wnd);
if (!msg || strlen (msg) == 2) {
free_if_alloc (msg);
@@ -587,7 +587,7 @@
viewer_dlg_proc, (LPARAM)&viewer);
}
}
- else {
+ else if (ctx->sign || ctx->encrypt) {
if (!ctx->to && !ctx->cc && !ctx->bcc) {
free_if_alloc (msg);
return gpg_error (GPG_ERR_NO_DATA);
Modified: trunk/src/OEDlgEncrypt.c
===================================================================
--- trunk/src/OEDlgEncrypt.c 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/src/OEDlgEncrypt.c 2006-04-03 17:10:15 UTC (rev 11)
@@ -118,12 +118,13 @@
/* Load the keylist in the list view @ctl. */
-static void
+static int
keylist_load (HWND ctl)
{
gpgme_ctx_t ctx;
gpgme_key_t key;
gpgme_error_t err;
+ int nkeys = 0;
ListView_SetExtendedListViewStyle(ctl, LVS_EX_FULLROWSELECT);
ListView_SetExtendedListViewStyle(ctl, LVS_EX_CHECKBOXES);
@@ -133,15 +134,17 @@
err = gpgme_new (&ctx);
if (err)
- return;
+ return 0;
err = gpgme_op_keylist_start (ctx, NULL, 0);
while (!err) {
err = gpgme_op_keylist_next (ctx, &key);
if (err)
break;
listview_add_key_item (ctl, key);
+ nkeys++;
}
gpgme_release (ctx);
+ return nkeys;
}
@@ -153,7 +156,11 @@
recip_list_t t;
lb = GetDlgItem (dlg, IDC_ENCRYPT_KEYLIST);
- keylist_load (lb);
+ if (keylist_load (lb) == 0) {
+ MessageBox (dlg, _("No keys found in the keyring"),
+ _("GPG Plug-in Error"), MB_ICONERROR|MB_OK);
+ EndDialog (dlg, 0);
+ }
SetDlgItemText (dlg, IDC_ENCRYPT_RECPMSG, _("Recipients which were NOT found"));
lb = GetDlgItem (dlg, IDC_ENCRYPT_INVLIST);
@@ -183,9 +190,6 @@
assert (ctx);
on_init_dialog (dlg, msg, wparam, lparam);
return TRUE;
-
- case WM_DESTROY:
- return FALSE;
case WM_NOTIFY:
notify = (NMHDR *)lparam;
Modified: trunk/src/OEDlgVerify.c
===================================================================
--- trunk/src/OEDlgVerify.c 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/src/OEDlgVerify.c 2006-04-03 17:10:15 UTC (rev 11)
@@ -48,17 +48,36 @@
}
+/* Return human readable description of the validity. */
+const char*
+get_key_validity (gpgme_signature_t sig)
+{
+ const char *valid;
+
+ switch (sig->validity) {
+ case GPGME_VALIDITY_UNKNOWN:
+ case GPGME_VALIDITY_UNDEFINED: valid = _("undefined"); break;
+ case GPGME_VALIDITY_NEVER: valid = _("NEVER"); break;
+ case GPGME_VALIDITY_MARGINAL: valid = _("marginal"); break;
+ case GPGME_VALIDITY_FULL:
+ case GPGME_VALIDITY_ULTIMATE: valid = _("full"); break;
+ default: valid = _("undefined"); break;
+ }
+
+ return valid;
+}
+
/* Return a humand readable description for the signature status @sum. */
const char*
-get_gpg_sigstat (gpgme_signature_t sig)
+get_sigstat (gpgme_signature_t sig)
{
const char *gpg_sigstat[] = {
_("Invalid signature"),
_("Good signature"),
_("BAD signature"),
+ _("Can't check signature: key not found."),
_("Invalid signature"),
_("Invalid signature"),
- _("Invalid signature"),
_("Good signature (Expired Key)"),
_("Good signature (Revoked Key)"),
NULL
@@ -71,9 +90,9 @@
}
-/* Put all signature information into the buffer @buffer. */
+/* Create human readable signature information. */
static void
-sig_get_info_buffer (gpgme_signature_t sig, char *buffer, DWORD buflen)
+set_sig_info (HWND dlg, gpgme_signature_t sig)
{
gpgme_key_t key = NULL;
gpgme_ctx_t gctx = NULL;
@@ -81,38 +100,36 @@
const char *keyid;
const char *stat;
char *uid;
+ char buffer[1024];
char date[64] = {0};
err = gpgme_new (&gctx);
- if (!err)
- err = gpgme_get_key (gctx, sig->fpr, &key, 0);
-
+ assert (!err);
+ gpgme_get_key (gctx, sig->fpr, &key, 0);
gpgme_release (gctx);
- if (err) {
- _snprintf (buffer, buflen-1,
- _("Error during verification: %s"), gpgme_strerror (err));
- return;
- }
keyid = strlen (sig->fpr) == 40? sig->fpr+32 : sig->fpr+24;
- stat = get_gpg_sigstat (sig);
+ stat = get_sigstat (sig);
if (!key)
uid = xstrdup (_("UserID not found"));
else
uid = utf8_to_native (key->uids->uid);
- if (sig->summary & GPGME_SIGSUM_KEY_MISSING)
- _snprintf (buffer, buflen, "%s", stat);
- else {
- strncpy (date, ctime (&sig->timestamp), sizeof (date)-2);
- date[strlen (date)-1]=0;
- _snprintf (buffer, buflen,
- _("Signature made '%s' using key ID 0x%08X\r\n"
- "%s from \"%s\"\r\n"), date, keyid, stat, uid);
- }
+ strncpy (date, ctime (&sig->timestamp), sizeof (date)-2);
+ date[strlen (date)-1]=0;
+ if (!key)
+ _snprintf (buffer, sizeof (buffer)-1,
+ _("Signature made '%s' using key ID 0x%08X\r\n"
+ "%s\r\n\"%s\""), date, keyid, stat, uid);
+ else
+ _snprintf (buffer, sizeof (buffer)-1,
+ _("Signature made '%s' using key ID 0x%08X\r\n"
+ "%s from \"%s\"\r\nValidity of the key: %s"),
+ date, keyid, stat, uid, get_key_validity (sig));
if (key)
gpgme_key_release (key);
free_if_alloc (uid);
+ SetDlgItemText (dlg, IDC_VERIFY_STATUS, buffer);
}
@@ -121,7 +138,6 @@
verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
gpgme_signature_t sig;
- char siginfo[2048] = {0};
switch (msg) {
case WM_INITDIALOG:
@@ -129,8 +145,7 @@
assert (sig);
SetWindowText (dlg, _("Signature Verification"));
- sig_get_info_buffer (sig, siginfo, sizeof (siginfo)-1);
- SetDlgItemText (dlg, IDC_VERIFY_STATUS, siginfo);
+ set_sig_info (dlg, sig);
SetForegroundWindow (dlg);
break;
Modified: trunk/src/OEDlgViewer.c
===================================================================
--- trunk/src/OEDlgViewer.c 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/src/OEDlgViewer.c 2006-04-03 17:10:15 UTC (rev 11)
@@ -40,7 +40,7 @@
if (n < 1)
return NULL;
p = xcalloc (1, n+1);
- n = GetDlgItemText (dlg, IDC_VIEWER_TEXT, p, n);
+ n = GetDlgItemText (dlg, IDC_VIEWER_TEXT2, p, n);
return p;
}
@@ -57,7 +57,7 @@
viewer = (viewer_ctx_t)lparam;
assert (viewer);
SetWindowText (dlg, _("Message Viewer"));
- SetDlgItemText (dlg, IDC_VIEWER_TEXT, viewer->msg);
+ SetDlgItemText (dlg, IDC_VIEWER_TEXT2, viewer->msg);
SetForegroundWindow (dlg);
SetFocus (GetDlgItem (dlg, IDOK));
return FALSE;
@@ -74,12 +74,12 @@
return TRUE;
case IDC_VIEWER_QUOTE:
- p = get_item_text (dlg, IDC_VIEWER_TEXT);
+ p = get_item_text (dlg, IDC_VIEWER_TEXT2);
free_if_alloc (p);
return TRUE;
case IDC_VIEWER_COPY:
- p = get_item_text (dlg, IDC_VIEWER_TEXT);
+ p = get_item_text (dlg, IDC_VIEWER_TEXT2);
if (p != NULL)
set_clip_text (NULL, p, strlen (p));
free_if_alloc (p);
Modified: trunk/src/OEPassphraseCBDlg.c
===================================================================
--- trunk/src/OEPassphraseCBDlg.c 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/src/OEPassphraseCBDlg.c 2006-04-03 17:10:15 UTC (rev 11)
@@ -27,6 +27,7 @@
#include "gpgme.h"
#include "GPGOE.h"
+
/* Structure for the passphrase callback. */
struct pass_cb_s {
const char *uid_hint;
Modified: trunk/src/OEProc.c
===================================================================
--- trunk/src/OEProc.c 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/src/OEProc.c 2006-04-03 17:10:15 UTC (rev 11)
@@ -23,13 +23,34 @@
#endif
#include <windows.h>
#include <stdio.h>
+#include <commctrl.h>
+
#include "gpgme.h"
#include "GPGOE.h"
+
/* 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;
+
+/* Display a warning that the attachments of the mail will be
+ sent in cleartext. */
+static void
+show_attachment_warn (HWND hwnd)
+{
+ if (attach_warn_shown)
+ return;
+
+ MessageBox (hwnd, _("GPGOE is unable to secure attachments.\r\n"
+ "As a result the data attached to this mail is NOT encrypted."),
+ _("GPG Plug-in Warning"), MB_ICONWARNING|MB_OK);
+ attach_warn_shown = 1;
+}
+
+
/* Display a warning that the mail will be sent in clear. */
static void
show_plaintext_warn (HWND hwnd, int rc)
@@ -37,7 +58,8 @@
const char *fmt, *s;
char *p;
- fmt = _("WARNING: This message will be sent in cleartext.\r\n%s");
+ fmt = _("WARNING: This message will be sent in cleartext.\r\n\r\n"
+ "Error description: %s.");
s = gpgme_strerror (rc);
p = xcalloc (1, strlen (fmt)+ strlen (s)+2);
sprintf (p, fmt, s);
@@ -123,6 +145,18 @@
}
+/* Check if the attach listview control contains at least one entry.
+ Return 1 if the mail has attachments. */
+int
+mail_has_attachments (plugin_ctx_t ctx)
+{
+ HWND attach;
+
+ attach = FindWindowEx (ctx->addr_wnd, NULL, "SysListView32", NULL);
+ return attach && ListView_GetItemCount (attach) > 0;
+}
+
+
/* Initialize the plugin context:
Find all windows the plugin need to handle messages.
The text of the recipients fields is only used when the message comes
@@ -131,6 +165,10 @@
int
plugin_init (plugin_ctx_t ctx, HWND main, int is_inbox)
{
+ /* store original clipboard text. */
+ free_if_alloc (ctx->orig_text);
+ ctx->orig_text = get_clip_text (NULL);
+
ctx->sign = 0;
ctx->encrypt = 0;
@@ -161,6 +199,7 @@
}
+/* Clear the clipboard contents. */
static void
clear_clipboard (void)
{
@@ -170,6 +209,17 @@
}
+/* Restore the clipboard data. */
+static void
+restore_clipboard (plugin_ctx_t ctx)
+{
+ if (!ctx->orig_text)
+ return;
+ set_clip_text (NULL, ctx->orig_text, strlen (ctx->orig_text));
+ free_if_alloc (ctx->orig_text);
+}
+
+
/* Subclass dialog procedure for the outlook message window. */
LRESULT CALLBACK
oe_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -183,21 +233,25 @@
initialized = SetTimer (hwnd, 1, 1000, NULL);
switch (msg) {
- case WM_CREATE:
+ case WM_CREATE:
+ /* we need to load this lib here otherwise the richedit
+ control would not be displayed. */
+ LoadLibrary ("RichEd32.Dll");
initialized = 0;
plugin_new (&oe_plug);
break;
case WM_DESTROY:
plugin_release (oe_plug);
+ encr_msg = sign_msg = 0;
break;
- case WM_TIMER:
- clear_clipboard ();
+ case WM_TIMER:
KillTimer (hwnd, initialized);
plugin_reset (oe_plug);
plugin_init (oe_plug, hwnd, 1);
if (window_is_inbox (oe_plug->to_wnd)) {
+ clear_clipboard ();
rc = oe_handle_mail (oe_plug);
if (rc)
show_error (hwnd, _("GPG Plug-in Error"), MB_ICONERROR|MB_OK,
@@ -225,16 +279,19 @@
if (encr_msg || sign_msg) {
plugin_init (oe_plug, hwnd, 0);
if (encr_msg) {
- SendMessage (hwnd, WM_COMMAND, MAKEWPARAM(ID_OE5_ENCRYPT, 0), 0);
+ 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);
+ 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;
}
Modified: trunk/src/resource.h
===================================================================
--- trunk/src/resource.h 2006-03-27 12:47:50 UTC (rev 10)
+++ trunk/src/resource.h 2006-04-03 17:10:15 UTC (rev 11)
@@ -18,6 +18,7 @@
#define IDC_ENCRYPT_RECPMSG 1008
#define IDC_SIGN_KEYLIST 1009
#define IDC_VIEWER_QUOTE 1010
+#define IDC_VIEWER_TEXT2 1013
// Next default values for new objects
//
@@ -25,7 +26,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 108
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1013
+#define _APS_NEXT_CONTROL_VALUE 1014
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
More information about the Gpgoe-commits
mailing list