/[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 208 by twoaday, Mon May 1 12:22:18 2006 UTC revision 219 by twoaday, Sat May 27 08:56:00 2006 UTC
# Line 95  strtimestamp (long timestamp) Line 95  strtimestamp (long timestamp)
95  }  }
96    
97    
98    /* Return human printable PKA status.
99       If no pka information is available, return NULL. */
100    char*
101    get_pka_status (gpgme_signature_t sig)
102    {
103        const char *fmt;
104        char *pka_inf;
105    
106        if (sig->pka_trust == 0 || !sig->pka_address)
107            return NULL;
108        fmt = _("PKA: Verified signer's address is '%s'");
109        pka_inf = new char[strlen (fmt)+strlen (sig->pka_address)+2];
110        if (!pka_inf)
111            BUG (NULL);    
112        sprintf (pka_inf, fmt, sig->pka_address);
113        return pka_inf;
114    }
115    
116    
117    /* Set additional signature information according to the
118       signature @sig. If no info control is used, just return. */
119    void
120    verlist_set_additional_info (verlist_ctrl_t vlv, gpgme_signature_t sig)
121    {
122        int used = 1;
123    
124        if (!vlv->infctl)
125            return;
126    
127        if (sig->exp_timestamp > (DWORD)time (NULL))
128            SendMessage (vlv->infctl, WM_SETTEXT, 0, (LPARAM)(char*)
129                         _("The signature is expired!"));
130        else if (sig->validity != GPGME_VALIDITY_MARGINAL &&
131                 sig->validity != GPGME_VALIDITY_FULL &&
132                 sig->validity != GPGME_VALIDITY_ULTIMATE) {
133            SendMessage (vlv->infctl, WM_SETTEXT, 0, (LPARAM)(char*)
134                         _("WARNING: This key is not certified with a trusted signature!\r\n"
135                           "                   There is no indication that the signature belongs to the owner.\r\n"));
136        }
137        else {
138            char *pka_info = get_pka_status (sig);
139            if (pka_info != NULL) {
140                SendMessage (vlv->infctl, WM_SETTEXT, 0, (LPARAM)(char*)pka_info);
141                free_if_alloc (pka_info);
142            }
143            else {
144                SendMessage (vlv->infctl, WM_SETTEXT, 0, (LPARAM)(char*)"");
145                used = 0;
146            }
147        }    
148        ShowWindow (vlv->infctl, used? SW_SHOW : SW_HIDE);
149    }
150    
151    
152  /* Build a verify signature list control. With the parent window  /* Build a verify signature list control. With the parent window
153     from @ctrl and the mod given in @fm_mode. @lv contains the     from @ctrl and the mod given in @fm_mode. @lv contains the
154     new control on success.     new control on success.
155     Return value: 0 on success. */     Return value: 0 on success. */
156  int  void
157  verlist_build (listview_ctrl_t *lv, HWND ctrl, int fm_mode)  verlist_build (verlist_ctrl_t *vlv, HWND ctrl, int fm_mode)
158  {      {
     struct listview_ctrl_s *c;  
159      struct listview_column_s verlist[] = {      struct listview_column_s verlist[] = {
160          {0, 100, (char *)_("Name")},          {0, 100, (char *)_("Name")},
161          {1, 140, (char *)_("Status") },          {1, 140, (char *)_("Status") },
# Line 112  verlist_build (listview_ctrl_t *lv, HWND Line 165  verlist_build (listview_ctrl_t *lv, HWND
165          {5, 160, (char *)_("User ID") },          {5, 160, (char *)_("User ID") },
166          {6, 0, NULL}          {6, 0, NULL}
167      };      };
168        struct verlist_ctrl_s *v;
169      int j;      int j;
170            
171      listview_new (&c, ctrl);      v = new verlist_ctrl_s;
172        if (!v)
173            BUG (0);
174        memset (v, 0, sizeof *v);
175        listview_new (&v->lv, ctrl);
176      for(j=0; verlist[j].fieldname; j++)      for(j=0; verlist[j].fieldname; j++)
177          listview_add_column (c, &verlist[j]);          listview_add_column (v->lv, &verlist[j]);
178      if (!fm_mode)      if (!fm_mode)
179          listview_set_column_width (c, 0, 60);          listview_set_column_width (v->lv, 0, 60);
180      listview_set_ext_style (c);      listview_set_ext_style (v->lv);
181      *lv = c;      *vlv = v;
182      return 0;  }
183    
184    
185    void
186    verlist_set_info_control (verlist_ctrl_t vlv, HWND infctl)
187    {
188        vlv->infctl = infctl;
189  }  }
190    
191    
192  /* Delete the given verify control in @lv. */  /* Delete the given verify control in @lv. */
193  void  void
194  verlist_delete (listview_ctrl_t lv)  verlist_delete (verlist_ctrl_t vlv)
195  {  {
196      if (lv) {      if (vlv) {
197          listview_release (lv);            listview_release (vlv->lv);
198            free_if_alloc (vlv);
199      }      }
200  }  }
201    
# Line 138  verlist_delete (listview_ctrl_t lv) Line 203  verlist_delete (listview_ctrl_t lv)
203  /* Add the given signature in @sig to the verify control @lv.  /* Add the given signature in @sig to the verify control @lv.
204     Return value: 0 on success. */     Return value: 0 on success. */
205  int  int
206  verlist_add_sig (listview_ctrl_t lv, gpgme_signature_t sig)  verlist_add_sig (verlist_ctrl_t vlv, gpgme_signature_t sig)
207  {  {
208        struct listview_ctrl_s *lv;
209      struct winpt_key_s key;      struct winpt_key_s key;
210      u32 key_attr;      u32 key_attr;
211      const char *attr;      const char *attr;
212      char keyid[32+1];      char keyid[32+1];
213            
214        lv = vlv->lv;
215      if (listview_add_item (lv, " "))      if (listview_add_item (lv, " "))
216          return WPTERR_GENERAL;          return WPTERR_GENERAL;
217                    
# Line 175  verlist_add_sig (listview_ctrl_t lv, gpg Line 242  verlist_add_sig (listview_ctrl_t lv, gpg
242            
243      attr = key.ctx? key.ext->uids->name : _("user ID not found");      attr = key.ctx? key.ext->uids->name : _("user ID not found");
244      listview_add_sub_item (lv, 0, VER_COL_UID, attr);      listview_add_sub_item (lv, 0, VER_COL_UID, attr);
245    
246        if (vlv->infctl)
247            verlist_set_additional_info (vlv, sig);
248      return 0;      return 0;
249  }  }
250    
# Line 182  verlist_add_sig (listview_ctrl_t lv, gpg Line 252  verlist_add_sig (listview_ctrl_t lv, gpg
252  /* Add the given file signature in @log to the verify control @lv.  /* Add the given file signature in @log to the verify control @lv.
253     Return value: 0 on success. */     Return value: 0 on success. */
254  int  int
255  verlist_add_sig_log (listview_ctrl_t lv, file_sig_ctx_t log)  verlist_add_sig_log (verlist_ctrl_t vlv, file_sig_ctx_t log)
256  {  {
257      gpgme_signature_t sig = log->sig;      gpgme_signature_t sig = log->sig;
258        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], *name;
262    
263        lv = vlv->lv;
264      if (listview_add_item (lv, "")) {      if (listview_add_item (lv, "")) {
265          log_debug ("verlist_add_sig_log: listview_add_item() failed.\n");          log_debug ("verlist_add_sig_log: listview_add_item() failed.\n");
266          return WPTERR_GENERAL;          return WPTERR_GENERAL;
267      }      }
268    
   
269      memset (&key, 0, sizeof (key));      memset (&key, 0, sizeof (key));
270      winpt_get_pubkey (sig->fpr, &key);      winpt_get_pubkey (sig->fpr, &key);
271            
# Line 230  verlist_add_sig_log (listview_ctrl_t lv, Line 301  verlist_add_sig_log (listview_ctrl_t lv,
301      listview_add_sub_item (lv, 0, VER_COL_UID,      listview_add_sub_item (lv, 0, VER_COL_UID,
302                             log->user_id?                             log->user_id?
303                             log->user_id : _("user ID not found"));                             log->user_id : _("user ID not found"));
304        if (vlv->infctl)
305            verlist_set_additional_info (vlv, sig);
306    
307      return 0;      return 0;
308  }  }

Legend:
Removed from v.208  
changed lines
  Added in v.219

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26