/* When we try to 'decrypt' a key, this gets called */ static guint import_keys (const gchar *text, SeahorseApplet *sapplet) { gchar **keys, **k; gint nkeys = 0; gboolean ret; ret = dbus_g_proxy_call (dbus_key_proxy, "ImportKeys", NULL, G_TYPE_STRING, "openpgp", G_TYPE_STRING, text, G_TYPE_INVALID, G_TYPE_STRV, &keys, G_TYPE_INVALID); if (ret) { for (k = keys, nkeys = 0; *k; k++) nkeys++; g_strfreev (keys); if (!nkeys) seahorse_notification_display(_("Import Failed"), _("Keys were found but not imported."), FALSE, NULL, GTK_WIDGET(sapplet)); } return nkeys; }
static gboolean import_done (SeahorseToolMode *mode, const gchar *uri, gpgme_data_t uridata, SeahorsePGPOperation *pop, GError **err) { gchar **keys, **k; gint nkeys = 0; gboolean ret; ret = dbus_g_proxy_end_call (dbus_key_proxy, import_proxy_call, err, G_TYPE_STRV, &keys, G_TYPE_INVALID); if (ret) { for (k = keys, nkeys = 0; *k; k++) nkeys++; g_strfreev (keys); if (!nkeys) seahorse_notification_display(_("Import Failed"), _("Keys were found but not imported."), FALSE, NULL, NULL); } g_object_unref (dbus_key_proxy); return FALSE; }
static void notification_error (const char *title, const char *detail, SeahorseApplet *sapplet, GError *err) { /* Never show an error for 'cancelled' */ if (err->code == DBUS_GERROR_REMOTE_EXCEPTION && err->domain == DBUS_GERROR && strstr (dbus_g_error_get_name (err), "Cancelled")) return; seahorse_notification_display(title, detail, FALSE, NULL, GTK_WIDGET (sapplet)); }
/** * data: optional, will be added to the title, can be NULL * status: the gpgme status * * Basing on the status a notification is created an displayed * */ static void notify_signatures (const gchar* data, gpgme_verify_result_t status) { const gchar *icon = NULL; SeahorseObject *object; gchar *title, *body, *unesc_data; gboolean sig = FALSE; GSList *rawids; GList *keys; /* Discover the key in question */ rawids = g_slist_append (NULL, status->signatures->fpr); keys = seahorse_context_discover_objects (SCTX_APP (), SEAHORSE_PGP, rawids); g_slist_free (rawids); g_return_if_fail (keys != NULL); object = SEAHORSE_OBJECT (keys->data); g_list_free (keys); /* Figure out what to display */ switch (gpgme_err_code (status->signatures->status)) { case GPG_ERR_KEY_EXPIRED: /* TRANSLATORS: <key id='xxx'> is a custom markup tag, do not translate. */ body = _("Signed by <i><key id='%s'/> <b>expired</b></i> on %s."); title = _("Invalid Signature"); icon = ICON_PREFIX "seahorse-sign-bad.png"; sig = TRUE; break; /* TRANSLATORS: <key id='xxx'> is a custom markup tag, do not translate. */ case GPG_ERR_SIG_EXPIRED: body = _("Signed by <i><key id='%s'/></i> on %s <b>Expired</b>."); title = _("Expired Signature"); icon = ICON_PREFIX "seahorse-sign-bad.png"; sig = TRUE; break; /* TRANSLATORS: <key id='xxx'> is a custom markup tag, do not translate. */ case GPG_ERR_CERT_REVOKED: body = _("Signed by <i><key id='%s'/> <b>Revoked</b></i> on %s."); title = _("Revoked Signature"); icon = ICON_PREFIX "seahorse-sign-bad.png"; sig = TRUE; break; case GPG_ERR_NO_ERROR: /* TRANSLATORS: <key id='xxx'> is a custom markup tag, do not translate. */ body = _("Signed by <i><key id='%s'/></i> on %s."); title = _("Good Signature"); icon = ICON_PREFIX "seahorse-sign-ok.png"; sig = TRUE; break; case GPG_ERR_NO_PUBKEY: body = _("Signing key not in keyring."); title = _("Unknown Signature"); icon = ICON_PREFIX "seahorse-sign-unknown.png"; break; case GPG_ERR_BAD_SIGNATURE: body = _("Bad or forged signature. The signed data was modified."); title = _("Bad Signature"); icon = ICON_PREFIX "seahorse-sign-bad.png"; break; case GPG_ERR_NO_DATA: return; default: if (!GPG_IS_OK (status->signatures->status)) seahorse_gpgme_handle_error (status->signatures->status, _("Couldn't verify signature.")); return; }; if (sig) { gchar *date = seahorse_util_get_display_date_string (status->signatures->timestamp); gchar *id = seahorse_context_id_to_dbus (SCTX_APP (), seahorse_object_get_id (object)); body = g_markup_printf_escaped (body, id, date); g_free (date); g_free (id); } else { body = g_strdup (body); } if (data) { data = seahorse_util_uri_get_last (data); unesc_data = g_uri_unescape_string (data, NULL); title = g_strdup_printf ("%s: %s", unesc_data, title); g_free (unesc_data); } else { title = g_strdup (title); } seahorse_notification_display (title, body, !sig, icon, NULL); g_free(title); g_free(body); }
static void dvi_received (GtkClipboard *board, const gchar *text, SeahorseApplet *sapplet) { SeahorseTextType type; /* Type of the current block */ gchar *rawtext = NULL; /* Replacement text */ guint keys = 0; /* Number of keys imported */ const gchar *start; /* Pointer to start of the block */ const gchar *end; /* Pointer to end of the block */ /* Try to figure out what clipboard contains */ if (text == NULL) type = SEAHORSE_TEXT_TYPE_NONE; else type = detect_text_type (text, -1, &start, &end); if (type == SEAHORSE_TEXT_TYPE_NONE || type == SEAHORSE_TEXT_TYPE_PLAIN) { seahorse_notification_display(_("No PGP key or message was found on clipboard"), _("No PGP data found."), FALSE, NULL, GTK_WIDGET(sapplet)); return; } switch (type) { /* A key, import it */ case SEAHORSE_TEXT_TYPE_KEY: keys = import_keys (text, sapplet); break; /* A message decrypt it */ case SEAHORSE_TEXT_TYPE_MESSAGE: rawtext = decrypt_text (text, sapplet); break; /* A message verify it */ case SEAHORSE_TEXT_TYPE_SIGNED: rawtext = verify_text (text, sapplet); break; default: g_assert_not_reached (); break; }; /* We got replacement text */ if (rawtext) { gtk_clipboard_set_text (board, rawtext, strlen (rawtext)); detect_received (board, rawtext, sapplet); if (((type == SEAHORSE_TEXT_TYPE_MESSAGE) && (seahorse_gconf_get_boolean (DISPLAY_CLIPBOARD_DEC_KEY) == TRUE)) || ((type == SEAHORSE_TEXT_TYPE_SIGNED) && (seahorse_gconf_get_boolean (DISPLAY_CLIPBOARD_VER_KEY) == TRUE))) { /* TRANSLATORS: This means 'The text that was decrypted' */ display_text (_("Decrypted Text"), rawtext, TRUE); } g_free (rawtext); rawtext = NULL; } }