/[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 47 by werner, Mon Oct 31 14:04:59 2005 UTC revision 225 by twoaday, Tue Jun 6 13:37:59 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    
# 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  /* Dialog box procedure to display the signature properties. */  /* Dialog box procedure to display the signature properties. */
117  static BOOL CALLBACK  BOOL CALLBACK
118  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
119  {  {
120      static listview_ctrl_t lv;      gpgme_key_sig_t ks;
121        winpt_key_s issuer;
122      char tmpbuf[256];      char tmpbuf[256];
123      int n;      static struct {
     struct {  
124          unsigned int exportable:1;          unsigned int exportable:1;
125          unsigned int expired:1;          unsigned int expired:1;
126          unsigned int nrev:1;          unsigned int nrev:1;
127          unsigned int rev:1;          unsigned int rev:1;
128          const char * alg;          const char *alg;
129          int _class;          int _class;
130      } ctx;      } ctx;
131      const char *fmt_templ = _("%s %s signature");      const char *fmt_templ = _("%s %s signature");
132        const char *s;
133    
134      switch (msg) {      switch (msg) {
     case WM_SYSCOMMAND:  
         if (LOWORD (wparam) == SC_CLOSE)  
             EndDialog (dlg, TRUE);  
         return FALSE;  
   
135      case WM_INITDIALOG:      case WM_INITDIALOG:
136          lv = (listview_ctrl_t)lparam;          ks = (gpgme_key_sig_t)lparam;
137          if (!lv)          if (!ks)
138              dlg_fatal_error (dlg, "could not get dialog param");              BUG (0);
139            SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));
140            SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));
141            SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired"));
142            SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));
143            SetDlgItemText (dlg, IDC_SIGPROPS_CLASSINF, _("Class"));
144            SetDlgItemText (dlg, IDC_SIGPROPS_EXPSTR, _("Expire date"));
145            SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key"));
146            SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID"));
147            SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL"));
148            SetWindowText (dlg, _("Signature Properties"));
149            
150          memset (&ctx, 0, sizeof ctx);          memset (&ctx, 0, sizeof ctx);
151          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);  
152          if (ctx._class == 0)          if (ctx._class == 0)
153              ctx._class = 10;              ctx._class = 16;    
154          else if (ctx._class < 10)          ctx._class -= 6;
155              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"))          
156              ctx.alg = "DSA";              ctx.alg = "DSA";
157          else if (strstr (tmpbuf, "RSA"))          else if (ks->pubkey_algo == GPGME_PK_RSA)
158              ctx.alg = "RSA";              ctx.alg = "RSA";
159          else          else
160              ctx.alg = "ELG";              ctx.alg = "ELG";
161            ctx.exportable = ks->exportable;
162          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,
163                     ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg);                     ctx.exportable? _("Exportable") : _("Non-exportable"),
164                       ctx.alg);
165          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);
166          listview_get_item_text (lv, n, 4, tmpbuf, DIM (tmpbuf)-1);          
167            _snprintf (tmpbuf, DIM (tmpbuf)-1, "0x%s", ks->keyid+8);
168          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);
169          SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);          SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);
170          if (ctx.exportable)          if (ctx.exportable)
171              CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);              CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);
172          listview_get_item_text (lv, n, 0, tmpbuf, DIM (tmpbuf)-1);          memset (&issuer, 0, sizeof (issuer));
173          SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, tmpbuf+1);          if (!winpt_get_pubkey (ks->keyid+8, &issuer))
174          tmpbuf[0] = 0;              s = issuer.ext->uids->uid;
175          listview_get_item_text (lv, n, 5, tmpbuf, DIM (tmpbuf)-1);          else
176          if (strlen (tmpbuf) == 0) {              s = _("  user ID not found");
177            SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, s);
178            if (ks->expires == 0) {
179              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);
180              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);
181          }          }
182          else {          else {
183              SYSTEMTIME st;              SYSTEMTIME st;
184              struct tm * tm;              struct tm *tm;
185              time_t t = time (NULL);              time_t now = time (NULL);
186                time_t tmp = ks->expires;
187    
188                tm = localtime (&tmp);
189              memset (&st, 0, sizeof st);              memset (&st, 0, sizeof st);
190              st.wYear = atoi (tmpbuf);              st.wYear = tm->tm_year+1900;
191              st.wMonth = atoi (tmpbuf+5);              st.wMonth = tm->tm_mon+1;
192              st.wDay = atoi (tmpbuf+8);              st.wDay = tm->tm_mday;
193              DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),              DateTime_SetSystemtime (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),
194                                      GDT_VALID, &st);                                      GDT_VALID, &st);
195    
196              tm = localtime (&t);              if (now > ks->expires)
             tm->tm_mon++;  
             tm->tm_year += 1900;  
             if (tm->tm_year > st.wYear)  
                 ctx.expired = 1;  
             else if (tm->tm_mon > st.wMonth)  
197                  ctx.expired = 1;                  ctx.expired = 1;
198              if (ctx.expired)              if (ctx.expired)
199                  CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED);                  CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED);
200          }          }
201            /* XXX (gpgme): \r at the end of the notation value. */
202            if (ks->notations && !ks->notations->name && ks->notations->value)
203                SetDlgItemText (dlg, IDC_SIGPROPS_POLIC, ks->notations->value);
204    
205          SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));          SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));
206          SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));          SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));
207          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));
# Line 199  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 212  sigprops_dlg_proc (HWND dlg, UINT msg, W
212          return TRUE;          return TRUE;
213    
214      case WM_COMMAND:      case WM_COMMAND:
215            if (HIWORD (wparam) == BN_CLICKED) {
216                /* Code to prevent the user changes the check buttons. */
217                switch (LOWORD (wparam)) {
218                case IDC_SIGPROPS_EXP:
219                    CheckDlgButton (dlg, IDC_SIGPROPS_EXP,
220                                     ctx.exportable? BST_CHECKED : BST_UNCHECKED);
221                    return TRUE;
222    
223                case IDC_SIGPROPS_EXPIRED:
224                    CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED,
225                                    ctx.expired? BST_CHECKED : BST_UNCHECKED);
226                    return TRUE;
227    
228                case IDC_SIGPROPS_REV:
229                    CheckDlgButton (dlg, IDC_SIGPROPS_REV,
230                                    ctx.rev? BST_CHECKED : BST_UNCHECKED);
231                    return TRUE;
232    
233                case IDC_SIGPROPS_NREV:
234                    CheckDlgButton (dlg, IDC_SIGPROPS_NREV,
235                                    ctx.nrev? BST_CHECKED : BST_UNCHECKED);
236                    return TRUE;
237                }
238            }
239    
240          switch (LOWORD (wparam)) {          switch (LOWORD (wparam)) {
241          case IDOK:          case IDOK:
242              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
243              break;              break;
244    
245            case IDCANCEL:
246                EndDialog (dlg, FALSE);
247                break;
248          }          }
249      }      }
250    
# Line 210  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 252  sigprops_dlg_proc (HWND dlg, UINT msg, W
252  }  }
253    
254    
255    /* Subclass window procedure for the list view. */
256  static BOOL CALLBACK  static BOOL CALLBACK
257  subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
258  {  {
259      listview_ctrl_t lv;      listview_ctrl_t lv;
260      winpt_key_t key;      winpt_key_t key;
261        gpgme_key_sig_t ks;
262    
263      switch (msg) {      switch (msg) {
264      case WM_KEYUP:      case WM_KEYUP:
# Line 222  subclass_dlg_proc (HWND dlg, UINT msg, W Line 266  subclass_dlg_proc (HWND dlg, UINT msg, W
266          key = (winpt_key_t)siglist_proc.opaque;          key = (winpt_key_t)siglist_proc.opaque;
267          lv = key->callback.ctl;          lv = key->callback.ctl;
268          if (virt_key == VK_SPACE) {          if (virt_key == VK_SPACE) {
269              if (is_sig (lv, -1))              if (is_sig (lv, -1)) {
270                    ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv));
271                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
272                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)ks);
273                }
274          }          }
275          else if (virt_key == VK_DELETE)          else if (virt_key == VK_DELETE)
276              do_delsig (dlg, lv, key);              do_delsig (dlg, lv, key);
# Line 241  check_for_missing_keys (listview_ctrl_t Line 287  check_for_missing_keys (listview_ctrl_t
287      int i, n;      int i, n;
288      char id[128];      char id[128];
289            
290      n = listview_count_items( lv, 0 );      n = listview_count_items (lv, 0);
291      for( i = 0; i < n; i++ ) {      for (i = 0; i < n; i++) {
292          listview_get_item_text( lv, i, 1, id, sizeof (id) - 1 );          listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1);
293          if( !strncmp( id, "NOKEY", 5 ) )          if (!strncmp (id, "NOKEY", 5))
294              return 1;              return 1;
295      }      }
296            
# Line 256  check_for_missing_keys (listview_ctrl_t Line 302  check_for_missing_keys (listview_ctrl_t
302  static int  static int
303  recv_missing_keys (HWND dlg, listview_ctrl_t lv)  recv_missing_keys (HWND dlg, listview_ctrl_t lv)
304  {  {
     int i, n, rc;  
305      char id[128], keyid[18+1];      char id[128], keyid[18+1];
306        int i, n, cnt=0;
307    
308        i = msg_box (dlg, _("Really receive all missing keys?"),
309                     _("Key Manager"), MB_YESNO|MB_INFO);
310        if (i == IDNO)
311            return 0;
312            
313      n = listview_count_items (lv, 0);      n = listview_count_items (lv, 0);
314      for( i = 0; i < n; i++ ) {      for (i = 0; i < n; i++) {
315          listview_get_item_text( lv, i, 1, id, sizeof id - 1 );          listview_get_item_text (lv, i, SL_COL_VALID, id, sizeof (id) - 1);
316          if( !strncmp( id, "NOKEY", 5 ) ) {          if (!strncmp (id, "NOKEY", 5)) {
317              listview_get_item_text( lv, i, 4, keyid, sizeof keyid -1 );              listview_get_item_text (lv, i, SL_COL_KEYID,
318              rc = hkp_recv_key( dlg, default_keyserver, default_keyserver_port, keyid, 0, 0 );                                      keyid, sizeof (keyid) -1);
319              if( rc )                            if (!hkp_recv_key (dlg, default_keyserver,
320                                   default_keyserver_port, keyid, 0, 0)) {
321                    keycache_update (0, keyid);
322                    cnt++;
323                }
324                else
325                  break;                  break;
326          }          }
327      }      }
328            return cnt;
     return rc;  
329  }  }
330    
331    
# Line 284  do_create_popup (HWND dlg) Line 339  do_create_popup (HWND dlg)
339      GetCursorPos (&p);      GetCursorPos (&p);
340      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));
341      sm = GetSubMenu (hm, 0);      sm = GetSubMenu (hm, 0);
   
342      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));
343      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));
   
344      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
   
345      DestroyMenu (hm);      DestroyMenu (hm);
346      DestroyMenu (sm);      DestroyMenu (sm);
347  }  }
348    
349    
350    /* Fetch a single key and extract the keyid from the listview
351       entry at the pos @idx. */
352    static int
353    recv_single_key (HWND dlg, listview_ctrl_t lv, int idx)
354    {
355        char keyid[32];
356        int rc;
357    
358        listview_get_item_text (lv, idx, SL_COL_KEYID, keyid, DIM (keyid)-1);      
359        rc = hkp_recv_key (dlg, default_keyserver,
360                           default_keyserver_port, keyid, 0, 0);
361        if (!rc)
362            keycache_update (0, keyid);
363        return rc;
364    }
365    
366    
367  /* Load the key property dialog with the selected key from @lv. */  /* Load the key property dialog with the selected key from @lv. */
368  static void  static void
369  do_load_keyprops (HWND dlg, listview_ctrl_t lv)  do_load_keyprops (HWND dlg, listview_ctrl_t lv)
370  {  {
371      winpt_key_s k;      winpt_key_s k;
     gpgme_key_t key;  
372      char keyid[32] = {0};      char keyid[32] = {0};
373      char status[64] = {0}, creation[64] = {0};      char status[64] = {0}, creation[64] = {0};
374      int n = listview_get_curr_pos (lv);      int n = listview_get_curr_pos (lv);
375    
376      listview_get_item_text (lv, n, 1, status, DIM (status)-1);      listview_get_item_text (lv, n, SL_COL_VALID, status, DIM (status)-1);
377      listview_get_item_text (lv, n, 3, creation, DIM (creation)-1);      listview_get_item_text (lv, n, SL_COL_CREATE, creation, DIM (creation)-1);
378      listview_get_item_text (lv, n, 4, keyid, DIM (keyid)-1);      listview_get_item_text (lv, n, SL_COL_KEYID, keyid, DIM (keyid)-1);
379      if (!strcmp (status, "NOKEY")) {      if (!strcmp (status, "NOKEY")) {
380          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?"),
381                   _("Key Manager"), MB_INFO);                            _("Key Manager"), MB_QUEST_ASK);
382          return;          if (id == IDNO)
383                return;
384            if (recv_single_key (dlg, lv, n))              
385                return;
386      }      }
387            
388      if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {      memset (&k, 0, sizeof k);
389        if ((strlen (keyid) < 3 || winpt_get_pubkey (keyid, &k))) {
390          if (strlen (creation) > 0)          if (strlen (creation) > 0)
391              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);
392          return;          return;
393      }      }
     memset (&k, 0, sizeof k);  
     k.keyid = keyid;  
394      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,
395                      keyprops_dlg_proc, (LPARAM)&k);                      keyprops_dlg_proc, (LPARAM)&k);
396  }  }
# Line 332  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 402  keysig_dlg_proc (HWND dlg, UINT msg, WPA
402  {  {
403      static listview_ctrl_t lv = NULL;      static listview_ctrl_t lv = NULL;
404      static struct winpt_key_s *k;      static struct winpt_key_s *k;
405      char inf[384], keyid[18+1];          gpgme_key_sig_t ks;
     int idx = 0, id, rc;  
406      HWND sl;      HWND sl;
407        char inf[384];
408        int idx = 0;    
409            
410      switch( msg ) {      switch (msg) {
411      case WM_INITDIALOG:      case WM_INITDIALOG:
412          k = (winpt_key_t) lparam;          k = (winpt_key_t) lparam;
413          if (!k)          if (!k)
# Line 344  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 415  keysig_dlg_proc (HWND dlg, UINT msg, WPA
415          if (k->uid)          if (k->uid)
416              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);
417          SetWindowText (dlg, inf);          SetWindowText (dlg, inf);
         #ifndef LANG_DE  
418          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));
419          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));
420          #endif  
421          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);
422          if (!check_for_missing_keys (lv))          if (!check_for_missing_keys (lv))
423              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), FALSE);              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), FALSE);
424            EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_SIGPROPS), FALSE);
425          k->callback.ctl = lv;          k->callback.ctl = lv;
426          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);
427          siglist_proc.dlg = dlg;          siglist_proc.dlg = dlg;
# Line 359  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 430  keysig_dlg_proc (HWND dlg, UINT msg, WPA
430          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);
431          if (siglist_proc.old) {          if (siglist_proc.old) {
432              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {
433                  msg_box (dlg, _("Could not set keylist window procedure."),                  msg_box (dlg, "Could not set keylist window procedure.",
434                           _("Key Manager"), MB_ERR);                           _("Key Manager"), MB_ERR);
435                  BUG (0);                  BUG (0);
436              }              }
# Line 369  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 440  keysig_dlg_proc (HWND dlg, UINT msg, WPA
440          return TRUE;          return TRUE;
441                    
442      case WM_DESTROY:      case WM_DESTROY:
443          if ( lv ) {          if (lv) {
444              siglist_delete( lv );              siglist_delete (lv);
445              lv = NULL;              lv = NULL;
446          }          }
447          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;  
448    
449      case WM_NOTIFY:      case WM_NOTIFY:
450          NMHDR *notify;          NMHDR *notify;
451                    
452          notify = (NMHDR *)lparam;          notify = (NMHDR *)lparam;
453          if (notify && notify->code == NM_DBLCLK          if (!notify)
454              && notify->idFrom == IDC_KEYSIG_LIST)              return FALSE;
455              do_load_keyprops (dlg, lv);          if (notify->code == NM_DBLCLK &&
         if (notify && notify->code == NM_RCLICK &&  
456              notify->idFrom == IDC_KEYSIG_LIST)              notify->idFrom == IDC_KEYSIG_LIST)
457                do_load_keyprops (dlg, lv);
458            if (notify->code == NM_RCLICK &&
459                notify->idFrom == IDC_KEYSIG_LIST &&
460                is_sig (lv, -1))
461              do_create_popup (dlg);              do_create_popup (dlg);
462          if (notify && notify->code == LVN_ITEMCHANGED &&          if (notify->code == LVN_ITEMCHANGED &&
463              ((LPNMLISTVIEW)lparam)->uNewState) {              ((LPNMLISTVIEW)lparam)->uNewState) {
464              idx = listview_get_curr_pos (lv);              idx = listview_get_curr_pos (lv);
465              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);              listview_get_item_text (lv, idx, SL_COL_VALID, inf, DIM (inf)-1);
466              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY),              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY),
467                            strcmp (inf, "NOKEY") == 0? TRUE: FALSE);                            strcmp (inf, "NOKEY") == 0? TRUE: FALSE);
468                EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_SIGPROPS),
469                              is_sig (lv, -1)? TRUE : FALSE);
470            }
471            if (notify->code == LVN_COLUMNCLICK) {
472                NMLISTVIEW *nft = (LPNMLISTVIEW) lparam;
473                int sortby = 0;
474                switch (nft->iSubItem) {
475                //case 0:  sortby = KEY_SORT_USERID; break;
476                case 1: sortby = KEY_SORT_VALIDITY; break;
477                case 2: sortby = SIG_SORT_CLASS; break;
478                case 3: sortby = KEY_SORT_CREATED; break;
479                case 4: sortby = KEY_SORT_KEYID; break;
480                case 5: sortby = SIG_SORT_EXPIRE; break;
481                case 6: sortby = KEY_SORT_ALGO; break;
482                default: return TRUE;
483                }
484                siglist_sort (lv, sortby);
485          }          }
486          break;          break;
487                    
488      case WM_COMMAND:      case WM_COMMAND:
489          switch ( LOWORD( wparam ) ) {          switch (LOWORD (wparam)) {
   
490          case ID_SIGCTX_KEYPROPS:          case ID_SIGCTX_KEYPROPS:
491              do_load_keyprops (dlg, lv);              do_load_keyprops (dlg, lv);
492              break;              break;
493    
494          case ID_SIGCTX_PROPS:          case ID_SIGCTX_PROPS:
495              if (is_sig (lv, -1))              if (is_sig (lv, -1)) {
496                    ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv));
497                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
498                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)ks);
499                }
500              break;              break;
501    
502          case IDC_KEYSIG_RECVKEY:          case IDC_KEYSIG_RECVKEY:
503              idx = listview_get_curr_pos (lv);              idx = listview_get_curr_pos (lv);
504              if (idx == -1) {              if (idx == -1)
505                  id = msg_box( dlg, _("Really receive all missing keys?"),                  recv_missing_keys (dlg, lv);
506                                  _("Key Manager"), MB_YESNO|MB_INFO );              else
507                  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, 4, keyid, DIM (keyid)-1);  
             rc = hkp_recv_key (dlg, default_keyserver, default_keyserver_port, keyid, 0, 0);  
             if (!rc)  
                 keycache_update (0, keyid);  
508              return TRUE;              return TRUE;
509    
510          case IDC_KEYSIG_SIGPROPS:          case IDC_KEYSIG_SIGPROPS:
511              if (is_sig (lv, -1))              if (is_sig (lv, -1)) {
512                    ks = ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv));
513                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
514                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)ks);
515                }
516              return TRUE;              return TRUE;
517                            
518            case IDCANCEL:
519                EndDialog (dlg, FALSE);
520                return TRUE;
521    
522          case IDOK:          case IDOK:
             if (k->update)  
                 keycache_update (0, k->keyid);  
523              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
524              return TRUE;              return TRUE;
525          }          }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26