[svn] GPGol - r141 - trunk/src
svn author twoaday
cvs at cvs.gnupg.org
Mon Mar 20 14:13:57 CET 2006
Author: twoaday
Date: 2006-03-20 14:13:56 +0100 (Mon, 20 Mar 2006)
New Revision: 141
Removed:
trunk/src/keylist.c
Modified:
trunk/src/ChangeLog
trunk/src/common.c
trunk/src/config-dialog.c
trunk/src/intern.h
trunk/src/passphrase-dialog.c
trunk/src/recipient-dialog.c
trunk/src/verify-dialog.c
trunk/src/w32-gettext.c
Log:
2006-03-17 Timo Schulz <ts at g10code.com>
* w32-gettext.c (utf8_to_native): Make it global.
* config-dialog.c (get_open_file_name): Make sure the selected
file really exists.
* passphrase-dialog.c (decrypt_dlg_proc): UTF8 conversion.
(passphrase_callback_box): Likewise.
* recipient-dialog.c (recipient_dlg_proc): Likewise.
* verify-dialog.c (load_akalist): Likewise.
(load_sigbox): Likewise.
* common.c (utf_to_wincp): New.
(keylist.c: removed unsued test file.)
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2006-03-20 12:05:18 UTC (rev 140)
+++ trunk/src/ChangeLog 2006-03-20 13:13:56 UTC (rev 141)
@@ -1,7 +1,19 @@
-2006-03-20 Werner Koch <wk at g10code.com>
+2006-03-20 Werner Koch <wk at g10code.com>
* olflange.cpp (Install): Also check major part of build version.
+
+2006-03-17 Timo Schulz <ts at g10code.com>
+ * w32-gettext.c (utf8_to_native): Make it global.
+ * config-dialog.c (get_open_file_name): Make sure the selected
+ file really exists.
+ * passphrase-dialog.c (decrypt_dlg_proc): UTF8 conversion.
+ (passphrase_callback_box): Likewise.
+ * recipient-dialog.c (recipient_dlg_proc): Likewise.
+ * verify-dialog.c (load_akalist): Likewise.
+ (load_sigbox): Likewise.
+ * common.c (utf_to_wincp): New.
+
2006-03-15 Werner Koch <wk at g10code.com>
* olflange.cpp (Install): Print gpgol version for debugging.
Modified: trunk/src/common.c
===================================================================
--- trunk/src/common.c 2006-03-20 12:05:18 UTC (rev 140)
+++ trunk/src/common.c 2006-03-20 13:13:56 UTC (rev 141)
@@ -22,6 +22,7 @@
#include "gpgme.h"
#include "intern.h"
+#include "util.h"
HINSTANCE glob_hinst = NULL;
@@ -79,7 +80,6 @@
is returned. */
char *
get_save_filename (HWND root, const char *srcname)
-
{
char filter[] = "All Files (*.*)\0*.*\0\0";
char fname[MAX_PATH+1];
@@ -98,7 +98,7 @@
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.Flags |= OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
- ofn.lpstrTitle = "GPG - Save decrypted attachment";
+ ofn.lpstrTitle = _("GPG - Save decrypted attachment");
ofn.lpstrFilter = filter;
if (GetSaveFileName (&ofn))
@@ -288,6 +288,57 @@
}
+/* CP850 -> CP1251 charset table. */
+static unsigned char cp850_to_cp1251[] =
+{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
+ 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
+ 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
+ 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
+ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
+ 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
+ 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
+ 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0xc7, 0xfc,
+ 0xe9, 0xe2, 0xe4, 0xe0, 0xe5, 0xe7, 0xea, 0xeb, 0xe8, 0xef, 0xee, 0xec, 0xc4,
+ 0xc5, 0xc9, 0xe6, 0xc6, 0xf4, 0xf6, 0xf2, 0xfb, 0xf9, 0xff, 0xd6, 0xdc, 0xf8,
+ 0xa3, 0xd8, 0xd7, 0x00, 0xe1, 0xed, 0xf3, 0xfa, 0xf1, 0xd1, 0xaa, 0xba, 0xbf,
+ 0xae, 0xac, 0xbd, 0xbc, 0xa1, 0xab, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1,
+ 0xc2, 0xc0, 0xa9, 0x00, 0x00, 0x00, 0x00, 0xa2, 0xa5, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xe3, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4,
+ 0xf0, 0xd0, 0xca, 0xcb, 0xc8, 0x00, 0xcd, 0xce, 0xcf, 0x00, 0x00, 0x00, 0x00,
+ 0xa6, 0xcc, 0x00, 0xd3, 0xdf, 0xd4, 0xd2, 0xf5, 0xd5, 0xb5, 0xfe, 0xde, 0xda,
+ 0xdb, 0xd9, 0xfd, 0xdd, 0xaf, 0xb4, 0xad, 0xb1, 0x00, 0xbe, 0xb6, 0xa7, 0xf7,
+ 0xb8, 0xb0, 0xa8, 0xb7, 0xb9, 0xb3, 0xb2, 0x00, 0xa0,
+};
+
+char *utf8_to_native (const char *string);
+
+/* Convert the console (CP850) encoded UTF8 data from STRING into
+ the current window charset and return it.
+ Caller must free string. */
+char *
+utf8_to_wincp (const char *string)
+{
+ char *res;
+ unsigned char *res_8;
+ size_t i;
+
+ res_8 = res = utf8_to_native (string);
+
+ /* XXX: currently only CP850->CP1251 is supported. */
+ for (i=0; i < strlen (res); i++)
+ {
+ unsigned char ch = cp850_to_cp1251[res_8[i]];
+ if (ch != 0x00)
+ res_8[i] = ch;
+ }
+
+ return res;
+}
+
+
/* Assume STRING is a Latin-1 encoded and convert it to utf-8.
Returns a newly malloced UTF-8 string. */
char *
Modified: trunk/src/config-dialog.c
===================================================================
--- trunk/src/config-dialog.c 2006-03-20 12:05:18 UTC (rev 140)
+++ trunk/src/config-dialog.c 2006-03-20 13:13:56 UTC (rev 141)
@@ -49,6 +49,7 @@
memset (fname, 0, sizeof (fname));
ofn.hwndOwner = GetDesktopWindow ();
ofn.hInstance = glob_hinst;
+ ofn.Flags = OFN_FILEMUSTEXIST;
ofn.lpstrTitle = title;
ofn.lStructSize = sizeof (ofn);
ofn.lpstrInitialDir = dir;
Modified: trunk/src/intern.h
===================================================================
--- trunk/src/intern.h 2006-03-20 12:05:18 UTC (rev 140)
+++ trunk/src/intern.h 2006-03-20 13:13:56 UTC (rev 141)
@@ -114,11 +114,11 @@
} opt;
-
/*-- common.c --*/
void set_global_hinstance (HINSTANCE hinst);
void center_window (HWND childwnd, HWND style);
char *get_save_filename (HWND root, const char *srcname);
+char *utf8_to_wincp (const char *string);
HRESULT w32_shgetfolderpath (HWND a, int b, HANDLE c, DWORD d, LPSTR e);
Deleted: trunk/src/keylist.c
Modified: trunk/src/passphrase-dialog.c
===================================================================
--- trunk/src/passphrase-dialog.c 2006-03-20 12:05:18 UTC (rev 140)
+++ trunk/src/passphrase-dialog.c 2006-03-20 13:13:56 UTC (rev 141)
@@ -227,8 +227,8 @@
while (!gpgme_op_keylist_next (ctx, &key))
{
- const char *name, *email, *keyid, *algo;
- char *p;
+ const char *email, *keyid, *algo;
+ char *p, *name;
long idx;
if (key->revoked || key->expired || key->disabled || key->invalid)
@@ -242,15 +242,17 @@
continue;
}
- name = key->uids->name;
- if (!name)
- name = "";
+ if (!key->uids->name)
+ name = strdup ("");
+ else
+ name = utf8_to_wincp (key->uids->name);
email = key->uids->email;
if (!email)
email = "";
keyid = key->subkeys->keyid;
if (!keyid || strlen (keyid) < 8)
{
+ xfree (name);
gpgme_key_release (key);
continue;
}
@@ -262,8 +264,9 @@
else
sprintf (p, "%s (0x%s, %s)", name, keyid+8, algo);
idx = SendDlgItemMessage (dlg, ctlid, CB_ADDSTRING, 0,
- (LPARAM)(const char *) p);
+ (LPARAM)(const char *)p);
xfree (p);
+ xfree (name);
if (idx < 0) /* Error. */
{
gpgme_key_release (key);
@@ -322,10 +325,7 @@
_("Invalid passphrase; please try again..."):"");
if (dec && !context->use_as_cb)
- {
- context->keyarray = load_secbox (dlg, IDC_DEC_KEYLIST);
- SetWindowText (dlg, _("Select Signing Key"));
- }
+ context->keyarray = load_secbox (dlg, IDC_DEC_KEYLIST);
CheckDlgButton (dlg, IDC_DEC_HIDE, BST_CHECKED);
center_window (dlg, NULL);
@@ -338,6 +338,8 @@
else
SetFocus (GetDlgItem (dlg, IDC_DEC_PASS));
+ if (!context->use_as_cb)
+ SetWindowText (dlg, _("Select Signing Key"));
SetForegroundWindow (dlg);
return FALSE;
}
@@ -733,7 +735,7 @@
else
s = "[no user Id]";
xfree (dec->user_id);
- dec->user_id = xstrdup (s);
+ dec->user_id = utf8_to_wincp (s);
dec->last_was_bad = prev_was_bad;
if (dec->flags & 0x01)
{
Modified: trunk/src/recipient-dialog.c
===================================================================
--- trunk/src/recipient-dialog.c 2006-03-20 12:05:18 UTC (rev 140)
+++ trunk/src/recipient-dialog.c 2006-03-20 13:13:56 UTC (rev 141)
@@ -170,8 +170,8 @@
continue;
}
- /* Ignore keys without a user ID or woithout a subkey */
- if (!key->uids || !key->subkeys )
+ /* Ignore keys without a user ID or without a subkey */
+ if (!key->uids || !key->subkeys)
{
gpgme_key_release (key);
continue;
@@ -179,8 +179,9 @@
ListView_InsertItem (hwnd, &lvi);
- s = key->uids->name;
+ s = utf8_to_wincp (key->uids->name);
ListView_SetItemText (hwnd, 0, COL_NAME, s);
+ xfree (s);
s = key->uids->email;
ListView_SetItemText (hwnd, 0, COL_EMAIL, s);
@@ -352,7 +353,7 @@
{
static struct recipient_cb_s * rset_cb;
static int rset_state = 1;
- NMHDR * notify;
+ NMHDR *notify;
HWND hrset;
const char *warn;
size_t pos;
@@ -365,7 +366,7 @@
initialize_rsetbox (GetDlgItem (dlg, IDC_ENC_RSET1));
rset_cb->keyarray = load_rsetbox (GetDlgItem (dlg, IDC_ENC_RSET1),
- &rset_cb->keyarray_count );
+ &rset_cb->keyarray_count);
initialize_rsetbox (GetDlgItem (dlg, IDC_ENC_RSET2));
@@ -382,6 +383,10 @@
SetForegroundWindow (dlg);
return TRUE;
+ case WM_DESTROY:
+ rset_state = 1; /* reset to default. */
+ break;
+
case WM_SYSCOMMAND:
if (wparam == SC_CLOSE)
EndDialog (dlg, TRUE);
@@ -409,7 +414,7 @@
break;
}
- switch ( LOWORD (wparam) )
+ switch (LOWORD (wparam))
{
case IDOK:
hrset = GetDlgItem (dlg, IDC_ENC_RSET2);
Modified: trunk/src/verify-dialog.c
===================================================================
--- trunk/src/verify-dialog.c 2006-03-20 12:05:18 UTC (rev 140)
+++ trunk/src/verify-dialog.c 2006-03-20 13:13:56 UTC (rev 141)
@@ -58,18 +58,22 @@
static int
load_akalist (HWND dlg, gpgme_key_t key)
{
- gpgme_user_id_t u;
- int n = 0;
-
- u = key->uids;
- if (!u->next)
- return n;
- for (u=u->next; u; u=u->next) {
- SendDlgItemMessage (dlg, IDC_VRY_AKALIST, LB_ADDSTRING,
- 0, (LPARAM)(const char*)u->uid);
- n++;
+ gpgme_user_id_t u;
+ char *uid;
+ int n = 0;
+
+ u = key->uids;
+ if (!u->next)
+ return n;
+ for (u=u->next; u; u=u->next)
+ {
+ uid = utf8_to_wincp (u->uid);
+ SendDlgItemMessage (dlg, IDC_VRY_AKALIST, LB_ADDSTRING,
+ 0, (LPARAM)(const char*)uid);
+ free (uid);
+ n++;
}
- return n;
+ return n;
}
@@ -139,8 +143,9 @@
if (key && key->uids)
{
- s = key->uids->uid;
- SetDlgItemText (dlg, IDC_VRY_ISSUER, s);
+ p = utf8_to_wincp (key->uids->uid);
+ SetDlgItemText (dlg, IDC_VRY_ISSUER, p);
+ free (p);
n = load_akalist (dlg, key);
gpgme_key_release (key);
Modified: trunk/src/w32-gettext.c
===================================================================
--- trunk/src/w32-gettext.c 2006-03-20 12:05:18 UTC (rev 140)
+++ trunk/src/w32-gettext.c 2006-03-20 13:13:56 UTC (rev 141)
@@ -1461,7 +1461,7 @@
}
-static char *
+char *
utf8_to_native (const char *string)
{
wchar_t *wstring;
More information about the Gnupg-commits
mailing list