From: Colin Leroy Date: Sat, 7 Oct 2006 17:45:59 +0000 (+0000) Subject: 2006-10-07 [colin] 2.5.3cvs16 X-Git-Tag: rel_2_6_0~59 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=2a353e44164b3b42214e91d78e3dcf7aceb8981c 2006-10-07 [colin] 2.5.3cvs16 * src/textview.c * src/textview.h Make a bit more of the API available * src/plugins/pgpcore/Makefile.am * src/plugins/pgpcore/plugin.c * src/plugins/pgpcore/sgpgme.c Add basic key import/export --- diff --git a/ChangeLog b/ChangeLog index e8e29c8ad..ec43fbb62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-10-07 [colin] 2.5.3cvs16 + + * src/textview.c + * src/textview.h + Make a bit more of the API available + * src/plugins/pgpcore/Makefile.am + * src/plugins/pgpcore/plugin.c + * src/plugins/pgpcore/sgpgme.c + Add basic key import/export + 2006-10-07 [colin] 2.5.3cvs15 * src/folderview.c diff --git a/PATCHSETS b/PATCHSETS index edc31f597..c44397930 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -1970,3 +1970,4 @@ ( cvs diff -u -r 1.115.2.108 -r 1.115.2.109 src/main.c; cvs diff -u -r 1.10.2.21 -r 1.10.2.22 src/prefs_gtk.c; cvs diff -u -r 1.5.2.8 -r 1.5.2.9 src/prefs_gtk.h; cvs diff -u -r 1.7.2.8 -r 1.7.2.9 src/common/sylpheed.c; ) > 2.5.3cvs13.patchset ( cvs diff -u -r 1.58.2.25 -r 1.58.2.26 po/de.po; cvs diff -u -r 1.60.2.35 -r 1.60.2.36 po/es.po; ) > 2.5.3cvs14.patchset ( cvs diff -u -r 1.207.2.129 -r 1.207.2.130 src/folderview.c; cvs diff -u -r 1.179.2.132 -r 1.179.2.133 src/imap.c; cvs diff -u -r 1.105.2.67 -r 1.105.2.68 src/prefs_account.c; cvs diff -u -r 1.1.2.36 -r 1.1.2.37 src/wizard.c; ) > 2.5.3cvs15.patchset +( cvs diff -u -r 1.96.2.153 -r 1.96.2.154 src/textview.c; cvs diff -u -r 1.12.2.13 -r 1.12.2.14 src/textview.h; cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/pgpcore/Makefile.am; cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/plugins/pgpcore/plugin.c; cvs diff -u -r 1.1.2.27 -r 1.1.2.28 src/plugins/pgpcore/sgpgme.c; ) > 2.5.3cvs16.patchset diff --git a/configure.ac b/configure.ac index 8fd04e887..fc2c49d70 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=5 MICRO_VERSION=3 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=15 +EXTRA_VERSION=16 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/plugins/pgpcore/Makefile.am b/src/plugins/pgpcore/Makefile.am index 83dcf6b6c..d5dfaf7de 100644 --- a/src/plugins/pgpcore/Makefile.am +++ b/src/plugins/pgpcore/Makefile.am @@ -50,14 +50,16 @@ pgpcore_la_SOURCES = \ plugin.c \ prefs_gpg.c \ select-keys.c \ - sgpgme.c + sgpgme.c \ + pgp_viewer.c pluginincludedir = $(pkgincludedir)/plugins/pgpcore plugininclude_HEADERS = \ passphrase.h \ prefs_gpg.h \ select-keys.h \ - sgpgme.h + sgpgme.h \ + pgp_viewer.h pgpcore_la_LDFLAGS = \ $(plugin_res_ldflag) $(no_undefined) $(export_symbols) \ diff --git a/src/plugins/pgpcore/plugin.c b/src/plugins/pgpcore/plugin.c index 8d2bcc4a6..84f8f8d59 100644 --- a/src/plugins/pgpcore/plugin.c +++ b/src/plugins/pgpcore/plugin.c @@ -29,6 +29,7 @@ #include "common/sylpheed.h" #include "sgpgme.h" #include "prefs_gpg.h" +#include "pgp_viewer.h" #include "plugin.h" gint plugin_init(gchar **error) @@ -46,11 +47,13 @@ gint plugin_init(gchar **error) sgpgme_init(); prefs_gpg_init(); sgpgme_check_create_key(); + pgp_viewer_init(); return 0; } void plugin_done(void) { + pgp_viewer_done(); prefs_gpg_done(); sgpgme_done(); } diff --git a/src/plugins/pgpcore/sgpgme.c b/src/plugins/pgpcore/sgpgme.c index b167a562c..40e2969a5 100644 --- a/src/plugins/pgpcore/sgpgme.c +++ b/src/plugins/pgpcore/sgpgme.c @@ -596,6 +596,11 @@ void sgpgme_create_secret_key(PrefsAccount *account, gboolean ask_create) if (account == NULL) account = account_get_default(); + if (account->address == NULL) { + alertpanel_error(_("You have to save the account's information with \"OK\" " + "before being able to generate a key pair.\n")); + return; + } if (ask_create) { val = alertpanel(_("No PGP key found"), _("Sylpheed-Claws did not find a secret PGP key, " @@ -694,9 +699,29 @@ again: gpgme_release(ctx); return; } else { - alertpanel_notice(_("Your new key pair has been generated. " - "Its fingerprint is:\n%s"), + gchar *buf = g_strdup_printf(_("Your new key pair has been generated. " + "Its fingerprint is:\n%s\n\nDo you want to export it " + "to a keyserver?"), key->fpr ? key->fpr:"null"); + AlertValue val = alertpanel(_("Key generated"), buf, + GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL); + g_free(buf); + if (val == G_ALERTALTERNATE) { +#ifndef G_OS_WIN32 + gchar *cmd = g_strdup_printf("gpg --send-keys %s", key->fpr); + int res = 0; + GTK_EVENTS_FLUSH(); + res = system(cmd); + if (res == 0) { + alertpanel_notice(_("Key exported.")); + } else { + alertpanel_notice(_("Couldn't export key.")); + } + g_free(cmd); +#else + alertpanel_error(_("Key export isn't implemented in Windows.")); +#endif + } } prefs_gpg_get_config()->gpg_ask_create_key = FALSE; prefs_gpg_save_config(); diff --git a/src/textview.c b/src/textview.c index c252e3160..425db39bf 100644 --- a/src/textview.c +++ b/src/textview.c @@ -69,23 +69,6 @@ #include "inputdialog.h" #include "timing.h" -struct _ClickableText -{ - gchar *uri; - - gchar *filename; - - gpointer data; - - guint start; - guint end; - - gboolean is_quote; - gint quote_level; - gboolean q_expanded; - gchar *fg_color; -}; - gint previousquotelevel = -1; static GdkColor quote_colors[3] = { @@ -227,7 +210,6 @@ static void save_file_cb (TextView *textview, static void open_image_cb (TextView *textview, guint action, void *data); -static void textview_show_icon(TextView *textview, const gchar *stock_id); static GtkItemFactoryEntry textview_link_popup_entries[] = { @@ -603,27 +585,6 @@ void textview_show_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp) END_TIMING(); } -#define TEXT_INSERT(str) \ - gtk_text_buffer_insert_with_tags_by_name \ - (buffer, &iter, str, -1,\ - "header", NULL) - -#define TEXT_INSERT_LINK(str, fname, udata) { \ - ClickableText *uri; \ - uri = g_new0(ClickableText, 1); \ - uri->uri = g_strdup(""); \ - uri->start = gtk_text_iter_get_offset(&iter); \ - gtk_text_buffer_insert_with_tags_by_name \ - (buffer, &iter, str, -1, \ - "link", "header_title", "header", \ - NULL); \ - uri->end = gtk_text_iter_get_offset(&iter); \ - uri->filename = fname?g_strdup(fname):NULL; \ - uri->data = udata; \ - textview->uri_list = \ - g_slist_prepend(textview->uri_list, uri); \ -} - static void textview_add_part(TextView *textview, MimeInfo *mimeinfo) { GtkTextView *text; @@ -685,7 +646,7 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo) || (mimeinfo->disposition == DISPOSITIONTYPE_INLINE && mimeinfo->type != MIMETYPE_TEXT)) { gtk_text_buffer_insert(buffer, &iter, "\n", 1); - TEXT_INSERT_LINK(buf, "sc://select_attachment", mimeinfo); + TEXTVIEW_INSERT_LINK(buf, "sc://select_attachment", mimeinfo); gtk_text_buffer_insert(buffer, &iter, " \n", -1); if (mimeinfo->type == MIMETYPE_IMAGE && prefs_common.inline_img ) { @@ -845,13 +806,13 @@ void textview_show_error(TextView *textview) buffer = gtk_text_view_get_buffer(text); gtk_text_buffer_get_start_iter(buffer, &iter); - TEXT_INSERT(_("\n" + TEXTVIEW_INSERT(_("\n" " This message can't be displayed.\n" " This is probably due to a network error.\n" "\n" " Use ")); - TEXT_INSERT_LINK(_("'View Log'"), "sc://view_log", NULL); - TEXT_INSERT(_(" in the Tools menu for more information.")); + TEXTVIEW_INSERT_LINK(_("'View Log'"), "sc://view_log", NULL); + TEXTVIEW_INSERT(_(" in the Tools menu for more information.")); textview_show_icon(textview, GTK_STOCK_DIALOG_ERROR); } @@ -871,30 +832,27 @@ void textview_show_mime_part(TextView *textview, MimeInfo *partinfo) buffer = gtk_text_view_get_buffer(text); gtk_text_buffer_get_start_iter(buffer, &iter); - TEXT_INSERT("\n"); - TEXT_INSERT(_(" The following can be performed on this part by\n")); - TEXT_INSERT(_(" right-clicking the icon or list item:\n")); - - TEXT_INSERT(_(" - To save, select ")); - TEXT_INSERT_LINK(_("'Save as...'"), "sc://save_as", NULL); - TEXT_INSERT(_(" (Shortcut key: 'y')\n")); - TEXT_INSERT(_(" - To display as text, select ")); - TEXT_INSERT_LINK(_("'Display as text'"), "sc://display_as_text", NULL); - TEXT_INSERT(_(" (Shortcut key: 't')\n")); - TEXT_INSERT(_(" - To open with an external program, select ")); - TEXT_INSERT_LINK(_("'Open'"), "sc://open", NULL); - TEXT_INSERT(_(" (Shortcut key: 'l')\n")); - TEXT_INSERT(_(" (alternately double-click, or click the middle ")); - TEXT_INSERT(_("mouse button)\n")); - TEXT_INSERT(_(" - Or use ")); - TEXT_INSERT_LINK(_("'Open with...'"), "sc://open_with", NULL); - TEXT_INSERT(_(" (Shortcut key: 'o')\n")); + TEXTVIEW_INSERT("\n"); + TEXTVIEW_INSERT(_(" The following can be performed on this part by\n")); + TEXTVIEW_INSERT(_(" right-clicking the icon or list item:\n")); + + TEXTVIEW_INSERT(_(" - To save, select ")); + TEXTVIEW_INSERT_LINK(_("'Save as...'"), "sc://save_as", NULL); + TEXTVIEW_INSERT(_(" (Shortcut key: 'y')\n")); + TEXTVIEW_INSERT(_(" - To display as text, select ")); + TEXTVIEW_INSERT_LINK(_("'Display as text'"), "sc://display_as_text", NULL); + TEXTVIEW_INSERT(_(" (Shortcut key: 't')\n")); + TEXTVIEW_INSERT(_(" - To open with an external program, select ")); + TEXTVIEW_INSERT_LINK(_("'Open'"), "sc://open", NULL); + TEXTVIEW_INSERT(_(" (Shortcut key: 'l')\n")); + TEXTVIEW_INSERT(_(" (alternately double-click, or click the middle ")); + TEXTVIEW_INSERT(_("mouse button)\n")); + TEXTVIEW_INSERT(_(" - Or use ")); + TEXTVIEW_INSERT_LINK(_("'Open with...'"), "sc://open_with", NULL); + TEXTVIEW_INSERT(_(" (Shortcut key: 'o')\n")); textview_show_icon(textview, GTK_STOCK_DIALOG_INFO); } -#undef TEXT_INSERT -#undef TEXT_INSERT_LINK - static void textview_write_body(TextView *textview, MimeInfo *mimeinfo) { FILE *tmpfp; @@ -1797,7 +1755,7 @@ bail: textview->image = NULL; } -static void textview_show_icon(TextView *textview, const gchar *stock_id) +void textview_show_icon(TextView *textview, const gchar *stock_id) { GtkTextView *text = GTK_TEXT_VIEW(textview->text); int x = 0; diff --git a/src/textview.h b/src/textview.h index b23edc838..e5fe0d311 100644 --- a/src/textview.h +++ b/src/textview.h @@ -30,6 +30,23 @@ typedef struct _TextView TextView; typedef struct _ClickableText ClickableText; +struct _ClickableText +{ + gchar *uri; + + gchar *filename; + + gpointer data; + + guint start; + guint end; + + gboolean is_quote; + gint quote_level; + gboolean q_expanded; + gchar *fg_color; +}; + #include "messageview.h" #include "procmime.h" @@ -102,5 +119,27 @@ gboolean textview_search_string_backward (TextView *textview, gboolean case_sens); void textview_cursor_wait(TextView *textview); void textview_cursor_normal(TextView *textview); +void textview_show_icon(TextView *textview, const gchar *stock_id); + +#define TEXTVIEW_INSERT(str) \ + gtk_text_buffer_insert_with_tags_by_name \ + (buffer, &iter, str, -1,\ + "header", NULL) + +#define TEXTVIEW_INSERT_LINK(str, fname, udata) { \ + ClickableText *uri; \ + uri = g_new0(ClickableText, 1); \ + uri->uri = g_strdup(""); \ + uri->start = gtk_text_iter_get_offset(&iter); \ + gtk_text_buffer_insert_with_tags_by_name \ + (buffer, &iter, str, -1, \ + "link", "header_title", "header", \ + NULL); \ + uri->end = gtk_text_iter_get_offset(&iter); \ + uri->filename = fname?g_strdup(fname):NULL; \ + uri->data = udata; \ + textview->uri_list = \ + g_slist_prepend(textview->uri_list, uri); \ +} #endif /* __TEXTVIEW_H__ */