2006-10-07 [colin] 2.5.3cvs16
authorColin Leroy <colin@colino.net>
Sat, 7 Oct 2006 17:45:59 +0000 (17:45 +0000)
committerColin Leroy <colin@colino.net>
Sat, 7 Oct 2006 17:45:59 +0000 (17:45 +0000)
* 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

ChangeLog
PATCHSETS
configure.ac
src/plugins/pgpcore/Makefile.am
src/plugins/pgpcore/plugin.c
src/plugins/pgpcore/sgpgme.c
src/textview.c
src/textview.h

index e8e29c8ad4734c9fd494af4548f2d9d185d26523..ec43fbb62558b23a653053f720233e872b9bbbc1 100644 (file)
--- 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
index edc31f597fd9b4f907e047c27ca214afb4eb235e..c44397930b395cb4e01cb8bfc6d15fe0d2ab83e6 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( 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
index 8fd04e88766985cdecaad180b9f0dbcc2cc5fee9..fc2c49d70fc5072cfcaddcc562a4b1ac94e1794f 100644 (file)
@@ -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=
 
index 83dcf6b6c7c94bbb0ac3d3514e7bb987b8e02485..d5dfaf7de7621c305624c141260bba55317da200 100644 (file)
@@ -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) \
index 8d2bcc4a6a95dcfbac6018e74b0d1730b568db49..84f8f8d59c32523df51e5a8de81b6d1a34a973ed 100644 (file)
@@ -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();
 }
index b167a562cf62839055ac9b8b68dd18ed6eb541e4..40e2969a55e677f8d254ce2c85ea6ece89159ddf 100644 (file)
@@ -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();
index c252e3160f71824636dc880992a0b1d5af59229c..425db39bf914448b6a90d041d1a44cb86f12153c 100644 (file)
 #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;
index b23edc838cd171366f456fefa0d566881c37b98b..e5fe0d3113fc8892f20a563c1449584b34036632 100644 (file)
 
 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__ */