/[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 36 by werner, Thu Oct 27 15:25:13 2005 UTC revision 255 by twoaday, Tue Aug 1 16:37:23 2006 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-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>
 #include <windows.h>  
25  #include <commctrl.h>  #include <commctrl.h>
26  #include <time.h>  #include <time.h>
27    
28  #include "../resource.h"  #include "resource.h"
29  #include "wptGPG.h"  #include "wptGPG.h"
30  #include "wptCommonCtl.h"  #include "wptCommonCtl.h"
31  #include "wptContext.h" /* for passphrase_s */  #include "wptContext.h" /* for passphrase_s */
32  #include "wptDlgs.h"  #include "wptDlgs.h"
33  #include "wptW32API.h"  #include "wptW32API.h"
34  #include "wptNLS.h"  #include "wptNLS.h"
35  #include "wptKeyList.h"  #include "wptKeylist.h"
36  #include "wptKeyserver.h"  #include "wptKeyserver.h"
37  #include "wptUTF8.h"  #include "wptUTF8.h"
38  #include "wptTypes.h"  #include "wptTypes.h"
# Line 45  Line 43 
43  static subclass_s siglist_proc;  static subclass_s siglist_proc;
44    
45    
46    /* Return -1 if the selected item is a signature. */
47  static int  static int
48  is_sig (listview_ctrl_t lv, int pos)  is_sig (listview_ctrl_t lv, int pos)
49  {  {
50      char tmpbuf[256];      char tmpbuf[200];
51    
52      if (pos == -1)      if (pos == -1)
53          pos = listview_get_curr_pos (lv);          pos = listview_get_curr_pos (lv);
54      if (pos == -1)      if (pos == -1)
55          return 0;          return 0;
56      listview_get_item_text (lv, pos, 0, tmpbuf, 200);      listview_get_item_text (lv, pos, SL_COL_UID, tmpbuf, sizeof (tmpbuf)-1);
57      if (*tmpbuf == ' ')      if (*tmpbuf == ' ')
58          return -1;          return -1;
59      return 0;      return 0;
# Line 66  is_sig (listview_ctrl_t lv, int pos) Line 65  is_sig (listview_ctrl_t lv, int pos)
65  static int  static int
66  do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key)  do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key)
67  {  {
     int pos, npos, id;  
     int signo=0, uidno=0;  
     GpgKeyEdit *ke;  
68      gpgme_error_t err;      gpgme_error_t err;
69        GpgKeyEdit *ke;
70        char keyid[32];
71        int pos, npos, id, is_selfsig=0;
72        int signo=0, uidno=0;
73    
74      npos = pos = listview_get_curr_pos (lv);      npos = pos = listview_get_curr_pos (lv);
75      if (!is_sig (lv, -1))      if (!is_sig (lv, -1))
76          return -1;          return -1;
77        listview_get_item_text (lv, pos, SL_COL_KEYID, keyid, sizeof (keyid)-1);
78        if (!strncmp (key->keyid, keyid+2, 8))
79            is_selfsig = 1;
80        
81      while (pos > 0 && is_sig (lv, pos)) {      while (pos > 0 && is_sig (lv, pos)) {
82          signo++;          signo++;
83          pos--;          pos--;
# Line 87  do_delsig (HWND dlg, listview_ctrl_t lv, Line 91  do_delsig (HWND dlg, listview_ctrl_t lv,
91      uidno++;      uidno++;
92    
93      /* XXX: do not allow to delete the self signature */      /* XXX: do not allow to delete the self signature */
94      id = log_box (_("Key Manager"), MB_YESNO,      id = log_box (_("Key Manager"), is_selfsig? MB_WARN_ASK : MB_QUEST_ASK,
95                    _("Are you really sure you want to delete this signature from\n"                    _("Are you really sure you want to delete this %s from\n\n"
96                      "  \"%s\""), key->uid);                    "  \"%s\""), is_selfsig? _("self signature") : _("signature"),
97                      key->uid);
98      if (id == IDNO)      if (id == IDNO)
99          return 0;          return 0;
100    
# Line 102  do_delsig (HWND dlg, listview_ctrl_t lv, Line 107  do_delsig (HWND dlg, listview_ctrl_t lv,
107      else      else
108          listview_del_item (lv, pos);          listview_del_item (lv, pos);
109      delete ke;      delete ke;
110      key->update = 1; /*update*/      if (!err)
111            key->update = 1;
112      return err? -1 : 0;      return err? -1 : 0;
113  }  }
114    
115    
116    /* Initialize a datepicker control with the time given in @t. */
117    static void
118    init_datepicker_from_time (HWND picker, time_t t)
119    {
120        SYSTEMTIME st;
121        struct tm *tm;
122    
123        tm = localtime (&t);
124        memset (&st, 0, sizeof st);
125        st.wYear = tm->tm_year+1900;
126        st.wMonth = tm->tm_mon+1;
127        st.wDay = tm->tm_mday;
128        DateTime_SetSystemtime (picker, GDT_VALID, &st);
129    }
130    
131    
132  /* Dialog box procedure to display the signature properties. */  /* Dialog box procedure to display the signature properties. */
133  static BOOL CALLBACK  BOOL CALLBACK
134  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
135  {  {
136      static listview_ctrl_t lv;      gpgme_key_sig_t ks;
137        winpt_key_s issuer;
138      char tmpbuf[256];      char tmpbuf[256];
139      int n;      static struct {
     struct {  
140          unsigned int exportable:1;          unsigned int exportable:1;
141          unsigned int expired:1;          unsigned int expired:1;
142          unsigned int nrev:1;          unsigned int nrev:1;
143          unsigned int rev:1;          unsigned int rev:1;
144          const char * alg;          const char *alg;
145          int _class;          int _class;
146      } ctx;      } ctx;
147      const char *fmt_templ = _("%s %s signature");      const char *fmt_templ = _("%s %s signature");
148        const char *s;
149    
150      switch (msg) {      switch (msg) {
     case WM_SYSCOMMAND:  
         if (LOWORD (wparam) == SC_CLOSE)  
             EndDialog (dlg, TRUE);  
         return FALSE;  
   
151      case WM_INITDIALOG:      case WM_INITDIALOG:
152          lv = (listview_ctrl_t)lparam;          ks = (gpgme_key_sig_t)lparam;
153          if (!lv)          if (!ks)
154              dlg_fatal_error (dlg, "could not get dialog param");              BUG (0);
155            SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));
156            SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));
157            SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired"));
158            SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));
159            SetDlgItemText (dlg, IDC_SIGPROPS_CLASSINF, _("Class"));
160            SetDlgItemText (dlg, IDC_SIGPROPS_EXPSTR, _("Expire date"));
161            SetDlgItemText (dlg, IDC_SIGPROPS_CREATSTR, _("Creation date"));
162            SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key"));
163            SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID"));
164            SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL"));
165            SetWindowText (dlg, _("Signature Properties"));
166            
167          memset (&ctx, 0, sizeof ctx);          memset (&ctx, 0, sizeof ctx);
168          n = listview_get_curr_pos (lv);          ctx._class = ks->sig_class;
         listview_get_item_text (lv, n, 2, tmpbuf, DIM (tmpbuf)-1);  
         if (!strstr (tmpbuf, "L"))  
             ctx.exportable = 1;  
         ctx._class = atoi (tmpbuf);  
169          if (ctx._class == 0)          if (ctx._class == 0)
170              ctx._class = 10;              ctx._class = 16;    
171          else if (ctx._class < 10)          ctx._class -= 6;
172              ctx._class += 10;          if (ks->pubkey_algo == GPGME_PK_DSA)
         listview_get_item_text (lv, n, 6, tmpbuf, DIM (tmpbuf)-1);  
         if (strstr (tmpbuf, "DSA"))          
173              ctx.alg = "DSA";              ctx.alg = "DSA";
174          else if (strstr (tmpbuf, "RSA"))          else if (ks->pubkey_algo == GPGME_PK_RSA)
175              ctx.alg = "RSA";              ctx.alg = "RSA";
176          else          else
177              ctx.alg = "ELG";              ctx.alg = "ELG";
178            ctx.exportable = ks->exportable;
179          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,
180                     ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg);                     ctx.exportable? _("Exportable") : _("Non-exportable"),
181                       ctx.alg);
182          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);
183          listview_get_item_text (lv, n, 4, tmpbuf, DIM (tmpbuf)-1);          
184            _snprintf (tmpbuf, DIM (tmpbuf)-1, "0x%s", ks->keyid+8);
185          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);
186          SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);          SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);
187          if (ctx.exportable)          if (ctx.exportable)
188              CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);              CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);
189          listview_get_item_text (lv, n, 0, tmpbuf, DIM (tmpbuf)-1);          memset (&issuer, 0, sizeof (issuer));
190          SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, tmpbuf+1);          if (!winpt_get_pubkey (ks->keyid+8, &issuer))
191          tmpbuf[0] = 0;              s = issuer.ext->uids->uid;
192          listview_get_item_text (lv, n, 5, tmpbuf, DIM (tmpbuf)-1);          else
193          if (strlen (tmpbuf) == 0) {              s = _("  user ID not found");
194            SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, s);
195    
196            init_datepicker_from_time (GetDlgItem (dlg, IDC_SIGPROPS_CREATDATE),
197                                        ks->timestamp);
198            if (ks->expires == 0) {
199              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);
200              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);
201          }          }
202          else {          else {
203              SYSTEMTIME st;              init_datepicker_from_time (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),
204              struct tm * tm;                                          ks->expires);
205              time_t t = time (NULL);              if (time (NULL) > ks->expires)
   
             memset (&st, 0, sizeof st);  
             st.wYear = atoi (tmpbuf);  
             st.wMonth = atoi (tmpbuf+5);  
             st.wDay = atoi (tmpbuf+8);  
             DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),  
                                     GDT_VALID, &st);  
   
             tm = localtime (&t);  
             tm->tm_mon++;  
             tm->tm_year += 1900;  
             if (tm->tm_year > st.wYear)  
                 ctx.expired = 1;  
             else if (tm->tm_mon > st.wMonth)  
206                  ctx.expired = 1;                  ctx.expired = 1;
207              if (ctx.expired)              if (ctx.expired)
208                  CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED);                  CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED);
209          }          }
210            /* XXX (gpgme): \r at the end of the notation value. */
211            if (ks->notations && !ks->notations->name && ks->notations->value)
212                SetDlgItemText (dlg, IDC_SIGPROPS_POLIC, ks->notations->value);
213    
214          SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));          SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));
215          SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));          SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));
216          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));
# Line 199  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 221  sigprops_dlg_proc (HWND dlg, UINT msg, W
221          return TRUE;          return TRUE;
222    
223      case WM_COMMAND:      case WM_COMMAND:
224            if (HIWORD (wparam) == BN_CLICKED) {
225                /* Code to prevent the user changes the check buttons. */
226                switch (LOWORD (wparam)) {
227                case IDC_SIGPROPS_EXP:
228                    CheckDlgButton (dlg, IDC_SIGPROPS_EXP,
229                                     ctx.exportable? BST_CHECKED : BST_UNCHECKED);
230                    return TRUE;
231    
232                case IDC_SIGPROPS_EXPIRED:
233                    CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED,
234                                    ctx.expired? BST_CHECKED : BST_UNCHECKED);
235                    return TRUE;
236    
237                case IDC_SIGPROPS_REV:
238                    CheckDlgButton (dlg, IDC_SIGPROPS_REV,
239                                    ctx.rev? BST_CHECKED : BST_UNCHECKED);
240                    return TRUE;
241    
242                case IDC_SIGPROPS_NREV:
243                    CheckDlgButton (dlg, IDC_SIGPROPS_NREV,
244                                    ctx.nrev? BST_CHECKED : BST_UNCHECKED);
245                    return TRUE;
246                }
247            }
248    
249          switch (LOWORD (wparam)) {          switch (LOWORD (wparam)) {
250          case IDOK:          case IDOK:
251              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
252              break;              break;
253    
254            case IDCANCEL:
255                EndDialog (dlg, FALSE);
256                break;
257          }          }
258      }      }
259    
# Line 210  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 261  sigprops_dlg_proc (HWND dlg, UINT msg, W
261  }  }
262    
263    
264    /* Subclass window procedure for the list view. */
265  static BOOL CALLBACK  static BOOL CALLBACK
266  subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
267  {  {
268      listview_ctrl_t lv;      listview_ctrl_t lv;
269      winpt_key_t key;      winpt_key_t key;
270        gpgme_key_sig_t ks;
271    
272      switch (msg) {      switch (msg) {
273      case WM_KEYUP:      case WM_KEYUP:
# Line 222  subclass_dlg_proc (HWND dlg, UINT msg, W Line 275  subclass_dlg_proc (HWND dlg, UINT msg, W
275          key = (winpt_key_t)siglist_proc.opaque;          key = (winpt_key_t)siglist_proc.opaque;
276          lv = key->callback.ctl;          lv = key->callback.ctl;
277          if (virt_key == VK_SPACE) {          if (virt_key == VK_SPACE) {
278              if (is_sig (lv, -1))              if (is_sig (lv, -1)) {
279                    ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv));
280                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
281                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)ks);
282                }
283          }          }
284          else if (virt_key == VK_DELETE)          else if (virt_key == VK_DELETE)
285              do_delsig (dlg, lv, key);              do_delsig (dlg, lv, key);
# Line 241  check_for_missing_keys (listview_ctrl_t Line 296  check_for_missing_keys (listview_ctrl_t
296      int i, n;      int i, n;
297      char id[128];      char id[128];
298            
299      n = listview_count_items( lv, 0 );      n = listview_count_items (lv, 0);
300      for( i = 0; i < n; i++ ) {      for (i = 0; i < n; i++) {
301          listview_get_item_text( lv, i, 1, id, sizeof (id) - 1 );          listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1);
302          if( !strncmp( id, "NOKEY", 5 ) )          if (!strncmp (id, "NOKEY", 5))
303              return 1;              return 1;
304      }      }
305            
# Line 256  check_for_missing_keys (listview_ctrl_t Line 311  check_for_missing_keys (listview_ctrl_t
311  static int  static int
312  recv_missing_keys (HWND dlg, listview_ctrl_t lv)  recv_missing_keys (HWND dlg, listview_ctrl_t lv)
313  {  {
     int i, n, rc;  
314      char id[128], keyid[18+1];      char id[128], keyid[18+1];
315        int i, n, cnt=0;
316    
317        i = msg_box (dlg, _("Really receive all missing keys?"),
318                     _("Key Manager"), MB_YESNO|MB_INFO);
319        if (i == IDNO)
320            return 0;
321            
322      n = listview_count_items (lv, 0);      n = listview_count_items (lv, 0);
323      for( i = 0; i < n; i++ ) {      for (i = 0; i < n; i++) {
324          listview_get_item_text( lv, i, 1, id, sizeof id - 1 );          listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1);
325          if( !strncmp( id, "NOKEY", 5 ) ) {          if (!strncmp (id, "NOKEY", 5)) {
326              listview_get_item_text( lv, i, 4, keyid, sizeof keyid -1 );              listview_get_item_text (lv, i, SL_COL_KEYID,
327              rc = hkp_recv_key( dlg, default_keyserver, default_keyserver_port, keyid, 0, 0 );                                      keyid, sizeof (keyid) -1);
328              if( rc )                            if (!hkp_recv_key (dlg, default_keyserver,
329                                   default_keyserver_port, keyid, 0, 0)) {
330                    keycache_update (0, keyid);
331                    cnt++;
332                }
333                else
334                  break;                  break;
335          }          }
336      }      }
337            return cnt;
     return rc;  
338  }  }
339    
340    
# Line 284  do_create_popup (HWND dlg) Line 348  do_create_popup (HWND dlg)
348      GetCursorPos (&p);      GetCursorPos (&p);
349      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));
350      sm = GetSubMenu (hm, 0);      sm = GetSubMenu (hm, 0);
   
351      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));
352      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));
   
353      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
   
354      DestroyMenu (hm);      DestroyMenu (hm);
355      DestroyMenu (sm);      DestroyMenu (sm);
356  }  }
357    
358    
359    /* Fetch a single key and extract the keyid from the listview
360       entry at the pos @idx. */
361    static int
362    recv_single_key (HWND dlg, listview_ctrl_t lv, int idx)
363    {
364        char keyid[32];
365        int rc;
366    
367        listview_get_item_text (lv, idx, SL_COL_KEYID, keyid, DIM (keyid)-1);      
368        rc = hkp_recv_key (dlg, default_keyserver,
369                           default_keyserver_port, keyid, 0, 0);
370        if (!rc)
371            keycache_update (0, keyid);
372        return rc;
373    }
374    
375    
376  /* Load the key property dialog with the selected key from @lv. */  /* Load the key property dialog with the selected key from @lv. */
377  static void  static void
378  do_load_keyprops (HWND dlg, listview_ctrl_t lv)  do_load_keyprops (HWND dlg, listview_ctrl_t lv)
379  {  {
380      winpt_key_s k;      winpt_key_s k;
     gpgme_key_t key;  
381      char keyid[32] = {0};      char keyid[32] = {0};
382      char status[64] = {0}, creation[64] = {0};      char status[64] = {0}, creation[64] = {0};
383      int n = listview_get_curr_pos (lv);      int n = listview_get_curr_pos (lv);
384    
385      listview_get_item_text (lv, n, 1, status, DIM (status)-1);      listview_get_item_text (lv, n, SL_COL_VALID, status, DIM (status)-1);
386      listview_get_item_text (lv, n, 3, creation, DIM (creation)-1);      listview_get_item_text (lv, n, SL_COL_CREATE, creation, DIM (creation)-1);
387      listview_get_item_text (lv, n, 4, keyid, DIM (keyid)-1);      listview_get_item_text (lv, n, SL_COL_KEYID, keyid, DIM (keyid)-1);
388      if (!strcmp (status, "NOKEY")) {      if (!strcmp (status, "NOKEY")) {
389          msg_box (dlg, _("Key not found in keyring, please get it from the keyserver first."),          int id = msg_box (dlg, _("Key not found in keyring, do you want to fetch it from the keyserver?"),
390                   _("Key Manager"), MB_INFO);                            _("Key Manager"), MB_QUEST_ASK);
391          return;          if (id == IDNO)
392                return;
393            if (recv_single_key (dlg, lv, n))              
394                return;
395      }      }
396            
397      if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {      memset (&k, 0, sizeof k);
398        if ((strlen (keyid) < 3 || winpt_get_pubkey (keyid, &k))) {
399          if (strlen (creation) > 0)          if (strlen (creation) > 0)
400              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);
401          return;          return;
402      }      }
     memset (&k, 0, sizeof k);  
     k.keyid = keyid;  
403      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,
404                      keyprops_dlg_proc, (LPARAM)&k);                      keyprops_dlg_proc, (LPARAM)&k);
405  }  }
# Line 332  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 411  keysig_dlg_proc (HWND dlg, UINT msg, WPA
411  {  {
412      static listview_ctrl_t lv = NULL;      static listview_ctrl_t lv = NULL;
413      static struct winpt_key_s *k;      static struct winpt_key_s *k;
414      char inf[384], keyid[18+1];          gpgme_key_sig_t ks;
     int idx = 0, id, rc;  
415      HWND sl;      HWND sl;
416        char inf[384];
417        int idx = 0;    
418            
419      switch( msg ) {      switch (msg) {
420      case WM_INITDIALOG:      case WM_INITDIALOG:
421          k = (winpt_key_t) lparam;          k = (winpt_key_t) lparam;
422          if (!k)          if (!k)
# Line 344  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 424  keysig_dlg_proc (HWND dlg, UINT msg, WPA
424          if (k->uid)          if (k->uid)
425              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);
426          SetWindowText (dlg, inf);          SetWindowText (dlg, inf);
         #ifndef LANG_DE  
427          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));
428          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));
429          #endif  
430          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);
431          if (!check_for_missing_keys (lv))          if (!check_for_missing_keys (lv))
432              EnableWindow (GetDlgItem( dlg, IDC_KEYSIG_RECVKEY ), FALSE);              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), FALSE);
433            EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_SIGPROPS), FALSE);
434          k->callback.ctl = lv;          k->callback.ctl = lv;
435          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);
436          siglist_proc.dlg = dlg;          siglist_proc.dlg = dlg;
# Line 359  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 439  keysig_dlg_proc (HWND dlg, UINT msg, WPA
439          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);
440          if (siglist_proc.old) {          if (siglist_proc.old) {
441              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {
442                  msg_box (dlg, _("Could not set keylist window procedure."),                  msg_box (dlg, "Could not set keylist window procedure.",
443                           _("Key Manager"), MB_ERR);                           _("Key Manager"), MB_ERR);
444                  BUG (0);                  BUG (0);
445              }              }
# Line 369  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 449  keysig_dlg_proc (HWND dlg, UINT msg, WPA
449          return TRUE;          return TRUE;
450                    
451      case WM_DESTROY:      case WM_DESTROY:
452          if ( lv ) {          if (lv) {
453              siglist_delete( lv );              siglist_delete (lv);
454              lv = NULL;              lv = NULL;
455          }          }
456          return FALSE;          return FALSE;
           
     case WM_SYSCOMMAND:  
         if (LOWORD (wparam) == SC_CLOSE) {  
             if (k->update)  
                 keycache_update (0, k->keyid);  
             EndDialog (dlg, TRUE);  
         }  
         return FALSE;  
457    
458      case WM_NOTIFY:      case WM_NOTIFY:
459          NMHDR * notify;          NMHDR *notify;
460                    
461          notify = (NMHDR *)lparam;          notify = (NMHDR *)lparam;
462          if( notify && notify->code == NM_DBLCLK          if (!notify)
463              && notify->idFrom == IDC_KEYSIG_LIST )              return FALSE;
464              do_load_keyprops (dlg, lv);          if (notify->code == NM_DBLCLK &&
         if (notify && notify->code == NM_RCLICK &&  
465              notify->idFrom == IDC_KEYSIG_LIST)              notify->idFrom == IDC_KEYSIG_LIST)
466                do_load_keyprops (dlg, lv);
467            if (notify->code == NM_RCLICK &&
468                notify->idFrom == IDC_KEYSIG_LIST &&
469                is_sig (lv, -1))
470              do_create_popup (dlg);              do_create_popup (dlg);
471            if (notify->code == LVN_ITEMCHANGED &&
472                ((LPNMLISTVIEW)lparam)->uNewState) {
473                idx = listview_get_curr_pos (lv);
474                listview_get_item_text (lv, idx, SL_COL_VALID, inf, DIM (inf)-1);
475                EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY),
476                              strcmp (inf, "NOKEY") == 0? TRUE: FALSE);
477                EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_SIGPROPS),
478                              is_sig (lv, -1)? TRUE : FALSE);
479            }
480            if (notify->code == LVN_COLUMNCLICK) {
481                NMLISTVIEW *nft = (LPNMLISTVIEW) lparam;
482                int sortby = 0;
483                switch (nft->iSubItem) {
484                //case 0:  sortby = KEY_SORT_USERID; break;
485                case 1: sortby = KEY_SORT_VALIDITY; break;
486                case 2: sortby = SIG_SORT_CLASS; break;
487                case 3: sortby = KEY_SORT_CREATED; break;
488                case 4: sortby = KEY_SORT_KEYID; break;
489                case 5: sortby = SIG_SORT_EXPIRE; break;
490                case 6: sortby = KEY_SORT_ALGO; break;
491                default: return TRUE;
492                }
493                siglist_sort (lv, sortby);
494            }
495          break;          break;
496                    
497      case WM_COMMAND:      case WM_COMMAND:
498          switch ( LOWORD( wparam ) ) {          switch (LOWORD (wparam)) {
   
499          case ID_SIGCTX_KEYPROPS:          case ID_SIGCTX_KEYPROPS:
500              do_load_keyprops (dlg, lv);              do_load_keyprops (dlg, lv);
501              break;              break;
502    
503          case ID_SIGCTX_PROPS:          case ID_SIGCTX_PROPS:
504              if (is_sig (lv, -1))              if (is_sig (lv, -1)) {
505                    ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv));
506                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
507                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)ks);
508                }
509              break;              break;
510    
511          case IDC_KEYSIG_RECVKEY:          case IDC_KEYSIG_RECVKEY:
512              idx = listview_get_curr_pos (lv);              idx = listview_get_curr_pos (lv);
513              if (idx == -1) {              if (idx == -1)
514                  id = msg_box( dlg, _("Really receive all missing keys?"),                  recv_missing_keys (dlg, lv);
515                                  _("Key Manager"), MB_YESNO|MB_INFO );              else
516                  if (id == IDYES) {                  recv_single_key (dlg, lv, idx);
                     rc = recv_missing_keys (dlg, lv);  
                     if( !rc )  
                         keycache_set_reload (1);  
                     return TRUE;  
                 }  
                 return TRUE;  
             }  
             listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);  
             if (strcmp (inf, "NOKEY"))  
                 return FALSE;  
             listview_get_item_text (lv, idx, 4, keyid, DIM (keyid)-1);  
             rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, keyid, 0, 0);  
             if (!rc)  
                 keycache_set_reload (1);  
517              return TRUE;              return TRUE;
518    
519          case IDC_KEYSIG_SIGPROPS:          case IDC_KEYSIG_SIGPROPS:
520              if (is_sig (lv, -1))              if (is_sig (lv, -1)) {
521                    ks = ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv));
522                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
523                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)ks);
524                }
525              return TRUE;              return TRUE;
526                            
527            case IDCANCEL:
528                EndDialog (dlg, FALSE);
529                return TRUE;
530    
531          case IDOK:          case IDOK:
             if (k->update)  
                 keycache_update (0, k->keyid);  
532              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
533              return TRUE;              return TRUE;
534          }          }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26