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

Diff of /trunk/Src/wptClipDecryptDlg.cpp

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

revision 256 by twoaday, Sat Aug 5 10:31:06 2006 UTC revision 286 by twoaday, Fri Mar 9 19:34:17 2007 UTC
# Line 1  Line 1 
1  /* wptClipDecryptDlg.cpp - Clipboard decryption  /* wptClipDecryptDlg.cpp - Clipboard decryption
2   *      Copyright (C) 2000-2006 Timo Schulz   *      Copyright (C) 2000-2007 Timo Schulz
3   *      Copyright (C) 2005 g10 Code GmbH   *      Copyright (C) 2005 g10 Code GmbH
4   *   *
5   * This file is part of WinPT.   * This file is part of WinPT.
# 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   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * 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  
16   */   */
   
17  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
18  #include <config.h>  #include <config.h>
19  #endif  #endif
# Line 40  Line 35 
35  #include "wptKeylist.h"  #include "wptKeylist.h"
36  #include "wptUTF8.h"  #include "wptUTF8.h"
37  #include "resource.h"  #include "resource.h"
38    #include "StringBuffer.h"
39    
40  bool is_seckey_available (gpgme_recipient_t rset);  bool is_seckey_available (gpgme_recipient_t rset);
41  char* get_pka_status (gpgme_signature_t sig);  char* get_pka_status (gpgme_signature_t sig);
# Line 51  char* Line 47  char*
47  get_key_userid (const char *keyid)  get_key_userid (const char *keyid)
48  {  {
49      winpt_key_s key;      winpt_key_s key;
50      const char *fmt, *userid;      StringBuffer p;
51        const char *userid;
52      char *uid;      char *uid;
53    
54      fmt = "\n    \"%s\"";      p = "\n    ";  
55      memset (&key, 0, sizeof (key));      memset (&key, 0, sizeof (key));
56      if (winpt_get_pubkey (keyid, &key))      if (winpt_get_pubkey (keyid, &key))
57          userid = (_("user ID not found"));          userid = (_("user ID not found"));
58      else      else
59          userid = key.ext->uids->uid;          userid = key.ext->uids->uid;
60      uid = new char[strlen (userid) + strlen (fmt)+ 2];      p = p + "\"" + userid + "\"";
61      if (!uid)  
         BUG (NULL);  
     sprintf (uid, fmt, userid);  
62      winpt_release_pubkey (&key);      winpt_release_pubkey (&key);
63        uid = p.getBufferCopy ();
64      return uid;      return uid;
65  }  }
66    
# Line 103  verify_get_key_ownertrust (gpgme_validit Line 99  verify_get_key_ownertrust (gpgme_validit
99  {  {
100      const char *s;      const char *s;
101    
102        if (novalid)
103            *novalid = 0; /* reset */
104      if (key_ot == GPGME_VALIDITY_FULL ||      if (key_ot == GPGME_VALIDITY_FULL ||
105          key_ot == GPGME_VALIDITY_ULTIMATE)          key_ot == GPGME_VALIDITY_ULTIMATE)
106          s = _("Signature status: created with a fully trusted key");              s = _("Signature status: created with a fully trusted key");    
107      else if (key_ot == GPGME_VALIDITY_MARGINAL)          else if (key_ot == GPGME_VALIDITY_MARGINAL)    
108          s = _("Signature status: created with a marginal trusted key");          s = _("Signature status: created with a marginal trusted key");
109      else if (key_ot == GPGME_VALIDITY_NEVER) {      else if (key_ot == GPGME_VALIDITY_NEVER) {
110          if (novalid) *novalid = 1;          if (novalid)
111                *novalid = 1;
112          s =  _("Signature status: created with an UNTRUSTED key");                s =  _("Signature status: created with an UNTRUSTED key");      
113      }      }
114      else      else
# Line 131  verify_get_clip_info (gpgme_signature_t Line 130  verify_get_clip_info (gpgme_signature_t
130                           "*** Signer: %s (0x%s)\r\n"                           "*** Signer: %s (0x%s)\r\n"
131                           "*** BEGIN PGP DECRYPTED TEXT ***\r\n");                           "*** BEGIN PGP DECRYPTED TEXT ***\r\n");
132      const char *foot = _("\r\n*** END PGP DECRYPTED TEXT ***");      const char *foot = _("\r\n*** END PGP DECRYPTED TEXT ***");
133      const char *s, *ver, *ot;      const char *stat, *ot, *uid, *keyid;
134      char *p, *made;      char made[128], ver[128];
135        char *p;
     if (winpt_get_pubkey (sig->fpr, &pk))  
         BUG (0);  
136    
137      ot = verify_get_key_ownertrust (pk.ctx->owner_trust, NULL);      if (winpt_get_pubkey (sig->fpr, &pk)) {
138      made = m_strdup (strtimestamp (sig->timestamp));          uid = _("user ID not found");
139      ver = strtimestamp (time (NULL));          ot = verify_get_key_ownertrust (GPGME_VALIDITY_UNDEFINED, NULL);
140      s = get_gpg_sigstat (sig->summary);      }
141      p = new char[strlen (head) + strlen (s) + strlen (made) +      else {
142            uid = pk.ext->uids->uid;
143            ot = verify_get_key_ownertrust (pk.ctx->owner_trust, NULL);
144        }
145        
146        if (!get_locale_timedate (sig->timestamp, made, DIM (made)-1))
147            _snprintf (made, DIM (made)-1, "'unknown time'");
148        if (!get_locale_timedate (time (NULL), ver, DIM (ver)-1))
149            _snprintf (ver, DIM (ver)-1, "'unknown time'");
150        stat = get_gpg_sigstat (sig->summary);
151        p = new char[strlen (head) + strlen (stat) + strlen (made) +
152                   strlen (sig->fpr) + strlen (ot) + strlen (ver) +                   strlen (sig->fpr) + strlen (ot) + strlen (ver) +
153                   strlen (pk.ext->uids->uid) + 1];                   strlen (uid) + 1];
154      if (!p)      if (!p)
155          BUG (0);          BUG (0);
156      sprintf (p, head, made, ver, ot, s,      if (strlen (sig->fpr) == 32) { /* RSA:MD5 */
157                  pk.ext->uids->uid, get_keyid_from_fpr (sig->fpr));          if (pk.ext != NULL)
158                keyid = pk.ext->key->subkeys->keyid+8;
159            else
160                keyid = sig->fpr; /* show the fingerprint in case of problems. */
161        }
162        else
163            keyid = get_keyid_from_fpr (sig->fpr);
164        sprintf (p, head, made, ver, ot, stat, uid, keyid);
165      *r_header = p;      *r_header = p;
166      *r_footer = m_strdup (foot);      *r_footer = m_strdup (foot);
     free_if_alloc (made);  
167  }  }
168    
169    
# Line 161  verify_show_signature_state (gpgme_signa Line 174  verify_show_signature_state (gpgme_signa
174      winpt_key_s key;      winpt_key_s key;
175      const char *keyid, *uid;      const char *keyid, *uid;
176      const char *s;      const char *s;
177      char *pka_info = NULL;      char *pka_info = NULL, timebuf[128];
178      int novalid = 0;      int novalid = 0;
179    
180      assert (sig->fpr != NULL);      assert (sig->fpr != NULL);
181                    
     keyid = get_keyid_from_fpr (sig->fpr);  
182      memset (&key, 0, sizeof (key));      memset (&key, 0, sizeof (key));
183      if (!winpt_get_pubkey (keyid, &key)) {      if (!winpt_get_pubkey (sig->fpr, &key)) {
184          s = verify_get_key_ownertrust (key.ctx->owner_trust, &novalid);          s = verify_get_key_ownertrust (key.ctx->owner_trust, &novalid);
185          uid = key.ext->uids->uid;                uid = key.ext->uids->uid;      
186      }      }
# Line 177  verify_show_signature_state (gpgme_signa Line 189  verify_show_signature_state (gpgme_signa
189          uid = _("user ID not found");          uid = _("user ID not found");
190      }      }
191    
192        if (!get_locale_timedate (sig->timestamp, timebuf, DIM (timebuf)-1))
193            _snprintf (timebuf, DIM (timebuf)-1, "'unknown time'");
194    
195        if (strlen (sig->fpr) == 32) {
196            if (key.ctx != NULL)
197                keyid = key.ctx->subkeys->keyid+8;
198            else
199                keyid = sig->fpr; /* in case of problems show the fingerprint. */
200        }  
201        else
202            keyid = get_keyid_from_fpr (sig->fpr);
203        
204      pka_info = get_pka_status (sig);      pka_info = get_pka_status (sig);
205      log_box (_("Decrypt Verify"), novalid? MB_WARN : MB_OK,      log_box (_("Decrypt Verify"), novalid? MB_WARN : MB_OK,
206               _("%s\n"               _("%s\n"
# Line 185  verify_show_signature_state (gpgme_signa Line 209  verify_show_signature_state (gpgme_signa
209                 "From \"%s\" using key ID 0x%s"                 "From \"%s\" using key ID 0x%s"
210                 "%s %s\n%s"),                 "%s %s\n%s"),
211                 s, get_gpg_sigstat (sig->summary),                                   s, get_gpg_sigstat (sig->summary),                  
212                 strtimestamp (sig->timestamp),                 timebuf, uid, keyid,
                uid, keyid,  
213                 novalid? "\nPrimary key fingerprint: " : "",                 novalid? "\nPrimary key fingerprint: " : "",
214                 novalid? get_key_fpr (key.ctx) : "",                 novalid? get_key_fpr (key.ctx) : "",
215                 pka_info? pka_info : ""                 pka_info? pka_info : ""

Legend:
Removed from v.256  
changed lines
  Added in v.286

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26