[svn] GPGol - r86 - trunk/src

svn author twoaday cvs at cvs.gnupg.org
Tue Sep 6 13:25:13 CEST 2005


Author: twoaday
Date: 2005-09-06 13:25:12 +0200 (Tue, 06 Sep 2005)
New Revision: 86

Modified:
   trunk/src/ChangeLog
   trunk/src/HashTable.cpp
   trunk/src/config-dialog.c
Log:
See ChangeLog.



Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2005-09-04 11:45:37 UTC (rev 85)
+++ trunk/src/ChangeLog	2005-09-06 11:25:12 UTC (rev 86)
@@ -1,3 +1,9 @@
+2005-09-06  Timo Schulz  <ts at g10code.com>
+
+	* config-dialog.c (get_open_file_name): Correctly terminated filter.
+	New parameter for the title. Changed all callers.
+	(get_folder): Likewise.
+	
 2005-09-01  Werner Koch  <wk at g10code.com>
 
 	* gpgmsg.cpp (get_pgp_armor_type): New.

Modified: trunk/src/HashTable.cpp
===================================================================
--- trunk/src/HashTable.cpp	2005-09-04 11:45:37 UTC (rev 85)
+++ trunk/src/HashTable.cpp	2005-09-06 11:25:12 UTC (rev 86)
@@ -55,12 +55,14 @@
     memset (table, 0, sizeof (void*)*n);
 }
 
-HashTable::HashTable (unsigned int n)
+HashTable::HashTable (unsigned int nelem)
 {
     pos = 0;
-    this->n = n;
-    table = new void*[n];
-    memset (table, 0, sizeof (void*)*n);
+    if (nelem < 1)
+	nelem = 1;
+    this->n = nelem;
+    table = new void*[nelem];
+    memset (table, 0, sizeof (void*)*nelem);
 }
 
 HashTable::~HashTable (void)

Modified: trunk/src/config-dialog.c
===================================================================
--- trunk/src/config-dialog.c	2005-09-04 11:45:37 UTC (rev 85)
+++ trunk/src/config-dialog.c	2005-09-06 11:25:12 UTC (rev 86)
@@ -41,24 +41,24 @@
 #define GPGOL_REGPATH "Software\\GNU\\GPGol"
 
 static char*
-get_open_file_name (const char *dir)
+get_open_file_name (const char *dir, const char *title)
 {
-    static char fname[MAX_PATH+1];
-    OPENFILENAME ofn;
+  static char fname[MAX_PATH+1];
+  OPENFILENAME ofn;
 
-    memset (&ofn, 0, sizeof (ofn));
-    memset (fname, 0, sizeof (fname));
-    ofn.hwndOwner = GetDesktopWindow();
-    ofn.hInstance = glob_hinst;
-    ofn.lpstrTitle = "Select GnuPG binary";
-    ofn.lStructSize = sizeof (ofn);
-    ofn.lpstrInitialDir = dir;
-    ofn.lpstrFilter = "*.EXE";
-    ofn.lpstrFile = fname;
-    ofn.nMaxFile = sizeof(fname)-1;
-    if (GetOpenFileName(&ofn) == FALSE)
-	return NULL;
-    return fname;
+  memset (&ofn, 0, sizeof (ofn));
+  memset (fname, 0, sizeof (fname));
+  ofn.hwndOwner = GetDesktopWindow ();
+  ofn.hInstance = glob_hinst;
+  ofn.lpstrTitle = title;
+  ofn.lStructSize = sizeof (ofn);
+  ofn.lpstrInitialDir = dir;
+  ofn.lpstrFilter = "EXE-Files (*.EXE)\0*.EXE";
+  ofn.lpstrFile = fname;
+  ofn.nMaxFile = sizeof (fname)-1;
+  if (GetOpenFileName (&ofn) == FALSE)
+    return NULL;
+  return fname;
 }
 
 
@@ -76,24 +76,25 @@
 
 /* Open the common dialog to select a folder. Caller has to free the string. */
 static char*
-get_folder (void)
+get_folder (const char *title)
 {
-    char fname[MAX_PATH+1];
-    BROWSEINFO bi;
-    ITEMIDLIST * il;
-    char *path = NULL;
+  char fname[MAX_PATH+1];
+  BROWSEINFO bi;
+  ITEMIDLIST * il;
+  char *path = NULL;
 
-    memset (&bi, 0, sizeof (bi));
-    memset (fname, 0, sizeof (fname));
-    bi.hwndOwner = GetDesktopWindow ();
-    bi.lpszTitle = "Select GnuPG home directory";
-    il = SHBrowseForFolder (&bi);
-    if (il != NULL) {
-	SHGetPathFromIDList (il, fname);
-	path = xstrdup (fname);
-	SHFree (il);
+  memset (&bi, 0, sizeof (bi));
+  memset (fname, 0, sizeof (fname));
+  bi.hwndOwner = GetDesktopWindow ();
+  bi.lpszTitle = title;
+  il = SHBrowseForFolder (&bi);
+  if (il != NULL)
+    {
+      SHGetPathFromIDList (il, fname);
+      path = xstrdup (fname);
+      SHFree (il);
     }
-    return path;
+  return path;
 }
 
 
@@ -258,14 +259,14 @@
 static void
 error_box (const char *title)
 {	
-    TCHAR buf[256];
-    DWORD last_err;
+  TCHAR buf[256];
+  DWORD last_err;
 
-    last_err = GetLastError ();
-    FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, last_err, 
-		   MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), 
-		   buf, sizeof (buf)-1, NULL);
-    MessageBox (NULL, buf, title, MB_OK);
+  last_err = GetLastError ();
+  FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, last_err, 
+                 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), 
+                 buf, sizeof (buf)-1, NULL);
+  MessageBox (NULL, buf, title, MB_OK);
 }
 
 
@@ -297,22 +298,22 @@
 	break;
 
     case WM_COMMAND:
-	switch (LOWORD(wparam)) {
+	switch (LOWORD (wparam)) {
 	case IDC_OPT_SELPRG:
-	    buf = get_open_file_name (NULL);
+	    buf = get_open_file_name (NULL, "Select GnuPG Binary");
 	    if (buf && *buf)
 		SetDlgItemText(dlg, IDC_OPT_GPGPRG, buf);
 	    break;
 
 	case IDC_OPT_SELHOMEDIR:
-	    buf = get_folder ();
+	    buf = get_folder ("Select GnuPG Home Directory");
 	    if (buf && *buf)
 		SetDlgItemText(dlg, IDC_OPT_HOMEDIR, buf);
 	    xfree (buf);
 	    break;
 
 	case IDC_OPT_SELKEYMAN:
-	    buf = get_open_file_name (NULL);
+	    buf = get_open_file_name (NULL, "Select GnuPG Key Manager");
 	    if (buf && *buf)
 		SetDlgItemText (dlg, IDC_OPT_KEYMAN, buf);
 	    break;
@@ -353,17 +354,18 @@
 void
 config_dialog_box (HWND parent)
 {
-    int resid=0;
+  int resid=0;
 
-    switch (GetUserDefaultLangID ()) {
+  switch (GetUserDefaultLangID ())
+    {
     case 0x0407:    resid = IDD_OPT_DE;break;
     default:	    resid = IDD_OPT; break;
     }
 
-    if (parent == NULL)
-	parent = GetDesktopWindow ();
-    DialogBoxParam (glob_hinst, (LPCTSTR)resid, parent,
-		    config_dlg_proc, 0);
+  if (parent == NULL)
+    parent = GetDesktopWindow ();
+  DialogBoxParam (glob_hinst, (LPCTSTR)resid, parent,
+                  config_dlg_proc, 0);
 }
 
 
@@ -412,8 +414,6 @@
             }
         }
     }
-
-
   
   /* Create startup info for the keymanager process. */
   memset (&si, 0, sizeof (si));
@@ -423,10 +423,11 @@
   
   if (CreateProcess (NULL, keyman,
                      NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE,
-                     NULL, NULL, &si, &pi) == TRUE) {
-    CloseHandle (pi.hProcess);
-    CloseHandle (pi.hThread);
-  }
+                     NULL, NULL, &si, &pi) == TRUE)
+    {
+      CloseHandle (pi.hProcess);
+      CloseHandle (pi.hThread);
+    }
   
   xfree (keyman);
   return 0;




More information about the Gnupg-commits mailing list