/[winpt]/trunk/Src/wptFileVerifyDlg.cpp
ViewVC logotype

Diff of /trunk/Src/wptFileVerifyDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 32 by twoaday, Mon Oct 24 08:03:48 2005 UTC revision 36 by werner, Thu Oct 27 15:25:13 2005 UTC
# Line 1  Line 1 
1  /* wptVerifyFileDlg.cpp - (File Manager) Verify file  /* wptVerifyFileDlg.cpp - (File Manager) Verify file
2   *      Copyright (C) 2001, 2002, 2005 Timo Schulz   *      Copyright (C) 2001, 2002, 2005 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
6   * WinPT is free software; you can redistribute it and/or modify   * WinPT is free software; you can redistribute it and/or modify
7   * it under the terms of the GNU General Public License as published by   * it under the terms of the GNU General Public License as published by
8   * the Free Software Foundation; either version 2 of the License, or   * the Free Software Foundation; either version 2 of the License, or
9   * (at your option) any later version.   * (at your option) any later version.
10   *   *
11   * WinPT is distributed in the hope that it will be useful,   * WinPT is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.   * GNU General Public License for more details.
15   *   *
16   * You should have received a copy of the GNU General Public License   * You should have received a copy of the GNU General Public License
17   * along with WinPT; if not, write to the Free Software Foundation,   * along with WinPT; if not, write to the Free Software Foundation,
18   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19   */   */
20    
21  #include <windows.h>  #ifdef HAVE_CONFIG_H
22    #include <config.h>
23  #include "../resource.h"  #endif
24  #include "wptGPG.h"  
25  #include "wptW32API.h"  #include <windows.h>
26  #include "wptTypes.h"  #include <windows.h>
27  #include "wptNLS.h"  
28  #include "wptVersion.h"  #include "../resource.h"
29  #include "wptCommonCtl.h"  #include "wptGPG.h"
30  #include "wptKeylist.h"  #include "wptW32API.h"
31  #include "wptTypes.h"  #include "wptTypes.h"
32  #include "wptKeyserver.h"  #include "wptNLS.h"
33    #include "wptVersion.h"
34  static listview_ctrl_t dlg_lv = NULL;  #include "wptCommonCtl.h"
35  static HWND dlg_wnd = NULL;             /* handle to the dialog box window */  #include "wptKeylist.h"
36  static HANDLE dlg_event = NULL;         /* event for the dialog. */  #include "wptTypes.h"
37    #include "wptKeyserver.h"
38    
39  /* Dialog box procedure to show the verify results of a file. */  static listview_ctrl_t dlg_lv = NULL;
40  static BOOL CALLBACK  static HWND dlg_wnd = NULL;             /* handle to the dialog box window */
41  file_verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  static HANDLE dlg_event = NULL;         /* event for the dialog. */
42  {  
43      static listview_ctrl_t lv = NULL;  
44      int rc = 0;  /* Dialog box procedure to show the verify results of a file. */
45        static BOOL CALLBACK
46      switch( msg ) {  file_verify_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
47      case WM_INITDIALOG:  {
48          #ifndef LANG_DE      static listview_ctrl_t lv = NULL;
49          SetWindowText (dlg, _("File Verify"));      int rc = 0;
50          SetDlgItemText (dlg, IDC_VERIFY_SAVE, _("&Save"));      
51          #endif      switch( msg ) {
52          rc = verlist_build (&lv, GetDlgItem (dlg, IDC_VERIFY_SIGLIST), 1);      case WM_INITDIALOG:
53          if (rc)          #ifndef LANG_DE
54              BUG (dlg);          SetWindowText (dlg, _("File Verify"));
55          EnableWindow (GetDlgItem (dlg, IDC_VERIFY_SAVE), FALSE);          SetDlgItemText (dlg, IDC_VERIFY_SAVE, _("&Save"));
56          SetForegroundWindow (dlg);          #endif
57          dlg_lv = lv;          rc = verlist_build (&lv, GetDlgItem (dlg, IDC_VERIFY_SIGLIST), 1);
58          dlg_wnd = dlg;          if (rc)
59          return TRUE;              BUG (dlg);
60                    EnableWindow (GetDlgItem (dlg, IDC_VERIFY_SAVE), FALSE);
61      case WM_DESTROY:          SetForegroundWindow (dlg);
62          if (lv) {          dlg_lv = lv;
63              listview_release (lv);          dlg_wnd = dlg;
64              lv = NULL;                            return TRUE;
65          }          
66          dlg_lv = NULL;      case WM_DESTROY:
67          dlg_wnd = NULL;          if (lv) {
68          return FALSE;              listview_release (lv);
69                lv = NULL;                  
70      case WM_NOTIFY:          }
71          NMHDR *notify;          dlg_lv = NULL;
72                    dlg_wnd = NULL;
73          notify = (NMHDR *)lparam;          return FALSE;
74          if (notify && notify->code == NM_DBLCLK &&  
75              notify->idFrom == IDC_VERIFY_SIGLIST) {      case WM_NOTIFY:
76              char buf[64];          NMHDR *notify;
77              listview_get_item_text (lv, listview_get_curr_pos (lv), 4, buf, 63);          
78              if (strlen (buf) == 10 && buf[0] == '0' && buf[1] == 'x') {          notify = (NMHDR *)lparam;
79                  rc = msg_box (dlg, _("Do you want to retrieve the key?"),          if (notify && notify->code == NM_DBLCLK &&
80                                _("Verify"), MB_QUEST_ASK);              notify->idFrom == IDC_VERIFY_SIGLIST) {
81                  if (rc == IDYES) {              char buf[64];
82                      if (!hkp_recv_key (dlg, default_keyserver,              listview_get_item_text (lv, listview_get_curr_pos (lv), 4, buf, 63);
83                                         default_keyserver_port, buf, 0, 0))              if (strlen (buf) == 10 && buf[0] == '0' && buf[1] == 'x') {
84                          keycache_reload (dlg);                  rc = msg_box (dlg, _("Do you want to retrieve the key?"),
85                  }                                _("Verify"), MB_QUEST_ASK);
86              }                  if (rc == IDYES) {
87                        if (!hkp_recv_key (dlg, default_keyserver,
88          }                                         default_keyserver_port, buf, 0, 0))
89          break;                          keycache_reload (dlg);
90                    }
91      case WM_SYSCOMMAND:              }
92          if (LOWORD (wparam) == SC_CLOSE)  
93              EndDialog (dlg, TRUE);          }
94          return FALSE;          break;
95            
96      case WM_COMMAND:      case WM_SYSCOMMAND:
97          switch (LOWORD (wparam)) {          if (LOWORD (wparam) == SC_CLOSE)
98          case IDOK:              EndDialog (dlg, TRUE);
99              if (dlg_event)          return FALSE;
100                  SetEvent (dlg_event);          
101              EndDialog (dlg, TRUE);      case WM_COMMAND:
102              return TRUE;          switch (LOWORD (wparam)) {
103          }          case IDOK:
104          break;              if (dlg_event)
105      }                  SetEvent (dlg_event);
106                    EndDialog (dlg, TRUE);
107      return FALSE;              return TRUE;
108  }          }
109            break;
110        }
111  /* Thread which spawns the verify dialog. */      
112  static DWORD CALLBACK      return FALSE;
113  file_verify_dlg_thread (void *opaque)  }
114  {  
115      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_VERIFY, GetActiveWindow(),  
116                      file_verify_dlg_proc, NULL);  /* Thread which spawns the verify dialog. */
117      if (dlg_event) {  static DWORD CALLBACK
118          CloseHandle (dlg_event);  file_verify_dlg_thread (void *opaque)
119          dlg_event = NULL;  {
120      }      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_VERIFY, GetActiveWindow(),
121                        file_verify_dlg_proc, NULL);
122      ExitThread (0);      if (dlg_event) {
123      return 0;          CloseHandle (dlg_event);
124  }          dlg_event = NULL;
125        }
126    
127  /* Create the verify dialog asynchronly. */      ExitThread (0);
128  int      return 0;
129  file_verify_create_dlg (void)  }
130  {  
131      DWORD tid;  
132      HANDLE thread_hd;  /* Create the verify dialog asynchronly. */
133      SECURITY_ATTRIBUTES sec_attr;  int
134        file_verify_create_dlg (void)
135      if (dlg_wnd)  {
136          return 0;      DWORD tid;
137            HANDLE thread_hd;
138      memset (&sec_attr, 0, sizeof (sec_attr));      SECURITY_ATTRIBUTES sec_attr;
139      sec_attr.bInheritHandle = FALSE;      
140      sec_attr.lpSecurityDescriptor = NULL;      if (dlg_wnd)
141      sec_attr.nLength = sizeof (sec_attr);          return 0;
142      thread_hd = CreateThread (&sec_attr, 0, file_verify_dlg_thread, NULL, 0, &tid);      
143      if (thread_hd == NULL) {      memset (&sec_attr, 0, sizeof (sec_attr));
144          msg_box (NULL, "Could not create verify thread.", _("Verify"), MB_ERR);      sec_attr.bInheritHandle = FALSE;
145          return -1;      sec_attr.lpSecurityDescriptor = NULL;
146      }      sec_attr.nLength = sizeof (sec_attr);
147            thread_hd = CreateThread (&sec_attr, 0, file_verify_dlg_thread, NULL, 0, &tid);
148      return 0;      if (thread_hd == NULL) {
149  }          msg_box (NULL, "Could not create verify thread.", _("Verify"), MB_ERR);
150            return -1;
151        }
152  /* Add the signature + information in @c to the verify dialog. */      
153  void      return 0;
154  file_verify_add_state (file_sig_ctx_t c)  }
155  {  
156      if (dlg_lv)  
157          verlist_add_sig_log (dlg_lv, c);  /* Add the signature + information in @c to the verify dialog. */
158  }  void
159    file_verify_add_state (file_sig_ctx_t c)
160    {
161  /* Create an event for the verify dialog. */      if (dlg_lv)
162  void          verlist_add_sig_log (dlg_lv, c);
163  file_verify_use_event (void)  }
164  {  
165      SECURITY_ATTRIBUTES sec_attr;  
166        /* Create an event for the verify dialog. */
167      memset (&sec_attr, 0, sizeof (sec_attr));  void
168      sec_attr.bInheritHandle = FALSE;  file_verify_use_event (void)
169      sec_attr.nLength = sizeof (sec_attr);  {
170      dlg_event = CreateEvent (&sec_attr, TRUE, FALSE, NULL);      SECURITY_ATTRIBUTES sec_attr;
171  }      
172        memset (&sec_attr, 0, sizeof (sec_attr));
173        sec_attr.bInheritHandle = FALSE;
174  /* Wait until the verify event is signaled. */      sec_attr.nLength = sizeof (sec_attr);
175  void      dlg_event = CreateEvent (&sec_attr, TRUE, FALSE, NULL);
176  file_verify_wait (void)  }
177  {  
178      WaitForSingleObject (dlg_event, INFINITE);  
179  }  /* Wait until the verify event is signaled. */
180    void
181    file_verify_wait (void)
182    {
183        WaitForSingleObject (dlg_event, INFINITE);
184    }

Legend:
Removed from v.32  
changed lines
  Added in v.36

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26