/[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 65 by twoaday, Thu Nov 3 16:55:25 2005 UTC revision 328 by twoaday, Fri Sep 25 16:07:38 2009 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, 2008 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
# Line 12  Line 12 
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.
  *  
  * You should have received a copy of the GNU General Public License  
  * along with WinPT; if not, write to the Free Software Foundation,  
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA  
15   */   */
   
16  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
17  #include <config.h>  #include <config.h>
18  #endif  #endif
# Line 44  Line 39 
39  static subclass_s siglist_proc;  static subclass_s siglist_proc;
40    
41    
42    /* Return -1 if the selected item is a signature. */
43  static int  static int
44  is_sig (listview_ctrl_t lv, int pos)  is_sig (listview_ctrl_t lv, int pos)
45  {  {
46      char tmpbuf[256];      char tmpbuf[200];
47    
48      if (pos == -1)      if (pos == -1)
49          pos = listview_get_curr_pos (lv);          pos = listview_get_curr_pos (lv);
50      if (pos == -1)      if (pos == -1)
51          return 0;          return 0;
52      listview_get_item_text (lv, pos, 0, tmpbuf, 200);      listview_get_item_text (lv, pos, SL_COL_UID, tmpbuf, sizeof (tmpbuf)-1);
53      if (*tmpbuf == ' ')      if (*tmpbuf == ' ')
54          return -1;          return -1;
55      return 0;      return 0;
# Line 65  is_sig (listview_ctrl_t lv, int pos) Line 61  is_sig (listview_ctrl_t lv, int pos)
61  static int  static int
62  do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key)  do_delsig (HWND dlg, listview_ctrl_t lv, winpt_key_t key)
63  {  {
     int pos, npos, id;  
     int signo=0, uidno=0;  
     GpgKeyEdit *ke;  
64      gpgme_error_t err;      gpgme_error_t err;
65        GpgKeyEdit ke;
66        char keyid[32];
67        int pos, npos, id, is_selfsig=0;
68        int signo=0, uidno=0;
69    
70      npos = pos = listview_get_curr_pos (lv);      npos = pos = listview_get_curr_pos (lv);
71      if (!is_sig (lv, -1))      if (!is_sig (lv, -1))
72          return -1;          return -1;
73        listview_get_item_text (lv, pos, SL_COL_KEYID, keyid, sizeof (keyid)-1);
74        if (!strncmp (key->keyid, keyid+2, 8))
75            is_selfsig = 1;
76        
77      while (pos > 0 && is_sig (lv, pos)) {      while (pos > 0 && is_sig (lv, pos)) {
78          signo++;          signo++;
79          pos--;          pos--;
# Line 86  do_delsig (HWND dlg, listview_ctrl_t lv, Line 87  do_delsig (HWND dlg, listview_ctrl_t lv,
87      uidno++;      uidno++;
88    
89      /* XXX: do not allow to delete the self signature */      /* XXX: do not allow to delete the self signature */
90      id = log_box (_("Key Manager"), MB_YESNO,      id = log_box (_("Key Manager"), is_selfsig? MB_WARN_ASK : MB_QUEST_ASK,
91                    _("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"
92                      "  \"%s\""), key->uid);                    "  \"%s\""), is_selfsig? _("self signature") : _("signature"),
93                      key->uid);
94      if (id == IDNO)      if (id == IDNO)
95          return 0;          return 0;
96    
97      ke = new GpgKeyEdit (key->keyid);      ke.setKeyID (key->keyid);
98      if (!ke)      err = ke.delUseridSignature (uidno, signo);
         BUG (NULL);      
     err = ke->delUseridSignature (uidno, signo);  
99      if (err)      if (err)
100          msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);          msg_box (dlg, gpgme_strerror (err), _("Key Manager"), MB_ERR);
101      else      else
102          listview_del_item (lv, pos);          listview_del_item (lv, pos);
103      delete ke;      if (!err)
104      key->update = 1; /*update*/          key->update = 1;
105      return err? -1 : 0;      return err? -1 : 0;
106  }  }
107    
108    
109    /* Initialize a datepicker control with the time given in @t. */
110    static void
111    init_datepicker_from_time (HWND picker, time_t t)
112    {
113        SYSTEMTIME st;
114        struct tm *tm;
115    
116        tm = localtime (&t);
117        memset (&st, 0, sizeof st);
118        st.wYear = tm->tm_year+1900;
119        st.wMonth = tm->tm_mon+1;
120        st.wDay = tm->tm_mday;
121        DateTime_SetSystemtime (picker, GDT_VALID, &st);
122    }
123    
124    
125  /* Dialog box procedure to display the signature properties. */  /* Dialog box procedure to display the signature properties. */
126  static BOOL CALLBACK  BOOL CALLBACK
127  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  sigprops_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
128  {  {
129      static listview_ctrl_t lv;      gpgme_key_sig_t ks;
130        winpt_key_s issuer;
131      char tmpbuf[256];      char tmpbuf[256];
132      int n;      static struct {
     struct {  
133          unsigned int exportable:1;          unsigned int exportable:1;
134          unsigned int expired:1;          unsigned int expired:1;
135          unsigned int nrev:1;          unsigned int nrev:1;
136          unsigned int rev:1;          unsigned int rev:1;
137          const char * alg;          const char *alg;
138          int _class;          int _class;
139      } ctx;      } ctx;
140      const char *fmt_templ = _("%s %s signature");      const char *fmt_templ = _("%s %s signature");
141        const char *s;
142    
143      switch (msg) {      switch (msg) {
     case WM_SYSCOMMAND:  
         if (LOWORD (wparam) == SC_CLOSE)  
             EndDialog (dlg, TRUE);  
         return FALSE;  
   
144      case WM_INITDIALOG:      case WM_INITDIALOG:
145          lv = (listview_ctrl_t)lparam;          ks = (gpgme_key_sig_t)lparam;
146          if (!lv)          if (!ks)
147              dlg_fatal_error (dlg, "could not get dialog param");              BUG (0);
148            SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));
149            SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));
150            SetDlgItemText (dlg, IDC_SIGPROPS_EXPIRED, _("Expired"));
151            SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));
152            SetDlgItemText (dlg, IDC_SIGPROPS_CLASSINF, _("Class"));
153            SetDlgItemText (dlg, IDC_SIGPROPS_EXPSTR, _("Expire date"));
154            SetDlgItemText (dlg, IDC_SIGPROPS_CREATSTR, _("Creation date"));
155            SetDlgItemText (dlg, IDC_SIGPROPS_KEYINF, _("Issuer key"));
156            SetDlgItemText (dlg, IDC_SIGPROPS_KEYIDINF, _("Issuer key ID"));
157            SetDlgItemText (dlg, IDC_SIGPROPS_POLICINF, _("Policy URL"));
158            SetDlgItemText (dlg, IDC_SIGPROPS_FRAME, _("Signature Info"));
159            SetWindowText (dlg, _("Signature Properties"));
160            
161          memset (&ctx, 0, sizeof ctx);          memset (&ctx, 0, sizeof ctx);
162          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);  
163          if (ctx._class == 0)          if (ctx._class == 0)
164              ctx._class = 10;              ctx._class = 16;    
165          else if (ctx._class < 10)          ctx._class -= 6;
166              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"))          
167              ctx.alg = "DSA";              ctx.alg = "DSA";
168          else if (strstr (tmpbuf, "RSA"))          else if (ks->pubkey_algo == GPGME_PK_RSA)
169              ctx.alg = "RSA";              ctx.alg = "RSA";
170          else          else
171              ctx.alg = "ELG";              ctx.alg = "ELG";
172            ctx.exportable = ks->exportable;
173          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,          _snprintf (tmpbuf, DIM (tmpbuf)-1, fmt_templ,
174                     ctx.exportable? _("Exportable") : _("Non-exportable"), ctx.alg);                     ctx.exportable? _("Exportable") : _("Non-exportable"),
175                       ctx.alg);
176          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);          SetDlgItemText (dlg, IDC_SIGPROPS_INFO, tmpbuf);
177          listview_get_item_text (lv, n, 4, tmpbuf, DIM (tmpbuf)-1);          
178            _snprintf (tmpbuf, DIM (tmpbuf)-1, "0x%s", ks->keyid+8);
179          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);          SetDlgItemText (dlg, IDC_SIGPROPS_KEYID, tmpbuf);
180          SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);          SetDlgItemInt (dlg, IDC_SIGPROPS_CLASS, ctx._class, FALSE);
181          if (ctx.exportable)          if (ctx.exportable)
182              CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);              CheckDlgButton (dlg, IDC_SIGPROPS_EXP, BST_CHECKED);
183          listview_get_item_text (lv, n, 0, tmpbuf, DIM (tmpbuf)-1);          memset (&issuer, 0, sizeof (issuer));
184          SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, tmpbuf+1);          if (!winpt_get_pubkey (ks->keyid+8, &issuer))
185          tmpbuf[0] = 0;              s = issuer.ext->uids->uid;
186          listview_get_item_text (lv, n, 5, tmpbuf, DIM (tmpbuf)-1);          else
187          if (strlen (tmpbuf) == 0) {              s = _("  user ID not found");
188            SetDlgItemText (dlg, IDC_SIGPROPS_ISSUER, s);
189    
190            init_datepicker_from_time (GetDlgItem (dlg, IDC_SIGPROPS_CREATDATE),
191                                        ks->timestamp);
192            if (ks->expires == 0) {
193              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPSTR), SW_HIDE);
194              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);              ShowWindow (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE), SW_HIDE);
195          }          }
196          else {          else {
197              SYSTEMTIME st;              init_datepicker_from_time (GetDlgItem (dlg, IDC_SIGPROPS_EXPDATE),
198              struct tm * tm;                                          ks->expires);
199              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)  
200                  ctx.expired = 1;                  ctx.expired = 1;
201              if (ctx.expired)              if (ctx.expired)
202                  CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED);                  CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED, BST_CHECKED);
203          }          }
204            if (ks->notations && !ks->notations->name && ks->notations->value)
205                SetDlgItemText (dlg, IDC_SIGPROPS_POLIC, ks->notations->value);
206    
207          SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));          SetDlgItemText (dlg, IDC_SIGPROPS_EXP, _("Exportable"));
208          SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));          SetDlgItemText (dlg, IDC_SIGPROPS_NREV, _("Non-revocably"));
209          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));          SetDlgItemText (dlg, IDC_SIGPROPS_REV, _("Revoked"));
# Line 198  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 214  sigprops_dlg_proc (HWND dlg, UINT msg, W
214          return TRUE;          return TRUE;
215    
216      case WM_COMMAND:      case WM_COMMAND:
217            if (HIWORD (wparam) == BN_CLICKED) {
218                /* Code to prevent the user changes the check buttons. */
219                switch (LOWORD (wparam)) {
220                case IDC_SIGPROPS_EXP:
221                    CheckDlgButton (dlg, IDC_SIGPROPS_EXP,
222                                     ctx.exportable? BST_CHECKED : BST_UNCHECKED);
223                    return TRUE;
224    
225                case IDC_SIGPROPS_EXPIRED:
226                    CheckDlgButton (dlg, IDC_SIGPROPS_EXPIRED,
227                                    ctx.expired? BST_CHECKED : BST_UNCHECKED);
228                    return TRUE;
229    
230                case IDC_SIGPROPS_REV:
231                    CheckDlgButton (dlg, IDC_SIGPROPS_REV,
232                                    ctx.rev? BST_CHECKED : BST_UNCHECKED);
233                    return TRUE;
234    
235                case IDC_SIGPROPS_NREV:
236                    CheckDlgButton (dlg, IDC_SIGPROPS_NREV,
237                                    ctx.nrev? BST_CHECKED : BST_UNCHECKED);
238                    return TRUE;
239                }
240            }
241    
242          switch (LOWORD (wparam)) {          switch (LOWORD (wparam)) {
243          case IDOK:          case IDOK:
244              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
245              break;              break;
246    
247            case IDCANCEL:
248                EndDialog (dlg, FALSE);
249                break;
250          }          }
251      }      }
252    
# Line 209  sigprops_dlg_proc (HWND dlg, UINT msg, W Line 254  sigprops_dlg_proc (HWND dlg, UINT msg, W
254  }  }
255    
256    
257    /* Subclass window procedure for the list view. */
258  static BOOL CALLBACK  static BOOL CALLBACK
259  subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  subclass_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
260  {  {
261      listview_ctrl_t lv;      listview_ctrl_t lv;
262      winpt_key_t key;      winpt_key_t key;
263        gpgme_key_sig_t ks;
264    
265      switch (msg) {      switch (msg) {
266      case WM_KEYUP:      case WM_KEYUP:
# Line 221  subclass_dlg_proc (HWND dlg, UINT msg, W Line 268  subclass_dlg_proc (HWND dlg, UINT msg, W
268          key = (winpt_key_t)siglist_proc.opaque;          key = (winpt_key_t)siglist_proc.opaque;
269          lv = key->callback.ctl;          lv = key->callback.ctl;
270          if (virt_key == VK_SPACE) {          if (virt_key == VK_SPACE) {
271              if (is_sig (lv, -1))              if (is_sig (lv, -1)) {
272                    ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv));
273                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
274                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)ks);
275                }
276          }          }
277          else if (virt_key == VK_DELETE)          else if (virt_key == VK_DELETE)
278              do_delsig (dlg, lv, key);              do_delsig (dlg, lv, key);
# Line 237  subclass_dlg_proc (HWND dlg, UINT msg, W Line 286  subclass_dlg_proc (HWND dlg, UINT msg, W
286  static int  static int
287  check_for_missing_keys (listview_ctrl_t lv)  check_for_missing_keys (listview_ctrl_t lv)
288  {  {
289      int i, n;      int n;
290      char id[128];      char id[128];
291        const char *txt = _("NOKEY");
292            
293      n = listview_count_items( lv, 0 );      n = listview_count_items (lv, 0);
294      for( i = 0; i < n; i++ ) {      for (int i = 0; i < n; i++) {
295          listview_get_item_text( lv, i, 1, id, sizeof (id) - 1 );          listview_get_item_text (lv, i, SL_COL_VALID, id, DIM (id) - 1);
296          if( !strncmp( id, "NOKEY", 5 ) )          if (!strncmp (id, txt, strlen (txt)))
297              return 1;              return 1;
298      }      }
299            
# Line 255  check_for_missing_keys (listview_ctrl_t Line 305  check_for_missing_keys (listview_ctrl_t
305  static int  static int
306  recv_missing_keys (HWND dlg, listview_ctrl_t lv)  recv_missing_keys (HWND dlg, listview_ctrl_t lv)
307  {  {
308      int i, n, rc=0;      const char *txt = _("NOKEY");
309      char id[128], keyid[18+1];      char id[128], keyid[18+1];
310        int n, cnt=0;
311    
312        if (msg_box (dlg, _("Really receive all missing keys?"),
313                     _("Key Manager"), MB_YESNO|MB_INFO) == IDNO)
314            return 0;
315            
316      n = listview_count_items (lv, 0);      n = listview_count_items (lv, 0);
317      for( i = 0; i < n; i++ ) {      for (int i = 0; i < n; i++) {
318          listview_get_item_text( lv, i, 1, id, sizeof id - 1 );          listview_get_item_text (lv, i, SL_COL_VALID, id, DIM (id) - 1);
319          if( !strncmp( id, "NOKEY", 5 ) ) {          if (!strncmp (id, txt, strlen (txt))) {
320              listview_get_item_text( lv, i, 4, keyid, sizeof keyid -1 );              listview_get_item_text (lv, i, SL_COL_KEYID,
321              rc = hkp_recv_key( dlg, default_keyserver, default_keyserver_port, keyid, 0, 0 );                                      keyid, DIM (keyid) -1);
322              if( rc )                            if (!hkp_recv_key (dlg, default_keyserver,
323                                   default_keyserver_port, keyid, 0, 0)) {
324                    keycache_update (0, keyid);
325                    cnt++;
326                }
327                else
328                  break;                  break;
329          }          }
330      }      }
331            return cnt;
     return rc;  
332  }  }
333    
334    
# Line 283  do_create_popup (HWND dlg) Line 342  do_create_popup (HWND dlg)
342      GetCursorPos (&p);      GetCursorPos (&p);
343      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));      hm = LoadMenu (glob_hinst, MAKEINTRESOURCE (IDR_WINPT_KEYSIG_CTX));
344      sm = GetSubMenu (hm, 0);      sm = GetSubMenu (hm, 0);
   
345      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));      set_menu_text (sm, ID_SIGCTX_PROPS, _("Signature &Properties"));
346      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));      set_menu_text (sm, ID_SIGCTX_KEYPROPS, _("Signing &Key Properties"));
   
347      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);      TrackPopupMenu (sm, TPM_RIGHTALIGN, p.x, p.y, 0, dlg, NULL);
   
348      DestroyMenu (hm);      DestroyMenu (hm);
349      DestroyMenu (sm);      DestroyMenu (sm);
350  }  }
351    
352    
353    /* Fetch a single key and extract the keyid from the listview
354       entry at the pos @idx. */
355    static int
356    recv_single_key (HWND dlg, listview_ctrl_t lv, int idx)
357    {
358        char keyid[32];
359        int rc;
360    
361        listview_get_item_text (lv, idx, SL_COL_KEYID, keyid, DIM (keyid)-1);      
362        rc = hkp_recv_key (dlg, default_keyserver,
363                           default_keyserver_port, keyid, 0, 0);
364        if (!rc)
365            keycache_update (0, keyid);
366        return rc;
367    }
368    
369    
370  /* Load the key property dialog with the selected key from @lv. */  /* Load the key property dialog with the selected key from @lv. */
371  static void  static void
372  do_load_keyprops (HWND dlg, listview_ctrl_t lv)  do_load_keyprops (HWND dlg, listview_ctrl_t lv)
373  {  {    
374      winpt_key_s k;      winpt_key_s k;
     gpgme_key_t key;  
375      char keyid[32] = {0};      char keyid[32] = {0};
376      char status[64] = {0}, creation[64] = {0};      char status[64] = {0}, creation[64] = {0};
377      int n = listview_get_curr_pos (lv);      int n = listview_get_curr_pos (lv);
378    
379      listview_get_item_text (lv, n, 1, status, DIM (status)-1);      listview_get_item_text (lv, n, SL_COL_VALID, status, DIM (status)-1);
380      listview_get_item_text (lv, n, 3, creation, DIM (creation)-1);      listview_get_item_text (lv, n, SL_COL_CREATE, creation, DIM (creation)-1);
381      listview_get_item_text (lv, n, 4, keyid, DIM (keyid)-1);      listview_get_item_text (lv, n, SL_COL_KEYID, keyid, DIM (keyid)-1);
382      if (!strcmp (status, "NOKEY")) {      if (!strcmp (status, _("NOKEY"))) {
383          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?"),
384                   _("Key Manager"), MB_INFO);                            _("Key Manager"), MB_QUEST_ASK);
385          return;          if (id == IDNO)
386                return;
387            if (recv_single_key (dlg, lv, n))              
388                return;
389      }      }
390            
391      if ((strlen (keyid) < 3 ||get_pubkey (keyid, &key))) {      memset (&k, 0, sizeof k);
392        if ((strlen (keyid) < 3 || winpt_get_pubkey (keyid, &k))) {
393          if (strlen (creation) > 0)          if (strlen (creation) > 0)
394              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);              msg_box (dlg, _("Key not found in keyring."), _("Key Manager"), MB_INFO);
395          return;          return;
396      }      }
     memset (&k, 0, sizeof k);  
     k.keyid = keyid;  
397      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_KEYPROPS, dlg,
398                      keyprops_dlg_proc, (LPARAM)&k);                      keyprops_dlg_proc, (LPARAM)&k);
399  }  }
# Line 331  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 405  keysig_dlg_proc (HWND dlg, UINT msg, WPA
405  {  {
406      static listview_ctrl_t lv = NULL;      static listview_ctrl_t lv = NULL;
407      static struct winpt_key_s *k;      static struct winpt_key_s *k;
408      char inf[384], keyid[18+1];          gpgme_key_sig_t ks;
     int idx = 0, id, rc;  
409      HWND sl;      HWND sl;
410        char inf[384];
411        int idx = 0;    
412            
413      switch( msg ) {      switch (msg) {
414      case WM_INITDIALOG:      case WM_INITDIALOG:
415          k = (winpt_key_t) lparam;          k = (winpt_key_t) lparam;
416          if (!k)          if (!k)
# Line 343  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 418  keysig_dlg_proc (HWND dlg, UINT msg, WPA
418          if (k->uid)          if (k->uid)
419              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);              _snprintf (inf, DIM (inf)-1, _("Signature List for \"%s\""), k->uid);
420          SetWindowText (dlg, inf);          SetWindowText (dlg, inf);
         #ifndef LANG_DE  
421          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));          SetDlgItemText (dlg, IDC_KEYSIG_RECVKEY, _("&Receive Key"));
422          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));          SetDlgItemText (dlg, IDC_KEYSIG_SIGPROPS, _("&Properties"));
423          #endif  
424          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);          lv = siglist_load (GetDlgItem (dlg, IDC_KEYSIG_LIST), k->keyid);
425          if (!check_for_missing_keys (lv))          if (!check_for_missing_keys (lv))
426              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), FALSE);              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY), FALSE);
427            EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_SIGPROPS), FALSE);
428          k->callback.ctl = lv;          k->callback.ctl = lv;
429          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);          sl = GetDlgItem (dlg, IDC_KEYSIG_LIST);
430          siglist_proc.dlg = dlg;          siglist_proc.dlg = dlg;
# Line 358  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 433  keysig_dlg_proc (HWND dlg, UINT msg, WPA
433          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);          siglist_proc.old = (WNDPROC)GetWindowLong (sl, GWL_WNDPROC);
434          if (siglist_proc.old) {          if (siglist_proc.old) {
435              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {              if (!SetWindowLong (sl, GWL_WNDPROC, (LONG)siglist_proc.current))  {
436                  msg_box (dlg, _("Could not set keylist window procedure."),                  msg_box (dlg, "Could not set keylist window procedure.",
437                           _("Key Manager"), MB_ERR);                           _("Key Manager"), MB_ERR);
438                  BUG (0);                  BUG (0);
439              }              }
# Line 368  keysig_dlg_proc (HWND dlg, UINT msg, WPA Line 443  keysig_dlg_proc (HWND dlg, UINT msg, WPA
443          return TRUE;          return TRUE;
444                    
445      case WM_DESTROY:      case WM_DESTROY:
446          if ( lv ) {          if (lv) {
447              siglist_delete( lv );              siglist_delete (lv);
448              lv = NULL;              lv = NULL;
449          }          }
450          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;  
451    
452      case WM_NOTIFY:      case WM_NOTIFY:
453          NMHDR *notify;          NMHDR *notify;
454                    
455          notify = (NMHDR *)lparam;          notify = (NMHDR *)lparam;
456          if (notify && notify->code == NM_DBLCLK          if (!notify)
457              && notify->idFrom == IDC_KEYSIG_LIST)              return FALSE;
458              do_load_keyprops (dlg, lv);          if (notify->code == NM_DBLCLK &&
         if (notify && notify->code == NM_RCLICK &&  
459              notify->idFrom == IDC_KEYSIG_LIST)              notify->idFrom == IDC_KEYSIG_LIST)
460                do_load_keyprops (dlg, lv);
461            if (notify->code == NM_RCLICK &&
462                notify->idFrom == IDC_KEYSIG_LIST &&
463                is_sig (lv, -1))
464              do_create_popup (dlg);              do_create_popup (dlg);
465          if (notify && notify->code == LVN_ITEMCHANGED &&          if (notify->code == LVN_ITEMCHANGED &&
466              ((LPNMLISTVIEW)lparam)->uNewState) {              ((LPNMLISTVIEW)lparam)->uNewState) {
467              idx = listview_get_curr_pos (lv);              idx = listview_get_curr_pos (lv);
468              listview_get_item_text (lv, idx, 1, inf, DIM (inf)-1);              listview_get_item_text (lv, idx, SL_COL_VALID, inf, DIM (inf)-1);
469              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY),              EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_RECVKEY),
470                            strcmp (inf, "NOKEY") == 0? TRUE: FALSE);                            strcmp (inf, _("NOKEY")) == 0? TRUE: FALSE);
471                EnableWindow (GetDlgItem (dlg, IDC_KEYSIG_SIGPROPS),
472                              is_sig (lv, -1)? TRUE : FALSE);
473            }
474            if (notify->code == LVN_COLUMNCLICK) {
475                NMLISTVIEW *nft = (LPNMLISTVIEW) lparam;
476                int sortby = 0;
477                switch (nft->iSubItem) {
478                //case 0:  sortby = KEY_SORT_USERID; break;
479                case 1: sortby = KEY_SORT_VALIDITY; break;
480                case 2: sortby = SIG_SORT_CLASS; break;
481                case 3: sortby = KEY_SORT_CREATED; break;
482                case 4: sortby = KEY_SORT_KEYID; break;
483                case 5: sortby = SIG_SORT_EXPIRE; break;
484                case 6: sortby = KEY_SORT_ALGO; break;
485                default: return TRUE;
486                }
487                siglist_sort (lv, sortby);
488          }          }
489          break;          break;
490                    
491      case WM_COMMAND:      case WM_COMMAND:
492          switch ( LOWORD( wparam ) ) {          switch (LOWORD (wparam)) {
   
493          case ID_SIGCTX_KEYPROPS:          case ID_SIGCTX_KEYPROPS:
494              do_load_keyprops (dlg, lv);              do_load_keyprops (dlg, lv);
495              break;              return TRUE;
496    
497          case ID_SIGCTX_PROPS:          case ID_SIGCTX_PROPS:
498              if (is_sig (lv, -1))              if (is_sig (lv, -1)) {
499                    ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv));
500                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
501                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)ks);
502              break;              }
503                return TRUE;
504    
505          case IDC_KEYSIG_RECVKEY:          case IDC_KEYSIG_RECVKEY:
506              idx = listview_get_curr_pos (lv);              idx = listview_get_curr_pos (lv);
507              if (idx == -1) {              if (idx == -1)
508                  id = msg_box( dlg, _("Really receive all missing keys?"),                  recv_missing_keys (dlg, lv);
509                                  _("Key Manager"), MB_YESNO|MB_INFO );              else
510                  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);  
511              return TRUE;              return TRUE;
512    
513          case IDC_KEYSIG_SIGPROPS:          case IDC_KEYSIG_SIGPROPS:
514              if (is_sig (lv, -1))              if (is_sig (lv, -1)) {
515                    ks = (gpgme_key_sig_t)listview_get_item2 (lv, listview_get_curr_pos (lv));
516                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,                  DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_SIGPROPS, dlg,
517                                  sigprops_dlg_proc, (LPARAM)lv);                                  sigprops_dlg_proc, (LPARAM)ks);
518                }
519              return TRUE;              return TRUE;
520                            
521            case IDCANCEL:
522                EndDialog (dlg, FALSE);
523                return TRUE;
524    
525          case IDOK:          case IDOK:
             if (k->update)  
                 keycache_update (0, k->keyid);  
526              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
527              return TRUE;              return TRUE;
528          }          }

Legend:
Removed from v.65  
changed lines
  Added in v.328

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26