[Winpt-commits] r409 - trunk/Src
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Mon Feb 6 20:39:00 CET 2012
Author: twoaday
Date: 2012-02-06 20:39:00 +0100 (Mon, 06 Feb 2012)
New Revision: 409
Modified:
trunk/Src/ChangeLog
trunk/Src/WinPT.cpp
trunk/Src/wptErrors.cpp
trunk/Src/wptFileManager.cpp
trunk/Src/wptGPG.cpp
trunk/Src/wptRegistry.cpp
Log:
2012-02-06 Timo Schulz <twoaday at gmx.net>
* wptGPG.cpp (check_keyring): Improved error checking.
* wptFileManager.cpp: Removed obsolete code.
Modified: trunk/Src/ChangeLog
===================================================================
--- trunk/Src/ChangeLog 2012-02-06 19:26:15 UTC (rev 408)
+++ trunk/Src/ChangeLog 2012-02-06 19:39:00 UTC (rev 409)
@@ -3,6 +3,8 @@
* wptNLS.cpp (gettext_free_current_domain): Replace free()
with safe_free():
* WinPT.cpp: Use log_debug to improve bug tracking capabilities.
+ * wptGPG.cpp (check_keyring): Improved error checking.
+ * wptFileManager.cpp: Removed obsolete code.
2012-01-29 Timo Schulz <twoaday at gmx.net>
Modified: trunk/Src/WinPT.cpp
===================================================================
--- trunk/Src/WinPT.cpp 2012-02-06 19:26:15 UTC (rev 408)
+++ trunk/Src/WinPT.cpp 2012-02-06 19:39:00 UTC (rev 409)
@@ -374,8 +374,7 @@
OSVERSIONINFOA osver;
memset (&osver, 0, sizeof (osver));
osver.dwOSVersionInfoSize = sizeof (osver);
-
- log_debug("check OS version");
+
if (!GetVersionEx (&osver)) {
MessageBox (NULL, _("Could not read the OS version."), _("WinPT Error"), MB_ERR);
return 0;
@@ -405,7 +404,8 @@
int first_start = 0, start_gpgprefs = 0;
int winpt_inst_found = 0;
int start_manager = 0;
-
+
+ log_debug("check OS version");
if (!check_os_version ())
return 0;
@@ -414,8 +414,10 @@
/* Allow to shutdown the process, for instance by an installer */
if (cmdline && stristr (cmdline, "--stop")) {
hwnd = FindWindow ("WinPT", "WinPT");
- if (hwnd != NULL)
+ if (hwnd != NULL) {
+ log_debug("shutdown an existing WinPT process");
PostMessage (hwnd, WM_DESTROY, 0, 0);
+ }
return 0;
}
Modified: trunk/Src/wptErrors.cpp
===================================================================
--- trunk/Src/wptErrors.cpp 2012-02-06 19:26:15 UTC (rev 408)
+++ trunk/Src/wptErrors.cpp 2012-02-06 19:39:00 UTC (rev 409)
@@ -1,5 +1,5 @@
/* wptErrors.cpp - Error management
- * Copyright (C) 2000-2006 Timo Schulz
+ * Copyright (C) 2000-2006, 2012 Timo Schulz
*
* This file is part of WinPT.
*
Modified: trunk/Src/wptFileManager.cpp
===================================================================
--- trunk/Src/wptFileManager.cpp 2012-02-06 19:26:15 UTC (rev 408)
+++ trunk/Src/wptFileManager.cpp 2012-02-06 19:39:00 UTC (rev 409)
@@ -1730,8 +1730,8 @@
fn = new char[strlen (p)];
if (!fn)
BUG (NULL);
- memcpy (fn, p+1, strlen (p) - 2);
- fn[strlen (p) -2] = '\0';
+ memcpy (fn, p + 1, strlen (p) - 2);
+ fn[strlen (p) - 2] = '\0';
}
else
fn = m_strdup (p);
@@ -1784,123 +1784,7 @@
return p+1;
}
-#if 0
-/* Store all selected files from @lv in a zip archive
- and encrypt the zip archive then.
- Return value: 0 on success. */
-int
-fm_encrypt_into_zip (fm_state_t ctx, listview_ctrl_t lv)
-{
- PK_FILE_LIST list=NULL;
- const char *outfile, *ext;
- char *out_enc;
- int nitems;
- int i, idx = -1;
- int rc;
- nitems = listview_count_items (lv, 0);
- if (!nitems) {
- msg_box (NULL, _("Encrypting into a ZIP archive makes sense with multiple files"),
- _("File Manager"), MB_ERR);
- return WPTERR_GENERAL;
- }
-
- outfile = get_filesave_dlg (ctx->dlg, _("Choose File Name for Output"),
- NULL, "Encrypted_Files.zip");
- if (!outfile)
- return WPTERR_GENERAL;
-
- for (i=0; i < nitems; i++) {
- char name[MAX_PATH+32];
-
- if (!listview_get_item_state (lv, i))
- continue;
- if (idx == -1)
- idx = i;
- listview_get_item_text (lv, i, 1, name, DIM (name)-1);
- pk_list_add (&list, name);
- }
-
- pk_archiv_create (list, outfile);
- pk_list_free (list);
-
- rc = fm_encrypt (ctx, outfile, 0);
- DeleteFile (outfile);
- if (rc)
- return rc;
-
- ext = file_get_extension (ctx->ctx, ctx->sigmode)+1;
- out_enc = make_filename (NULL, outfile, ext);
- fm_set_status (lv, idx, FM_ENCRYPT, (gpgme_sig_mode_t)0, 1, out_enc);
- free_if_alloc (out_enc);
-
- for (i=nitems; i > -1; i--) {
- if (i != idx && listview_get_item_state (lv, i))
- listview_del_item (lv, i);
- }
- return 0;
-}
-
-int
-fm_encrypt_directory (fm_state_t c, const char *name)
-{
- WIN32_FIND_DATA findbuf;
- HANDLE hd;
- PK_FILE_LIST list = NULL;
- const char *s;
- char *patt = NULL, *p;
- int rc = 0;
-
- if (!is_directory (name))
- return -1;
- patt = new char[strlen (name) + 4];
- if (!patt)
- BUG (NULL);
- strcpy (patt, name);
- strcat (patt, "\\*");
- hd = FindFirstFile (patt, &findbuf);
- if (!hd) {
- free_if_alloc (patt);
- return WPTERR_GENERAL;
- }
- if (strcmp (findbuf.cFileName, ".") && strcmp (findbuf.cFileName, "..")) {
- p = make_filename (name, findbuf.cFileName, NULL);
- pk_list_add (&list, p);
- free_if_alloc (p);
- }
- /* XXX: support to scan sub directories also. */
- while (FindNextFile (hd, &findbuf)) {
- if (strcmp (findbuf.cFileName, ".") && strcmp (findbuf.cFileName, "..")) {
- p = make_filename (name, findbuf.cFileName, NULL);
- pk_list_add (&list, p);
- free_if_alloc (p);
- }
- }
- s = get_filesave_dlg (c->dlg, _("Choose a Name for the Archive"),
- NULL, default_dirname (name));
- if (!s) {
- msg_box (c->dlg, _("Invalid archive name. Exit."),
- _("Encrypt Directory"), MB_ERR);
- rc = -1;
- goto leave;
- }
-
- rc = pk_archiv_create (list, s);
- if (rc)
- msg_box (c->dlg, _("Could not create zip archive."),
- _("Encrypt Directory"), MB_ERR);
- else {
- fm_encrypt (c, s, 0);
- DeleteFile (s);
- }
-leave:
- FindClose (hd);
- pk_list_free (list);
- free_if_alloc (patt);
- return rc;
-}
-#endif
-
static int CALLBACK
fm_cmp_cb (LPARAM first, LPARAM second, LPARAM sortby)
{
@@ -1944,9 +1828,8 @@
fm_send_file (listview_ctrl_t lv)
{
char name[MAX_PATH+1];
- int rc;
- rc = listview_get_item_text (lv, -1, FM_COL_NAME, name, DIM (name)-1);
+ int rc = listview_get_item_text (lv, -1, FM_COL_NAME, name, DIM (name)-1);
if (rc != -1)
mapi_send_ascfile (name);
return 0;
Modified: trunk/Src/wptGPG.cpp
===================================================================
--- trunk/Src/wptGPG.cpp 2012-02-06 19:26:15 UTC (rev 408)
+++ trunk/Src/wptGPG.cpp 2012-02-06 19:39:00 UTC (rev 409)
@@ -637,11 +637,9 @@
/* Store the last access of the file inside the watcher @ctx. */
static int
get_last_gnupg_access (gpg_monitor_t ctx)
-{
- HANDLE fd;
-
- fd = CreateFile (ctx->fpath_object, GENERIC_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, 0, NULL);
+{
+ HANDLE fd = CreateFile (ctx->fpath_object, GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, 0, NULL);
if (fd == INVALID_HANDLE_VALUE)
return WPTERR_FILE_OPEN;
GetFileTime (fd, NULL, NULL, &ctx->access);
@@ -672,11 +670,8 @@
void
init_gnupg_table (void)
{
- char *path;
- int j;
-
- path = get_gnupg_path ();
- for (j = 0; j < gpg_table_count; j++) {
+ char *path = get_gnupg_path ();
+ for (int j = 0; j < gpg_table_count; j++) {
gpg_table[j].object = m_strdup (gpg_objs[j]);
gpg_table[j].fpath_object = make_filename (path, gpg_objs[j], NULL);
memset (&gpg_table[j].access, 0, sizeof (FILETIME));
@@ -691,7 +686,7 @@
void
free_gnupg_table (void)
{
- for (int j=0; j < gpg_table_count; j++) {
+ for (int j = 0; j < gpg_table_count; j++) {
free_if_alloc (gpg_table[j].object);
free_if_alloc (gpg_table[j].fpath_object);
}
@@ -702,9 +697,7 @@
int
keyring_check_last_access (void)
{
- int nfiles;
-
- nfiles = 0;
+ int nfiles = 0;
for (int pos = 0; pos < gpg_table_count; pos++) {
get_last_gnupg_access (&gpg_table[pos]);
check_last_gnupg_access (&gpg_table[pos]);
@@ -749,12 +742,10 @@
static int
check_file_access (const char *fname, int mode)
{
- HANDLE hd;
-
if (!mode)
mode = FILE_SHARE_WRITE;
- hd = CreateFile (fname, GENERIC_WRITE, mode,
- NULL, OPEN_EXISTING, 0, NULL);
+ HANDLE hd = CreateFile (fname, GENERIC_WRITE, mode,
+ NULL, OPEN_EXISTING, 0, NULL);
if (hd == INVALID_HANDLE_VALUE)
return -1;
CloseHandle (hd);
@@ -993,7 +984,7 @@
if (!*r_path)
return 0;
p = make_filename (*r_path, "pubring", "gpg");
- if (get_file_size (p) <= 0)
+ if (!p || get_file_size (p) < 1)
return 0;
opt = get_gnupg_cfgfile ();
Modified: trunk/Src/wptRegistry.cpp
===================================================================
--- trunk/Src/wptRegistry.cpp 2012-02-06 19:26:15 UTC (rev 408)
+++ trunk/Src/wptRegistry.cpp 2012-02-06 19:39:00 UTC (rev 409)
@@ -276,6 +276,7 @@
if (created)
*created = 1;
RegCloseKey (reg);
+ /* FIXME: check this part */
if (with_ext) {
id = msg_box (NULL, _("WinPT can register some GPG file types for you so they can "
"be processed with a double click in the explorer.\n"
@@ -296,14 +297,16 @@
}
}
/* Store the install directory for later use. */
- if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) {
+ n = GetModuleFileName (NULL, modpath, MAX_PATH-1);
+ if (n > 0) {
while (n-- > 0) {
if (modpath[n] == '\\') {
modpath[n] = 0;
break;
}
}
- set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Install Directory", modpath);
+ log_debug("storing install directory '%s'", modpath);
+ set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Install Directory", modpath);
}
return 0;
}
More information about the Winpt-commits
mailing list