*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <glib.h>
#include <glib/gi18n.h>
#include <stdio.h>
+#include <errno.h>
#include "sgpgme.h"
#include "privacy.h"
if ((err = gpgme_op_verify(ctx, sig, plain, dummy)) != GPG_ERR_NO_ERROR) {
debug_print("op_verify err %s\n", gpgme_strerror(err));
- return NULL;
+ return GINT_TO_POINTER(-GPG_ERR_SYSTEM_ERROR);
+
}
status = gpgme_op_verify_result(ctx);
unsigned long validity = 0;
gpgme_signature_t sig = NULL;
- if (status == NULL)
- return SIGNATURE_UNCHECKED;
+ if (GPOINTER_TO_INT(status) == -GPG_ERR_SYSTEM_ERROR) {
+ debug_print("system error\n");
+ return SIGNATURE_CHECK_FAILED;
+ }
+ if (status == NULL) {
+ debug_print("status == NULL\n");
+ return SIGNATURE_UNCHECKED;
+ }
sig = status->signatures;
- if (sig == NULL)
+ if (sig == NULL) {
+ debug_print("sig == NULL\n");
return SIGNATURE_UNCHECKED;
-
+ }
validity = sig->validity;
+ debug_print("err code %d\n", gpg_err_code(sig->status));
switch (gpg_err_code(sig->status)) {
case GPG_ERR_NO_ERROR:
if ((validity != GPGME_VALIDITY_MARGINAL) &&
gchar *sgpgme_sigstat_info_short(gpgme_ctx_t ctx, gpgme_verify_result_t status)
{
gpgme_signature_t sig = NULL;
- gpgme_user_id_t user = NULL;
gchar *uname = NULL;
gpgme_key_t key;
+ if (GPOINTER_TO_INT(status) == -GPG_ERR_SYSTEM_ERROR) {
+ return g_strdup(_("The signature can't be checked - GPG error."));
+ }
+
if (status == NULL) {
return g_strdup(_("The signature has not been checked."));
}
{
gpgme_data_t data = NULL;
gpgme_error_t err;
- FILE *fp = fopen(mimeinfo->data.filename, "rb");
+ FILE *fp = g_fopen(mimeinfo->data.filename, "rb");
gchar *tmp_file = NULL;
if (!fp)
tmp_file = get_tmp_file();
copy_file_part(fp, mimeinfo->offset, mimeinfo->length, tmp_file);
fclose(fp);
- fp = fopen(tmp_file, "rb");
+ fp = g_fopen(tmp_file, "rb");
debug_print("tmp file %s\n", tmp_file);
if (!fp)
return NULL;
err = gpgme_data_new_from_file(&data, tmp_file, 1);
- unlink(tmp_file);
+ g_unlink(tmp_file);
g_free(tmp_file);
- debug_print("data %p (%d %d)\n", data, mimeinfo->offset, mimeinfo->length);
+ debug_print("data %p (%d %d)\n", (void *)&data, mimeinfo->offset, mimeinfo->length);
if (err) {
debug_print ("gpgme_data_new_from_file failed: %s\n",
- gpgme_strerror (err));
+ gpgme_strerror (err));
return NULL;
}
return data;
gchar *sgpgme_get_encrypt_data(GSList *recp_names)
{
- gpgme_key_t *keys = gpgmegtk_recipient_selection(recp_names);
+ SelectionResult result = KEY_SELECTION_CANCEL;
+ gpgme_key_t *keys = gpgmegtk_recipient_selection(recp_names, &result);
gchar *ret = NULL;
int i = 0;
- if (!keys)
- return NULL;
-
+ if (!keys) {
+ if (result == KEY_SELECTION_DONT)
+ return g_strdup("_DONT_ENCRYPT_");
+ else
+ return NULL;
+ }
while (keys[i]) {
gpgme_subkey_t skey = keys[i]->subkeys;
gchar *fpr = skey->fpr;
if (prefs_gpg_get_config()->gpg_warning) {
AlertValue val;
- val = alertpanel_message_with_disable
+ val = alertpanel_full
(_("Warning"),
_("GnuPG is not installed properly, or needs "
- "to be upgraded.\n"
- "OpenPGP support disabled."),
- NULL, NULL, NULL, ALERT_WARNING);
+ "to be upgraded.\n"
+ "OpenPGP support disabled."),
+ GTK_STOCK_CLOSE, NULL, NULL, TRUE, NULL,
+ ALERT_WARNING, G_ALERTDEFAULT);
if (val & G_ALERTDISABLE)
prefs_gpg_get_config()->gpg_warning = FALSE;
}