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

Diff of /trunk/Src/wptKeyPropsDlg.cpp

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

revision 217 by twoaday, Mon May 22 14:21:39 2006 UTC revision 226 by twoaday, Mon Jun 12 13:40:21 2006 UTC
# Line 78  ownertrust_to_string (int val, bool is_k Line 78  ownertrust_to_string (int val, bool is_k
78    
79  /* Generate a unique temp name for the photo which  /* Generate a unique temp name for the photo which
80     depends on the dialog handle and return it. */     depends on the dialog handle and return it. */
81  static const char*  const char*
82  get_photo_tmpname (HWND dlg)  get_photo_tmpname (HWND dlg)
83  {  {
84      static char buf[MAX_PATH+128+1];      static char buf[MAX_PATH+128+1];
85      char name[64];      char name[64];
86    
87      _snprintf (name, sizeof (name)-1, "winpt_photo_%08lX.tmp", (DWORD)dlg);      _snprintf (name, DIM (name)-1, "winpt_photo_%08lX.tmp", (DWORD)dlg);
88      get_temp_name (buf, DIM (buf)-1, name);      get_temp_name (buf, DIM (buf)-1, name);
89      return buf;      return buf;
90  }  }
# Line 99  draw_nophoto_img (HWND dlg) Line 99  draw_nophoto_img (HWND dlg)
99  }  }
100    
101    
102    
103    /* Delete temporary photo file. */
104    void
105    key_unload_photo (HWND dlg)
106    {
107        DeleteFile (get_photo_tmpname (dlg));
108    }
109    
110    
111  /* Load the photo from the key @key */  /* Load the photo from the key @key */
112  static int  int
113  keyprops_load_photo (HWND dlg, gpgme_key_t key, gpgme_validity_t *r_valid)  key_load_photo (HWND dlg, gpgme_key_t key, gpgme_validity_t *r_valid)
114  {  {
115      winpt_key_s k;      winpt_key_s k;
116      FILE *f;      FILE *f;
# Line 115  keyprops_load_photo (HWND dlg, gpgme_key Line 124  keyprops_load_photo (HWND dlg, gpgme_key
124      imglen = k.ext->attrib.len;      imglen = k.ext->attrib.len;
125      if (img && !k.ext->attrib.validity)      if (img && !k.ext->attrib.validity)
126          get_uat_validity (key->subkeys->keyid, &k.ext->attrib.validity);          get_uat_validity (key->subkeys->keyid, &k.ext->attrib.validity);
127      *r_valid = k.ext->attrib.validity;      if (r_valid)
128            *r_valid = k.ext->attrib.validity;
129    
130      if (!img || !imglen) {      if (!img || !imglen) {
131          draw_nophoto_img (dlg);          draw_nophoto_img (dlg);
# Line 132  keyprops_load_photo (HWND dlg, gpgme_key Line 142  keyprops_load_photo (HWND dlg, gpgme_key
142  }  }
143    
144    
 /* Display the photo in the image control in the dialog @dlg. */  
 static int  
 keyprops_show_photo (HWND dlg)  
 {  
     RECT r;      
     POINT p;  
     HWND h;  
   
     h = GetDlgItem (dlg, IDC_KEYPROPS_IMG);  
     GetWindowRect (h, &r);  
     p.x = r.left + 5;  
     p.y = r.top - 2;  
     memset (&p, 0, sizeof (p));  
     PTD_jpg_show (h, &p, get_photo_tmpname (dlg));  
       
     return 0;  
 }  
   
   
145  /* Return string representation of the key validity. @key. */  /* Return string representation of the key validity. @key. */
146  static const char*  static const char*
147  get_validity (gpgme_key_t key)  get_validity (gpgme_key_t key)
# Line 161  get_validity (gpgme_key_t key) Line 152  get_validity (gpgme_key_t key)
152          return _("Revoked");          return _("Revoked");
153      if (key->disabled)      if (key->disabled)
154          return _("Disabled");          return _("Disabled");
155        if (key->invalid)
156            return _("Invalid");
157      return get_key_trust2 (NULL, key->uids->validity, 0, 0);      return get_key_trust2 (NULL, key->uids->validity, 0, 0);
158  }  }
159    
# Line 191  get_pref_cipher (winpt_key_t k) Line 184  get_pref_cipher (winpt_key_t k)
184  static bool  static bool
185  check_for_desig_rev (gpgme_key_t key)  check_for_desig_rev (gpgme_key_t key)
186  {  {
187      winpt_key_s kk;      winpt_key_s k;
188    
189      memset (&kk, 0, sizeof (kk));      memset (&k, 0, sizeof (k));
190      if (!winpt_get_pubkey (key->subkeys->keyid, &kk))      if (!winpt_get_pubkey (key->subkeys->keyid, &k))
191          return kk.ext->gloflags.has_desig_rev? true : false;          return k.ext->gloflags.has_desig_rev? true : false;
192      return false;      return false;
193  }  }
194    
# Line 292  on_init_dialog (HWND dlg, WPARAM wparam, Line 285  on_init_dialog (HWND dlg, WPARAM wparam,
285      SetDlgItemText (dlg, IDC_KEYPROPS_OTINF, _("Ownertrust"));        SetDlgItemText (dlg, IDC_KEYPROPS_OTINF, _("Ownertrust"));  
286            
287      display_key_info (dlg, k);      display_key_info (dlg, k);
288      if (!keyprops_load_photo (dlg, k->ctx, &valid)) {      if (!key_load_photo (dlg, k->ctx, &valid)) {
289          k->has_photo = 1;          k->has_photo = 1;
290          if (valid < GPGME_VALIDITY_MARGINAL)          if (valid < GPGME_VALIDITY_MARGINAL)
291              SetDlgItemText (dlg, IDC_KEYPROPS_IMGINF, _("Photo-ID not validated."));              SetDlgItemText (dlg, IDC_KEYPROPS_IMGINF, _("Photo-ID not validated."));
# Line 330  keyprops_dlg_proc (HWND dlg, UINT msg, W Line 323  keyprops_dlg_proc (HWND dlg, UINT msg, W
323          return TRUE;          return TRUE;
324    
325      case WM_DESTROY:      case WM_DESTROY:
326          remove (get_photo_tmpname (dlg));          key_unload_photo (dlg);
327          delete prop;prop=NULL;          delete prop;prop = NULL;
328          SetWindowLong (dlg, GWL_USERDATA, 0);          SetWindowLong (dlg, GWL_USERDATA, 0);
329          break;          break;
330                
331      case WM_PAINT:      case WM_PAINT:
332          if (prop->key->has_photo)          /* Display the photo in the frame of the dialog @dlg.
333              keyprops_show_photo (dlg);             The coordinates are fixed to (0,0). */
334            if (prop->key->has_photo) {
335                POINT p;
336                p.x = p.y = 0;
337                PTD_jpg_show (GetDlgItem (dlg, IDC_KEYPROPS_IMG),
338                                &p, get_photo_tmpname (dlg));
339            }
340          break;          break;
341            
342      case WM_COMMAND:      case WM_COMMAND:
343          switch (LOWORD (wparam)) {          switch (LOWORD (wparam)) {
344          case IDOK:          case IDOK:

Legend:
Removed from v.217  
changed lines
  Added in v.226

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26