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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26