2004-11-23 [christoph] 0.9.12cvs164
authorChristoph Hohmann <reboot@gmx.ch>
Tue, 23 Nov 2004 13:49:58 +0000 (13:49 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Tue, 23 Nov 2004 13:49:58 +0000 (13:49 +0000)
* src/common/Makefile.am
* src/common/partial_download.[ch]
* src/Makefile.am
* src/partial_download.[ch]
* src/folderview.c
move to src because it depends on src stuff

* src/codeconv.c
* src/common/base64.h
move B64LEN macro to base64.h

* src/compose.c
* src/privacy.[ch]
add PrefsAccount to sign-function parameters

* src/main.c
* src/prefs_account.[ch]
* src/gtk/prefswindow.[ch]
o use new prefswindow for account prefs
o add possibility to add new pages to account prefs

* src/plugins/pgpmime/prefs_gpg.[ch]
* src/plugins/pgpmime/prefs_gpg.glade
add account prefs for GPG

* src/plugins/pgpmime/pgpmime.c
* src/plugins/pgpmime/sgpgme.[ch]
create signers list based on the GPG account prefs

24 files changed:
ChangeLog.claws
PATCHSETS
configure.ac
src/Makefile.am
src/codeconv.c
src/common/Makefile.am
src/common/base64.h
src/compose.c
src/folderview.c
src/gtk/prefswindow.c
src/gtk/prefswindow.h
src/main.c
src/partial_download.c [moved from src/common/partial_download.c with 100% similarity]
src/partial_download.h [moved from src/common/partial_download.h with 100% similarity]
src/plugins/pgpmime/pgpmime.c
src/plugins/pgpmime/prefs_gpg.c
src/plugins/pgpmime/prefs_gpg.glade
src/plugins/pgpmime/prefs_gpg.h
src/plugins/pgpmime/sgpgme.c
src/plugins/pgpmime/sgpgme.h
src/prefs_account.c
src/prefs_account.h
src/privacy.c
src/privacy.h

index 421629b..cd65d8a 100644 (file)
@@ -1,3 +1,34 @@
+2004-11-23 [christoph] 0.9.12cvs164
+
+       * src/common/Makefile.am
+       * src/common/partial_download.[ch]
+       * src/Makefile.am
+       * src/partial_download.[ch]
+       * src/folderview.c
+               move to src because it depends on src stuff
+
+       * src/codeconv.c
+       * src/common/base64.h
+               move B64LEN macro to base64.h
+
+       * src/compose.c
+       * src/privacy.[ch]
+               add PrefsAccount to sign-function parameters
+
+       * src/main.c
+       * src/prefs_account.[ch]
+       * src/gtk/prefswindow.[ch]
+               o use new prefswindow for account prefs
+               o add possibility to add new pages to account prefs
+
+       * src/plugins/pgpmime/prefs_gpg.[ch]
+       * src/plugins/pgpmime/prefs_gpg.glade
+               add account prefs for GPG
+
+       * src/plugins/pgpmime/pgpmime.c
+       * src/plugins/pgpmime/sgpgme.[ch]
+               create signers list based on the GPG account prefs
+
 2004-11-23 [colin]     0.9.12cvs163
 
        * src/main.c
index efa9b96..7092883 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.6 -r 1.7 src/gtk/gtkstext.c; ) > 0.9.12cvs161.patchset
 ( cvs diff -u -r 1.27 -r 1.28 src/msgcache.c; ) > 0.9.12cvs162.patchset
 ( cvs diff -u -r 1.148 -r 1.149 src/main.c; ) > 0.9.12cvs163.patchset
+( cvs diff -u -r 1.188 -r 1.189 src/Makefile.am; cvs diff -u -r 1.73 -r 1.74 src/codeconv.c; cvs diff -u -r 1.457 -r 1.458 src/compose.c; cvs diff -u -r 1.251 -r 1.252 src/folderview.c; cvs diff -u -r 1.149 -r 1.150 src/main.c; cvs diff -u -r 0 -r 1 src/partial_download.c; cvs diff -u -r 0 -r 1 src/partial_download.h; cvs diff -u -r 1.121 -r 1.122 src/prefs_account.c; cvs diff -u -r 1.56 -r 1.57 src/prefs_account.h; cvs diff -u -r 1.12 -r 1.13 src/privacy.c; cvs diff -u -r 1.11 -r 1.12 src/privacy.h; cvs diff -u -r 1.28 -r 1.29 src/common/Makefile.am; cvs diff -u -r 1.1 -r 1.2 src/common/base64.h; cvs diff -u -r -1.5 -r -1.6 src/common/partial_download.c; cvs diff -u -r -1.2 -r -1.3 src/common/partial_download.h; cvs diff -u -r 1.15 -r 1.16 src/gtk/prefswindow.c; cvs diff -u -r 1.8 -r 1.9 src/gtk/prefswindow.h; cvs diff -u -r 1.11 -r 1.12 src/plugins/pgpmime/pgpmime.c; cvs diff -u -r 1.2 -r 1.3 src/plugins/pgpmime/prefs_gpg.c; cvs diff -u -r 1.1 -r 1.2 src/plugins/pgpmime/prefs_gpg.glade; cvs diff -u -r 1.2 -r 1.3 src/plugins/pgpmime/prefs_gpg.h; cvs diff -u -r 1.5 -r 1.6 src/plugins/pgpmime/sgpgme.c; cvs diff -u -r 1.3 -r 1.4 src/plugins/pgpmime/sgpgme.h; ) > 0.9.12cvs164.patchset
index 14f76b5..32147f9 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=163
+EXTRA_VERSION=164
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index 555b82e..35d2628 100644 (file)
@@ -78,6 +78,7 @@ sylpheed_SOURCES = \
        news.c \
        news_gtk.c \
        noticeview.c \
+       partial_download.c \
        pine.c \
        pop.c \
        prefs_account.c \
@@ -204,6 +205,7 @@ sylpheedinclude_HEADERS = \
        news.h \
        news_gtk.h \
        noticeview.h \
+       partial_download.h \
        pine.h \
        pop.h \
        prefs_account.h \
index a54cc17..baba8b4 100644 (file)
@@ -1500,8 +1500,6 @@ void conv_unmime_header(gchar *outbuf, gint outlen, const gchar *str,
 #define MIMESEP_BEGIN          "=?"
 #define MIMESEP_END            "?="
 
-#define B64LEN(len)    ((len) / 3 * 4 + ((len) % 3 ? 4 : 0))
-
 #define LBREAK_IF_REQUIRED(cond, is_plain_text)                                \
 {                                                                      \
        if (len - (destp - (guchar *)dest) < MAX_LINELEN + 2) {         \
index 759273c..b8c93f4 100644 (file)
@@ -7,7 +7,6 @@ libsylpheedcommon_la_SOURCES = \
        md5.c \
        mgutils.c \
        nntp.c \
-       partial_download.c \
        passcrypt.c \
        plugin.c \
        prefs.c \
@@ -37,7 +36,6 @@ sylpheedcommoninclude_HEADERS = \
        md5.h \
        mgutils.h \
        nntp.h \
-       partial_download.h \
        passcrypt.h \
        plugin.h \
        prefs.h \
index 4aa5575..5152e0a 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <glib.h>
 
+#define B64LEN(len)    ((len) / 3 * 4 + ((len) % 3 ? 4 : 0))
+
 typedef struct _Base64Decoder  Base64Decoder;
 
 struct _Base64Decoder
index 48dfd62..514fda3 100644 (file)
@@ -3456,7 +3456,7 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action)
        /* sign message if sending */
        if (action == COMPOSE_WRITE_FOR_SEND && compose->use_signing && 
            privacy_system_can_sign(compose->privacy_system))
-               if (!privacy_sign(compose->privacy_system, mimemsg))
+               if (!privacy_sign(compose->privacy_system, mimemsg, compose->account))
                        return -1;
 
        procmime_write_mimeinfo(mimemsg, fp);
index 338f768..217ce54 100644 (file)
@@ -62,7 +62,7 @@
 #include "statusbar.h"
 #include "hooks.h"
 #include "folderutils.h"
-#include "common/partial_download.h"
+#include "partial_download.h"
 
 typedef enum
 {
index 7680fff..d36b560 100644 (file)
@@ -50,8 +50,9 @@ struct _PrefsWindow
 
        GtkWidget *empty_page;
 
-       gpointer   data;
-       GSList    *prefs_pages;
+       gpointer          data;
+       GSList           *prefs_pages;
+       GtkDestroyNotify  func;
 };
 
 struct _PrefsTreeNode
@@ -135,25 +136,24 @@ static void apply_button_released(GtkButton *button, gpointer user_data)
        save_all_pages(prefswindow->prefs_pages);
 }
 
-static void ok_button_released(GtkButton *button, gpointer user_data)
+static void close_prefs_window(PrefsWindow *prefswindow)
 {
-       PrefsWindow *prefswindow = (PrefsWindow *) user_data;
+       debug_print("prefs window closed\n");
 
-       save_all_pages(prefswindow->prefs_pages);
        close_all_pages(prefswindow->prefs_pages);
        gtk_widget_destroy(prefswindow->window);
        g_slist_free(prefswindow->prefs_pages);
+       if (prefswindow->func != NULL)
+               prefswindow->func(prefswindow->data);
        g_free(prefswindow);
 }
 
-static void close_prefs_window(PrefsWindow *prefswindow)
+static void ok_button_released(GtkButton *button, gpointer user_data)
 {
-       debug_print("prefs window closed\n");
+       PrefsWindow *prefswindow = (PrefsWindow *) user_data;
 
-       close_all_pages(prefswindow->prefs_pages);
-       gtk_widget_destroy(prefswindow->window);
-       g_slist_free(prefswindow->prefs_pages);
-       g_free(prefswindow);
+       save_all_pages(prefswindow->prefs_pages);
+       close_prefs_window(prefswindow);
 }
 
 static void cancel_button_released(GtkButton *button, gpointer user_data)
@@ -204,9 +204,9 @@ gint compare_func(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
                                                                  0;
 }
 
-void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data)
+void prefswindow_open_full(const gchar *title, GSList *prefs_pages, gpointer data, GtkDestroyNotify func)
 {
-       static gchar *titles [1];
+       static gchar *titles[1];
        GSList *cur;
        gint optsize;
        PrefsWindow *prefswindow;
@@ -216,6 +216,7 @@ void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data)
        prefswindow = g_new0(PrefsWindow, 1);
 
        prefswindow->data = data;
+       prefswindow->func = func;
        prefswindow->prefs_pages = g_slist_copy(prefs_pages);
 
        prefswindow->window = gtk_window_new(GTK_WINDOW_DIALOG);
@@ -227,38 +228,47 @@ void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data)
        gtk_container_set_border_width(GTK_CONTAINER(prefswindow->window), 4);
 
        prefswindow->table1 = gtk_table_new(2, 2, FALSE);
+       gtk_widget_show(prefswindow->table1);
        gtk_container_add(GTK_CONTAINER(prefswindow->window), prefswindow->table1);
 
        prefswindow->scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
+       gtk_widget_show(prefswindow->scrolledwindow1);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(prefswindow->scrolledwindow1), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
        gtk_table_attach(GTK_TABLE(prefswindow->table1), prefswindow->scrolledwindow1, 0, 1, 0, 1, GTK_FILL, GTK_FILL | GTK_EXPAND, 2, 2);
 
        prefswindow->ctree = gtk_ctree_new_with_titles(1, 0, titles);
+       gtk_widget_show(prefswindow->ctree);
        gtk_container_add(GTK_CONTAINER(prefswindow->scrolledwindow1), prefswindow->ctree);
 
        prefswindow->frame = gtk_frame_new(NULL);
+       gtk_widget_show(prefswindow->frame);
        gtk_frame_set_shadow_type(GTK_FRAME(prefswindow->frame), GTK_SHADOW_IN);
        gtk_table_attach(GTK_TABLE(prefswindow->table1), prefswindow->frame, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 2, 2);
 
        prefswindow->table2 = gtk_table_new(1, 2, FALSE);
+       gtk_widget_show(prefswindow->table2);
        gtk_container_add(GTK_CONTAINER(prefswindow->frame), prefswindow->table2);
 
        prefswindow->labelframe = gtk_frame_new(NULL);
+       gtk_widget_show(prefswindow->labelframe);
        gtk_frame_set_shadow_type(GTK_FRAME(prefswindow->labelframe), GTK_SHADOW_OUT);
        gtk_table_attach(GTK_TABLE(prefswindow->table2), prefswindow->labelframe, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 1, 1);
 
        prefswindow->pagelabel = gtk_label_new("");
+       gtk_widget_show(prefswindow->pagelabel);
        gtk_label_set_justify(GTK_LABEL(prefswindow->pagelabel), GTK_JUSTIFY_LEFT);
        gtk_misc_set_alignment(GTK_MISC(prefswindow->pagelabel), 0, 0.0);
        gtk_container_add(GTK_CONTAINER(prefswindow->labelframe), prefswindow->pagelabel);
 
        prefswindow->notebook = gtk_notebook_new();
+       gtk_widget_show(prefswindow->notebook);
        gtk_notebook_set_scrollable(GTK_NOTEBOOK(prefswindow->notebook), TRUE);
        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(prefswindow->notebook), FALSE);
        gtk_notebook_set_show_border(GTK_NOTEBOOK(prefswindow->notebook), FALSE);
        gtk_table_attach(GTK_TABLE(prefswindow->table2), prefswindow->notebook, 0, 1, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 8, 8);
 
        prefswindow->empty_page = gtk_label_new("");
+       gtk_widget_show(prefswindow->empty_page);
        gtk_container_add(GTK_CONTAINER(prefswindow->notebook), prefswindow->empty_page);
 
        /* actually we should create a tree here */
@@ -316,6 +326,7 @@ void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data)
                                &prefswindow->ok_btn,           _("OK"),
                                &prefswindow->cancel_btn,       _("Cancel"),
                                &prefswindow->apply_btn,        _("Apply"));
+       gtk_widget_show_all(prefswindow->confirm_area);
 
        gtk_table_attach(GTK_TABLE(prefswindow->table1), prefswindow->confirm_area, 0, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 2, 2);
 
@@ -324,5 +335,10 @@ void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data)
        gtk_signal_connect(GTK_OBJECT(prefswindow->apply_btn), "released", GTK_SIGNAL_FUNC(apply_button_released), prefswindow);
        gtk_signal_connect(GTK_OBJECT(prefswindow->window), "delete_event", GTK_SIGNAL_FUNC(window_closed), prefswindow);
 
-       gtk_widget_show_all(prefswindow->window);
+       gtk_widget_show(prefswindow->window);
 }
+
+void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data)
+{
+       prefswindow_open_full(title, prefs_pages, data, NULL);
+}
\ No newline at end of file
index 016f4fb..b3122ab 100644 (file)
@@ -41,6 +41,10 @@ struct _PrefsPage
        PrefsSavePageFunc         save_page;
 };
 
+void prefswindow_open_full             (const gchar *title, 
+                                        GSList *prefs_pages,
+                                        gpointer data,
+                                        GtkDestroyNotify func);
 void prefswindow_open                  (const gchar *title, 
                                         GSList *prefs_pages,
                                         gpointer data);
index 27a6146..f32c84a 100644 (file)
@@ -343,6 +343,7 @@ int main(int argc, char *argv[])
                                        lock_socket_input_cb,
                                        mainwin);
 
+       prefs_account_init();
        account_read_config_all();
 
        if (folder_read_list() < 0) {
index 87cf209..ad59130 100644 (file)
@@ -402,7 +402,7 @@ extract_micalg (char *xml)
     return NULL;
 }
 
-gboolean pgpmime_sign(MimeInfo *mimeinfo)
+gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account)
 {
        MimeInfo *msgcontent, *sigmultipart, *newinfo;
        gchar *textstr, *opinfo, *micalg;
@@ -412,7 +412,7 @@ gboolean pgpmime_sign(MimeInfo *mimeinfo)
        GpgmeData gpgtext, gpgsig;
        guint len;
        struct passphrase_cb_info_s info;
-  
+
        memset (&info, 0, sizeof info);
 
        /* remove content node from message */
@@ -446,7 +446,9 @@ gboolean pgpmime_sign(MimeInfo *mimeinfo)
        gpgme_new(&ctx);
        gpgme_set_textmode(ctx, 1);
        gpgme_set_armor(ctx, 1);
-       gpgme_signers_clear(ctx);
+
+       if (!sgpgme_setup_signers(ctx, account))
+               return FALSE;
 
        if (!getenv("GPG_AGENT_INFO")) {
                info.c = ctx;
index 351c803..aa326ff 100644 (file)
@@ -223,6 +223,178 @@ static void prefs_gpg_save_func(PrefsPage *_page)
        prefs_gpg_save_config();
 }
 
+struct GPGAccountPage
+{
+       PrefsPage page;
+
+       GtkWidget *key_default;
+       GtkWidget *key_by_from;
+       GtkWidget *key_custom;
+       GtkWidget *keyid;
+
+       PrefsAccount *account;
+};
+
+void key_custom_toggled(GtkToggleButton *togglebutton, gpointer user_data)
+{
+       struct GPGAccountPage *page = (struct GPGAccountPage *) user_data;
+       gboolean active;
+
+       active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->key_custom));
+       gtk_widget_set_sensitive(GTK_WIDGET(page->keyid), active);
+       if (!active)
+               gtk_editable_delete_text(GTK_EDITABLE(page->keyid), 0, -1);
+}
+
+static void prefs_gpg_account_create_widget_func(PrefsPage *_page,
+                                                GtkWindow *window,
+                                                gpointer data)
+{
+       struct GPGAccountPage *page = (struct GPGAccountPage *) _page;
+       PrefsAccount *account = (PrefsAccount *) data;
+       GPGAccountConfig *config;
+
+       /*** BEGIN GLADE CODE ***/
+       GtkWidget *vbox;
+       GtkWidget *frame1;
+       GtkWidget *table1;
+       GSList *key_group = NULL;
+       GtkWidget *key_default;
+       GtkWidget *key_by_from;
+       GtkWidget *key_custom;
+       GtkWidget *label13;
+       GtkWidget *label14;
+       GtkWidget *label15;
+       GtkWidget *label16;
+       GtkWidget *keyid;
+
+       vbox = gtk_vbox_new(FALSE, 0);
+       gtk_widget_show(vbox);
+
+       frame1 = gtk_frame_new(_("Sign key"));
+       gtk_widget_show(frame1);
+       gtk_box_pack_start(GTK_BOX(vbox), frame1, FALSE, FALSE, 0);
+       gtk_frame_set_label_align(GTK_FRAME(frame1), 4.84288e-08, 0.5);
+
+       table1 = gtk_table_new(4, 3, FALSE);
+       gtk_widget_show(table1);
+       gtk_container_add(GTK_CONTAINER(frame1), table1);
+       gtk_container_set_border_width(GTK_CONTAINER(table1), 8);
+       gtk_table_set_row_spacings(GTK_TABLE(table1), 4);
+       gtk_table_set_col_spacings(GTK_TABLE(table1), 4);
+
+       key_default = gtk_radio_button_new_with_label(key_group, "");
+       key_group = gtk_radio_button_group(GTK_RADIO_BUTTON(key_default));
+       gtk_widget_show(key_default);
+       gtk_table_attach(GTK_TABLE(table1), key_default, 0, 1, 0, 1,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+
+       key_by_from = gtk_radio_button_new_with_label(key_group, "");
+       key_group = gtk_radio_button_group(GTK_RADIO_BUTTON(key_by_from));
+       gtk_widget_show(key_by_from);
+       gtk_table_attach(GTK_TABLE(table1), key_by_from, 0, 1, 1, 2,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+
+       key_custom = gtk_radio_button_new_with_label(key_group, "");
+       key_group = gtk_radio_button_group(GTK_RADIO_BUTTON(key_custom));
+       gtk_widget_show(key_custom);
+       gtk_table_attach(GTK_TABLE(table1), key_custom, 0, 1, 2, 3,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+
+       label13 = gtk_label_new(_("Use default GnuPG key"));
+       gtk_widget_show(label13);
+       gtk_table_attach(GTK_TABLE(table1), label13, 1, 3, 0, 1,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       gtk_misc_set_alignment(GTK_MISC(label13), 0, 0.5);
+
+       label14 = gtk_label_new(_("Select key by your email address"));
+       gtk_widget_show(label14);
+       gtk_table_attach(GTK_TABLE(table1), label14, 1, 3, 1, 2,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       gtk_misc_set_alignment(GTK_MISC(label14), 0, 0.5);
+
+       label15 = gtk_label_new(_("Specify key manually"));
+       gtk_widget_show(label15);
+       gtk_table_attach(GTK_TABLE(table1), label15, 1, 3, 2, 3,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       gtk_misc_set_alignment(GTK_MISC(label15), 0, 0.5);
+
+       label16 = gtk_label_new(_("User or key ID:"));
+       gtk_widget_show(label16);
+       gtk_table_attach(GTK_TABLE(table1), label16, 1, 2, 3, 4,
+                        (GtkAttachOptions) (GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       gtk_label_set_justify(GTK_LABEL(label16), GTK_JUSTIFY_LEFT);
+
+       keyid = gtk_entry_new();
+       gtk_widget_show(keyid);
+       gtk_table_attach(GTK_TABLE(table1), keyid, 2, 3, 3, 4,
+                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                        (GtkAttachOptions) (0), 0, 0);
+       /*** END GLADE CODE ***/
+
+       config = prefs_gpg_account_get_config(account);
+       switch (config->sign_key) {
+       case SIGN_KEY_DEFAULT:
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(key_default), TRUE);
+               gtk_widget_set_sensitive(GTK_WIDGET(keyid), FALSE);
+               break;
+       case SIGN_KEY_BY_FROM:
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(key_by_from), TRUE);
+               gtk_widget_set_sensitive(GTK_WIDGET(keyid), FALSE);
+               break;
+       case SIGN_KEY_CUSTOM:
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(key_custom), TRUE);
+               gtk_widget_set_sensitive(GTK_WIDGET(keyid), TRUE);
+               break;
+       }
+
+       if (config->sign_key_id != NULL)
+               gtk_entry_set_text(GTK_ENTRY(keyid), config->sign_key_id);
+
+       gtk_signal_connect(GTK_OBJECT(key_custom), "toggled", GTK_SIGNAL_FUNC(key_custom_toggled), page);
+
+       page->key_default = key_default;
+       page->key_by_from = key_by_from;
+       page->key_custom = key_custom;
+       page->keyid = keyid;
+
+       page->page.widget = vbox;
+       page->account = account;
+}
+
+static void prefs_gpg_account_destroy_widget_func(PrefsPage *_page)
+{
+       /* nothing to do here */
+}
+
+static void prefs_gpg_account_save_func(PrefsPage *_page)
+{
+       struct GPGAccountPage *page = (struct GPGAccountPage *) _page;
+       GPGAccountConfig *config;
+
+       config = prefs_gpg_account_get_config(page->account);
+
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->key_default)))
+               config->sign_key = SIGN_KEY_DEFAULT;
+       else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->key_by_from)))
+               config->sign_key = SIGN_KEY_BY_FROM;
+       else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->key_custom))) {
+               config->sign_key = SIGN_KEY_CUSTOM;
+               g_free(config->sign_key_id);
+               config->sign_key_id = gtk_editable_get_chars(GTK_EDITABLE(page->keyid), 0, -1);
+       }
+
+       prefs_gpg_account_set_config(page->account, config);
+       prefs_gpg_account_free_config(config);
+}
+
 GPGConfig *prefs_gpg_get_config(void)
 {
        return &prefs_gpg;
@@ -251,7 +423,68 @@ void prefs_gpg_save_config(void)
        prefs_file_close(pfile);
 }
 
+struct GPGAccountConfig *prefs_gpg_account_get_config(PrefsAccount *account)
+{
+       GPGAccountConfig *config;
+       const gchar *confstr;
+       gchar **strv;
+
+       config = g_new0(GPGAccountConfig, 1);
+       config->sign_key = SIGN_KEY_DEFAULT;
+       config->sign_key_id = NULL;
+
+       confstr = prefs_account_get_privacy_prefs(account, "gpg");
+       if (confstr == NULL)
+               return config;
+
+       strv = g_strsplit(confstr, ";", 0);
+       if (strv[0] != NULL) {
+               if (!strcmp(strv[0], "DEFAULT"))
+                       config->sign_key = SIGN_KEY_DEFAULT;
+               if (!strcmp(strv[0], "BY_FROM"))
+                       config->sign_key = SIGN_KEY_BY_FROM;
+               if (!strcmp(strv[0], "CUSTOM")) {
+                       if (strv[1] != NULL) {
+                               config->sign_key = SIGN_KEY_CUSTOM;
+                               config->sign_key_id = g_strdup(strv[1]);
+                       } else
+                               config->sign_key = SIGN_KEY_DEFAULT;
+               }
+       }
+       g_strfreev(strv);
+
+       return config;
+}
+
+void prefs_gpg_account_set_config(PrefsAccount *account, GPGAccountConfig *config)
+{
+       gchar *confstr;
+
+       switch (config->sign_key) {
+       case SIGN_KEY_DEFAULT:
+               confstr = g_strdup("DEFAULT");
+               break;
+       case SIGN_KEY_BY_FROM:
+               confstr = g_strdup("BY_FROM");
+               break;
+       case SIGN_KEY_CUSTOM:
+               confstr = g_strdup_printf("CUSTOM;%s", config->sign_key_id);
+               break;
+       }
+
+       prefs_account_set_privacy_prefs(account, "gpg", confstr);
+
+       g_free(confstr);
+}
+
+void prefs_gpg_account_free_config(GPGAccountConfig *config)
+{
+       g_free(config->sign_key_id);
+       g_free(config);
+}
+
 static struct GPGPage gpg_page;
+static struct GPGAccountPage gpg_account_page;
 
 void prefs_gpg_init()
 {
@@ -271,6 +504,14 @@ void prefs_gpg_init()
         gpg_page.page.weight = 30.0;
 
         prefs_gtk_register_page((PrefsPage *) &gpg_page);
+
+        gpg_account_page.page.path = path;
+        gpg_account_page.page.create_widget = prefs_gpg_account_create_widget_func;
+        gpg_account_page.page.destroy_widget = prefs_gpg_account_destroy_widget_func;
+        gpg_account_page.page.save_page = prefs_gpg_account_save_func;
+        gpg_account_page.page.weight = 30.0;
+
+        prefs_account_register_page((PrefsPage *) &gpg_account_page);
 }
 
 void prefs_gpg_done()
index 54117c3..6d01bbf 100644 (file)
   </widget>
 </widget>
 
+<widget>
+  <class>GtkWindow</class>
+  <name>prefs_gpg_account</name>
+  <title>window1</title>
+  <type>GTK_WINDOW_TOPLEVEL</type>
+  <position>GTK_WIN_POS_NONE</position>
+  <modal>False</modal>
+  <allow_shrink>False</allow_shrink>
+  <allow_grow>True</allow_grow>
+  <auto_shrink>False</auto_shrink>
+
+  <widget>
+    <class>GtkVBox</class>
+    <name>vbox</name>
+    <homogeneous>False</homogeneous>
+    <spacing>0</spacing>
+
+    <widget>
+      <class>GtkFrame</class>
+      <name>frame1</name>
+      <label>Sign key</label>
+      <label_xalign>4.84288e-08</label_xalign>
+      <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
+      <child>
+       <padding>0</padding>
+       <expand>False</expand>
+       <fill>False</fill>
+      </child>
+
+      <widget>
+       <class>GtkTable</class>
+       <name>table1</name>
+       <border_width>8</border_width>
+       <rows>4</rows>
+       <columns>3</columns>
+       <homogeneous>False</homogeneous>
+       <row_spacing>4</row_spacing>
+       <column_spacing>4</column_spacing>
+
+       <widget>
+         <class>GtkRadioButton</class>
+         <name>key_default</name>
+         <can_focus>True</can_focus>
+         <label></label>
+         <active>False</active>
+         <draw_indicator>True</draw_indicator>
+         <group>key</group>
+         <child>
+           <left_attach>0</left_attach>
+           <right_attach>1</right_attach>
+           <top_attach>0</top_attach>
+           <bottom_attach>1</bottom_attach>
+           <xpad>0</xpad>
+           <ypad>0</ypad>
+           <xexpand>False</xexpand>
+           <yexpand>False</yexpand>
+           <xshrink>False</xshrink>
+           <yshrink>False</yshrink>
+           <xfill>True</xfill>
+           <yfill>False</yfill>
+         </child>
+       </widget>
+
+       <widget>
+         <class>GtkRadioButton</class>
+         <name>key_by_from</name>
+         <can_focus>True</can_focus>
+         <label></label>
+         <active>False</active>
+         <draw_indicator>True</draw_indicator>
+         <group>key</group>
+         <child>
+           <left_attach>0</left_attach>
+           <right_attach>1</right_attach>
+           <top_attach>1</top_attach>
+           <bottom_attach>2</bottom_attach>
+           <xpad>0</xpad>
+           <ypad>0</ypad>
+           <xexpand>False</xexpand>
+           <yexpand>False</yexpand>
+           <xshrink>False</xshrink>
+           <yshrink>False</yshrink>
+           <xfill>True</xfill>
+           <yfill>False</yfill>
+         </child>
+       </widget>
+
+       <widget>
+         <class>GtkRadioButton</class>
+         <name>key_custom</name>
+         <can_focus>True</can_focus>
+         <label></label>
+         <active>False</active>
+         <draw_indicator>True</draw_indicator>
+         <group>key</group>
+         <child>
+           <left_attach>0</left_attach>
+           <right_attach>1</right_attach>
+           <top_attach>2</top_attach>
+           <bottom_attach>3</bottom_attach>
+           <xpad>0</xpad>
+           <ypad>0</ypad>
+           <xexpand>False</xexpand>
+           <yexpand>False</yexpand>
+           <xshrink>False</xshrink>
+           <yshrink>False</yshrink>
+           <xfill>True</xfill>
+           <yfill>False</yfill>
+         </child>
+       </widget>
+
+       <widget>
+         <class>GtkLabel</class>
+         <name>label13</name>
+         <label>Use default GnuPG key</label>
+         <justify>GTK_JUSTIFY_CENTER</justify>
+         <wrap>False</wrap>
+         <xalign>0</xalign>
+         <yalign>0.5</yalign>
+         <xpad>0</xpad>
+         <ypad>0</ypad>
+         <child>
+           <left_attach>1</left_attach>
+           <right_attach>3</right_attach>
+           <top_attach>0</top_attach>
+           <bottom_attach>1</bottom_attach>
+           <xpad>0</xpad>
+           <ypad>0</ypad>
+           <xexpand>False</xexpand>
+           <yexpand>False</yexpand>
+           <xshrink>False</xshrink>
+           <yshrink>False</yshrink>
+           <xfill>True</xfill>
+           <yfill>False</yfill>
+         </child>
+       </widget>
+
+       <widget>
+         <class>GtkLabel</class>
+         <name>label14</name>
+         <label>Select key by your email address</label>
+         <justify>GTK_JUSTIFY_CENTER</justify>
+         <wrap>False</wrap>
+         <xalign>0</xalign>
+         <yalign>0.5</yalign>
+         <xpad>0</xpad>
+         <ypad>0</ypad>
+         <child>
+           <left_attach>1</left_attach>
+           <right_attach>3</right_attach>
+           <top_attach>1</top_attach>
+           <bottom_attach>2</bottom_attach>
+           <xpad>0</xpad>
+           <ypad>0</ypad>
+           <xexpand>False</xexpand>
+           <yexpand>False</yexpand>
+           <xshrink>False</xshrink>
+           <yshrink>False</yshrink>
+           <xfill>True</xfill>
+           <yfill>False</yfill>
+         </child>
+       </widget>
+
+       <widget>
+         <class>GtkLabel</class>
+         <name>label15</name>
+         <label>Specify key manually</label>
+         <justify>GTK_JUSTIFY_CENTER</justify>
+         <wrap>False</wrap>
+         <xalign>0</xalign>
+         <yalign>0.5</yalign>
+         <xpad>0</xpad>
+         <ypad>0</ypad>
+         <child>
+           <left_attach>1</left_attach>
+           <right_attach>3</right_attach>
+           <top_attach>2</top_attach>
+           <bottom_attach>3</bottom_attach>
+           <xpad>0</xpad>
+           <ypad>0</ypad>
+           <xexpand>False</xexpand>
+           <yexpand>False</yexpand>
+           <xshrink>False</xshrink>
+           <yshrink>False</yshrink>
+           <xfill>True</xfill>
+           <yfill>False</yfill>
+         </child>
+       </widget>
+
+       <widget>
+         <class>GtkLabel</class>
+         <name>label16</name>
+         <label>User or key ID:</label>
+         <justify>GTK_JUSTIFY_LEFT</justify>
+         <wrap>False</wrap>
+         <xalign>0.5</xalign>
+         <yalign>0.5</yalign>
+         <xpad>0</xpad>
+         <ypad>0</ypad>
+         <child>
+           <left_attach>1</left_attach>
+           <right_attach>2</right_attach>
+           <top_attach>3</top_attach>
+           <bottom_attach>4</bottom_attach>
+           <xpad>0</xpad>
+           <ypad>0</ypad>
+           <xexpand>False</xexpand>
+           <yexpand>False</yexpand>
+           <xshrink>False</xshrink>
+           <yshrink>False</yshrink>
+           <xfill>True</xfill>
+           <yfill>False</yfill>
+         </child>
+       </widget>
+
+       <widget>
+         <class>GtkEntry</class>
+         <name>keyid</name>
+         <can_focus>True</can_focus>
+         <editable>True</editable>
+         <text_visible>True</text_visible>
+         <text_max_length>0</text_max_length>
+         <text></text>
+         <child>
+           <left_attach>2</left_attach>
+           <right_attach>3</right_attach>
+           <top_attach>3</top_attach>
+           <bottom_attach>4</bottom_attach>
+           <xpad>0</xpad>
+           <ypad>0</ypad>
+           <xexpand>True</xexpand>
+           <yexpand>False</yexpand>
+           <xshrink>False</xshrink>
+           <yshrink>False</yshrink>
+           <xfill>True</xfill>
+           <yfill>False</yfill>
+         </child>
+       </widget>
+      </widget>
+    </widget>
+  </widget>
+</widget>
+
 </GTK-Interface>
index 2952e4a..c9ad350 100644 (file)
  */
 
 typedef struct GPGConfig GPGConfig;
+typedef struct GPGAccountConfig GPGAccountConfig;
+
+typedef enum {
+       SIGN_KEY_DEFAULT,
+       SIGN_KEY_BY_FROM,
+       SIGN_KEY_CUSTOM,
+} SignKeyType;
+
+#include "prefs_account.h"
 
 struct GPGConfig
 {
-       gboolean auto_check_signatures;
-       gboolean store_passphrase;
-       gint store_passphrase_timeout;
-       gboolean passphrase_grab;
-       gboolean gpg_warning;
+       gboolean         auto_check_signatures;
+       gboolean         store_passphrase;
+       gint             store_passphrase_timeout;
+       gboolean         passphrase_grab;
+       gboolean         gpg_warning;
+};
+
+struct GPGAccountConfig
+{
+       SignKeyType      sign_key;
+       gchar           *sign_key_id;
 };
 
 void prefs_gpg_init(void);
 void prefs_gpg_done(void);
 void prefs_gpg_save_config(void);
-struct GPGConfig *prefs_gpg_get_config();
+struct GPGConfig *prefs_gpg_get_config(void);
+struct GPGAccountConfig *prefs_gpg_account_get_config(PrefsAccount *account);
+void prefs_gpg_account_set_config(PrefsAccount *account, GPGAccountConfig *config);
+void prefs_gpg_account_free_config(GPGAccountConfig *config);
index 271a6ad..36abf8c 100644 (file)
@@ -303,6 +303,40 @@ gchar *sgpgme_get_encrypt_data(GSList *recp_names)
        return data;
 }
 
+gboolean sgpgme_setup_signers(GpgmeCtx ctx, PrefsAccount *account)
+{
+       GPGAccountConfig *config;
+
+       gpgme_signers_clear(ctx);
+
+       config = prefs_gpg_account_get_config(account);
+
+       if (config->sign_key != SIGN_KEY_DEFAULT) {
+               gchar *keyid;
+               GpgmeKey key;
+
+               if (config->sign_key == SIGN_KEY_BY_FROM)
+                       keyid = account->address;
+               else if (config->sign_key == SIGN_KEY_CUSTOM)
+                       keyid = config->sign_key_id;
+               else
+                       return FALSE;
+
+               gpgme_op_keylist_start(ctx, keyid, 1);
+               while (!gpgme_op_keylist_next(ctx, &key)) {
+                       debug_print("adding key: %s\n", 
+                               gpgme_key_get_string_attr(key, GPGME_ATTR_KEYID, NULL, 0));
+                       gpgme_signers_add(ctx, key);
+                       gpgme_key_release(key);
+               }
+               gpgme_op_keylist_end(ctx);
+       }
+
+       prefs_gpg_account_free_config(config);
+
+       return TRUE;
+}
+
 void sgpgme_init()
 {
        if (gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP) != 
index 70f86a2..4b30dc8 100644 (file)
@@ -41,5 +41,6 @@ GpgmeData sgpgme_data_from_mimeinfo   (MimeInfo *mimeinfo);
 GpgmeData sgpgme_decrypt_verify                (GpgmeData cipher, GpgmeSigStat *status,
                                         GpgmeCtx ctx);
 gchar *sgpgme_get_encrypt_data         (GSList *recp_names);
+gboolean sgpgme_setup_signers          (GpgmeCtx ctx, PrefsAccount *account);
 
 #endif /* SGPGME_H */
index 7d79172..e681363 100644 (file)
 #include "smtp.h"
 #include "imap.h"
 #include "remotefolder.h"
+#include "base64.h"
 
 static gboolean cancelled;
+static gboolean new_account;
 
 static PrefsAccount tmp_ac_prefs;
 
-static PrefsDialog dialog;
+static GtkWidget *notebook;
+
+static GSList *prefs_pages = NULL;
 
 static struct Basic {
        GtkWidget *acname_entry;
@@ -225,6 +229,8 @@ static void prefs_account_nntpauth_toggled(GtkToggleButton *button,
 static void prefs_account_mailcmd_toggled(GtkToggleButton *button,
                                          gpointer user_data);
 
+static gchar *privacy_prefs;
+
 static PrefParam param[] = {
        /* Basic */
        {"account_name", NULL, &tmp_ac_prefs.account_name, P_STRING,
@@ -413,6 +419,8 @@ static PrefParam param[] = {
        {"save_clear_text", "FALSE", &tmp_ac_prefs.save_encrypted_as_clear_text, P_BOOL,
         &privacy.save_clear_text_chkbtn,
         prefs_set_data_from_toggle, prefs_set_toggle},
+       {"privacy_prefs", "", &privacy_prefs, P_STRING,
+        NULL, NULL, NULL},
 
 #if USE_OPENSSL
        /* SSL */
@@ -554,6 +562,124 @@ static void prefs_account_ok                      (void);
 static gint prefs_account_apply                        (void);
 static void prefs_account_cancel               (void);
 
+typedef struct AccountPage
+{
+        PrefsPage page;
+        GtkWidget *vbox;
+} AccountPage;
+
+static AccountPage account_page;
+
+void update_privacy_system_menu() {
+       GtkWidget *menu;
+       GtkWidget *menuitem;
+       GSList *system_ids, *cur;
+
+       menu = gtk_menu_new();
+
+       menuitem = gtk_menu_item_new_with_label(_("None"));
+       gtk_widget_show(menuitem);
+       gtk_object_set_data(GTK_OBJECT(menuitem), "user_data", "");
+       gtk_menu_append(GTK_MENU(menu), menuitem);
+
+       system_ids = privacy_get_system_ids();
+       for (cur = system_ids; cur != NULL; cur = g_slist_next(cur)) {
+               gchar *id = (gchar *) cur->data;
+               const gchar *name;
+               
+               name = privacy_system_get_name(id);
+               menuitem = gtk_menu_item_new_with_label(name);
+               gtk_widget_show(menuitem);
+               gtk_object_set_data_full(GTK_OBJECT(menuitem), "user_data", id, g_free);
+               gtk_menu_append(GTK_MENU(menu), menuitem);
+       }
+
+       gtk_option_menu_set_menu(GTK_OPTION_MENU(privacy.default_privacy_system), menu);
+}
+
+static void create_widget_func(PrefsPage * _page,
+                                           GtkWindow * window,
+                                           gpointer data)
+{
+       AccountPage *page = (AccountPage *) _page;
+       PrefsAccount *ac_prefs = (PrefsAccount *) data;
+       GtkWidget *vbox;
+
+       vbox = gtk_vbox_new(FALSE, 6);
+       gtk_widget_show(vbox);
+
+       if (notebook == NULL)
+               prefs_account_create();
+       gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
+       gtk_notebook_set_page(GTK_NOTEBOOK(notebook), 0);
+
+       update_privacy_system_menu();
+
+       tmp_ac_prefs = *ac_prefs;
+
+       if (new_account) {
+               PrefsAccount *def_ac;
+               gchar *buf;
+
+               prefs_set_dialog_to_default(param);
+               buf = g_strdup_printf(_("Account%d"), ac_prefs->account_id);
+               gtk_entry_set_text(GTK_ENTRY(basic.acname_entry), buf);
+               g_free(buf);
+               def_ac = account_get_default();
+               if (def_ac) {
+                       gtk_entry_set_text(GTK_ENTRY(basic.name_entry),
+                                          def_ac->name ? def_ac->name : "");
+                       gtk_entry_set_text(GTK_ENTRY(basic.addr_entry),
+                                          def_ac->address ? def_ac->address : "");
+                       gtk_entry_set_text(GTK_ENTRY(basic.org_entry),
+                                          def_ac->organization ? def_ac->organization : "");
+               }
+               menu_set_sensitive_all
+                       (GTK_MENU_SHELL
+                               (gtk_option_menu_get_menu
+                                       (GTK_OPTION_MENU
+                                               (basic.protocol_optmenu))),
+                        TRUE);
+       } else
+               prefs_set_dialog(param);
+
+       pop_bfr_smtp_tm_set_sens (NULL, NULL);
+       
+       page->vbox = vbox;
+
+       page->page.widget = vbox;
+}
+
+static void destroy_widget_func(PrefsPage *_page)
+{
+       AccountPage *page = (AccountPage *) _page;
+
+       gtk_container_remove(GTK_CONTAINER (page->vbox), notebook);
+}
+
+static void save_func(PrefsPage * _page)
+{
+       if (prefs_account_apply() >= 0)
+               cancelled = FALSE;
+}
+
+void prefs_account_init()
+{
+        static gchar *path[2];
+
+        path[0] = _("Account");
+        path[2] = NULL;
+        
+        account_page.page.path = path;
+       account_page.page.weight = 1000.0;
+        account_page.page.create_widget = create_widget_func;
+        account_page.page.destroy_widget = destroy_widget_func;
+        account_page.page.save_page = save_func;
+
+        prefs_account_register_page((PrefsPage *) &account_page);
+}
+
 PrefsAccount *prefs_account_new(void)
 {
        PrefsAccount *ac_prefs;
@@ -564,6 +690,8 @@ PrefsAccount *prefs_account_new(void)
        *ac_prefs = tmp_ac_prefs;
        ac_prefs->account_id = prefs_account_get_new_id();
 
+       ac_prefs->privacy_prefs = g_hash_table_new(g_str_hash, g_str_equal);
+
        return ac_prefs;
 }
 
@@ -571,11 +699,14 @@ void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
 {
        const guchar *p = label;
        gint id;
+       gchar **strv, **cur;
 
        g_return_if_fail(ac_prefs != NULL);
        g_return_if_fail(label != NULL);
 
        memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
+       tmp_ac_prefs.privacy_prefs = ac_prefs->privacy_prefs;
+
        prefs_read_config(param, label, ACCOUNT_RC);
        *ac_prefs = tmp_ac_prefs;
        while (*p && !isdigit(*p)) p++;
@@ -589,9 +720,45 @@ void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
                ac_prefs->use_apop_auth = TRUE;
        }
 
+       if (privacy_prefs != NULL) {
+               strv = g_strsplit(privacy_prefs, ",", 0);
+               for (cur = strv; *cur != NULL; cur++) {
+                       gchar *encvalue, *value;
+
+                       encvalue = strchr(*cur, '=');
+                       if (encvalue == NULL)
+                               continue;
+                       encvalue[0] = '\0';
+                       encvalue++;
+
+                       value = g_malloc0(strlen(encvalue));
+                       if (base64_decode(value, encvalue, strlen(encvalue)) > 0)
+                               g_hash_table_insert(ac_prefs->privacy_prefs, g_strdup(*cur), g_strdup(value));
+                       g_free(value);
+               }
+               g_strfreev(strv);
+               g_free(privacy_prefs);
+               privacy_prefs = NULL;
+       }
+
        prefs_custom_header_read_config(ac_prefs);
 }
 
+static void create_privacy_prefs(gpointer key, gpointer _value, gpointer user_data)
+{
+       GString *str = (GString *) user_data;
+       gchar *encvalue;
+       gchar *value = (gchar *) _value;
+
+       if (str->len > 0)
+               g_string_append_c(str, ',');
+
+       encvalue = g_malloc0(B64LEN(strlen(value)) + 1);
+       base64_encode(encvalue, (gchar *) value, strlen(value));
+       g_string_sprintfa(str, "%s=%s", (gchar *) key, encvalue);
+       g_free(encvalue);
+}
+
 void prefs_account_write_config_all(GList *account_list)
 {
        GList *cur;
@@ -606,14 +773,28 @@ void prefs_account_write_config_all(GList *account_list)
        g_free(rcpath);
 
        for (cur = account_list; cur != NULL; cur = cur->next) {
+               GString *str;
+
                tmp_ac_prefs = *(PrefsAccount *)cur->data;
                if (fprintf(pfile->fp, "[Account: %d]\n",
-                           tmp_ac_prefs.account_id) <= 0 ||
-                   prefs_write_param(param, pfile->fp) < 0) {
+                           tmp_ac_prefs.account_id) <= 0)
+                       return;
+
+               str = g_string_sized_new(32);
+               g_hash_table_foreach(tmp_ac_prefs.privacy_prefs, create_privacy_prefs, str);
+               privacy_prefs = str->str;                   
+               g_string_free(str, FALSE);
+
+               if (prefs_write_param(param, pfile->fp) < 0) {
                        g_warning("failed to write configuration to file\n");
                        prefs_file_close_revert(pfile);
-                       return;
+                       g_free(privacy_prefs);
+                       privacy_prefs = NULL;
+                       return;
                }
+               g_free(privacy_prefs);
+               privacy_prefs = NULL;
+
                if (cur->next) {
                        if (fputc('\n', pfile->fp) == EOF) {
                                FILE_OP_ERROR(rcpath, "fputc");
@@ -627,14 +808,44 @@ void prefs_account_write_config_all(GList *account_list)
                g_warning("failed to write configuration to file\n");
 }
 
+static gboolean free_privacy_prefs(gpointer key, gpointer value, gpointer user_data)
+{
+       g_free(key);
+       g_free(value);
+
+       return TRUE;
+}
+
 void prefs_account_free(PrefsAccount *ac_prefs)
 {
        if (!ac_prefs) return;
 
+       g_hash_table_foreach_remove(ac_prefs->privacy_prefs, free_privacy_prefs, NULL);
+
        tmp_ac_prefs = *ac_prefs;
        prefs_free(param);
 }
 
+const gchar *prefs_account_get_privacy_prefs(PrefsAccount *account, gchar *id)
+{
+       return g_hash_table_lookup(account->privacy_prefs, id);
+}
+
+void prefs_account_set_privacy_prefs(PrefsAccount *account, gchar *id, gchar *new_value)
+{
+       gchar *orig_key = NULL, *value;
+
+       if (g_hash_table_lookup_extended(account->privacy_prefs, id, (gpointer *) &orig_key, (gpointer *) &value)) {
+               g_hash_table_remove(account->privacy_prefs, id);
+
+               g_free(orig_key);
+               g_free(value);
+       }
+
+       if (new_value != NULL)
+               g_hash_table_insert(account->privacy_prefs, g_strdup(id), g_strdup(new_value));
+}
+
 static gint prefs_account_get_new_id(void)
 {
        GList *ac_list;
@@ -651,36 +862,19 @@ static gint prefs_account_get_new_id(void)
        return last_id + 1;
 }
 
-void update_privacy_system_menu() {
-       GtkWidget *menu;
-       GtkWidget *menuitem;
-       GSList *system_ids, *cur;
-
-       menu = gtk_menu_new();
-
-       menuitem = gtk_menu_item_new_with_label(_("None"));
-       gtk_widget_show(menuitem);
-       gtk_object_set_data(GTK_OBJECT(menuitem), "user_data", "");
-       gtk_menu_append(GTK_MENU(menu), menuitem);
+void destroy_dialog(gpointer data)
+{
+       PrefsAccount *ac_prefs = (PrefsAccount *) data;
 
-       system_ids = privacy_get_system_ids();
-       for (cur = system_ids; cur != NULL; cur = g_slist_next(cur)) {
-               gchar *id = (gchar *) cur->data;
-               const gchar *name;
-               
-               name = privacy_system_get_name(id);
-               menuitem = gtk_menu_item_new_with_label(name);
-               gtk_widget_show(menuitem);
-               gtk_object_set_data_full(GTK_OBJECT(menuitem), "user_data", id, g_free);
-               gtk_menu_append(GTK_MENU(menu), menuitem);
-       }
+       if (!cancelled)
+               *ac_prefs = tmp_ac_prefs;
 
-       gtk_option_menu_set_menu(GTK_OPTION_MENU(privacy.default_privacy_system), menu);
+       gtk_main_quit();
 }
 
 PrefsAccount *prefs_account_open(PrefsAccount *ac_prefs)
 {
-       gboolean new_account = FALSE;
+       gchar *title;
 
        if (prefs_rc_is_readonly(ACCOUNT_RC))
                return ac_prefs;
@@ -689,76 +883,31 @@ PrefsAccount *prefs_account_open(PrefsAccount *ac_prefs)
 
        inc_lock();
 
-       cancelled = FALSE;
+       cancelled = TRUE;
 
        if (!ac_prefs) {
                ac_prefs = prefs_account_new();
                new_account = TRUE;
-       }
-
-       if (!dialog.window) {
-               prefs_account_create();
-       }
-
-       manage_window_set_transient(GTK_WINDOW(dialog.window));
-       gtk_notebook_set_page(GTK_NOTEBOOK(dialog.notebook), 0);
-       gtk_widget_grab_focus(dialog.ok_btn);
-
-       tmp_ac_prefs = *ac_prefs;
-
-       update_privacy_system_menu();
+       } else
+               new_account = FALSE;
 
-       if (new_account) {
-               PrefsAccount *def_ac;
-               gchar *buf;
-
-               prefs_set_dialog_to_default(param);
-               buf = g_strdup_printf(_("Account%d"), ac_prefs->account_id);
-               gtk_entry_set_text(GTK_ENTRY(basic.acname_entry), buf);
-               g_free(buf);
-               def_ac = account_get_default();
-               if (def_ac) {
-                       gtk_entry_set_text(GTK_ENTRY(basic.name_entry),
-                                          def_ac->name ? def_ac->name : "");
-                       gtk_entry_set_text(GTK_ENTRY(basic.addr_entry),
-                                          def_ac->address ? def_ac->address : "");
-                       gtk_entry_set_text(GTK_ENTRY(basic.org_entry),
-                                          def_ac->organization ? def_ac->organization : "");
-               }
-               menu_set_sensitive_all
-                       (GTK_MENU_SHELL
-                               (gtk_option_menu_get_menu
-                                       (GTK_OPTION_MENU
-                                               (basic.protocol_optmenu))),
-                        TRUE);
-               gtk_window_set_title(GTK_WINDOW(dialog.window),
-                                    _("Preferences for new account"));
-               gtk_widget_hide(dialog.apply_btn);
-       } else {
-               gchar *title;
-               prefs_set_dialog(param);
+       if (new_account)
+               title = g_strdup (_("Preferences for new account"));
+       else
                title = g_strdup_printf (_("%s - Account preferences"),
                                ac_prefs->account_name);
-               gtk_window_set_title(GTK_WINDOW(dialog.window), title);
-               g_free (title);
-               gtk_widget_show(dialog.apply_btn);
-       }
 
-       pop_bfr_smtp_tm_set_sens (NULL, NULL);
-       
-       gtk_widget_show(dialog.window);
+       prefswindow_open_full(title, prefs_pages, ac_prefs, destroy_dialog);
+       g_free(title);
        gtk_main();
-       gtk_widget_hide(dialog.window);
 
        inc_unlock();
 
        if (cancelled && new_account) {
-               g_free(ac_prefs);
+               prefs_account_free(ac_prefs);
                return NULL;
-       } else {
-               *ac_prefs = tmp_ac_prefs;
+       } else
                return ac_prefs;
-       }
 }
 
 static void prefs_account_create(void)
@@ -767,37 +916,33 @@ static void prefs_account_create(void)
 
        debug_print("Creating account preferences window...\n");
 
-       /* create dialog */
-       prefs_dialog_create(&dialog);
-       gtk_signal_connect(GTK_OBJECT(dialog.window), "delete_event",
-                          GTK_SIGNAL_FUNC(prefs_account_deleted), NULL);
-       gtk_signal_connect(GTK_OBJECT(dialog.window), "key_press_event",
-                          GTK_SIGNAL_FUNC(prefs_account_key_pressed), NULL);
-       MANAGE_WINDOW_SIGNALS_CONNECT(dialog.window);
-
-       gtk_signal_connect(GTK_OBJECT(dialog.ok_btn), "clicked",
-                          GTK_SIGNAL_FUNC(prefs_account_ok), NULL);
-       gtk_signal_connect(GTK_OBJECT(dialog.apply_btn), "clicked",
-                          GTK_SIGNAL_FUNC(prefs_account_apply), NULL);
-       gtk_signal_connect(GTK_OBJECT(dialog.cancel_btn), "clicked",
-                          GTK_SIGNAL_FUNC(prefs_account_cancel), NULL);
+       notebook = gtk_notebook_new ();
+       gtk_widget_show(notebook);
+       gtk_container_set_border_width (GTK_CONTAINER (notebook), 2);
+       /* GTK_WIDGET_UNSET_FLAGS (notebook, GTK_CAN_FOCUS); */
+       gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
+       
+       gtk_notebook_popup_enable (GTK_NOTEBOOK (notebook));
+
+       gtk_widget_ref(notebook);
 
+       /* create all widgets on notebook */
        prefs_account_basic_create();
-       SET_NOTEBOOK_LABEL(dialog.notebook, _("Basic"), page++);
+       SET_NOTEBOOK_LABEL(notebook, _("Basic"), page++);
        prefs_account_receive_create();
-       SET_NOTEBOOK_LABEL(dialog.notebook, _("Receive"), page++);
+       SET_NOTEBOOK_LABEL(notebook, _("Receive"), page++);
        prefs_account_send_create();
-       SET_NOTEBOOK_LABEL(dialog.notebook, _("Send"), page++);
+       SET_NOTEBOOK_LABEL(notebook, _("Send"), page++);
        prefs_account_compose_create();
-       SET_NOTEBOOK_LABEL(dialog.notebook, _("Compose"), page++);
+       SET_NOTEBOOK_LABEL(notebook, _("Compose"), page++);
        prefs_account_privacy_create();
-       SET_NOTEBOOK_LABEL(dialog.notebook, _("Privacy"), page++);
+       SET_NOTEBOOK_LABEL(notebook, _("Privacy"), page++);
 #if USE_OPENSSL
        prefs_account_ssl_create();
-       SET_NOTEBOOK_LABEL(dialog.notebook, _("SSL"), page++);
+       SET_NOTEBOOK_LABEL(notebook, _("SSL"), page++);
 #endif /* USE_OPENSSL */
        prefs_account_advanced_create();
-       SET_NOTEBOOK_LABEL(dialog.notebook, _("Advanced"), page++);
+       SET_NOTEBOOK_LABEL(notebook, _("Advanced"), page++);
 
        prefs_account_fix_size();
 }
@@ -869,7 +1014,7 @@ static void prefs_account_basic_create(void)
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
-       gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
+       gtk_container_add (GTK_CONTAINER (notebook), vbox1);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
 
        hbox = gtk_hbox_new (FALSE, 8);
@@ -1158,7 +1303,7 @@ static void prefs_account_receive_create(void)
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
-       gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
+       gtk_container_add (GTK_CONTAINER (notebook), vbox1);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
 
        PACK_FRAME (vbox1, frame1, _("POP3"));
@@ -1375,7 +1520,7 @@ static void prefs_account_send_create(void)
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
-       gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
+       gtk_container_add (GTK_CONTAINER (notebook), vbox1);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
 
        PACK_FRAME (vbox1, frame, _("Header"));
@@ -1565,7 +1710,7 @@ static void prefs_account_compose_create(void)
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
-       gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
+       gtk_container_add (GTK_CONTAINER (notebook), vbox1);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
 
        PACK_FRAME(vbox1, frame_sig, _("Signature"));
@@ -1695,7 +1840,7 @@ static void prefs_account_privacy_create(void)
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
-       gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
+       gtk_container_add (GTK_CONTAINER (notebook), vbox1);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
 
        vbox2 = gtk_vbox_new (FALSE, 0);
@@ -1789,7 +1934,7 @@ static void prefs_account_ssl_create(void)
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
-       gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
+       gtk_container_add (GTK_CONTAINER (notebook), vbox1);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
 
        PACK_FRAME (vbox1, pop_frame, _("POP3"));
@@ -1993,7 +2138,7 @@ static void prefs_account_advanced_create(void)
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
-       gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
+       gtk_container_add (GTK_CONTAINER (notebook), vbox1);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
 
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW_2);
@@ -2909,3 +3054,13 @@ static void prefs_account_mailcmd_toggled(GtkToggleButton *button,
        gtk_widget_set_sensitive(basic.uid_entry,  !use_mailcmd);
        gtk_widget_set_sensitive(basic.pass_entry, !use_mailcmd);
 }
+
+void prefs_account_register_page(PrefsPage *page)
+{
+       prefs_pages = g_slist_append(prefs_pages, page);
+}
+
+void prefs_acount_unregister_page(PrefsPage *page)
+{
+       prefs_pages = g_slist_remove(prefs_pages, page);
+}
index a00c91f..01130d0 100644 (file)
@@ -17,8 +17,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#ifndef __PREFS_ACCOUNT_H__
-#define __PREFS_ACCOUNT_H__
+#ifndef PREFS_ACCOUNT_H
+#define PREFS_ACCOUNT_H
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
@@ -46,8 +46,7 @@ typedef enum {
 
 #include "smtp.h"
 #include "folder.h"
-
-
+#include "gtk/prefswindow.h"
 
 struct _PrefsAccount
 {
@@ -175,8 +174,12 @@ struct _PrefsAccount
        gint account_id;
 
        Folder *folder;
+
+       GHashTable *privacy_prefs;
 };
 
+void prefs_account_init                        (void);
+
 PrefsAccount *prefs_account_new                (void);
 
 void prefs_account_read_config         (PrefsAccount   *ac_prefs,
@@ -187,4 +190,10 @@ void prefs_account_free                    (PrefsAccount   *ac_prefs);
 
 PrefsAccount *prefs_account_open       (PrefsAccount   *ac_prefs);
 
-#endif /* __PREFS_ACCOUNT_H__ */
+const gchar *prefs_account_get_privacy_prefs(PrefsAccount *account, gchar *id);
+void prefs_account_set_privacy_prefs(PrefsAccount *account, gchar *id, gchar *new_value);
+
+void prefs_account_register_page       (PrefsPage      *page);
+void prefs_acount_unregister_page      (PrefsPage      *page);
+
+#endif /* PREFS_ACCOUNT_H */
index aeeb030..27d0cf2 100644 (file)
@@ -295,7 +295,7 @@ gboolean privacy_system_can_encrypt(const gchar *id)
        return system->can_encrypt;
 }
 
-gboolean privacy_sign(const gchar *id, MimeInfo *target)
+gboolean privacy_sign(const gchar *id, MimeInfo *target, PrefsAccount *account)
 {
        PrivacySystem *system;
 
@@ -310,7 +310,7 @@ gboolean privacy_sign(const gchar *id, MimeInfo *target)
        if (system->sign == NULL)
                return FALSE;
 
-       return system->sign(target);
+       return system->sign(target, account);
 }
 
 gchar *privacy_get_encrypt_data(const gchar *id, GSList *recp_names)
index c322203..90c3c7b 100644 (file)
@@ -34,6 +34,7 @@ typedef enum {
 #include <glib.h>
 
 #include "procmime.h"
+#include "prefs_account.h"
 
 void privacy_register_system                   (PrivacySystem *system);
 void privacy_unregister_system                 (PrivacySystem *system);
@@ -54,13 +55,14 @@ const gchar *privacy_system_get_name                (const gchar *);
 gboolean privacy_system_can_sign               (const gchar *);
 gboolean privacy_system_can_encrypt            (const gchar *);
 
-gboolean privacy_sign                          (const gchar *system,
-                                                MimeInfo    *mimeinfo);
-gchar *privacy_get_encrypt_data                        (const gchar *system,
-                                                GSList      *recp_names);
-gboolean privacy_encrypt                       (const gchar *system,
-                                                MimeInfo    *mimeinfo,
-                                                const gchar *encdata);
+gboolean privacy_sign                          (const gchar  *system,
+                                                MimeInfo     *mimeinfo,
+                                                PrefsAccount *account);
+gchar *privacy_get_encrypt_data                        (const gchar  *system,
+                                                GSList       *recp_names);
+gboolean privacy_encrypt                       (const gchar  *system,
+                                                MimeInfo     *mimeinfo,
+                                                const gchar  *encdata);
 
 struct _PrivacySystem {
        /** Identifier for the PrivacySystem that can use in config files */
@@ -80,7 +82,8 @@ struct _PrivacySystem {
        MimeInfo        *(*decrypt)             (MimeInfo *mimeinfo);
 
        gboolean           can_sign;
-       gboolean         (*sign)                (MimeInfo *mimeinfo);
+       gboolean         (*sign)                (MimeInfo *mimeinfo,
+                                                PrefsAccount *account);
 
        gboolean           can_encrypt;
        gchar           *(*get_encrypt_data)    (GSList *recp_names);