/[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 48 by werner, Mon Oct 31 21:14:11 2005 UTC revision 255 by twoaday, Tue Aug 1 16:37:23 2006 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-2006 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
# Line 17  Line 17 
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  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
21  #include <config.h>  #include <config.h>
22  #endif  #endif
23    
24  #include <windows.h>  #include <windows.h>
25  #include <commctrl.h>  #include <commctrl.h>
26    #include <time.h>
27    #include <assert.h>
28    
29  #include "resource.h"  #include "resource.h"
30  #include "wptGPG.h"  #include "wptGPG.h"
# Line 40  Line 41 
41  #include "wptKeylist.h"  #include "wptKeylist.h"
42  #include "wptKeyEdit.h"  #include "wptKeyEdit.h"
43    
44  static int sig_class_choice = 0;  
45    void key_unload_photo (HWND dlg);
46    int  key_load_photo (HWND dlg, gpgme_key_t key, gpgme_validity_t *r_valid);
47    const char* get_photo_tmpname (HWND dlg);
48    
49  /* Return a beautified printable fingerprint of @fpr. */  /* Return a beautified printable fingerprint of @fpr. */
50  static const char*  static const char*
51  get_printable_fpr (const char *fpr)  get_printable_fpr (const char *fpr)
52  {  {
53      static char pfpr[64];          static char pfpr[64];
54      int pos = 0;      int pos = 0;
55      size_t i;      size_t i;
56    
# Line 62  get_printable_fpr (const char *fpr) Line 66  get_printable_fpr (const char *fpr)
66    
67    
68  /* Return human friendly information about the key @key. */  /* Return human friendly information about the key @key. */
69  static const char*  const char*
70  get_keyinfo (gpgme_key_t key)  get_keyinfo (gpgme_key_t key)
71  {  {
72      static char buf[64+16];      static char buf[64+16];
73      struct winpt_key_s k;      struct winpt_key_s k;
74    
75      memset (&k, 0, sizeof (k));      memset (&k, 0, sizeof (k));
76      winpt_get_seckey (key->subkeys->keyid, &k);      if (winpt_get_seckey (key->subkeys->keyid, &k))
77      _snprintf (buf, DIM (buf)-1-16, "%d-bit %s key, ID %s",          BUG (0);
78          key->subkeys->length,      _snprintf (buf, DIM (buf)-1-16, _("%d-bit %s key, ID 0x%s"),
79          get_key_pubalgo (key->subkeys->pubkey_algo),                 key->subkeys->length,
80          key->subkeys->keyid+8);                 get_key_pubalgo (key->subkeys->pubkey_algo),
81                   key->subkeys->keyid+8);
82      if (k.ext->gloflags.divert_to_card)      if (k.ext->gloflags.divert_to_card)
83          strcat (buf, " (Card)");          strcat (buf, " (Card)");
84      return buf;      return buf;
# Line 87  static int Line 92  static int
92  do_fill_seckeylist (HWND dlg, const char *keyid)  do_fill_seckeylist (HWND dlg, const char *keyid)
93  {  {
94      gpg_keycache_t sec;      gpg_keycache_t sec;
95      gpgme_key_t pk;      gpgme_key_t pk, defkey;
96      const char * s;      const char *s, *inf;
97      char * uid, * p;          char *uid, *p;
98      int i = 0, n=0;      int i = 0, n = 0, curr_sel = 0;
99        int len = 0;
100    
101      sec = keycache_get_ctx (0);      sec = keycache_get_ctx (0);
102      if (!sec)      gpg_keycache_get_default_key (sec, &defkey);
         BUG (0);  
103      gpg_keycache_rewind (sec);      gpg_keycache_rewind (sec);
104      while (!gpg_keycache_next_key (sec, 1, &pk)) {      while (!gpg_keycache_next_key (sec, 1, &pk)) {
105          if (!pk)          if (!pk)
# Line 111  do_fill_seckeylist (HWND dlg, const char Line 116  do_fill_seckeylist (HWND dlg, const char
116          s = pk->uids->name;          s = pk->uids->name;
117          if (!s)          if (!s)
118              continue;              continue;
119          uid = utf8_to_wincp (s, strlen (s));          if (defkey && !strcmp (defkey->subkeys->keyid, pk->subkeys->keyid))
120          p = new char[strlen (uid) + 64];              curr_sel = i;
121            uid = utf8_to_native (s);
122            inf = get_keyinfo (pk);
123            len = strlen (uid) + strlen (inf) + 8;
124            p = new char[len+1];
125          if (!p)          if (!p)
126              BUG (NULL);              BUG (NULL);
127          _snprintf (p, strlen (uid) + 63, "%s (%s)", uid, get_keyinfo (pk));          _snprintf (p, len, "%s (%s)", uid, inf);
128          SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST, CB_ADDSTRING, i, (LPARAM)(char *)p);          SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,
129          SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST, CB_SETITEMDATA, i++, (LPARAM)(DWORD)pk);                              CB_ADDSTRING, i, (LPARAM)(char *)p);
130            SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,
131                                CB_SETITEMDATA, i++, (LPARAM)(DWORD)pk);
132          free_if_alloc (p);          free_if_alloc (p);
133          free (uid);          safe_free (uid);
134          n++;          n++;
135      }      }
136      SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST, CB_SETCURSEL, 0, 0);      SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,
137                            CB_SETCURSEL, (WPARAM)curr_sel, 0);
138      if (!n)      if (!n)
139          return -1;          return -1;
140      return 0;      return 0;
# Line 134  do_fill_seckeylist (HWND dlg, const char Line 146  do_fill_seckeylist (HWND dlg, const char
146  static void  static void
147  do_check_protection (HWND dlg)  do_check_protection (HWND dlg)
148  {  {
     int idx, protec;  
149      gpgme_key_t key;      gpgme_key_t key;
150      struct winpt_key_s k;      struct winpt_key_s k;
151        int idx, protec;    
152    
153      idx = SendDlgItemMessage( dlg, IDC_KEYSIGN_KEYLIST, CB_GETCURSEL, 0, 0 );      idx = SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST, CB_GETCURSEL, 0, 0);
154      key = (gpgme_key_t)SendDlgItemMessage( dlg, IDC_KEYSIGN_KEYLIST, CB_GETITEMDATA, (WPARAM)idx, 0 );      key = (gpgme_key_t)SendDlgItemMessage (dlg, IDC_KEYSIGN_KEYLIST,
155                                               CB_GETITEMDATA, (WPARAM)idx, 0);
156      if (key) {      if (key) {
157          winpt_get_seckey (key->subkeys->keyid, &k);          if (winpt_get_seckey (key->subkeys->keyid, &k))
158                BUG (0);
159          protec = k.is_protected;          protec = k.is_protected;
160          if (!protec)          if (!protec)
161              protec = k.ext->gloflags.divert_to_card;              protec = k.ext->gloflags.divert_to_card;
# Line 150  do_check_protection (HWND dlg) Line 164  do_check_protection (HWND dlg)
164  }  }
165    
166    
167    /* Show the photographic ID of the key in a separate dialog window. */
168    BOOL CALLBACK
169    showphoto_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
170    {
171        static winpt_key_t key;
172        char buf[200];
173    
174        switch (msg) {
175        case WM_INITDIALOG:
176            key = (winpt_key_t)lparam;
177            if (!key)
178                BUG (0);
179            key_load_photo (dlg, key->ctx, NULL);
180            _snprintf (buf, sizeof (buf)-1, _("Photo of %s"), key->uid);
181            SetWindowText (dlg, buf);
182            SetForegroundWindow (dlg);
183            break;
184    
185        case WM_PAINT:
186            if (key->ext && key->ext->attrib.len > 0) {
187                POINT p;
188                p.x = p.y = 0;
189                PTD_jpg_show (GetDlgItem (dlg, IDC_SHOWPHOTO_IMG),
190                                &p, get_photo_tmpname (dlg));
191            }
192            break;
193    
194        case WM_DESTROY:
195            key_unload_photo (dlg);
196            break;
197    
198        case WM_COMMAND:
199            switch (LOWORD (wparam)) {
200            case IDCANCEL:
201            case IDOK:
202                EndDialog (dlg, TRUE);
203                break;
204            }
205            break;
206        }
207    
208        return FALSE;
209    }
210    
211    
212  /* Dialog box procedure to choose the signature class. */  /* Dialog box procedure to choose the signature class. */
213  BOOL CALLBACK  BOOL CALLBACK
214  sig_class_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  sig_class_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
215  {  {
216        HWND parent;
217        int sig_class = 0;
218    
219      switch (msg) {      switch (msg) {
220      case WM_INITDIALOG:      case WM_INITDIALOG:
221            parent = (HWND)lparam;
222          SetWindowText (dlg, _("Choose Signature Class"));          SetWindowText (dlg, _("Choose Signature Class"));
223          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\"."));          SetDlgItemText (dlg, IDC_SIGCLASS_TITLEINF,
224          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS0, _("(0) I will not answer (default)"));                          _("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\"."));
225          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS1, _("(1) I have not checked at all."));          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS0,
226          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS2, _("(2) I have done causal checking."));                          _("(0) I will not answer (default)"));
227          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS3, _("(3) I have done very careful checkings."));          SetDlgItemText (dlg, IDC_SIGCLASS_CLASS1,
228                            _("(1) I have not checked at all."));
229            SetDlgItemText (dlg, IDC_SIGCLASS_CLASS2,
230                            _("(2) I have done causal checking."));
231            SetDlgItemText (dlg, IDC_SIGCLASS_CLASS3,
232                            _("(3) I have done very careful checking."));
233          CheckDlgButton (dlg, IDC_SIGCLASS_CLASS0, BST_CHECKED);          CheckDlgButton (dlg, IDC_SIGCLASS_CLASS0, BST_CHECKED);
234          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
235          center_window (dlg, NULL);          center_window (dlg, parent? parent : NULL);
236          return TRUE;          return TRUE;
237    
238      case WM_COMMAND:      case WM_COMMAND:
239          switch( LOWORD( wparam ) ) {          switch (LOWORD (wparam)) {
240          case IDOK:          case IDOK:
241              if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS0))              if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS0))
242                  sig_class_choice = 0;                  sig_class = 0;
243              else if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS1))              else if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS1))
244                  sig_class_choice = 1;                  sig_class = 1;
245              else if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS2))              else if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS2))
246                  sig_class_choice = 2;                  sig_class = 2;
247              else if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS3))              else if (IsDlgButtonChecked (dlg, IDC_SIGCLASS_CLASS3))
248                  sig_class_choice = 3;                  sig_class = 3;
249              else              else
250                  sig_class_choice = 0;                  sig_class = 0;
251              EndDialog (dlg, TRUE);              EndDialog (dlg, sig_class);
252                return TRUE;
253    
254            case IDCANCEL:
255                EndDialog (dlg, 0);
256              return TRUE;              return TRUE;
257          }          }
258          break;          break;
# Line 194  sig_class_dlg_proc (HWND dlg, UINT msg, Line 266  sig_class_dlg_proc (HWND dlg, UINT msg,
266  static const char*  static const char*
267  get_expire_date (gpgme_key_t key)  get_expire_date (gpgme_key_t key)
268  {  {
     static char tmp[64];  
   
269      u32 u = key->subkeys->expires;      u32 u = key->subkeys->expires;
270      if (!u)      if (!u)
271          return _("never");          return _("never");
272      return get_key_expire_date (u);      return get_key_expire_date (u);
273  }  }
274    
275  /* Display photo of key @key in a separate window. */  
276    /* Check if the given system time @st points to today. */
277    static int
278    date_is_today (SYSTEMTIME *st)
279    {
280        time_t t;
281        struct tm *tm;
282    
283        t = time (NULL);
284        tm = localtime (&t);
285        if (st->wDay == tm->tm_mday &&
286            st->wYear == tm->tm_year+1900 &&
287            st->wMonth == tm->tm_mon+1)
288            return -1;
289        return 0;
290    }
291    
292    
293    /* Display all needed information about the key @key in the dialog @dlg. */
294  static void  static void
295  show_photo (winpt_key_t key)  display_keyinfo (HWND dlg, winpt_key_t key)
296  {  {
297      /* XXX: fill it with life. */      gpgme_data_t kinf;
298        struct native_uid_s *u;
299        char tmp[256], *p;
300        size_t len;
301    
302        gpgme_data_new (&kinf);
303        _snprintf (tmp, sizeof (tmp) -1,
304                       _("pub %d/0x%s  created: %s    expires: %s\n\n"
305                         "Primary key fingerprint: %s\n\n"),
306                       key->ctx->subkeys->length,
307                       key->ctx->subkeys->keyid+8,
308                       get_key_created (key->ctx->subkeys->timestamp),
309                       get_expire_date (key->ctx),
310                       get_printable_fpr (key->ctx->subkeys->fpr));
311        gpgme_data_write (kinf, tmp, strlen (tmp));
312        for (len=0, u = key->ext->uids; u; u = u->next, len++) {
313            if (len > 2)
314                break;
315            gpgme_data_write (kinf, "\t\"", 2);
316            gpgme_data_write (kinf, u->uid, strlen (u->uid));
317            gpgme_data_write (kinf, "\"\n", 2);
318        }
319        p = (char*)_("\n\nAre you really sure that you want to sign this key with YOUR key?\n");
320        gpgme_data_write (kinf, p, strlen (p));
321        gpgme_data_write (kinf, "\0", 1);
322        p = gpgme_data_release_and_get_mem (kinf, &len);
323        SetDlgItemText (dlg, IDC_KEYSIGN_INFOS, p);
324        gpgme_free (p);
325  }  }
326    
327    
# Line 219  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 334  keysign_dlg_proc (HWND dlg, UINT msg, WP
334      gpgme_error_t err;      gpgme_error_t err;
335      gpgme_key_t k;      gpgme_key_t k;
336      SYSTEMTIME st;      SYSTEMTIME st;
337      HWND h;      char keymsg[64], *pwd;
     char keymsg[2048], pwd[256];  
     char *uid = NULL;  
338      const char *keyid, *s;      const char *keyid, *s;
339      int type, expires=0, idx;      int type, expires=0, idx;
340        int sig_class = 0;
341            
342      switch ( msg )  {      switch (msg)  {
343      case WM_INITDIALOG:      case WM_INITDIALOG:
         if (lparam == NULL)  
             dlg_fatal_error (dlg, "Could not get dialog param.");  
         #ifndef LANG_DE  
         SetWindowText (dlg, _("Key Signing"));  
         #endif  
344          key = (winpt_key_t) lparam;          key = (winpt_key_t) lparam;
345          s = key->ctx->uids->uid;          if (!key)
346          uid = utf8_to_wincp (s, strlen (s));              BUG (0);        
         _snprintf (keymsg, sizeof keymsg -1,  
                    _("pub %d/%s  created: %s    expires: %s\n\n"  
                      "Primary key fingerprint: %s\n\n"  
                      "\t%s\n\n"  
                      "\nAre you really sure that you want to sign this key with YOUR key?\n"),  
                    key->ctx->subkeys->length,  
                    key->ctx->subkeys->keyid+8,  
                    get_key_created (key->ctx->subkeys->timestamp),  
                    get_expire_date (key->ctx),  
                    get_printable_fpr (key->ctx->subkeys->fpr),  
                    uid);  
         free (uid);  
347          s = key->ctx->subkeys->keyid;          s = key->ctx->subkeys->keyid;
348          if (do_fill_seckeylist (dlg, s)) {          if (do_fill_seckeylist (dlg, s)) {
349              msg_box (dlg, _("No valid secret key found."), _("Key Signing"), MB_ERR);              msg_box (dlg, _("No valid secret key found."), _("Key Signing"), MB_ERR);
350              EndDialog (dlg, FALSE);              EndDialog (dlg, FALSE);
351                return TRUE;
352          }          }
353          SetDlgItemText (dlg, IDC_KEYSIGN_INFOS, keymsg);          do_check_protection (dlg);
354          #ifndef LANG_DE          display_keyinfo (dlg, key);
355          SetDlgItemText (dlg, IDC_KEYSIGN_LOCAL, _("Sign local only (non exportable signature)"));          SetDlgItemText (dlg, IDC_KEYSIGN_LOCAL, _("Sign local only (non exportable signature)"));
356          SetDlgItemText (dlg, IDC_KEYSIGN_EXPSIG, _("Signature expires on"));          SetDlgItemText (dlg, IDC_KEYSIGN_EXPSIG, _("Signature expires on"));
357          SetDlgItemText (dlg, IDC_KEYSIGN_NREV, _("Sign non-revocably"));          SetDlgItemText (dlg, IDC_KEYSIGN_NREV, _("Sign non-revocably"));
358          SetDlgItemText (dlg, IDC_KEYSIGN_ASKLEVEL, _("&Ask for certification level"));          SetDlgItemText (dlg, IDC_KEYSIGN_ASKLEVEL, _("&Ask for certification level"));
359          SetDlgItemText (dlg, IDC_KEYSIGN_PWDINF, _("Passphrase"));          SetDlgItemText (dlg, IDC_KEYSIGN_PWDINF, _("Passphrase"));
360          #endif          SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
361            SetDlgItemText (dlg, IDC_KEYSIGN_SHOWIMG, _("&Show photo"));
362            SetDlgItemText (dlg, IDC_KEYSIGN_HIDE, _("&Hide Typing"));
363            SetWindowText (dlg, _("Key Signing"));
364          CheckDlgButton (dlg, IDC_KEYSIGN_LOCAL, BST_CHECKED);          CheckDlgButton (dlg, IDC_KEYSIGN_LOCAL, BST_CHECKED);
365          CheckDlgButton (dlg, IDC_KEYSIGN_EXPSIG, BST_UNCHECKED);          CheckDlgButton (dlg, IDC_KEYSIGN_EXPSIG, BST_UNCHECKED);
366          CheckDlgButton (dlg, IDC_KEYSIGN_ASKLEVEL, BST_UNCHECKED);          CheckDlgButton (dlg, IDC_KEYSIGN_ASKLEVEL, BST_UNCHECKED);
367          EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), FALSE);          EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), FALSE);
368          if (reg_prefs.expert == 0)          if (reg_prefs.expert == 0)
369              ShowWindow (GetDlgItem (dlg, IDC_KEYSIGN_NREV), SW_HIDE);              ShowWindow (GetDlgItem (dlg, IDC_KEYSIGN_NREV), SW_HIDE);
370          if (key->ext && key->ext->attrib.len > 0)          if (key->ext && key->ext->attrib.len == 0)
371              EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_SHOWIMG), TRUE);              ShowWindow (GetDlgItem (dlg, IDC_KEYSIGN_SHOWIMG), SW_HIDE);
372          if (!reg_prefs.gpg.ask_cert_level)          if (!reg_prefs.gpg.ask_cert_level)
373              EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_ASKLEVEL), FALSE);              EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_ASKLEVEL), FALSE);
374            if (!reg_prefs.gpg.ask_cert_expire)
375                EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_EXPSIG), FALSE);
376            CheckDlgButton (dlg, IDC_KEYSIGN_HIDE, BST_CHECKED);
377          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
378          h = GetDlgItem (dlg, IDC_KEYSIGN_PASSPHRASE);          SetFocus (GetDlgItem (dlg, IDC_KEYSIGN_PASSPHRASE));
         SetFocus (h);  
         return FALSE;  
       
     case WM_DESTROY:  
         sig_class_choice = 0;  
         break;  
   
     case WM_SYSCOMMAND:  
         if( LOWORD( wparam ) == SC_CLOSE ) {  
             SetDlgItemText( dlg, IDC_KEYSIGN_PASSPHRASE, "" );  
             EndDialog( dlg, TRUE );  
         }  
379          return FALSE;          return FALSE;
380                    
381      case WM_COMMAND:      case WM_COMMAND:
382          if (HIWORD( wparam ) == CBN_SELCHANGE) {          if (HIWORD (wparam) == CBN_SELCHANGE) {
383              do_check_protection (dlg);              do_check_protection (dlg);
384              break;              break;
385          }          }
386          if (HIWORD (wparam) == BN_CLICKED && LOWORD (wparam) == IDC_KEYSIGN_EXPSIG) {          if (HIWORD (wparam) == BN_CLICKED &&
387                LOWORD (wparam) == IDC_KEYSIGN_EXPSIG) {
388              int enable = IsDlgButtonChecked (dlg, IDC_KEYSIGN_EXPSIG);              int enable = IsDlgButtonChecked (dlg, IDC_KEYSIGN_EXPSIG);
389    
390              EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), enable? TRUE : FALSE);              EnableWindow (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), enable? TRUE : FALSE);
391          }          }
392            if (HIWORD (wparam) == BN_CLICKED &&
393                LOWORD (wparam) == IDC_KEYSIGN_HIDE) {
394                HWND hwnd = GetDlgItem (dlg, IDC_KEYSIGN_PASSPHRASE);
395                int hide = IsDlgButtonChecked (dlg, IDC_KEYSIGN_HIDE);
396    
397                SendMessage (hwnd, EM_SETPASSWORDCHAR, hide? '*' : 0, 0);
398                SetFocus (hwnd);
399            }
400    
401          switch( LOWORD( wparam ) ) {          switch (LOWORD (wparam)) {
402          case IDOK:          case IDOK:
403              if (IsDlgButtonChecked (dlg, IDC_KEYSIGN_ASKLEVEL))              if (IsDlgButtonChecked (dlg, IDC_KEYSIGN_ASKLEVEL))
404                  dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_SIGCLASS, dlg,                  sig_class = dialog_box_param (glob_hinst,
405                                    sig_class_dlg_proc, (LPARAM)NULL,                                                (LPCSTR)IDD_WINPT_SIGCLASS, dlg,
406                                    _("Choose Signature Class"),  IDS_WINPT_SIGCLASS);                                                sig_class_dlg_proc, (LPARAM)dlg,
407                                                  _("Choose Signature Class"),
408                                                  IDS_WINPT_SIGCLASS);
409              type = IsDlgButtonChecked (dlg, IDC_KEYSIGN_LOCAL);              type = IsDlgButtonChecked (dlg, IDC_KEYSIGN_LOCAL);
410              if (type)              if (type)
411                  type = GPG_EDITKEY_LSIGN;                  type = GPG_EDITKEY_LSIGN;
# Line 314  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 418  keysign_dlg_proc (HWND dlg, UINT msg, WP
418                      type = GPG_EDITKEY_NRLSIGN;                      type = GPG_EDITKEY_NRLSIGN;
419              }              }
420              if (IsDlgButtonChecked (dlg, IDC_KEYSIGN_EXPSIG)) {              if (IsDlgButtonChecked (dlg, IDC_KEYSIGN_EXPSIG)) {
                 expires = 1;  
421                  DateTime_GetSystemtime (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), &st);                  DateTime_GetSystemtime (GetDlgItem (dlg, IDC_KEYSIGN_EXPIRES), &st);
422                  sprintf (keymsg, "%04d-%02d-%02d", st.wYear, st.wMonth, st.wDay);                  if (date_is_today (&st)) {
423                        msg_box (dlg, _("You cannot select today as the expiration date."),
424                                 _("Key Signing"), MB_INFO);
425                        return TRUE;
426                    }
427                    else
428                        expires = 1;
429                    _snprintf (keymsg, sizeof (keymsg)-1, "%04d-%02d-%02d",
430                               st.wYear, st.wMonth, st.wDay);
431              }              }
432    
433              /* XXX: check for --ask-cert-level and --ask-cert-expire in the gpg.conf              /* XXX: check for --ask-cert-level and --ask-cert-expire in the gpg.conf
434                      if an advanced button is checked and offer to add it to the config                      if an advanced button is checked and offer to add it to the config
435                      file. */                      file. */
436    
437              GetDlgItemText( dlg, IDC_KEYSIGN_PASSPHRASE, pwd, DIM (pwd)-1);              GetDlgItemText_utf8 (dlg, IDC_KEYSIGN_PASSPHRASE, &pwd);
438              keyid = key->ctx->subkeys->keyid;              keyid = key->ctx->subkeys->keyid;
439              if( !keyid ) {              assert (keyid != NULL); /* should be always true. */
                 msg_box( dlg, _("Could not get Key ID from key."), _("Key Signing"), MB_ERR );  
                 return TRUE;  
             }  
440              ke = new GpgKeyEdit (keyid);              ke = new GpgKeyEdit (keyid);
441              if (!ke)              if (!ke)
442                  BUG (NULL);                  BUG (NULL);
# Line 339  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 447  keysign_dlg_proc (HWND dlg, UINT msg, WP
447              if (k)              if (k)
448                  ke->setLocalUser (k);                  ke->setLocalUser (k);
449    
450              err = ke->signKey (type, sig_class_choice, expires? keymsg : "0");              err = ke->signKey (type, sig_class, expires? keymsg : "0");
451              memset (&pwd, 0, sizeof pwd);                        sfree_if_alloc (pwd);
452              if (err) {              if (err) {
453                  delete ke;                  delete ke;
454                  msg_box (dlg, gpgme_strerror (err), _("Key Signing"), MB_ERR);                  msg_box (dlg, gpgme_strerror (err), _("Key Signing"), MB_ERR);
455                  return TRUE;                  return TRUE;
456              }              }
457              if (ke->getResult () != 0)              if (ke->getResult () != 0) {
458                  msg_box (dlg, _("This key is already signed by your key"), _("Key Signing"), MB_INFO);                  msg_box (dlg, _("This key is already signed by your key"),
459                             _("Key Signing"), MB_INFO);
460                    delete ke;
461                    return TRUE;
462                }
463              else {              else {
464                  status_box (dlg, _("Key successfully signed."), PGM_NAME);                  status_box (dlg, _("Key successfully signed."), _("Key Signing"));
465                  key->update = 1;                  key->update = 1;
466              }              }
467              delete ke;              delete ke;
# Line 361  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 473  keysign_dlg_proc (HWND dlg, UINT msg, WP
473              return TRUE;              return TRUE;
474    
475          case IDC_KEYSIGN_SHOWIMG:          case IDC_KEYSIGN_SHOWIMG:
476              show_photo (key);              DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SHOWPHOTO,
477                                dlg, showphoto_dlg_proc, (LPARAM)key);
478              return TRUE;              return TRUE;
479          }          }
480          break;          break;
# Line 369  keysign_dlg_proc (HWND dlg, UINT msg, WP Line 482  keysign_dlg_proc (HWND dlg, UINT msg, WP
482            
483      return FALSE;      return FALSE;
484  }  }
   

Legend:
Removed from v.48  
changed lines
  Added in v.255

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26