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

Diff of /trunk/Src/wptVerifyList.cpp

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

revision 262 by twoaday, Sat Sep 30 10:24:34 2006 UTC revision 292 by twoaday, Mon Mar 12 20:37:13 2007 UTC
# Line 13  Line 13 
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * General Public License for more details.   * 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  
16   */   */
17    
18  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
# Line 53  enum { Line 49  enum {
49  static char*  static char*
50  extract_filename (const char *path)  extract_filename (const char *path)
51  {  {
52      char * fname, *p;      char *p;
53      int n, len = 0;      size_t pos;
54    
55      p = strrchr (path, '\\');      p = strrchr (path, '\\');
56      if (!p)      if (p == NULL)
57          return m_strdup (path);          return m_strdup (path);
58      n = p - path;      pos = p-path;
59      len = strlen (path) - n;      return substr (path, pos+1, strlen (path)-1);
     fname = new char[len+1];  
     if (!fname)  
         BUG (NULL);  
     memcpy (fname, path+n+1, len);  
     fname[len] = '\0';  
     return fname;  
 }  
   
   
 /* String representaton of the time in @timestamp.  
    Format YEAR-MON-DAY HOUR:MIN:SEC.  
    Return value: time as formatted string. */  
 const char*  
 strtimestamp (long timestamp)  
 {  
     static char timebuf[64];  
     struct tm *warp;  
     const char *dat;  
       
     dat = get_locale_date (timestamp, timebuf, sizeof (timebuf)-1);  
     warp = localtime (&timestamp);  
     if (!dat)  
         _snprintf (timebuf, sizeof (timebuf) - 1,  
                    "%04d-%02d-%02d %02d:%02d:%02d",  
                     warp->tm_year+1900, warp->tm_mon+1, warp->tm_mday,    
                     warp->tm_hour, warp->tm_min, warp->tm_sec);  
     else  
         _snprintf (timebuf, sizeof (timebuf)-1,  
                    "%s %02d:%02d:%02d", dat,  
                    warp->tm_hour, warp->tm_min, warp->tm_sec);  
   
     return timebuf;  
60  }  }
61    
62    
# Line 182  verlist_build (verlist_ctrl_t *vlv, HWND Line 146  verlist_build (verlist_ctrl_t *vlv, HWND
146          BUG (0);          BUG (0);
147      memset (v, 0, sizeof *v);      memset (v, 0, sizeof *v);
148      listview_new (&v->lv, ctrl);      listview_new (&v->lv, ctrl);
149      for(j=0; verlist[j].fieldname; j++)      for (j=0; verlist[j].fieldname; j++)
150          listview_add_column (v->lv, &verlist[j]);          listview_add_column (v->lv, &verlist[j]);
151      if (!fm_mode)      if (!fm_mode)
152          listview_set_column_width (v->lv, 0, 80);          listview_set_column_width (v->lv, 0, 80);
# Line 212  verlist_delete (verlist_ctrl_t vlv) Line 176  verlist_delete (verlist_ctrl_t vlv)
176  }  }
177    
178    
179    /* Handy function to extract the real key ID from a signature. */
180    const char *
181    sig_get_real_keyid (gpgme_signature_t sig, winpt_key_t key)
182    {
183        const char *keyid;
184        
185         /* We still need an extra check for RSA:MD5 keys because we
186            cannot derrive the keyid directly from the fingerprint. */
187        if (strlen (sig->fpr) == 32) {
188            if (key->ext != NULL)
189                keyid = key->ext->key->subkeys->keyid+8;
190            else /* show the fingerprint if the key is not in the keyring. */
191                keyid = sig->fpr;
192        }
193        else
194            keyid = get_keyid_from_fpr (sig->fpr);
195        return keyid;
196    }
197    
198        
199  /* Add the given signature in @sig to the verify control @lv.  /* Add the given signature in @sig to the verify control @lv.
200     Return value: 0 on success. */     Return value: 0 on success. */
201  int  int
# Line 220  verlist_add_sig (verlist_ctrl_t vlv, gpg Line 204  verlist_add_sig (verlist_ctrl_t vlv, gpg
204      listview_ctrl_t lv;      listview_ctrl_t lv;
205      struct winpt_key_s key;          struct winpt_key_s key;    
206      const char *attr;      const char *attr;
207      char keyid[32+1];      char keyid[32+1], timebuf[128];
208      u32 key_attr;      u32 key_attr;
209      int is_bad;      int is_bad;
210            
# Line 229  verlist_add_sig (verlist_ctrl_t vlv, gpg Line 213  verlist_add_sig (verlist_ctrl_t vlv, gpg
213      if (listview_add_item_image (lv, " ", is_bad))      if (listview_add_item_image (lv, " ", is_bad))
214          return WPTERR_GENERAL;          return WPTERR_GENERAL;
215                    
216      listview_add_sub_item (lv, 0, VER_COL_NAME, "Clipboard");      listview_add_sub_item (lv, 0, VER_COL_NAME, _("Clipboard"));
217    
218      memset (&key, 0, sizeof (key));      memset (&key, 0, sizeof (key));
219      winpt_get_pubkey (sig->fpr, &key);      winpt_get_pubkey (sig->fpr, &key);
# Line 240  verlist_add_sig (verlist_ctrl_t vlv, gpg Line 224  verlist_add_sig (verlist_ctrl_t vlv, gpg
224      if (attr)      if (attr)
225          listview_add_sub_item (lv, 0, VER_COL_STAT, (char *)attr);          listview_add_sub_item (lv, 0, VER_COL_STAT, (char *)attr);
226            
227      attr = strtimestamp (sig->timestamp);      attr = get_locale_timedate (sig->timestamp, timebuf, DIM (timebuf)-1);
228        if (!attr)
229            attr = _("Unknown");
230      listview_add_sub_item (lv, 0, VER_COL_SIGNED, (char *)attr);      listview_add_sub_item (lv, 0, VER_COL_SIGNED, (char *)attr);
231            
232      attr = _("Unknown");      attr = _("Unknown");
# Line 250  verlist_add_sig (verlist_ctrl_t vlv, gpg Line 236  verlist_add_sig (verlist_ctrl_t vlv, gpg
236      }      }
237      listview_add_sub_item (lv, 0, VER_COL_TRUST, (char *)attr);      listview_add_sub_item (lv, 0, VER_COL_TRUST, (char *)attr);
238            
239      attr = get_keyid_from_fpr (sig->fpr);            attr = sig_get_real_keyid (sig, &key);
240      _snprintf (keyid, sizeof keyid -1, "0x%s", attr);      _snprintf (keyid, DIM (keyid) -1, "0x%s", attr);
241      listview_add_sub_item (lv, 0, VER_COL_KEYID, keyid);      listview_add_sub_item (lv, 0, VER_COL_KEYID, keyid);
242            
243      attr = key.ctx? key.ext->uids->name : _("user ID not found");      attr = key.ctx? key.ext->uids->name : _("user ID not found");
# Line 272  verlist_add_sig_log (verlist_ctrl_t vlv, Line 258  verlist_add_sig_log (verlist_ctrl_t vlv,
258      struct listview_ctrl_s *lv;      struct listview_ctrl_s *lv;
259      struct winpt_key_s key;      struct winpt_key_s key;
260      const char *attr;      const char *attr;
261      char t[64], *name;      char t[64], timebuf[128], *name;
262        int is_bad;
263    
264      lv = vlv->lv;      lv = vlv->lv;
265      if (listview_add_item (lv, "")) {      is_bad = sig->summary & GPGME_SIGSUM_RED? 1 : 0;
266        if (listview_add_item_image (lv, "", is_bad)) {
267          log_debug ("verlist_add_sig_log: listview_add_item() failed.\n");          log_debug ("verlist_add_sig_log: listview_add_item() failed.\n");
268          return WPTERR_GENERAL;          return WPTERR_GENERAL;
269      }      }
# Line 284  verlist_add_sig_log (verlist_ctrl_t vlv, Line 272  verlist_add_sig_log (verlist_ctrl_t vlv,
272      winpt_get_pubkey (sig->fpr, &key);      winpt_get_pubkey (sig->fpr, &key);
273            
274      name = extract_filename (log->file);      name = extract_filename (log->file);
275      if (name)      if (name != NULL)
276          listview_add_sub_item (lv, 0, VER_COL_NAME, name);          listview_add_sub_item (lv, 0, VER_COL_NAME, name);
277      else      else
278          listview_add_sub_item (lv, 0, VER_COL_NAME, log->file);          listview_add_sub_item (lv, 0, VER_COL_NAME, log->file);
# Line 294  verlist_add_sig_log (verlist_ctrl_t vlv, Line 282  verlist_add_sig_log (verlist_ctrl_t vlv,
282          attr = get_gpg_sigstat (GPGME_SIGSUM_GREEN);          attr = get_gpg_sigstat (GPGME_SIGSUM_GREEN);
283      else      else
284          attr = get_gpg_sigstat (sig->summary);          attr = get_gpg_sigstat (sig->summary);
285      if (attr)      listview_add_sub_item (lv, 0, VER_COL_STAT, attr);
         listview_add_sub_item (lv, 0, VER_COL_STAT, attr);  
286    
287      if (sig->timestamp > 0)      if (sig->timestamp > 0) {
288          attr = strtimestamp (sig->timestamp);          attr = get_locale_timedate (sig->timestamp, timebuf, DIM (timebuf)-1);
289            if (!attr)
290                attr = _("Unknown");
291        }
292      else      else
293          attr = "No time";          attr = _("Unknown");
294      listview_add_sub_item (lv, 0, VER_COL_SIGNED, attr);      listview_add_sub_item (lv, 0, VER_COL_SIGNED, attr);
295                    
296      if (key.ctx != NULL)      if (key.ctx != NULL)
# Line 309  verlist_add_sig_log (verlist_ctrl_t vlv, Line 299  verlist_add_sig_log (verlist_ctrl_t vlv,
299          attr = _("Unknown");          attr = _("Unknown");
300      listview_add_sub_item (lv, 0, VER_COL_TRUST, attr);      listview_add_sub_item (lv, 0, VER_COL_TRUST, attr);
301    
302      attr = get_keyid_from_fpr (sig->fpr);      attr = sig_get_real_keyid (sig, &key);
303      _snprintf (t, sizeof (t)-1, "0x%s", attr);      _snprintf (t, DIM (t)-1, "0x%s", attr);
304      listview_add_sub_item (lv, 0, VER_COL_KEYID, t);      listview_add_sub_item (lv, 0, VER_COL_KEYID, t);
305      listview_add_sub_item (lv, 0, VER_COL_UID,      listview_add_sub_item (lv, 0, VER_COL_UID,
306                             log->user_id?                             log->user_id?

Legend:
Removed from v.262  
changed lines
  Added in v.292

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26