/[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 228 by twoaday, Tue May 30 15:31:49 2006 UTC revision 229 by twoaday, Mon Jun 19 14:04:31 2006 UTC
# Line 93  gpgme_op_clip_decrypt (gpgme_ctx_t ctx) Line 93  gpgme_op_clip_decrypt (gpgme_ctx_t ctx)
93  }  }
94    
95    
96    /* Return humand readable ownertrust description for verification info. */
97    const char*
98    verify_get_key_ownertrust (gpgme_validity_t key_ot, int *novalid)
99    {
100        const char *s;
101    
102        if (key_ot == GPGME_VALIDITY_FULL ||
103            key_ot == GPGME_VALIDITY_ULTIMATE)
104            s = _("Signature status: created with a fully trusted key");    
105        else if (key_ot == GPGME_VALIDITY_MARGINAL)    
106            s = _("Signature status: created with a marginal trusted key");
107        else if (key_ot == GPGME_VALIDITY_NEVER) {
108            if (novalid) *novalid = 1;
109            s =  _("Signature status: created with an UNTRUSTED key");      
110        }
111        else
112            s = _("Signature status: created with an undefined trusted key");
113        return s;
114    }
115    
116    
117    /* Return a signature specific header and footer for the clipboard. */
118    void
119    verify_get_clip_info (gpgme_signature_t sig, char **r_header, char **r_footer)
120    {
121        struct winpt_key_s pk;
122        const char *head = "***** BEGIN PGP SIGNED TEXT *****\r\n"
123                           "***** Signature made %s using key ID 0x%s\r\n"
124                           "***** %s\r\n"
125                           "***** \"%s\" from %s\r\n";
126        const char *foot = "***** END PGP SIGNED TEXT *****";    
127        const char *s, *made, *ot;
128        char *p;
129    
130        if (winpt_get_pubkey (sig->fpr, &pk))
131            BUG (0);
132        ot = verify_get_key_ownertrust (pk.ctx->owner_trust, NULL);
133        made = strtimestamp (sig->timestamp);
134        s = get_gpg_sigstat (sig->summary);
135        p = new char[strlen (head) + strlen (s) + strlen (made) +
136                     strlen (sig->fpr) + strlen (ot) +
137                     strlen (pk.ext->uids->uid) + 1];
138        if (!p)
139            BUG (0);
140        sprintf (p, head, made, get_keyid_from_fpr (sig->fpr), ot, s, pk.ext->uids->uid);
141        *r_header = p;
142        *r_footer = m_strdup (foot);
143    }
144    
145    
146  /* Show a human readable description of the given signature @sig. */  /* Show a human readable description of the given signature @sig. */
147  void  void
148  verify_show_signature_state (gpgme_signature_t sig)  verify_show_signature_state (gpgme_signature_t sig)
# Line 109  verify_show_signature_state (gpgme_signa Line 159  verify_show_signature_state (gpgme_signa
159      keyid = get_keyid_from_fpr (sig->fpr);      keyid = get_keyid_from_fpr (sig->fpr);
160      memset (&key, 0, sizeof (key));      memset (&key, 0, sizeof (key));
161    
     pka_info = get_pka_status (sig);  
   
162      if (!winpt_get_pubkey (keyid, &key)) {      if (!winpt_get_pubkey (keyid, &key)) {
163          if (key.ctx->owner_trust == GPGME_VALIDITY_FULL ||                s = verify_get_key_ownertrust (key.ctx->owner_trust, &novalid);
             key.ctx->owner_trust == GPGME_VALIDITY_ULTIMATE)  
             s = _("Signature Status: Created with a fully trusted key");  
         else if (key.ctx->owner_trust == GPGME_VALIDITY_MARGINAL)  
             s = _("Signature Status: Created with a marginal trusted key");  
         else if (key.ctx->owner_trust == GPGME_VALIDITY_NEVER) {  
             novalid = 1;  
             s =  _("Signature Status: Created with an UNTRUSTED key");  
         }  
         else  
             s = _("Signature Status: Created with an undefined trusted key");  
164          uid = key.ext->uids->uid;                uid = key.ext->uids->uid;      
165      }        }  
166      else {      else {
# Line 130  verify_show_signature_state (gpgme_signa Line 168  verify_show_signature_state (gpgme_signa
168          uid = _("user ID not found");          uid = _("user ID not found");
169      }      }
170    
171        pka_info = get_pka_status (sig);
172      log_box (_("Decrypt Verify"), novalid? MB_WARN : MB_OK,      log_box (_("Decrypt Verify"), novalid? MB_WARN : MB_OK,
173               _("%s\n"               _("%s\n"
174                 "%s\n"                 "%s\n"
# Line 152  verify_show_signature_state (gpgme_signa Line 191  verify_show_signature_state (gpgme_signa
191     @hwnd is the parent window used for showing messsages.     @hwnd is the parent window used for showing messsages.
192     Return value: 0 on success. */     Return value: 0 on success. */
193  gpgme_error_t  gpgme_error_t
194  clip_decrypt_dlg (HWND hwnd)  clip_decrypt_dlg (HWND hwnd, int use_viewer)
195  {  {
196      gpgme_error_t err;      gpgme_error_t err;
197      gpgme_ctx_t ctx = NULL;      gpgme_ctx_t ctx = NULL;
# Line 219  clip_decrypt_dlg (HWND hwnd) Line 258  clip_decrypt_dlg (HWND hwnd)
258      show_msg (GetDesktopWindow (), 1500, _("GnuPG Status: Finished"));      show_msg (GetDesktopWindow (), 1500, _("GnuPG Status: Finished"));
259    
260      sigres = gpgme_op_verify_result (ctx);      sigres = gpgme_op_verify_result (ctx);
261      if (sigres && sigres->signatures)      if (sigres && sigres->signatures) {
262          verify_show_signature_state (sigres->signatures);            if (!use_viewer)
263                    verify_show_signature_state (sigres->signatures);
264            else
265                DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_CLIPEDIT,
266                                hwnd, clip_edit_dlg_proc,
267                                (LPARAM)sigres->signatures);
268        }
269    
270  leave:  leave:
271      release_gpg_passphrase_cb (&pwd);      release_gpg_passphrase_cb (&pwd);
272      gpgme_release (ctx);      gpgme_release (ctx);

Legend:
Removed from v.228  
changed lines
  Added in v.229

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26