21 |
/* TODO: |
/* TODO: |
22 |
* check_armor_type: we should check the whole file and not only the first line! |
* check_armor_type: we should check the whole file and not only the first line! |
23 |
*/ |
*/ |
|
|
|
24 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
25 |
#include <config.h> |
#include <config.h> |
26 |
#endif |
#endif |
281 |
const char *s = NULL; |
const char *s = NULL; |
282 |
int rc = 0; |
int rc = 0; |
283 |
|
|
284 |
|
/* XXX: if the text was created with gpg --sign and armored |
285 |
|
there is no way to differ between an encrypted text |
286 |
|
and a one-pass signature. */ |
287 |
if (r_type) |
if (r_type) |
288 |
*r_type = PGP_NONE; |
*r_type = PGP_NONE; |
289 |
if (!fname) { |
if (!fname) { |
339 |
s = "SECKEY"; rc = -2; |
s = "SECKEY"; rc = -2; |
340 |
if (r_type) *r_type = PGP_SECKEY; |
if (r_type) *r_type = PGP_SECKEY; |
341 |
break; |
break; |
342 |
|
|
343 |
default: |
default: |
344 |
break; |
break; |
345 |
} |
} |
732 |
} /* fm_check_file_type */ |
} /* fm_check_file_type */ |
733 |
|
|
734 |
|
|
735 |
|
/* Set the file status of the given command @fm_cmd. |
736 |
|
@success is 0 on success. */ |
737 |
static void |
static void |
738 |
fm_set_status (listview_ctrl_t lv, int pos, int fm_cmd, int success, |
fm_set_status (listview_ctrl_t lv, int pos, int fm_cmd, |
739 |
const char * output) |
gpgme_sig_mode_t sigmode, int success, const char *output) |
740 |
{ |
{ |
741 |
char status[128], operat[128]; |
char status[128], operat[128]; |
742 |
int update = 1; |
int update = 1; |
743 |
const char *s; |
const char *s; |
744 |
|
|
745 |
if ( fm_cmd == FM_LIST ) |
if (fm_cmd == FM_LIST) |
746 |
return; |
return; |
747 |
success ? s = "SUCCESS" : s = "FAILED"; |
success ? s = "SUCCESS" : s = "FAILED"; |
748 |
strcpy( operat, s ); |
strcpy (operat, s); |
749 |
|
|
750 |
switch (fm_cmd) { |
switch (fm_cmd) { |
751 |
case FM_ENCRYPT: |
case FM_ENCRYPT: |
752 |
case FM_ENCRYPT_DIR: |
case FM_ENCRYPT_DIR: |
753 |
case FM_SIGNENCRYPT: strcpy( status, "ENCRYPTED" ); break; |
case FM_SIGNENCRYPT: strcpy (status, "ENCRYPTED"); break; |
754 |
case FM_DECRYPT: strcpy( status, "UNKNOWN" ); break; |
case FM_DECRYPT: strcpy (status, "UNKNOWN"); break; |
755 |
case FM_SIGN: strcpy( status, "SIGNED" ); break; |
case FM_SIGN: |
756 |
|
if (sigmode == GPGME_SIG_MODE_DETACH) |
757 |
|
strcpy (status, "SIGNED-DETACH"); |
758 |
|
else |
759 |
|
strcpy (status, "SIGNED"); |
760 |
|
break; |
761 |
case FM_VERIFY: update = 0; break; |
case FM_VERIFY: update = 0; break; |
762 |
case FM_SYMENC: strcpy( status, "SYMKEYENC" ); break; |
case FM_SYMENC: strcpy (status, "SYMKEYENC"); break; |
763 |
case FM_IMPORT: update = 0; break; |
case FM_IMPORT: update = 0; break; |
764 |
case FM_WIPE: strcpy( status, "WIPED" ); break; |
case FM_WIPE: strcpy (status, "WIPED"); break; |
765 |
default: strcpy( status, "UNKNOWN"); break; |
default: strcpy (status, "UNKNOWN"); break; |
766 |
} |
} |
767 |
|
|
768 |
if (success) { |
if (success) { |
772 |
} |
} |
773 |
} |
} |
774 |
listview_add_sub_item( lv, pos, 2, operat ); |
listview_add_sub_item( lv, pos, 2, operat ); |
775 |
} /* fm_set_status */ |
} |
776 |
|
|
777 |
|
|
778 |
int |
int |
944 |
rc = fm_import (ctx, fname); |
rc = fm_import (ctx, fname); |
945 |
break; |
break; |
946 |
} |
} |
947 |
fm_set_status (lv, i, fm_cmd, !rc, ctx->output); |
fm_set_status (lv, i, fm_cmd, ctx->sigmode, !rc, ctx->output); |
948 |
free_if_alloc (ctx->output); |
free_if_alloc (ctx->output); |
949 |
progress_cleanup (&pfx); |
progress_cleanup (&pfx); |
950 |
} |
} |
1659 |
gpgme_error_t err; |
gpgme_error_t err; |
1660 |
gpgme_key_t *rset = c->recp; |
gpgme_key_t *rset = c->recp; |
1661 |
file_data_t keydata = NULL; |
file_data_t keydata = NULL; |
1662 |
const char *name; |
const char *name, *s = NULL; |
1663 |
char *p = NULL, *patt = NULL; |
char *p = NULL, *patt = NULL; |
1664 |
|
|
1665 |
if (!rset || !rset[0]) { |
if (!rset || !rset[0]) { |
1768 |
fm_verify (ctx, detached, fn); |
fm_verify (ctx, detached, fn); |
1769 |
file_verify_wait (); |
file_verify_wait (); |
1770 |
break; |
break; |
1771 |
|
|
1772 |
default: |
default: |
1773 |
break; |
break; |
1774 |
} |
} |
1834 |
return rc; |
return rc; |
1835 |
|
|
1836 |
out_enc = make_filename (NULL, outfile, "gpg"); |
out_enc = make_filename (NULL, outfile, "gpg"); |
1837 |
fm_set_status (lv, idx, FM_ENCRYPT, 1, out_enc); |
fm_set_status (lv, idx, FM_ENCRYPT, (gpgme_sig_mode_t)0, 1, out_enc); |
1838 |
free_if_alloc (out_enc); |
free_if_alloc (out_enc); |
1839 |
|
|
1840 |
for (i=0; i < nitems; i++) { |
for (i=0; i < nitems; i++) { |