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

Diff of /trunk/Src/wptKeysigDlg.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 47 by werner, Mon Oct 31 14:04:59 2005 UTC
# Line 1  Line 1 
1  /* wptKeysigDlg.cpp - Key signature listing  /* wptKeysigDlg.cpp - Key signature listing
2   *      Copyright (C) 2001-2005 Timo Schulz   *      Copyright (C) 2001-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 <commctrl.h>  #include <config.h>
23  #include <time.h>  #endif
24    
25  #include "../resource.h"  #include <windows.h>
26  #include "wptGPG.h"  #include <windows.h>
27  #include "wptCommonCtl.h"  #include <commctrl.h>
28  #include "wptContext.h" /* for passphrase_s */  #include <time.h>
29  #include "wptDlgs.h"  
30  #include "wptW32API.h"  #include "resource.h"
31  #include "wptNLS.h"  #include "wptGPG.h"
32  #include "wptKeyList.h"  #include "wptCommonCtl.h"
33  #include "wptKeyserver.h"  #include "wptContext.h" /* for passphrase_s */
34  #include "wptUTF8.h"  #include "wptDlgs.h"
35  #include "wptTypes.h"  #include "wptW32API.h"
36  #include "wptVersion.h"  #include "wptNLS.h"
37  #include "wptErrors.h"  #include "wptKeylist.h"
38  #include "wptKeyEdit.h"  #include "wptKeyserver.h"
39    #include "wptUTF8.h"
40  static subclass_s siglist_proc;  #include "wptTypes.h"
41    #include "wptVersion.h"
42    #include "wptErrors.h"
43  static int inline  #include "wptKeyEdit.h"
44  is_sig (listview_ctrl_t lv, int pos)  
45  {  static subclass_s siglist_proc;
46      char tmpbuf[256];  
47    
48      if (pos == -1)  static int
49          pos = listview_get_curr_pos (lv);  is_sig (listview_ctrl_t lv, int pos)
50      listview_get_item_text (lv, pos, 0, tmpbuf, 200);  {
51      if (*tmpbuf == ' ')      char tmpbuf[256];
52          return -1;  
53      return 0;      if (pos == -1)
54  }          pos = listview_get_curr_pos (lv);
55        if (pos == -1)
56            return 0;
57  /* Delete the selected signature from list view @lv. The      listview_get_item_text (lv, pos, 0, tmpbuf, 200);
58     key is given in @key. */      if (*tmpbuf == ' ')
59  static int          return -1;
60  do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key)      return 0;
61  {  }
62      int pos, npos, id;  
63      int signo=0, uidno=0;  
64      GpgKeyEdit *ke;  /* Delete the selected signature from list view @lv. The
65      gpgme_error_t err;     key is given in @key. */
66    static int
67      npos = pos = listview_get_curr_pos (lv);  do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key)
68      if (!is_sig (lv, -1))  {
69          return -1;      int pos, npos, id;
70      while (pos > 0 && is_sig (lv, pos)) {      int signo=0, uidno=0;
71          signo++;      GpgKeyEdit *ke;
72          pos--;      gpgme_error_t err;
73      }  
74      pos = npos;      npos = pos = listview_get_curr_pos (lv);
75      while (npos > 0) {      if (!is_sig (lv, -1))
76          if (!is_sig (lv, npos))          return -1;
77              uidno++;      while (pos > 0 && is_sig (lv, pos)) {
78          npos--;          signo++;
79      }          pos--;
80      uidno++;      }
81        pos = npos;
82      /* XXX: do not allow to delete the self signature */      while (npos > 0) {
83      id = log_box (_("Key Manager"), MB_YESNO,          if (!is_sig (lv, npos))
84                    _("Are you really sure you want to delete this signature from\n"              uidno++;
85                      "  \"%s\""), key->uid);          npos--;
86      if (id == IDNO)      }
87          return 0;      uidno++;
88    
89      ke = new GpgKeyEdit (key->keyid);      /* XXX: do not allow to delete the self signature */
90      if (!ke)      id = log_box (_("Key Manager"), MB_YESNO,
91          BUG (NULL);                        _("Are you really sure you want to delete this signature from\n"
92      err = ke->delUseridSignature (uidno, signo);                      "  \"%s\""), key->uid);
93      if (err)      if (id == IDNO)
94          msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);          return 0;
95      else  
96          listview_del_item (lv, pos);      ke = new GpgKeyEdit (key->keyid);
97      delete ke;      if (!ke)
98      key->update = 1; /*update*/          BUG (NULL);    
99      return err? -1 : 0;      err = ke->delUseridSignature (uidno, signo);
100  }      if (err)
101            msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);
102        else
103  /* Dialog box procedure to display the signature properties. */          listview_del_item (lv, pos);
104  static BOOL CALLBACK      delete ke;
105  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)      key->update = 1; /*update*/
106  {      return err? -1 : 0;
107      static listview_ctrl_t lv;  }
108      char tmpbuf[256];  
109      int n;  
110      struct {  /* Dialog box procedure to display the signature properties. */
111          unsigned int exportable:1;  static BOOL CALLBACK
112          unsigned int expired:1;  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
113          unsigned int nrev:1;  {
114          unsigned int rev:1;      static listview_ctrl_t lv;
115          const char * alg;      char tmpbuf[256];
116          int _class;      int n;
117      } ctx;      struct {
118      const char *fmt_templ = _("%s %s signature");          unsigned int exportable:1;
119            unsigned int expired:1;
120      switch (msg) {          unsigned int nrev:1;
121      case WM_SYSCOMMAND:          unsigned int rev:1;
122          if (LOWORD (wparam) == SC_CLOSE)          const char * alg;
123              EndDialog (dlg, TRUE);          int _class;
124          return FALSE;      } ctx;
125        const char *fmt_templ = _("%s %s signature");
126      case WM_INITDIALOG:  
127          lv = (listview_ctrl_t)lparam;      switch (msg) {
128          if (!lv)      case WM_SYSCOMMAND:
129              dlg_fatal_error (dlg, "could not get dialog param");          if (LOWORD (wparam) == SC_CLOSE)
130          memset (&ctx, 0, sizeof ctx);              EndDialog (dlg, TRUE);
131          n = listview_get_curr_pos (lv);          return FALSE;
132          listview_get_item_text (lv, n, 2, tmpbuf, DIM (tmpbuf)-1);  
133          if (!strstr (tmpbuf, "L"))      case WM_INITDIALOG:
134              ctx.exportable = 1;          lv = (listview_ctrl_t)lparam;
135          ctx._class = atoi (tmpbuf);          if (!lv)
136          if (ctx._class == 0)              dlg_fatal_error (dlg, "could not get dialog param");
137              ctx._class = 10;          memset (&ctx, 0, sizeof ctx);
138          else if (ctx._class < 10)          n = listview_get_curr_pos (lv);
139              ctx._class += 10;          listview_get_item_text (lv, n, 2, tmpbuf, DIM (tmpbuf)-1);
140          listview_get_item_text (lv, n, 6, tmpbuf, DIM (tmpbuf)-1);          if (!strstr (tmpbuf, "L"))
141          if (strstr (tmpbuf, "DSA"))                      ctx.exportable = 1;
142              ctx.alg = "DSA";          ctx._class = atoi (tmpbuf);
143          else if (strstr (tmpbuf, "RSA"))          if (ctx._class == 0)
144              ctx.alg = "RSA";              ctx._class = 10;
145          else          else if (ctx._class < 10)
146              ctx.alg = "ELG";              ctx._class += 10;
147          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,          listview_get_item_text (lv, n, 6, tmpbuf, DIM (tmpbuf)-1);
148                     ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg);          if (strstr (tmpbuf, "DSA"))        
149          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);              ctx.alg = "DSA";
150          listview_get_item_text (lv, n, 4, tmpbuf, DIM (tmpbuf)-1);          else if (strstr (tmpbuf, "RSA"))
151          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);              ctx.alg = "RSA";
152          SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);          else
153          if (ctx.exportable)              ctx.alg = "ELG";
154              CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,
155          listview_get_item_text (lv, n, 0, tmpbuf, DIM (tmpbuf)-1);                     ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg);
156          SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, tmpbuf+1);          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);
157          tmpbuf[0] = 0;          listview_get_item_text (lv, n, 4, tmpbuf, DIM (tmpbuf)-1);
158          listview_get_item_text (lv, n, 5, tmpbuf, DIM (tmpbuf)-1);          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);
159          if (strlen (tmpbuf) == 0) {          SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);
160              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);          if (ctx.exportable)
161              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);              CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);
162          }          listview_get_item_text (lv, n, 0, tmpbuf, DIM (tmpbuf)-1);
163          else {          SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, tmpbuf+1);
164              SYSTEMTIME st;          tmpbuf[0] = 0;
165              struct tm * tm;          listview_get_item_text (lv, n, 5, tmpbuf, DIM (tmpbuf)-1);
166              time_t t = time (NULL);          if (strlen (tmpbuf) == 0) {
167                ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);
168              memset (&st, 0, sizeof st);              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);
169              st.wYear = atoi (tmpbuf);          }
170              st.wMonth = atoi (tmpbuf+5);          else {
171              st.wDay = atoi (tmpbuf+8);              SYSTEMTIME st;
172              DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),              struct tm * tm;
173                                      GDT_VALID, &st);              time_t t = time (NULL);
174    
175              tm = localtime (&t);              memset (&st, 0, sizeof st);
176              tm->tm_mon++;              st.wYear = atoi (tmpbuf);
177              tm->tm_year += 1900;              st.wMonth = atoi (tmpbuf+5);
178              if (tm->tm_year > st.wYear)              st.wDay = atoi (tmpbuf+8);
179                  ctx.expired = 1;              DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),
180              else if (tm->tm_mon > st.wMonth)                                      GDT_VALID, &st);
181                  ctx.expired = 1;  
182              if (ctx.expired)              tm = localtime (&t);
183                  CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED);              tm->tm_mon++;
184          }              tm->tm_year += 1900;
185          SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));              if (tm->tm_year > st.wYear)
186          SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));                  ctx.expired = 1;
187          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));              else if (tm->tm_mon > st.wMonth)
188          SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired"));                  ctx.expired = 1;
189          SetWindowText (dlg, _("Signature Properties"));              if (ctx.expired)
190          SetForegroundWindow (dlg);                  CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED);
191          center_window (dlg, NULL);          }
192          return TRUE;          SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));
193            SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));
194      case WM_COMMAND:          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));
195          switch (LOWORD (wparam)) {          SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired"));
196          case IDOK:          SetWindowText (dlg, _("Signature Properties"));
197              EndDialog (dlg, TRUE);          SetForegroundWindow (dlg);
198              break;          center_window (dlg, NULL);
199          }          return TRUE;
200      }  
201        case WM_COMMAND:
202      return FALSE;          switch (LOWORD (wparam)) {
203  }          case IDOK:
204                EndDialog (dlg, TRUE);
205                break;
206  static BOOL CALLBACK          }
207  subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)      }
208  {  
209      listview_ctrl_t lv;      return FALSE;
210      winpt_key_t key;  }
211    
212      switch (msg) {  
213      case WM_KEYUP:  static BOOL CALLBACK
214          int virt_key = (int)wparam;  subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
215          key = (winpt_key_t)siglist_proc.opaque;  {
216          lv = key->callback.ctl;      listview_ctrl_t lv;
217          if (virt_key == VK_SPACE) {      winpt_key_t key;
218              if (is_sig (lv, -1))  
219                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,      switch (msg) {
220                                  sigprops_dlg_proc, (LPARAM)lv);      case WM_KEYUP:
221          }          int virt_key = (int)wparam;
222          else if (virt_key == VK_DELETE)          key = (winpt_key_t)siglist_proc.opaque;
223              do_delsig (dlg, lv, key);          lv = key->callback.ctl;
224          break;          if (virt_key == VK_SPACE) {
225      }              if (is_sig (lv, -1))
226      return CallWindowProc (siglist_proc.old, dlg, msg, wparam, lparam);                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
227  }                                  sigprops_dlg_proc, (LPARAM)lv);
228            }
229            else if (virt_key == VK_DELETE)
230  /* Return 1 if the list view @lv contains non-available keys. */              do_delsig (dlg, lv, key);
231  static int          break;
232  check_for_missing_keys (listview_ctrl_t lv)      }
233  {      return CallWindowProc (siglist_proc.old, dlg, msg, wparam, lparam);
234      int i, n;  }
235      char id[128];  
236        
237      n = listview_count_items( lv, 0 );  /* Return 1 if the list view @lv contains non-available keys. */
238      for( i = 0; i < n; i++ ) {  static int
239          listview_get_item_text( lv, i, 1, id, sizeof (id) - 1 );  check_for_missing_keys (listview_ctrl_t lv)
240          if( !strncmp( id, "NOKEY", 5 ) )  {
241              return 1;      int i, n;
242      }      char id[128];
243            
244      return 0;      n = listview_count_items( lv, 0 );
245  }      for( i = 0; i < n; i++ ) {
246            listview_get_item_text( lv, i, 1, id, sizeof (id) - 1 );
247            if( !strncmp( id, "NOKEY", 5 ) )
248  /* Receive all missing keys marked in the list @lv. */              return 1;
249  static int      }
250  recv_missing_keys (HWND dlg, listview_ctrl_t lv)      
251  {      return 0;
252      int i, n, rc;  }
253      char id[128], keyid[18+1];  
254        
255      n = listview_count_items (lv, 0);  /* Receive all missing keys marked in the list @lv. */
256      for( i = 0; i < n; i++ ) {  static int
257          listview_get_item_text( lv, i, 1, id, sizeof id - 1 );  recv_missing_keys (HWND dlg, listview_ctrl_t lv)
258          if( !strncmp( id, "NOKEY", 5 ) ) {  {
259              listview_get_item_text( lv, i, 4, keyid, sizeof keyid -1 );      int i, n, rc;
260              rc = hkp_recv_key( dlg, default_keyserver, default_keyserver_port, keyid, 0, 0 );      char id[128], keyid[18+1];
261              if( rc )                    
262                  break;      n = listview_count_items (lv, 0);
263          }      for( i = 0; i < n; i++ ) {
264      }          listview_get_item_text( lv, i, 1, id, sizeof id - 1 );
265                if( !strncmp( id, "NOKEY", 5 ) ) {
266      return rc;              listview_get_item_text( lv, i, 4, keyid, sizeof keyid -1 );
267  }              rc = hkp_recv_key( dlg, default_keyserver, default_keyserver_port, keyid, 0, 0 );
268                if( rc )              
269                    break;
270  /* Create a mini popup with available choices. */          }
271  static void      }
272  do_create_popup (HWND dlg)      
273  {      return rc;
274      HMENU hm, sm;  }
275      POINT p;  
276    
277      GetCursorPos (&p);  /* Create a mini popup with available choices. */
278      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));  static void
279      sm = GetSubMenu (hm, 0);  do_create_popup (HWND dlg)
280    {
281      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));      HMENU hm, sm;
282      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));      POINT p;
283    
284      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);      GetCursorPos (&p);
285        hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));
286      DestroyMenu (hm);      sm = GetSubMenu (hm, 0);
287      DestroyMenu (sm);  
288  }      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));
289        set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));
290    
291  /* Load the key property dialog with the selected key from @lv. */      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
292  static void  
293  do_load_keyprops (HWND dlg, listview_ctrl_t lv)      DestroyMenu (hm);
294  {      DestroyMenu (sm);
295      winpt_key_s k;  }
296      gpgme_key_t key;  
297      char keyid[32] = {0};  
298      char status[64] = {0}, creation[64] = {0};  /* Load the key property dialog with the selected key from @lv. */
299      int n = listview_get_curr_pos (lv);  static void
300    do_load_keyprops (HWND dlg, listview_ctrl_t lv)
301      listview_get_item_text (lv, n, 1, status, DIM (status)-1);  {
302      listview_get_item_text (lv, n, 3, creation, DIM (creation)-1);      winpt_key_s k;
303      listview_get_item_text (lv, n, 4, keyid, DIM (keyid)-1);      gpgme_key_t key;
304      if (!strcmp (status, "NOKEY")) {      char keyid[32] = {0};
305          msg_box (dlg, _("Key not found in keyring, please get it from the keyserver first."),      char status[64] = {0}, creation[64] = {0};
306                   _("Key Manager"), MB_INFO);      int n = listview_get_curr_pos (lv);
307          return;  
308      }      listview_get_item_text (lv, n, 1, status, DIM (status)-1);
309            listview_get_item_text (lv, n, 3, creation, DIM (creation)-1);
310      if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {      listview_get_item_text (lv, n, 4, keyid, DIM (keyid)-1);
311          if (strlen (creation) > 0)      if (!strcmp (status, "NOKEY")) {
312              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);          msg_box (dlg, _("Key not found in keyring, please get it from the keyserver first."),
313          return;                   _("Key Manager"), MB_INFO);
314      }          return;
315      memset (&k, 0, sizeof k);      }
316      k.keyid = keyid;      
317      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,      if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {
318                      keyprops_dlg_proc, (LPARAM)&k);          if (strlen (creation) > 0)
319  }              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);
320            return;
321        }
322  /* Dialog box procedure to list signatures. */      memset (&k, 0, sizeof k);
323  BOOL CALLBACK      k.keyid = keyid;
324  keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,
325  {                      keyprops_dlg_proc, (LPARAM)&k);
326      static listview_ctrl_t lv = NULL;  }
327      static struct winpt_key_s *k;  
328      char inf[384], keyid[18+1];      
329      int idx = 0, id, rc;  /* Dialog box procedure to list signatures. */
330      HWND sl;  BOOL CALLBACK
331        keysig_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
332      switch( msg ) {  {
333      case WM_INITDIALOG:      static listview_ctrl_t lv = NULL;
334          k = (winpt_key_t) lparam;      static struct winpt_key_s *k;
335          if (!k)      char inf[384], keyid[18+1];    
336              BUG (0);      int idx = 0, id, rc;
337          if (k->uid)      HWND sl;
338              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);      
339          SetWindowText (dlg, inf);      switch( msg ) {
340          #ifndef LANG_DE      case WM_INITDIALOG:
341          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));          k = (winpt_key_t) lparam;
342          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));          if (!k)
343          #endif              BUG (0);
344          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);          if (k->uid)
345          if (!check_for_missing_keys (lv))              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);
346              EnableWindow (GetDlgItem( dlg, IDC_KEYSIG_RECVKEY ), FALSE);          SetWindowText (dlg, inf);
347          k->callback.ctl = lv;          #ifndef LANG_DE
348          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));
349          siglist_proc.dlg = dlg;          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));
350          siglist_proc.opaque = k;          #endif
351          siglist_proc.current = (WNDPROC)subclass_dlg_proc;          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);
352          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);          if (!check_for_missing_keys (lv))
353          if (siglist_proc.old) {              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), FALSE);
354              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {          k->callback.ctl = lv;
355                  msg_box (dlg, _("Could not set keylist window procedure."),          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);
356                           _("Key Manager"), MB_ERR);          siglist_proc.dlg = dlg;
357                  BUG (0);          siglist_proc.opaque = k;
358              }          siglist_proc.current = (WNDPROC)subclass_dlg_proc;
359          }          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);
360          SetForegroundWindow (dlg);          if (siglist_proc.old) {
361          center_window (dlg, NULL);              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {
362          return TRUE;                  msg_box (dlg, _("Could not set keylist window procedure."),
363                                     _("Key Manager"), MB_ERR);
364      case WM_DESTROY:                  BUG (0);
365          if ( lv ) {              }
366              siglist_delete( lv );          }
367              lv = NULL;          SetForegroundWindow (dlg);
368          }          center_window (dlg, NULL);
369          return FALSE;          return TRUE;
370                    
371      case WM_SYSCOMMAND:      case WM_DESTROY:
372          if (LOWORD (wparam) == SC_CLOSE) {          if ( lv ) {
373              if (k->update)              siglist_delete( lv );
374                  keycache_update (0, k->keyid);              lv = NULL;
375              EndDialog (dlg, TRUE);          }
376          }          return FALSE;
377          return FALSE;          
378        case WM_SYSCOMMAND:
379      case WM_NOTIFY:          if (LOWORD (wparam) == SC_CLOSE) {
380          NMHDR * notify;              if (k->update)
381                            keycache_update (0, k->keyid);
382          notify = (NMHDR *)lparam;              EndDialog (dlg, TRUE);
383          if( notify && notify->code == NM_DBLCLK          }
384              && notify->idFrom == IDC_KEYSIG_LIST )          return FALSE;
385              do_load_keyprops (dlg, lv);  
386          if (notify && notify->code == NM_RCLICK &&      case WM_NOTIFY:
387              notify->idFrom == IDC_KEYSIG_LIST)          NMHDR *notify;
388              do_create_popup (dlg);          
389          break;          notify = (NMHDR *)lparam;
390                    if (notify && notify->code == NM_DBLCLK
391      case WM_COMMAND:              && notify->idFrom == IDC_KEYSIG_LIST)
392          switch ( LOWORD( wparam ) ) {              do_load_keyprops (dlg, lv);
393            if (notify && notify->code == NM_RCLICK &&
394          case ID_SIGCTX_KEYPROPS:              notify->idFrom == IDC_KEYSIG_LIST)
395              do_load_keyprops (dlg, lv);              do_create_popup (dlg);
396              break;          if (notify && notify->code == LVN_ITEMCHANGED &&
397                ((LPNMLISTVIEW)lparam)->uNewState) {
398          case ID_SIGCTX_PROPS:              idx = listview_get_curr_pos (lv);
399              if (is_sig (lv, -1))              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);
400                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY),
401                                  sigprops_dlg_proc, (LPARAM)lv);                            strcmp (inf, "NOKEY") == 0? TRUE: FALSE);
402              break;          }
403            break;
404          case IDC_KEYSIG_RECVKEY:          
405              idx = listview_get_curr_pos (lv);      case WM_COMMAND:
406              if (idx == -1) {          switch ( LOWORD( wparam ) ) {
407                  id = msg_box( dlg, _("Really receive all missing keys?"),  
408                                  _("Key Manager"), MB_YESNO|MB_INFO );          case ID_SIGCTX_KEYPROPS:
409                  if (id == IDYES) {              do_load_keyprops (dlg, lv);
410                      rc = recv_missing_keys (dlg, lv);              break;
411                      if( !rc )  
412                          keycache_set_reload (1);          case ID_SIGCTX_PROPS:
413                      return TRUE;              if (is_sig (lv, -1))
414                  }                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
415                  return TRUE;                                  sigprops_dlg_proc, (LPARAM)lv);
416              }              break;
417              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);  
418              if (strcmp (inf, "NOKEY"))          case IDC_KEYSIG_RECVKEY:
419                  return FALSE;              idx = listview_get_curr_pos (lv);
420              listview_get_item_text (lv, idx, 4, keyid, DIM (keyid)-1);              if (idx == -1) {
421              rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, keyid, 0, 0);                  id = msg_box( dlg, _("Really receive all missing keys?"),
422              if (!rc)                                  _("Key Manager"), MB_YESNO|MB_INFO );
423                  keycache_set_reload (1);                  if (id == IDYES) {
424              return TRUE;                      rc = recv_missing_keys (dlg, lv);
425                        if (!rc)
426          case IDC_KEYSIG_SIGPROPS:                          keycache_set_reload (1);
427              if (is_sig (lv, -1))                      return TRUE;
428                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  }
429                                  sigprops_dlg_proc, (LPARAM)lv);                  return TRUE;
430              return TRUE;              }
431                            listview_get_item_text (lv, idx, 4, keyid, DIM (keyid)-1);
432          case IDOK:              rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, keyid, 0, 0);
433              if (k->update)              if (!rc)
434                  keycache_update (0, k->keyid);                  keycache_update (0, keyid);
435              EndDialog (dlg, TRUE);              return TRUE;
436              return TRUE;  
437          }          case IDC_KEYSIG_SIGPROPS:
438          break;              if (is_sig (lv, -1))
439      }                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
440      return FALSE;                                  sigprops_dlg_proc, (LPARAM)lv);
441                return TRUE;
442                
443            case IDOK:
444                if (k->update)
445                    keycache_update (0, k->keyid);
446                EndDialog (dlg, TRUE);
447                return TRUE;
448            }
449            break;
450        }
451        return FALSE;
452  }  }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26