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

Diff of /trunk/Src/wptKeysignDlg.cpp

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

revision 25 by twoaday, Wed Oct 12 10:04:26 2005 UTC revision 36 by werner, Thu Oct 27 15:25:13 2005 UTC
# Line 1  Line 1 
1  /* wptKeysignDlg.cpp - Key signing dialog  /* wptKeysignDlg.cpp - Key signing dialog
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    #endif
24  #include "../resource.h"  
25  #include "wptGPG.h"  #include <windows.h>
26  #include "wptNLS.h"  #include <windows.h>
27  #include "wptW32API.h"  #include <commctrl.h>
28  #include "wptVersion.h"  
29  #include "wptTypes.h"  #include "../resource.h"
30  #include "wptErrors.h"  #include "wptGPG.h"
31  #include "wptCommonCtl.h"  #include "wptNLS.h"
32  #include "wptContext.h"  #include "wptW32API.h"
33  #include "wptDlgs.h"  #include "wptVersion.h"
34  #include "wptUTF8.h"  #include "wptTypes.h"
35  #include "wptRegistry.h"  #include "wptErrors.h"
36  #include "wptKeyList.h"  #include "wptCommonCtl.h"
37  #include "wptKeyEdit.h"  #include "wptContext.h"
38    #include "wptDlgs.h"
39  static int sig_class_choice = 0;  #include "wptUTF8.h"
40    #include "wptRegistry.h"
41  /* Return a beautified printable fingerprint of @fpr. */  #include "wptKeyList.h"
42  static const char*  #include "wptKeyEdit.h"
43  get_printable_fpr (const char *fpr)  
44  {  static int sig_class_choice = 0;
45      static char pfpr[64];      
46      int pos = 0;  /* Return a beautified printable fingerprint of @fpr. */
47      size_t i;  static const char*
48    get_printable_fpr (const char *fpr)
49      for (i = 0; i < strlen (fpr); i += 4) {  {
50          pfpr[pos++] = fpr[i];      static char pfpr[64];    
51          pfpr[pos++] = fpr[i+1];      int pos = 0;
52          pfpr[pos++] = fpr[i+2];      size_t i;
53          pfpr[pos++] = fpr[i+3];  
54          pfpr[pos++] = ' ';      for (i = 0; i < strlen (fpr); i += 4) {
55      }          pfpr[pos++] = fpr[i];
56      return pfpr;          pfpr[pos++] = fpr[i+1];
57  }          pfpr[pos++] = fpr[i+2];
58            pfpr[pos++] = fpr[i+3];
59            pfpr[pos++] = ' ';
60  /* Return human friendly information about the key @key. */      }
61  static const char*      return pfpr;
62  get_keyinfo (gpgme_key_t key)  }
63  {  
64      static char buf[64+16];  
65      struct winpt_key_s k;  /* Return human friendly information about the key @key. */
66    static const char*
67      memset (&k, 0, sizeof (k));  get_keyinfo (gpgme_key_t key)
68      winpt_get_seckey (key->subkeys->keyid, &k);  {
69      _snprintf (buf, DIM (buf)-1-16, "%d-bit %s key, ID %s",      static char buf[64+16];
70          key->subkeys->length,      struct winpt_key_s k;
71          get_key_pubalgo (key->subkeys->pubkey_algo),  
72          key->subkeys->keyid+8);      memset (&k, 0, sizeof (k));
73      if (k.ext->gloflags.divert_to_card)      winpt_get_seckey (key->subkeys->keyid, &k);
74          strcat (buf, " (Card)");      _snprintf (buf, DIM (buf)-1-16, "%d-bit %s key, ID %s",
75      return buf;          key->subkeys->length,
76  }          get_key_pubalgo (key->subkeys->pubkey_algo),
77            key->subkeys->keyid+8);
78        if (k.ext->gloflags.divert_to_card)
79  /* Fill the secret key combo-box with all entries from the cache.          strcat (buf, " (Card)");
80     @dlg is the handle to the combo-box. @keyid show which key to skip.      return buf;
81     Return value: 0 on success. */  }
82  static int  
83  do_fill_seckeylist (HWND dlg, const char *keyid)  
84  {  /* Fill the secret key combo-box with all entries from the cache.
85      gpg_keycache_t sec;     @dlg is the handle to the combo-box. @keyid show which key to skip.
86      gpgme_key_t pk;     Return value: 0 on success. */
87      const char * s;  static int
88      char * uid, * p;      do_fill_seckeylist (HWND dlg, const char *keyid)
89      int i = 0, n=0;  {
90        gpg_keycache_t sec;
91      sec = keycache_get_ctx (0);      gpgme_key_t pk;
92      if (!sec)      const char * s;
93          BUG (0);      char * uid, * p;    
94      gpg_keycache_rewind (sec);      int i = 0, n=0;
95      while (!gpg_keycache_next_key (sec, 1, &pk)) {  
96          if (!pk)      sec = keycache_get_ctx (0);
97              continue;      if (!sec)
98          s = pk->subkeys->keyid;          BUG (0);
99          if (!strcmp (s, keyid))      gpg_keycache_rewind (sec);
100              continue;      while (!gpg_keycache_next_key (sec, 1, &pk)) {
101          /* skip all ElGamal sign+encrypt keys */          if (!pk)
102          if (pk->subkeys->pubkey_algo == GPGME_PK_ELG)              continue;
103              continue;          s = pk->subkeys->keyid;
104          /* make sure the public key is okay not: revoked, expired or disabled. */          if (!strcmp (s, keyid))
105          if (pk->expired ||pk->revoked || pk->disabled)              continue;
106              continue;          /* skip all ElGamal sign+encrypt keys */
107          s = pk->uids->name;          if (pk->subkeys->pubkey_algo == GPGME_PK_ELG)
108          if (!s)              continue;
109              continue;          /* make sure the public key is okay not: revoked, expired or disabled. */
110          uid = utf8_to_wincp (s, strlen (s));          if (pk->expired ||pk->revoked || pk->disabled)
111          p = new char[strlen (uid) + 64];              continue;
112          if (!p)          s = pk->uids->name;
113              BUG (NULL);          if (!s)
114          _snprintf (p, strlen (uid) + 63, "%s (%s)", uid, get_keyinfo (pk));              continue;
115          SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST, CB_ADDSTRING, i, (LPARAM)(char *)p);          uid = utf8_to_wincp (s, strlen (s));
116          SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST, CB_SETITEMDATA, i++, (LPARAM)(DWORD)pk);          p = new char[strlen (uid) + 64];
117          free_if_alloc (p);          if (!p)
118          free (uid);              BUG (NULL);
119          n++;          _snprintf (p, strlen (uid) + 63, "%s (%s)", uid, get_keyinfo (pk));
120      }          SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST, CB_ADDSTRING, i, (LPARAM)(char *)p);
121      SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST, CB_SETCURSEL, 0, 0);          SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST, CB_SETITEMDATA, i++, (LPARAM)(DWORD)pk);
122      if (!n)          free_if_alloc (p);
123          return -1;          free (uid);
124      return 0;          n++;
125  }      }
126        SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST, CB_SETCURSEL, 0, 0);
127        if (!n)
128  /* Check if the selected key is protected and en- or disable the          return -1;
129     passphrase control. */      return 0;
130  static void  }
131  do_check_protection (HWND dlg)  
132  {  
133      int idx, protec;  /* Check if the selected key is protected and en- or disable the
134      gpgme_key_t key;     passphrase control. */
135      struct winpt_key_s k;  static void
136    do_check_protection (HWND dlg)
137      idx = SendDlgItemMessage( dlg, IDC_KEYSIGN_KEYLIST, CB_GETCURSEL, 0, 0 );  {
138      key = (gpgme_key_t)SendDlgItemMessage( dlg, IDC_KEYSIGN_KEYLIST, CB_GETITEMDATA, (WPARAM)idx, 0 );      int idx, protec;
139      if (key) {      gpgme_key_t key;
140          winpt_get_seckey (key->subkeys->keyid, &k);      struct winpt_key_s k;
141          protec = k.is_protected;  
142          if (!protec)      idx = SendDlgItemMessage( dlg, IDC_KEYSIGN_KEYLIST, CB_GETCURSEL, 0, 0 );
143              protec = k.ext->gloflags.divert_to_card;      key = (gpgme_key_t)SendDlgItemMessage( dlg, IDC_KEYSIGN_KEYLIST, CB_GETITEMDATA, (WPARAM)idx, 0 );
144          EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_PASSPHRASE), protec? TRUE : FALSE);      if (key) {
145      }          winpt_get_seckey (key->subkeys->keyid, &k);
146  }          protec = k.is_protected;
147            if (!protec)
148                protec = k.ext->gloflags.divert_to_card;
149  /* Dialog box procedure to choose the signature class. */          EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_PASSPHRASE), protec? TRUE : FALSE);
150  BOOL CALLBACK      }
151  sig_class_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  }
152  {  
153      switch (msg) {  
154      case WM_INITDIALOG:  /* Dialog box procedure to choose the signature class. */
155          SetWindowText (dlg, _("Choose Signature Class"));  BOOL CALLBACK
156          SetDlgItemText (dlg, IDC_SIGCLASS_TITLEINF, _("How carefully have you verified the key you are about to sign actually belongs to the person? If you don't know what to anwser, use \"0\"."));  sig_class_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
157          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS0, _("(0) I will not answer (default)"));  {
158          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS1, _("(1) I have not checked at all."));      switch (msg) {
159          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS2, _("(2) I have done causal checking."));      case WM_INITDIALOG:
160          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS3, _("(3) I have done very careful checkings."));          SetWindowText (dlg, _("Choose Signature Class"));
161          CheckDlgButton (dlg, IDC_SIGCLASS_CLASS0, BST_CHECKED);          SetDlgItemText (dlg, IDC_SIGCLASS_TITLEINF, _("How carefully have you verified the key you are about to sign actually belongs to the person? If you don't know what to anwser, use \"0\"."));
162          SetForegroundWindow (dlg);          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS0, _("(0) I will not answer (default)"));
163          center_window (dlg, NULL);          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS1, _("(1) I have not checked at all."));
164          return TRUE;          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS2, _("(2) I have done causal checking."));
165            SetDlgItemText (dlg, IDC_SIGCLASS_CLASS3, _("(3) I have done very careful checkings."));
166      case WM_COMMAND:          CheckDlgButton (dlg, IDC_SIGCLASS_CLASS0, BST_CHECKED);
167          switch( LOWORD( wparam ) ) {          SetForegroundWindow (dlg);
168          case IDOK:          center_window (dlg, NULL);
169              if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS0))          return TRUE;
170                  sig_class_choice = 0;  
171              else if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS1))      case WM_COMMAND:
172                  sig_class_choice = 1;          switch( LOWORD( wparam ) ) {
173              else if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS2))          case IDOK:
174                  sig_class_choice = 2;              if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS0))
175              else if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS3))                  sig_class_choice = 0;
176                  sig_class_choice = 3;              else if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS1))
177              else                  sig_class_choice = 1;
178                  sig_class_choice = 0;              else if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS2))
179              EndDialog (dlg, TRUE);                  sig_class_choice = 2;
180              return TRUE;              else if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS3))
181          }                  sig_class_choice = 3;
182          break;              else
183      }                  sig_class_choice = 0;
184                EndDialog (dlg, TRUE);
185      return FALSE;              return TRUE;
186  }          }
187            break;
188        }
189  /* Return the humand friendly expiration date of @key. */  
190  static const char*      return FALSE;
191  get_expire_date (gpgme_key_t key)  }
192  {  
193      static char tmp[64];  
194    /* Return the humand friendly expiration date of @key. */
195      u32 u = key->subkeys->expires;  static const char*
196      if (!u)  get_expire_date (gpgme_key_t key)
197          return "never";  {
198      return get_key_expire_date (u);      static char tmp[64];
199  }  
200        u32 u = key->subkeys->expires;
201        if (!u)
202  /* Dialog box procedure to sign a key. */          return _("never");
203  BOOL CALLBACK      return get_key_expire_date (u);
204  keysign_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  }
205  {  
206      static winpt_key_t key;  /* Display photo of key @key in a separate window. */
207      GpgKeyEdit *ke;  static void
208      gpgme_error_t err;  show_photo (winpt_key_t key)
209      gpgme_key_t k;  {
210      SYSTEMTIME st;      /* XXX: fill it with life. */
211      HWND h;  }
212      char keymsg[4096], pwd[256], *uid = NULL;  
213      const char *keyid, *s;  
214      u32 created;  /* Dialog box procedure to sign a key. */
215      int type, expires=0, idx;  BOOL CALLBACK
216        keysign_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
217      switch ( msg )  {  {
218      case WM_INITDIALOG:      static winpt_key_t key;
219          if (lparam == NULL)      GpgKeyEdit *ke;
220              dlg_fatal_error (dlg, "Could not get dialog param.");      gpgme_error_t err;
221          #ifndef LANG_DE      gpgme_key_t k;
222          SetWindowText (dlg, _("Key Signing"));      SYSTEMTIME st;
223          #endif      HWND h;
224          key = (winpt_key_t) lparam;      char keymsg[2048], pwd[256];
225          created = key->ctx->subkeys->timestamp;      char *uid = NULL;
226          s = key->ctx->uids->uid;      const char *keyid, *s;
227          if (s)      int type, expires=0, idx;
228              uid = utf8_to_wincp (s, strlen (s));      
229          _snprintf (keymsg, sizeof keymsg -1,      switch ( msg )  {
230                     _("pub %d/%s  created: %s    expires: %s\n\n"      case WM_INITDIALOG:
231                       "Primary key fingerprint: %s\n\n"          if (lparam == NULL)
232                       "\t%s\n\n"              dlg_fatal_error (dlg, "Could not get dialog param.");
233                       "\nAre you really sure that you want to sign this key with YOUR key?\n"),          #ifndef LANG_DE
234                     key->ctx->subkeys->length,          SetWindowText (dlg, _("Key Signing"));
235                     key->ctx->subkeys->keyid+8,          #endif
236                     get_key_created (key->ctx->subkeys->timestamp),          key = (winpt_key_t) lparam;
237                     get_expire_date (key->ctx),          s = key->ctx->uids->uid;
238                     get_printable_fpr (key->ctx->subkeys->fpr),          uid = utf8_to_wincp (s, strlen (s));
239                     uid);          _snprintf (keymsg, sizeof keymsg -1,
240          free (uid);                     _("pub %d/%s  created: %s    expires: %s\n\n"
241          s = key->ctx->subkeys->keyid;                       "Primary key fingerprint: %s\n\n"
242          if (do_fill_seckeylist (dlg, s)) {                       "\t%s\n\n"
243              msg_box( dlg, _("No valid secret key found."), _("Key Signing"), MB_ERR );                       "\nAre you really sure that you want to sign this key with YOUR key?\n"),
244              EndDialog( dlg, FALSE );                     key->ctx->subkeys->length,
245          }                     key->ctx->subkeys->keyid+8,
246          SetDlgItemText (dlg, IDC_KEYSIGN_INFOS, keymsg);                     get_key_created (key->ctx->subkeys->timestamp),
247          #ifndef LANG_DE                     get_expire_date (key->ctx),
248          SetDlgItemText (dlg, IDC_KEYSIGN_LOCAL, _("Sign local only (non exportable signature)"));                     get_printable_fpr (key->ctx->subkeys->fpr),
249          SetDlgItemText (dlg, IDC_KEYSIGN_EXPSIG, _("Signature expires on"));                     uid);
250          SetDlgItemText (dlg, IDC_KEYSIGN_NREV, _("Sign non-revocably"));          free (uid);
251          #endif          s = key->ctx->subkeys->keyid;
252          CheckDlgButton (dlg, IDC_KEYSIGN_LOCAL, BST_CHECKED);          if (do_fill_seckeylist (dlg, s)) {
253          CheckDlgButton (dlg, IDC_KEYSIGN_EXPSIG, BST_UNCHECKED);              msg_box (dlg, _("No valid secret key found."), _("Key Signing"), MB_ERR);
254          CheckDlgButton (dlg, IDC_KEYSIGN_ASKLEVEL, BST_UNCHECKED);              EndDialog (dlg, FALSE);
255          EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), FALSE);          }
256          if (reg_prefs.expert == 0)          SetDlgItemText (dlg, IDC_KEYSIGN_INFOS, keymsg);
257              ShowWindow (GetDlgItem (dlg, IDC_KEYSIGN_NREV), SW_HIDE);          #ifndef LANG_DE
258          SetForegroundWindow( dlg );          SetDlgItemText (dlg, IDC_KEYSIGN_LOCAL, _("Sign local only (non exportable signature)"));
259          h = GetDlgItem( dlg, IDC_KEYSIGN_PASSPHRASE );          SetDlgItemText (dlg, IDC_KEYSIGN_EXPSIG, _("Signature expires on"));
260          SetFocus( h );          SetDlgItemText (dlg, IDC_KEYSIGN_NREV, _("Sign non-revocably"));
261          return FALSE;          SetDlgItemText (dlg, IDC_KEYSIGN_ASKLEVEL, _("&Ask for certification level"));
262                SetDlgItemText (dlg, IDC_KEYSIGN_PWDINF, _("Passphrase"));
263      case WM_DESTROY:          #endif
264          sig_class_choice = 0;          CheckDlgButton (dlg, IDC_KEYSIGN_LOCAL, BST_CHECKED);
265          break;          CheckDlgButton (dlg, IDC_KEYSIGN_EXPSIG, BST_UNCHECKED);
266            CheckDlgButton (dlg, IDC_KEYSIGN_ASKLEVEL, BST_UNCHECKED);
267      case WM_SYSCOMMAND:          EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), FALSE);
268          if( LOWORD( wparam ) == SC_CLOSE ) {          if (reg_prefs.expert == 0)
269              SetDlgItemText( dlg, IDC_KEYSIGN_PASSPHRASE, "" );              ShowWindow (GetDlgItem (dlg, IDC_KEYSIGN_NREV), SW_HIDE);
270              EndDialog( dlg, TRUE );          if (key->ext && key->ext->attrib.len > 0)
271          }              EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_SHOWIMG), TRUE);
272          return FALSE;          SetForegroundWindow (dlg);
273                    h = GetDlgItem (dlg, IDC_KEYSIGN_PASSPHRASE);
274      case WM_COMMAND:          SetFocus (h);
275          if( HIWORD( wparam ) == CBN_SELCHANGE ) {          return FALSE;
276              do_check_protection( dlg );      
277              break;      case WM_DESTROY:
278          }          sig_class_choice = 0;
279          if (HIWORD (wparam) == BN_CLICKED && LOWORD (wparam) == IDC_KEYSIGN_EXPSIG) {          break;
280              int enable = IsDlgButtonChecked (dlg, IDC_KEYSIGN_EXPSIG);  
281              EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), enable? TRUE : FALSE);      case WM_SYSCOMMAND:
282          }          if( LOWORD( wparam ) == SC_CLOSE ) {
283                SetDlgItemText( dlg, IDC_KEYSIGN_PASSPHRASE, "" );
284          switch( LOWORD( wparam ) ) {              EndDialog( dlg, TRUE );
285          case IDOK:          }
286              if (IsDlgButtonChecked (dlg, IDC_KEYSIGN_ASKLEVEL))          return FALSE;
287                  dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_SIGCLASS, dlg,          
288                                    sig_class_dlg_proc, (LPARAM)NULL,      case WM_COMMAND:
289                                    _("Choose Signature Class"),  IDS_WINPT_SIGCLASS);          if (HIWORD( wparam ) == CBN_SELCHANGE) {
290              type = IsDlgButtonChecked (dlg, IDC_KEYSIGN_LOCAL);              do_check_protection (dlg);
291              if (type)              break;
292                  type = GPG_EDITKEY_LSIGN;          }
293              else          if (HIWORD (wparam) == BN_CLICKED && LOWORD (wparam) == IDC_KEYSIGN_EXPSIG) {
294                  type = GPG_EDITKEY_SIGN;              int enable = IsDlgButtonChecked (dlg, IDC_KEYSIGN_EXPSIG);
295                EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), enable? TRUE : FALSE);
296              if (reg_prefs.expert && IsDlgButtonChecked (dlg, IDC_KEYSIGN_NREV)) {          }
297                  type = GPG_EDITKEY_NRSIGN;  
298                  if (type == GPG_EDITKEY_LSIGN)          switch( LOWORD( wparam ) ) {
299                      type = GPG_EDITKEY_NRLSIGN;          case IDOK:
300              }              if (IsDlgButtonChecked (dlg, IDC_KEYSIGN_ASKLEVEL))
301              if (IsDlgButtonChecked (dlg, IDC_KEYSIGN_EXPSIG)) {                  dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_SIGCLASS, dlg,
302                  expires = 1;                                    sig_class_dlg_proc, (LPARAM)NULL,
303                  DateTime_GetSystemtime (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), &st);                                    _("Choose Signature Class"),  IDS_WINPT_SIGCLASS);
304                  sprintf (keymsg, "%04d-%02d-%02d", st.wYear, st.wMonth, st.wDay);              type = IsDlgButtonChecked (dlg, IDC_KEYSIGN_LOCAL);
305              }              if (type)
306                    type = GPG_EDITKEY_LSIGN;
307              /* XXX: check for --ask-cert-level and --ask-cert-expire in the gpg.conf              else
308                      if an advanced button is checked and offer to add it to the config                  type = GPG_EDITKEY_SIGN;
309                      file. */  
310                if (reg_prefs.expert && IsDlgButtonChecked (dlg, IDC_KEYSIGN_NREV)) {
311              GetDlgItemText( dlg, IDC_KEYSIGN_PASSPHRASE, pwd, DIM (pwd)-1);                  type = GPG_EDITKEY_NRSIGN;
312              keyid = key->ctx->subkeys->keyid;                  if (type == GPG_EDITKEY_LSIGN)
313              if( !keyid ) {                      type = GPG_EDITKEY_NRLSIGN;
314                  msg_box( dlg, _("Could not get Key ID from key."), _("Key Signing"), MB_ERR );              }
315                  return TRUE;              if (IsDlgButtonChecked (dlg, IDC_KEYSIGN_EXPSIG)) {
316              }                  expires = 1;
317              ke = new GpgKeyEdit (keyid);                  DateTime_GetSystemtime (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), &st);
318              if (!ke)                  sprintf (keymsg, "%04d-%02d-%02d", st.wYear, st.wMonth, st.wDay);
319                  BUG (NULL);              }
320              ke->setPassphrase (pwd);  
321              idx = SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST, CB_GETCURSEL, 0, 0);              /* XXX: check for --ask-cert-level and --ask-cert-expire in the gpg.conf
322              k = (gpgme_key_t)SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,                      if an advanced button is checked and offer to add it to the config
323                                                   CB_GETITEMDATA, (WPARAM)idx, 0);                      file. */
324              if (k)  
325                  ke->setLocalUser (k);              GetDlgItemText( dlg, IDC_KEYSIGN_PASSPHRASE, pwd, DIM (pwd)-1);
326                keyid = key->ctx->subkeys->keyid;
327              err = ke->signKey (type, sig_class_choice, expires? keymsg : "0");              if( !keyid ) {
328              memset (&pwd, 0, sizeof pwd);                            msg_box( dlg, _("Could not get Key ID from key."), _("Key Signing"), MB_ERR );
329              if (err) {                  return TRUE;
330                  delete ke;              }
331                  msg_box (dlg, gpgme_strerror (err), _("Key Signing"), MB_ERR);              ke = new GpgKeyEdit (keyid);
332                  return TRUE;              if (!ke)
333              }                  BUG (NULL);
334              if (ke->getResultValue () != 0)              ke->setPassphrase (pwd);
335                  msg_box (dlg, _("This key is already signed by your key"), _("Key Signing"), MB_INFO);              idx = SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST, CB_GETCURSEL, 0, 0);
336              else {              k = (gpgme_key_t)SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,
337                  status_box (dlg, _("Key successfully signed."), PGM_NAME);                                                   CB_GETITEMDATA, (WPARAM)idx, 0);
338                  key->update = 1;              if (k)
339              }                  ke->setLocalUser (k);
340              delete ke;  
341              EndDialog (dlg, TRUE);              err = ke->signKey (type, sig_class_choice, expires? keymsg : "0");
342              return TRUE;              memset (&pwd, 0, sizeof pwd);          
343                            if (err) {
344          case IDCANCEL:                  delete ke;
345              EndDialog (dlg, FALSE);                  msg_box (dlg, gpgme_strerror (err), _("Key Signing"), MB_ERR);
346              return TRUE;                  return TRUE;
347          }              }
348          break;              if (ke->getResult () != 0)
349      }                  msg_box (dlg, _("This key is already signed by your key"), _("Key Signing"), MB_INFO);
350                    else {
351      return FALSE;                  status_box (dlg, _("Key successfully signed."), PGM_NAME);
352  }                  key->update = 1;
353                }
354                delete ke;
355                EndDialog (dlg, TRUE);
356                return TRUE;
357                
358            case IDCANCEL:
359                EndDialog (dlg, FALSE);
360                return TRUE;
361    
362            case IDC_KEYSIGN_SHOWIMG:
363                show_photo (key);
364                return TRUE;
365            }
366            break;
367        }
368        
369        return FALSE;
370    }
371    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26